forked from wojodesign/simplecart-js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
simpleCart.min.js
executable file
·1 lines (1 loc) · 21.4 KB
/
simpleCart.min.js
1
!function(t,e){var n="string",r="undefined",i="function",a=typeof{},c=function(t,e){return typeof t===e},o=function(t){return c(t,n)},u=function(t){return c(t,r)},s=function(t){return c(t,i)},l=function(t){return c(t,a)},h=function(t){return"object"==typeof HTMLElement?t instanceof HTMLElement:"object"==typeof t&&1===t.nodeType&&"string"==typeof t.nodeName},d=function(n){function r(t){var e=t||{};return T.extend({attr:"",label:"",view:"attr",text:"",className:"",hide:!1},e)}function i(t,e){var n=s(e.view)?e.view:o(e.view)&&s(m[e.view])?m[e.view]:m.attr;return n.call(T,t,e)}function a(){if(!T.isReady){try{e.documentElement.doScroll("left")}catch(t){return void setTimeout(a,1)}T.init()}}function c(){if("complete"===e.readyState)return setTimeout(T.init,1);if(e.addEventListener)e.addEventListener("DOMContentLoaded",DOMContentLoaded,!1),t.addEventListener("load",T.init,!1);else if(e.attachEvent){e.attachEvent("onreadystatechange",DOMContentLoaded),t.attachEvent("onload",T.init);var n=!1;try{n=null===t.frameElement}catch(r){}e.documentElement.doScroll&&n&&a()}}var f,m,p={MooTools:"$$",Prototype:"$$",jQuery:"*"},y=0,v="SCI-",g={},_=n||"simpleCart",b={},x={},C={},w=t.localStorage,k=t.console||{msgs:[],log:function(t){k.msgs.push(t)}},E="value",S="text",R="html",F="click",L={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",accuracy:0},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}},N={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:!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:{}},T=function(t){return s(t)?T.ready(t):l(t)?T.extend(N,t):void 0};return T.extend=function(t,e){var n;u(e)&&(e=t,t=T);for(n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},T.extend({copy:function(t){var e=d(t);return e.init(),e}}),T.extend({isReady:!1,add:function(t,e){var n,r=t||{},i=new T.Item(r),a=!0,c=e===!0?e:!1;return c||(a=T.trigger("beforeAdd",[i]),a!==!1)?(n=T.has(i),n?(n.increment(i.quantity()),i=n):g[i.id()]=i,T.update(),c||T.trigger("afterAdd",[i,u(n)]),i):!1},each:function(t,e){var n,r,i,a,c=0;if(s(t))i=t,a=g;else{if(!s(e))return;i=e,a=t}for(n in a)if(Object.prototype.hasOwnProperty.call(a,n)){if(r=i.call(T,a[n],c,n),r===!1)return;c+=1}},find:function(t){var e=[];return l(g[t])?g[t]:l(t)?(T.each(function(n){var r=!0;T.each(t,function(t,e,i){return o(t)?t.match(/<=.*/)?(t=parseFloat(t.replace("<=","")),n.get(i)&&parseFloat(n.get(i))<=t||(r=!1)):t.match(/</)?(t=parseFloat(t.replace("<","")),n.get(i)&&parseFloat(n.get(i))<t||(r=!1)):t.match(/>=/)?(t=parseFloat(t.replace(">=","")),n.get(i)&&parseFloat(n.get(i))>=t||(r=!1)):t.match(/>/)?(t=parseFloat(t.replace(">","")),n.get(i)&&parseFloat(n.get(i))>t||(r=!1)):n.get(i)&&n.get(i)===t||(r=!1):n.get(i)&&n.get(i)===t||(r=!1),r}),r&&e.push(n)}),e):u(t)?(T.each(function(t){e.push(t)}),e):e},items:function(){return this.find()},has:function(t){var e=!1;return T.each(function(n){n.equals(t)&&(e=n)}),e},empty:function(){var t={};T.each(function(e){e.remove(!0)===!1&&(t[e.id()]=e)}),g=t,T.update()},quantity:function(){var t=0;return T.each(function(e){t+=e.quantity()}),t},total:function(){var t=0;return T.each(function(e){t+=e.total()}),t},grandTotal:function(){return T.total()+T.tax()+T.shipping()},update:function(){T.save(),T.trigger("update")},init:function(){T.load(),T.update(),T.ready()},$:function(t){return new T.ELEMENT(t)},$create:function(t){return T.$(e.createElement(t))},setupViewTool:function(){var e,n,r,i=t;for(r in p)if(Object.prototype.hasOwnProperty.call(p,r)&&t[r]&&(e=p[r].replace("*",r).split("."),n=e.shift(),n&&(i=i[n]),"function"==typeof i))return f=i,void T.extend(T.ELEMENT._,b[r])},ids:function(){var t=[];return T.each(function(e){t.push(e.id())}),t},save:function(){T.trigger("beforeSave");var t={};T.each(function(e){t[e.id()]=T.extend(e.fields(),e.options())}),w.setItem(_+"_items",JSON.stringify(t)),T.trigger("afterSave")},load:function(){g={};var t=w.getItem(_+"_items");if(t){try{T.each(JSON.parse(t),function(t){T.add(t,!0)})}catch(e){T.error("Error Loading data: "+e)}T.trigger("load")}},ready:function(t){s(t)?T.isReady?t.call(T):T.bind("ready",t):u(t)&&!T.isReady&&(T.trigger("ready"),T.isReady=!0)},error:function(t){var e="";o(t)?e=t:l(t)&&o(t.message)&&(e=t.message);try{k.log("simpleCart(js) Error: "+e)}catch(n){}T.trigger("error",[t])}}),T.extend({tax:function(){var t=N.taxShipping?T.total()+T.shipping():T.total(),e=T.taxRate()*t;return T.each(function(t){t.get("tax")?e+=t.get("tax"):t.get("taxRate")&&(e+=t.get("taxRate")*t.total())}),parseFloat(e)},taxRate:function(){return N.taxRate||0},shipping:function(t){if(s(t))return void T({shippingCustom:t});var e=N.shippingQuantityRate*T.quantity()+N.shippingTotalRate*T.total()+N.shippingFlatRate;return s(N.shippingCustom)&&(e+=N.shippingCustom.call(T)),T.each(function(t){e+=parseFloat(t.get("shipping")||0)}),parseFloat(e)}}),m={attr:function(t,e){return t.get(e.attr)||""},currency:function(t,e){return T.toCurrency(t.get(e.attr)||0)},link:function(t,e){return"<a href='"+t.get(e.attr)+"'>"+e.text+"</a>"},decrement:function(t,e){return"<a href='javascript:;' class='"+_+"_decrement'>"+(e.text||"-")+"</a>"},increment:function(t,e){return"<a href='javascript:;' class='"+_+"_increment'>"+(e.text||"+")+"</a>"},image:function(t,e){return"<img src='"+t.get(e.attr)+"'/>"},input:function(t,e){return"<input type='text' value='"+t.get(e.attr)+"' class='"+_+"_input'/>"},remove:function(t,e){return"<a href='javascript:;' class='"+_+"_remove'>"+(e.text||"X")+"</a>"}},T.extend({writeCart:function(t){var e,n,i,a,c,o=N.cartStyle.toLowerCase(),u="table"===o,s=u?"tr":"div",l=u?"th":"div",h=u?"td":"div",d=u?"thead":"div",f=T.$create(o),m=T.$create(d),p=T.$create(s).addClass("headerRow"),y=T.$(t);for(y.html(" ").append(f),f.append(m),m.append(p),a=0,c=N.cartColumns.length;c>a;a+=1)e=r(N.cartColumns[a]),n="item-"+(e.attr||e.view||e.label||e.text||"cell")+" "+e.className,i=e.label||"",p.append(T.$create(l).addClass(n).html(i));return T.each(function(t,e){T.createCartRow(t,e,s,h,f)}),f},createCartRow:function(t,e,n,a,c){var u,s,l,h,d,f,m=T.$create(n).addClass("itemRow row-"+e+" "+(e%2?"even":"odd")).attr("id","cartItem_"+t.id());for(c.append(m),u=0,s=N.cartColumns.length;s>u;u+=1)l=r(N.cartColumns[u]),h="item-"+(l.attr||(o(l.view)?l.view:l.label||l.text||"cell"))+" "+l.className,d=i(t,l),f=T.$create(a).addClass(h).html(d),m.append(f);return m}}),T.Item=function(t){function e(){o(n.price)&&(n.price=parseFloat(n.price.replace(T.currency().decimal,".").replace(/[^0-9\.]+/gi,""))),isNaN(n.price)&&(n.price=0),n.price<0&&(n.price=0),o(n.quantity)&&(n.quantity=parseInt(n.quantity.replace(T.currency().delimiter,""),10)),isNaN(n.quantity)&&(n.quantity=1),n.quantity<=0&&r.remove()}var n={},r=this;for(l(t)&&T.extend(n,t),y+=1,n.id=n.id||v+y;!u(g[n.id]);)y+=1,n.id=v+y;r.get=function(t,e){var i=!e;return u(t)?t:s(n[t])?n[t].call(r):u(n[t])?s(r[t])&&i?r[t].call(r):!u(r[t])&&i?r[t]:n[t]:n[t]},r.set=function(t,i){return u(t)||(n[t.toLowerCase()]=i,("price"===t.toLowerCase()||"quantity"===t.toLowerCase())&&e()),r},r.equals=function(t){for(var e in n)if(Object.prototype.hasOwnProperty.call(n,e)&&"quantity"!==e&&"id"!==e&&t.get(e)!==n[e])return!1;return!0},r.options=function(){var t={};return T.each(n,function(e,n,i){var a=!0;T.each(r.reservedFields(),function(t){return t===i&&(a=!1),a}),a&&(t[i]=r.get(i))}),t},e()},T.Item._=T.Item.prototype={increment:function(t){var e=t||1;return e=parseInt(e,10),this.quantity(this.quantity()+e),this.quantity()<1?(this.remove(),null):this},decrement:function(t){var e=t||1;return this.increment(-parseInt(e,10))},remove:function(t){var e=T.trigger("beforeRemove",[g[this.id()]]);return e===!1?!1:(delete g[this.id()],t||T.update(),null)},reservedFields:function(){return["quantity","id","item_number","price","name","shipping","tax","taxRate"]},fields:function(){var t={},e=this;return T.each(e.reservedFields(),function(n){e.get(n)&&(t[n]=e.get(n))}),t},quantity:function(t){return u(t)?parseInt(this.get("quantity",!0)||1,10):this.set("quantity",t)},price:function(t){return u(t)?parseFloat(this.get("price",!0).toString().replace(T.currency().symbol,"").replace(T.currency().delimiter,"")||1):this.set("price",parseFloat(t.toString().replace(T.currency().symbol,"").replace(T.currency().delimiter,"")))},id:function(){return this.get("id",!1)},total:function(){return this.quantity()*this.price()}},T.extend({checkout:function(){if("custom"===N.checkout.type.toLowerCase()&&s(N.checkout.fn))N.checkout.fn.call(T,N.checkout);else if(s(T.checkout[N.checkout.type])){var t=T.checkout[N.checkout.type].call(T,N.checkout);t.data&&t.action&&t.method&&!1!==T.trigger("beforeCheckout",[t.data])&&T.generateAndSendForm(t)}else T.error("No Valid Checkout Method Specified")},extendCheckout:function(t){return T.extend(T.checkout,t)},generateAndSendForm:function(t){var e=T.$create("form");e.attr("style","display:none;"),e.attr("action",t.action),e.attr("method",t.method),T.each(t.data,function(t,n,r){e.append(T.$create("input").attr("type","hidden").attr("name",r).val(t))}),T.$("body").append(e),e.el.submit(),e.remove()}}),T.extendCheckout({PayPal:function(t){if(!t.email)return T.error("No email provided for PayPal checkout");var e={cmd:"_cart",upload:"1",currency_code:T.currency().code,business:t.email,rm:"GET"===t.method?"0":"2",tax_cart:(1*T.tax()).toFixed(2),handling_cart:(1*T.shipping()).toFixed(2),charset:"utf-8"},n=t.sandbox?"https://www.sandbox.paypal.com/cgi-bin/webscr":"https://www.paypal.com/cgi-bin/webscr",r="GET"===t.method?"GET":"POST";return t.success&&(e["return"]=t.success),t.cancel&&(e.cancel_return=t.cancel),t.notify&&(e.notify_url=t.notify),T.each(function(t,n){var r,i=n+1,a=t.options(),c=0;e["item_name_"+i]=t.get("name"),e["quantity_"+i]=t.quantity(),e["amount_"+i]=(1*t.price()).toFixed(2),e["item_number_"+i]=t.get("item_number")||i,T.each(a,function(t,n,a){10>n&&(r=!0,T.each(N.excludeFromCheckout,function(t){t===a&&(r=!1)}),r&&(c+=1,e["on"+n+"_"+i]=a,e["os"+n+"_"+i]=t))}),e["option_index_"+n]=Math.min(10,c)}),{action:n,method:r,data:e}},GoogleCheckout:function(t){if(!t.merchantID)return T.error("No merchant id provided for GoogleCheckout");if("USD"!==T.currency().code&&"GBP"!==T.currency().code)return T.error("Google Checkout only accepts USD and GBP");var e={ship_method_name_1:"Shipping",ship_method_price_1:T.shipping(),ship_method_currency_1:T.currency().code,_charset_:""},n="https://checkout.google.com/api/checkout/v2/checkoutForm/Merchant/"+t.merchantID,r="GET"===t.method?"GET":"POST";return T.each(function(t,n){var r,i=n+1,a=[];e["item_name_"+i]=t.get("name"),e["item_quantity_"+i]=t.quantity(),e["item_price_"+i]=t.price(),e["item_currency_ "+i]=T.currency().code,e["item_tax_rate"+i]=t.get("taxRate")||T.taxRate(),T.each(t.options(),function(t,e,n){r=!0,T.each(N.excludeFromCheckout,function(t){t===n&&(r=!1)}),r&&a.push(n+": "+t)}),e["item_description_"+i]=a.join(", ")}),{action:n,method:r,data:e}},AmazonPayments:function(t){if(!t.merchant_signature)return T.error("No merchant signature provided for Amazon Payments");if(!t.merchant_id)return T.error("No merchant id provided for Amazon Payments");if(!t.aws_access_key_id)return T.error("No AWS access key id provided for Amazon Payments");var e={aws_access_key_id:t.aws_access_key_id,merchant_signature:t.merchant_signature,currency_code:T.currency().code,tax_rate:T.taxRate(),weight_unit:t.weight_unit||"lb"},n="https://payments"+(t.sandbox?"-sandbox":"")+".amazon.com/checkout/"+t.merchant_id,r="GET"===t.method?"GET":"POST";return T.each(function(n,r){var i=r+1,a=[];e["item_title_"+i]=n.get("name"),e["item_quantity_"+i]=n.quantity(),e["item_price_"+i]=n.price(),e["item_sku_ "+i]=n.get("sku")||n.id(),e["item_merchant_id_"+i]=t.merchant_id,n.get("weight")&&(e["item_weight_"+i]=n.get("weight")),N.shippingQuantityRate&&(e["shipping_method_price_per_unit_rate_"+i]=N.shippingQuantityRate),T.each(n.options(),function(t,e,n){var r=!0;T.each(N.excludeFromCheckout,function(t){t===n&&(r=!1)}),r&&"weight"!==n&&"tax"!==n&&a.push(n+": "+t)}),e["item_description_"+i]=a.join(", ")}),{action:n,method:r,data:e}},SendForm:function(t){if(!t.url)return T.error("URL required for SendForm Checkout");var e={currency:T.currency().code,shipping:T.shipping(),tax:T.tax(),taxRate:T.taxRate(),itemCount:T.find({}).length},n=t.url,r="GET"===t.method?"GET":"POST";return T.each(function(t,n){var r,i=n+1,a=[];e["item_name_"+i]=t.get("name"),e["item_quantity_"+i]=t.quantity(),e["item_price_"+i]=t.price(),T.each(t.options(),function(t,e,n){r=!0,T.each(N.excludeFromCheckout,function(t){t===n&&(r=!1)}),r&&a.push(n+": "+t)}),e["item_options_"+i]=a.join(", ")}),t.success&&(e["return"]=t.success),t.cancel&&(e.cancel_return=t.cancel),t.extra_data&&(e=T.extend(e,t.extra_data)),{action:n,method:r,data:e}}}),x={bind:function(t,e){if(!s(e))return this;this._events||(this._events={});var n=t.split(/ +/);return T.each(n,function(t){this._events[t]===!0?e.apply(this):u(this._events[t])?this._events[t]=[e]:this._events[t].push(e)}),this},trigger:function(t,e){var n,r,i=!0;if(this._events||(this._events={}),!u(this._events[t])&&s(this._events[t][0]))for(n=0,r=this._events[t].length;r>n;n+=1)i=this._events[t][n].apply(this,e||[]);return i===!1?!1:!0}},x.on=x.bind,T.extend(x),T.extend(T.Item._,x),C={beforeAdd:null,afterAdd:null,load:null,beforeSave:null,afterSave:null,update:null,ready:null,checkoutSuccess:null,checkoutFail:null,beforeCheckout:null,beforeRemove:null},T(C),T.each(C,function(t,e,n){T.bind(n,function(){s(N[n])&&N[n].apply(this,arguments)})}),T.extend({toCurrency:function(t,e){var n=parseFloat(t),r=e||{},i=T.extend(T.extend({symbol:"$",decimal:".",delimiter:",",accuracy:2,after:!1},T.currency()),r),a=n.toFixed(i.accuracy).split("."),c=a[1],o=a[0];return o=T.chunk(o.reverse(),3).join(i.delimiter.reverse()).reverse(),(i.after?"":i.symbol)+o+(c?i.decimal+c:"")+(i.after?i.symbol:"")},chunk:function(t,e){"undefined"==typeof e&&(e=2);var n=t.match(new RegExp(".{1,"+e+"}","g"));return n||[]}}),String.prototype.reverse=function(){return this.split("").reverse().join("")},T.extend({currency:function(t){if(o(t)&&!u(L[t]))N.currency=t;else{if(!l(t))return L[N.currency];L[t.code]=t,N.currency=t.code}}}),T.extend({bindOutlets:function(t){T.each(t,function(t,e,n){T.bind("update",function(){T.setOutlet("."+_+"_"+n,t)})})},setOutlet:function(t,e){var n=e.call(T,t);l(n)&&n.el?T.$(t).html(" ").append(n):u(n)||T.$(t).html(n)},bindInputs:function(t){T.each(t,function(t){T.setInput("."+_+"_"+t.selector,t.event,t.callback)})},setInput:function(t,e,n){T.$(t).live(e,n)}}),T.ELEMENT=function(t){this.create(t),this.selector=t||null},T.extend(b,{MooTools:{text:function(t){return this.attr(S,t)},html:function(t){return this.attr(R,t)},val:function(t){return this.attr(E,t)},attr:function(t,e){return u(e)?this.el[0]&&this.el[0].get(t):(this.el.set(t,e),this)},remove:function(){return this.el.dispose(),null},addClass:function(t){return this.el.addClass(t),this},removeClass:function(t){return this.el.removeClass(t),this},append:function(t){return this.el.adopt(t.el),this},each:function(t){return s(t)&&T.each(this.el,function(e,n,r){t.call(n,n,e,r)}),this},click:function(t){return s(t)?this.each(function(e){e.addEvent(F,function(n){t.call(e,n)})}):u(t)&&this.el.fireEvent(F),this},live:function(t,e){var n=this.selector;s(e)&&T.$("body").el.addEvent(t+":relay("+n+")",function(t,n){e.call(n,t)})},match:function(t){return this.el.match(t)},parent:function(){return T.$(this.el.getParent())},find:function(t){return T.$(this.el.getElements(t))},closest:function(t){return T.$(this.el.getParent(t))},descendants:function(){return this.find("*")},tag:function(){return this.el[0].tagName},submit:function(){return this.el[0].submit(),this},create:function(t){this.el=f(t)}},Prototype:{text:function(t){return u(t)?this.el[0].innerHTML:(this.each(function(e,n){$(n).update(t)}),this)},html:function(t){return this.text(t)},val:function(t){return this.attr(E,t)},attr:function(t,e){return u(e)?this.el[0].readAttribute(t):(this.each(function(n,r){$(r).writeAttribute(t,e)}),this)},append:function(t){return this.each(function(e,n){t.el?t.each(function(t,e){$(n).appendChild(e)}):h(t)&&$(n).appendChild(t)}),this},remove:function(){return this.each(function(t,e){$(e).remove()}),this},addClass:function(t){return this.each(function(e,n){$(n).addClassName(t)}),this},removeClass:function(t){return this.each(function(e,n){$(n).removeClassName(t)}),this},each:function(t){return s(t)&&T.each(this.el,function(e,n,r){t.call(n,n,e,r)}),this},click:function(t){return s(t)?this.each(function(e,n){$(n).observe(F,function(e){t.call(n,e)})}):u(t)&&this.each(function(t,e){$(e).fire(F)}),this},live:function(t,n){if(s(n)){var r=this.selector;e.observe(t,function(t,e){e===f(t).findElement(r)&&n.call(e,t)})}},parent:function(){return T.$(this.el.up())},find:function(t){return T.$(this.el.getElementsBySelector(t))},closest:function(t){return T.$(this.el.up(t))},descendants:function(){return T.$(this.el.descendants())},tag:function(){return this.el.tagName},submit:function(){this.el[0].submit()},create:function(t){o(t)?this.el=f(t):h(t)&&(this.el=[t])}},jQuery:{passthrough:function(t,e){return u(e)?this.el[t]():(this.el[t](e),this)},text:function(t){return this.passthrough(S,t)},html:function(t){return this.passthrough(R,t)},val:function(t){return this.passthrough("val",t)},append:function(t){var e=t.el||t;return this.el.append(e),this},attr:function(t,e){return u(e)?this.el.attr(t):(this.el.attr(t,e),this)},remove:function(){return this.el.remove(),this},addClass:function(t){return this.el.addClass(t),this},removeClass:function(t){return this.el.removeClass(t),this},each:function(t){return this.passthrough("each",t)},click:function(t){return this.passthrough(F,t)},live:function(t,n){return f(e).delegate(this.selector,t,n),this},parent:function(){return T.$(this.el.parent())},find:function(t){return T.$(this.el.find(t))},closest:function(t){return T.$(this.el.closest(t))},tag:function(){return this.el[0].tagName},descendants:function(){return T.$(this.el.find("*"))},submit:function(){return this.el.submit()},create:function(t){this.el=f(t)}}}),T.ELEMENT._=T.ELEMENT.prototype,T.ready(T.setupViewTool),T.ready(function(){T.bindOutlets({total:function(){return T.toCurrency(T.total())},quantity:function(){return T.quantity()},items:function(t){T.writeCart(t)},tax:function(){return T.toCurrency(T.tax())},taxRate:function(){return T.taxRate().toFixed()},shipping:function(){return T.toCurrency(T.shipping())},grandTotal:function(){return T.toCurrency(T.grandTotal())}}),T.bindInputs([{selector:"checkout",event:"click",callback:function(){T.checkout()}},{selector:"empty",event:"click",callback:function(){T.empty()}},{selector:"increment",event:"click",callback:function(){T.find(T.$(this).closest(".itemRow").attr("id").split("_")[1]).increment(),T.update()}},{selector:"decrement",event:"click",callback:function(){T.find(T.$(this).closest(".itemRow").attr("id").split("_")[1]).decrement(),T.update()}},{selector:"remove",event:"click",callback:function(){T.find(T.$(this).closest(".itemRow").attr("id").split("_")[1]).remove()}},{selector:"input",event:"change",callback:function(){var t=T.$(this),e=t.parent(),n=e.attr("class").split(" ");T.each(n,function(n){if(n.match(/item-.+/i)){var r=n.split("-")[1];return T.find(e.closest(".itemRow").attr("id").split("_")[1]).set(r,t.val()),void T.update()}})}},{selector:"shelfItem .item_add",event:"click",callback:function(){var t=T.$(this),e={};t.closest("."+_+"_shelfItem").descendants().each(function(t,n){var r=T.$(n);r.attr("class")&&r.attr("class").match(/item_.+/)&&!r.attr("class").match(/item_add/)&&T.each(r.attr("class").split(" "),function(t){var n,i,a;if(t.match(/item_.+/)){switch(n=t.split("_")[1],i="",r.tag().toLowerCase()){case"input":case"textarea":case"select":a=r.attr("type"),(!a||("checkbox"===a.toLowerCase()||"radio"===a.toLowerCase())&&r.attr("checked")||"text"===a.toLowerCase()||"number"===a.toLowerCase())&&(i=r.val());break;case"img":i=r.attr("src");break;default:i=r.text()}null!==i&&""!==i&&(e[n.toLowerCase()]=e[n.toLowerCase()]?e[n.toLowerCase()]+", "+i:i)}})}),T.add(e)}}])}),e.addEventListener?t.DOMContentLoaded=function(){e.removeEventListener("DOMContentLoaded",DOMContentLoaded,!1),T.init()}:e.attachEvent&&(t.DOMContentLoaded=function(){"complete"===e.readyState&&(e.detachEvent("onreadystatechange",DOMContentLoaded),T.init())}),c(),T};t.simpleCart=d()}(window,document);