(function(){angular.module("silverpeas.directives").directive("suggestionboxValidation",["context",function(b){return{restrict:"AE",templateUrl:webContext+"/suggestionBox/jsp/javaScript/angularjs/directives/suggestionbox-validation.jsp",replace:true,link:function a(e,d,c){applyTokenSecurity("#suggestionValidation");function f(h){jQuery("#suggestionValidationMessage").html(h);jQuery("#suggestionValidationComment").val("");jQuery(".validationApproveItem").hide();jQuery(".validationRefuseItem").hide();return jQuery("#suggestionValidation")}function g(k){var i=k?jQuery("#validationApproveLabel").html():jQuery("#validationRefuseLabel").html();var h=true;var l=jQuery("#suggestionValidationComment").val()||"";if(!k&&l.isNotDefined()){notyError(jQuery("#commentMandatoryErrorMessageMsg").html().replace("@name@",i));h=false}var m=jQuery("#suggestionValidationComment").val();var j=(m?(m.split(/\n/).length+m.length):0);if(j>2000){notyError(jQuery("#commentNbMaxCharErrorMessageMsg").html().replace("@name@",i));h=false}return h}e.approve=function(i){var j=jQuery("#suggestionValidationApproveMsg").html().replace("@name@",i.title);var h=f(j);jQuery(".validationApproveItem").show();h.popup("confirmation",{callback:function(){if(g(true)){jQuery("#suggestionValidationForm").attr("action",b.componentUriBase+"suggestions/"+i.id+"/approve").submit();return true}return false}})};e.refuse=function(i){var j=jQuery("#suggestionValidationRefuseMsg").html().replace("@name@",i.title);var h=f(j);jQuery(".validationRefuseItem").show();h.popup("confirmation",{callback:function(){if(g(false)){jQuery("#suggestionValidationForm").attr("action",b.componentUriBase+"suggestions/"+i.id+"/refuse").submit();return true}return false}})}}}}])})();