This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* jQuery hoverClass plugin | |
*/ | |
$.fn.hoverClass = function(className) { | |
return this.each(function() { | |
var $this = $(this); | |
$this.hover(function() { | |
$this.addClass(className); | |
}, function() { | |
$this.removeClass(className); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Useful date functions if you're building a calendar */ | |
var getStartOfCurrentDay = function(date) { | |
return new Date(date.getFullYear(), date.getMonth(), date.getDate()); | |
}; | |
var getStartOfNextDay = function(date) { | |
return new Date(date.getFullYear(), date.getMonth(), date.getDate() + 1); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* parseQueryParameters & parseFragmentIdentifiers */ | |
var setValue = function(obj, prop, val) { | |
if (!(prop in obj)) { | |
obj[prop] = val; | |
} else { | |
if (!(obj[prop] instanceof Array)) { | |
obj[prop] = [obj[prop]]; | |
} | |
obj[prop].push(val); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var stress = function(fn, iterations) { | |
iterations = iterations || 1; | |
var result; | |
var start = new Date(); | |
for (var i = 0; i < iterations; ++i) { | |
result = fn(); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var _parseHTMLFromDOMElement = function(el) { | |
if (el.outerHTML) { | |
return el.outerHTML; | |
} else { | |
var sandbox = document.createElement('DIV'); | |
sandbox.appendChild(el.cloneNode(true)); | |
return sandbox.innerHTML; | |
} | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* $.fn.unwrap | |
* Unwraps an element (replaces an elements parent with the element) | |
* | |
* NO LONGER NECESSARY AS OF jQuery 1.4 | |
* | |
* Example: | |
* $('#foo').unwrap(); | |
* Will replace: | |
* <div><span id="foo">bar</span></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @class PeriodicalExecuter | |
* @param {Function} callback | |
* @param {Number} interval | |
* @param {Boolean} defer | |
* @constructs | |
*/ | |
var PeriodicalExecuter = function(callback, interval, defer) { | |
this.callback = callback; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var bind = function(fn, obj /*, defaults */) { | |
var scope = obj || window, defaults; | |
fn = (typeof fn === 'string') ? scope[fn] : fn; | |
// If no defaults are supplied, return the lightweight callback | |
if (arguments.length < 3) { | |
return function() { | |
fn.apply(scope, arguments); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* isDST | |
* Returns true if the supplied date (default Today) is DST | |
*/ | |
var isDST = function(date) { | |
date = date ? new Date(date) : new Date(); | |
var winter = new Date(date.getFullYear(), 0, 1); | |
return (date.getTimezoneOffset() !== winter.getTimezoneOffset()); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Abstract methods and interfaces | |
/** | |
* AbstractMethod factory class | |
* | |
* @method AbstractMethod | |
* @param {string} methodName Name of the method | |
* @return {type} Return value description | |
*/ | |
var AbstractMethod = function(methodName) { |
OlderNewer