File: D:/HostingSpaces/SBogers10/topswtw.komma.pro/wwwroot/js/app/checkout/couponCodeValidator.ng.js
define([],function()
{
function couponCodeValidator() {
return {
restrict: 'A',
require: 'ngModel',
link: function(scope, element, attr, ctrl) {
checkForWrongCouponCode = false;
var checkCouponCode = function(value){
if(value){
ctrl.$setValidity('coupon-code', true);
}else{
if(checkForWrongCouponCode)
ctrl.$setValidity('coupon-code', false);
}
if(scope.couponCode == ""){
ctrl.$setValidity('coupon-code', true);
}
};
scope.$watch('activeCouponDiscount', checkCouponCode);
element.blur(function(){
checkForWrongCouponCode = true;
checkCouponCode(scope.activeCouponDiscount);
});
}
}
}
return couponCodeValidator;
});