Skip to content

Instantly share code, notes, and snippets.

@bencooling
bencooling / and-jquery.js
Created October 8, 2014 04:36
amd compatible jquery plugin
(function(factory) {
'use strict';
if (typeof define === 'function' && define.amd) {
define(['jquery'], factory);
} else if (typeof exports !== 'undefined') {
module.exports = factory(require('jquery'));
} else {
factory(jQuery);
}
@bencooling
bencooling / README.md
Created September 3, 2014 04:00
zebra rows, stripes, odd & even classes handlebars helper
@bencooling
bencooling / lazyload.html
Created June 12, 2014 10:33
Javascript Lazy Load Images
<!-- markup -->
<img data-src="/image/to/lazy/load.jpg" src="" />
<script type="text/javascript">
lazyLoad : function($images){
$images.each(function(i, el){
var $el = $(el);
if (!el.loaded){
$el.attr('src', $el.attr('data-src'));
el.loaded=1;
@bencooling
bencooling / jquery-plugin.js
Last active August 29, 2015 14:01
jQuery plugin with public api, pub sub dependency for plugin events
/*
|--------------------------------------------------------------------------
| jQuery plugin
|--------------------------------------------------------------------------
| By Ben Cooling (https://github.com/bencooling, http://bcooling.com.au)
|
| Plugin with:
| - Public api for programitically calling plugin methods
| - Options for overiding default configuration values
| - AMD compatability
@bencooling
bencooling / presentation.md
Last active August 29, 2015 13:57
Analysis of bcooling.com.au

Presentation Notes

bcooling.com.au

Progressive enhancement

  • Older browsers don't miss out on any functionality but the UX is richer in modern, capable browsers.
  • Uses PIE polyfill where possible for older browsers
@bencooling
bencooling / mail.php
Created February 20, 2014 20:31
mailcatcher configuration with larval
// Send through php mail function
'driver' => 'mail',
// mailcatcher does not support encryption
'encryption' => '',
@bencooling
bencooling / Gruntfile.js
Created February 2, 2014 09:14
HTML Email gists
(function () {
'use strict';
module.exports = function(grunt) {
// Plugins
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-sass');
grunt.loadNpmTasks('grunt-contrib-clean');
@bencooling
bencooling / style.scss
Last active January 3, 2016 00:29
Sass: useful functions, mixing, imports, variables etc
// dependencies
@import "vendor/normalize-scss/_normalize";
@import "vendor/bourbon/app/assets/stylesheets/_bourbon";
@import "vendor/neat/app/assets/stylesheets/_neat";
@import "vendor/bitters/app/assets/stylesheets/_bitters";
@import "vendor/bec/jquery.reveal.css";
@import "vendor/animate-css/animate.css";
// Fonts
@import "fonts/rambla/stylesheet.css";

This is a plugin meant for Jekyll.

Example use:

Easily embed a YouTube video. Just drop this file in your _plugins directory.

{% youtube oHg5SJYRHA0 %}
@bencooling
bencooling / script.js
Created October 15, 2013 03:26
jsonp workflow
$(function(){
var xhr, $form = $('form');
function getResponse(data){
console.log(data);
}
function postForm(){
return $.ajax({
'dataType' : "jsonp",