Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Rebundled.

  • Loading branch information...
commit b1466590cf4a3c1646ad10926ea214ade868a4f8 1 parent f19753d
@ismasan ismasan authored
View
5 dist/0.0.1/bootic_cart.js
@@ -148,7 +148,7 @@ Cart.prototype = {
opts.data = data;
- this.trigger('adding', [{variant_id: variantId}]);
+ //this.trigger('adding', [{variant_id: variantId}]);
this.request(opts.url, opts, function (cartData) {
this.update(cartData)
@@ -379,6 +379,9 @@ $(function () {
quantity: 1
}
+ // We need to trigger the product ID here, because we don't get it from the API until added.
+ $e.trigger('adding.bootic', {product_id: $e.data('bootic-cart-add')})
+
Bootic.Cart.find(variantId, function (item) {
if(qtyIput.length > 0) { // user is providing quantity
options.quantity = qtyIput.val()
View
13 dist/0.0.1/bootic_cart.min.js
@@ -25,13 +25,14 @@ OTHER DEALINGS IN THE SOFTWARE.
------------------------------------------------------------------*/
var Bootic=Bootic||{};
(function(w,d){var h=function(){this.reset(!0)};h.prototype={load:function(c){this.trigger("loading");c=c||d.noop;this.request("/cart.json",{type:"get"},function(b){this.update(b);c(this);this.trigger("loaded",[this])});return this},reset:function(c){this.products=[];this.units=0;this.formatted_total="0";this.currency=null;this.total=0;this._productCounts={};this._loaded=!1;c&&this.trigger("reset");return this},add:function(c,b,a){b=b||d.noop;a=d.extend({url:"/cart/cart_items",quantity:1,type:"post",
-dataType:"json"},a||{});a.data={cart_item:{variant_id:c,quantity:a.quantity}};this.trigger("adding",[{variant_id:c}]);this.request(a.url,a,function(a){this.update(a);a=this.find(c);b(a);this.trigger("added",[a])});return this},find:function(c,b){var a=null;this.forEach(function(b){b.variant_id==c&&(a=b)});b&&b(a);return a},findByProductId:function(c,b){var a=null;this.forEach(function(b){b.product_id==c&&(a=b)});b&&b(a);return a},forEach:function(c,b){b=b||this;var a;return this.loadAndThen(function(){for(a=
-0;a<this.products.length;a++)c.call(b,this.products[a],a,this.products)})},remove:function(c,b){b=b||d.noop;return this.loadAndThen(function(){var a=this.find(c);if(!a)return this.trigger("error",["No cart item with variant ID "+c]),this;this.trigger("removing",[a]);var i=d.extend({url:"/cart/cart_items/"+a.id,type:"delete"},i);this.request(i.url,i,function(c){this.update(c);this._productCounts[a.product_id]?(a=this.findByProductId(a.product_id),this.trigger("added",[a])):(b(a),this.trigger("removed",
-[a]))})})},loadAndThen:function(c){this._loaded?c.call(this):this.load(d.proxy(c,this));return this},isEmpty:function(){return!this.products||this.products.length<1},update:function(c){this._loaded=!0;this._productCounts={};d.extend(this,c);this._calculateCounts();this._decorateProducts();this.trigger("updated")},request:function(c,b,a){b=d.extend({success:d.proxy(a,this),error:d.proxy(function(a){this.trigger("error",[a])},this)},b||{});return d.ajax(c,b)},_decorateProducts:function(){this.forEach(function(c){c.total_units=
-this._productCounts[c.product_id]})},_calculateCounts:function(){d.each(this.products,d.proxy(function(c,b){this._productCounts[b.product_id]=this._productCounts[b.product_id]||0;this._productCounts[b.product_id]+=b.quantity},this))}};d.extend(h.prototype,{track:function(c){"Bootic"in w&&"track"in w.Bootic&&Bootic.track("Bootic.Cart:"+c)},bind:function(c,b){d(this).bind(c,b);return this},trigger:function(c,b){this.track(c);d(this).trigger(c,b);return this}});Bootic.Cart=new h;d(function(){function c(a){return d('[data-bootic-productId="'+
+dataType:"json"},a||{});a.data={cart_item:{variant_id:c,quantity:a.quantity}};this.request(a.url,a,function(a){this.update(a);a=this.find(c);b(a);this.trigger("added",[a])});return this},find:function(c,b){var a=null;this.forEach(function(b){b.variant_id==c&&(a=b)});b&&b(a);return a},findByProductId:function(c,b){var a=null;this.forEach(function(b){b.product_id==c&&(a=b)});b&&b(a);return a},forEach:function(c,b){b=b||this;var a;return this.loadAndThen(function(){for(a=0;a<this.products.length;a++)c.call(b,
+this.products[a],a,this.products)})},remove:function(c,b){b=b||d.noop;return this.loadAndThen(function(){var a=this.find(c);if(!a)return this.trigger("error",["No cart item with variant ID "+c]),this;this.trigger("removing",[a]);var i=d.extend({url:"/cart/cart_items/"+a.id,type:"delete"},i);this.request(i.url,i,function(c){this.update(c);this._productCounts[a.product_id]?(a=this.findByProductId(a.product_id),this.trigger("added",[a])):(b(a),this.trigger("removed",[a]))})})},loadAndThen:function(c){this._loaded?
+c.call(this):this.load(d.proxy(c,this));return this},isEmpty:function(){return!this.products||this.products.length<1},update:function(c){this._loaded=!0;this._productCounts={};d.extend(this,c);this._calculateCounts();this._decorateProducts();this.trigger("updated")},request:function(c,b,a){b=d.extend({success:d.proxy(a,this),error:d.proxy(function(a){this.trigger("error",[a])},this)},b||{});return d.ajax(c,b)},_decorateProducts:function(){this.forEach(function(c){c.total_units=this._productCounts[c.product_id]})},
+_calculateCounts:function(){d.each(this.products,d.proxy(function(c,b){this._productCounts[b.product_id]=this._productCounts[b.product_id]||0;this._productCounts[b.product_id]+=b.quantity},this))}};d.extend(h.prototype,{track:function(c){"Bootic"in w&&"track"in w.Bootic&&Bootic.track("Bootic.Cart:"+c)},bind:function(c,b){d(this).bind(c,b);return this},trigger:function(c,b){this.track(c);d(this).trigger(c,b);return this}});Bootic.Cart=new h;d(function(){function c(a){return d('[data-bootic-productId="'+
a+'"]')}function b(a){return a.is(":radio")?a.filter(":checked").val():a.val()}Bootic.Cart.bind("adding",function(a,b){c(b.product_id).trigger("adding.bootic",[b])}).bind("added",function(a,b){c(b.product_id).trigger("added.bootic",[b])}).bind("removing",function(a,b){c(b.product_id).trigger("removing.bootic",[b])}).bind("removed",function(a,b){c(b.product_id).trigger("removed.bootic",[b])}).bind("loaded",function(a,b){b.forEach(function(a){c(a.product_id).trigger("added.bootic",[a])})});d('input[name="cart_item[quantity]"]').remove();
-d("form[data-bootic-cart-add]").on("added.bootic",function(){d(this).addClass("bootic_cart_added")}).on("removed.bootic",function(){d(this).removeClass("bootic_cart_added")}).on("submit",function(a){var c=d(this),g=b(c.find('input[name="cart_item[variant_id]"]')),h=c.find('input[name="cart_item[quantity]"]');if(g==void 0)throw a.preventDefault(),"Your form must have an input of name cart_item[variant_id]";var k={type:c.attr("method"),url:c.attr("action"),quantity:1};Bootic.Cart.find(g,function(a){if(h.length>
-0)k.quantity=h.val();else if(a)k.quantity=a.quantity+1;Bootic.Cart.add(g,null,k)});return!1});Bootic.templateEngine=tim.parser({start:"<%",end:"%>",type:"text/html"});Bootic.templates=Bootic.templates||{};d("script[type='text/html'][data-template]").each(function(){var a=d(this);Bootic.templates[a.data("template")]=a.html()});d.fn.booticTemplateRender=function(a,b){var c=Bootic.templateEngine(Bootic.templates[a],b);d(this).empty().append(c);return d(this)}})})(window,jQuery);
+d("form[data-bootic-cart-add]").on("added.bootic",function(){d(this).addClass("bootic_cart_added")}).on("removed.bootic",function(){d(this).removeClass("bootic_cart_added")}).on("submit",function(a){var c=d(this),g=b(c.find('input[name="cart_item[variant_id]"]')),h=c.find('input[name="cart_item[quantity]"]');if(g==void 0)throw a.preventDefault(),"Your form must have an input of name cart_item[variant_id]";var k={type:c.attr("method"),url:c.attr("action"),quantity:1};c.trigger("adding.bootic",{product_id:c.data("bootic-cart-add")});
+Bootic.Cart.find(g,function(a){if(h.length>0)k.quantity=h.val();else if(a)k.quantity=a.quantity+1;Bootic.Cart.add(g,null,k)});return!1});Bootic.templateEngine=tim.parser({start:"<%",end:"%>",type:"text/html"});Bootic.templates=Bootic.templates||{};d("script[type='text/html'][data-template]").each(function(){var a=d(this);Bootic.templates[a.data("template")]=a.html()});d.fn.booticTemplateRender=function(a,b){var c=Bootic.templateEngine(Bootic.templates[a],b);d(this).empty().append(c);return d(this)}})})(window,
+jQuery);
var tim=function createTim(d){function h(){r=RegExp(m.start+"\\s*("+m.path+")\\s*"+m.end,"gi")}function c(a){var b;if(a){for(b in a)a.hasOwnProperty(b)&&(m[b]=a[b]);h()}return m}function b(a,c){var d;switch(typeof a){case "string":if(c===s)return l[a]||"";else c===!1?delete l[a]:l[a]=c;break;case "object":for(d in a)a.hasOwnProperty(d)&&b(d,a[d]);break;case "boolean":a||(l={})}return l}function a(a,b){return a[1]-b[1]}function i(b,c,d){var j=o[b];j||(j=o[b]=[]);j.push([c,d||0]);j.sort(a);return c}
function g(a,b){var c=o[a],d,e,f,g;if(c){d=[b];e=2;for(f=arguments.length;e<f;e++)d.push(arguments[e]);e=0;for(f=c.length;e<f;e++)if(d[0]=b,g=c[e][0].apply(null,d),b!==s&&g!==s&&(b=g),v){v=!1;break}}return b}function x(a,b){return(typeof b==="function"?i:g).apply(null,arguments)}function k(a,c){var d;y||(y=1,g("init"));a=g("templateBefore",a);a.indexOf(m.start)<0&&(d=b(a))&&(a=d);if((a=g("template",a))&&c!==s){d=a;for(var j,e,f,h,n,i,l,p,t,q,o;(j=r.exec(d))!==null;){e=j[1];f=g("token",e,c,d);h=j.index;
j=r.lastIndex;h=d.slice(0,h);n=d.slice(j);typeof f==="function"&&(f=f.call(c));if(typeof f!=="boolean"&&typeof f!=="object")d=h+f+n;else if(i="",l=m.start+"/"+e+m.end,p=n.indexOf(l),p>=0){n=n.slice(0,p);if(typeof f==="boolean")i=f?n:"";else{for(t in f)if(f.hasOwnProperty(t)){r.lastIndex=0;q={_key:t,_content:f[t]};p=f[t];var u=void 0;for(u in p)p.hasOwnProperty(u)&&(q[u]=p[u]);q=g("loopData",q,o,e);o=k(n,q);i+=g("loop",o,e,q)}i=g("loopEnd",i,e,q)}d=h+i+d.slice(j+n.length+l.length)}else throw"tim: '"+
View
5 dist/0.0/bootic_cart.js
@@ -148,7 +148,7 @@ Cart.prototype = {
opts.data = data;
- this.trigger('adding', [{variant_id: variantId}]);
+ //this.trigger('adding', [{variant_id: variantId}]);
this.request(opts.url, opts, function (cartData) {
this.update(cartData)
@@ -379,6 +379,9 @@ $(function () {
quantity: 1
}
+ // We need to trigger the product ID here, because we don't get it from the API until added.
+ $e.trigger('adding.bootic', {product_id: $e.data('bootic-cart-add')})
+
Bootic.Cart.find(variantId, function (item) {
if(qtyIput.length > 0) { // user is providing quantity
options.quantity = qtyIput.val()
View
13 dist/0.0/bootic_cart.min.js
@@ -25,13 +25,14 @@ OTHER DEALINGS IN THE SOFTWARE.
------------------------------------------------------------------*/
var Bootic=Bootic||{};
(function(w,d){var h=function(){this.reset(!0)};h.prototype={load:function(c){this.trigger("loading");c=c||d.noop;this.request("/cart.json",{type:"get"},function(b){this.update(b);c(this);this.trigger("loaded",[this])});return this},reset:function(c){this.products=[];this.units=0;this.formatted_total="0";this.currency=null;this.total=0;this._productCounts={};this._loaded=!1;c&&this.trigger("reset");return this},add:function(c,b,a){b=b||d.noop;a=d.extend({url:"/cart/cart_items",quantity:1,type:"post",
-dataType:"json"},a||{});a.data={cart_item:{variant_id:c,quantity:a.quantity}};this.trigger("adding",[{variant_id:c}]);this.request(a.url,a,function(a){this.update(a);a=this.find(c);b(a);this.trigger("added",[a])});return this},find:function(c,b){var a=null;this.forEach(function(b){b.variant_id==c&&(a=b)});b&&b(a);return a},findByProductId:function(c,b){var a=null;this.forEach(function(b){b.product_id==c&&(a=b)});b&&b(a);return a},forEach:function(c,b){b=b||this;var a;return this.loadAndThen(function(){for(a=
-0;a<this.products.length;a++)c.call(b,this.products[a],a,this.products)})},remove:function(c,b){b=b||d.noop;return this.loadAndThen(function(){var a=this.find(c);if(!a)return this.trigger("error",["No cart item with variant ID "+c]),this;this.trigger("removing",[a]);var i=d.extend({url:"/cart/cart_items/"+a.id,type:"delete"},i);this.request(i.url,i,function(c){this.update(c);this._productCounts[a.product_id]?(a=this.findByProductId(a.product_id),this.trigger("added",[a])):(b(a),this.trigger("removed",
-[a]))})})},loadAndThen:function(c){this._loaded?c.call(this):this.load(d.proxy(c,this));return this},isEmpty:function(){return!this.products||this.products.length<1},update:function(c){this._loaded=!0;this._productCounts={};d.extend(this,c);this._calculateCounts();this._decorateProducts();this.trigger("updated")},request:function(c,b,a){b=d.extend({success:d.proxy(a,this),error:d.proxy(function(a){this.trigger("error",[a])},this)},b||{});return d.ajax(c,b)},_decorateProducts:function(){this.forEach(function(c){c.total_units=
-this._productCounts[c.product_id]})},_calculateCounts:function(){d.each(this.products,d.proxy(function(c,b){this._productCounts[b.product_id]=this._productCounts[b.product_id]||0;this._productCounts[b.product_id]+=b.quantity},this))}};d.extend(h.prototype,{track:function(c){"Bootic"in w&&"track"in w.Bootic&&Bootic.track("Bootic.Cart:"+c)},bind:function(c,b){d(this).bind(c,b);return this},trigger:function(c,b){this.track(c);d(this).trigger(c,b);return this}});Bootic.Cart=new h;d(function(){function c(a){return d('[data-bootic-productId="'+
+dataType:"json"},a||{});a.data={cart_item:{variant_id:c,quantity:a.quantity}};this.request(a.url,a,function(a){this.update(a);a=this.find(c);b(a);this.trigger("added",[a])});return this},find:function(c,b){var a=null;this.forEach(function(b){b.variant_id==c&&(a=b)});b&&b(a);return a},findByProductId:function(c,b){var a=null;this.forEach(function(b){b.product_id==c&&(a=b)});b&&b(a);return a},forEach:function(c,b){b=b||this;var a;return this.loadAndThen(function(){for(a=0;a<this.products.length;a++)c.call(b,
+this.products[a],a,this.products)})},remove:function(c,b){b=b||d.noop;return this.loadAndThen(function(){var a=this.find(c);if(!a)return this.trigger("error",["No cart item with variant ID "+c]),this;this.trigger("removing",[a]);var i=d.extend({url:"/cart/cart_items/"+a.id,type:"delete"},i);this.request(i.url,i,function(c){this.update(c);this._productCounts[a.product_id]?(a=this.findByProductId(a.product_id),this.trigger("added",[a])):(b(a),this.trigger("removed",[a]))})})},loadAndThen:function(c){this._loaded?
+c.call(this):this.load(d.proxy(c,this));return this},isEmpty:function(){return!this.products||this.products.length<1},update:function(c){this._loaded=!0;this._productCounts={};d.extend(this,c);this._calculateCounts();this._decorateProducts();this.trigger("updated")},request:function(c,b,a){b=d.extend({success:d.proxy(a,this),error:d.proxy(function(a){this.trigger("error",[a])},this)},b||{});return d.ajax(c,b)},_decorateProducts:function(){this.forEach(function(c){c.total_units=this._productCounts[c.product_id]})},
+_calculateCounts:function(){d.each(this.products,d.proxy(function(c,b){this._productCounts[b.product_id]=this._productCounts[b.product_id]||0;this._productCounts[b.product_id]+=b.quantity},this))}};d.extend(h.prototype,{track:function(c){"Bootic"in w&&"track"in w.Bootic&&Bootic.track("Bootic.Cart:"+c)},bind:function(c,b){d(this).bind(c,b);return this},trigger:function(c,b){this.track(c);d(this).trigger(c,b);return this}});Bootic.Cart=new h;d(function(){function c(a){return d('[data-bootic-productId="'+
a+'"]')}function b(a){return a.is(":radio")?a.filter(":checked").val():a.val()}Bootic.Cart.bind("adding",function(a,b){c(b.product_id).trigger("adding.bootic",[b])}).bind("added",function(a,b){c(b.product_id).trigger("added.bootic",[b])}).bind("removing",function(a,b){c(b.product_id).trigger("removing.bootic",[b])}).bind("removed",function(a,b){c(b.product_id).trigger("removed.bootic",[b])}).bind("loaded",function(a,b){b.forEach(function(a){c(a.product_id).trigger("added.bootic",[a])})});d('input[name="cart_item[quantity]"]').remove();
-d("form[data-bootic-cart-add]").on("added.bootic",function(){d(this).addClass("bootic_cart_added")}).on("removed.bootic",function(){d(this).removeClass("bootic_cart_added")}).on("submit",function(a){var c=d(this),g=b(c.find('input[name="cart_item[variant_id]"]')),h=c.find('input[name="cart_item[quantity]"]');if(g==void 0)throw a.preventDefault(),"Your form must have an input of name cart_item[variant_id]";var k={type:c.attr("method"),url:c.attr("action"),quantity:1};Bootic.Cart.find(g,function(a){if(h.length>
-0)k.quantity=h.val();else if(a)k.quantity=a.quantity+1;Bootic.Cart.add(g,null,k)});return!1});Bootic.templateEngine=tim.parser({start:"<%",end:"%>",type:"text/html"});Bootic.templates=Bootic.templates||{};d("script[type='text/html'][data-template]").each(function(){var a=d(this);Bootic.templates[a.data("template")]=a.html()});d.fn.booticTemplateRender=function(a,b){var c=Bootic.templateEngine(Bootic.templates[a],b);d(this).empty().append(c);return d(this)}})})(window,jQuery);
+d("form[data-bootic-cart-add]").on("added.bootic",function(){d(this).addClass("bootic_cart_added")}).on("removed.bootic",function(){d(this).removeClass("bootic_cart_added")}).on("submit",function(a){var c=d(this),g=b(c.find('input[name="cart_item[variant_id]"]')),h=c.find('input[name="cart_item[quantity]"]');if(g==void 0)throw a.preventDefault(),"Your form must have an input of name cart_item[variant_id]";var k={type:c.attr("method"),url:c.attr("action"),quantity:1};c.trigger("adding.bootic",{product_id:c.data("bootic-cart-add")});
+Bootic.Cart.find(g,function(a){if(h.length>0)k.quantity=h.val();else if(a)k.quantity=a.quantity+1;Bootic.Cart.add(g,null,k)});return!1});Bootic.templateEngine=tim.parser({start:"<%",end:"%>",type:"text/html"});Bootic.templates=Bootic.templates||{};d("script[type='text/html'][data-template]").each(function(){var a=d(this);Bootic.templates[a.data("template")]=a.html()});d.fn.booticTemplateRender=function(a,b){var c=Bootic.templateEngine(Bootic.templates[a],b);d(this).empty().append(c);return d(this)}})})(window,
+jQuery);
var tim=function createTim(d){function h(){r=RegExp(m.start+"\\s*("+m.path+")\\s*"+m.end,"gi")}function c(a){var b;if(a){for(b in a)a.hasOwnProperty(b)&&(m[b]=a[b]);h()}return m}function b(a,c){var d;switch(typeof a){case "string":if(c===s)return l[a]||"";else c===!1?delete l[a]:l[a]=c;break;case "object":for(d in a)a.hasOwnProperty(d)&&b(d,a[d]);break;case "boolean":a||(l={})}return l}function a(a,b){return a[1]-b[1]}function i(b,c,d){var j=o[b];j||(j=o[b]=[]);j.push([c,d||0]);j.sort(a);return c}
function g(a,b){var c=o[a],d,e,f,g;if(c){d=[b];e=2;for(f=arguments.length;e<f;e++)d.push(arguments[e]);e=0;for(f=c.length;e<f;e++)if(d[0]=b,g=c[e][0].apply(null,d),b!==s&&g!==s&&(b=g),v){v=!1;break}}return b}function x(a,b){return(typeof b==="function"?i:g).apply(null,arguments)}function k(a,c){var d;y||(y=1,g("init"));a=g("templateBefore",a);a.indexOf(m.start)<0&&(d=b(a))&&(a=d);if((a=g("template",a))&&c!==s){d=a;for(var j,e,f,h,n,i,l,p,t,q,o;(j=r.exec(d))!==null;){e=j[1];f=g("token",e,c,d);h=j.index;
j=r.lastIndex;h=d.slice(0,h);n=d.slice(j);typeof f==="function"&&(f=f.call(c));if(typeof f!=="boolean"&&typeof f!=="object")d=h+f+n;else if(i="",l=m.start+"/"+e+m.end,p=n.indexOf(l),p>=0){n=n.slice(0,p);if(typeof f==="boolean")i=f?n:"";else{for(t in f)if(f.hasOwnProperty(t)){r.lastIndex=0;q={_key:t,_content:f[t]};p=f[t];var u=void 0;for(u in p)p.hasOwnProperty(u)&&(q[u]=p[u]);q=g("loopData",q,o,e);o=k(n,q);i+=g("loop",o,e,q)}i=g("loopEnd",i,e,q)}d=h+i+d.slice(j+n.length+l.length)}else throw"tim: '"+
Please sign in to comment.
Something went wrong with that request. Please try again.