diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 266a13f..0ebddef 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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. \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 9f4cbc4..ddabbd4 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,3 +1,8 @@ +/*jslint node: true */ +'use strict'; + +var pkg = require('./package.json'); + module.exports = function(grunt) { // Grunt Config @@ -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", @@ -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'); @@ -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']); }; \ No newline at end of file diff --git a/bower.json b/bower.json index 35cf191..3590461 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "tg-angular-validator", - "version": "1.2.5", + "version": "1.2.6", "authors": [ "Zohar Jackson " ], @@ -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" } diff --git a/dist/angular-validator.js b/dist/angular-validator.js index a4e8b63..a5ab597 100644 --- a/dist/angular-validator.js +++ b/dist/angular-validator.js @@ -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 @@ -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'); diff --git a/dist/angular-validator.min.js b/dist/angular-validator.min.js index 18904f2..ef95326 100644 --- a/dist/angular-validator.min.js +++ b/dist/angular-validator.min.js @@ -1 +1 @@ -angular.module("angularValidator",[]),angular.module("angularValidator").directive("angularValidator",function(){return{restrict:"A",link:function(a,b,c,d){function e(a){for(var b=0;b Required"},d=function(){return" Invalid"};if(b.name in p){var e=p[b.name],f=l(b);f&&f.remove(),(e.$dirty||a[b.form.name].submitted)&&(e.$error.required?"required-message"in b.attributes?angular.element(b).after(k(b.attributes["required-message"].value)):angular.element(b).after(k(c)):e.$valid||("invalid-message"in b.attributes?angular.element(b).after(k(b.attributes["invalid-message"].value)):angular.element(b).after(k(d))))}}function k(b){return""}function l(a){for(var b=angular.element(a).parent().children(),c=0;c Required"},d=function(){return" Invalid"};if(b.name in n){var e=n[b.name],f=j(b);f&&f.remove(),(e.$dirty||a[b.form.name]&&a[b.form.name].submitted)&&(e.$error.required?angular.element(b).after("required-message"in b.attributes?i(b.attributes["required-message"].value):i(c)):e.$valid||angular.element(b).after("invalid-message"in b.attributes?i(b.attributes["invalid-message"].value):i(d)))}}function i(b){return""}function j(a){for(var b=angular.element(a).parent().children(),c=0;c