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
/* Take an image, or any other element with height/width attrs (e.g. iframe) and stretch it to fill parent | |
* MIT license | |
* | |
* Dependencies: | |
* imagesLoaded: https://github.com/desandro/imagesloaded | |
* | |
* Usage examples: | |
* $('.fillcontainer img.main').willFillParent({ closest: '.fillcontainer', windowEvent: 'debouncedresize load' }); | |
* $('.video-bg > .video').willFillParent({ windowEvent: 'resize' }); | |
* |
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')) { |
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
/// Bump-down a div to fit (position:fixed style) inside a browser | |
$(function(){ | |
if($('.bump-me-down').length > 0) { | |
$(window).on('scroll process-bump-me-downs resize', function(){ | |
var scrollTop = $(window).scrollTop(); | |
var defaultPad = 20; | |
$('.bump-me-down').each(function(){ | |
var thisOffset = $(this).offset().top; | |
if($(this).data('bumpOffset')) { | |
thisOffset -= $(this).data('bumpOffset'); |
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
{% comment %} | |
Use: | |
{% include 'split_images_from_content' with collection.description %} | |
<div class="header">{{ split_images }}</div> | |
<div class="description">{{ split_content }}</div> | |
{% endcomment %} | |
{% assign num_to_split = 1 %} | |
{% assign split_content = split_images_from_content %} | |
{% assign split_images = '' %} |
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
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') { |
OlderNewer