Skip to content

Instantly share code, notes, and snippets.

View cbourdage's full-sized avatar

Collin Bourdage cbourdage

View GitHub Profile
@cbourdage
cbourdage / ajax-file-upload.js
Last active August 29, 2015 14:01
Snippet for ajax file uploading
document.getElementById('form').addEventListener('submit', function(e) {
var form = this,
files = document.getElementById('file').files;
var reader = new FileReader();
reader.onloadend = (function(file) {
return function(e) {
if (e.target.readyState == FileReader.DONE) {
document.getElementById('file-contents').value = btoa(e.target.result);
document.getElementById('file-name').value = escape(file.name);
// Counter attempt 1 - via recursion
.loop(@total, @cols @i: 1) when (@i =< (@total * @cols)) {
.item-@{i} {
margin-left: 0;
}
.loop(@total, @cols, (@i + 5)); // next iteration
}
/**
* keep body from scrolling when nav menu is open in iOS
*/
$(document).on('touchmove', function(e){
if($('body').hasClass('nav-showing')){
var $target = $(e.target);
if($target.is('#nav-wrapper') || $target.parents('#nav-wrapper')){
e.stopPropagation();
}
}
@cbourdage
cbourdage / plugin.js
Created March 17, 2014 22:06
General Gorilla Plugin Syntax
;
/**
* Gorilla manufacturers.js
* Copyright 2013 Gorilla Group.
*
* Standard Tab plugin. Works with the following
* conventions on the tabs themselves:
* - current tab index (within tabs array)
* - data-target
* - href (matching #id)
@cbourdage
cbourdage / slide-extend.js
Created March 17, 2014 22:04
Slider extending to add indicators/counters
// @dependency bananaPeel
$('#compare-slider').on('init.bananaPeel', function(e) {
e.options.$visible = $(this).parents('.block-compare').find('.visible');
e.options.visibleMultiplier = 1;
if (e.options.itemsCount > e.options.itemsToShow) {
e.options.$visible.find('.visible-display').html(1 + '-' + e.options.itemsToShow + ' of ');
}
})
.on('slide.bananaPeel', function(e) {
@cbourdage
cbourdage / magento-kitchen.html
Last active December 31, 2015 06:19
Kitchen Sink Markup (for Magento)
<div class="kitchen-sinks">
<section>
<h6 class="grey">Page Titles</h6>
<div class="page-title">
<h1>Page Title Here</h1>
</div>
</section>
<section>