diff --git a/src/showErrors.coffee b/src/showErrors.coffee index 4d66b4d..923b7a4 100644 --- a/src/showErrors.coffee +++ b/src/showErrors.coffee @@ -21,11 +21,11 @@ showErrorsModule.directive 'showErrors', showSuccess = getShowSuccess options trigger = getTrigger options - inputEl = el[0].querySelector '.form-control[name]' + inputEl = el[0].querySelector 'input[name],select[name],password[name],email[name],datetime[name],datetime-local[name],date[name],month[name],time[name],week[name],number[name],url[name],search[name],tel[name],color[name],textarea[name]' inputNgEl = angular.element inputEl inputName = $interpolate(inputNgEl.attr('name') || '')(scope) unless inputName - throw "show-errors element has no child input elements with a 'name' attribute and a 'form-control' class" + throw "show-errors element has no child input element with a 'name' attribute" inputNgEl.bind trigger, -> blurred = true diff --git a/src/showErrors.js b/src/showErrors.js index 934f59b..d074eca 100644 --- a/src/showErrors.js +++ b/src/showErrors.js @@ -28,11 +28,11 @@ options = scope.$eval(attrs.showErrors); showSuccess = getShowSuccess(options); trigger = getTrigger(options); - inputEl = el[0].querySelector('.form-control[name]'); + inputEl = el[0].querySelector('input[name],select[name],password[name],email[name],datetime[name],datetime-local[name],date[name],month[name],time[name],week[name],number[name],url[name],search[name],tel[name],color[name],textarea[name]'); inputNgEl = angular.element(inputEl); inputName = $interpolate(inputNgEl.attr('name') || '')(scope); if (!inputName) { - throw "show-errors element has no child input elements with a 'name' attribute and a 'form-control' class"; + throw "show-errors element has no child input element with a 'name' attribute"; } inputNgEl.bind(trigger, function() { blurred = true; diff --git a/src/showErrors.min.js b/src/showErrors.min.js index 72c5343..3e53a7e 100644 --- a/src/showErrors.min.js +++ b/src/showErrors.min.js @@ -1,2 +1,2 @@ -/*! angular-bootstrap-show-errors (version 2.3.0) 2015-01-19 */ -(function(){var a;a=angular.module("ui.bootstrap.showErrors",[]),a.directive("showErrors",["$timeout","showErrorsConfig","$interpolate",function(a,b,c){var d,e,f;return e=function(a){var c;return c=b.trigger,a&&null!=a.trigger&&(c=a.trigger),c},d=function(a){var c;return c=b.showSuccess,a&&null!=a.showSuccess&&(c=a.showSuccess),c},f=function(b,f,g,h){var i,j,k,l,m,n,o,p;if(i=!1,m=b.$eval(g.showErrors),n=d(m),p=e(m),j=f[0].querySelector(".form-control[name]"),l=angular.element(j),k=c(l.attr("name")||"")(b),!k)throw"show-errors element has no child input elements with a 'name' attribute and a 'form-control' class";return l.bind(p,function(){return i=!0,o(h[k].$invalid)}),b.$watch(function(){return h[k]&&h[k].$invalid},function(a){return i?o(a):void 0}),b.$on("show-errors-check-validity",function(){return o(h[k].$invalid)}),b.$on("show-errors-reset",function(){return a(function(){return f.removeClass("has-error"),f.removeClass("has-success"),i=!1},0,!1)}),o=function(a){return f.toggleClass("has-error",a),n?f.toggleClass("has-success",!a):void 0}},{restrict:"A",require:"^form",compile:function(a,b){if(-1===b.showErrors.indexOf("skipFormGroupCheck")&&!a.hasClass("form-group")&&!a.hasClass("input-group"))throw"show-errors element does not have the 'form-group' or 'input-group' class";return f}}}]),a.provider("showErrorsConfig",function(){var a,b;a=!1,b="blur",this.showSuccess=function(b){return a=b},this.trigger=function(a){return b=a},this.$get=function(){return{showSuccess:a,trigger:b}}})}).call(this); \ No newline at end of file +/*! angular-bootstrap-show-errors (version 2.3.0) 2015-02-18 */ +(function(){var a;a=angular.module("ui.bootstrap.showErrors",[]),a.directive("showErrors",["$timeout","showErrorsConfig","$interpolate",function(a,b,c){var d,e,f;return e=function(a){var c;return c=b.trigger,a&&null!=a.trigger&&(c=a.trigger),c},d=function(a){var c;return c=b.showSuccess,a&&null!=a.showSuccess&&(c=a.showSuccess),c},f=function(b,f,g,h){var i,j,k,l,m,n,o,p;if(i=!1,m=b.$eval(g.showErrors),n=d(m),p=e(m),j=f[0].querySelector("input[name],select[name],password[name],email[name],datetime[name],datetime-local[name],date[name],month[name],time[name],week[name],number[name],url[name],search[name],tel[name],color[name],textarea[name]"),l=angular.element(j),k=c(l.attr("name")||"")(b),!k)throw"show-errors element has no child input element with a 'name' attribute";return l.bind(p,function(){return i=!0,o(h[k].$invalid)}),b.$watch(function(){return h[k]&&h[k].$invalid},function(a){return i?o(a):void 0}),b.$on("show-errors-check-validity",function(){return o(h[k].$invalid)}),b.$on("show-errors-reset",function(){return a(function(){return f.removeClass("has-error"),f.removeClass("has-success"),i=!1},0,!1)}),o=function(a){return f.toggleClass("has-error",a),n?f.toggleClass("has-success",!a):void 0}},{restrict:"A",require:"^form",compile:function(a,b){if(-1===b.showErrors.indexOf("skipFormGroupCheck")&&!a.hasClass("form-group")&&!a.hasClass("input-group"))throw"show-errors element does not have the 'form-group' or 'input-group' class";return f}}}]),a.provider("showErrorsConfig",function(){var a,b;a=!1,b="blur",this.showSuccess=function(b){return a=b},this.trigger=function(a){return b=a},this.$get=function(){return{showSuccess:a,trigger:b}}})}).call(this); \ No newline at end of file diff --git a/test/showErrors.spec.coffee b/test/showErrors.spec.coffee index 5ead727..95f6684 100644 --- a/test/showErrors.spec.coffee +++ b/test/showErrors.spec.coffee @@ -27,11 +27,11 @@ describe 'showErrors', -> $scope.$digest() el - describe 'directive does not contain an input element with a form-control class and name attribute', -> + describe 'directive does not contain an input element with a "name" attribute', -> it 'throws an exception', -> expect( -> - $compile('
')($scope) - ).toThrow "show-errors element has no child input elements with a 'name' attribute and a 'form-control' class" + $compile('')($scope) + ).toThrow "show-errors element has no child input element with a 'name' attribute" it "throws an exception if the element doesn't have the form-group or input-group class", -> expect( -> diff --git a/test/showErrors.spec.js b/test/showErrors.spec.js index 4186e2d..5f92e41 100644 --- a/test/showErrors.spec.js +++ b/test/showErrors.spec.js @@ -28,11 +28,11 @@ $scope.$digest(); return el; }; - describe('directive does not contain an input element with a form-control class and name attribute', function() { + describe('directive does not contain an input element with a "name" attribute', function() { return it('throws an exception', function() { return expect(function() { - return $compile('')($scope); - }).toThrow("show-errors element has no child input elements with a 'name' attribute and a 'form-control' class"); + return $compile('')($scope); + }).toThrow("show-errors element has no child input element with a 'name' attribute"); }); }); it("throws an exception if the element doesn't have the form-group or input-group class", function() {