cobuild-angular-stack
Version:
Base stack angular sass jade gulp
1 lines • 17.8 kB
JavaScript
!function(){String.prototype.trim||!function(){var a=/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g;String.prototype.trim=function(){return this.replace(a,"")}}();var JSON=JSON||{};JSON.parse||!function(){JSON.parse=function(obj){"use strict";return eval("("+obj+")")}}(),JSON.stringify||!function(){JSON.stringify=function(a){var b=typeof a;if("object"!=b||null===a)return"string"==b&&(a='"'+a+'"'),String(a);var c,d,e=[],f=a&&a.constructor==Array;for(c in a)d=a[c],b=typeof d,"string"==b?d='"'+d+'"':"object"==b&&null!==d&&(d=JSON.stringify(d)),"function"!==b&&e.push((f?"":'"'+c+'":')+String(d));return(f?"[":"{")+String(e)+(f?"]":"}")}}(),Array.prototype.filter||!function(){Array.prototype.filter=function(a){"use strict";if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;for(var d=[],e=arguments.length>=2?arguments[1]:void 0,f=0;c>f;f++)if(f in b){var g=b[f];a.call(e,g,f,b)&&d.push(g)}return d}}(),Array.prototype.forEach||(Array.prototype.forEach=function(a,b){"use strict";var c,d;if(null==this)throw new TypeError("this is null or not defined");var e,f=Object(this),g=f.length>>>0;if("[object Function]"!=={}.toString.call(a))throw new TypeError(a+" is not a function");for(arguments.length>=2&&(c=b),d=0;g>d;)d in f&&(e=f[d],a.call(c,e,d,f)),d++}),document.querySelectorAll||!function(){document.querySelectorAll=function(a){var d,b=document.createElement("style"),c=[];for(document.documentElement.firstChild.appendChild(b),document._qsa=[],b.styleSheet.cssText=a+"{x-qsa:expression(document._qsa && document._qsa.push(this))}",window.scrollBy(0,0),b.parentNode.removeChild(b);document._qsa.length;)d=document._qsa.shift(),d.style.removeAttribute("x-qsa"),c.push(d);return document._qsa=null,c}}(),document.querySelector||!function(){document.querySelector=function(a){var b=document.querySelectorAll(a);return b.length?b[0]:null}}()}(),function(){var a={version:"1.4.2",initialized:!1,key:null,deviceProfileId:null,tokenId:null},b={utils:{},card:{},request:{},trackErrors:{},paymentMethods:{}};a.referer=function(){var a=window.location.protocol+"//"+window.location.hostname+(window.location.port?":"+window.location.port:"");return a}(),a.setPublishableKey=function(b){a.key=b,a.initMercadopago()},function(a){"use strict";var b={baseUrl:"https://api.mercadopago.com/v1"};b.clear=function(a){return(""+a).trim().replace(/\s+|-/g,"")},b.paramsForm=function(a){var b={},c=a.querySelectorAll("[data-checkout]");return Array.prototype.forEach.call(c,function(a){var c=a.getAttribute("data-checkout"),d=a.selectedIndex;"SELECT"===a.nodeName&&null!==d&&-1!==d?b[c]=a.options[d].value:b[c]=a.value}),b},b.isEmpty=function(a){var b=Object.prototype.hasOwnProperty;if(null==a)return!0;if(a.length>0)return!1;if(0===a.length)return!0;for(var c in a)if(b.call(a,c))return!1;return!0},a.utils=b}(b),function(b){function c(b){var e,c=!!window.XDomainRequest,d=c?new XDomainRequest:new XMLHttpRequest;b.url+=(b.url.indexOf("?")>=0?"&":"?")+"referer="+escape(a.referer),b.requestedMethod=b.method,c&&"PUT"==b.method&&(b.method="POST",b.url+="&_method=PUT"),d.open(b.method,b.url,!0),d.timeout=b.timeout||1e3,window.XDomainRequest?(d.onload=function(){e=JSON.parse(d.responseText),"function"==typeof b.success&&b.success("POST"===b.requestedMethod?201:200,e)},d.onerror=d.ontimeout=function(){"function"==typeof b.error&&b.error(400,{user_agent:window.navigator.userAgent,error:"bad_request",cause:[]})},d.onprogress=function(){}):(d.setRequestHeader("Accept","application/json"),b.contentType?d.setRequestHeader("Content-Type",b.contentType):d.setRequestHeader("Content-Type","application/json"),d.onreadystatechange=function(){4===this.readyState&&(this.status>=200&&this.status<400?(e=JSON.parse(this.responseText),"function"==typeof b.success&&b.success(this.status,e)):this.status>=400?(e=JSON.parse(this.responseText),"function"==typeof b.error&&b.error(this.status,e)):"function"==typeof b.error&&b.error(503,{}))}),"GET"===b.method||null==b.data||void 0==b.data?d.send():d.send(JSON.stringify(b.data))}b.request.AJAX=c}(b),function(a,b){function e(b){var e=d.baseUrl+"/payment_methods/track_error?public_key="+a.key+"&js_version="+a.version;c.AJAX({url:e,method:"POST",data:b,timeout:5e3})}var c=b.request,d=b.utils;b.trackErrors=e}(a,b),function(a,b){function l(a,b){function l(d){if(a.bin){e=[];for(pm in d)if(!a.payment_type_id||a.payment_type_id&&a.payment_type_id==d[pm].payment_type_id)for(c in d[pm].settings)k.validateBinPattern(a.bin,d[pm].settings[c])&&(e[f++]=d[pm])}else a.payment_method_id&&(e=d.filter(function(b){return b.id==a.payment_method_id}));e&&e.length>0&&(g[h]=e),e&&0==e.length?(i=400,j={message:"payment method not found",error:"bad_request",status:400,cause:[]}):j=e,"function"==typeof b?b(i,j):null}var e,j,d=k.getPaymentMethods(),f=0,h=a.bin||a.payment_method_id,i=200;d.length>0?l(d):k.getAllPaymentMethods(function(a,c){200===a?l(c):"function"==typeof b?b(a,c):null})}var d=b.utils,e=b.trackErrors,f=b.request,g={},h={},i=[],j={},k={};k.validateBinPattern=function(a,b){var c=a.slice(0,6);return b&&b.bin&&(c.match(b.bin.pattern)?!0:!1)&&(!b.bin.exclusion_pattern||!c.match(b.bin.exclusion_pattern))},k.setPaymentMethods=function(a){i=a},k.getPaymentMethods=function(){return i},k.getPaymentMethod=function(a,b){var c=a.bin||a.payment_method_id;return c?(a.bin&&(a.bin=d.clear(a.bin).replace(/[^0-9]/g,"").slice(0,6)),g&&g[c]?"function"==typeof b?b(200,g[c]):null:l(a,b)):"function"==typeof b?b(400,{status:400,error:"bad_request",cause:{code:"2000",description:"the payment_method_id or bin are required"}},a):null},k.getAllPaymentMethods=function(b){var c=d.baseUrl+"/payment_methods?public_key="+a.key+"&js_version="+a.version;document.querySelector("html").getAttribute("lang")&&(c+="&locale="+document.querySelector("html").getAttribute("lang")),f.AJAX({method:"GET",url:c,timeout:1e4,success:function(a,c){k.setPaymentMethods(c),"function"==typeof b?b(a,c):null},error:function(a,c){e({status:a,type:"getAllPaymentMethods",data:c}),"function"==typeof b?b(a,c):null}})},k.getInstallments=function(b,c){var g=d.baseUrl+"/payment_methods/installments?public_key="+a.key+"&js_version="+a.version,i=b.bin||b.payment_method_id,j="";return b.bin&&(j+="&bin="+b.bin),b.payment_method_id&&(j+="&payment_method_id="+b.payment_method_id),b.issuer_id&&(j+="&issuer.id="+b.issuer_id),b.payment_type_id&&(j+="&payment_type_id="+b.payment_type_id),b.amount&&(j+="&amount="+b.amount),b.differential_pricing_id&&(j+="&differential_pricing_id="+b.differential_pricing_id),document.querySelector("html").getAttribute("lang")&&(j+="&locale="+document.querySelector("html").getAttribute("lang")),g+=j,h&&h[j]?"function"==typeof c?c(200,h[j]):null:void f.AJAX({method:"GET",url:g,timeout:1e4,error:function(a,d){e({status:a,type:"getInstallments",data:d}),"function"==typeof c?c(a,d,b):null},success:function(a,d){200===a&&d.length>0&&(i&&(h[i]=d),j&&(h[j]=d)),"function"==typeof c?c(a,d,b):null}})},k.getIssuers=function(b,c){var g=d.baseUrl+"/payment_methods/card_issuers?public_key="+a.key+"&js_version="+a.version;return(null!==b||void 0!==b)&&(g+="&payment_method_id="+b),j[b]?"function"==typeof c?c(200,j[b]):null:void f.AJAX({method:"GET",url:g,timeout:1e4,error:function(a,b){e({status:a,type:"cardIssuers",data:b}),"function"==typeof c?c(a,b):null},success:function(a,d){200===a&&(j[b]=d),"function"==typeof c?c(a,d):null}})},b.paymentMethods=k;for(exports in k)a[exports]=k[exports]}(a,b),function(a,b){function h(b){function f(a,c){if("function"==typeof b)b(a,c);else if(200==a){var d=document.querySelector("select[data-checkout=docType]");if(d){d.options.length=0;for(var f=0;f<c.length;f++){var g=c[f],h=new Option(g.name,g.id);d.options.add(h)}}}}g.identificationTypes.length>=1?f(200,g.identificationTypes):e.AJAX({method:"GET",timeout:5e3,url:c.baseUrl+"/identification_types?public_key="+a.key,success:function(a,b){200==a&&(g.identificationTypes=b),f(a,b)},error:function(a,c){if(404!==a)d({status:a,type:"getIdentificationTypes",data:c});else{var e=[document.querySelector("select[data-checkout=docType]"),document.querySelector("input[data-checkout=docNumber]"),document.querySelector("label[for=docType]"),document.querySelector("label[for=docNumber]")];for(i in e)e[i]&&(e[i].style.display="none")}"function"==typeof b?b(a,c):null}})}function j(a){var b,c,d,e,f,g;for(d=!0,e=0,c=(a+"").split("").reverse(),f=0,g=c.length;g>f;f++)b=c[f],b=parseInt(b,10),(d=!d)&&(b*=2),b>9&&(b-=9),e+=b;return e%10===0}function k(a,b,d){a=c.clear(a),void 0==d&&"function"==typeof b&&(d=b);var e={bin:a,internal_validate:!0};"function"!=typeof b&&(e.payment_method_id=b),f.getPaymentMethod(e,function(b,c){var e=!1;if(200==b)for(var g=0;g<c.length&&!e;g++){config=c[g].settings;for(var h=0;config&&h<config.length&&!e;h++)e=a.length==config[h].card_number.length&&f.validateBinPattern(a,config[h])&&("none"==config[h].card_number.validation||j(a))}"function"==typeof d?d(b,e):null})}function l(a,b,d){return a=c.clear(a),a&&!/^\d+$/.test(a)?"function"==typeof d?d(200,!1):null:void f.getPaymentMethod({bin:b,internal_validate:!0},function(b,c){var e=!0;if(200==b)for(var f=c[0]?c[0].settings:[],g=0;f&&g<f.length&&e;g++)e=!f[g].security_code.length||a.length==f[g].security_code.length||"optional"==f[g].security_code.mode&&!a.length;return"function"==typeof d?d(b,e):null})}function m(a,b,c){var d=b.length;f.getPaymentMethod({bin:a.cardNumber,internal_validate:!0},function(e,f){if(200==e)for(var h=f[0]?f[0].additional_info_needed:[],i=0;i<h.length;i++)switch(h[i]){case"cardholder_name":a.cardholderName&&""!==a.cardholderName?n(a.cardholderName)||(b[d++]=g.invalidParamsCode.cardholderName):b[d++]=g.requiredParamsCodes.cardholderName;break;case"cardholder_identification_type":a.docType&&""!==a.docType?g.identificationTypes&&!g.identificationTypes.filter(function(b){return b.id==a.docType})&&(b[d++]=g.invalidParamsCode.docType):b[d++]=g.requiredParamsCodes.docType;break;case"cardholder_identification_number":a.docNumber&&""!==a.docNumber?o(a.docType,a.docNumber)||(b[d++]=g.invalidParamsCode.docNumber):b[d++]=g.requiredParamsCodes.docNumber}"function"==typeof c?c(e,b):null})}function n(a){var b="^[a-zA-Z\xe3\xc3\xe1\xc1\xe0\xc0\xe2\xc2\xe4\xc4\u1ebd\u1ebc\xe9\xc9\xe8\xc8\xea\xca\xeb\xcb\u0129\u0128\xed\xcd\xec\xcc\xee\xce\xef\xcf\xf5\xd5\xf3\xd3\xf2\xd2\xf4\xd4\xf6\xd6\u0169\u0168\xfa\xda\xf9\xd9\xfb\xdb\xfc\xdc\xe7\xc7\u2019\xf1\xd1 .']*$";return a.match(b)?!0:!1}function o(a,b){if(0===g.identificationTypes.length)return!0;b=c.clear(b);var d=0===g.identificationTypes.length?null:g.identificationTypes.filter(function(b){return b.id==a})[0];return d=d||null,b=b||null,null!==d&&null!==b&&d.min_length<=b.length&&b.length<=d.max_length}function p(a,b){var c,d;if(a=(""+a).trim(),void 0==b){if(1==a.split("/").length)return!1;b=a.split("/")[1],a=a.split("/")[0]}return b=(""+b).trim(),2==b.length&&(b="20"+b),/^\d+$/.test(a)&&/^\d+$/.test(b)&&parseInt(a,10)<=12?(d=new Date(b,a),c=new Date,d.setMonth(d.getMonth()-1),d.setMonth(d.getMonth()+1,1),d>c):!1}function q(b,d){var e,f=0,h=[];if(b.cardId&&""!==b.cardId&&"-1"!==b.cardId)return void d(h);!b.cardExpiration||b.cardExpirationMonth&&b.cardExpirationYear?b.cardExpiration=b.cardExpirationMonth+"/"+b.cardExpirationYear:(b.cardExpirationMonth=b.cardExpiration.split("/")[0],b.cardExpirationYear=b.cardExpiration.split("/")[1]),b.cardExpirationYear&&2==b.cardExpirationYear.length&&(b.cardExpirationYear="20"+b.cardExpirationYear),b.docNumber=c.clear(b.docNumber);for(var j=0;j<g.whitelistedAttrs.length;j++)e=g.whitelistedAttrs[j],("cardNumber"==e||"securityCode"==e)&&(b[e]=c.clear(b[e])),b[e]&&""!==b[e]||"cardIssuerId"===e||"securityCode"===e||(h[f++]=g.requiredParamsCodes[e]);a.validateExpiryDate(b.cardExpirationMonth,b.cardExpirationYear)||(h[f++]=g.invalidParamsCode.cardExpirationMonth,h[f++]=g.invalidParamsCode.cardExpirationYear),k(b.cardNumber,function(a,c){c||(h[f++]=g.invalidParamsCode.cardNumber),l(b.securityCode,b.cardNumber,function(a,c){c||(h[f++]=g.invalidParamsCode.securityCode),m(b,h,function(a,b){d(b)})})})}var c=b.utils,d=b.trackErrors,e=b.request,f=b.paymentMethods,g={tokenName:"card",whitelistedAttrs:["cardNumber","securityCode","cardExpirationMonth","cardExpirationYear","cardExpiration","cardIssuerId"],identificationTypes:[],requiredParamsCodes:{cardholderName:{code:"221",description:"parameter cardholderName can not be null/empty"},docNumber:{code:"214",description:"parameter docNumber can not be null/empty"},docType:{code:"212",description:"parameter docType can not be null/empty"},cardNumber:{code:"205",description:"parameter cardNumber can not be null/empty"},securityCode:{code:"224",description:"parameter securityCode can not be null/empty"},cardExpirationMonth:{code:"208",description:"parameter cardExpirationMonth can not be null/empty"},cardExpirationYear:{code:"209",description:"parameter cardExpirationYear can not be null/empty"},cardIssuerId:{code:"220",description:"parameter cardIssuerId can not be null/empty"}},invalidParamsCode:{cardholderName:{code:"316",description:"invalid parameter cardholderName"},docNumber:{code:"324",description:"invalid parameter docNumber"},docType:{code:"322",description:"invalid parameter docType"},cardNumber:{code:"E301",description:"invalid parameter cardNumber"},securityCode:{code:"E302",description:"invalid parameter securityCode"},cardExpirationMonth:{code:"325",description:"invalid parameter cardExpirationMonth"},cardExpirationYear:{code:"326",description:"invalid parameter cardExpirationYear"}}};a.validateLuhn=j,a.validateCardNumber=k,a.validateSecurityCode=l,a.validateCardholderName=n,a.validateIdentification=o,a.validateExpiryDate=p,a.getIdentificationTypes=h,g.validate=q,b.card=g}(a,b),function(a,b){function g(b){var c={};return a.deviceProfileId&&(c.device={meli:{session_id:a.deviceProfileId}}),b.cardId&&""!==b.cardId&&"-1"!==b.cardId?(c.card_id=b.cardId,c.security_code=b.securityCode,c):(c.card_number=b.cardNumber,c.security_code=b.securityCode,c.expiration_month=parseInt(b.cardExpirationMonth,10),c.expiration_year=parseInt(b.cardExpirationYear,10),c.cardholder={name:b.cardholderName},c.cardholder.identification={type:""===b.docType||void 0===b.docType?null:b.docType,number:""===b.docNumber||void 0===b.docNumber?null:b.docNumber},c)}function h(b,d){var h,i=c.baseUrl+"/card_tokens",j=b.card?g(b.card):{};a.tokenId?(h="PUT",i+="/"+a.tokenId):h="POST",i+="?public_key="+a.key+"&js_version="+a.version,f.AJAX({method:h,url:i,data:j,timeout:1e4,error:function(a,b){e({status:a,type:"cardForm",data:b}),"function"==typeof d?d(a,b):null},success:function(a,b){"function"==typeof d?d(a,b):null}})}function i(a,b,f){a&&a.jquery&&(a=a[0]),(a instanceof HTMLFormElement||void 0!==a.nodeType&&a.nodeType===document.ELEMENT_NODE)&&(a=c.paramsForm(a)),c.isEmpty(a)?f(a):d.validate(a,function(b){b.length&&(a=b,e({status:400,type:"validateForm",data:a})),f(a)})}function j(b,c){function f(){for(var b=0,c=[],f=0;d&&f<d.length;f++){var g=d[f];null===g.name||void 0===g.name||""===g.name||"cardNumber"!=g.getAttribute("data-checkout")&&"securityCode"!=g.getAttribute("data-checkout")||(c[b++]=g.getAttribute("data-checkout"))}c.length>0&&e({status:200,type:"DSS-"+window.location.host,data:{inputNames:c,user_agent:window.navigator.userAgent,public_key:a.key}})}if(!a.key||"string"!=typeof a.key)throw new Error("You did not set a valid publishable key. Call Mercadopago.setPublishableKey() with your public_key.");if(/\s/g.test(a.key))throw new Error("Your key is invalid, as it contains whitespaces.");var d=document.querySelectorAll("[data-checkout]");if("file:"!=window.location.protocol&&"https:"!=window.location.protocol&&d&&d.length>0&&!/^TEST/.test(a.key))throw e({status:200,type:"validateReferer",data:{referer:window.location.host,user_agent:window.navigator.userAgent,public_key:a.key}}),new Error("Your payment cannot be processed because the website contains credit card data and is not using a secure connection.SSL certificate is required to operate.");f(),b.card.public_key=a.key,h(b,c)}function k(a,b){function e(a){return c[d.tokenName]=a,c[d.tokenName][0]?b(400,{error:"bad_request",message:"invalid parameters",cause:c[d.tokenName]}):j(c,b)}var c={};i(a,d.whitelistedAttrs,e)}var c=b.utils,d=b.card,e=b.trackErrors,f=b.request;a.createToken=k}(a,b),function(a){function b(b,c){var d=c.id;a.tokenId=d;var e=document.querySelector("iframe#thm_mp_cntnr");if(e){var f=e.parentElement.removeChild(e);try{delete f}catch(g){}}var h=document.createElement("iframe");h.id="thm_mp_cntnr",h.setAttribute("width","0"),h.setAttribute("height","0"),h.setAttribute("frameborder","0"),h.style.visibility="hidden",document.querySelector("body").appendChild(h),h.contentDocument.open(),h.contentDocument.write("<!doctype html><html><body></body></html>"),h.contentDocument.close();var i=document.createElement("script");i.id="thm_loader",i.setAttribute("type","text/javascript"),i.setAttribute("src","https://content.mercadopago.com/fp/tags.js?org_id=jk96mpy0&session_id="+d),h.contentDocument.body.appendChild(i)}function c(b,c){if(200==b||201==b){a.deviceProfileId=c.id;var d=document.querySelector("iframe#meli_device");if(d){var e=d.parentElement.removeChild(d);try{delete e}catch(f){}}var g=document.createElement("iframe");g.id="meli_device",g.style.display="none",g.src="https://mldp.mercadopago.com/device_profile?public_key="+a.key+"&session_id="+c.id,document.body.appendChild(g)}}a.createMeliDevice=c,a.getPixels=b}(a),function(a){function b(){a.initialized!==!0&&(a.createToken({},function(b,c){a.getPixels(b,c),a.createMeliDevice(b,c)}),0===a.getPaymentMethods().length&&a.getAllPaymentMethods(),a.initialized=!0)}function c(){a.tokenId=null,a.deviceProfileId=null,a.initialized=!1,b()}a.clearSession=c,a.initMercadopago=b}(a),this.Mercadopago=a}.call();