From 1c22c57023292a8f3eecf89561295b76820b9907 Mon Sep 17 00:00:00 2001 From: mstuart Date: Tue, 12 Mar 2013 22:08:56 -0700 Subject: [PATCH 01/16] Removed dead code for deprecated hosted buttons. --- dist/paypal-button-minicart.min.js | 4 ++-- dist/paypal-button.min.js | 4 ++-- src/paypal-button.js | 8 +------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/dist/paypal-button-minicart.min.js b/dist/paypal-button-minicart.min.js index 92b73bb..b3f1bd8 100644 --- a/dist/paypal-button-minicart.min.js +++ b/dist/paypal-button-minicart.min.js @@ -1,6 +1,6 @@ /*! * PayPalJSButtons * JavaScript integration for PayPal's payment buttons - * @version 1.0.0 - 2013-03-10, 11:42:12 PM + * @version 1.0.0 - 2013-03-12, 10:08:30 PM * @author Jeff Harrell - */if(PAYPAL===void 0||!PAYPAL)var PAYPAL={};PAYPAL.apps=PAYPAL.apps||{},function(){"use strict";function e(e,t){var n,i,r,l,s,d,p,u=document.createElement("form"),m=document.createElement("input"),b=document.createElement("input"),y=e.items;m.type="image",b.type="hidden",u.method="post",u.action=c,u.className="paypal-button",u.target="_top";for(s in y)n=y[s],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(o.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),u.appendChild(i);if(d=y.size&&y.size.value,p=y.lc&&y.lc.value,u.appendChild(m),m.src=a(t,d,p),PAYPAL.apps.MiniCart&&"_cart"===e.items.cmd.value){var f=PAYPAL.apps.MiniCart;f.UI.itemList||f.render(),f.bindForm(u)}return u}function t(e,t){var a,n,i=document.createElement("img"),o=c+"?",l=13,s=e.items;t=t&&t.value||250;for(n in s)a=s[n],o+=a.key+"="+encodeURIComponent(a.value)+"&";return o=encodeURIComponent(o),i.src=r.replace("{url}",o).replace("{pattern}",l).replace("{size}",t),i}function a(e,t,a){var n=d[e]||d.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,o,c={};if(t=e.attributes)for(o=0,i=t.length;i>o;o++)a=t[o],(n=/^data-([a-z0-9]+)(-editable)?/i.exec(a.name))&&(c[n[1]]={value:a.value,isEditable:!!n[2]});return c}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 o={},c="https://www.paypal.com/cgi-bin/webscr",r="https://www.paypal.com/webapps/ppint/qrcode?data={url}&pattern={pattern}&height={size}",l="JavaScriptButton_{type}",s={id:"hosted_button_id",name:"item_name",number:"item_number",lang:"lc"},d={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||(o.config={labels:{item_name:"Item",item_number:"Number",amount:"Amount",quantity:"Quantity"}},o.buttons={buynow:0,cart:0,hosted:0,donate:0,qr:0,subscribe:0},o.create=function(a,n,o,c){var r,d,p=new i;if(!a)return!1;for(d in n)p.add(s[d]||d,n[d].value,n[d].isEditable);return o=o||"buynow",p.items.hosted_button_id?(o="hosted",p.add("cmd","_s-xclick")):"cart"===o?(p.add("cmd","_cart"),p.add("add",!0)):"donate"===o?p.add("cmd","_donations"):"subscribe"===o?p.add("cmd","_xclick-subscriptions"):p.add("cmd","_xclick"),p.add("business",a),p.add("bn",l.replace(/\{type\}/,o)),"qr"===o?(r=t(p,p.items.size),p.remove("size")):r=e(p,o),this.buttons[o]+=1,c&&c.appendChild(r),r},PAYPAL.apps.ButtonFactory=o),"undefined"!=typeof document){var p,u,m,b,y,f,v=PAYPAL.apps.ButtonFactory,h=document.getElementsByTagName("script");for(y=0,f=h.length;f>y;y++)p=h[y],p&&p.src&&(u=p&&n(p),m=u&&u.button&&u.button.value,b=p.src.split("?merchant=")[1],b&&(v.create(b,u,m,p.parentNode),p.parentNode.removeChild(p)))}}(),"object"==typeof module&&"object"==typeof module.exports&&(module.exports=PAYPAL); \ No newline at end of file + */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",lang:"lc"},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.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); \ No newline at end of file diff --git a/dist/paypal-button.min.js b/dist/paypal-button.min.js index 92b73bb..fe307a8 100644 --- a/dist/paypal-button.min.js +++ b/dist/paypal-button.min.js @@ -1,6 +1,6 @@ /*! * PayPalJSButtons * JavaScript integration for PayPal's payment buttons - * @version 1.0.0 - 2013-03-10, 11:42:12 PM + * @version 1.0.0 - 2013-03-12, 10:08:29 PM * @author Jeff Harrell - */if(PAYPAL===void 0||!PAYPAL)var PAYPAL={};PAYPAL.apps=PAYPAL.apps||{},function(){"use strict";function e(e,t){var n,i,r,l,s,d,p,u=document.createElement("form"),m=document.createElement("input"),b=document.createElement("input"),y=e.items;m.type="image",b.type="hidden",u.method="post",u.action=c,u.className="paypal-button",u.target="_top";for(s in y)n=y[s],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(o.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),u.appendChild(i);if(d=y.size&&y.size.value,p=y.lc&&y.lc.value,u.appendChild(m),m.src=a(t,d,p),PAYPAL.apps.MiniCart&&"_cart"===e.items.cmd.value){var f=PAYPAL.apps.MiniCart;f.UI.itemList||f.render(),f.bindForm(u)}return u}function t(e,t){var a,n,i=document.createElement("img"),o=c+"?",l=13,s=e.items;t=t&&t.value||250;for(n in s)a=s[n],o+=a.key+"="+encodeURIComponent(a.value)+"&";return o=encodeURIComponent(o),i.src=r.replace("{url}",o).replace("{pattern}",l).replace("{size}",t),i}function a(e,t,a){var n=d[e]||d.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,o,c={};if(t=e.attributes)for(o=0,i=t.length;i>o;o++)a=t[o],(n=/^data-([a-z0-9]+)(-editable)?/i.exec(a.name))&&(c[n[1]]={value:a.value,isEditable:!!n[2]});return c}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 o={},c="https://www.paypal.com/cgi-bin/webscr",r="https://www.paypal.com/webapps/ppint/qrcode?data={url}&pattern={pattern}&height={size}",l="JavaScriptButton_{type}",s={id:"hosted_button_id",name:"item_name",number:"item_number",lang:"lc"},d={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||(o.config={labels:{item_name:"Item",item_number:"Number",amount:"Amount",quantity:"Quantity"}},o.buttons={buynow:0,cart:0,hosted:0,donate:0,qr:0,subscribe:0},o.create=function(a,n,o,c){var r,d,p=new i;if(!a)return!1;for(d in n)p.add(s[d]||d,n[d].value,n[d].isEditable);return o=o||"buynow",p.items.hosted_button_id?(o="hosted",p.add("cmd","_s-xclick")):"cart"===o?(p.add("cmd","_cart"),p.add("add",!0)):"donate"===o?p.add("cmd","_donations"):"subscribe"===o?p.add("cmd","_xclick-subscriptions"):p.add("cmd","_xclick"),p.add("business",a),p.add("bn",l.replace(/\{type\}/,o)),"qr"===o?(r=t(p,p.items.size),p.remove("size")):r=e(p,o),this.buttons[o]+=1,c&&c.appendChild(r),r},PAYPAL.apps.ButtonFactory=o),"undefined"!=typeof document){var p,u,m,b,y,f,v=PAYPAL.apps.ButtonFactory,h=document.getElementsByTagName("script");for(y=0,f=h.length;f>y;y++)p=h[y],p&&p.src&&(u=p&&n(p),m=u&&u.button&&u.button.value,b=p.src.split("?merchant=")[1],b&&(v.create(b,u,m,p.parentNode),p.parentNode.removeChild(p)))}}(),"object"==typeof module&&"object"==typeof module.exports&&(module.exports=PAYPAL); \ No newline at end of file + */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",lang:"lc"},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.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); \ No newline at end of file diff --git a/src/paypal-button.js b/src/paypal-button.js index 87376b9..dd2efbc 100644 --- a/src/paypal-button.js +++ b/src/paypal-button.js @@ -15,7 +15,6 @@ PAYPAL.apps = PAYPAL.apps || {}; qrCodeURL = 'https://www.paypal.com/webapps/ppint/qrcode?data={url}&pattern={pattern}&height={size}', bnCode = 'JavaScriptButton_{type}', prettyParams = { - id: 'hosted_button_id', name: 'item_name', number: 'item_number', lang: 'lc' @@ -47,7 +46,6 @@ PAYPAL.apps = PAYPAL.apps || {}; app.buttons = { buynow: 0, cart: 0, - hosted: 0, donate: 0, qr: 0, subscribe: 0 @@ -75,12 +73,8 @@ PAYPAL.apps = PAYPAL.apps || {}; // Defaults type = type || 'buynow'; - // Hosted buttons - if (data.items.hosted_button_id) { - type = 'hosted'; - data.add('cmd', '_s-xclick'); // Cart buttons - } else if (type === 'cart') { + if (type === 'cart') { data.add('cmd', '_cart'); data.add('add', true); // Donation buttons From 97bb32a979d8ae2d9f804cac3b2b89a7c1000390 Mon Sep 17 00:00:00 2001 From: Jeff Harrell Date: Fri, 15 Mar 2013 21:29:17 -0700 Subject: [PATCH 02/16] Updating tests --- Gruntfile.js | 23 +- dist/paypal-button-minicart.js | 2230 ++++++++++++++++++++++++++++ dist/paypal-button-minicart.min.js | 5 +- dist/paypal-button.js | 327 ++++ dist/paypal-button.min.js | 5 +- package.json | 59 +- test/index.html | 28 +- 7 files changed, 2626 insertions(+), 51 deletions(-) create mode 100644 dist/paypal-button-minicart.js create mode 100644 dist/paypal-button.js diff --git a/Gruntfile.js b/Gruntfile.js index 246e534..41f35c1 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -13,19 +13,35 @@ module.exports = function (grunt) { } } }, + concat: { + dist: { + src: [ "", "src/paypal-button.js" ], + dest: "dist/paypal-button.js", + options: { + banner: "/*!\n * <%= pkg.name %>\n * <%= pkg.description %>\n * @version <%= pkg.version %> - <%= grunt.template.today(\'yyyy-mm-dd\') %>\n * @author <%= pkg.author.name %> <<%= pkg.author.url %>>\n */\n" + } + }, + bundled: { + src: [ "", "lib/MiniCart/minicart.js", "src/paypal-button.js" ], + dest: "dist/paypal-button-minicart.js", + options: { + banner: "/*!\n * <%= pkg.name %>\n * <%= pkg.description %>\n * @version <%= pkg.version %> - <%= grunt.template.today(\'yyyy-mm-dd\') %>\n * @author <%= pkg.author.name %> <<%= pkg.author.url %>>\n */\n" + } + } + }, uglify: { dist: { src: [ "", "src/paypal-button.js" ], dest: "dist/paypal-button.min.js", options: { - banner: "/*!\n * <%= pkg.name %>\n * <%= pkg.description %>\n * @version <%= pkg.version %> - <%= grunt.template.today(\'yyyy-mm-dd, h:MM:ss TT\') %>\n * @author <%= pkg.author.name %> <<%= pkg.author.url %>>\n */" + banner: "/*!\n * <%= pkg.name %>\n * <%= pkg.description %>\n * @version <%= pkg.version %> - <%= grunt.template.today(\'yyyy-mm-dd\') %>\n * @author <%= pkg.author.name %> <<%= pkg.author.url %>>\n */\n" } }, bundled: { src: [ "", "lib/MiniCart/minicart.js", "src/paypal-button.js" ], dest: "dist/paypal-button-minicart.min.js", options: { - banner: "/*!\n * <%= pkg.name %>\n * <%= pkg.description %>\n * @version <%= pkg.version %> - <%= grunt.template.today(\'yyyy-mm-dd, h:MM:ss TT\') %>\n * @author <%= pkg.author.name %> <<%= pkg.author.url %>>\n */" + banner: "/*!\n * <%= pkg.name %>\n * <%= pkg.description %>\n * @version <%= pkg.version %> - <%= grunt.template.today(\'yyyy-mm-dd\') %>\n * @author <%= pkg.author.name %> <<%= pkg.author.url %>>\n */\n" } } } @@ -34,8 +50,9 @@ module.exports = function (grunt) { // Load grunt tasks from npm packages grunt.loadNpmTasks("grunt-contrib-jshint"); grunt.loadNpmTasks("grunt-contrib-uglify"); + grunt.loadNpmTasks("grunt-contrib-concat"); // Default task. - grunt.registerTask("default", ["jshint", "uglify"]); + grunt.registerTask("default", ["jshint", "concat", "uglify"]); }; diff --git a/dist/paypal-button-minicart.js b/dist/paypal-button-minicart.js new file mode 100644 index 0000000..59602e8 --- /dev/null +++ b/dist/paypal-button-minicart.js @@ -0,0 +1,2230 @@ +/*! + * PayPalJSButtons + * JavaScript integration for PayPal's payment buttons + * @version 1.0.0 - 2013-03-15 + * @author Jeff Harrell + */ +/*! + * The PayPal Mini Cart + * Visit http://www.minicartjs.com/ for details + * Use subject to license agreement as set forth at the link below + * + * @author Jeff Harrell + * @license https://github.com/jeffharrell/MiniCart/blob/master/LICENSE eBay Open Source License Agreement + */ +if (typeof PAYPAL === 'undefined' || !PAYPAL) { + var PAYPAL = {}; +} + +PAYPAL.apps = PAYPAL.apps || {}; + + +(function () { + 'use strict'; + + /** + * Default configuration + */ + var config = { + /** + * The parent element the cart should "pin" to + */ + parent: document.body, + + /** + * Edge of the window to pin the cart to + */ + displayEdge: 'right', + + /** + * Distance from the edge of the window + */ + edgeDistance: '50px', + + /** + * HTML target property for the checkout form + */ + formTarget: null, + + /** + * The base path of your website to set the cookie to + */ + cookiePath: '/', + + /** + * Strings used for display text + */ + strings: { + button: '', + subtotal: '', + discount: '', + shipping: '', + processing: '' + }, + + /** + * Unique ID used on the wrapper element + */ + name: 'PPMiniCart', + + /** + * Boolean to determine if the cart should "peek" when it's hidden with items + */ + peekEnabled: true, + + /** + * The URL of the PayPal website + */ + paypalURL: 'https://www.paypal.com/cgi-bin/webscr', + + /** + * The base URL to the visual assets + */ + assetURL: 'http://www.minicartjs.com/build/', + + events: { + /** + * Custom event fired before the cart is rendered + */ + onRender: null, + + /** + * Custom event fired after the cart is rendered + */ + afterRender: null, + + /** + * Custom event fired before the cart is hidden + * + * @param e {event} The triggering event + */ + onHide: null, + + /** + * Custom event fired after the cart is hidden + * + * @param e {event} The triggering event + */ + afterHide: null, + + /** + * Custom event fired before the cart is shown + * + * @param e {event} The triggering event + */ + onShow: null, + + /** + * Custom event fired after the cart is shown + * + * @param e {event} The triggering event + */ + afterShow: null, + + /** + * Custom event fired before a product is added to the cart + * + * @param data {object} Product object + */ + onAddToCart: null, + + /** + * Custom event fired after a product is added to the cart + * + * @param data {object} Product object + */ + afterAddToCart: null, + + /** + * Custom event fired before a product is removed from the cart + * + * @param data {object} Product object + */ + onRemoveFromCart: null, + + /** + * Custom event fired after a product is removed from the cart + * + * @param data {object} Product object + */ + afterRemoveFromCart: null, + + /** + * Custom event fired before the checkout action takes place + * + * @param e {event} The triggering event + */ + onCheckout: null, + + /** + * Custom event fired before the cart is reset + */ + onReset: null, + + /** + * Custom event fired after the cart is reset + */ + afterReset: null + } + }; + + + + if (!PAYPAL.apps.MiniCart) { + + /** + * Mini Cart application + */ + PAYPAL.apps.MiniCart = (function () { + + var minicart = {}, + isShowing = false, + isRendered = false; + + + /** PRIVATE **/ + + /** + * PayPal form cmd values which are supported + */ + var SUPPORTED_CMDS = { _cart: true, _xclick: true }; + + + /** + * The form origin that is passed to PayPal + */ + var BN_VALUE = 'MiniCart_AddToCart_WPS_US'; + + + /** + * Regex filter for cart settings, which appear only once in a cart + */ + var SETTING_FILTER = /^(?: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)/; + + + /** + * Adds the cart's CSS to the page in a