Skip to content

Instantly share code, notes, and snippets.

View influxweb's full-sized avatar
Coffee Helps Me Focus...Coffee Helps Me Focus...Coffee Helps Me Focus...

Matt Zimmermann influxweb

Coffee Helps Me Focus...Coffee Helps Me Focus...Coffee Helps Me Focus...
View GitHub Profile
iframe {
max-width: 100%;
}
@influxweb
influxweb / mini-basket_checkout-basket.html
Created August 31, 2015 18:12
ReadyTheme updates for attribute pricing in the mini-baskets and checkout baskets.
Suivant and Iron & Wool Mini-Basket
Replace:
<mvt:if expr="l.settings:item:subtotal_base_price OR l.settings:item:subtotal">
<mvt:if expr="l.settings:item:subtotal_base_price NE l.settings:item:subtotal">
<s>&mvt:item:formatted_subtotal_base_price;</s><br />
</mvt:if>
<strong>&mvt:item:formatted_subtotal;</strong>
<mvt:else>
<strong>&mvt:item:formatted_subtotal_comprehensive;</strong>
</mvt:if>
@influxweb
influxweb / ie_check.js
Last active September 8, 2015 17:20 — forked from padolsey/gist:527683
Check IE version using JavaScript
// ----------------------------------------------------------
// A short snippet for detecting versions of IE in JavaScript
// without resorting to user-agent sniffing
// ----------------------------------------------------------
// If you're not in IE (or IE version is less than 5) then:
// ie === undefined
// If you're in IE (>=5) then you can determine which version:
// ie === 7; // IE7
// Thus, to detect IE:
// if (ie) {}
@influxweb
influxweb / patr_page_details.html
Created September 16, 2015 15:55
Updated PATR page for Suivant and Iron & Wool ReadyThemes
<mvt:item name="html_profile" />
<head>
<mvt:if expr="NOT ISNULL l.settings:page:title">
<title>&mvt:page:title;</title>
<mvt:else>
<title>&mvt:store:name;: &mvt:page:name;</title>
</mvt:if>
<mvt:item name="head" param="head_tag" />
<mvt:item name="attributemachine" param="head" />
<mvt:item name="product_display_imagemachine" param="head" />
@influxweb
influxweb / html-entities.js
Created May 1, 2012 15:33 — forked from dbushell/gist:2567294
HTML Entities with jQuery and the Browser
var div = $('<div/>');
function encodeEntities(str) {
return div.text(str).html();
}
function decodeEntities(str) {
return div.html(str).text();
}
@influxweb
influxweb / Elegant and accessible content toggle with CSS.markdown
Created November 11, 2015 15:36
Elegant and accessible content toggle with CSS
@influxweb
influxweb / image-resize.js
Created June 19, 2013 15:27
Image resizing using jQuery Although you should resize your images on server side (using PHP and GD for example) it can be useful to be able to resize images using jQuery. Here’s a handy code snippet to do it. http://www.catswhocode.com/blog/useful-jquery-code-snippets
$(window).bind("load", function() {
// IMAGE RESIZE
$('#product_cat_list img').each(function() {
var maxWidth = 120;
var maxHeight = 120;
var ratio = 0;
var width = $(this).width();
var height = $(this).height();
if(width > maxWidth){
@influxweb
influxweb / content-loading.js
Created June 19, 2013 15:28
Load content on scroll automatically Some websites such as Twitter loads content on scroll. Which means that all content is dynamically loaded on a single page as long as you scroll down. Here’s how you can replicate this effect on your website: http://www.catswhocode.com/blog/useful-jquery-code-snippets
var loading = false;
$(window).scroll(function(){
if((($(window).scrollTop()+$(window).height())+250)>=$(document).height()){
if(loading == false){
loading = true;
$('#loadingbar').css("display","block");
$.get("load.php?start="+$('#loaded_max').val(), function(loaded){
$('body').append(loaded);
$('#loaded_max').val(parseInt($('#loaded_max').val())+50);
$('#loadingbar').css("display","none");
@influxweb
influxweb / password-strength.js
Created June 19, 2013 15:29
Test Password Strength When building forms, it’s a very good practice to provide verifications on the front-end first so the visitor do not have to submit the form endlessly to correct problems. This code snippet is using regular expressions to test if a password is strong enough. Of course, don’t forget to validate your forms on the server side…
$('#pass').keyup(function(e) {
var strongRegex = new RegExp("^(?=.{8,})(?=.*[A-Z])(?=.*[a-z])(?=.*[0-9])(?=.*\W).*$", "g");
var mediumRegex = new RegExp("^(?=.{7,})(((?=.*[A-Z])(?=.*[a-z]))|((?=.*[A-Z])(?=.*[0-9]))|((?=.*[a-z])(?=.*[0-9]))).*$", "g");
var enoughRegex = new RegExp("(?=.{6,}).*", "g");
if (false == enoughRegex.test($(this).val())) {
$('#passstrength').html('More Characters');
} else if (strongRegex.test($(this).val())) {
$('#passstrength').className = 'ok';
$('#passstrength').html('Strong!');
} else if (mediumRegex.test($(this).val())) {
@influxweb
influxweb / parse-json.js
Created June 19, 2013 15:32
Parsing json with jQuery Parsing json data with jQuery is not complicated at all. Here is an efficient example on how to parse json data and append it to your web page. http://www.catswhocode.com/blog/useful-jquery-code-snippets
function parseJson(){
//Start by calling the json object, I will be using a
//file from my own site for the tutorial
//Then we declare a callback function to process the data
$.getJSON('hcj.json',getPosts);
//The process function, I am going to get the title,
//url and excerpt for 5 latest posts
function getPosts(data){