Skip to content

Instantly share code, notes, and snippets.

View cbourdage's full-sized avatar

Collin Bourdage cbourdage

View GitHub Profile
@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>
@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 / 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)
/**
* 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();
}
}
// 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
}
@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);
.sprite(@pos-x; @pos-y; @repeat: no-repeat) {
background: url("../images/sprite.png") @pos-x @pos-y @repeat;
@media only screen and (-webkit-min-device-pixel-ratio: 2),
only screen and ( min--moz-device-pixel-ratio: 2),
only screen and ( -o-min-device-pixel-ratio: 2/1),
only screen and ( min-device-pixel-ratio: 2),
only screen and ( min-resolution: 192dpi),
only screen and ( min-resolution: 2dppx) {
background-size: 500px 500px;
<script>
(function(doc, script) {
var js,
s = doc.getElementsByTagName(script)[0],
load = function(src, callback, id) {
if (d.getElementById(id)) return;
js = doc.createElement(script);
js.src = src;
js.id = id;
//js.async = true;
@cbourdage
cbourdage / form.less
Last active August 29, 2015 14:02
Custom form validation by extending prototype validation
// Validation errors
.input-box {
position: relative;
.validation-failed {
padding-right: 80px;
}
.validation-advice {
background-color: #fff;
border: 2px solid @brand-orange;
@cbourdage
cbourdage / accordion-updates.js
Created June 18, 2014 17:03
Scroll UX and Custom Elements/Selects For Checkout
Accordion.prototype.openSection = function(section) {
var section = $(section);
// Check allow
if (this.checkAllow && !Element.hasClassName(section, 'allow')){
return;
}
if(section.id != this.currentSection) {
this.closeExistingSection();