From 8020b5d2d73f13def10f40cea579892818ef2ad6 Mon Sep 17 00:00:00 2001 From: marstuart Date: Thu, 31 Jan 2013 22:24:56 -0800 Subject: [PATCH 1/7] Converted the script include to an async format. Converted
-

Buy Now (Small)

- +

Buy Now (Small)

+ + Check Out with PayPal
- +
-

Buy Now (Large)

- +

Buy Now (Large)

+ + Check Out with PayPal
- +
-

Buy Now (Spanish)

- +

Buy Now (Spanish)

+ + Check Out with PayPal
- +
-

Buy Now (French)

- +

Buy Now (French)

+ + Check Out with PayPal
- +
-

Buy Now (German)

- +

Buy Now (German)

+ + Check Out with PayPal
- +
-

Buy Now (Editable)

- +

Buy Now (Editable)

+ + Check Out with PayPal
- +
-

Cart (Small)

- +

Cart (Small)

+ + Check Out with PayPal
- +
-

Cart (Large)

- -
+

Cart (Large)

+ Check Out with PayPal + +
-

Hosted (Small)

- + data-id="8R63A645E2QB6" + data-size="small" + >Check Out with PayPal
- +
-

Hosted

- + data-id="8R63A645E2QB6" + >Check Out with PayPal
- +

QR Code

- + >Check Out with PayPal
+ + \ No newline at end of file From aa63a9d5e43bd567ed4061f88ff25cb21d7add53 Mon Sep 17 00:00:00 2001 From: mstuart Date: Thu, 31 Jan 2013 22:45:09 -0800 Subject: [PATCH 2/7] whoops. ripped out href from my own testing. --- test/index.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/index.html b/test/index.html index c7507eb..12090a3 100644 --- a/test/index.html +++ b/test/index.html @@ -11,8 +11,7 @@

Buy Now (Small)

- Date: Fri, 1 Feb 2013 00:26:19 -0800 Subject: [PATCH 3/7] buttons are now image-less and using css. definitely a 1st cut though. need to clean up the CSS a bit, do more cross-browser testing, etc. --- src/paypal-button.js | 61 ++++++++++++++++++++++++++++++++++++++++---- test/index.html | 12 +++++++++ 2 files changed, 68 insertions(+), 5 deletions(-) diff --git a/src/paypal-button.js b/src/paypal-button.js index d811d58..29e5328 100644 --- a/src/paypal-button.js +++ b/src/paypal-button.js @@ -24,6 +24,24 @@ PAYPAL.apps = PAYPAL.apps || {}; buttonImgs = { buynow: '//www.paypalobjects.com/{locale}/i/btn/btn_buynow_{size}.gif', cart: '//www.paypalobjects.com/{locale}/i/btn/btn_cart_{size}.gif' + }, + buttonText = { + en_US: { + buynow: 'Buy Now', + cart: 'Add to Cart' + }, + es_ES: { + buynow: 'Comporar ahora', + cart: 'Añadir al carro' + }, + fr_FR: { + buynow: 'Acheter', + cart: 'Ajouter au panier' + }, + de_DE: { + buynow: 'Jetzt kaufen', + cart: 'In den Warenkorb' + } }; if (!PAYPAL.apps.ButtonFactory) { @@ -96,6 +114,9 @@ PAYPAL.apps = PAYPAL.apps || {}; } else { button = buildForm(data, type); } + + // Inject CSS + injectCSS(); // Register it this.buttons[type] += 1; @@ -122,12 +143,12 @@ 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; - btn.type = 'image'; + btn.type = 'submit'; hidden.type = 'hidden'; form.method = 'post'; form.action = paypalURL; @@ -161,11 +182,14 @@ PAYPAL.apps = PAYPAL.apps || {}; form.appendChild(child); } - size = items.size && items.size.value; - locale = items.lc && items.lc.value; + size = items.size ? items.size.value : "large"; + locale = items.lc ? items.lc.value : "en_US"; + //btn.src = getButtonImg(type, size, locale); + btn.className = "paypal-button " + size; + btn.innerHTML = buttonText[locale][items.button.value]; + form.appendChild(btn); - btn.src = getButtonImg(type, size, locale); // If the Mini Cart is present then register the form if (PAYPAL.apps.MiniCart && data.cmd === '_cart') { @@ -180,6 +204,33 @@ PAYPAL.apps = PAYPAL.apps || {}; return form; } + + /** + * Injects button CSS in the + * + * @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); + } /** diff --git a/test/index.html b/test/index.html index 12090a3..eab900f 100644 --- a/test/index.html +++ b/test/index.html @@ -7,6 +7,9 @@ + + +

Buy Now (Small)

@@ -17,6 +20,7 @@ data-amount="1.00" data-size="small" >Check Out with PayPal +
@@ -27,6 +31,7 @@ data-name="Buy now!" data-amount="1.00" >Check Out with PayPal +
@@ -38,6 +43,8 @@ data-amount="1.00" data-lang="es_ES" >Check Out with PayPal + +
@@ -49,6 +56,7 @@ data-amount="1.00" data-lang="fr_FR" >Check Out with PayPal +
@@ -60,6 +68,7 @@ data-amount="1.00" data-lang="de_DE" >Check Out with PayPal +
@@ -72,6 +81,7 @@ data-quantity-editable="1" data-lang="en_US" >Check Out with PayPal +
@@ -83,6 +93,7 @@ data-amount="1.00" data-size="small" >Check Out with PayPal +
@@ -94,6 +105,7 @@ data-amount="1.00" data-size="large" >Check Out with PayPal +
From f6059162a94e3a3c10da7ae994228f3358b157eb Mon Sep 17 00:00:00 2001 From: mstuart Date: Fri, 1 Feb 2013 00:32:43 -0800 Subject: [PATCH 4/7] converting special chars to entities. --- src/paypal-button.js | 2 +- test/index.html | 12 ------------ 2 files changed, 1 insertion(+), 13 deletions(-) diff --git a/src/paypal-button.js b/src/paypal-button.js index 29e5328..887c8a9 100644 --- a/src/paypal-button.js +++ b/src/paypal-button.js @@ -32,7 +32,7 @@ PAYPAL.apps = PAYPAL.apps || {}; }, es_ES: { buynow: 'Comporar ahora', - cart: 'Añadir al carro' + cart: 'Añadir al carro' }, fr_FR: { buynow: 'Acheter', diff --git a/test/index.html b/test/index.html index eab900f..12090a3 100644 --- a/test/index.html +++ b/test/index.html @@ -7,9 +7,6 @@ - - -

Buy Now (Small)

@@ -20,7 +17,6 @@ data-amount="1.00" data-size="small" >Check Out with PayPal -
@@ -31,7 +27,6 @@ data-name="Buy now!" data-amount="1.00" >Check Out with PayPal -
@@ -43,8 +38,6 @@ data-amount="1.00" data-lang="es_ES" >Check Out with PayPal - -
@@ -56,7 +49,6 @@ data-amount="1.00" data-lang="fr_FR" >Check Out with PayPal -
@@ -68,7 +60,6 @@ data-amount="1.00" data-lang="de_DE" >Check Out with PayPal -
@@ -81,7 +72,6 @@ data-quantity-editable="1" data-lang="en_US" >Check Out with PayPal -
@@ -93,7 +83,6 @@ data-amount="1.00" data-size="small" >Check Out with PayPal -
@@ -105,7 +94,6 @@ data-amount="1.00" data-size="large" >Check Out with PayPal -
From aa3548255f62db79b6b00c3103338cfda9a9f237 Mon Sep 17 00:00:00 2001 From: mstuart Date: Fri, 1 Feb 2013 00:49:42 -0800 Subject: [PATCH 5/7] converted anchors to buttons. --- src/paypal-button.js | 2 +- test/index.html | 44 ++++++++++++++++++++++---------------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/paypal-button.js b/src/paypal-button.js index 887c8a9..d7de824 100644 --- a/src/paypal-button.js +++ b/src/paypal-button.js @@ -338,7 +338,7 @@ PAYPAL.apps = PAYPAL.apps || {}; } return function (attr) { - var elems = document.body.getElementsByTagName('a*'), + var elems = document.body.getElementsByTagName('button'), match = [], elem, i; diff --git a/test/index.html b/test/index.html index 12090a3..71b5622 100644 --- a/test/index.html +++ b/test/index.html @@ -11,119 +11,119 @@

Buy Now (Small)

- Check Out with PayPal + >

Buy Now (Large)

- Check Out with PayPal + >

Buy Now (Spanish)

- Check Out with PayPal + >

Buy Now (French)

- Check Out with PayPal + >

Buy Now (German)

- Check Out with PayPal + >

Buy Now (Editable)

- Check Out with PayPal + >

Cart (Small)

- Check Out with PayPal + >

Cart (Large)

- Check Out with PayPal + >

Hosted (Small)

- Check Out with PayPal + >

Hosted

- Check Out with PayPal + >

QR Code

- Check Out with PayPal + >
+``` + We have a few flavors of buttons for you to use: ### Buy Now Buy Now buttons are for single item purchases. ```html - + data-amount="1.00" +> ``` @@ -20,21 +39,21 @@ Buy Now buttons are for single item purchases. Add To Cart buttons lets users add multiple items to their PayPal cart. ```html - +> ``` ### Hosted Hosted buttons help tamper-proof your button's data. ```html - +> ``` *Note: Hosted buttons IDs must be created on PayPal.com or via the Button Manager APIs using your credentials.* @@ -43,14 +62,12 @@ Hosted buttons help tamper-proof your button's data. QR codes which can be scanned with a smart phone can also be easily generated. ```html - +> ``` - ## Button variables All of PayPal's [HTML button variables](https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_html_Appx_websitestandard_htmlvariables) are supported by prefixing their name with "data-". Here are the most commonly used: @@ -107,7 +124,7 @@ The JavaScript buttons have been tested and work in all modern browsers includin ## Getting your Merchant ID -Your merchant ID needs to be added to the URL of the referenced script. This ID can either be your Secure Merchant ID, which can be found by logging into your PayPal account and visiting your profile, or your email address. +Your merchant ID needs to be added to the top of the referenced script. This ID can either be your Secure Merchant ID, which can be found by logging into your PayPal account and visiting your profile, or your email address. ## Contributing From 8fabdff971b060594508f581b28beaa05c6296b2 Mon Sep 17 00:00:00 2001 From: mstuart Date: Mon, 18 Feb 2013 20:11:56 -0800 Subject: [PATCH 7/7] Moved merchant ID to the top of the async snippet. Removed an unnecessary JSHint global. Removed some dead code that was commented. --- dist/paypal-button-minicart.min.js | 4 ++-- dist/paypal-button.min.js | 4 ++-- src/paypal-button.js | 3 +-- test/index.html | 9 ++++++--- 4 files changed, 11 insertions(+), 9 deletions(-) diff --git a/dist/paypal-button-minicart.min.js b/dist/paypal-button-minicart.min.js index 0c12237..7235deb 100644 --- a/dist/paypal-button-minicart.min.js +++ b/dist/paypal-button-minicart.min.js @@ -1,7 +1,7 @@ /*! * PayPalJSButtons * JavaScript integration for PayPal's payment buttons - * @version 1.0.0 - 2013-01-24, 5:42:15 PM + * @version 1.0.0 - 2013-02-18, 8:09:56 PM * @author Jeff Harrell */ -if(typeof PAYPAL=="undefined"||!PAYPAL)var PAYPAL={};PAYPAL.apps=PAYPAL.apps||{},function(){"use strict";var config={parent:document.body,displayEdge:"right",edgeDistance:"50px",formTarget:null,cookiePath:"/",strings:{button:"",subtotal:"",discount:"",shipping:"",processing:""},name:"PPMiniCart",peekEnabled:!0,paypalURL:"https://www.paypal.com/cgi-bin/webscr",assetURL:"http://www.minicartjs.com/build/",events:{onRender:null,afterRender:null,onHide:null,afterHide:null,onShow:null,afterShow:null,onAddToCart:null,afterAddToCart:null,onRemoveFromCart:null,afterRemoveFromCart:null,onCheckout:null,onReset:null,afterReset:null}};PAYPAL.apps.MiniCart=function(){var e={},t=!1,n=!1,r={_cart:!0,_xclick:!0},i="MiniCart_AddToCart_WPS_US",s=/^(?:business|currency_code|lc|paymentaction|no_shipping|cn|no_note|invoice|handling_cart|weight_cart|weight_unit|tax_cart|page_style|image_url|cpp_|cs|cbt|return|cancel_return|notify_url|rm|custom|charset)/,o=function(){var e=config.name,t=[],n,r;t.push("#"+e+" form { position:fixed; float:none; top:-250px; "+config.displayEdge+":"+config.edgeDistance+"; width:265px; margin:0; padding:50px 10px 0; min-height:170px; background:#fff url("+config.assetURL+"images/minicart_sprite.png) no-repeat -125px -60px; border:1px solid #999; border-top:0; font:13px/normal arial, helvetica; color:#333; text-align:left; -moz-border-radius:0 0 8px 8px; -webkit-border-radius:0 0 8px 8px; border-radius:0 0 8px 8px; -moz-box-shadow:1px 1px 1px rgba(0, 0, 0, 0.1); -webkit-box-shadow:1px 1px 1px rgba(0, 0, 0, 0.1); box-shadow:1px 1px 1px rgba(0, 0, 0, 0.1); } "),t.push("#"+e+" ul { position:relative; overflow-x:hidden; overflow-y:auto; height:130px; margin:0 0 7px; padding:0; list-style-type:none; border-top:1px solid #ccc; border-bottom:1px solid #ccc; } "),t.push("#"+e+" li { position:relative; margin:-1px 0 0; padding:6px 5px 6px 0; border-top:1px solid #f2f2f2; } "),t.push("#"+e+" li a { display: block; width: 155px; color:#333; text-decoration:none; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; } "),t.push("#"+e+" li a span { color:#999; font-size:10px; } "),t.push("#"+e+" li .quantity { position:absolute; top:.5em; right:78px; width:22px; padding:1px; border:1px solid #83a8cc; text-align:right; } "),t.push("#"+e+" li .price { position:absolute; top:.5em; right:4px; } "),t.push("#"+e+" li .remove { position:absolute; top:9px; right:60px; width:14px; height:14px; background:url("+config.assetURL+"images/minicart_sprite.png) no-repeat -134px -4px; border:0; cursor:pointer; } "),t.push("#"+e+" p { margin:0; padding:0 0 0 20px; background:url("+config.assetURL+"images/minicart_sprite.png) no-repeat; font-size:13px; font-weight:bold; } "),t.push("#"+e+" p:hover { cursor:pointer; } "),t.push("#"+e+" p input { float:right; margin:4px 0 0; padding:1px 4px; text-decoration:none; font-weight:normal; color:#333; background:#ffa822 url("+config.assetURL+"images/minicart_sprite.png) repeat-x left center; border:1px solid #d5bd98; border-right-color:#935e0d; border-bottom-color:#935e0d; -moz-border-radius:2px; -webkit-border-radius:2px; border-radius:2px; } "),t.push("#"+e+" p .shipping { display:block; font-size:10px; font-weight:normal; color:#999; } "),n=document.createElement("style"),n.type="text/css",n.styleSheet?n.styleSheet.cssText=t.join(""):n.appendChild(document.createTextNode(t.join(""))),r=document.getElementsByTagName("head")[0],r.appendChild(n)},u=function(){var t=e.UI,n,r,s,o,u;t.wrapper=document.createElement("div"),t.wrapper.id=config.name,n=document.createElement("input"),n.type="hidden",n.name="cmd",n.value="_cart",r=n.cloneNode(!1),r.name="upload",r.value="1",s=n.cloneNode(!1),s.name="bn",s.value=i,t.cart=document.createElement("form"),t.cart.method="post",t.cart.action=config.paypalURL,config.formTarget&&(t.cart.target=config.formTarget),t.cart.appendChild(n),t.cart.appendChild(r),t.cart.appendChild(s),t.wrapper.appendChild(t.cart),t.itemList=document.createElement("ul"),t.cart.appendChild(t.itemList),t.summary=document.createElement("p"),t.cart.appendChild(t.summary),t.button=document.createElement("input"),t.button.type="submit",t.button.value=config.strings.button||"Checkout",t.summary.appendChild(t.button),t.subtotal=document.createElement("span"),t.subtotal.innerHTML=config.strings.subtotal||"Subtotal: ",t.subtotalAmount=document.createElement("span"),t.subtotalAmount.innerHTML="0.00",t.subtotal.appendChild(t.subtotalAmount),t.summary.appendChild(t.subtotal),t.shipping=document.createElement("span"),t.shipping.className="shipping",t.shipping.innerHTML=config.strings.shipping||"does not include shipping & tax",t.summary.appendChild(t.shipping);if(window.attachEvent&&!window.opera){u=navigator.userAgent.match(/MSIE\s([^;]*)/);if(u){u=parseFloat(u[1]);if(u<7||u>=7&&document.compatMode==="BackCompat")t.cart.style.position="absolute",t.wrapper.style[config.displayEdge]="0",t.wrapper.style.setExpression("top","x = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop")}}o=typeof config.parent=="string"?document.getElementById(config.parent):config.parent,o.appendChild(t.wrapper)},a=function(){var n=e.UI,i,s,o;i=document.getElementsByTagName("form");for(o=0;o=15){r.style.backgroundColor="transparent",i==="0.00"&&e.hide(null,!0);return}setTimeout(c,30)}()},e.show=function(n){var r=parseInt(e.UI.cart.offsetTop,10),i=0,s=config.events,o=s.onShow,u=s.afterShow;n&&n.preventDefault&&n.preventDefault();if(typeof o=="function"&&o.call(e,n)===!1)return;$.util.animate(e.UI.cart,"top",{from:r,to:i},function(){typeof u=="function"&&u.call(e,n)}),e.UI.summary.style.backgroundPosition="-195px 2px",t=!0},e.hide=function(n,r){var i=e.UI,s=i.cart,o=i.summary,u=s.offsetHeight?s.offsetHeight:document.defaultView.getComputedStyle(s,"").getPropertyValue("height"),a=o.offsetHeight?o.offsetHeight:document.defaultView.getComputedStyle(o,"").getPropertyValue("height"),f=parseInt(s.offsetTop,10),l=config.events,c=l.onHide,h=l.afterHide,p;r||e.products.length===0||!config.peekEnabled?p=u*-1:p=(u-a-8)*-1,n&&n.preventDefault&&n.preventDefault();if(typeof c=="function"&&c.call(e,n)===!1)return;$.util.animate(s,"top",{from:f,to:p},function(){typeof h=="function"&&h.call(e,n)}),o.style.backgroundPosition="-195px -32px",t=!1},e.toggle=function(n){t?e.hide(n):e.show(n)},e.reset=function(){var n=e.UI,r=config.events,i=r.onReset,s=r.afterReset;if(typeof i=="function"&&i.call(e)===!1)return;e.products=[],t&&(n.itemList.innerHTML="",n.subtotalAmount.innerHTML="",e.hide(null,!0)),$.storage.remove(),typeof s=="function"&&s.call(e)},e}();var ProductNode=function(e,t){this._view(e,t)};ProductNode.prototype={_view:function(e,t){var n,r,i,s,o,u,a;this.product=e.product,this.settings=e.settings,this.liNode=document.createElement("li"),this.nameNode=document.createElement("a"),this.metaNode=document.createElement("span"),this.discountNode=document.createElement("span"),this.discountInput=document.createElement("input"),this.priceNode=document.createElement("span"),this.quantityInput=document.createElement("input"),this.removeInput=document.createElement("input");if(!this.product||!this.product.item_name&&!this.product.item_number){this.isPlaceholder=!0;return}this.product.item_name&&(n=this.product.item_name),this.nameNode.innerHTML=n,this.nameNode.title=n,this.nameNode.href=this.product.href,this.nameNode.appendChild(this.metaNode),this.product.item_number&&(this.metaNode.innerHTML="
#"+this.product.item_number),o=this.getOptions();for(a in o)this.metaNode.innerHTML+="
"+a+": "+o[a];s=this.getDiscount(),this.discountInput.type="hidden",this.discountInput.name="discount_amount_"+t,this.discountInput.value=s,this.metaNode.appendChild(this.discountNode),r=this.getPrice(),this.priceNode.className="price",i=this.getQuantity(),this.quantityInput.name="quantity_"+t,this.quantityInput.className="quantity",this.quantityInput.setAttribute("autocomplete","off"),this.setQuantity(i),this.removeInput.type="button",this.removeInput.className="remove",this.liNode.appendChild(this.nameNode),this.liNode.appendChild(this.quantityInput),this.liNode.appendChild(this.discountInput),this.liNode.appendChild(this.removeInput),this.liNode.appendChild(this.priceNode);for(a in this.product)a!=="quantity"&&a.indexOf("discount_")===-1&&(u=document.createElement("input"),u.type="hidden",u.name=a+"_"+t,u.value=this.product[a],this.liNode.appendChild(u))},getDiscount:function(){var e=0,t=this.product.discount_num||-1,n;return this.product.discount_amount?(e=parseFloat(this.product.discount_amount),this.product.discount_amount2&&(n=this.getQuantity(),n>1&&(e+=Math.max(n-1,t)*parseFloat(this.product.discount_amount2)))):this.product.discount_rate&&(e=this.product.amount*parseFloat(this.product.discount_rate)/100,this.product.discount_rate2&&(n=this.getQuantity(),n>1&&(e+=Math.max(n-1,t)*this.product.amount*parseFloat(this.product.discount_amount2)/100))),e&&e.toFixed(2)},getOptions:function(){var e={},t=0;while(typeof this.product["on"+t]!="undefined")e[this.product["on"+t]]=this.product["os"+t],t++;return e},setQuantity:function(e){var t;e=parseInt(e,10),this.product.quantity=e;if(this.quantityInput.value!==e){this.quantityInput.value=e;if(t=this.getDiscount())this.discountInput.value=t,this.discountNode.innerHTML="
",this.discountNode.innerHTML+=config.strings.discount||"Discount: ",this.discountNode.innerHTML+=$.util.formatCurrency(t,this.settings.currency_code)}this.setPrice(this.product.amount*e)},getQuantity:function(){return typeof this.product.quantity!==undefined?this.product.quantity:1},setPrice:function(e){e=parseFloat(e,10),this.priceNode.innerHTML=$.util.formatCurrency(e.toFixed(2),this.settings.currency_code)},getPrice:function(){return(this.product.amount*this.getQuantity()).toFixed(2)}};var $={};$.storage=function(){var e=config.name;return window.localStorage?{load:function(){var t=localStorage.getItem(e);return t&&(t=JSON.parse(decodeURIComponent(t))),t},save:function(t){var n=[],r,i,s;if(t){for(s=0,i=t.length;s0&&s>n.to||i<0&&s=7&&document.compatMode==="BackCompat")t.cart.style.position="absolute",t.wrapper.style[config.displayEdge]="0",t.wrapper.style.setExpression("top","x = document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop")}}o=typeof config.parent=="string"?document.getElementById(config.parent):config.parent,o.appendChild(t.wrapper)},a=function(){var n=e.UI,i,s,o;i=document.getElementsByTagName("form");for(o=0;o=15){r.style.backgroundColor="transparent",i==="0.00"&&e.hide(null,!0);return}setTimeout(c,30)}()},e.show=function(n){var r=parseInt(e.UI.cart.offsetTop,10),i=0,s=config.events,o=s.onShow,u=s.afterShow;n&&n.preventDefault&&n.preventDefault();if(typeof o=="function"&&o.call(e,n)===!1)return;$.util.animate(e.UI.cart,"top",{from:r,to:i},function(){typeof u=="function"&&u.call(e,n)}),e.UI.summary.style.backgroundPosition="-195px 2px",t=!0},e.hide=function(n,r){var i=e.UI,s=i.cart,o=i.summary,u=s.offsetHeight?s.offsetHeight:document.defaultView.getComputedStyle(s,"").getPropertyValue("height"),a=o.offsetHeight?o.offsetHeight:document.defaultView.getComputedStyle(o,"").getPropertyValue("height"),f=parseInt(s.offsetTop,10),l=config.events,c=l.onHide,h=l.afterHide,p;r||e.products.length===0||!config.peekEnabled?p=u*-1:p=(u-a-8)*-1,n&&n.preventDefault&&n.preventDefault();if(typeof c=="function"&&c.call(e,n)===!1)return;$.util.animate(s,"top",{from:f,to:p},function(){typeof h=="function"&&h.call(e,n)}),o.style.backgroundPosition="-195px -32px",t=!1},e.toggle=function(n){t?e.hide(n):e.show(n)},e.reset=function(){var n=e.UI,r=config.events,i=r.onReset,s=r.afterReset;if(typeof i=="function"&&i.call(e)===!1)return;e.products=[],t&&(n.itemList.innerHTML="",n.subtotalAmount.innerHTML="",e.hide(null,!0)),$.storage.remove(),typeof s=="function"&&s.call(e)},e}();var ProductNode=function(e,t){this._view(e,t)};ProductNode.prototype={_view:function(e,t){var n,r,i,s,o,u,a;this.product=e.product,this.settings=e.settings,this.liNode=document.createElement("li"),this.nameNode=document.createElement("a"),this.metaNode=document.createElement("span"),this.discountNode=document.createElement("span"),this.discountInput=document.createElement("input"),this.priceNode=document.createElement("span"),this.quantityInput=document.createElement("input"),this.removeInput=document.createElement("input");if(!this.product||!this.product.item_name&&!this.product.item_number){this.isPlaceholder=!0;return}this.product.item_name&&(n=this.product.item_name),this.nameNode.innerHTML=n,this.nameNode.title=n,this.nameNode.href=this.product.href,this.nameNode.appendChild(this.metaNode),this.product.item_number&&(this.metaNode.innerHTML="
#"+this.product.item_number),o=this.getOptions();for(a in o)this.metaNode.innerHTML+="
"+a+": "+o[a];s=this.getDiscount(),this.discountInput.type="hidden",this.discountInput.name="discount_amount_"+t,this.discountInput.value=s,this.metaNode.appendChild(this.discountNode),r=this.getPrice(),this.priceNode.className="price",i=this.getQuantity(),this.quantityInput.name="quantity_"+t,this.quantityInput.className="quantity",this.quantityInput.setAttribute("autocomplete","off"),this.setQuantity(i),this.removeInput.type="button",this.removeInput.className="remove",this.liNode.appendChild(this.nameNode),this.liNode.appendChild(this.quantityInput),this.liNode.appendChild(this.discountInput),this.liNode.appendChild(this.removeInput),this.liNode.appendChild(this.priceNode);for(a in this.product)a!=="quantity"&&a.indexOf("discount_")===-1&&(u=document.createElement("input"),u.type="hidden",u.name=a+"_"+t,u.value=this.product[a],this.liNode.appendChild(u))},getDiscount:function(){var e=0,t=this.product.discount_num||-1,n;return this.product.discount_amount?(e=parseFloat(this.product.discount_amount),this.product.discount_amount2&&(n=this.getQuantity(),n>1&&(e+=Math.max(n-1,t)*parseFloat(this.product.discount_amount2)))):this.product.discount_rate&&(e=this.product.amount*parseFloat(this.product.discount_rate)/100,this.product.discount_rate2&&(n=this.getQuantity(),n>1&&(e+=Math.max(n-1,t)*this.product.amount*parseFloat(this.product.discount_amount2)/100))),e&&e.toFixed(2)},getOptions:function(){var e={},t=0;while(typeof this.product["on"+t]!="undefined")e[this.product["on"+t]]=this.product["os"+t],t++;return e},setQuantity:function(e){var t;e=parseInt(e,10),this.product.quantity=e;if(this.quantityInput.value!==e){this.quantityInput.value=e;if(t=this.getDiscount())this.discountInput.value=t,this.discountNode.innerHTML="
",this.discountNode.innerHTML+=config.strings.discount||"Discount: ",this.discountNode.innerHTML+=$.util.formatCurrency(t,this.settings.currency_code)}this.setPrice(this.product.amount*e)},getQuantity:function(){return typeof this.product.quantity!==undefined?this.product.quantity:1},setPrice:function(e){e=parseFloat(e,10),this.priceNode.innerHTML=$.util.formatCurrency(e.toFixed(2),this.settings.currency_code)},getPrice:function(){return(this.product.amount*this.getQuantity()).toFixed(2)}};var $={};$.storage=function(){var e=config.name;return window.localStorage?{load:function(){var t=localStorage.getItem(e);return t&&(t=JSON.parse(decodeURIComponent(t))),t},save:function(t){var n=[],r,i,s;if(t){for(s=0,i=t.length;s0&&s>n.to||i<0&&s-1;i--)r=t[i],r.getAttribute(e)&&n.push(t);return n}}function v(e){function i(e,t){t(e),e=e.firstChild;while(e)i(e,t),e=e.nextSibling}var t=[],n="data-paypal",r;return i(document.body,function(i){i.nodeType===1&&(r=i.getAttribute(n))&&r===e&&t.push(i)}),t}function m(){var e=document.getElementsByTagName("script"),t,n,r,i,s,o;for(s=0,o=e.length;s */ -if(typeof PAYPAL=="undefined"||!PAYPAL)var PAYPAL={};PAYPAL.apps=PAYPAL.apps||{},function(){"use strict";function u(n,r){var i=document.createElement("form"),s=document.createElement("input"),o=document.createElement("input"),u=n.items,a,l,c,h,p,d,v;s.type="image",o.type="hidden",i.method="post",i.action=t,i.className="paypal-button",i.target="_top";for(p in u)a=u[p],a.isEditable?(h=document.createElement("input"),h.type="text",h.className="paypal-input",h.name=a.key,h.value=a.value,c=document.createElement("label"),c.className="paypal-label",c.appendChild(document.createTextNode(e.config.labels[a.key]+" "||"")),c.appendChild(h),l=document.createElement("p"),l.className="paypal-group",l.appendChild(c)):(h=l=o.cloneNode(!0),h.name=a.key,h.value=a.value),i.appendChild(l);d=u.size&&u.size.value,v=u.lc&&u.lc.value,i.appendChild(s),s.src=f(r,d,v);if(PAYPAL.apps.MiniCart&&n.cmd==="_cart"){var m=PAYPAL.apps.MiniCart;m.UI.itemList||m.render(),m.bindForm(i)}return i}function a(e,r,i){var s=document.createElement("img"),o=t+"?",u=13,a=e.items,f,l;r=r.value||250;for(l in a)f=a[l],o+=f.key+"="+encodeURIComponent(f.value)+"&";return o=encodeURIComponent(o),s.src=n.replace("{url}",o).replace("{pattern}",u).replace("{size}",r),s}function f(e,t,n){var r=o[e]||o.buynow;return n=n||"en_US",t=t==="small"?"SM":"LG",r.replace(/\{locale\}/,n).replace(/\{size\}/,t)}function l(e){var t={},n,r,i,s,o;if(n=e.attributes)for(o=0,s=n.length;o-1;i--)r=t[i],r.getAttribute(e)&&n.push(t);return n}}function v(e){function i(e,t){t(e),e=e.firstChild;while(e)i(e,t),e=e.nextSibling}var t=[],n="data-paypal",r;return i(document.body,function(i){i.nodeType===1&&(r=i.getAttribute(n))&&r===e&&t.push(i)}),t}function m(){var e=document.getElementsByTagName("script"),t,n,r,i,s,o;for(s=0,o=e.length;sQR Code