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
/** | |
* Curried delay function | |
*/ | |
const delay = (cb, delay = 0) => (...args) => setTimeout(() => { | |
cb() | |
if (args.length > 0) args.shift()(...args) | |
}, delay) | |
/** | |
* Fire series of delays |
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
const objectFit = document.documentElement.style.hasOwnProperty('objectFit') | |
const images = Layzr({ threshold: 90 }) | |
images.on('src:after', img => { | |
let parent = img.parentNode | |
// optional, to style loaded state | |
parent.setAttribute('data-lazy', 'is-loaded') |
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
<div id="{{form_outer_id}}" class="address__form relative w1 {{form_classes}}" style="display: none;"> | |
{% form 'customer_address', form_action %} | |
{% assign form_id = form.id %} | |
{% capture form_script %}{% if form_id == 'new' %}barrel.toggleNewForm(event){% else %}barrel.toggleForm(event, {{form_id}}){% endif %}{% endcapture %} | |
{% capture form_suffix %}{% if form_id and form_id != 'new' %}_{{form_id}}{% endif %}{% endcapture %} | |
{% capture form_city_id %}{% if form_id == 'new' %}AddressCityNew{% else %}AddressCity{% endif %}{% endcapture%} | |
{% capture form_country_id %}{% if form_id == 'new' %}AddressCountryNew{% else %}AddressCountry{% endif %}{% endcapture%} |
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
import delegate from 'delegate' | |
const checkTouch = (root) => { | |
let select = root.querySelector('.js-select-outer') | |
let dropdown = root.querySelector('.js-dropdown') | |
if (!select) return | |
if (!window.feature.touch){ | |
dropdown.style.display = 'inline-block' |
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
import jss from 'jss-browserify' | |
import stockpile from 'stockpile.js' | |
const storage = stockpile('GV') | |
window.STORE = storage | |
/** | |
* requestAnimationFrame polyfill | |
*/ |
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
export default function(el){ | |
const input = el.querySelector('.js-counter-input') | |
const buttons = Array.prototype.slice.call(el.querySelectorAll('button')) | |
const state = { | |
min: parseInt(input.getAttribute('min'),10) || 0, | |
max: parseInt(input.getAttribute('max'),10) || 9999, | |
store: { | |
value: parseInt(input.value,10) | |
}, |
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
// require() some stuff from npm (like you were using browserify) | |
// and then hit Run Code to run it on the right | |
var observable = require('lookoutjs'); | |
function on(event, element, observable, property, callback){ | |
element.addEventListener(event, function(e){ | |
observable[property] = e.target.value; | |
callback(observable[property]) | |
}, false); | |
} |
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
// require() some stuff from npm (like you were using browserify) | |
// and then hit Run Code to run it on the right | |
var observable = require('lookoutjs'); | |
function on(event, element, observable, property, callback){ | |
element.addEventListener(event, function(e){ | |
observable[property] = e.target.value; | |
callback(observable[property]) | |
}, false); | |
} |
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
function delay(callback, ms){ | |
var _timer = null; | |
return function(){ | |
clearTimeout(_timer); | |
_timer = setTimeout(callback, ms); | |
}; | |
}; |