Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

CSS tweaks for resizing and to test file

  • Loading branch information...
commit 9515dea212e84bd95c1d15886d9a61b4554d6381 1 parent a9ce4c0
@jeffharrell jeffharrell authored
View
3  .gitignore
@@ -1,3 +1,4 @@
node_modules
.DS_Store
-*.log
+*.log
+*.orig
View
117 dist/paypal-button-minicart.js
@@ -29,11 +29,33 @@ PAYPAL.apps = PAYPAL.apps || {};
period: 't3',
callback: 'notify_url'
},
- buttonImgs = {
- buynow: '//www.paypalobjects.com/{locale}/i/btn/btn_buynow_{size}.gif',
- cart: '//www.paypalobjects.com/{locale}/i/btn/btn_cart_{size}.gif',
- donate: '//www.paypalobjects.com/{locale}/i/btn/btn_donate_{size}.gif',
- subscribe: '//www.paypalobjects.com/{locale}/i/btn/btn_subscribe_{size}.gif'
+ buttonText = {
+ da_DK: { buynow: 'Køb nu', cart: 'Læg i indkøbsvogn', donate: 'Doner', subscribe: 'Abonner', item_name: 'Vare', number: 'Nummer', amount: 'Pris', quantity: 'Antal' },
+ de_DE: { buynow: 'Jetzt kaufen', cart: 'In den Warenkorb', donate: 'Spenden', subscribe: 'Abonnieren', item_name: 'Artikel', number: 'Nummer', amount: 'Betrag', quantity: 'Menge' },
+ en_AU: { buynow: 'Buy Now', cart: 'Add to Cart', donate: 'Donate', subscribe: 'Subscribe', item_name: 'Item', number: 'Number', amount: 'Amount', quantity: 'Quantity' },
+ en_GB: { buynow: 'Buy Now', cart: 'Add to Cart', donate: 'Donate', subscribe: 'Subscribe', item_name: 'Item', number: 'Number', amount: 'Amount', quantity: 'Quantity' },
+ en_US: { buynow: 'Buy Now', cart: 'Add to Cart', donate: 'Donate', subscribe: 'Subscribe', item_name: 'Item', number: 'Number', amount: 'Amount', quantity: 'Quantity' },
+ es_ES: { buynow: 'Comprar ahora', cart: 'Añadir al carro', donate: 'Donar', subscribe: 'Suscribirse', item_name: 'Artículo', number: 'Número', amount: 'Importe', quantity: 'Cantidad' },
+ es_XC: { buynow: 'Comprar ahora', cart: 'Añadir al carrito', donate: 'Donar', subscribe: 'Suscribirse', item_name: 'Artículo', number: 'Número', amount: 'Importe', quantity: 'Cantidad' },
+ fr_CA: { buynow: 'Acheter', cart: 'Ajouter au panier', donate: 'Faire un don', subscribe: 'Souscrire', item_name: 'Objet', number: 'Numéro', amount: 'Montant', quantity: 'Quantité' },
+ fr_FR: { buynow: 'Acheter', cart: 'Ajouter au panier', donate: 'Faire un don', subscribe: 'Souscrire', item_name: 'Objet', number: 'Numéro', amount: 'Montant', quantity: 'Quantité' },
+ fr_XC: { buynow: 'Acheter', cart: 'Ajouter au panier', donate: 'Faire un don', subscribe: 'Souscrire', item_name: 'Objet', number: 'Numéro', amount: 'Montant', quantity: 'Quantité' },
+ he_IL: { buynow: 'וישכע הנק', cart: 'תוינקה לסל ףסוה', donate: 'םורת', subscribe: 'יונמכ ףרטצה', item_name: 'טירפ', number: 'רפסמ', amount: 'םוכס', quantity: 'מותכ' },
+ id_ID: { buynow: 'Beli Sekarang', cart: 'Tambah ke Keranjang', donate: 'Donasikan', subscribe: 'Berlangganan', item_name: 'Barang', number: 'Nomor', amount: 'Harga', quantity: 'Kuantitas' },
+ it_IT: { buynow: 'Paga adesso', cart: 'Aggiungi al carrello', donate: 'Donazione', subscribe: 'Iscriviti', item_name: 'Oggetto', number: 'Numero', amount: 'Importo', quantity: 'Quantità' },
+ ja_JP: { buynow: '今すぐ購入', cart: 'カートに追加', donate: '寄付', subscribe: '購読', item_name: '商品', number: '番号', amount: '価格', quantity: '数量' },
+ nl_NL: { buynow: 'Nu kopen', cart: 'Aan winkelwagentje toevoegen', donate: 'Doneren', subscribe: 'Abonneren', item_name: 'Item', number: 'Nummer', amount: 'Bedrag', quantity: 'Hoeveelheid' },
+ no_NO: { buynow: 'Kjøp nå', cart: 'Legg til i kurv', donate: 'Doner', subscribe: 'Abonner', item_name: 'Vare', number: 'Nummer', amount: 'Beløp', quantity: 'Antall' },
+ pl_PL: { buynow: 'Kup teraz', cart: 'Dodaj do koszyka', donate: 'Przekaż darowiznę', subscribe: 'Subskrybuj', item_name: 'Przedmiot', number: 'Numer', amount: 'Kwota', quantity: 'Ilość' },
+ pt_BR: { buynow: 'Comprar agora', cart: 'Adicionar ao carrinho', donate: 'Doar', subscribe: 'Assinar', item_name: 'Produto', number: 'Número', amount: 'Valor', quantity: 'Quantidade' },
+ ru_RU: { buynow: 'Купить сейчас', cart: 'Добавить в корзину', donate: 'Пожертвовать', subscribe: 'Подписаться', item_name: 'Товар', number: 'Номер', amount: 'Сумма', quantity: 'Количество' },
+ sv_SE: { buynow: 'Köp nu', cart: 'Lägg till i kundvagn', donate: 'Donera', subscribe: 'Abonnera', item_name: 'Objekt', number: 'Nummer', amount: 'Belopp', quantity: 'Antal' },
+ th_TH: { buynow: 'ซื้อทันที', cart: 'เพิ่มลงตะกร้า', donate: 'บริจาค', subscribe: 'บอกรับสมาชิก', item_name: 'ชื่อสินค้า', number: 'รหัสสินค้า', amount: 'ราคา', quantity: 'จำนวน' },
+ tr_TR: { buynow: 'Hemen Alın', cart: 'Sepete Ekleyin', donate: 'Bağış Yapın', subscribe: 'Abone Olun', item_name: 'Ürün', number: 'Numara', amount: 'Tutar', quantity: 'Miktar' },
+ zh_CN: { buynow: '立即购买', cart: '添加到购物车', donate: '捐赠', subscribe: '租用', item_name: '物品', number: '编号', amount: '金额', quantity: '数量' },
+ zh_HK: { buynow: '立即買', cart: '加入購物車', donate: '捐款', subscribe: '訂用', item_name: '項目', number: '號碼', amount: '金額', quantity: '數量' },
+ zh_TW: { buynow: '立即購', cart: '加到購物車', donate: '捐款', subscribe: '訂閱', item_name: '商品', number: '商品編號', amount: '單價', quantity: '數量' },
+ zh_XC: { buynow: '立即购买', cart: '添加到购物车', donate: '捐赠', subscribe: '租用', item_name: '物品', number: '编号', amount: '金额', quantity: '数量' }
};
if (!PAYPAL.apps.ButtonFactory) {
@@ -42,12 +64,7 @@ PAYPAL.apps = PAYPAL.apps || {};
* Initial config for the app. These values can be overridden by the page.
*/
app.config = {
- labels: {
- item_name: 'Item',
- item_number: 'Number',
- amount: 'Amount',
- quantity: 'Quantity'
- }
+ labels: {}
};
/**
@@ -116,6 +133,9 @@ PAYPAL.apps = PAYPAL.apps || {};
button = buildForm(data, type);
}
+ // Inject CSS
+ injectCSS();
+
// Register it
this.buttons[type] += 1;
@@ -141,18 +161,22 @@ PAYPAL.apps = PAYPAL.apps || {};
*/
function buildForm(data, type) {
var form = document.createElement('form'),
- btn = document.createElement('input'),
+ btn = document.createElement('button'),
hidden = document.createElement('input'),
items = data.items,
- item, child, label, input, key, size, locale;
+ item, child, label, input, key, size, locale, localeText;
- btn.type = 'image';
- hidden.type = 'hidden';
form.method = 'post';
form.action = paypalURL;
form.className = 'paypal-button';
form.target = '_top';
+ hidden.type = 'hidden';
+
+ size = items.size && items.size.value || 'large';
+ locale = items.lc && items.lc.value || 'en_US';
+ localeText = buttonText[locale] || buttonText.en_US;
+
for (key in items) {
item = items[key];
@@ -165,7 +189,7 @@ PAYPAL.apps = PAYPAL.apps || {};
label = document.createElement('label');
label.className = 'paypal-label';
- label.appendChild(document.createTextNode(app.config.labels[item.key] + ' ' || ''));
+ label.appendChild(document.createTextNode(app.config.labels[item.key] || localeText[item.key]));
label.appendChild(input);
child = document.createElement('p');
@@ -180,11 +204,11 @@ PAYPAL.apps = PAYPAL.apps || {};
form.appendChild(child);
}
- size = items.size && items.size.value;
- locale = items.lc && items.lc.value;
+ btn.type = 'submit';
+ btn.className = 'paypal-button ' + size;
+ btn.appendChild(document.createTextNode(localeText[type]));
form.appendChild(btn);
- btn.src = getButtonImg(type, size, locale);
// If the Mini Cart is present then register the form
if (PAYPAL.apps.MiniCart && data.items.cmd.value === '_cart') {
@@ -200,6 +224,42 @@ PAYPAL.apps = PAYPAL.apps || {};
return form;
}
+ /**
+ * Injects button CSS in the <head>
+ *
+ * @return {void}
+ */
+ function injectCSS() {
+ var css, styleEl, paypalButton, paypalInput;
+
+ if (document.getElementById('paypal-button')) {
+ return;
+ }
+
+ css = '';
+ styleEl = document.createElement('style');
+ paypalButton = '.paypal-button';
+ paypalInput = paypalButton + ' button[type=submit]';
+
+ css += paypalButton + ' { white-space: nowrap; }';
+ css += paypalInput + ' { white-space: nowrap; overflow: hidden; border-radius: 13px; font-family: "Arial", bold, italic; font-weight: bold; font-style: italic; border: 1px solid #ffa823; color: #0E3168; background: transparent; position: relative; text-shadow: 0 1px 0 rgba(255,255,255,.5); cursor: pointer; }';
+ css += paypalInput + ':before { content: " "; position: absolute; width: 100%; height: 100%; border-radius: 11px; top: 0; left: 0; background: #ffa823; background: -webkit-linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); background: -moz-linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); background: -ms-linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); background: linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); z-index: -2; }';
+ css += paypalInput + ':after { content: " "; position: absolute; width: 98%; height: 60%; border-radius: 40px 40px 38px 38px; top: 0; left: 0; background: -webkit-linear-gradient(top, #fefefe 0%, #fed994 100%); background: -moz-linear-gradient(top, #fefefe 0%, #fed994 100%); background: -ms-linear-gradient(top, #fefefe 0%, #fed994 100%); background: linear-gradient(top, #fefefe 0%, #fed994 100%); z-index: -1; -webkit-transform: translateX(1%);-moz-transform: translateX(1%); -ms-transform: translateX(1%); transform: translateX(1%); }';
+ css += paypalInput + '.small { padding: 3px 15px; font-size: 12px; }';
+ css += paypalInput + '.large { padding: 4px 19px; font-size: 14px; }';
+
+ styleEl.type = 'text/css';
+ styleEl.id = 'paypal-button';
+
+ if (styleEl.styleSheet) {
+ styleEl.styleSheet.cssText = css;
+ } else {
+ styleEl.appendChild(document.createTextNode(css));
+ }
+
+ document.getElementsByTagName('head')[0].appendChild(styleEl);
+ }
+
/**
* Builds the image for a QR code
@@ -231,25 +291,6 @@ PAYPAL.apps = PAYPAL.apps || {};
/**
- * Utility function to return the rendered button image URL
- *
- * @param type {String} The type of button to render
- * @param size {String} The size of button (small/large)
- * @param locale {String} The locale
- * @return {String}
- */
- function getButtonImg(type, size, locale) {
- var img = buttonImgs[type] || buttonImgs.buynow;
-
- // Image defaults
- locale = locale || 'en_US';
- size = (size === 'small') ? 'SM' : 'LG';
-
- return img.replace(/\{locale\}/, locale).replace(/\{size\}/, size);
- }
-
-
- /**
* Utility function to polyfill dataset functionality with a bit of a spin
*
* @param el {HTMLElement} The element to check
View
4 dist/paypal-button-minicart.min.js
@@ -1,7 +1,7 @@
/*!
* PayPalJSButtons
* JavaScript integration for PayPal's payment buttons
- * @version 1.0.0 - 2013-03-15, 6:52:50 PM
+ * @version 1.0.1 - 2013-03-26
* @author Jeff Harrell <https://github.com/jeffharrell/>
*/
-if(PAYPAL===void 0||!PAYPAL)var PAYPAL={};PAYPAL.apps=PAYPAL.apps||{},function(){"use strict";function e(e,t){var n,i,r,l,p,s,u,d=document.createElement("form"),m=document.createElement("input"),b=document.createElement("input"),y=e.items;m.type="image",b.type="hidden",d.method="post",d.action=o,d.className="paypal-button",d.target="_top";for(p in y)n=y[p],n.isEditable?(l=document.createElement("input"),l.type="text",l.className="paypal-input",l.name=n.key,l.value=n.value,r=document.createElement("label"),r.className="paypal-label",r.appendChild(document.createTextNode(c.config.labels[n.key]+" "||"")),r.appendChild(l),i=document.createElement("p"),i.className="paypal-group",i.appendChild(r)):(l=i=b.cloneNode(!0),l.name=n.key,l.value=n.value),d.appendChild(i);if(s=y.size&&y.size.value,u=y.lc&&y.lc.value,d.appendChild(m),m.src=a(t,s,u),PAYPAL.apps.MiniCart&&"_cart"===e.items.cmd.value){var f=PAYPAL.apps.MiniCart;f.UI.itemList||f.render(),f.bindForm(d)}return d}function t(e,t){var a,n,i=document.createElement("img"),c=o+"?",l=13,p=e.items;t=t&&t.value||250;for(n in p)a=p[n],c+=a.key+"="+encodeURIComponent(a.value)+"&";return c=encodeURIComponent(c),i.src=r.replace("{url}",c).replace("{pattern}",l).replace("{size}",t),i}function a(e,t,a){var n=s[e]||s.buynow;return a=a||"en_US",t="small"===t?"SM":"LG",n.replace(/\{locale\}/,a).replace(/\{size\}/,t)}function n(e){var t,a,n,i,c,o={};if(t=e.attributes)for(c=0,i=t.length;i>c;c++)a=t[c],(n=/^data-([a-z0-9_]+)(-editable)?/i.exec(a.name))&&(o[n[1]]={value:a.value,isEditable:!!n[2]});return o}function i(){this.items={},this.add=function(e,t,a){this.items[e]={key:e,value:t,isEditable:a}},this.remove=function(e){delete this.items[e]}}var c={},o="https://www.paypal.com/cgi-bin/webscr",r="https://www.paypal.com/webapps/ppint/qrcode?data={url}&pattern={pattern}&height={size}",l="JavaScriptButton_{type}",p={name:"item_name",number:"item_number",locale:"lc",currency:"currency_code",recurrence:"p3",period:"t3",callback:"notify_url"},s={buynow:"//www.paypalobjects.com/{locale}/i/btn/btn_buynow_{size}.gif",cart:"//www.paypalobjects.com/{locale}/i/btn/btn_cart_{size}.gif",donate:"//www.paypalobjects.com/{locale}/i/btn/btn_donate_{size}.gif",subscribe:"//www.paypalobjects.com/{locale}/i/btn/btn_subscribe_{size}.gif"};if(PAYPAL.apps.ButtonFactory||(c.config={labels:{item_name:"Item",item_number:"Number",amount:"Amount",quantity:"Quantity"}},c.buttons={buynow:0,cart:0,donate:0,qr:0,subscribe:0},c.create=function(a,n,c,o){var r,s,u=new i;if(!a)return!1;for(s in n)u.add(p[s]||s,n[s].value,n[s].isEditable);return c=c||"buynow","cart"===c?(u.add("cmd","_cart"),u.add("add",!0)):"donate"===c?u.add("cmd","_donations"):"subscribe"===c?(u.add("cmd","_xclick-subscriptions"),u.items.amount&&!u.items.a3&&u.add("a3",u.items.amount.value)):u.add("cmd","_xclick"),u.add("business",a),u.add("bn",l.replace(/\{type\}/,c)),"qr"===c?(r=t(u,u.items.size),u.remove("size")):r=e(u,c),this.buttons[c]+=1,o&&o.appendChild(r),r},PAYPAL.apps.ButtonFactory=c),"undefined"!=typeof document){var u,d,m,b,y,f,v=PAYPAL.apps.ButtonFactory,w=document.getElementsByTagName("script");for(y=0,f=w.length;f>y;y++)u=w[y],u&&u.src&&(d=u&&n(u),m=d&&d.button&&d.button.value,b=u.src.split("?merchant=")[1],b&&(v.create(b,d,m,u.parentNode),u.parentNode.removeChild(u)))}}(),"object"==typeof module&&"object"==typeof module.exports&&(module.exports=PAYPAL);
+if(PAYPAL===void 0||!PAYPAL)var PAYPAL={};PAYPAL.apps=PAYPAL.apps||{},function(){"use strict";function e(e,t){var a,n,r,i,m,d,c,s,l=document.createElement("form"),p=document.createElement("button"),y=document.createElement("input"),A=e.items;l.method="post",l.action=u,l.className="paypal-button",l.target="_top",y.type="hidden",d=A.size&&A.size.value||"large",c=A.lc&&A.lc.value||"en_US",s=b[c]||b.en_US;for(m in A)a=A[m],a.isEditable?(i=document.createElement("input"),i.type="text",i.className="paypal-input",i.name=a.key,i.value=a.value,r=document.createElement("label"),r.className="paypal-label",r.appendChild(document.createTextNode(o.config.labels[a.key]||s[a.key])),r.appendChild(i),n=document.createElement("p"),n.className="paypal-group",n.appendChild(r)):(i=n=y.cloneNode(!0),i.name=a.key,i.value=a.value),l.appendChild(n);if(p.type="submit",p.className="paypal-button "+d,p.appendChild(document.createTextNode(s[t])),l.appendChild(p),PAYPAL.apps.MiniCart&&"_cart"===e.items.cmd.value){var f=PAYPAL.apps.MiniCart;f.UI.itemList||f.render(),f.bindForm(l)}return l}function t(){var e,t,a,n;document.getElementById("paypal-button")||(e="",t=document.createElement("style"),a=".paypal-button",n=a+" button[type=submit]",e+=a+" { white-space: nowrap; }",e+=n+' { white-space: nowrap; overflow: hidden; border-radius: 13px; font-family: "Arial", bold, italic; font-weight: bold; font-style: italic; border: 1px solid #ffa823; color: #0E3168; background: transparent; position: relative; text-shadow: 0 1px 0 rgba(255,255,255,.5); cursor: pointer; }',e+=n+':before { content: " "; position: absolute; width: 100%; height: 100%; border-radius: 11px; top: 0; left: 0; background: #ffa823; background: -webkit-linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); background: -moz-linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); background: -ms-linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); background: linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); z-index: -2; }',e+=n+':after { content: " "; position: absolute; width: 98%; height: 60%; border-radius: 40px 40px 38px 38px; top: 0; left: 0; background: -webkit-linear-gradient(top, #fefefe 0%, #fed994 100%); background: -moz-linear-gradient(top, #fefefe 0%, #fed994 100%); background: -ms-linear-gradient(top, #fefefe 0%, #fed994 100%); background: linear-gradient(top, #fefefe 0%, #fed994 100%); z-index: -1; -webkit-transform: translateX(1%);-moz-transform: translateX(1%); -ms-transform: translateX(1%); transform: translateX(1%); }',e+=n+".small { padding: 3px 15px; font-size: 12px; }",e+=n+".large { padding: 4px 19px; font-size: 14px; }",t.type="text/css",t.id="paypal-button",t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e)),document.getElementsByTagName("head")[0].appendChild(t))}function a(e,t){var a,n,r=document.createElement("img"),o=u+"?",m=13,d=e.items;t=t&&t.value||250;for(n in d)a=d[n],o+=a.key+"="+encodeURIComponent(a.value)+"&";return o=encodeURIComponent(o),r.src=i.replace("{url}",o).replace("{pattern}",m).replace("{size}",t),r}function n(e){var t,a,n,r,o,u={};if(t=e.attributes)for(o=0,r=t.length;r>o;o++)a=t[o],(n=/^data-([a-z0-9_]+)(-editable)?/i.exec(a.name))&&(u[n[1]]={value:a.value,isEditable:!!n[2]});return u}function r(){this.items={},this.add=function(e,t,a){this.items[e]={key:e,value:t,isEditable:a}},this.remove=function(e){delete this.items[e]}}var o={},u="https://www.paypal.com/cgi-bin/webscr",i="https://www.paypal.com/webapps/ppint/qrcode?data={url}&pattern={pattern}&height={size}",m="JavaScriptButton_{type}",d={name:"item_name",number:"item_number",locale:"lc",currency:"currency_code",recurrence:"p3",period:"t3",callback:"notify_url"},b={da_DK:{buynow:"Køb nu",cart:"Læg i indkøbsvogn",donate:"Doner",subscribe:"Abonner",item_name:"Vare",number:"Nummer",amount:"Pris",quantity:"Antal"},de_DE:{buynow:"Jetzt kaufen",cart:"In den Warenkorb",donate:"Spenden",subscribe:"Abonnieren",item_name:"Artikel",number:"Nummer",amount:"Betrag",quantity:"Menge"},en_AU:{buynow:"Buy Now",cart:"Add to Cart",donate:"Donate",subscribe:"Subscribe",item_name:"Item",number:"Number",amount:"Amount",quantity:"Quantity"},en_GB:{buynow:"Buy Now",cart:"Add to Cart",donate:"Donate",subscribe:"Subscribe",item_name:"Item",number:"Number",amount:"Amount",quantity:"Quantity"},en_US:{buynow:"Buy Now",cart:"Add to Cart",donate:"Donate",subscribe:"Subscribe",item_name:"Item",number:"Number",amount:"Amount",quantity:"Quantity"},es_ES:{buynow:"Comprar ahora",cart:"Añadir al carro",donate:"Donar",subscribe:"Suscribirse",item_name:"Artículo",number:"Número",amount:"Importe",quantity:"Cantidad"},es_XC:{buynow:"Comprar ahora",cart:"Añadir al carrito",donate:"Donar",subscribe:"Suscribirse",item_name:"Artículo",number:"Número",amount:"Importe",quantity:"Cantidad"},fr_CA:{buynow:"Acheter",cart:"Ajouter au panier",donate:"Faire un don",subscribe:"Souscrire",item_name:"Objet",number:"Numéro",amount:"Montant",quantity:"Quantité"},fr_FR:{buynow:"Acheter",cart:"Ajouter au panier",donate:"Faire un don",subscribe:"Souscrire",item_name:"Objet",number:"Numéro",amount:"Montant",quantity:"Quantité"},fr_XC:{buynow:"Acheter",cart:"Ajouter au panier",donate:"Faire un don",subscribe:"Souscrire",item_name:"Objet",number:"Numéro",amount:"Montant",quantity:"Quantité"},he_IL:{buynow:"וישכע הנק",cart:"תוינקה לסל ףסוה",donate:"םורת",subscribe:"יונמכ ףרטצה",item_name:"טירפ",number:"רפסמ",amount:"םוכס",quantity:"מותכ"},id_ID:{buynow:"Beli Sekarang",cart:"Tambah ke Keranjang",donate:"Donasikan",subscribe:"Berlangganan",item_name:"Barang",number:"Nomor",amount:"Harga",quantity:"Kuantitas"},it_IT:{buynow:"Paga adesso",cart:"Aggiungi al carrello",donate:"Donazione",subscribe:"Iscriviti",item_name:"Oggetto",number:"Numero",amount:"Importo",quantity:"Quantità"},ja_JP:{buynow:"今すぐ購入",cart:"カートに追加",donate:"寄付",subscribe:"購読",item_name:"商品",number:"番号",amount:"価格",quantity:"数量"},nl_NL:{buynow:"Nu kopen",cart:"Aan winkelwagentje toevoegen",donate:"Doneren",subscribe:"Abonneren",item_name:"Item",number:"Nummer",amount:"Bedrag",quantity:"Hoeveelheid"},no_NO:{buynow:"Kjøp nå",cart:"Legg til i kurv",donate:"Doner",subscribe:"Abonner",item_name:"Vare",number:"Nummer",amount:"Beløp",quantity:"Antall"},pl_PL:{buynow:"Kup teraz",cart:"Dodaj do koszyka",donate:"Przekaż darowiznę",subscribe:"Subskrybuj",item_name:"Przedmiot",number:"Numer",amount:"Kwota",quantity:"Ilość"},pt_BR:{buynow:"Comprar agora",cart:"Adicionar ao carrinho",donate:"Doar",subscribe:"Assinar",item_name:"Produto",number:"Número",amount:"Valor",quantity:"Quantidade"},ru_RU:{buynow:"Купить сейчас",cart:"Добавить в корзину",donate:"Пожертвовать",subscribe:"Подписаться",item_name:"Товар",number:"Номер",amount:"Сумма",quantity:"Количество"},sv_SE:{buynow:"Köp nu",cart:"Lägg till i kundvagn",donate:"Donera",subscribe:"Abonnera",item_name:"Objekt",number:"Nummer",amount:"Belopp",quantity:"Antal"},th_TH:{buynow:"ซื้อทันที",cart:"เพิ่มลงตะกร้า",donate:"บริจาค",subscribe:"บอกรับสมาชิก",item_name:"ชื่อสินค้า",number:"รหัสสินค้า",amount:"ราคา",quantity:"จำนวน"},tr_TR:{buynow:"Hemen Alın",cart:"Sepete Ekleyin",donate:"Bağış Yapın",subscribe:"Abone Olun",item_name:"Ürün",number:"Numara",amount:"Tutar",quantity:"Miktar"},zh_CN:{buynow:"立即购买",cart:"添加到购物车",donate:"捐赠",subscribe:"租用",item_name:"物品",number:"编号",amount:"金额",quantity:"数量"},zh_HK:{buynow:"立即買",cart:"加入購物車",donate:"捐款",subscribe:"訂用",item_name:"項目",number:"號碼",amount:"金額",quantity:"數量"},zh_TW:{buynow:"立即購",cart:"加到購物車",donate:"捐款",subscribe:"訂閱",item_name:"商品",number:"商品編號",amount:"單價",quantity:"數量"},zh_XC:{buynow:"立即购买",cart:"添加到购物车",donate:"捐赠",subscribe:"租用",item_name:"物品",number:"编号",amount:"金额",quantity:"数量"}};if(PAYPAL.apps.ButtonFactory||(o.config={labels:{}},o.buttons={buynow:0,cart:0,donate:0,qr:0,subscribe:0},o.create=function(n,o,u,i){var b,c,s=new r;if(!n)return!1;for(c in o)s.add(d[c]||c,o[c].value,o[c].isEditable);return u=u||"buynow","cart"===u?(s.add("cmd","_cart"),s.add("add",!0)):"donate"===u?s.add("cmd","_donations"):"subscribe"===u?(s.add("cmd","_xclick-subscriptions"),s.items.amount&&!s.items.a3&&s.add("a3",s.items.amount.value)):s.add("cmd","_xclick"),s.add("business",n),s.add("bn",m.replace(/\{type\}/,u)),"qr"===u?(b=a(s,s.items.size),s.remove("size")):b=e(s,u),t(),this.buttons[u]+=1,i&&i.appendChild(b),b},PAYPAL.apps.ButtonFactory=o),"undefined"!=typeof document){var c,s,l,p,y,A,f=PAYPAL.apps.ButtonFactory,_=document.getElementsByTagName("script");for(y=0,A=_.length;A>y;y++)c=_[y],c&&c.src&&(s=c&&n(c),l=s&&s.button&&s.button.value,p=c.src.split("?merchant=")[1],p&&(f.create(p,s,l,c.parentNode),c.parentNode.removeChild(c)))}}(),"object"==typeof module&&"object"==typeof module.exports&&(module.exports=PAYPAL);
View
117 dist/paypal-button.js
@@ -29,11 +29,33 @@ PAYPAL.apps = PAYPAL.apps || {};
period: 't3',
callback: 'notify_url'
},
- buttonImgs = {
- buynow: '//www.paypalobjects.com/{locale}/i/btn/btn_buynow_{size}.gif',
- cart: '//www.paypalobjects.com/{locale}/i/btn/btn_cart_{size}.gif',
- donate: '//www.paypalobjects.com/{locale}/i/btn/btn_donate_{size}.gif',
- subscribe: '//www.paypalobjects.com/{locale}/i/btn/btn_subscribe_{size}.gif'
+ buttonText = {
+ da_DK: { buynow: 'Køb nu', cart: 'Læg i indkøbsvogn', donate: 'Doner', subscribe: 'Abonner', item_name: 'Vare', number: 'Nummer', amount: 'Pris', quantity: 'Antal' },
+ de_DE: { buynow: 'Jetzt kaufen', cart: 'In den Warenkorb', donate: 'Spenden', subscribe: 'Abonnieren', item_name: 'Artikel', number: 'Nummer', amount: 'Betrag', quantity: 'Menge' },
+ en_AU: { buynow: 'Buy Now', cart: 'Add to Cart', donate: 'Donate', subscribe: 'Subscribe', item_name: 'Item', number: 'Number', amount: 'Amount', quantity: 'Quantity' },
+ en_GB: { buynow: 'Buy Now', cart: 'Add to Cart', donate: 'Donate', subscribe: 'Subscribe', item_name: 'Item', number: 'Number', amount: 'Amount', quantity: 'Quantity' },
+ en_US: { buynow: 'Buy Now', cart: 'Add to Cart', donate: 'Donate', subscribe: 'Subscribe', item_name: 'Item', number: 'Number', amount: 'Amount', quantity: 'Quantity' },
+ es_ES: { buynow: 'Comprar ahora', cart: 'Añadir al carro', donate: 'Donar', subscribe: 'Suscribirse', item_name: 'Artículo', number: 'Número', amount: 'Importe', quantity: 'Cantidad' },
+ es_XC: { buynow: 'Comprar ahora', cart: 'Añadir al carrito', donate: 'Donar', subscribe: 'Suscribirse', item_name: 'Artículo', number: 'Número', amount: 'Importe', quantity: 'Cantidad' },
+ fr_CA: { buynow: 'Acheter', cart: 'Ajouter au panier', donate: 'Faire un don', subscribe: 'Souscrire', item_name: 'Objet', number: 'Numéro', amount: 'Montant', quantity: 'Quantité' },
+ fr_FR: { buynow: 'Acheter', cart: 'Ajouter au panier', donate: 'Faire un don', subscribe: 'Souscrire', item_name: 'Objet', number: 'Numéro', amount: 'Montant', quantity: 'Quantité' },
+ fr_XC: { buynow: 'Acheter', cart: 'Ajouter au panier', donate: 'Faire un don', subscribe: 'Souscrire', item_name: 'Objet', number: 'Numéro', amount: 'Montant', quantity: 'Quantité' },
+ he_IL: { buynow: 'וישכע הנק', cart: 'תוינקה לסל ףסוה', donate: 'םורת', subscribe: 'יונמכ ףרטצה', item_name: 'טירפ', number: 'רפסמ', amount: 'םוכס', quantity: 'מותכ' },
+ id_ID: { buynow: 'Beli Sekarang', cart: 'Tambah ke Keranjang', donate: 'Donasikan', subscribe: 'Berlangganan', item_name: 'Barang', number: 'Nomor', amount: 'Harga', quantity: 'Kuantitas' },
+ it_IT: { buynow: 'Paga adesso', cart: 'Aggiungi al carrello', donate: 'Donazione', subscribe: 'Iscriviti', item_name: 'Oggetto', number: 'Numero', amount: 'Importo', quantity: 'Quantità' },
+ ja_JP: { buynow: '今すぐ購入', cart: 'カートに追加', donate: '寄付', subscribe: '購読', item_name: '商品', number: '番号', amount: '価格', quantity: '数量' },
+ nl_NL: { buynow: 'Nu kopen', cart: 'Aan winkelwagentje toevoegen', donate: 'Doneren', subscribe: 'Abonneren', item_name: 'Item', number: 'Nummer', amount: 'Bedrag', quantity: 'Hoeveelheid' },
+ no_NO: { buynow: 'Kjøp nå', cart: 'Legg til i kurv', donate: 'Doner', subscribe: 'Abonner', item_name: 'Vare', number: 'Nummer', amount: 'Beløp', quantity: 'Antall' },
+ pl_PL: { buynow: 'Kup teraz', cart: 'Dodaj do koszyka', donate: 'Przekaż darowiznę', subscribe: 'Subskrybuj', item_name: 'Przedmiot', number: 'Numer', amount: 'Kwota', quantity: 'Ilość' },
+ pt_BR: { buynow: 'Comprar agora', cart: 'Adicionar ao carrinho', donate: 'Doar', subscribe: 'Assinar', item_name: 'Produto', number: 'Número', amount: 'Valor', quantity: 'Quantidade' },
+ ru_RU: { buynow: 'Купить сейчас', cart: 'Добавить в корзину', donate: 'Пожертвовать', subscribe: 'Подписаться', item_name: 'Товар', number: 'Номер', amount: 'Сумма', quantity: 'Количество' },
+ sv_SE: { buynow: 'Köp nu', cart: 'Lägg till i kundvagn', donate: 'Donera', subscribe: 'Abonnera', item_name: 'Objekt', number: 'Nummer', amount: 'Belopp', quantity: 'Antal' },
+ th_TH: { buynow: 'ซื้อทันที', cart: 'เพิ่มลงตะกร้า', donate: 'บริจาค', subscribe: 'บอกรับสมาชิก', item_name: 'ชื่อสินค้า', number: 'รหัสสินค้า', amount: 'ราคา', quantity: 'จำนวน' },
+ tr_TR: { buynow: 'Hemen Alın', cart: 'Sepete Ekleyin', donate: 'Bağış Yapın', subscribe: 'Abone Olun', item_name: 'Ürün', number: 'Numara', amount: 'Tutar', quantity: 'Miktar' },
+ zh_CN: { buynow: '立即购买', cart: '添加到购物车', donate: '捐赠', subscribe: '租用', item_name: '物品', number: '编号', amount: '金额', quantity: '数量' },
+ zh_HK: { buynow: '立即買', cart: '加入購物車', donate: '捐款', subscribe: '訂用', item_name: '項目', number: '號碼', amount: '金額', quantity: '數量' },
+ zh_TW: { buynow: '立即購', cart: '加到購物車', donate: '捐款', subscribe: '訂閱', item_name: '商品', number: '商品編號', amount: '單價', quantity: '數量' },
+ zh_XC: { buynow: '立即购买', cart: '添加到购物车', donate: '捐赠', subscribe: '租用', item_name: '物品', number: '编号', amount: '金额', quantity: '数量' }
};
if (!PAYPAL.apps.ButtonFactory) {
@@ -42,12 +64,7 @@ PAYPAL.apps = PAYPAL.apps || {};
* Initial config for the app. These values can be overridden by the page.
*/
app.config = {
- labels: {
- item_name: 'Item',
- item_number: 'Number',
- amount: 'Amount',
- quantity: 'Quantity'
- }
+ labels: {}
};
/**
@@ -116,6 +133,9 @@ PAYPAL.apps = PAYPAL.apps || {};
button = buildForm(data, type);
}
+ // Inject CSS
+ injectCSS();
+
// Register it
this.buttons[type] += 1;
@@ -141,18 +161,22 @@ PAYPAL.apps = PAYPAL.apps || {};
*/
function buildForm(data, type) {
var form = document.createElement('form'),
- btn = document.createElement('input'),
+ btn = document.createElement('button'),
hidden = document.createElement('input'),
items = data.items,
- item, child, label, input, key, size, locale;
+ item, child, label, input, key, size, locale, localeText;
- btn.type = 'image';
- hidden.type = 'hidden';
form.method = 'post';
form.action = paypalURL;
form.className = 'paypal-button';
form.target = '_top';
+ hidden.type = 'hidden';
+
+ size = items.size && items.size.value || 'large';
+ locale = items.lc && items.lc.value || 'en_US';
+ localeText = buttonText[locale] || buttonText.en_US;
+
for (key in items) {
item = items[key];
@@ -165,7 +189,7 @@ PAYPAL.apps = PAYPAL.apps || {};
label = document.createElement('label');
label.className = 'paypal-label';
- label.appendChild(document.createTextNode(app.config.labels[item.key] + ' ' || ''));
+ label.appendChild(document.createTextNode(app.config.labels[item.key] || localeText[item.key]));
label.appendChild(input);
child = document.createElement('p');
@@ -180,11 +204,11 @@ PAYPAL.apps = PAYPAL.apps || {};
form.appendChild(child);
}
- size = items.size && items.size.value;
- locale = items.lc && items.lc.value;
+ btn.type = 'submit';
+ btn.className = 'paypal-button ' + size;
+ btn.appendChild(document.createTextNode(localeText[type]));
form.appendChild(btn);
- btn.src = getButtonImg(type, size, locale);
// If the Mini Cart is present then register the form
if (PAYPAL.apps.MiniCart && data.items.cmd.value === '_cart') {
@@ -200,6 +224,42 @@ PAYPAL.apps = PAYPAL.apps || {};
return form;
}
+ /**
+ * Injects button CSS in the <head>
+ *
+ * @return {void}
+ */
+ function injectCSS() {
+ var css, styleEl, paypalButton, paypalInput;
+
+ if (document.getElementById('paypal-button')) {
+ return;
+ }
+
+ css = '';
+ styleEl = document.createElement('style');
+ paypalButton = '.paypal-button';
+ paypalInput = paypalButton + ' button[type=submit]';
+
+ css += paypalButton + ' { white-space: nowrap; }';
+ css += paypalInput + ' { white-space: nowrap; overflow: hidden; border-radius: 13px; font-family: "Arial", bold, italic; font-weight: bold; font-style: italic; border: 1px solid #ffa823; color: #0E3168; background: transparent; position: relative; text-shadow: 0 1px 0 rgba(255,255,255,.5); cursor: pointer; }';
+ css += paypalInput + ':before { content: " "; position: absolute; width: 100%; height: 100%; border-radius: 11px; top: 0; left: 0; background: #ffa823; background: -webkit-linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); background: -moz-linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); background: -ms-linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); background: linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); z-index: -2; }';
+ css += paypalInput + ':after { content: " "; position: absolute; width: 98%; height: 60%; border-radius: 40px 40px 38px 38px; top: 0; left: 0; background: -webkit-linear-gradient(top, #fefefe 0%, #fed994 100%); background: -moz-linear-gradient(top, #fefefe 0%, #fed994 100%); background: -ms-linear-gradient(top, #fefefe 0%, #fed994 100%); background: linear-gradient(top, #fefefe 0%, #fed994 100%); z-index: -1; -webkit-transform: translateX(1%);-moz-transform: translateX(1%); -ms-transform: translateX(1%); transform: translateX(1%); }';
+ css += paypalInput + '.small { padding: 3px 15px; font-size: 12px; }';
+ css += paypalInput + '.large { padding: 4px 19px; font-size: 14px; }';
+
+ styleEl.type = 'text/css';
+ styleEl.id = 'paypal-button';
+
+ if (styleEl.styleSheet) {
+ styleEl.styleSheet.cssText = css;
+ } else {
+ styleEl.appendChild(document.createTextNode(css));
+ }
+
+ document.getElementsByTagName('head')[0].appendChild(styleEl);
+ }
+
/**
* Builds the image for a QR code
@@ -231,25 +291,6 @@ PAYPAL.apps = PAYPAL.apps || {};
/**
- * Utility function to return the rendered button image URL
- *
- * @param type {String} The type of button to render
- * @param size {String} The size of button (small/large)
- * @param locale {String} The locale
- * @return {String}
- */
- function getButtonImg(type, size, locale) {
- var img = buttonImgs[type] || buttonImgs.buynow;
-
- // Image defaults
- locale = locale || 'en_US';
- size = (size === 'small') ? 'SM' : 'LG';
-
- return img.replace(/\{locale\}/, locale).replace(/\{size\}/, size);
- }
-
-
- /**
* Utility function to polyfill dataset functionality with a bit of a spin
*
* @param el {HTMLElement} The element to check
View
2  dist/paypal-button.min.js
@@ -4,4 +4,4 @@
* @version 1.0.1 - 2013-03-26
* @author Jeff Harrell <https://github.com/jeffharrell/>
*/
-if(PAYPAL===void 0||!PAYPAL)var PAYPAL={};PAYPAL.apps=PAYPAL.apps||{},function(){"use strict";function e(e,t){var n,i,r,l,p,s,u,d=document.createElement("form"),m=document.createElement("input"),b=document.createElement("input"),y=e.items;m.type="image",b.type="hidden",d.method="post",d.action=o,d.className="paypal-button",d.target="_top";for(p in y)n=y[p],n.isEditable?(l=document.createElement("input"),l.type="text",l.className="paypal-input",l.name=n.key,l.value=n.value,r=document.createElement("label"),r.className="paypal-label",r.appendChild(document.createTextNode(c.config.labels[n.key]+" "||"")),r.appendChild(l),i=document.createElement("p"),i.className="paypal-group",i.appendChild(r)):(l=i=b.cloneNode(!0),l.name=n.key,l.value=n.value),d.appendChild(i);if(s=y.size&&y.size.value,u=y.lc&&y.lc.value,d.appendChild(m),m.src=a(t,s,u),PAYPAL.apps.MiniCart&&"_cart"===e.items.cmd.value){var f=PAYPAL.apps.MiniCart;f.UI.itemList||f.render(),f.bindForm(d)}return d}function t(e,t){var a,n,i=document.createElement("img"),c=o+"?",l=13,p=e.items;t=t&&t.value||250;for(n in p)a=p[n],c+=a.key+"="+encodeURIComponent(a.value)+"&";return c=encodeURIComponent(c),i.src=r.replace("{url}",c).replace("{pattern}",l).replace("{size}",t),i}function a(e,t,a){var n=s[e]||s.buynow;return a=a||"en_US",t="small"===t?"SM":"LG",n.replace(/\{locale\}/,a).replace(/\{size\}/,t)}function n(e){var t,a,n,i,c,o={};if(t=e.attributes)for(c=0,i=t.length;i>c;c++)a=t[c],(n=/^data-([a-z0-9_]+)(-editable)?/i.exec(a.name))&&(o[n[1]]={value:a.value,isEditable:!!n[2]});return o}function i(){this.items={},this.add=function(e,t,a){this.items[e]={key:e,value:t,isEditable:a}},this.remove=function(e){delete this.items[e]}}var c={},o="https://www.paypal.com/cgi-bin/webscr",r="https://www.paypal.com/webapps/ppint/qrcode?data={url}&pattern={pattern}&height={size}",l="JavaScriptButton_{type}",p={name:"item_name",number:"item_number",locale:"lc",currency:"currency_code",recurrence:"p3",period:"t3",callback:"notify_url"},s={buynow:"//www.paypalobjects.com/{locale}/i/btn/btn_buynow_{size}.gif",cart:"//www.paypalobjects.com/{locale}/i/btn/btn_cart_{size}.gif",donate:"//www.paypalobjects.com/{locale}/i/btn/btn_donate_{size}.gif",subscribe:"//www.paypalobjects.com/{locale}/i/btn/btn_subscribe_{size}.gif"};if(PAYPAL.apps.ButtonFactory||(c.config={labels:{item_name:"Item",item_number:"Number",amount:"Amount",quantity:"Quantity"}},c.buttons={buynow:0,cart:0,donate:0,qr:0,subscribe:0},c.create=function(a,n,c,o){var r,s,u=new i;if(!a)return!1;for(s in n)u.add(p[s]||s,n[s].value,n[s].isEditable);return c=c||"buynow","cart"===c?(u.add("cmd","_cart"),u.add("add",!0)):"donate"===c?u.add("cmd","_donations"):"subscribe"===c?(u.add("cmd","_xclick-subscriptions"),u.items.amount&&!u.items.a3&&u.add("a3",u.items.amount.value)):u.add("cmd","_xclick"),u.add("business",a),u.add("bn",l.replace(/\{type\}/,c)),"qr"===c?(r=t(u,u.items.size),u.remove("size")):r=e(u,c),this.buttons[c]+=1,o&&o.appendChild(r),r},PAYPAL.apps.ButtonFactory=c),"undefined"!=typeof document){var u,d,m,b,y,f,v=PAYPAL.apps.ButtonFactory,w=document.getElementsByTagName("script");for(y=0,f=w.length;f>y;y++)u=w[y],u&&u.src&&(d=u&&n(u),m=d&&d.button&&d.button.value,b=u.src.split("?merchant=")[1],b&&(v.create(b,d,m,u.parentNode),u.parentNode.removeChild(u)))}}(),"object"==typeof module&&"object"==typeof module.exports&&(module.exports=PAYPAL);
+if(PAYPAL===void 0||!PAYPAL)var PAYPAL={};PAYPAL.apps=PAYPAL.apps||{},function(){"use strict";function e(e,t){var a,n,r,i,m,d,c,s,l=document.createElement("form"),p=document.createElement("button"),y=document.createElement("input"),A=e.items;l.method="post",l.action=u,l.className="paypal-button",l.target="_top",y.type="hidden",d=A.size&&A.size.value||"large",c=A.lc&&A.lc.value||"en_US",s=b[c]||b.en_US;for(m in A)a=A[m],a.isEditable?(i=document.createElement("input"),i.type="text",i.className="paypal-input",i.name=a.key,i.value=a.value,r=document.createElement("label"),r.className="paypal-label",r.appendChild(document.createTextNode(o.config.labels[a.key]||s[a.key])),r.appendChild(i),n=document.createElement("p"),n.className="paypal-group",n.appendChild(r)):(i=n=y.cloneNode(!0),i.name=a.key,i.value=a.value),l.appendChild(n);if(p.type="submit",p.className="paypal-button "+d,p.appendChild(document.createTextNode(s[t])),l.appendChild(p),PAYPAL.apps.MiniCart&&"_cart"===e.items.cmd.value){var f=PAYPAL.apps.MiniCart;f.UI.itemList||f.render(),f.bindForm(l)}return l}function t(){var e,t,a,n;document.getElementById("paypal-button")||(e="",t=document.createElement("style"),a=".paypal-button",n=a+" button[type=submit]",e+=a+" { white-space: nowrap; }",e+=n+' { white-space: nowrap; overflow: hidden; border-radius: 13px; font-family: "Arial", bold, italic; font-weight: bold; font-style: italic; border: 1px solid #ffa823; color: #0E3168; background: transparent; position: relative; text-shadow: 0 1px 0 rgba(255,255,255,.5); cursor: pointer; }',e+=n+':before { content: " "; position: absolute; width: 100%; height: 100%; border-radius: 11px; top: 0; left: 0; background: #ffa823; background: -webkit-linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); background: -moz-linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); background: -ms-linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); background: linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); z-index: -2; }',e+=n+':after { content: " "; position: absolute; width: 98%; height: 60%; border-radius: 40px 40px 38px 38px; top: 0; left: 0; background: -webkit-linear-gradient(top, #fefefe 0%, #fed994 100%); background: -moz-linear-gradient(top, #fefefe 0%, #fed994 100%); background: -ms-linear-gradient(top, #fefefe 0%, #fed994 100%); background: linear-gradient(top, #fefefe 0%, #fed994 100%); z-index: -1; -webkit-transform: translateX(1%);-moz-transform: translateX(1%); -ms-transform: translateX(1%); transform: translateX(1%); }',e+=n+".small { padding: 3px 15px; font-size: 12px; }",e+=n+".large { padding: 4px 19px; font-size: 14px; }",t.type="text/css",t.id="paypal-button",t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e)),document.getElementsByTagName("head")[0].appendChild(t))}function a(e,t){var a,n,r=document.createElement("img"),o=u+"?",m=13,d=e.items;t=t&&t.value||250;for(n in d)a=d[n],o+=a.key+"="+encodeURIComponent(a.value)+"&";return o=encodeURIComponent(o),r.src=i.replace("{url}",o).replace("{pattern}",m).replace("{size}",t),r}function n(e){var t,a,n,r,o,u={};if(t=e.attributes)for(o=0,r=t.length;r>o;o++)a=t[o],(n=/^data-([a-z0-9_]+)(-editable)?/i.exec(a.name))&&(u[n[1]]={value:a.value,isEditable:!!n[2]});return u}function r(){this.items={},this.add=function(e,t,a){this.items[e]={key:e,value:t,isEditable:a}},this.remove=function(e){delete this.items[e]}}var o={},u="https://www.paypal.com/cgi-bin/webscr",i="https://www.paypal.com/webapps/ppint/qrcode?data={url}&pattern={pattern}&height={size}",m="JavaScriptButton_{type}",d={name:"item_name",number:"item_number",locale:"lc",currency:"currency_code",recurrence:"p3",period:"t3",callback:"notify_url"},b={da_DK:{buynow:"Køb nu",cart:"Læg i indkøbsvogn",donate:"Doner",subscribe:"Abonner",item_name:"Vare",number:"Nummer",amount:"Pris",quantity:"Antal"},de_DE:{buynow:"Jetzt kaufen",cart:"In den Warenkorb",donate:"Spenden",subscribe:"Abonnieren",item_name:"Artikel",number:"Nummer",amount:"Betrag",quantity:"Menge"},en_AU:{buynow:"Buy Now",cart:"Add to Cart",donate:"Donate",subscribe:"Subscribe",item_name:"Item",number:"Number",amount:"Amount",quantity:"Quantity"},en_GB:{buynow:"Buy Now",cart:"Add to Cart",donate:"Donate",subscribe:"Subscribe",item_name:"Item",number:"Number",amount:"Amount",quantity:"Quantity"},en_US:{buynow:"Buy Now",cart:"Add to Cart",donate:"Donate",subscribe:"Subscribe",item_name:"Item",number:"Number",amount:"Amount",quantity:"Quantity"},es_ES:{buynow:"Comprar ahora",cart:"Añadir al carro",donate:"Donar",subscribe:"Suscribirse",item_name:"Artículo",number:"Número",amount:"Importe",quantity:"Cantidad"},es_XC:{buynow:"Comprar ahora",cart:"Añadir al carrito",donate:"Donar",subscribe:"Suscribirse",item_name:"Artículo",number:"Número",amount:"Importe",quantity:"Cantidad"},fr_CA:{buynow:"Acheter",cart:"Ajouter au panier",donate:"Faire un don",subscribe:"Souscrire",item_name:"Objet",number:"Numéro",amount:"Montant",quantity:"Quantité"},fr_FR:{buynow:"Acheter",cart:"Ajouter au panier",donate:"Faire un don",subscribe:"Souscrire",item_name:"Objet",number:"Numéro",amount:"Montant",quantity:"Quantité"},fr_XC:{buynow:"Acheter",cart:"Ajouter au panier",donate:"Faire un don",subscribe:"Souscrire",item_name:"Objet",number:"Numéro",amount:"Montant",quantity:"Quantité"},he_IL:{buynow:"וישכע הנק",cart:"תוינקה לסל ףסוה",donate:"םורת",subscribe:"יונמכ ףרטצה",item_name:"טירפ",number:"רפסמ",amount:"םוכס",quantity:"מותכ"},id_ID:{buynow:"Beli Sekarang",cart:"Tambah ke Keranjang",donate:"Donasikan",subscribe:"Berlangganan",item_name:"Barang",number:"Nomor",amount:"Harga",quantity:"Kuantitas"},it_IT:{buynow:"Paga adesso",cart:"Aggiungi al carrello",donate:"Donazione",subscribe:"Iscriviti",item_name:"Oggetto",number:"Numero",amount:"Importo",quantity:"Quantità"},ja_JP:{buynow:"今すぐ購入",cart:"カートに追加",donate:"寄付",subscribe:"購読",item_name:"商品",number:"番号",amount:"価格",quantity:"数量"},nl_NL:{buynow:"Nu kopen",cart:"Aan winkelwagentje toevoegen",donate:"Doneren",subscribe:"Abonneren",item_name:"Item",number:"Nummer",amount:"Bedrag",quantity:"Hoeveelheid"},no_NO:{buynow:"Kjøp nå",cart:"Legg til i kurv",donate:"Doner",subscribe:"Abonner",item_name:"Vare",number:"Nummer",amount:"Beløp",quantity:"Antall"},pl_PL:{buynow:"Kup teraz",cart:"Dodaj do koszyka",donate:"Przekaż darowiznę",subscribe:"Subskrybuj",item_name:"Przedmiot",number:"Numer",amount:"Kwota",quantity:"Ilość"},pt_BR:{buynow:"Comprar agora",cart:"Adicionar ao carrinho",donate:"Doar",subscribe:"Assinar",item_name:"Produto",number:"Número",amount:"Valor",quantity:"Quantidade"},ru_RU:{buynow:"Купить сейчас",cart:"Добавить в корзину",donate:"Пожертвовать",subscribe:"Подписаться",item_name:"Товар",number:"Номер",amount:"Сумма",quantity:"Количество"},sv_SE:{buynow:"Köp nu",cart:"Lägg till i kundvagn",donate:"Donera",subscribe:"Abonnera",item_name:"Objekt",number:"Nummer",amount:"Belopp",quantity:"Antal"},th_TH:{buynow:"ซื้อทันที",cart:"เพิ่มลงตะกร้า",donate:"บริจาค",subscribe:"บอกรับสมาชิก",item_name:"ชื่อสินค้า",number:"รหัสสินค้า",amount:"ราคา",quantity:"จำนวน"},tr_TR:{buynow:"Hemen Alın",cart:"Sepete Ekleyin",donate:"Bağış Yapın",subscribe:"Abone Olun",item_name:"Ürün",number:"Numara",amount:"Tutar",quantity:"Miktar"},zh_CN:{buynow:"立即购买",cart:"添加到购物车",donate:"捐赠",subscribe:"租用",item_name:"物品",number:"编号",amount:"金额",quantity:"数量"},zh_HK:{buynow:"立即買",cart:"加入購物車",donate:"捐款",subscribe:"訂用",item_name:"項目",number:"號碼",amount:"金額",quantity:"數量"},zh_TW:{buynow:"立即購",cart:"加到購物車",donate:"捐款",subscribe:"訂閱",item_name:"商品",number:"商品編號",amount:"單價",quantity:"數量"},zh_XC:{buynow:"立即购买",cart:"添加到购物车",donate:"捐赠",subscribe:"租用",item_name:"物品",number:"编号",amount:"金额",quantity:"数量"}};if(PAYPAL.apps.ButtonFactory||(o.config={labels:{}},o.buttons={buynow:0,cart:0,donate:0,qr:0,subscribe:0},o.create=function(n,o,u,i){var b,c,s=new r;if(!n)return!1;for(c in o)s.add(d[c]||c,o[c].value,o[c].isEditable);return u=u||"buynow","cart"===u?(s.add("cmd","_cart"),s.add("add",!0)):"donate"===u?s.add("cmd","_donations"):"subscribe"===u?(s.add("cmd","_xclick-subscriptions"),s.items.amount&&!s.items.a3&&s.add("a3",s.items.amount.value)):s.add("cmd","_xclick"),s.add("business",n),s.add("bn",m.replace(/\{type\}/,u)),"qr"===u?(b=a(s,s.items.size),s.remove("size")):b=e(s,u),t(),this.buttons[u]+=1,i&&i.appendChild(b),b},PAYPAL.apps.ButtonFactory=o),"undefined"!=typeof document){var c,s,l,p,y,A,f=PAYPAL.apps.ButtonFactory,_=document.getElementsByTagName("script");for(y=0,A=_.length;A>y;y++)c=_[y],c&&c.src&&(s=c&&n(c),l=s&&s.button&&s.button.value,p=c.src.split("?merchant=")[1],p&&(f.create(p,s,l,c.parentNode),c.parentNode.removeChild(c)))}}(),"object"==typeof module&&"object"==typeof module.exports&&(module.exports=PAYPAL);
View
4 src/paypal-button.js
@@ -239,8 +239,8 @@ PAYPAL.apps = PAYPAL.apps || {};
css += paypalInput + ' { white-space: nowrap; overflow: hidden; border-radius: 13px; font-family: "Arial", bold, italic; font-weight: bold; font-style: italic; border: 1px solid #ffa823; color: #0E3168; background: transparent; position: relative; text-shadow: 0 1px 0 rgba(255,255,255,.5); cursor: pointer; }';
css += paypalInput + ':before { content: " "; position: absolute; width: 100%; height: 100%; border-radius: 11px; top: 0; left: 0; background: #ffa823; background: -webkit-linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); background: -moz-linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); background: -ms-linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); background: linear-gradient(top, #FFAA00 0%,#FFAA00 80%,#FFF8FC 100%); z-index: -2; }';
css += paypalInput + ':after { content: " "; position: absolute; width: 98%; height: 60%; border-radius: 40px 40px 38px 38px; top: 0; left: 0; background: -webkit-linear-gradient(top, #fefefe 0%, #fed994 100%); background: -moz-linear-gradient(top, #fefefe 0%, #fed994 100%); background: -ms-linear-gradient(top, #fefefe 0%, #fed994 100%); background: linear-gradient(top, #fefefe 0%, #fed994 100%); z-index: -1; -webkit-transform: translateX(1%);-moz-transform: translateX(1%); -ms-transform: translateX(1%); transform: translateX(1%); }';
- css += paypalInput + '.small { padding: 3px 15px; font-size: 12px; line-height: 14px; }';
- css += paypalInput + '.large { padding: 4px 19px; font-size: 14px; line-height: 16px; }';
+ css += paypalInput + '.small { padding: 3px 15px; font-size: 12px; }';
+ css += paypalInput + '.large { padding: 4px 19px; font-size: 14px; }';
styleEl.type = 'text/css';
styleEl.id = 'paypal-button';
View
28 test/index.html
@@ -13,7 +13,7 @@
data-name="Buy now!"
data-amount="1.00"
data-size="small"
- data-callback="http://example.com/callback"
+ data-callback="http://example.com/callback"
></script>
</div>
@@ -28,18 +28,18 @@
<div id="buynow-es_ES">
<h2>Buy Now (Large/Spanish)</h2>
- <script src="../src/paypal-button.js?merchant=6XF3MPZBZV6HU"
+ <script src="../dist/paypal-button.js?merchant=6XF3MPZBZV6HU"
data-button="buynow"
data-name="Buy now!"
data-amount="1.00"
data-locale="es_ES"
- data-currency_code="EUR"
+ data-currency="EUR"
></script>
</div>
<div id="buynow-ja_JP">
<h2>Buy Now (Large/Japanese)</h2>
- <script src="../src/paypal-button.js?merchant=6XF3MPZBZV6HU"
+ <script src="../dist/paypal-button.js?merchant=6XF3MPZBZV6HU"
data-button="buynow"
data-name="Buy now!"
data-amount="1.00"
@@ -49,18 +49,18 @@
<div id="buynow-de_DE">
<h2>Buy Now (Large/German)</h2>
- <script src="../src/paypal-button.js?merchant=6XF3MPZBZV6HU"
+ <script src="../dist/paypal-button.js?merchant=6XF3MPZBZV6HU"
data-button="buynow"
data-name="Buy now!"
data-amount="1.00"
data-locale="de_DE"
- data-currency_code="EUR"
+ data-currency="EUR"
></script>
</div>
<div id="buynow-editable">
<h2>Buy Now (Large/Editable/English)</h2>
- <script src="../src/paypal-button.js?merchant=6XF3MPZBZV6HU"
+ <script src="../dist/paypal-button.js?merchant=6XF3MPZBZV6HU"
data-button="buynow"
data-name-editable="Buy now!"
data-amount-editable="1.00"
@@ -71,7 +71,7 @@
<div id="cart-sm">
<h2>Cart (Small/Italian)</h2>
- <script src="../src/paypal-button.js?merchant=6XF3MPZBZV6HU"
+ <script src="../dist/paypal-button.js?merchant=6XF3MPZBZV6HU"
data-button="cart"
data-name="Add to cart!"
data-amount="1.00"
@@ -82,7 +82,7 @@
<div id="cart-lg">
<h2>Cart (Large/English)</h2>
- <script src="../src/paypal-button.js?merchant=6XF3MPZBZV6HU"
+ <script src="../dist/paypal-button.js?merchant=6XF3MPZBZV6HU"
data-button="cart"
data-name="Add to cart!"
data-amount="1.00"
@@ -92,7 +92,7 @@
<div id="donate-sm">
<h2>Donate (Small/English)</h2>
- <script src="../src/paypal-button.js?merchant=6XF3MPZBZV6HU"
+ <script src="../dist/paypal-button.js?merchant=6XF3MPZBZV6HU"
data-button="donate"
data-name="Donate!"
data-amount="1.00"
@@ -102,7 +102,7 @@
<div id="donate-lg">
<h2>Donate (Large/English)</h2>
- <script src="../src/paypal-button.js?merchant=6XF3MPZBZV6HU"
+ <script src="../dist/paypal-button.js?merchant=6XF3MPZBZV6HU"
data-button="donate"
data-name="Donate!"
data-amount="1.00"
@@ -112,7 +112,7 @@
<div id="subscribe-sm">
<h2>Subscribe (Small/English)</h2>
- <script src="../src/paypal-button.js?merchant=6XF3MPZBZV6HU"
+ <script src="../dist/paypal-button.js?merchant=6XF3MPZBZV6HU"
data-button="subscribe"
data-name="Subscribe!"
data-size="small"
@@ -124,7 +124,7 @@
<div id="subscribe-lg">
<h2>Subscribe (Large/English)</h2>
- <script src="../src/paypal-button.js?merchant=6XF3MPZBZV6HU"
+ <script src="../dist/paypal-button.js?merchant=6XF3MPZBZV6HU"
data-button="subscribe"
data-name="Subscribe!"
data-amount="1.00"
@@ -135,7 +135,7 @@
<div id="qr">
<h2>QR Code</h2>
- <script src="../src/paypal-button.js?merchant=6XF3MPZBZV6HU"
+ <script src="../dist/paypal-button.js?merchant=6XF3MPZBZV6HU"
data-button="qr"
data-name="Buy from a QR code!"
data-amount="1.00"
Please sign in to comment.
Something went wrong with that request. Please try again.