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 a = 1; | |
(function(){ | |
var a = 2; | |
(function(parent){ | |
var global = this; | |
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
function repeat(s,n){return Array(n+1).join(s);} | |
// usage | |
repeat('x', 3); // returns "xxx" |
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
//EnhanceJS isIE test idea | |
//detect IE and version number through injected conditional comments (no UA detect, no need for cond. compilation / jscript check) | |
//version arg is for IE version (optional) | |
//comparison arg supports 'lte', 'gte', etc (optional) | |
var isIE = (function(){ | |
var doc = document, |
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
// ========================= | |
// SetInterval | |
// ========================= | |
// While not truly accurate, setInterval is still fairly good, time-wise. | |
// Better for things like a "one second tick" but not great for expensive | |
// code executed at small intervals as iterations can "stack". | |
// (ECMAScript 5 strict mode compatible) |
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
// "Cheat" special event using this pattern: | |
// http://benalman.com/news/2010/03/jquery-special-events/#pattern | |
// | |
// Also see: | |
// http://benalman.com/news/2010/03/jquery-special-events/#add-and-remove-tripleclick-per-handler | |
(function($){ | |
$.event.special.cheat = { | |
setup: function() { |
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
/*! | |
* bindAndTrigger - v0.1 - 04/30/2010 | |
* http://benalman.com/ | |
* | |
* http://jsfiddle.net/cowboy/fJnA2/ | |
*/ | |
(function($,undefined){ | |
$.fn.bindAndTrigger = function( all, type, data, 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
$.fn.format = function(opts){ | |
var o = $.extend({}, defaults.format, opts), codez = formatCodes(o.locale); | |
return this.each(function(){ | |
var me = $(this); | |
me[ me.is(":input") ? "val" : "text" ](function(i,v){ | |
return formatNumber( v, o, codez ); | |
}); | |
}); | |
} |
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.preloadImg | |
* description: cache images via $.preloadImg(['src','src']) or $('img').preloadImg() | |
* author: Cody Lindley | |
*/ | |
(function($) { | |
// Internal cache of image src values. | |
var cache = {}; |
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
/* | |
Usages: | |
$(selector).classList() //returns an array of classnames | |
$(selector).classList('newclass') //replaces the current element's classes | |
$(selector).classList(['new', 'class', 'names']) //replaces the current element's classes | |
*/ | |
jQuery.fn.classList = function( classNames ) { | |
if ( jQuery.isArray( classNames ) ) { | |
// An array was passed, join it into a string. |
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
function relativeDate(str) { | |
var s = ( +new Date() - Date.parse(str) ) / 1e3, | |
m = s / 60, | |
h = m / 60, | |
d = h / 24, | |
w = d / 7, | |
y = d / 365.242199, | |
M = y * 12; | |
function approx(num) { |
OlderNewer