diff --git a/dist/angular-validation.js b/dist/angular-validation.js index 34f394e..04d5248 100644 --- a/dist/angular-validation.js +++ b/dist/angular-validation.js @@ -399,7 +399,8 @@ angular.module('validation.directive', ['validation.provider']); * @returns {} */ var validFunc = function(element, validMessage, validation, scope, ctrl, attrs) { - var messageToShow = validMessage || $validationProvider.getDefaultMsg(validation).success; + var successMessage = validation + 'SuccessMessage'; + var messageToShow = (attrs[successMessage] !== null && attrs[successMessage] !== undefined) ? (validMessage || $validationProvider.getDefaultMsg(validation).success) : ""; var validCallback = $parse(attrs.validCallback); var messageId = attrs.messageId; var validationGroup = attrs.validationGroup; diff --git a/dist/angular-validation.min.js b/dist/angular-validation.min.js index 4d75ee0..f4e75e8 100644 --- a/dist/angular-validation.min.js +++ b/dist/angular-validation.min.js @@ -1 +1 @@ -angular.module("validation",["validation.provider","validation.directive"]),angular.module("validation.provider",[]),angular.module("validation.directive",["validation.provider"]),function(){function a(){var a,b,c,d,e,f=this,g=function(f){a=f,b=a.get("$rootScope"),c=a.get("$http"),d=a.get("$q"),e=a.get("$timeout")},h={},i=null,j={};this.setExpression=function(a){return angular.extend(h,a),f},this.getExpression=function(a){return h[a]},this.setDefaultMsg=function(a){return angular.extend(j,a),f},this.getDefaultMsg=function(a){return j[a]},this.setValidMethod=function(a){i=a},this.getValidMethod=function(){return i},this.setErrorHTML=function(a){if(a.constructor===Function)return f.getErrorHTML=a,f},this.getErrorHTML=function(a){return'
'+a+"
"},this.setSuccessHTML=function(a){if(a.constructor===Function)return f.getSuccessHTML=a,f},this.getSuccessHTML=function(a){return''+a+"
"},this.showSuccessMessage=!0,this.showErrorMessage=!0,this.checkValid=function(a){return!(!a||!a.$valid)},this.validate=function(a){var c=d.defer(),g=0;if(void 0===a)return console.error("This is not a regular Form name scope"),c.reject("This is not a regular Form name scope"),c.promise;if(a.validationId)b.$broadcast(a.$name+"submit-"+a.validationId,g++);else if(a.constructor===Array)for(var h in a)b.$broadcast(a[h].$name+"submit-"+a[h].validationId,g++);else for(var i in a)"$"!==i[0]&&a[i].hasOwnProperty("$dirty")&&b.$broadcast(i+"submit-"+a[i].validationId,g++);return c.promise.success=function(a){return c.promise.then(function(b){a(b)}),c.promise},c.promise.error=function(a){return c.promise.then(null,function(b){a(b)}),c.promise},e(function(){f.checkValid(a)?c.resolve("success"):c.reject("error")}),c.promise},this.validCallback=null,this.invalidCallback=null,this.resetCallback=null,this.reset=function(a){if(void 0===a)return void console.error("This is not a regular Form name scope");if(a.validationId)b.$broadcast(a.$name+"reset-"+a.validationId);else if(a.constructor===Array)for(var c in a)b.$broadcast(a[c].$name+"reset-"+a[c].validationId);else for(var d in a)"$"!==d[0]&&a[d].hasOwnProperty("$dirty")&&b.$broadcast(d+"reset-"+a[d].validationId)},this.addMsgElement=function(a){return a.after("")},this.getMsgElement=function(a){return a.next()},this.$get=["$injector",function(a){return g(a),{setValidMethod:this.setValidMethod,getValidMethod:this.getValidMethod,setErrorHTML:this.setErrorHTML,getErrorHTML:this.getErrorHTML,setSuccessHTML:this.setSuccessHTML,getSuccessHTML:this.getSuccessHTML,setExpression:this.setExpression,getExpression:this.getExpression,setDefaultMsg:this.setDefaultMsg,getDefaultMsg:this.getDefaultMsg,showSuccessMessage:this.showSuccessMessage,showErrorMessage:this.showErrorMessage,checkValid:this.checkValid,validate:this.validate,validCallback:this.validCallback,invalidCallback:this.invalidCallback,resetCallback:this.resetCallback,reset:this.reset,addMsgElement:this.addMsgElement,getMsgElement:this.getMsgElement}}]}angular.module("validation.provider").provider("$validation",a)}.call(this),function(){function a(a){var b=a.get("$validation"),c=a.get("$timeout"),d=a.get("$parse");return{link:function(a,e,f){var g=d(f.validationReset)(a);c(function(){e.on("click",function(a){a.preventDefault(),b.reset(g)})})}}}angular.module("validation.directive").directive("validationReset",a),a.$inject=["$injector"]}.call(this),function(){function a(a){var b=a.get("$validation"),c=a.get("$timeout"),d=a.get("$parse");return{priority:1,require:"?ngClick",link:function(a,e,f){var g=d(f.validationSubmit)(a);c(function(){e.off("click"),e.on("click",function(c){c.preventDefault(),b.validate(g).success(function(){d(f.ngClick)(a)})})})}}}angular.module("validation.directive").directive("validationSubmit",a),a.$inject=["$injector"]}.call(this),function(){function a(a){function b(a,b,c){for(var d=document.querySelectorAll("*[validation-group="+b+"]"),e=0,f=d.length;e'+n+"<\/p>"};this.setSuccessHTML=function(n){if(n.constructor===Function)return t.getSuccessHTML=n,t};this.getSuccessHTML=function(n){return'
'+n+"<\/p>"};this.showSuccessMessage=!0;this.showErrorMessage=!0;this.checkValid=function(n){return!!(n&&n.$valid)};this.validate=function(i){var f=r.defer(),o=0,s,e;if(i===undefined)return console.error("This is not a regular Form name scope"),f.reject("This is not a regular Form name scope"),f.promise;if(i.validationId)n.$broadcast(i.$name+"submit-"+i.validationId,o++);else if(i.constructor===Array)for(s in i)n.$broadcast(i[s].$name+"submit-"+i[s].validationId,o++);else for(e in i)e[0]!=="$"&&i[e].hasOwnProperty("$dirty")&&n.$broadcast(e+"submit-"+i[e].validationId,o++);return f.promise.success=function(n){return f.promise.then(function(t){n(t)}),f.promise},f.promise.error=function(n){return f.promise.then(null,function(t){n(t)}),f.promise},u(function(){t.checkValid(i)?f.resolve("success"):f.reject("error")}),f.promise};this.validCallback=null;this.invalidCallback=null;this.resetCallback=null;this.reset=function(t){var r,i;if(t===undefined){console.error("This is not a regular Form name scope");return}if(t.validationId)n.$broadcast(t.$name+"reset-"+t.validationId);else if(t.constructor===Array)for(r in t)n.$broadcast(t[r].$name+"reset-"+t[r].validationId);else for(i in t)i[0]!=="$"&&t[i].hasOwnProperty("$dirty")&&n.$broadcast(i+"reset-"+t[i].validationId)};this.addMsgElement=function(n){return n.after("<\/span>")};this.getMsgElement=function(n){return n.next()};this.$get=["$injector",function(n){return h(n),{setValidMethod:this.setValidMethod,getValidMethod:this.getValidMethod,setErrorHTML:this.setErrorHTML,getErrorHTML:this.getErrorHTML,setSuccessHTML:this.setSuccessHTML,getSuccessHTML:this.getSuccessHTML,setExpression:this.setExpression,getExpression:this.getExpression,setDefaultMsg:this.setDefaultMsg,getDefaultMsg:this.getDefaultMsg,showSuccessMessage:this.showSuccessMessage,showErrorMessage:this.showErrorMessage,checkValid:this.checkValid,validate:this.validate,validCallback:this.validCallback,invalidCallback:this.invalidCallback,resetCallback:this.resetCallback,reset:this.reset,addMsgElement:this.addMsgElement,getMsgElement:this.getMsgElement}}]}angular.module("validation.provider").provider("$validation",n)}.call(this),function(){function n(n){var t=n.get("$validation"),i=n.get("$timeout"),r=n.get("$parse");return{link:function(n,u,f){var e=r(f.validationReset)(n);i(function(){u.on("click",function(n){n.preventDefault();t.reset(e)})})}}}angular.module("validation.directive").directive("validationReset",n);n.$inject=["$injector"]}.call(this),function(){function n(n){var i=n.get("$validation"),r=n.get("$timeout"),t=n.get("$parse");return{priority:1,require:"?ngClick",link:function(n,u,f){var e=t(f.validationSubmit)(n);r(function(){u.off("click");u.on("click",function(r){r.preventDefault();i.validate(e).success(function(){t(f.ngClick)(n)})})})}}}angular.module("validation.directive").directive("validationSubmit",n);n.$inject=["$injector"]}.call(this),function(){function n(n){function r(n,t,i){for(var u=document.querySelectorAll("*[validation-group="+t+"]"),r=0,o=u.length;r