Skip to content

Commit

Permalink
Updated dependancies, added ngAnnotate, cleaned up code
Browse files Browse the repository at this point in the history
  • Loading branch information
Zohar committed Jun 28, 2015
1 parent 07823d5 commit 42427f8
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 15 deletions.
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@ Thanks for wanting to contribute. Please follow the instructions below.
1. Clone the repository
2. Run `bower install` in the repository directory
3. Run `npm install` in the repository directory
4. Run `grunt serve` to start servering the demo on `http://localhost:9001/demo/`
4. Run `grunt serve` to start serving the demo on `http://localhost:9001/demo/`



## Before creating a pull request
1. Make sure you add tests to `/test/angular-validator-spec.js` that test your changes. To run tests `grunt test`
2. If approriate update the readme to reflect your changes.
2. If appropriate update the README to reflect your changes.
3. Run `grunt build` to minify and create a `dist` version of your changes
4. If approriate update the demo in /demo/
4. If appropriate update the demo in /demo/
5. The project maintainer will update the Plunker demo that is linked in README.md if needed.
17 changes: 15 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*jslint node: true */
'use strict';

var pkg = require('./package.json');

module.exports = function(grunt) {

// Grunt Config
Expand All @@ -21,6 +26,12 @@ module.exports = function(grunt) {
"dest": "dist/angular-validator.js"
}
},
ngAnnotate: {
main: {
src: 'dist/angular-validator.js',
dest: 'dist/angular-validator.js'
},
},
uglify: {
dist: {
src: "dist/angular-validator.js",
Expand Down Expand Up @@ -66,6 +77,8 @@ module.exports = function(grunt) {

grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-ng-annotate');


// Load the plugin that provides the "jshint" task.
grunt.loadNpmTasks('grunt-contrib-jshint');
Expand All @@ -81,8 +94,8 @@ module.exports = function(grunt) {

// Register Task
grunt.registerTask('serve', ['connect', 'watch']);
grunt.registerTask('build', ['concat', 'uglify', 'karma:build',]);
grunt.registerTask('test', ['karma:build',]);
grunt.registerTask('build', ['concat', 'ngAnnotate', 'uglify', 'karma:build']);
grunt.registerTask('test', ['karma:build', ]);
grunt.registerTask('test-debug', ['karma:debug']);
grunt.registerTask('travis', ['karma:travis']);
};
5 changes: 3 additions & 2 deletions bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tg-angular-validator",
"version": "1.2.5",
"version": "1.2.6",
"authors": [
"Zohar Jackson <[email protected]>"
],
Expand Down Expand Up @@ -32,7 +32,8 @@
"dependencies": {
"angular": ">=1.3.0",
"bootstrap": ">=3.2.0",
"font-awesome": ">=4.0.3"
"font-awesome": ">=4.0.3",
"angular-mocks": "~1.4.1"
},
"homepage": "https://github.com/turinggroup/angular-validator"
}
4 changes: 2 additions & 2 deletions dist/angular-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ angular.module('angularValidator').directive('angularValidator',


// Only add validation messages if the form field is $dirty or the form has been submitted
if (scopeElementModel.$dirty || scope[element.form.name].submitted) {
if (scopeElementModel.$dirty || (scope[element.form.name] && scope[element.form.name].submitted)) {

if (scopeElementModel.$error.required) {
// If there is a custom required message display it
Expand Down Expand Up @@ -232,7 +232,7 @@ angular.module('angularValidator').directive('angularValidator',


// Only add/remove validation classes if the field is $dirty or the form has been submitted
if (formField.$dirty || scope[element.form.name].submitted) {
if (formField.$dirty || (scope[element.form.name] && scope[element.form.name].submitted)) {
if (formField.$invalid) {
angular.element(element.parentNode).addClass('has-error');

Expand Down
2 changes: 1 addition & 1 deletion dist/angular-validator.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ module.exports = function(config) {

// list of files / patterns to load in the browser
files: [
'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.6/angular.js',
'https://ajax.googleapis.com/ajax/libs/angularjs/1.3.0-beta.6/angular-mocks.js',
'bower_components/angular/angular.js',
'bower_components/angular-mocks/angular-mocks.js',
'dist/angular-validator.min.js',
'test/*.js'
],
Expand Down
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
"karma-jasmine": "~0.1.5",
"karma-chrome-launcher": "~0.1.2",
"karma-phantomjs-launcher": "~0.1.2",
"karma-firefox-launcher": "~0.1.3"
"karma-firefox-launcher": "~0.1.3",
"ng-annotate": "0.15.4",
"grunt-ng-annotate": "~0.10.0"
}
}
4 changes: 2 additions & 2 deletions src/angular-validator.js
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ angular.module('angularValidator').directive('angularValidator',


// Only add validation messages if the form field is $dirty or the form has been submitted
if (scopeElementModel.$dirty || scope[element.form.name].submitted) {
if (scopeElementModel.$dirty || (scope[element.form.name] && scope[element.form.name].submitted)) {

if (scopeElementModel.$error.required) {
// If there is a custom required message display it
Expand Down Expand Up @@ -232,7 +232,7 @@ angular.module('angularValidator').directive('angularValidator',


// Only add/remove validation classes if the field is $dirty or the form has been submitted
if (formField.$dirty || scope[element.form.name].submitted) {
if (formField.$dirty || (scope[element.form.name] && scope[element.form.name].submitted)) {
if (formField.$invalid) {
angular.element(element.parentNode).addClass('has-error');

Expand Down

0 comments on commit 42427f8

Please sign in to comment.