ng-form-group
Advanced tools
Comparing version 1.4.0 to 1.4.1
22
index.js
@@ -12,3 +12,2 @@ (function() { | ||
function FormGroupController($scope) { | ||
var unref; | ||
this.$scope = $scope; | ||
@@ -19,4 +18,3 @@ this.update = bind(this.update, this); | ||
this.inputs = []; | ||
unref = this.$scope.$watch(this.update); | ||
this.$scope.$on("$destroy", unref); | ||
this.$scope.$watch(this.update); | ||
} | ||
@@ -41,6 +39,6 @@ | ||
FormGroupController.prototype.update = function() { | ||
if (this.canValidate()) { | ||
return this.status = this.inputs.every(function(i) { | ||
if (this.disabled === false && this.canValidate()) { | ||
return this.status = (this.inputs.every(function(i) { | ||
return i.$valid; | ||
}) ? "success" : "error"; | ||
})) ? "success" : "error"; | ||
} else { | ||
@@ -65,5 +63,5 @@ return this.status = null; | ||
link: function(scope, el, attrs, ctrls) { | ||
var ctrl, dereg, ngFormCtrl; | ||
var ctrl, ngFormCtrl; | ||
ctrl = ctrls[0], ngFormCtrl = ctrls[1]; | ||
if (el.hasClass('form-group-without-feedback') || ctrl.inputs.length === 0) { | ||
if (ctrl.inputs.length === 0) { | ||
ctrl.disabled = true; | ||
@@ -75,3 +73,8 @@ return; | ||
} | ||
dereg = scope.$watch((function() { | ||
scope.$watch((function() { | ||
return el.hasClass('form-group-without-feedback'); | ||
}), function(value) { | ||
return ctrl.disabled = value; | ||
}); | ||
return scope.$watch((function() { | ||
return ctrl.status; | ||
@@ -84,3 +87,2 @@ }), function(status) { | ||
}); | ||
return scope.$on('$destroy', dereg); | ||
} | ||
@@ -87,0 +89,0 @@ }; |
(function(){angular.module("ng-form-group",[])}).call(this); | ||
(function(){var t,r=function(t,r){return function(){return t.apply(r,arguments)}};t=function(){function t(t){var n;this.$scope=t,this.update=r(this.update,this),this.status=null,this.disabled=!1,this.inputs=[],n=this.$scope.$watch(this.update),this.$scope.$on("$destroy",n)}return t.prototype.setParentForm=function(t){return this.ngFormCtrl=t},t.prototype.canValidate=function(){var t;return t=this.inputs.every(function(t){return t.$dirty&&!t.$pending}),this.ngFormCtrl?this.ngFormCtrl.$submitted||t:t},t.prototype.update=function(){return this.status=this.canValidate()?this.inputs.every(function(t){return t.$valid})?"success":"error":null},t.prototype.addInput=function(t){return this.inputs.push(t)},t}(),angular.module("ng-form-group").controller("FormGroupController",["$scope",t]).directive("formGroup",function(){return{restrict:"C",require:["formGroup","?^form"],controller:"FormGroupController",link:function(t,r,n,o){var e,i,u;return e=o[0],u=o[1],r.hasClass("form-group-without-feedback")||0===e.inputs.length?(e.disabled=!0,void 0):(u&&e.setParentForm(u),i=t.$watch(function(){return e.status},function(t){return r.removeClass("has-error has-success"),t?r.addClass("has-"+t):void 0}),t.$on("$destroy",i))}}}).directive("formControl",function(){return{restrict:"C",require:["?ngModel","?^formGroup"],link:function(t,r,n,o){var e,i;return i=o[0],e=o[1],e&&!e.disabled?i&&e?e.addInput(i):void 0:void 0}}})}).call(this); | ||
(function(){var t,r=function(t,r){return function(){return t.apply(r,arguments)}};t=function(){function t(t){this.$scope=t,this.update=r(this.update,this),this.status=null,this.disabled=!1,this.inputs=[],this.$scope.$watch(this.update)}return t.prototype.setParentForm=function(t){return this.ngFormCtrl=t},t.prototype.canValidate=function(){var t;return t=this.inputs.every(function(t){return t.$dirty&&!t.$pending}),this.ngFormCtrl?this.ngFormCtrl.$submitted||t:t},t.prototype.update=function(){return this.status=this.disabled===!1&&this.canValidate()?this.inputs.every(function(t){return t.$valid})?"success":"error":null},t.prototype.addInput=function(t){return this.inputs.push(t)},t}(),angular.module("ng-form-group").controller("FormGroupController",["$scope",t]).directive("formGroup",function(){return{restrict:"C",require:["formGroup","?^form"],controller:"FormGroupController",link:function(t,r,n,e){var o,i;return o=e[0],i=e[1],0===o.inputs.length?(o.disabled=!0,void 0):(i&&o.setParentForm(i),t.$watch(function(){return r.hasClass("form-group-without-feedback")},function(t){return o.disabled=t}),t.$watch(function(){return o.status},function(t){return r.removeClass("has-error has-success"),t?r.addClass("has-"+t):void 0}))}}}).directive("formControl",function(){return{restrict:"C",require:["?ngModel","?^formGroup"],link:function(t,r,n,e){var o,i;return i=e[0],o=e[1],o&&!o.disabled?i&&o?o.addInput(i):void 0:void 0}}})}).call(this); | ||
(function(){var r;r=function(r){return Array.prototype.slice.call(r)},angular.module("ng-form-group").directive("hasFeedback",function(){return{restrict:"C",compile:function(e){return r(e[0].querySelectorAll(".form-control")).forEach(function(r){return r.setAttribute("has-feedback-watcher","")})}}}).directive("hasFeedbackWatcher",function(){return{require:"ngModel",link:function(e,n,t,o){var c,i;return c=function(r){var e;return null==r&&(r=!1),e=r?"glyphicon-ok":"glyphicon-remove",'<span class="glyphicon '+e+' form-control-feedback"></span>'},i=e.$watch(function(){return r(n[0].parentElement.querySelectorAll(".form-control-feedback")).forEach(function(r){return r.parentElement.removeChild(r)}),o.$dirty?o.$valid?n.after(c(!0)):o.$invalid?n.after(c(!1)):void 0:void 0}),e.$on("$destroy",i)}}})}).call(this); |
{ | ||
"name": "ng-form-group", | ||
"version": "1.4.0", | ||
"version": "1.4.1", | ||
"description": "Automatic Bootstrap validation based on ngModel", | ||
@@ -5,0 +5,0 @@ "main": "index.min.js", |
Sorry, the diff of this file is not supported yet
274
58057
16