This file contains 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
var notification = { | |
element: $('#notification'), | |
timeout: null, | |
show: function(type, message) { | |
'use strict'; | |
// reset the current timer | |
clearTimeout(this.timeout); | |
this.element |
This file contains 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
<!-- add the options +tags to the listed products attributes --> | |
{% if p.options[0] == 'Color' %}{% capture colours %}{% for variant in p.variants %}{% unless forloop.first %},{% endunless %}{{ variant.options[0] }}{% endfor %}{% endcapture %}{% endif %} | |
{% if p.options[1] == 'Material' %}{% capture materials %}{% for variant in p.variants %}{% unless forloop.first %},{% endunless %}{{ variant.options[1] }}{% endfor %}{% endcapture %}{% endif %} | |
{% if p.options[2] == 'Style' %}{% capture styles %}{% for variant in p.variants %}{% unless forloop.first %},{% endunless %}{{ variant.options[2] }}{% endfor %}{% endcapture %}{% endif %} | |
{% if p.tags %}{% capture tagg %}{% for tag in p.tags %}{% if tag contains 'recommended:' %}{% unless forloop.first %},{% endunless %}{{ tag | replace: 'recommended:', '' }}{% endif %}{% endfor %}{% endcapture %}{% endif %} | |
<div class="product" data-colours="{{ colours | escape }}" data-materials="{{ materials | escape }}" data-styles="{{ styles | escape }}" data-tags="{{ tagg | esc |
This file contains 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
// call a callback function every *interval* until *stopTime* or until (bool)true is | |
// returned from the callback function | |
function setIntervalTimeout(callback, interval, stopTime) { | |
var i; | |
i = setInterval(function() { | |
if(callback()) clearInterval(i); | |
}, interval); | |
setTimeout(function() { |
This file contains 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
/* jQuery Tiny Pub/Sub - v0.7 - 10/27/2011 | |
* http://benalman.com/ | |
* Copyright (c) 2011 "Cowboy" Ben Alman; Licensed MIT, GPL */ | |
(function($) { | |
var o = $({}); | |
$.subscribe = function() { | |
o.on.apply(o, arguments); |
This file contains 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
// ajax call from a form | |
api.formAjax = function($form, type, callback) { | |
var data = {}; | |
$form | |
.find('input:not([type="submit"], [type="file"]), textarea, select') | |
.each(function() { | |
data[$(this).attr('name')] = $(this).val(); | |
}) | |
.promise() | |
.done(function() { |
This file contains 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
<!-- | |
a new template will need to be created for this file then this will | |
be what's called from the ajax by sending it with a property of | |
view:*template name*. | |
--> | |
{% layout none %} | |
{% paginate items by 5 %} | |
{% for item in items %} | |
<!-- item html --> |
This file contains 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
// add multiple items to the cart by passing an array of item objects | |
function addItems(items, callback) { | |
if(!items.length) { | |
// we ran out of items | |
if(typeof callback === 'function') callback(); | |
return; | |
} | |
$.ajax('/cart/add.js', { | |
type:'POST', |
This file contains 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
var wait = (function() { | |
var timers = {}; | |
return function(name, time) { | |
// if the current timer has not been set yet or it has previously | |
// been set but finished it's waiting period | |
if(typeof(timers[name])==='undefined' || timers[name]) { | |
timers[name] = false; | |
setTimeout(function() { timers[name] = true; }, time); | |
return true; |
This file contains 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
var Cart = (function($, Shopify) { | |
var list = '.sproducts'; | |
var total = '.shoppingbag-total'; | |
function updateTotal() { | |
Shopify.getCart(function(data) { | |
$(total).text(Shopify.formatMoney(data.total_price, '£\{\{amount}}')); | |
}); | |
} | |
OlderNewer