Skip to content

Instantly share code, notes, and snippets.

View craigmdennis's full-sized avatar
🚀

Craig Dennis craigmdennis

🚀
View GitHub Profile
@craigmdennis
craigmdennis / multiple.bxslider.js
Created November 1, 2011 16:34
Dynamically generate multiple BX Sliders
$(function () {
var bxSliderInstances = {};
// Use a class rather than an ID
var $slider = $('.mini-slider');
// For each result
$slider.each(function (index, element) {
@craigmdennis
craigmdennis / gallery.bxslider.html
Created November 1, 2011 16:48
A BX Slider configuration that uses 2 separate sliders. One for the gallery and one for the thumbs.
@craigmdennis
craigmdennis / multiple.js
Created November 1, 2011 16:52
Return true if one number is a multiple of the other
// Return true if it is a multiple
function multiple(int, multipleOf) {
var remainder = int % multipleOf;
if (remainder === 0) {
return true;
} else {
return false;
}
}
@craigmdennis
craigmdennis / markup.html
Created November 30, 2011 15:22
Show password text with checkbox toggle
<form action="">
<fieldset class="error">
<div class="form-row">
<span class="error-hook">
Please enter a valid email address
</span>
<div class="input-hook">
<label for="email-address" class="placeholder">
Email address
</label>
@craigmdennis
craigmdennis / spinSubmit.js
Created December 7, 2011 16:02
Add a loading animation to a submit <button> or <a> before submitting a form
/**
Requires:
Spin.js (http://fgnass.github.com/spin.js/)
Spin.js jQuery plugin (https://gist.github.com/1290439)
Usage: $(#your-id).spinSubmit();
For best results, change the 'small' to - small:{lines:12,length:3,width:2,radius:4} in the jQuery plugin
@craigmdennis
craigmdennis / gist:1446936
Created December 8, 2011 13:01
Simple LESS Grid Calculator
#grid {
/* Consult http://gridulator.com for viable grids */
@totalColumns: 12;
@siteWidth: 960px;
@margin: 10px;
.container() {
margin-left: auto;
margin-right: auto;
@craigmdennis
craigmdennis / wmode.js
Created February 6, 2012 20:35
Add wmode=transparent to YouTube iframes
function wmode() {
// For each iFrame
$('iframe').each(function () {
// Store some variables
var $this = $(this),
src = $this.attr('src'),
query;
@craigmdennis
craigmdennis / hasLayout.js
Created February 6, 2012 23:34
Detect if element hasLayout in IE and invoke it if false
/**
* If you wonder why filter:alpha(opacity=20); sometimes does nothing,
* Read http://joseph.randomnetworks.com/2006/08/16/css-opacity-in-internet-explorer-ie/
* Use the function below to detect if an element has layout & to apply it dynamically if not
*/
function hasLayout(selector) {
$(selector).each(function (index, element) {
if (element.currentStyle.hasLayout === false) {
$(element).css({
@craigmdennis
craigmdennis / beforeNavigation.js
Created February 12, 2012 22:13
Capture a link and perform an animation before navigating to it
$('a:not(.external').on('click', function(e) {
// Detect if the ctrl key is pressed (indicating opening in a new tab)
if (!e.ctrlKey) {
// Cache variables for speed
var $this = $(this);
var href = $this.attr('href');
e.preventDefault();
@craigmdennis
craigmdennis / fullHeight.js
Created February 20, 2012 18:19
Set the height of an element to the height of the window
$.fn.fullHeight = function( offset ){
// Check if offset specified
if (offset === '') {
// If it's not then set it to 0
offset = 0;
}
// Maintain chainability