mirror of
https://codeberg.org/nobody/LocalCDN.git
synced 2024-12-23 00:25:15 +01:00
Normal version replaced with minified (#285)
This commit is contained in:
parent
5a026a4697
commit
931dbcfde7
@ -157,7 +157,7 @@ var resources = {
|
||||
},
|
||||
// Angular Stripe Checkout [Deprecated]
|
||||
'angularStripeCheckout': {
|
||||
'path': 'resources/angular-stripe-checkout/{version}/angular-stripe-checkout.jsm',
|
||||
'path': 'resources/angular-stripe-checkout/{version}/angular-stripe-checkout.min.jsm',
|
||||
'type': 'application/javascript'
|
||||
},
|
||||
// Angular Translate
|
||||
|
@ -653,7 +653,7 @@ const ListOfFiles = {
|
||||
'angular-resource.min.jsm': 'AngularJS Resource',
|
||||
'angular-route.min.jsm': 'AngularJS Route',
|
||||
'angular-sanitize.min.jsm': 'AngularJS Sanitize',
|
||||
'angular-stripe-checkout.jsm': 'Angular Stripe Checkout',
|
||||
'angular-stripe-checkout.min.jsm': 'Angular Stripe Checkout',
|
||||
'angular-touch.min.jsm': 'AngularJS Touch',
|
||||
'angular-ui-router.min.jsm': 'Angular UI Router',
|
||||
'angular.min.jsm': 'Angular (JS)',
|
||||
|
@ -1,216 +0,0 @@
|
||||
(function() {
|
||||
/* global StripeCheckout */
|
||||
'use strict';
|
||||
|
||||
var MODULE_NAME = 'stripe.checkout';
|
||||
var STRIPE_CHECKOUT_URL = 'https://checkout.stripe.com/checkout.js';
|
||||
|
||||
var OPTIONS = {
|
||||
address: ['data-address', 'boolean'],
|
||||
alipay: ['data-alipay', 'boolean-or-auto'],
|
||||
alipayReusable: ['data-alipay-reusable', 'boolean'],
|
||||
allowRememberMe: ['data-allow-remember-me', 'boolean'],
|
||||
amount: ['data-amount', 'number'],
|
||||
billingAddress: ['data-billing-address', 'boolean'],
|
||||
bitcoin: ['data-bitcoin', 'boolean'],
|
||||
currency: ['data-currency', 'string'],
|
||||
description: ['data-description', 'string'],
|
||||
email: ['data-email', 'string'],
|
||||
image: ['data-image', 'string'],
|
||||
key: ['data-key', 'string'],
|
||||
label: ['data-label', 'string'],
|
||||
locale: ['data-locale', 'string'],
|
||||
name: ['data-name', 'string'],
|
||||
color: ['data-color', 'string'],
|
||||
panelLabel: ['data-panel-label', 'string'],
|
||||
shippingAddress: ['data-shipping-address', 'boolean'],
|
||||
zipCode: ['data-zip-code', 'boolean']
|
||||
};
|
||||
|
||||
|
||||
var angular;
|
||||
|
||||
if (typeof module !== 'undefined' && typeof module.exports === 'object') {
|
||||
angular = require('angular');
|
||||
module.exports = MODULE_NAME;
|
||||
} else {
|
||||
angular = window.angular;
|
||||
}
|
||||
|
||||
var extend = angular.extend;
|
||||
|
||||
angular.module(MODULE_NAME,[])
|
||||
.directive('stripeCheckout',StripeCheckoutDirective)
|
||||
.provider('StripeCheckout',StripeCheckoutProvider);
|
||||
|
||||
|
||||
StripeCheckoutDirective.$inject = ['$parse', 'StripeCheckout'];
|
||||
|
||||
function StripeCheckoutDirective($parse, StripeCheckout) {
|
||||
return { link: link };
|
||||
|
||||
function link(scope, el, attrs) {
|
||||
var handler;
|
||||
|
||||
StripeCheckout.load()
|
||||
.then(function() {
|
||||
handler = StripeCheckout.configure(getOptions(el));
|
||||
});
|
||||
|
||||
el.on('click',function() {
|
||||
if (handler)
|
||||
handler.open(getOptions(el)).then(function(result) {
|
||||
var callback = $parse(attrs.stripeCheckout)(scope);
|
||||
if (typeof callback === 'function')
|
||||
callback.apply(null,result);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function StripeCheckoutProvider() {
|
||||
var defaults = {};
|
||||
|
||||
this.defaults = function(options) {
|
||||
extend(defaults,options);
|
||||
};
|
||||
|
||||
|
||||
this.load = function(StripeCheckout) {
|
||||
return StripeCheckout.load();
|
||||
};
|
||||
|
||||
this.load.$inject = ['StripeCheckout'];
|
||||
|
||||
|
||||
this.$get = function($document, $q) {
|
||||
return new StripeCheckoutService($document,$q,defaults);
|
||||
};
|
||||
|
||||
this.$get.$inject = ['$document', '$q'];
|
||||
}
|
||||
|
||||
|
||||
function StripeCheckoutService($document, $q, providerDefaults) {
|
||||
var defaults = {};
|
||||
var promise;
|
||||
|
||||
this.configure = function(options) {
|
||||
return new StripeHandlerWrapper($q,extend({},
|
||||
providerDefaults,
|
||||
defaults,
|
||||
options
|
||||
));
|
||||
};
|
||||
|
||||
this.load = function() {
|
||||
if (!promise)
|
||||
promise = loadLibrary($document,$q);
|
||||
|
||||
return promise;
|
||||
};
|
||||
|
||||
this.defaults = function(options) {
|
||||
extend(defaults,options);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function StripeHandlerWrapper($q, options) {
|
||||
var deferred, success;
|
||||
|
||||
var handler = StripeCheckout.configure(extend({},options,{
|
||||
token: function(token, args) {
|
||||
if (options.token) options.token(token,args);
|
||||
|
||||
success = true;
|
||||
deferred.resolve([token, args]);
|
||||
},
|
||||
|
||||
closed: function() {
|
||||
if (options.closed) options.closed();
|
||||
if (!success) deferred.reject();
|
||||
}
|
||||
}));
|
||||
|
||||
this.open = function(openOptions) {
|
||||
deferred = $q.defer();
|
||||
success = false;
|
||||
|
||||
handler.open(openOptions);
|
||||
|
||||
return deferred.promise;
|
||||
};
|
||||
|
||||
this.close = function() {
|
||||
success = false;
|
||||
|
||||
handler.close();
|
||||
|
||||
if (options.closed) options.closed();
|
||||
if (deferred) deferred.reject();
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function getOptions(el) {
|
||||
var opt, def, val, options = {};
|
||||
|
||||
for (opt in OPTIONS) {
|
||||
if (!OPTIONS.hasOwnProperty(opt))
|
||||
continue;
|
||||
|
||||
def = OPTIONS[opt];
|
||||
val = parseValue(el.attr(def[0]),def[1]);
|
||||
|
||||
if (val != null)
|
||||
options[opt] = val;
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
function loadLibrary($document, $q) {
|
||||
var deferred = $q.defer();
|
||||
|
||||
var doc = $document[0];
|
||||
var script = doc.createElement('script');
|
||||
script.src = STRIPE_CHECKOUT_URL;
|
||||
|
||||
script.onload = function () {
|
||||
deferred.resolve();
|
||||
};
|
||||
|
||||
script.onreadystatechange = function () {
|
||||
var rs = this.readyState;
|
||||
if (rs === 'loaded' || rs === 'complete')
|
||||
deferred.resolve();
|
||||
};
|
||||
|
||||
script.onerror = function () {
|
||||
deferred.reject(new Error('Unable to load checkout.js'));
|
||||
};
|
||||
|
||||
var container = doc.getElementsByTagName('head')[0];
|
||||
container.appendChild(script);
|
||||
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function parseValue(value, type) {
|
||||
if (type === 'boolean') {
|
||||
return value && value !== 'false';
|
||||
} else if (type === 'number') {
|
||||
return value && Number(value);
|
||||
} else if (type === 'boolean-or-auto') {
|
||||
if (value === 'auto')
|
||||
return value;
|
||||
else
|
||||
return parseValue(value,'boolean');
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
})();
|
@ -0,0 +1 @@
|
||||
(function(){"use strict";var e="stripe.checkout";var t="https://checkout.stripe.com/checkout.js";var n={address:["data-address","boolean"],alipay:["data-alipay","boolean-or-auto"],alipayReusable:["data-alipay-reusable","boolean"],allowRememberMe:["data-allow-remember-me","boolean"],amount:["data-amount","number"],billingAddress:["data-billing-address","boolean"],bitcoin:["data-bitcoin","boolean"],currency:["data-currency","string"],description:["data-description","string"],email:["data-email","string"],image:["data-image","string"],key:["data-key","string"],label:["data-label","string"],locale:["data-locale","string"],name:["data-name","string"],color:["data-color","string"],panelLabel:["data-panel-label","string"],shippingAddress:["data-shipping-address","boolean"],zipCode:["data-zip-code","boolean"]};var a;if(typeof module!=="undefined"&&typeof module.exports==="object"){a=require("angular");module.exports=e}else{a=window.angular}var o=a.extend;a.module(e,[]).directive("stripeCheckout",r).provider("StripeCheckout",i);r.$inject=["$parse","StripeCheckout"];function r(e,t){return{link:n};function n(n,a,o){var r;t.load().then(function(){r=t.configure(u(a))});a.on("click",function(){if(r)r.open(u(a)).then(function(t){var a=e(o.stripeCheckout)(n);if(typeof a==="function")a.apply(null,t)})})}}function i(){var e={};this.defaults=function(t){o(e,t)};this.load=function(e){return e.load()};this.load.$inject=["StripeCheckout"];this.$get=function(t,n){return new l(t,n,e)};this.$get.$inject=["$document","$q"]}function l(e,t,n){var a={};var r;this.configure=function(e){return new c(t,o({},n,a,e))};this.load=function(){if(!r)r=s(e,t);return r};this.defaults=function(e){o(a,e)}}function c(e,t){var n,a;var r=StripeCheckout.configure(o({},t,{token:function(e,o){if(t.token)t.token(e,o);a=true;n.resolve([e,o])},closed:function(){if(t.closed)t.closed();if(!a)n.reject()}}));this.open=function(t){n=e.defer();a=false;r.open(t);return n.promise};this.close=function(){a=false;r.close();if(t.closed)t.closed();if(n)n.reject()}}function u(e){var t,a,o,r={};for(t in n){if(!n.hasOwnProperty(t))continue;a=n[t];o=d(e.attr(a[0]),a[1]);if(o!=null)r[t]=o}return r}function s(e,n){var a=n.defer();var o=e[0];var r=o.createElement("script");r.src=t;r.onload=function(){a.resolve()};r.onreadystatechange=function(){var e=this.readyState;if(e==="loaded"||e==="complete")a.resolve()};r.onerror=function(){a.reject(new Error("Unable to load checkout.js"))};var i=o.getElementsByTagName("head")[0];i.appendChild(r);return a.promise}function d(e,t){if(t==="boolean"){return e&&e!=="false"}else if(t==="number"){return e&&Number(e)}else if(t==="boolean-or-auto"){if(e==="auto")return e;else return d(e,"boolean")}else{return e}}})();
|
Loading…
Reference in New Issue
Block a user