+ *
+ * @return {void}
+ */
+ function injectCSS() {
+ var css = '',
+ styleEl = document.createElement('style'),
+ paypalButton = '.paypal-button',
+ paypalInput = paypalButton + ' button[type=submit]';
+
+ css += paypalButton + ' { white-space: nowrap; overflow: hidden; }';
+ css += paypalInput + ' { outline: none; text-decoration: none; -moz-box-sizing: border-box; -webkit-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box; max-width: 100%; position: relative; margin: 0; background-color: rgb(252,155,0); background: -moz-linear-gradient(top, rgb(255,248,252) 0%, rgb(252,155,0) 66%, rgb(252,155,0) 66%, rgb(255,248,252) 100%); background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,rgb(255,248,252)), color-stop(66%,rgb(252,155,0)), color-stop(66%,rgb(252,155,0)), color-stop(100%,rgb(255,248,252))); background: -webkit-linear-gradient(top, rgb(255,248,252) 0%,rgb(252,155,0) 66%,rgb(252,155,0) 66%,rgb(255,248,252) 100%); background: -o-linear-gradient(top, rgb(255,248,252) 0%,rgb(252,155,0) 66%,rgb(252,155,0) 66%,rgb(255,248,252) 100%); background: -ms-linear-gradient(top, rgb(255,248,252) 0%,rgb(252,155,0) 66%,rgb(252,155,0) 66%,rgb(255,248,252) 100%); background: linear-gradient(to bottom, rgb(255,248,252) 0%,rgb(252,155,0) 66%,rgb(252,155,0) 66%,rgb(255,248,252) 100%);filter:progid:DXImageTransform.Microsoft.gradient( startColorstr="rgb(255,248,252)", endColorstr="rgb(252,155,0)",GradientType=0 );border: rgb(251,137,0) solid 1px; -moz-border-radius: 12px; -webkit-border-radius: 12px; border-radius: 12px; color: rgb(5, 37, 87); font-weight: bold; text-shadow: 0 1px 0 rgba(255,255,255,.5); -webkit-user-select: none; -moz-user-select: none; -o-user-select: none; user-select: none; cursor: pointer; max-width: 100%; overflow: hidden; font-style: italic; font-family: "Verdana"; }';
+ css += paypalInput + '.small { padding: 3px 15px; font-size: 11px; }';
+ css += paypalInput + '.large { padding: 4px 22px; font-size: 13px; }';
+
+ styleEl.type = 'text/css';
+
+ if (styleEl.styleSheet) {
+ styleEl.styleSheet.cssText = css;
+ } else {
+ styleEl.appendChild(document.createTextNode(css));
+ }
+
+ document.getElementsByTagName('head')[0].appendChild(styleEl);
+ }
/**
@@ -256,7 +306,6 @@ PAYPAL.apps = PAYPAL.apps || {};
return dataset;
}
-
/**
* A storage object to create structured methods around a button's data
*/
@@ -275,28 +324,107 @@ PAYPAL.apps = PAYPAL.apps || {};
delete this.items[key];
};
}
+
+
+ function getButtons() {
+ var slice;
+
+ if (document.querySelectorAll) {
+ slice = Array.prototype.slice;
+ return function (attr) {
+ return slice.call(document.body.querySelectorAll('[data-paypal]'));
+ };
+ }
+ return function (attr) {
+ var elems = document.body.getElementsByTagName('button'),
+ match = [],
+ elem, i;
+
+ for (i = elems.length - 1; i > -1; i--) {
+ elem = elems[i];
+ // Non-existent attributes generally return empty string ('') or null,
+ // so their falsy-ness suffices in this case.
+ if (elem.getAttribute(attr)) {
+ match.push(elems);
+ }
+ }
- // Init the buttons
- if (typeof document !== 'undefined') {
- var ButtonFactory = PAYPAL.apps.ButtonFactory,
- nodes = document.getElementsByTagName('script'),
+ return match;
+ };
+ }
+
+ /**
+ * Gets all elements w/ data-paypal attributes
+ *
+ * @param type {String} The data-paypal value to match against
+ * @return {NodeList}
+ */
+ function getButtonsByType(type){
+ var nodes = [],
+ attr = "data-paypal",
+ value;
+
+ function getButton(node, fn) {
+ fn(node);
+ node = node.firstChild;
+
+ while (node) {
+ getButton(node, fn);
+ node = node.nextSibling;
+ }
+ }
+
+ getButton(document.body, function(n) {
+ if (n.nodeType === 1 && (value = n.getAttribute(attr))) {
+ if (value === type) {
+ nodes.push(n);
+ }
+ }
+ });
+
+ return nodes;
+ }
+
+ /**
+ * Grab the merchant's ID off of the
-
Buy Now (Small)
-
+
Buy Now (Small)
+
+
-
+
-
Buy Now (Large)
-
+
Buy Now (Large)
+
+
-
+
-
Buy Now (Spanish)
-
+
Buy Now (Spanish)
+
+
-
+
-
Buy Now (French)
-
+
Buy Now (French)
+
+
-
+
-
Buy Now (German)
-
+
Buy Now (German)
+
+
-
+
-
Buy Now (Editable)
-
+
Buy Now (Editable)
+
+
-
+
-
Cart (Small)
-
+
Cart (Small)
+
+
-
+
-
Cart (Large)
-
-
+ Cart (Large)
+
+
+
-
Hosted (Small)
-
+ data-id="8R63A645E2QB6"
+ data-size="small"
+ >
-
+
-
Hosted
-
+ data-id="8R63A645E2QB6"
+ >
-
+
QR Code
-
+ >
+
+