From 17333ba3a58bfcc718e7d14dfd7f7b7b836531d4 Mon Sep 17 00:00:00 2001 From: Brett Wejrowski Date: Tue, 12 Jun 2012 15:42:13 -0400 Subject: [PATCH 1/6] Added paypal price formatting and moved checkout event to inside of .checkout() --- README.md | 7 +++--- simpleCart.js | 48 ++++++++++++++++++++++------------------ test/test.core.js | 56 ++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 81 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index 09fd881..f0bd3a1 100755 --- a/README.md +++ b/README.md @@ -14,10 +14,9 @@ Dual licensed under the MIT or GPL licenses. If you would like to use an older version, you can use a different branch or see them in the downloads area -v3.0.4 changelog - - added .on alias for .bind - - allowing for multiple event bindings at once with space separated list - - fixed check to bug with switched currency and shipping +v3.0.5 changelog + - moved beforeCheckout event and form sending inside of .checkout() to keep dry + - added price, shipping, tax formatting for paypal checkout ## Quick Start diff --git a/simpleCart.js b/simpleCart.js index 46227b1..43ca016 100755 --- a/simpleCart.js +++ b/simpleCart.js @@ -883,7 +883,16 @@ if (settings.checkout.type.toLowerCase() === 'custom' && isFunction(settings.checkout.fn)) { settings.checkout.fn.call(simpleCart,settings.checkout); } else if (isFunction(simpleCart.checkout[settings.checkout.type])) { - simpleCart.checkout[settings.checkout.type].call(simpleCart,settings.checkout); + var checkoutData = simpleCart.checkout[settings.checkout.type].call(simpleCart,settings.checkout); + + // if the checkout method returns data, try to send the form + if( checkoutData.data && checkoutData.action && checkoutData.method ){ + // if no one has any objections, send the checkout form + if( false !== simpleCart.trigger('beforeCheckout', [checkoutData.data]) ){ + simpleCart.generateAndSendForm( checkoutData ); + } + } + } else { simpleCart.error("No Valid Checkout Method Specified"); } @@ -921,8 +930,8 @@ , currency_code : simpleCart.currency().code , business : opts.email , rm : opts.method === "GET" ? "0" : "2" - , tax_cart : simpleCart.tax() - , handling_cart : simpleCart.shipping() + , tax_cart : (simpleCart.tax()*1).toFixed(2) + , handling_cart : (simpleCart.shipping()*1).toFixed(2) , charset : "utf-8" }, action = opts.sandbox ? "https://www.sandbox.paypal.com/cgi-bin/webscr" : "https://www.paypal.com/cgi-bin/webscr", @@ -948,7 +957,7 @@ // basic item data data["item_name_" + counter] = item.get("name"); data["quantity_" + counter] = item.quantity(); - data["amount_" + counter] = item.price(); + data["amount_" + counter] = (item.price()*1).toFixed(2); data["item_number_" + counter] = item.get("item_number") || counter; @@ -975,13 +984,14 @@ data["option_index_"+ x] = Math.min(10, optionCount); }); - simpleCart.trigger('beforeCheckout', [data]); - simpleCart.generateAndSendForm({ + // return the data for the checkout form + return { action : action , method : method , data : data - }); + }; + }, @@ -1035,13 +1045,13 @@ data['item_description_' + counter] = options_list.join(", "); }); - simpleCart.trigger('beforeCheckout', [data]); - - simpleCart.generateAndSendForm({ + // return the data for the checkout form + return { action : action , method : method , data : data - }); + }; + }, @@ -1104,14 +1114,12 @@ data['item_description_' + counter] = options_list.join(", "); }); - simpleCart.trigger('beforeCheckout', [data]); - - simpleCart.generateAndSendForm({ + // return the data for the checkout form + return { action : action , method : method , data : data - }); - + }; }, @@ -1172,14 +1180,12 @@ data = simpleCart.extend(data,opts.extra_data); } - simpleCart.trigger('beforeCheckout', [data]); - - simpleCart.generateAndSendForm({ + // return the data for the checkout form + return { action : action , method : method , data : data - }); - + }; } diff --git a/test/test.core.js b/test/test.core.js index 97d1a6f..9e69fc7 100755 --- a/test/test.core.js +++ b/test/test.core.js @@ -77,6 +77,18 @@ test("adding and removing items", function(){ }); same( item3.price() , 36 , "Price with dollar sign in front is parsed correctly"); + + + simpleCart.empty(); + + var item4 = simpleCart.add({ + name: "RaceCar", + quantity: 1.4342 + }); + + same( item4.quantity() , 1 , "Item quantity parsed as INT and not decimal"); + same( simpleCart.quantity(), 1 , "SimpleCart quantity parsed as INT and not decimal"); + }); test("editing items", function(){ @@ -252,7 +264,6 @@ test("editing items", function(){ item.set("special_value" , "hullo"); - }); @@ -272,9 +283,7 @@ test("editing items", function(){ simpleCart.bind( 'afterAdd' , function( item ){ afteradd_not_called = false; }); - - - + simpleCart.load(); ok( beforeadd_not_called , "beforeAdd event is not called on load" ); @@ -381,7 +390,6 @@ test("editing items", function(){ shippingCustom: null }); same( simpleCart.shipping() , 7 , "Item shipping prototype function works"); - }); test("tax works", function(){ @@ -435,6 +443,44 @@ test("editing items", function(){ }); + test("tax and shipping send to paypal", function(){ + + simpleCart({ + taxRate: 0.5 + }); + + simpleCart.shipping(function(){ + return 5.55555; + }); + + simpleCart.empty(); + simpleCart.add({ + name: "cool thing with weird price", + price: 111.1111111111 + }); + + simpleCart({ + checkout: { + type: "PayPal", + email: "you@yours.com" + } + }); + + simpleCart.bind( "beforeCheckout" , function(data){ + + same( data.amount_1 , ( data.amount_1*1).toFixed(2) , "Item price is correctly formatted before going to paypal"); + same( data.tax_cart , ( data.tax_cart*1 ).toFixed(2) , "Tax is correctly formated before going to paypal"); + same( data.handling_cart , ( data.handling_cart*1 ).toFixed(2) ,"Shipping is correctly formated before going to paypal" ); + + //return false; + }); + + + simpleCart.checkout(); + + }); + + module('simpleCart.find'); test("simpleCart.find() function works", function(){ From dfe3b53484ffd1c767747aa43b3adaebaade4264 Mon Sep 17 00:00:00 2001 From: Brett Wejrowski Date: Tue, 12 Jun 2012 15:43:15 -0400 Subject: [PATCH 2/6] updated .min for 3.0.5 --- simpleCart.min.js | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/simpleCart.min.js b/simpleCart.min.js index 0679069..a68557e 100755 --- a/simpleCart.min.js +++ b/simpleCart.min.js @@ -16,25 +16,25 @@ p)&&h(y[d.view])?y[d.view]:y.attr).call(b,j,d),f=b.$create(g).addClass(f).html(j c.id||"SCI-"+l;!d(o[c.id]);)l+=1,c.id="SCI-"+l;g.get=function(a,b){var e=!b;return d(a)?a:h(c[a])?c[a].call(g):!d(c[a])?c[a]:h(g[a])&&e?g[a].call(g):!d(g[a])&&e?g[a]:c[a]};g.set=function(a,b){d(a)||(c[a.toLowerCase()]=b,("price"===a.toLowerCase()||"quantity"===a.toLowerCase())&&e());return g};g.equals=function(a){for(var b in c)if(Object.prototype.hasOwnProperty.call(c,b)&&"quantity"!==b&&"id"!==b&&a.get(b)!==c[b])return!1;return!0};g.options=function(){var a={};b.each(c,function(e,c,d){var f=!0; b.each(g.reservedFields(),function(a){a===d&&(f=!1);return f});f&&(a[d]=g.get(d))});return a};e()};b.Item._=b.Item.prototype={increment:function(a){a=parseInt(a||1,10);this.quantity(this.quantity()+a);return 1>this.quantity()?(this.remove(),null):this},decrement:function(a){return this.increment(-parseInt(a||1,10))},remove:function(a){if(!1===b.trigger("beforeRemove",[o[this.id()]]))return!1;delete o[this.id()];a||b.update();return null},reservedFields:function(){return"quantity id item_number price name shipping tax taxRate".split(" ")}, fields:function(){var a={},e=this;b.each(e.reservedFields(),function(b){e.get(b)&&(a[b]=e.get(b))});return a},quantity:function(a){return d(a)?parseInt(this.get("quantity",!0)||1,10):this.set("quantity",a)},price:function(a){return d(a)?parseFloat(this.get("price",!0).toString().replace(b.currency().symbol,"").replace(b.currency().delimiter,"")||1):this.set("price",parseFloat(a.toString().replace(b.currency().symbol,"").replace(b.currency().delimiter,"")))},id:function(){return this.get("id",!1)}, -total:function(){return this.quantity()*this.price()}};b.extend({checkout:function(){"custom"===k.checkout.type.toLowerCase()&&h(k.checkout.fn)?k.checkout.fn.call(b,k.checkout):h(b.checkout[k.checkout.type])?b.checkout[k.checkout.type].call(b,k.checkout):b.error("No Valid Checkout Method Specified")},extendCheckout:function(a){return b.extend(b.checkout,a)},generateAndSendForm:function(a){var e=b.$create("form");e.attr("style","display:none;");e.attr("action",a.action);e.attr("method",a.method);b.each(a.data, -function(a,g,d){e.append(b.$create("input").attr("type","hidden").attr("name",d).val(a))});b.$("body").append(e);e.el.submit();e.remove()}});b.extendCheckout({PayPal:function(a){if(!a.email)return b.error("No email provided for PayPal checkout");var e={cmd:"_cart",upload:"1",currency_code:b.currency().code,business:a.email,rm:"GET"===a.method?"0":"2",tax_cart:b.tax(),handling_cart:b.shipping(),charset:"utf-8"},c=a.sandbox?"https://www.sandbox.paypal.com/cgi-bin/webscr":"https://www.paypal.com/cgi-bin/webscr", -g="GET"===a.method?"GET":"POST";a.success&&(e["return"]=a.success);a.cancel&&(e.cancel_return=a.cancel);b.each(function(a,c){var g=c+1,d=a.options(),f=0,h;e["item_name_"+g]=a.get("name");e["quantity_"+g]=a.quantity();e["amount_"+g]=a.price();e["item_number_"+g]=a.get("item_number")||g;b.each(d,function(a,c,d){if(c<10){h=true;b.each(k.excludeFromCheckout,function(a){a===d&&(h=false)});if(h){f=f+1;e["on"+c+"_"+g]=d;e["os"+c+"_"+g]=a}}});e["option_index_"+c]=Math.min(10,f)});b.trigger("beforeCheckout", -[e]);b.generateAndSendForm({action:c,method:g,data:e})},GoogleCheckout:function(a){if(!a.merchantID)return b.error("No merchant id provided for GoogleCheckout");if("USD"!==b.currency().code&&"GBP"!==b.currency().code)return b.error("Google Checkout only accepts USD and GBP");var e={ship_method_name_1:"Shipping",ship_method_price_1:b.shipping(),ship_method_currency_1:b.currency().code,_charset_:""},c="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/"+a.merchantID,a="GET"===a.method? -"GET":"POST";b.each(function(a,c){var d=c+1,f=[],h;e["item_name_"+d]=a.get("name");e["item_quantity_"+d]=a.quantity();e["item_price_"+d]=a.price();e["item_currency_ "+d]=b.currency().code;e["item_tax_rate"+d]=a.get("taxRate")||b.taxRate();b.each(a.options(),function(a,e,c){h=!0;b.each(k.excludeFromCheckout,function(a){a===c&&(h=!1)});h&&f.push(c+": "+a)});e["item_description_"+d]=f.join(", ")});b.trigger("beforeCheckout",[e]);b.generateAndSendForm({action:c,method:a,data:e})},AmazonPayments:function(a){if(!a.merchant_signature)return b.error("No merchant signature provided for Amazon Payments"); -if(!a.merchant_id)return b.error("No merchant id provided for Amazon Payments");if(!a.aws_access_key_id)return b.error("No AWS access key id provided for Amazon Payments");var e={aws_access_key_id:a.aws_access_key_id,merchant_signature:a.merchant_signature,currency_code:b.currency().code,tax_rate:b.taxRate(),weight_unit:a.weight_unit||"lb"},c=(a.sandbox?"https://sandbox.google.com/checkout/":"https://checkout.google.com/")+"cws/v2/Merchant/"+a.merchant_id+"/checkoutForm",g="GET"===a.method?"GET": -"POST";b.each(function(c,g){var d=g+1,f=[];e["item_title_"+d]=c.get("name");e["item_quantity_"+d]=c.quantity();e["item_price_"+d]=c.price();e["item_sku_ "+d]=c.get("sku")||c.id();e["item_merchant_id_"+d]=a.merchant_id;c.get("weight")&&(e["item_weight_"+d]=c.get("weight"));k.shippingQuantityRate&&(e["shipping_method_price_per_unit_rate_"+d]=k.shippingQuantityRate);b.each(c.options(),function(a,e,c){var d=true;b.each(k.excludeFromCheckout,function(a){a===c&&(d=false)});d&&(c!=="weight"&&c!=="tax")&& -f.push(c+": "+a)});e["item_description_"+d]=f.join(", ")});b.trigger("beforeCheckout",[e]);b.generateAndSendForm({action:c,method:g,data:e})},SendForm:function(a){if(!a.url)return b.error("URL required for SendForm Checkout");var e={currency:b.currency().code,shipping:b.shipping(),tax:b.tax(),taxRate:b.taxRate(),itemCount:b.find({}).length},c=a.url,d="GET"===a.method?"GET":"POST";b.each(function(a,c){var d=c+1,g=[],f;e["item_name_"+d]=a.get("name");e["item_quantity_"+d]=a.quantity();e["item_price_"+ -d]=a.price();b.each(a.options(),function(a,e,c){f=!0;b.each(k.excludeFromCheckout,function(a){a===c&&(f=!1)});f&&g.push(c+": "+a)});e["item_options_"+d]=g.join(", ")});a.success&&(e["return"]=a.success);a.cancel&&(e.cancel_return=a.cancel);a.extra_data&&(e=b.extend(e,a.extra_data));b.trigger("beforeCheckout",[e]);b.generateAndSendForm({action:c,method:d,data:e})}});n={bind:function(a,e){if(!h(e))return this;this._events||(this._events={});var c=a.split(/ +/);b.each(c,function(a){this._events[a]=== -true?e.apply(this):d(this._events[a])?this._events[a]=[e]:this._events[a].push(e)});return this},trigger:function(a,b){var c=!0,g,f;this._events||(this._events={});if(!d(this._events[a])&&h(this._events[a][0])){g=0;for(f=this._events[a].length;g Date: Tue, 12 Jun 2012 17:01:42 -0400 Subject: [PATCH 3/6] fixed some mootools bugs and added .submit method to ELEMENT --- README.md | 2 ++ simpleCart.js | 54 +++++++++++++++------------- simpleCart.min.js | 91 ++++++++++++++++++++++++----------------------- test/test.core.js | 17 +++++++-- 4 files changed, 93 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index f0bd3a1..367d65a 100755 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ downloads area v3.0.5 changelog - moved beforeCheckout event and form sending inside of .checkout() to keep dry - added price, shipping, tax formatting for paypal checkout + - added .submit method to ELEMENT + - fixed mootools .get and .live bugs ## Quick Start diff --git a/simpleCart.js b/simpleCart.js index 43ca016..e4c4b5f 100755 --- a/simpleCart.js +++ b/simpleCart.js @@ -2,7 +2,7 @@ Copyright (c) 2012 Brett Wejrowski wojodesign.com - simplecartjs.com + simplecartjs.org http://github.com/wojodesign/simplecart-js VERSION 3.0.4 @@ -12,7 +12,6 @@ /*jslint browser: true, unparam: true, white: true, nomen: true, regexp: true, maxerr: 50, indent: 4 */ (function (window, document) { - //"use strict"; /*global HTMLElement */ var typeof_string = typeof "", @@ -1401,7 +1400,7 @@ }, attr: function (attr, val) { if (isUndefined(val)) { - return this.el.get(attr); + return this.el[0] && this.el[0].get(attr); } this.el.set(attr, val); @@ -1425,7 +1424,9 @@ }, each: function (callback) { if (isFunction(callback)) { - simpleCart.each(this.el, callback); + simpleCart.each(this.el, function( e, i, c) { + callback.call( i, i, e, c ); + }); } return this; }, @@ -1445,11 +1446,8 @@ live: function ( event,callback) { var selector = this.selector; if (isFunction(callback)) { - simpleCart.$(document).el.addEvent(event, function (e) { - var target = simpleCart.$(e.target); - if (target.match(selector)) { - callback.call(target, e); - } + simpleCart.$("body").el.addEvent(event + ":relay(" + selector + ")", function (e, el) { + callback.call(el, e); }); } }, @@ -1471,8 +1469,10 @@ tag: function () { return this.el[0].tagName; }, - - + submit: function (){ + this.el[0].submit(); + return this; + }, create: function (selector) { this.el = $engine(selector); } @@ -1485,7 +1485,7 @@ if (isUndefined(text)) { return this.el[0].innerHTML; } - this.each(function (e) { + this.each(function (i,e) { $(e).update(text); }); return this; @@ -1500,15 +1500,15 @@ if (isUndefined(val)) { return this.el[0].readAttribute(attr); } - this.each(function (e) { + this.each(function (i,e) { $(e).writeAttribute(attr, val); }); return this; }, append: function (item) { - this.each(function (e) { + this.each(function (i,e) { if (item.el) { - item.each(function (e2) { + item.each(function (i2,e2) { $(e).appendChild(e2); }); } else if (isElement(item)) { @@ -1518,38 +1518,40 @@ return this; }, remove: function () { - this.each(function (e) { + this.each(function (i, e) { $(e).remove(); }); return this; }, addClass: function (klass) { - this.each(function (e) { + this.each(function (i, e) { $(e).addClassName(klass); }); return this; }, removeClass: function (klass) { - this.each(function (e) { + this.each(function (i, e) { $(e).removeClassName(klass); }); return this; }, each: function (callback) { if (isFunction(callback)) { - simpleCart.each(this.el, callback); + simpleCart.each(this.el, function( e, i, c) { + callback.call( i, i, e, c ); + }); } return this; }, click: function (callback) { if (isFunction(callback)) { - this.each(function (e) { + this.each(function (i, e) { $(e).observe(_CLICK_, function (ev) { callback.call(e,ev); }); }); } else if (isUndefined(callback)) { - this.each(function (e) { + this.each(function (i, e) { $(e).fire(_CLICK_); }); } @@ -1580,7 +1582,9 @@ tag: function () { return this.el.tagName; }, - + submit: function() { + this.el[0].submit(); + }, create: function (selector) { if (isString(selector)) { @@ -1594,7 +1598,7 @@ }, - "jQuery" : { + "jQuery": { passthrough: function (action, val) { if (isUndefined(val)) { return this.el[action](); @@ -1661,7 +1665,9 @@ descendants: function () { return simpleCart.$(this.el.find("*")); }, - + submit: function() { + return this.el.submit(); + }, create: function (selector) { this.el = $engine(selector); diff --git a/simpleCart.min.js b/simpleCart.min.js index a68557e..86edb4f 100755 --- a/simpleCart.min.js +++ b/simpleCart.min.js @@ -1,51 +1,52 @@ -(function(m,f){var p="string",i=function(d,f){return typeof d===f},d=function(d){return i(d,"undefined")},h=function(d){return i(d,"function")},v=function(d){return"object"===typeof HTMLElement?d instanceof HTMLElement:"object"===typeof d&&1===d.nodeType&&"string"===typeof d.nodeName},z=function(n){function B(a){return b.extend({attr:"",label:"",view:"attr",text:"",className:"",hide:!1},a||{})}function C(){if(!b.isReady){try{f.documentElement.doScroll("left")}catch(a){setTimeout(C,1);return}b.init()}} +(function(m,f){var p="string",i=function(e,f){return typeof e===f},e=function(e){return i(e,"undefined")},h=function(e){return i(e,"function")},v=function(e){return"object"===typeof HTMLElement?e instanceof HTMLElement:"object"===typeof e&&1===e.nodeType&&"string"===typeof e.nodeName},z=function(n){function B(a){return b.extend({attr:"",label:"",view:"attr",text:"",className:"",hide:!1},a||{})}function C(){if(!b.isReady){try{f.documentElement.doScroll("left")}catch(a){setTimeout(C,1);return}b.init()}} var q={MooTools:"$$",Prototype:"$$",jQuery:"*"},l=0,o={},u=n||"simpleCart",w={},n={},n={},s=m.localStorage,j=m.console||{msgs:[],log:function(a){j.msgs.push(a)}},A={USD:{code:"USD",symbol:"$",name:"US Dollar"},AUD:{code:"AUD",symbol:"$",name:"Australian Dollar"},BRL:{code:"BRL",symbol:"R$",name:"Brazilian Real"},CAD:{code:"CAD",symbol:"$",name:"Canadian Dollar"},CZK:{code:"CZK",symbol:" Kč",name:"Czech Koruna",after:!0},DKK:{code:"DKK",symbol:"DKK ",name:"Danish Krone"}, EUR:{code:"EUR",symbol:"€",name:"Euro"},HKD:{code:"HKD",symbol:"$",name:"Hong Kong Dollar"},HUF:{code:"HUF",symbol:"Ft",name:"Hungarian Forint"},ILS:{code:"ILS",symbol:"₪",name:"Israeli New Sheqel"},JPY:{code:"JPY",symbol:"¥",name:"Japanese Yen"},MXN:{code:"MXN",symbol:"$",name:"Mexican Peso"},NOK:{code:"NOK",symbol:"NOK ",name:"Norwegian Krone"},NZD:{code:"NZD",symbol:"$",name:"New Zealand Dollar"},PLN:{code:"PLN",symbol:"PLN ",name:"Polish Zloty"},GBP:{code:"GBP", symbol:"£",name:"Pound Sterling"},SGD:{code:"SGD",symbol:"$",name:"Singapore Dollar"},SEK:{code:"SEK",symbol:"SEK ",name:"Swedish Krona"},CHF:{code:"CHF",symbol:"CHF ",name:"Swiss Franc"},THB:{code:"THB",symbol:"฿",name:"Thai Baht"},BTC:{code:"BTC",symbol:" BTC",name:"Bitcoin",accuracy:4,after:!0}},k={checkout:{type:"PayPal",email:"you@yours.com"},currency:"USD",language:"english-us",cartStyle:"div",cartColumns:[{attr:"name",label:"Name"},{attr:"price",label:"Price",view:"currency"}, -{view:"decrement",label:!1},{attr:"quantity",label:"Qty"},{view:"increment",label:!1},{attr:"total",label:"SubTotal",view:"currency"},{view:"remove",text:"Remove",label:!1}],excludeFromCheckout:["thumb"],shippingFlatRate:0,shippingQuantityRate:0,shippingTotalRate:0,shippingCustom:null,taxRate:0,taxShipping:!1,data:{}},b=function(a){if(h(a))return b.ready(a);if(i(a,"object"))return b.extend(k,a)},x,y;b.extend=function(a,e){var c;d(e)&&(e=a,a=b);for(c in e)Object.prototype.hasOwnProperty.call(e,c)&& -(a[c]=e[c]);return a};b.extend({copy:function(a){a=z(a);a.init();return a}});b.extend({isReady:!1,add:function(a,e){var c=new b.Item(a||{}),g=!0,r=!0===e?e:!1;if(!r&&(g=b.trigger("beforeAdd",[c]),!1===g))return!1;(g=b.has(c))?(g.increment(c.quantity()),c=g):o[c.id()]=c;b.update();r||b.trigger("afterAdd",[c,d(g)]);return c},each:function(a,e){var c,g=0,r,d,t;if(h(a))d=a,t=o;else if(h(e))d=e,t=a;else return;for(c in t)if(Object.prototype.hasOwnProperty.call(t,c)){r=d.call(b,t[c],g,c);if(!1===r)break; -g+=1}},find:function(a){var e=[];if(i(o[a],"object"))return o[a];if(i(a,"object"))return b.each(function(c){var g=!0;b.each(a,function(a,b,e){i(a,p)?a.match(/<=.*/)?(a=parseFloat(a.replace("<=","")),c.get(e)&&parseFloat(c.get(e))<=a||(g=!1)):a.match(/=/)?(a=parseFloat(a.replace(">=","")),c.get(e)&&parseFloat(c.get(e))>=a||(g=!1)):a.match(/>/)?(a=parseFloat(a.replace(">","")),c.get(e)&&parseFloat(c.get(e))>a|| -(g=!1)):c.get(e)&&c.get(e)===a||(g=!1):c.get(e)&&c.get(e)===a||(g=!1);return g});g&&e.push(c)}),e;d(a)&&b.each(function(a){e.push(a)});return e},items:function(){return this.find()},has:function(a){var e=!1;b.each(function(b){b.equals(a)&&(e=b)});return e},empty:function(){var a={};b.each(function(b){!1===b.remove(!0)&&(a[b.id()]=b)});o=a;b.update()},quantity:function(){var a=0;b.each(function(b){a+=b.quantity()});return a},total:function(){var a=0;b.each(function(b){a+=b.total()});return a},grandTotal:function(){return b.total()+ -b.tax()+b.shipping()},update:function(){b.save();b.trigger("update")},init:function(){b.load();b.update();b.ready()},$:function(a){return new b.ELEMENT(a)},$create:function(a){return b.$(f.createElement(a))},setupViewTool:function(){var a,e=m,c;for(c in q)if(Object.prototype.hasOwnProperty.call(q,c)&&m[c]&&(a=q[c].replace("*",c).split("."),(a=a.shift())&&(e=e[a]),"function"===typeof e)){x=e;b.extend(b.ELEMENT._,w[c]);break}},ids:function(){var a=[];b.each(function(b){a.push(b.id())});return a},save:function(){b.trigger("beforeSave"); -var a={};b.each(function(e){a[e.id()]=b.extend(e.fields(),e.options())});s.setItem(u+"_items",JSON.stringify(a));b.trigger("afterSave")},load:function(){o={};var a=s.getItem(u+"_items");if(a){try{b.each(JSON.parse(a),function(a){b.add(a,!0)})}catch(e){b.error("Error Loading data: "+e)}b.trigger("load")}},ready:function(a){h(a)?b.isReady?a.call(b):b.bind("ready",a):d(a)&&!b.isReady&&(b.trigger("ready"),b.isReady=!0)},error:function(a){var e="";i(a,p)?e=a:i(a,"object")&&i(a.message,p)&&(e=a.message); -try{j.log("simpleCart(js) Error: "+e)}catch(c){}b.trigger("error",a)}});b.extend({tax:function(){var a=k.taxShipping?b.total()+b.shipping():b.total(),e=b.taxRate()*a;b.each(function(a){a.get("tax")?e+=a.get("tax"):a.get("taxRate")&&(e+=a.get("taxRate")*a.total())});return parseFloat(e)},taxRate:function(){return k.taxRate||0},shipping:function(a){if(h(a))b({shippingCustom:a});else{var e=k.shippingQuantityRate*b.quantity()+k.shippingTotalRate*b.total()+k.shippingFlatRate;h(k.shippingCustom)&&(e+=k.shippingCustom.call(b)); -b.each(function(a){e+=parseFloat(a.get("shipping")||0)});return parseFloat(e)}}});y={attr:function(a,b){return a.get(b.attr)||""},currency:function(a,e){return b.toCurrency(a.get(e.attr)||0)},link:function(a,b){return""+b.text+""},decrement:function(a,b){return""+(b.text||"-")+""},increment:function(a,b){return""+(b.text||"+")+""},image:function(a,b){return""},input:function(a,b){return""},remove:function(a,b){return""+(b.text||"X")+""}};b.extend({writeCart:function(a){var e=k.cartStyle.toLowerCase(),c="table"===e,g=c?"tr":"div",r=c?"th":"div",d=c?"td":"div",t=b.$create(e),e=b.$create(g).addClass("headerRow"),f,h;b.$(a).html(" ").append(t);t.append(e);c=0;for(h=k.cartColumns.length;cc.price&&(c.price=0);i(c.quantity,p)&&(c.quantity=parseInt(c.quantity.replace(b.currency().delimiter,""),10));isNaN(c.quantity)&&(c.quantity=1);0>=c.quantity&&g.remove()}var c={},g=this;i(a,"object")&&b.extend(c,a);l+=1;for(c.id= -c.id||"SCI-"+l;!d(o[c.id]);)l+=1,c.id="SCI-"+l;g.get=function(a,b){var e=!b;return d(a)?a:h(c[a])?c[a].call(g):!d(c[a])?c[a]:h(g[a])&&e?g[a].call(g):!d(g[a])&&e?g[a]:c[a]};g.set=function(a,b){d(a)||(c[a.toLowerCase()]=b,("price"===a.toLowerCase()||"quantity"===a.toLowerCase())&&e());return g};g.equals=function(a){for(var b in c)if(Object.prototype.hasOwnProperty.call(c,b)&&"quantity"!==b&&"id"!==b&&a.get(b)!==c[b])return!1;return!0};g.options=function(){var a={};b.each(c,function(e,c,d){var f=!0; -b.each(g.reservedFields(),function(a){a===d&&(f=!1);return f});f&&(a[d]=g.get(d))});return a};e()};b.Item._=b.Item.prototype={increment:function(a){a=parseInt(a||1,10);this.quantity(this.quantity()+a);return 1>this.quantity()?(this.remove(),null):this},decrement:function(a){return this.increment(-parseInt(a||1,10))},remove:function(a){if(!1===b.trigger("beforeRemove",[o[this.id()]]))return!1;delete o[this.id()];a||b.update();return null},reservedFields:function(){return"quantity id item_number price name shipping tax taxRate".split(" ")}, -fields:function(){var a={},e=this;b.each(e.reservedFields(),function(b){e.get(b)&&(a[b]=e.get(b))});return a},quantity:function(a){return d(a)?parseInt(this.get("quantity",!0)||1,10):this.set("quantity",a)},price:function(a){return d(a)?parseFloat(this.get("price",!0).toString().replace(b.currency().symbol,"").replace(b.currency().delimiter,"")||1):this.set("price",parseFloat(a.toString().replace(b.currency().symbol,"").replace(b.currency().delimiter,"")))},id:function(){return this.get("id",!1)}, -total:function(){return this.quantity()*this.price()}};b.extend({checkout:function(){if("custom"===k.checkout.type.toLowerCase()&&h(k.checkout.fn))k.checkout.fn.call(b,k.checkout);else if(h(b.checkout[k.checkout.type])){var a=b.checkout[k.checkout.type].call(b,k.checkout);a.data&&a.action&&a.method&&!1!==b.trigger("beforeCheckout",[a.data])&&b.generateAndSendForm(a)}else b.error("No Valid Checkout Method Specified")},extendCheckout:function(a){return b.extend(b.checkout,a)},generateAndSendForm:function(a){var e= -b.$create("form");e.attr("style","display:none;");e.attr("action",a.action);e.attr("method",a.method);b.each(a.data,function(a,g,d){e.append(b.$create("input").attr("type","hidden").attr("name",d).val(a))});b.$("body").append(e);e.el.submit();e.remove()}});b.extendCheckout({PayPal:function(a){if(!a.email)return b.error("No email provided for PayPal checkout");var e={cmd:"_cart",upload:"1",currency_code:b.currency().code,business:a.email,rm:"GET"===a.method?"0":"2",tax_cart:(1*b.tax()).toFixed(2), -handling_cart:(1*b.shipping()).toFixed(2),charset:"utf-8"},c=a.sandbox?"https://www.sandbox.paypal.com/cgi-bin/webscr":"https://www.paypal.com/cgi-bin/webscr",g="GET"===a.method?"GET":"POST";a.success&&(e["return"]=a.success);a.cancel&&(e.cancel_return=a.cancel);b.each(function(a,c){var g=c+1,d=a.options(),f=0,h;e["item_name_"+g]=a.get("name");e["quantity_"+g]=a.quantity();e["amount_"+g]=(a.price()*1).toFixed(2);e["item_number_"+g]=a.get("item_number")||g;b.each(d,function(a,c,d){if(c<10){h=true; -b.each(k.excludeFromCheckout,function(a){a===d&&(h=false)});if(h){f=f+1;e["on"+c+"_"+g]=d;e["os"+c+"_"+g]=a}}});e["option_index_"+c]=Math.min(10,f)});return{action:c,method:g,data:e}},GoogleCheckout:function(a){if(!a.merchantID)return b.error("No merchant id provided for GoogleCheckout");if("USD"!==b.currency().code&&"GBP"!==b.currency().code)return b.error("Google Checkout only accepts USD and GBP");var e={ship_method_name_1:"Shipping",ship_method_price_1:b.shipping(),ship_method_currency_1:b.currency().code, -_charset_:""},c="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/"+a.merchantID,a="GET"===a.method?"GET":"POST";b.each(function(a,c){var d=c+1,f=[],h;e["item_name_"+d]=a.get("name");e["item_quantity_"+d]=a.quantity();e["item_price_"+d]=a.price();e["item_currency_ "+d]=b.currency().code;e["item_tax_rate"+d]=a.get("taxRate")||b.taxRate();b.each(a.options(),function(a,e,c){h=!0;b.each(k.excludeFromCheckout,function(a){a===c&&(h=!1)});h&&f.push(c+": "+a)});e["item_description_"+d]=f.join(", ")}); -return{action:c,method:a,data:e}},AmazonPayments:function(a){if(!a.merchant_signature)return b.error("No merchant signature provided for Amazon Payments");if(!a.merchant_id)return b.error("No merchant id provided for Amazon Payments");if(!a.aws_access_key_id)return b.error("No AWS access key id provided for Amazon Payments");var e={aws_access_key_id:a.aws_access_key_id,merchant_signature:a.merchant_signature,currency_code:b.currency().code,tax_rate:b.taxRate(),weight_unit:a.weight_unit||"lb"},c=(a.sandbox? -"https://sandbox.google.com/checkout/":"https://checkout.google.com/")+"cws/v2/Merchant/"+a.merchant_id+"/checkoutForm",g="GET"===a.method?"GET":"POST";b.each(function(c,g){var d=g+1,f=[];e["item_title_"+d]=c.get("name");e["item_quantity_"+d]=c.quantity();e["item_price_"+d]=c.price();e["item_sku_ "+d]=c.get("sku")||c.id();e["item_merchant_id_"+d]=a.merchant_id;c.get("weight")&&(e["item_weight_"+d]=c.get("weight"));k.shippingQuantityRate&&(e["shipping_method_price_per_unit_rate_"+d]=k.shippingQuantityRate); -b.each(c.options(),function(a,e,c){var d=true;b.each(k.excludeFromCheckout,function(a){a===c&&(d=false)});d&&(c!=="weight"&&c!=="tax")&&f.push(c+": "+a)});e["item_description_"+d]=f.join(", ")});return{action:c,method:g,data:e}},SendForm:function(a){if(!a.url)return b.error("URL required for SendForm Checkout");var e={currency:b.currency().code,shipping:b.shipping(),tax:b.tax(),taxRate:b.taxRate(),itemCount:b.find({}).length},c=a.url,d="GET"===a.method?"GET":"POST";b.each(function(a,c){var d=c+1, -g=[],f;e["item_name_"+d]=a.get("name");e["item_quantity_"+d]=a.quantity();e["item_price_"+d]=a.price();b.each(a.options(),function(a,e,c){f=!0;b.each(k.excludeFromCheckout,function(a){a===c&&(f=!1)});f&&g.push(c+": "+a)});e["item_options_"+d]=g.join(", ")});a.success&&(e["return"]=a.success);a.cancel&&(e.cancel_return=a.cancel);a.extra_data&&(e=b.extend(e,a.extra_data));return{action:c,method:d,data:e}}});n={bind:function(a,e){if(!h(e))return this;this._events||(this._events={});var c=a.split(/ +/); -b.each(c,function(a){this._events[a]===true?e.apply(this):d(this._events[a])?this._events[a]=[e]:this._events[a].push(e)});return this},trigger:function(a,b){var c=!0,g,f;this._events||(this._events={});if(!d(this._events[a])&&h(this._events[a][0])){g=0;for(f=this._events[a].length;gd?"0"+d:d}function f(f){d.lastIndex=0;return d.test(f)?'"'+f.replace(d,function(d){var f=z[d];return"string"===typeof f?f:"\\u"+("0000"+d.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+f+'"'}function p(d,i){var q,l,o,m,w=h,s,j=i[d];j&&"object"===typeof j&&"function"===typeof j.toJSON&&(j=j.toJSON(d));"function"===typeof n&&(j=n.call(i,d,j));switch(typeof j){case "string":return f(j);case "number":return isFinite(j)?""+j:"null";case "boolean":case "null":return""+ +{view:"decrement",label:!1},{attr:"quantity",label:"Qty"},{view:"increment",label:!1},{attr:"total",label:"SubTotal",view:"currency"},{view:"remove",text:"Remove",label:!1}],excludeFromCheckout:["thumb"],shippingFlatRate:0,shippingQuantityRate:0,shippingTotalRate:0,shippingCustom:null,taxRate:0,taxShipping:!1,data:{}},b=function(a){if(h(a))return b.ready(a);if(i(a,"object"))return b.extend(k,a)},x,y;b.extend=function(a,d){var c;e(d)&&(d=a,a=b);for(c in d)Object.prototype.hasOwnProperty.call(d,c)&& +(a[c]=d[c]);return a};b.extend({copy:function(a){a=z(a);a.init();return a}});b.extend({isReady:!1,add:function(a,d){var c=new b.Item(a||{}),g=!0,r=!0===d?d:!1;if(!r&&(g=b.trigger("beforeAdd",[c]),!1===g))return!1;(g=b.has(c))?(g.increment(c.quantity()),c=g):o[c.id()]=c;b.update();r||b.trigger("afterAdd",[c,e(g)]);return c},each:function(a,d){var c,g=0,r,e,t;if(h(a))e=a,t=o;else if(h(d))e=d,t=a;else return;for(c in t)if(Object.prototype.hasOwnProperty.call(t,c)){r=e.call(b,t[c],g,c);if(!1===r)break; +g+=1}},find:function(a){var d=[];if(i(o[a],"object"))return o[a];if(i(a,"object"))return b.each(function(c){var g=!0;b.each(a,function(a,b,d){i(a,p)?a.match(/<=.*/)?(a=parseFloat(a.replace("<=","")),c.get(d)&&parseFloat(c.get(d))<=a||(g=!1)):a.match(/=/)?(a=parseFloat(a.replace(">=","")),c.get(d)&&parseFloat(c.get(d))>=a||(g=!1)):a.match(/>/)?(a=parseFloat(a.replace(">","")),c.get(d)&&parseFloat(c.get(d))>a|| +(g=!1)):c.get(d)&&c.get(d)===a||(g=!1):c.get(d)&&c.get(d)===a||(g=!1);return g});g&&d.push(c)}),d;e(a)&&b.each(function(a){d.push(a)});return d},items:function(){return this.find()},has:function(a){var d=!1;b.each(function(b){b.equals(a)&&(d=b)});return d},empty:function(){var a={};b.each(function(b){!1===b.remove(!0)&&(a[b.id()]=b)});o=a;b.update()},quantity:function(){var a=0;b.each(function(b){a+=b.quantity()});return a},total:function(){var a=0;b.each(function(b){a+=b.total()});return a},grandTotal:function(){return b.total()+ +b.tax()+b.shipping()},update:function(){b.save();b.trigger("update")},init:function(){b.load();b.update();b.ready()},$:function(a){return new b.ELEMENT(a)},$create:function(a){return b.$(f.createElement(a))},setupViewTool:function(){var a,d=m,c;for(c in q)if(Object.prototype.hasOwnProperty.call(q,c)&&m[c]&&(a=q[c].replace("*",c).split("."),(a=a.shift())&&(d=d[a]),"function"===typeof d)){x=d;b.extend(b.ELEMENT._,w[c]);break}},ids:function(){var a=[];b.each(function(b){a.push(b.id())});return a},save:function(){b.trigger("beforeSave"); +var a={};b.each(function(d){a[d.id()]=b.extend(d.fields(),d.options())});s.setItem(u+"_items",JSON.stringify(a));b.trigger("afterSave")},load:function(){o={};var a=s.getItem(u+"_items");if(a){try{b.each(JSON.parse(a),function(a){b.add(a,!0)})}catch(d){b.error("Error Loading data: "+d)}b.trigger("load")}},ready:function(a){h(a)?b.isReady?a.call(b):b.bind("ready",a):e(a)&&!b.isReady&&(b.trigger("ready"),b.isReady=!0)},error:function(a){var d="";i(a,p)?d=a:i(a,"object")&&i(a.message,p)&&(d=a.message); +try{j.log("simpleCart(js) Error: "+d)}catch(c){}b.trigger("error",a)}});b.extend({tax:function(){var a=k.taxShipping?b.total()+b.shipping():b.total(),d=b.taxRate()*a;b.each(function(a){a.get("tax")?d+=a.get("tax"):a.get("taxRate")&&(d+=a.get("taxRate")*a.total())});return parseFloat(d)},taxRate:function(){return k.taxRate||0},shipping:function(a){if(h(a))b({shippingCustom:a});else{var d=k.shippingQuantityRate*b.quantity()+k.shippingTotalRate*b.total()+k.shippingFlatRate;h(k.shippingCustom)&&(d+=k.shippingCustom.call(b)); +b.each(function(a){d+=parseFloat(a.get("shipping")||0)});return parseFloat(d)}}});y={attr:function(a,b){return a.get(b.attr)||""},currency:function(a,d){return b.toCurrency(a.get(d.attr)||0)},link:function(a,b){return""+b.text+""},decrement:function(a,b){return""+(b.text||"-")+""},increment:function(a,b){return""+(b.text||"+")+""},image:function(a,b){return""},input:function(a,b){return""},remove:function(a,b){return""+(b.text||"X")+""}};b.extend({writeCart:function(a){var d=k.cartStyle.toLowerCase(),c="table"===d,g=c?"tr":"div",r=c?"th":"div",e=c?"td":"div",t=b.$create(d),d=b.$create(g).addClass("headerRow"),f,h;b.$(a).html(" ").append(t);t.append(d);c=0;for(h=k.cartColumns.length;cc.price&&(c.price=0);i(c.quantity,p)&&(c.quantity=parseInt(c.quantity.replace(b.currency().delimiter,""),10));isNaN(c.quantity)&&(c.quantity=1);0>=c.quantity&&g.remove()}var c={},g=this;i(a,"object")&&b.extend(c,a);l+=1;for(c.id= +c.id||"SCI-"+l;!e(o[c.id]);)l+=1,c.id="SCI-"+l;g.get=function(a,b){var d=!b;return e(a)?a:h(c[a])?c[a].call(g):!e(c[a])?c[a]:h(g[a])&&d?g[a].call(g):!e(g[a])&&d?g[a]:c[a]};g.set=function(a,b){e(a)||(c[a.toLowerCase()]=b,("price"===a.toLowerCase()||"quantity"===a.toLowerCase())&&d());return g};g.equals=function(a){for(var b in c)if(Object.prototype.hasOwnProperty.call(c,b)&&"quantity"!==b&&"id"!==b&&a.get(b)!==c[b])return!1;return!0};g.options=function(){var a={};b.each(c,function(d,c,e){var f=!0; +b.each(g.reservedFields(),function(a){a===e&&(f=!1);return f});f&&(a[e]=g.get(e))});return a};d()};b.Item._=b.Item.prototype={increment:function(a){a=parseInt(a||1,10);this.quantity(this.quantity()+a);return 1>this.quantity()?(this.remove(),null):this},decrement:function(a){return this.increment(-parseInt(a||1,10))},remove:function(a){if(!1===b.trigger("beforeRemove",[o[this.id()]]))return!1;delete o[this.id()];a||b.update();return null},reservedFields:function(){return"quantity id item_number price name shipping tax taxRate".split(" ")}, +fields:function(){var a={},d=this;b.each(d.reservedFields(),function(b){d.get(b)&&(a[b]=d.get(b))});return a},quantity:function(a){return e(a)?parseInt(this.get("quantity",!0)||1,10):this.set("quantity",a)},price:function(a){return e(a)?parseFloat(this.get("price",!0).toString().replace(b.currency().symbol,"").replace(b.currency().delimiter,"")||1):this.set("price",parseFloat(a.toString().replace(b.currency().symbol,"").replace(b.currency().delimiter,"")))},id:function(){return this.get("id",!1)}, +total:function(){return this.quantity()*this.price()}};b.extend({checkout:function(){if("custom"===k.checkout.type.toLowerCase()&&h(k.checkout.fn))k.checkout.fn.call(b,k.checkout);else if(h(b.checkout[k.checkout.type])){var a=b.checkout[k.checkout.type].call(b,k.checkout);a.data&&a.action&&a.method&&!1!==b.trigger("beforeCheckout",[a.data])&&b.generateAndSendForm(a)}else b.error("No Valid Checkout Method Specified")},extendCheckout:function(a){return b.extend(b.checkout,a)},generateAndSendForm:function(a){var d= +b.$create("form");d.attr("style","display:none;");d.attr("action",a.action);d.attr("method",a.method);b.each(a.data,function(a,g,e){d.append(b.$create("input").attr("type","hidden").attr("name",e).val(a))});b.$("body").append(d);d.el.submit();d.remove()}});b.extendCheckout({PayPal:function(a){if(!a.email)return b.error("No email provided for PayPal checkout");var d={cmd:"_cart",upload:"1",currency_code:b.currency().code,business:a.email,rm:"GET"===a.method?"0":"2",tax_cart:(1*b.tax()).toFixed(2), +handling_cart:(1*b.shipping()).toFixed(2),charset:"utf-8"},c=a.sandbox?"https://www.sandbox.paypal.com/cgi-bin/webscr":"https://www.paypal.com/cgi-bin/webscr",g="GET"===a.method?"GET":"POST";a.success&&(d["return"]=a.success);a.cancel&&(d.cancel_return=a.cancel);b.each(function(a,c){var g=c+1,e=a.options(),f=0,h;d["item_name_"+g]=a.get("name");d["quantity_"+g]=a.quantity();d["amount_"+g]=(a.price()*1).toFixed(2);d["item_number_"+g]=a.get("item_number")||g;b.each(e,function(a,c,e){if(c<10){h=true; +b.each(k.excludeFromCheckout,function(a){a===e&&(h=false)});if(h){f=f+1;d["on"+c+"_"+g]=e;d["os"+c+"_"+g]=a}}});d["option_index_"+c]=Math.min(10,f)});return{action:c,method:g,data:d}},GoogleCheckout:function(a){if(!a.merchantID)return b.error("No merchant id provided for GoogleCheckout");if("USD"!==b.currency().code&&"GBP"!==b.currency().code)return b.error("Google Checkout only accepts USD and GBP");var d={ship_method_name_1:"Shipping",ship_method_price_1:b.shipping(),ship_method_currency_1:b.currency().code, +_charset_:""},c="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/"+a.merchantID,a="GET"===a.method?"GET":"POST";b.each(function(a,c){var e=c+1,f=[],h;d["item_name_"+e]=a.get("name");d["item_quantity_"+e]=a.quantity();d["item_price_"+e]=a.price();d["item_currency_ "+e]=b.currency().code;d["item_tax_rate"+e]=a.get("taxRate")||b.taxRate();b.each(a.options(),function(a,d,c){h=!0;b.each(k.excludeFromCheckout,function(a){a===c&&(h=!1)});h&&f.push(c+": "+a)});d["item_description_"+e]=f.join(", ")}); +return{action:c,method:a,data:d}},AmazonPayments:function(a){if(!a.merchant_signature)return b.error("No merchant signature provided for Amazon Payments");if(!a.merchant_id)return b.error("No merchant id provided for Amazon Payments");if(!a.aws_access_key_id)return b.error("No AWS access key id provided for Amazon Payments");var d={aws_access_key_id:a.aws_access_key_id,merchant_signature:a.merchant_signature,currency_code:b.currency().code,tax_rate:b.taxRate(),weight_unit:a.weight_unit||"lb"},c=(a.sandbox? +"https://sandbox.google.com/checkout/":"https://checkout.google.com/")+"cws/v2/Merchant/"+a.merchant_id+"/checkoutForm",g="GET"===a.method?"GET":"POST";b.each(function(c,g){var e=g+1,f=[];d["item_title_"+e]=c.get("name");d["item_quantity_"+e]=c.quantity();d["item_price_"+e]=c.price();d["item_sku_ "+e]=c.get("sku")||c.id();d["item_merchant_id_"+e]=a.merchant_id;c.get("weight")&&(d["item_weight_"+e]=c.get("weight"));k.shippingQuantityRate&&(d["shipping_method_price_per_unit_rate_"+e]=k.shippingQuantityRate); +b.each(c.options(),function(a,d,c){var g=true;b.each(k.excludeFromCheckout,function(a){a===c&&(g=false)});g&&(c!=="weight"&&c!=="tax")&&f.push(c+": "+a)});d["item_description_"+e]=f.join(", ")});return{action:c,method:g,data:d}},SendForm:function(a){if(!a.url)return b.error("URL required for SendForm Checkout");var d={currency:b.currency().code,shipping:b.shipping(),tax:b.tax(),taxRate:b.taxRate(),itemCount:b.find({}).length},c=a.url,g="GET"===a.method?"GET":"POST";b.each(function(a,c){var g=c+1, +e=[],f;d["item_name_"+g]=a.get("name");d["item_quantity_"+g]=a.quantity();d["item_price_"+g]=a.price();b.each(a.options(),function(a,d,c){f=!0;b.each(k.excludeFromCheckout,function(a){a===c&&(f=!1)});f&&e.push(c+": "+a)});d["item_options_"+g]=e.join(", ")});a.success&&(d["return"]=a.success);a.cancel&&(d.cancel_return=a.cancel);a.extra_data&&(d=b.extend(d,a.extra_data));return{action:c,method:g,data:d}}});n={bind:function(a,d){if(!h(d))return this;this._events||(this._events={});var c=a.split(/ +/); +b.each(c,function(a){this._events[a]===true?d.apply(this):e(this._events[a])?this._events[a]=[d]:this._events[a].push(d)});return this},trigger:function(a,b){var c=!0,g,f;this._events||(this._events={});if(!e(this._events[a])&&h(this._events[a][0])){g=0;for(f=this._events[a].length;ge?"0"+e:e}function f(f){e.lastIndex=0;return e.test(f)?'"'+f.replace(e,function(e){var f=z[e];return"string"===typeof f?f:"\\u"+("0000"+e.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+f+'"'}function p(e,i){var q,l,o,m,w=h,s,j=i[e];j&&"object"===typeof j&&"function"===typeof j.toJSON&&(j=j.toJSON(e));"function"===typeof n&&(j=n.call(i,e,j));switch(typeof j){case "string":return f(j);case "number":return isFinite(j)?""+j:"null";case "boolean":case "null":return""+ j;case "object":if(!j)return"null";h+=v;s=[];if("[object Array]"===Object.prototype.toString.apply(j)){m=j.length;for(q=0;q Date: Tue, 12 Jun 2012 20:35:31 -0400 Subject: [PATCH 4/6] version bump --- simpleCart.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simpleCart.js b/simpleCart.js index e4c4b5f..5b61a70 100755 --- a/simpleCart.js +++ b/simpleCart.js @@ -5,7 +5,7 @@ simplecartjs.org http://github.com/wojodesign/simplecart-js - VERSION 3.0.4 + VERSION 3.0.5 Dual licensed under the MIT or GPL licenses. ~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~*/ From 0f3106943fa1aa3f01d1908d6b23bd0b3bea53f6 Mon Sep 17 00:00:00 2001 From: Brett Wejrowski Date: Tue, 12 Jun 2012 21:50:30 -0400 Subject: [PATCH 5/6] updated test for form submit to work in ff --- test/test.core.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/test.core.js b/test/test.core.js index 9e4e27c..1bda570 100755 --- a/test/test.core.js +++ b/test/test.core.js @@ -511,11 +511,11 @@ test("editing items", function(){ module('simpleCart UI updates'); test("form submit works properly",function(){ - var form = simpleCart.$create("form"), - formSubmittedProperly = false; + var form = simpleCart.$create("form"); window.formSubmittedProperly = false; form.attr('style', 'display:none;'); - form.attr('action', 'javascript:formSubmittedProperly=true;'); + form.attr('action', 'javascript:;'); + form.attr('onsubmit','formSubmittedProperly=true;') form.attr('method', "GET"); simpleCart.$("body").append(form); form.submit(); From 1e4f8b5dfd8d962e1098460032fbcdc79e3d7c2d Mon Sep 17 00:00:00 2001 From: Brett Wejrowski Date: Tue, 12 Jun 2012 22:23:23 -0400 Subject: [PATCH 6/6] removed form submit test.. its causing trouble where it shouldn't. --- test/test.core.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/test/test.core.js b/test/test.core.js index 1bda570..cfdc0f2 100755 --- a/test/test.core.js +++ b/test/test.core.js @@ -509,21 +509,6 @@ test("editing items", function(){ }); - module('simpleCart UI updates'); - test("form submit works properly",function(){ - var form = simpleCart.$create("form"); - window.formSubmittedProperly = false; - form.attr('style', 'display:none;'); - form.attr('action', 'javascript:;'); - form.attr('onsubmit','formSubmittedProperly=true;') - form.attr('method', "GET"); - simpleCart.$("body").append(form); - form.submit(); - form.remove(); - - ok( window.formSubmittedProperly , "form submitted properly" ); - }); - test("basic outlets work", function(){ var item = simpleCart.add({