Created
November 28, 2012 16:11
-
-
Save pablasso/4162239 to your computer and use it in GitHub Desktop.
Shop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(j,l){var g=typeof"",i=typeof undefined,c=typeof function(){},d=typeof{},h=function(o,n){return typeof o===n},a=function(n){return h(n,g)},e=function(n){return h(n,i)},b=function(n){return h(n,c)},m=function(n){return h(n,d)},k=function(n){return typeof HTMLElement==="object"?n instanceof HTMLElement:typeof n==="object"&&n.nodeType===1&&typeof n.nodeName==="string"},f=function(H){var E={MooTools:"$$",Prototype:"$$",jQuery:"*"},w=0,s="SCI-",x={},t=H||"simpleCart",J={},C={},u={},F=j.localStorage,B=j.console||{msgs:[],log:function(L){B.msgs.push(L)}},z="value",I="text",K="html",y="click",D={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:true},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:true}},G={checkout:{type:"PayPal",email:"[email protected]"},currency:"USD",language:"english-us",cartStyle:"div",cartColumns:[{attr:"name",label:"Name"},{attr:"price",label:"Price",view:"currency"},{view:"decrement",label:false},{attr:"quantity",label:"Qty"},{view:"increment",label:false},{attr:"total",label:"SubTotal",view:"currency"},{view:"remove",text:"Remove",label:false}],excludeFromCheckout:["thumb"],shippingFlatRate:0,shippingQuantityRate:0,shippingTotalRate:0,shippingCustom:null,taxRate:0,taxShipping:false,data:{}},r=function(L){if(b(L)){return r.ready(L)}if(m(L)){return r.extend(G,L)}},n,p;r.extend=function(N,M){var L;if(e(M)){M=N;N=r}for(L in M){if(Object.prototype.hasOwnProperty.call(M,L)){N[L]=M[L]}}return N};r.extend({copy:function(M){var L=f(M);L.init();return L}});r.extend({isReady:false,add:function(L,R){var P=L||{},N=new r.Item(P),Q=true,M=R===true?R:false,O;if(!M){Q=r.trigger("beforeAdd",[N]);if(Q===false){return false}}O=r.has(N);if(O){O.increment(N.quantity());N=O}else{x[N.id()]=N}r.update();if(!M){r.trigger("afterAdd",[N,e(O)])}return N},each:function(R,Q){var P,N=0,M,L,O;if(b(R)){L=R;O=x}else{if(b(Q)){L=Q;O=R}else{return}}for(P in O){if(Object.prototype.hasOwnProperty.call(O,P)){M=L.call(r,O[P],N,P);if(M===false){return}N+=1}}},find:function(M){var L=[];if(m(x[M])){return x[M]}if(m(M)){r.each(function(O){var N=true;r.each(M,function(R,Q,P){if(a(R)){if(R.match(/<=.*/)){R=parseFloat(R.replace("<=",""));if(!(O.get(P)&&parseFloat(O.get(P))<=R)){N=false}}else{if(R.match(/</)){R=parseFloat(R.replace("<",""));if(!(O.get(P)&&parseFloat(O.get(P))<R)){N=false}}else{if(R.match(/>=/)){R=parseFloat(R.replace(">=",""));if(!(O.get(P)&&parseFloat(O.get(P))>=R)){N=false}}else{if(R.match(/>/)){R=parseFloat(R.replace(">",""));if(!(O.get(P)&&parseFloat(O.get(P))>R)){N=false}}else{if(!(O.get(P)&&O.get(P)===R)){N=false}}}}}}else{if(!(O.get(P)&&O.get(P)===R)){N=false}}return N});if(N){L.push(O)}});return L}if(e(M)){r.each(function(N){L.push(N)});return L}return L},items:function(){return this.find()},has:function(M){var L=false;r.each(function(N){if(N.equals(M)){L=N}});return L},empty:function(){var L={};r.each(function(M){if(M.remove(true)===false){L[M.id()]=M}});x=L;r.update()},quantity:function(){var L=0;r.each(function(M){L+=M.quantity()});return L},total:function(){var L=0;r.each(function(M){L+=M.total()});return L},grandTotal:function(){return r.total()+r.tax()+r.shipping()},update:function(){r.save();r.trigger("update")},init:function(){r.load();r.update();r.ready()},$:function(L){return new r.ELEMENT(L)},$create:function(L){return r.$(l.createElement(L))},setupViewTool:function(){var L,O,M=j,N;for(N in E){if(Object.prototype.hasOwnProperty.call(E,N)&&j[N]){L=E[N].replace("*",N).split(".");O=L.shift();if(O){M=M[O]}if(typeof M==="function"){n=M;r.extend(r.ELEMENT._,J[N]);return}}}},ids:function(){var L=[];r.each(function(M){L.push(M.id())});return L},save:function(){r.trigger("beforeSave");var L={};r.each(function(M){L[M.id()]=r.extend(M.fields(),M.options())});F.setItem(t+"_items",JSON.stringify(L));r.trigger("afterSave")},load:function(){x={};var L=F.getItem(t+"_items");if(!L){return}try{r.each(JSON.parse(L),function(N){r.add(N,true)})}catch(M){r.error("Error Loading data: "+M)}r.trigger("load")},ready:function(L){if(b(L)){if(r.isReady){L.call(r)}else{r.bind("ready",L)}}else{if(e(L)&&!r.isReady){r.trigger("ready");r.isReady=true}}},error:function(L){var N="";if(a(L)){N=L}else{if(m(L)&&a(L.message)){N=L.message}}try{B.log("simpleCart(js) Error: "+N)}catch(M){}r.trigger("error",L)}});r.extend({tax:function(){var L=G.taxShipping?r.total()+r.shipping():r.total(),M=r.taxRate()*L;r.each(function(N){if(N.get("tax")){M+=N.get("tax")}else{if(N.get("taxRate")){M+=N.get("taxRate")*N.total()}}});return parseFloat(M)},taxRate:function(){return G.taxRate||0},shipping:function(L){if(b(L)){r({shippingCustom:L});return}var M=G.shippingQuantityRate*r.quantity()+G.shippingTotalRate*r.total()+G.shippingFlatRate;if(b(G.shippingCustom)){M+=G.shippingCustom.call(r)}r.each(function(N){M+=parseFloat(N.get("shipping")||0)});return parseFloat(M)}});p={attr:function(M,L){return M.get(L.attr)||""},currency:function(M,L){return r.toCurrency(M.get(L.attr)||0)},link:function(M,L){return"<a href='"+M.get(L.attr)+"'>"+L.text+"</a>"},decrement:function(M,L){return"<a href='javascript:;' class='"+t+"_decrement'>"+(L.text||"-")+"</a>"},increment:function(M,L){return"<a href='javascript:;' class='"+t+"_increment'>"+(L.text||"+")+"</a>"},image:function(M,L){return"<img src='"+M.get(L.attr)+"'/>"},input:function(M,L){return"<input type='text' value='"+M.get(L.attr)+"' class='"+t+"_input'/>"},remove:function(M,L){return"<a href='javascript:;' class='"+t+"_remove'>"+(L.text||"X")+"</a>"}};function v(M){var L=M||{};return r.extend({attr:"",label:"",view:"attr",text:"",className:"",hide:false},L)}function A(N,M){var L=b(M.view)?M.view:a(M.view)&&b(p[M.view])?p[M.view]:p.attr;return L.call(r,N,M)}r.extend({writeCart:function(R){var U=G.cartStyle.toLowerCase(),Y=U==="table",O=Y?"tr":"div",T=Y?"th":"div",X=Y?"td":"div",M=r.$create(U),N=r.$create(O).addClass("headerRow"),L=r.$(R),Q,S,W,V,P;L.html(" ").append(M);M.append(N);for(V=0,P=G.cartColumns.length;V<P;V+=1){Q=v(G.cartColumns[V]);S="item-"+(Q.attr||Q.view||Q.label||Q.text||"cell")+" "+Q.className;W=Q.label||"";N.append(r.$create(T).addClass(S).html(W))}r.each(function(Z,aa){r.createCartRow(Z,aa,O,X,M)});return M},createCartRow:function(V,R,M,S,L){var W=r.$create(M).addClass("itemRow row-"+R+" "+(R%2?"even":"odd")).attr("id","cartItem_"+V.id()),O,U,N,Q,P,T;L.append(W);for(O=0,U=G.cartColumns.length;O<U;O+=1){N=v(G.cartColumns[O]);Q="item-"+(N.attr||(a(N.view)?N.view:N.label||N.text||"cell"))+" "+N.className;P=A(V,N);T=r.$create(S).addClass(Q).html(P);W.append(T)}return W}});r.Item=function(O){var M={},N=this;if(m(O)){r.extend(M,O)}w+=1;M.id=M.id||s+w;while(!e(x[M.id])){w+=1;M.id=s+w}function L(){if(a(M.price)){M.price=parseFloat(M.price.replace(r.currency().decimal,".").replace(/[^0-9\.]+/ig,""))}if(isNaN(M.price)){M.price=0}if(M.price<0){M.price=0}if(a(M.quantity)){M.quantity=parseInt(M.quantity.replace(r.currency().delimiter,""),10)}if(isNaN(M.quantity)){M.quantity=1}if(M.quantity<=0){N.remove()}}N.get=function(Q,P){var R=!P;if(e(Q)){return Q}return b(M[Q])?M[Q].call(N):!e(M[Q])?M[Q]:b(N[Q])&&R?N[Q].call(N):!e(N[Q])&&R?N[Q]:M[Q]};N.set=function(P,Q){if(!e(P)){M[P.toLowerCase()]=Q;if(P.toLowerCase()==="price"||P.toLowerCase()==="quantity"){L()}}return N};N.equals=function(Q){for(var P in M){if(Object.prototype.hasOwnProperty.call(M,P)){if(P!=="quantity"&&P!=="id"){if(Q.get(P)!==M[P]){return false}}}}return true};N.options=function(){var P={};r.each(M,function(T,Q,R){var S=true;r.each(N.reservedFields(),function(U){if(U===R){S=false}return S});if(S){P[R]=N.get(R)}});return P};L()};r.Item._=r.Item.prototype={increment:function(L){var M=L||1;M=parseInt(M,10);this.quantity(this.quantity()+M);if(this.quantity()<1){this.remove();return null}return this},decrement:function(L){var M=L||1;return this.increment(-parseInt(M,10))},remove:function(M){var L=r.trigger("beforeRemove",[x[this.id()]]);if(L===false){return false}delete x[this.id()];if(!M){r.update()}return null},reservedFields:function(){return["quantity","id","item_number","price","name","shipping","tax","taxRate"]},fields:function(){var M={},L=this;r.each(L.reservedFields(),function(N){if(L.get(N)){M[N]=L.get(N)}});return M},quantity:function(L){return e(L)?parseInt(this.get("quantity",true)||1,10):this.set("quantity",L)},price:function(L){return e(L)?parseFloat((this.get("price",true).toString()).replace(r.currency().symbol,"").replace(r.currency().delimiter,"")||1):this.set("price",parseFloat((L).toString().replace(r.currency().symbol,"").replace(r.currency().delimiter,"")))},id:function(){return this.get("id",false)},total:function(){return this.quantity()*this.price()}};r.extend({checkout:function(){if(G.checkout.type.toLowerCase()==="custom"&&b(G.checkout.fn)){G.checkout.fn.call(r,G.checkout)}else{if(b(r.checkout[G.checkout.type])){var L=r.checkout[G.checkout.type].call(r,G.checkout);if(L.data&&L.action&&L.method){if(false!==r.trigger("beforeCheckout",[L.data])){r.generateAndSendForm(L)}}}else{r.error("No Valid Checkout Method Specified")}}},extendCheckout:function(L){return r.extend(r.checkout,L)},generateAndSendForm:function(M){var L=r.$create("form");L.attr("style","display:none;");L.attr("action",M.action);L.attr("method",M.method);L.attr("target","_blank");r.each(M.data,function(P,N,O){L.append(r.$create("input").attr("type","hidden").attr("name",O).val(P))});r.$("body").append(L);L.el.submit();L.remove()}});r.extendCheckout({PayPal:function(L){if(!L.email){return r.error("No email provided for PayPal checkout")}var N={cmd:"_cart",upload:"1",currency_code:r.currency().code,business:L.email,rm:L.method==="GET"?"0":"2",tax_cart:(r.tax()*1).toFixed(2),handling_cart:(r.shipping()*1).toFixed(2),charset:"utf-8"},M=L.sandbox?"https://www.sandbox.paypal.com/cgi-bin/webscr":"https://www.paypal.com/cgi-bin/webscr",O=L.method==="GET"?"GET":"POST";if(L.success){N["return"]=L.success}if(L.cancel){N.cancel_return=L.cancel}r.each(function(S,P){var R=P+1,Q=S.options(),U=0,T;N["item_name_"+R]=S.get("name");N["quantity_"+R]=S.quantity();N["amount_"+R]=(S.price()*1).toFixed(2);N["item_number_"+R]=S.get("item_number")||R;r.each(Q,function(X,W,V){if(W<10){T=true;r.each(G.excludeFromCheckout,function(Y){if(Y===V){T=false}});if(T){U+=1;N["on"+W+"_"+R]=V;N["os"+W+"_"+R]=X}}});N["option_index_"+P]=Math.min(10,U)});return{action:M,method:O,data:N}},GoogleCheckout:function(L){if(!L.merchantID){return r.error("No merchant id provided for GoogleCheckout")}if(r.currency().code!=="USD"&&r.currency().code!=="GBP"){return r.error("Google Checkout only accepts USD and GBP")}var N={ship_method_name_1:"Shipping",ship_method_price_1:r.shipping(),ship_method_currency_1:r.currency().code,_charset_:""},M="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/"+L.merchantID,O=L.method==="GET"?"GET":"POST";r.each(function(S,P){var Q=P+1,R=[],T;N["item_name_"+Q]=S.get("name");N["item_quantity_"+Q]=S.quantity();N["item_price_"+Q]=S.price();N["item_currency_ "+Q]=r.currency().code;N["item_tax_rate"+Q]=S.get("taxRate")||r.taxRate();r.each(S.options(),function(W,V,U){T=true;r.each(G.excludeFromCheckout,function(X){if(X===U){T=false}});if(T){R.push(U+": "+W)}});N["item_description_"+Q]=R.join(", ")});return{action:M,method:O,data:N}},AmazonPayments:function(L){if(!L.merchant_signature){return r.error("No merchant signature provided for Amazon Payments")}if(!L.merchant_id){return r.error("No merchant id provided for Amazon Payments")}if(!L.aws_access_key_id){return r.error("No AWS access key id provided for Amazon Payments")}var N={aws_access_key_id:L.aws_access_key_id,merchant_signature:L.merchant_signature,currency_code:r.currency().code,tax_rate:r.taxRate(),weight_unit:L.weight_unit||"lb"},M=(L.sandbox?"https://sandbox.google.com/checkout/":"https://checkout.google.com/")+"cws/v2/Merchant/"+L.merchant_id+"/checkoutForm",O=L.method==="GET"?"GET":"POST";r.each(function(S,P){var Q=P+1,R=[];N["item_title_"+Q]=S.get("name");N["item_quantity_"+Q]=S.quantity();N["item_price_"+Q]=S.price();N["item_sku_ "+Q]=S.get("sku")||S.id();N["item_merchant_id_"+Q]=L.merchant_id;if(S.get("weight")){N["item_weight_"+Q]=S.get("weight")}if(G.shippingQuantityRate){N["shipping_method_price_per_unit_rate_"+Q]=G.shippingQuantityRate}r.each(S.options(),function(W,U,T){var V=true;r.each(G.excludeFromCheckout,function(X){if(X===T){V=false}});if(V&&T!=="weight"&&T!=="tax"){R.push(T+": "+W)}});N["item_description_"+Q]=R.join(", ")});return{action:M,method:O,data:N}},SendForm:function(L){if(!L.url){return r.error("URL required for SendForm Checkout")}var N={currency:r.currency().code,shipping:r.shipping(),tax:r.tax(),taxRate:r.taxRate(),itemCount:r.find({}).length},M=L.url,O=L.method==="GET"?"GET":"POST";r.each(function(S,P){var Q=P+1,R=[],T;N["item_name_"+Q]=S.get("name");N["item_quantity_"+Q]=S.quantity();N["item_price_"+Q]=S.price();r.each(S.options(),function(W,V,U){T=true;r.each(G.excludeFromCheckout,function(X){if(X===U){T=false}});if(T){R.push(U+": "+W)}});N["item_options_"+Q]=R.join(", ")});if(L.success){N["return"]=L.success}if(L.cancel){N.cancel_return=L.cancel}if(L.extra_data){N=r.extend(N,L.extra_data)}return{action:M,method:O,data:N}}});C={bind:function(L,N){if(!b(N)){return this}if(!this._events){this._events={}}var M=L.split(/ +/);r.each(M,function(O){if(this._events[O]===true){N.apply(this)}else{if(!e(this._events[O])){this._events[O].push(N)}else{this._events[O]=[N]}}});return this},trigger:function(O,N){var P=true,L,M;if(!this._events){this._events={}}if(!e(this._events[O])&&b(this._events[O][0])){for(L=0,M=this._events[O].length;L<M;L+=1){P=this._events[O][L].apply(this,(N||[]))}}if(P===false){return false}return true}};C.on=C.bind;r.extend(C);r.extend(r.Item._,C);u={beforeAdd:null,afterAdd:null,load:null,beforeSave:null,afterSave:null,update:null,ready:null,checkoutSuccess:null,checkoutFail:null,beforeCheckout:null,beforeRemove:null};r(u);r.each(u,function(N,L,M){r.bind(M,function(){if(b(G[M])){G[M].apply(this,arguments)}})});r.extend({toCurrency:function(O,N){var L=parseFloat(O),P=N||{},M=r.extend(r.extend({symbol:"$",decimal:".",delimiter:",",accuracy:2,after:false},r.currency()),P),S=L.toFixed(M.accuracy).split("."),R=S[1],Q=S[0];Q=r.chunk(Q.reverse(),3).join(M.delimiter.reverse()).reverse();return(!M.after?M.symbol:"")+Q+(R?M.decimal+R:"")+(M.after?M.symbol:"")},chunk:function(M,N){if(typeof N==="undefined"){N=2}var L=M.match(new RegExp(".{1,"+N+"}","g"));return L||[]}});String.prototype.reverse=function(){return this.split("").reverse().join("")};r.extend({currency:function(L){if(a(L)&&!e(D[L])){G.currency=L}else{if(m(L)){D[L.code]=L;G.currency=L.code}else{return D[G.currency]}}}});r.extend({bindOutlets:function(L){r.each(L,function(O,N,M){r.bind("update",function(){r.setOutlet("."+t+"_"+M,O)})})},setOutlet:function(L,M){var N=M.call(r,L);if(m(N)&&N.el){r.$(L).html(" ").append(N)}else{if(!e(N)){r.$(L).html(N)}}},bindInputs:function(L){r.each(L,function(M){r.setInput("."+t+"_"+M.selector,M.event,M.callback)})},setInput:function(L,N,M){r.$(L).live(N,M)}});r.ELEMENT=function(L){this.create(L);this.selector=L||null};r.extend(J,{MooTools:{text:function(L){return this.attr(I,L)},html:function(L){return this.attr(K,L)},val:function(L){return this.attr(z,L)},attr:function(L,M){if(e(M)){return this.el[0]&&this.el[0].get(L)}this.el.set(L,M);return this},remove:function(){this.el.dispose();return null},addClass:function(L){this.el.addClass(L);return this},removeClass:function(L){this.el.removeClass(L);return this},append:function(L){this.el.adopt(L.el);return this},each:function(L){if(b(L)){r.each(this.el,function(N,M,O){L.call(M,M,N,O)})}return this},click:function(L){if(b(L)){this.each(function(M){M.addEvent(y,function(N){L.call(M,N)})})}else{if(e(L)){this.el.fireEvent(y)}}return this},live:function(M,N){var L=this.selector;if(b(N)){r.$("body").el.addEvent(M+":relay("+L+")",function(P,O){N.call(O,P)})}},match:function(L){return this.el.match(L)},parent:function(){return r.$(this.el.getParent())},find:function(L){return r.$(this.el.getElements(L))},closest:function(L){return r.$(this.el.getParent(L))},descendants:function(){return this.find("*")},tag:function(){return this.el[0].tagName},submit:function(){this.el[0].submit();return this},create:function(L){this.el=n(L)}},Prototype:{text:function(L){if(e(L)){return this.el[0].innerHTML}this.each(function(M,N){$(N).update(L)});return this},html:function(L){return this.text(L)},val:function(L){return this.attr(z,L)},attr:function(L,M){if(e(M)){return this.el[0].readAttribute(L)}this.each(function(N,O){$(O).writeAttribute(L,M)});return this},append:function(L){this.each(function(M,N){if(L.el){L.each(function(O,P){$(N).appendChild(P)})}else{if(k(L)){$(N).appendChild(L)}}});return this},remove:function(){this.each(function(L,M){$(M).remove()});return this},addClass:function(L){this.each(function(M,N){$(N).addClassName(L)});return this},removeClass:function(L){this.each(function(M,N){$(N).removeClassName(L)});return this},each:function(L){if(b(L)){r.each(this.el,function(N,M,O){L.call(M,M,N,O)})}return this},click:function(L){if(b(L)){this.each(function(M,N){$(N).observe(y,function(O){L.call(N,O)})})}else{if(e(L)){this.each(function(M,N){$(N).fire(y)})}}return this},live:function(M,N){if(b(N)){var L=this.selector;l.observe(M,function(P,O){if(O===n(P).findElement(L)){N.call(O,P)}})}},parent:function(){return r.$(this.el.up())},find:function(L){return r.$(this.el.getElementsBySelector(L))},closest:function(L){return r.$(this.el.up(L))},descendants:function(){return r.$(this.el.descendants())},tag:function(){return this.el.tagName},submit:function(){this.el[0].submit()},create:function(L){if(a(L)){this.el=n(L)}else{if(k(L)){this.el=[L]}}}},jQuery:{passthrough:function(L,M){if(e(M)){return this.el[L]()}this.el[L](M);return this},text:function(L){return this.passthrough(I,L)},html:function(L){return this.passthrough(K,L)},val:function(L){return this.passthrough("val",L)},append:function(L){var M=L.el||L;this.el.append(M);return this},attr:function(L,M){if(e(M)){return this.el.attr(L)}this.el.attr(L,M);return this},remove:function(){this.el.remove();return this},addClass:function(L){this.el.addClass(L);return this},removeClass:function(L){this.el.removeClass(L);return this},each:function(L){return this.passthrough("each",L)},click:function(L){return this.passthrough(y,L)},live:function(L,M){n(l).delegate(this.selector,L,M);return this},parent:function(){return r.$(this.el.parent())},find:function(L){return r.$(this.el.find(L))},closest:function(L){return r.$(this.el.closest(L))},tag:function(){return this.el[0].tagName},descendants:function(){return r.$(this.el.find("*"))},submit:function(){return this.el.submit()},create:function(L){this.el=n(L)}}});r.ELEMENT._=r.ELEMENT.prototype;r.ready(r.setupViewTool);r.ready(function(){r.bindOutlets({total:function(){return r.toCurrency(r.total())},quantity:function(){return r.quantity()},items:function(L){r.writeCart(L)},tax:function(){return r.toCurrency(r.tax())},taxRate:function(){return r.taxRate().toFixed()},shipping:function(){return r.toCurrency(r.shipping())},grandTotal:function(){return r.toCurrency(r.grandTotal())}});r.bindInputs([{selector:"checkout",event:"click",callback:function(){r.checkout()}},{selector:"empty",event:"click",callback:function(){r.empty()}},{selector:"increment",event:"click",callback:function(){r.find(r.$(this).closest(".itemRow").attr("id").split("_")[1]).increment();r.update()}},{selector:"decrement",event:"click",callback:function(){r.find(r.$(this).closest(".itemRow").attr("id").split("_")[1]).decrement();r.update()}},{selector:"remove",event:"click",callback:function(){r.find(r.$(this).closest(".itemRow").attr("id").split("_")[1]).remove()}},{selector:"input",event:"change",callback:function(){var N=r.$(this),L=N.parent(),M=L.attr("class").split(" ");r.each(M,function(O){if(O.match(/item-.+/i)){var P=O.split("-")[1];r.find(L.closest(".itemRow").attr("id").split("_")[1]).set(P,N.val());r.update();return}})}},{selector:"shelfItem .item_add",event:"click",callback:function(){var M=r.$(this),L={};M.closest("."+t+"_shelfItem").descendants().each(function(N,P){var O=r.$(P);if(O.attr("class")&&O.attr("class").match(/item_.+/)&&!O.attr("class").match(/item_add/)){r.each(O.attr("class").split(" "),function(R){var Q,T,S;if(R.match(/item_.+/)){Q=R.split("_")[1];T="";switch(O.tag().toLowerCase()){case"input":case"textarea":case"select":S=O.attr("type");if(!S||((S.toLowerCase()==="checkbox"||S.toLowerCase()==="radio")&&O.attr("checked"))||S.toLowerCase()==="text"){T=O.val()}break;case"img":T=O.attr("src");break;default:T=O.text();break}if(T!==null&&T!==""){L[Q.toLowerCase()]=L[Q.toLowerCase()]?L[Q.toLowerCase()]+", "+T:T}}})}});r.add(L)}}])});if(l.addEventListener){j.DOMContentLoaded=function(){l.removeEventListener("DOMContentLoaded",DOMContentLoaded,false);r.init()}}else{if(l.attachEvent){j.DOMContentLoaded=function(){if(l.readyState==="complete"){l.detachEvent("onreadystatechange",DOMContentLoaded);r.init()}}}}function o(){if(r.isReady){return}try{l.documentElement.doScroll("left")}catch(L){setTimeout(o,1);return}r.init()}function q(){if(l.readyState==="complete"){return setTimeout(r.init,1)}if(l.addEventListener){l.addEventListener("DOMContentLoaded",DOMContentLoaded,false);j.addEventListener("load",r.init,false)}else{if(l.attachEvent){l.attachEvent("onreadystatechange",DOMContentLoaded);j.attachEvent("onload",r.init);var L=false;try{L=j.frameElement===null}catch(M){}if(l.documentElement.doScroll&&L){o()}}}}q();return r};j.simpleCart=f()}(window,document));var JSON;JSON||(JSON={});(function(){function k(a){return a<10?"0"+a:a}function o(a){p.lastIndex=0;return p.test(a)?'"'+a.replace(p,function(a){var c=r[a];return typeof c==="string"?c:"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+a+'"'}function l(a,j){var c,d,h,m,g=e,f,b=j[a];b&&typeof b==="object"&&typeof b.toJSON==="function"&&(b=b.toJSON(a));typeof i==="function"&&(b=i.call(j,a,b));switch(typeof b){case"string":return o(b);case"number":return isFinite(b)?String(b):"null";case"boolean":case"null":return String(b);case"object":if(!b){return"null"}e+=n;f=[];if(Object.prototype.toString.apply(b)==="[object Array]"){m=b.length;for(c=0;c<m;c+=1){f[c]=l(c,b)||"null"}h=f.length===0?"[]":e?"[\n"+e+f.join(",\n"+e)+"\n"+g+"]":"["+f.join(",")+"]";e=g;return h}if(i&&typeof i==="object"){m=i.length;for(c=0;c<m;c+=1){typeof i[c]==="string"&&(d=i[c],(h=l(d,b))&&f.push(o(d)+(e?": ":":")+h))}}else{for(d in b){Object.prototype.hasOwnProperty.call(b,d)&&(h=l(d,b))&&f.push(o(d)+(e?": ":":")+h)}}h=f.length===0?"{}":e?"{\n"+e+f.join(",\n"+e)+"\n"+g+"}":"{"+f.join(",")+"}";e=g;return h}}if(typeof Date.prototype.toJSON!=="function"){Date.prototype.toJSON=function(){return isFinite(this.valueOf())?this.getUTCFullYear()+"-"+k(this.getUTCMonth()+1)+"-"+k(this.getUTCDate())+"T"+k(this.getUTCHours())+":"+k(this.getUTCMinutes())+":"+k(this.getUTCSeconds())+"Z":null},String.prototype.toJSON=Number.prototype.toJSON=Boolean.prototype.toJSON=function(){return this.valueOf()}}var q=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,p=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,e,n,r={"\u0008":"\\b","\t":"\\t","\n":"\\n","\u000c":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},i;if(typeof JSON.stringify!=="function"){JSON.stringify=function(a,j,c){var d;n=e="";if(typeof c==="number"){for(d=0;d<c;d+=1){n+=" "}}else{typeof c==="string"&&(n=c)}if((i=j)&&typeof j!=="function"&&(typeof j!=="object"||typeof j.length!=="number")){throw Error("JSON.stringify")}return l("",{"":a})}}if(typeof JSON.parse!=="function"){JSON.parse=function(a,e){function c(a,d){var g,f,b=a[d];if(b&&typeof b==="object"){for(g in b){Object.prototype.hasOwnProperty.call(b,g)&&(f=c(b,g),f!==void 0?b[g]=f:delete b[g])}}return e.call(a,d,b)}var d,a=String(a);q.lastIndex=0;q.test(a)&&(a=a.replace(q,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)}));if(/^[\],:{}\s]*$/.test(a.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@").replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]").replace(/(?:^|:|,)(?:\s*\[)+/g,""))){return d=eval("("+a+")"),typeof e==="function"?c({"":d},""):d}throw new SyntaxError("JSON.parse")}}})();(function(){if(!this.localStorage){if(this.globalStorage){try{this.localStorage=this.globalStorage}catch(f){}}else{var b=document.createElement("div");b.style.display="none";document.getElementsByTagName("head")[0].appendChild(b);if(b.addBehavior){b.addBehavior("#default#userdata");var g=this.localStorage={length:0,setItem:function(a,c){b.load("localStorage");a=h(a);b.getAttribute(a)||this.length++;b.setAttribute(a,c);b.save("localStorage")},getItem:function(a){b.load("localStorage");a=h(a);return b.getAttribute(a)},removeItem:function(a){b.load("localStorage");a=h(a);b.removeAttribute(a);b.save("localStorage");this.length=0},clear:function(){b.load("localStorage");for(var a=0;attr=b.XMLDocument.documentElement.attributes[a++];){b.removeAttribute(attr.name)}b.save("localStorage");this.length=0},key:function(a){b.load("localStorage");return b.XMLDocument.documentElement.attributes[a]}},h=function(c){return c.replace(/[^-._0-9A-Za-z\xb7\xc0-\xd6\xd8-\xf6\xf8-\u037d\u37f-\u1fff\u200c-\u200d\u203f\u2040\u2070-\u218f]/g,"-")};b.load("localStorage");g.length=b.XMLDocument.documentElement.attributes.length}}}})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment