Skip to content

Instantly share code, notes, and snippets.

@cole007
cole007 / index.html
Created January 7, 2015 09:31
Simple lazy load technique
<!-- place this at bottom the of your HTML page. it has to be after your images appear in the DOM -->
<script>
var imgs = document.getElementsByTagName('img');
// var i = 1 skips first instance. use 0 to do all images
for (var i = 1; i < imgs.length; i++) {
var src = imgs[i].src;
imgs[i].setAttribute('data-src',src);
// whatever, placeholder image
imgs[i].src="hello.jpg";
}
<!-- from page being fetched -->
<div class="page-content">
<h1>here is some content on the case-study page</h1>
</div>
@cole007
cole007 / PHP.md
Last active August 29, 2015 14:10
PHP role @asclearasmud, Bath

No recruitment agencies please. Yes, we know you’re different to all those other agencies that call unsolicited. It’s not you. It’s us. Sorry


Mid-level PHP developer (£30-40k)

We are looking for a PHP developer to assist with the delivery of content-managed and bespoke websites at our offices in the centre of Bath.

You are happiest in code, executing front-end templates and design ideas in PHP and working in a modular, methodical fashion.

@cole007
cole007 / BEM rhyme
Created December 2, 2014 12:37
BEM rhyme for @kaelifa :D
Block is a house that is nice and square,
Element is a room with its walls all bare,
Modifier is the wallpaper, hang with care!
.house
.house__room
.house__room—-paisley
@cole007
cole007 / gist:54874745ec4178ca64c6
Created November 24, 2014 13:43
Capitalism quote, Che Guevara
"In capitalist system people live in an invisible cage, for example, they accept the myth of the self-made man, but they do not understand that opportunities for majority are determined by the forces completely beyond individual control"
From Che, Part One
http://www.imdb.com/title/tt0892255/
if(viewportwidth > 1183 && !$('.page').hasClass('home') ){
$('a.icon--search').on('click touchend',function(e) {
e.preventDefault();
$(this).toggleClass('nav-active');
$(this).next('.search__form').toggleClass('search__form--active');
$('.header__secondary-menu').fadeToggle();
});
$('.search__form').css('top','5.45em');
} else {
$('a.icon--search').on('click touchend',function(e) {
@cole007
cole007 / dobanners.js
Last active August 29, 2015 14:05
Do Banners polyfill
doBanners: function() {
var banners = $('.banners-wrapper');
banners.after('<div class="banner-nav-wrapper"></div>');
$('.banner-nav-wrapper').append('<ul class="banner-switch"></ul>')
.append('<ul class="banner-nav"></ul>');
banners.find('.item').each(function(i) {
$(this).addClass('banner-panel-'+i);
var url = $(this).find('.more a').attr('href');
if (i == 0) $(this).addClass('active');
var navImg = $(this).find('.do-image').data('nav');
@cole007
cole007 / footer.JS
Created August 26, 2014 09:12
From footer template
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<div class="booking-item booking-item--left booking-item--full">
@cole007
cole007 / jquery.customSelect.js
Last active August 29, 2015 14:03
Custom select
// fork of library at http://adam.co/lab/jquery/customselect/
// removes width calculations
/*!
* jquery.customSelect() - v0.5.1
* http://adam.co/lab/jquery/customselect/
* 2014-03-19
*
* Copyright 2013 Adam Coulombe
* @license http://www.opensource.org/licenses/mit-license.html MIT License