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 compList = ['products', 'collections', '_thumb.jpg', '.myshopify.com/', '//cdn.shopify.com/s/files/', 'http://', 'shopify.com']; | |
function miniComp(str) { | |
for(var i=0; i<compList.length; i++) { | |
str = str.split(compList[i]).join('#['+i+']'); //Split/join vs regex speed = surprising | |
} | |
return str; | |
} | |
function miniDecomp(str) { |
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 shallow scan of a JSON object to test for equality | |
function getNumKeysInJsonObject(obj) { | |
var i = 0; | |
for (var x in obj) | |
if (obj.hasOwnProperty(x)) i++; | |
return i; | |
} | |
function jsonIsEqual(obj1, obj2) { | |
var isEqual = true; //Equal until proven otherwise | |
if(typeof obj1 != 'undefined' && typeof obj2 != 'undefined') { |
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
/* | |
Stagger an event across a collection of elements. Useful for making the pretties. | |
Example - for loading in ajax results with a class-based css3 transition, where results are initially hidden with hide(): | |
$('#ajax-results').on('loaded', function(){ | |
$(this).children('.result').addClass('pre-transition').slideDown(250).staggerEvent(function(el){ | |
$(el).removeClass('pre-transition'); | |
}, 150, 250); | |
}); | |
*/ |
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
{% if settings.show_multiple_currencies %} | |
{{ "//cdn.shopify.com/s/javascripts/currencies.js" | script_tag }} | |
{{ "jquery.currencies.min.js" | asset_url | script_tag }} | |
<script> | |
{% if settings.currency_format %} | |
Currency.format = '{{ settings.currency_format }}'; | |
{% endif %} |
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
$(window).on('debouncedresize load', function(){ | |
$('[data-normheights]').each(function(){ | |
var $items = $(this).find($(this).data('normheights')), | |
childFilter = $(this).data('normheights-inner'), | |
tallest = 0, | |
lastYOffset = 0, | |
row = []; | |
$items.each(function(index){ | |
var $img = $(this).find(childFilter); | |
var yOffset = $(this).offset().top; |
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
/// Scroll to in-page links | |
$(document).on('click', 'a[href^="#"]:not([href="#"]), a[href^="'+location.pathname+'#"]', function(e){ | |
var $target = $('#'+$(this).attr('href').split('#')[1]).first(); | |
if($target.length == 1) { | |
$('html:not(:animated),body:not(:animated)').animate({ | |
scrollTop: $target.offset().top | |
}, 500 ); | |
e.preventDefault(); | |
} | |
}); |
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
/// Crop and scale images to a specific ratio | |
$.fn.cropImageToRatio = function(params){ | |
//params | |
var params = $.extend({ | |
ratio: 4/3, | |
wrapper: '<div/>' | |
}, params); | |
//loop all images | |
return $(this).each(function(){ | |
//only allow init once |
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
<script> | |
$(function(){ | |
$('textarea[maxlength], input[maxlength]').bind('keyup change paste', function(){ | |
var maxlength = parseInt($(this).attr('maxlength')); | |
var val = $(this).val(); | |
var currLen = val.length; | |
var newLines = val.match(/(\r\n|\n|\r)/g); | |
if(newLines != null) { | |
currLen += newLines.length; | |
} |
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
<script> | |
$(function(){ | |
//Text that scales up/down based on container width | |
function resizeScalingTextFromColumn() { | |
$('.scaled-text').each(function(){ | |
var $base = $(this).closest('.scaled-text-base'); | |
var scale = $base.width() / {{ settings.adv_page_width }}; | |
$(this).css('font-size', (scale * 100) + '%'); | |
}); | |
} |
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
//Ignore if you already have it: | |
$.fn.reverse = [].reverse; | |
//Hide orphaned thumbs, call on parent with child selector | |
$.fn.hideOrphans = function(selector, totalCountSelector){ | |
var selector = selector; | |
$(this).each(function(){ | |
var $children = $(this).find(selector); | |
$children.filter('.hidden-orphan').show().removeClass('hidden-orphan'); | |
if($(this).hasClass('show-orphans')) { |
OlderNewer