Skip to content

Instantly share code, notes, and snippets.

David Parker boldfacedesign

Block or report user

Report or block boldfacedesign

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View PPK cookies
//read, write and erase cookie functions by PPK - quirksmode.org
function createCookie(name,value,days) {
if (days) {
var date = new Date();
date.setTime(date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
@boldfacedesign
boldfacedesign / Shopify sitemap collection urls
Created Apr 27, 2014
Shopify get all collection urls from sitemap
View Shopify sitemap collection urls
function loadXMLDoc(filename) {
if (window.XMLHttpRequest) {
xhttp=new XMLHttpRequest();
}
else {
xhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xhttp.open("GET",filename,false);
xhttp.send();
return xhttp.responseXML;
View URL parts.txt
Property Description
hash Returns anchor portion of the URL, including the leading hash. (“#results”)
host Returns the hostname and port (if available) of a URL. (“www.example.com” or “www.example.com:80″)
hostname Returns the hostname portion of the URL (“www.example.com”)
href Returns the entire URL. (“http://www.example.com:80/example.php?x=1&y=2#results”)
pathname Returns the path name of the URL (“/example.php”)
port Returns the port portion of the URL (“80″ within the host “www.example.com:80″)
protocol Returns the protocol portion of the URL, including the trailing colon (“http:”, “https:”, “ftp”, etc)
search Returns the query portion of the URL, including the question mark (“?x=1&y=2″)
View fix Array.indexOf()
if (!Array.prototype.indexOf) {
Array.prototype.indexOf = function(obj, start) {
for (var i = (start || 0), j = this.length; i < j; i++) {
if (this[i] === obj) { return i; }
}
return -1;
}
}
@boldfacedesign
boldfacedesign / TEST FOR SUPPORT OF MIN-HEIGHT ON DISPLAY TABLE ELEMENTS
Created Apr 8, 2014
TEST FOR SUPPORT OF MIN-HEIGHT ON DISPLAY TABLE ELEMENTS
View TEST FOR SUPPORT OF MIN-HEIGHT ON DISPLAY TABLE ELEMENTS
//TEST FOR SUPPORT OF MIN-HEIGHT ON DISPLAY TABLE ELEMENTS
(function() {
//CREATE ELEMENT IN DOM
var elem = document.createElement('div');
//ADD STYLES
elem.style.display = 'table';
elem.style.minHeight = '2px';
//APPEND TO DOM
document.body.appendChild(elem);
//MEASURE HEIGHT
View Placeholder polyfil
//POLYFILL PLACEHOLDERS IN IE8/9
if (document.createElement("input").placeholder == undefined) {
//GET ALL TEXT INPUTS
var inp = document.querySelectorAll('input[type=text]');
//LOOP THROUGH AND USE PLACEHOLDER AS VALUE
for (i=0;i<inp.length;i++) {
var plhTxt = inp[i].getAttribute('placeholder');
inp[i].setAttribute('value',plhTxt);
//SET VALUE TO BLANK ON FOCUS IF VALUE = PLACEHOLDER
inp[i].onfocus=function(){
View touch optimized mega-menus
//Touch optimization for mega-menus
if ($('html').hasClass('touch')) {
$('#page').on('click', function(e){
if ($('.region-navigation .menu-name-menu-main-navigation > ul > li').hasClass('open')) {
e.stopPropagation();
e.preventDefault();
$('.region-navigation .menu-name-menu-main-navigation > ul > li').removeClass('open');
}
});
View Gulp KSS
var gulp = require('gulp'),
kss = require('gulp-kss'),
rename = require('rename');
gulp.task('kss-css', function() {
return gulp.src(['css/master.css']) //get compiled CSS
.pipe(rename('style.css')) //rename to KSS required nameing convention
.pipe(gulp.dest('guides/complete/public')); //move to KSS compile folder
});
@boldfacedesign
boldfacedesign / Compass sprite cleaner
Created Apr 8, 2014
Compass sprite cleaner function (Ruby)
View Compass sprite cleaner
module Compass::SassExtensions::Functions::Sprites
def sprite_url(map)
verify_map(map, "sprite-url")
map.generate
generated_image_url(Sass::Script::String.new(map.name_and_hash))
end
end
module Compass::SassExtensions::Sprites::SpriteMethods
def name_and_hash
View shopify collection loop
{% if c.handle contains collection.handle and c.handle != collection.handle %}
<li class="{{ forloop.index }}">
<a href="{{ c.url }}" title="{{ c.title }}">
<span class="product-border"></span>
<div class="img-wrap">
<span class="img-wrap__inner">
<img src="{{ c.image.src | collection_img_url: 'medium' }}">
</span>
</div>
You can’t perform that action at this time.