From 1005bf2a52e2643a58e5ae5d1ec7008d5cb8e5ca Mon Sep 17 00:00:00 2001 From: Nick Date: Sat, 22 Apr 2017 14:23:04 -0500 Subject: [PATCH] Mangle minified code --- dist/braintree-validation.min.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/braintree-validation.min.js b/dist/braintree-validation.min.js index 35f6f7e..de05d14 100644 --- a/dist/braintree-validation.min.js +++ b/dist/braintree-validation.min.js @@ -6,4 +6,4 @@ * Copyright (c) 2017 Nick Bagnall * Released under the MIT license */ - (function(root,factory){if(typeof define==="function"&&define.amd){define(["hosted-fields","jquery.validate"],factory)}else if(typeof module==="object"&&module.exports){module.exports=factory(require("braintree-web/hosted-fields"),require("jquery-validation"))}else{factory(root.braintree.hostedFields,root.jQuery)}})(this,function(hostedFields,$){var hostedFieldsInstanceRef;function getFieldNameFromFrameElement(frameElement){if(hostedFieldsInstanceRef===undefined){console.error("You cannot call getFieldNameFromFrameElement() without first calling validate() on the braintree.hostedFields!");return}for(field in hostedFieldsInstanceRef._fields){if(hostedFieldsInstanceRef._fields[field].frameElement===frameElement){return field}}}hostedFields.getFieldNameFromFrameElement=getFieldNameFromFrameElement;function getFieldFromFrameElement(frameElement){if(hostedFieldsInstanceRef===undefined){console.error("You cannot call getFieldFromFrameElement() without first calling validate() on the braintree.hostedFields!");return}return hostedFieldsInstanceRef._state.fields[getFieldNameFromFrameElement(frameElement)]}hostedFields.getFieldFromFrameElement=getFieldFromFrameElement;hostedFields.rules=function(command,argument){if(hostedFieldsInstanceRef===undefined){console.error("You cannot call rules() without first calling validate() on the braintree.hostedFields!");return}var form=$(hostedFieldsInstanceRef._fields[Object.keys(hostedFieldsInstanceRef._fields)[0]].containerElement).closest("form");if(command){switch(command){case"add":$(form).rules("add",argument);break;case"remove":return $(form).rules("remove",argument)}return}else{return $(form).rules()}};hostedFields.valid=function(){if(hostedFieldsInstanceRef===undefined){console.error("You cannot call valid() without first calling validate() on the braintree.hostedFields!");return}var form=$(hostedFieldsInstanceRef._fields[Object.keys(hostedFieldsInstanceRef._fields)[0]].containerElement).closest("form");return $(form).valid()};hostedFields.validate=function(hostedFieldsInstance,options){if(typeof $==="undefined"){console.error("No jQuery object is defined!");return}if(typeof $.validator==="undefined"){console.error("jQuery Validation plugin not found!");return}if(!hostedFieldsInstance._fields){console.error("hostedFieldsInstance._fields has no value!");return}hostedFieldsInstanceRef=hostedFieldsInstance;var form=$(hostedFieldsInstance._fields[Object.keys(hostedFieldsInstance._fields)[0]].containerElement).closest("form"),rules=options&&options.rules||{},messages=options&&options.messages||{},eventMap={focus:function(){return new FocusEvent("focus",{bubbles:true,cancelable:true})},blur:function(){return new FocusEvent("blur",{bubbles:true,cancelable:true})},inputSubmitRequest:function(){return new Event("submit",{bubbles:true,cancelable:true})},empty:function(){return new Event("keyup",{bubbles:true,cancelable:true,key:"Q"})},notEmpty:function(){return new Event("keyup",{bubbles:true,cancelable:true,key:"Q"})},cardTypeChange:function(){return new Event("keyup",{bubbles:true,cancelable:true,key:"Q"})},validityChange:function(){return new Event("keyup",{bubbles:true,cancelable:true,key:"Q"})}},fieldDescriptionMap={number:"card number",cvv:"CVV",expirationMonth:"expiration month",expirationYear:"expiration year",postalCode:"postal code"};for(field in hostedFieldsInstance._fields){var frameElement=$(hostedFieldsInstance._fields[field].frameElement),frameElementName=$(frameElement).attr("name");frameElement.attr("contenteditable",true);$.validator.addMethod(frameElementName+"-isRequired",function(value,frameElement){return!getFieldFromFrameElement(frameElement).isEmpty});$.validator.addMethod(frameElementName+"-isValid",function(value,frameElement){return getFieldFromFrameElement(frameElement).isValid});if(frameElementName in rules){if(options.debug)console.warn("You are overriding braintree-validation's default validation rules for the "+fieldDescriptionMap[field]+". Please refer to the library's GitHub documentation if you have not already done so.")}else{rules[frameElementName]={};rules[frameElementName][frameElementName+"-isRequired"]=true;rules[frameElementName][frameElementName+"-isValid"]=true}if(frameElementName in messages){if(options.debug)console.warn("You are overriding braintree-validation's default error messages for the "+fieldDescriptionMap[field]+". Please refer to the library's GitHub documentation if you have not already done so.")}else{messages[frameElementName]={};messages[frameElementName][frameElementName+"-isRequired"]=fieldDescriptionMap[field].charAt(0).toUpperCase()+fieldDescriptionMap[field].slice(1)+" is required.";messages[frameElementName][frameElementName+"-isValid"]="Please enter a valid "+fieldDescriptionMap[field]+"."}}if(options.onfocusout===false){delete eventMap["blur"]}if(options.onkeyup===false){delete eventMap["empty"];delete eventMap["notEmpty"];delete eventMap["validityChange"];delete eventMap["cardTypeChange"]}for(braintreeEvent in eventMap){(function(scopedBraintreeEvent){hostedFieldsInstance.on(scopedBraintreeEvent,function(event){if(scopedBraintreeEvent==="inputSubmitRequest"){$(event.fields[event.emittedBy].container).closest("form")[0].dispatchEvent(eventMap[scopedBraintreeEvent]())}else{$(event.fields[event.emittedBy].container).children("iframe")[0].dispatchEvent(eventMap[scopedBraintreeEvent]())}})})(braintreeEvent)}options.rules=rules;options.messages=messages;if(!options.errorPlacement){options.errorPlacement=function(error,element){if(getFieldNameFromFrameElement(element[0])!==undefined){error.insertAfter(element.parent())}else{error.insertAfter(element)}}}else if(options.debug){console.warn("You are overriding braintree-validation's default implementation of errorPlacement(). Please refer to the library's GitHub documentation if you have not already done so.")}var validator=form.validate(options);var defaultHighlightFn=validator.settings.highlight,defaultUnhighlightFn=validator.settings.unhighlight,defaultRequiredFn=$.validator.methods.required;if(options.ignore&&typeof options.ignore==="string"&&options.ignore.match(/iframe/gi)){if(options.debug)console.warn("iframe is being expunged from the options.ignore string.");validator.settings.ignore=options.ignore.replace(/iframe/gi,"")}if(!options.highlight){validator.settings.highlight=function(element,errorClass,validClass){var braintreeFieldName=getFieldNameFromFrameElement(element);if(braintreeFieldName!==undefined){hostedFieldsInstance.addClass(braintreeFieldName,errorClass,function(addClassErr){if(options.debug&&addClassErr)console.error(addClassErr)});hostedFieldsInstance.removeClass(braintreeFieldName,validClass,function(removeClassErr){if(options.debug&&removeClassErr)console.error(removeClassErr)})}else{defaultHighlightFn(element,errorClass,validClass)}}}else if(options.debug){console.warn("You are overriding braintree-validation's default implementation of highlight(). Please refer to the library's GitHub documentation if you have not already done so.")}if(!options.unhighlight){validator.settings.unhighlight=function(element,errorClass,validClass){if(getFieldNameFromFrameElement(element)!==undefined){hostedFieldsInstance.removeClass(getFieldNameFromFrameElement(element),errorClass,function(removeClassErr){if(options.debug&&removeClassErr)console.error(removeClassErr)});hostedFieldsInstance.addClass(getFieldNameFromFrameElement(element),validClass,function(addClassErr){if(options.debug&&addClassErr)console.error(addClassErr)})}else{defaultUnhighlightFn(element,errorClass,validClass)}}}else if(options.debug){console.warn("You are overriding braintree-validation's default implementation of unhighlight(). Please refer to the library's GitHub documentation if you have not already done so.")}$.validator.addMethod("required",function(value,element,param){var braintreeField=getFieldFromFrameElement(element);if(braintreeField!==undefined){return!braintreeField.isEmpty}else{return defaultRequiredFn.call(validator,value,element,param)}});var defaultBlankImplementation=$.expr.pseudos.blank;$.expr.pseudos.blank=function(element){var braintreeField=getFieldFromFrameElement(element);if(braintreeField!==undefined){return braintreeField.isEmpty}return defaultBlankImplementation(element)};var defaultFilledImplementation=$.expr.pseudos.filled;$.expr.pseudos.filled=function(element){var braintreeField=getFieldFromFrameElement(element);if(braintreeField!==undefined){return!braintreeField.isEmpty}return defaultFilledImplementation(element)};return validator};return hostedFields}); \ No newline at end of file + (function(e,r){if(typeof define==="function"&&define.amd){define(["hosted-fields","jquery.validate"],r)}else if(typeof module==="object"&&module.exports){module.exports=r(require("braintree-web/hosted-fields"),require("jquery-validation"))}else{r(e.braintree.hostedFields,e.jQuery)}})(this,function(e,r){var i;function t(e){if(i===undefined){console.error("You cannot call getFieldNameFromFrameElement() without first calling validate() on the braintree.hostedFields!");return}for(field in i._fields){if(i._fields[field].frameElement===e){return field}}}e.getFieldNameFromFrameElement=t;function n(e){if(i===undefined){console.error("You cannot call getFieldFromFrameElement() without first calling validate() on the braintree.hostedFields!");return}return i._state.fields[t(e)]}e.getFieldFromFrameElement=n;e.rules=function(e,t){if(i===undefined){console.error("You cannot call rules() without first calling validate() on the braintree.hostedFields!");return}var n=r(i._fields[Object.keys(i._fields)[0]].containerElement).closest("form");if(e){switch(e){case"add":r(n).rules("add",t);break;case"remove":return r(n).rules("remove",t)}return}else{return r(n).rules()}};e.valid=function(){if(i===undefined){console.error("You cannot call valid() without first calling validate() on the braintree.hostedFields!");return}var e=r(i._fields[Object.keys(i._fields)[0]].containerElement).closest("form");return r(e).valid()};e.validate=function(e,o){if(typeof r==="undefined"){console.error("No jQuery object is defined!");return}if(typeof r.validator==="undefined"){console.error("jQuery Validation plugin not found!");return}if(!e._fields){console.error("hostedFieldsInstance._fields has no value!");return}i=e;var a=r(e._fields[Object.keys(e._fields)[0]].containerElement).closest("form"),l=o&&o.rules||{},u=o&&o.messages||{},s={focus:function(){return new FocusEvent("focus",{bubbles:true,cancelable:true})},blur:function(){return new FocusEvent("blur",{bubbles:true,cancelable:true})},inputSubmitRequest:function(){return new Event("submit",{bubbles:true,cancelable:true})},empty:function(){return new Event("keyup",{bubbles:true,cancelable:true,key:"Q"})},notEmpty:function(){return new Event("keyup",{bubbles:true,cancelable:true,key:"Q"})},cardTypeChange:function(){return new Event("keyup",{bubbles:true,cancelable:true,key:"Q"})},validityChange:function(){return new Event("keyup",{bubbles:true,cancelable:true,key:"Q"})}},d={number:"card number",cvv:"CVV",expirationMonth:"expiration month",expirationYear:"expiration year",postalCode:"postal code"};for(field in e._fields){var f=r(e._fields[field].frameElement),c=r(f).attr("name");f.attr("contenteditable",true);r.validator.addMethod(c+"-isRequired",function(e,r){return!n(r).isEmpty});r.validator.addMethod(c+"-isValid",function(e,r){return n(r).isValid});if(c in l){if(o.debug)console.warn("You are overriding braintree-validation's default validation rules for the "+d[field]+". Please refer to the library's GitHub documentation if you have not already done so.")}else{l[c]={};l[c][c+"-isRequired"]=true;l[c][c+"-isValid"]=true}if(c in u){if(o.debug)console.warn("You are overriding braintree-validation's default error messages for the "+d[field]+". Please refer to the library's GitHub documentation if you have not already done so.")}else{u[c]={};u[c][c+"-isRequired"]=d[field].charAt(0).toUpperCase()+d[field].slice(1)+" is required.";u[c][c+"-isValid"]="Please enter a valid "+d[field]+"."}}if(o.onfocusout===false){delete s["blur"]}if(o.onkeyup===false){delete s["empty"];delete s["notEmpty"];delete s["validityChange"];delete s["cardTypeChange"]}for(braintreeEvent in s){(function(i){e.on(i,function(e){if(i==="inputSubmitRequest"){r(e.fields[e.emittedBy].container).closest("form")[0].dispatchEvent(s[i]())}else{r(e.fields[e.emittedBy].container).children("iframe")[0].dispatchEvent(s[i]())}})})(braintreeEvent)}o.rules=l;o.messages=u;if(!o.errorPlacement){o.errorPlacement=function(e,r){if(t(r[0])!==undefined){e.insertAfter(r.parent())}else{e.insertAfter(r)}}}else if(o.debug){console.warn("You are overriding braintree-validation's default implementation of errorPlacement(). Please refer to the library's GitHub documentation if you have not already done so.")}var b=a.validate(o);var m=b.settings.highlight,h=b.settings.unhighlight,v=r.validator.methods.required;if(o.ignore&&typeof o.ignore==="string"&&o.ignore.match(/iframe/gi)){if(o.debug)console.warn("iframe is being expunged from the options.ignore string.");b.settings.ignore=o.ignore.replace(/iframe/gi,"")}if(!o.highlight){b.settings.highlight=function(r,i,n){var a=t(r);if(a!==undefined){e.addClass(a,i,function(e){if(o.debug&&e)console.error(e)});e.removeClass(a,n,function(e){if(o.debug&&e)console.error(e)})}else{m(r,i,n)}}}else if(o.debug){console.warn("You are overriding braintree-validation's default implementation of highlight(). Please refer to the library's GitHub documentation if you have not already done so.")}if(!o.unhighlight){b.settings.unhighlight=function(r,i,n){if(t(r)!==undefined){e.removeClass(t(r),i,function(e){if(o.debug&&e)console.error(e)});e.addClass(t(r),n,function(e){if(o.debug&&e)console.error(e)})}else{h(r,i,n)}}}else if(o.debug){console.warn("You are overriding braintree-validation's default implementation of unhighlight(). Please refer to the library's GitHub documentation if you have not already done so.")}r.validator.addMethod("required",function(e,r,i){var t=n(r);if(t!==undefined){return!t.isEmpty}else{return v.call(b,e,r,i)}});var g=r.expr.pseudos.blank;r.expr.pseudos.blank=function(e){var r=n(e);if(r!==undefined){return r.isEmpty}return g(e)};var y=r.expr.pseudos.filled;r.expr.pseudos.filled=function(e){var r=n(e);if(r!==undefined){return!r.isEmpty}return y(e)};return b};return e}); \ No newline at end of file