This file contains hidden or 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
// Uber-basic templating.. good? bad? ugly? | |
function interpolate( str, data ) { | |
data = data || window; | |
return !str | |
? '' | |
: str.replace( /{([^}]*)}/g, function(a,b){ | |
return data[ b ] || ''; | |
}); | |
}; |
This file contains hidden or 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
/* | |
Say you have widgets in the page, and each one has its own option defaults. | |
You embed these widgets in the page, but as your site grows, you may want | |
to change the defaults in a way that affects only new widgets, leaving the | |
existing widgets unmodified. How do you manage these "schema" updates? | |
Sample HTML: | |
<div class="widget" data-schema="1" data-type="that_widget" data-params="bar=5&baz=6" style="width:200px;height:300px"> |
This file contains hidden or 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
// Public domain, really. | |
jQuery.expr[':'].focus = function( elem ) { | |
return elem === document.activeElement && ( elem.type || elem.href ); | |
}; |
This file contains hidden or 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 outerHTML - v0.3 - 06/25/2010 | |
* http://benalman.com/ | |
* | |
* Copyright (c) 2010 "Cowboy" Ben Alman | |
* Dual licensed under the MIT and GPL licenses. | |
* http://benalman.com/about/license/ | |
* | |
* Inspired by Brandon Aaron's outerHTML plugin. | |
* http://github.com/brandonaaron/jquery-outerhtml |
This file contains hidden or 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 hidden or 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 ready - v0.4pre - 06/28/2010 | |
* http://benalman.com/projects/jquery-ready-plugin/ | |
* | |
* Copyright (c) 2010 "Cowboy" Ben Alman | |
* Dual licensed under the MIT and GPL licenses. | |
* http://benalman.com/about/license/ | |
*/ | |
(function($,undefined){ |
This file contains hidden or 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
// Block page loading, for testing ready events / etc. | |
function block( delay ) { | |
var html = '<script src="http://1.cuzillion.com/bin/resource.cgi?type=js&sleep=' | |
+ delay + '&jsdelay=' + delay + '&t=' + +new Date + '"><\/script>'; | |
document.write( html ); | |
}; | |
/* |
This file contains hidden or 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 isVersion - v0.1 - 07/02/2010 | |
* http://benalman.com/ | |
* | |
* Copyright (c) 2010 "Cowboy" Ben Alman | |
* Dual licensed under the MIT and GPL licenses. | |
* http://benalman.com/about/license/ | |
*/ | |
(function($){ |
This file contains hidden or 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
// Fillbox plugin, to go along with Rey Bango's blog post, | |
// "Generic Activity Indicator for Ajax Requests" | |
// http://blog.reybango.com/2010/07/06/generic-activity-indicator-for-ajax-requests/ | |
(function($){ | |
// Call as $('#foo').fillbox() to use default options or override as-needed | |
// like $('#bar').fillbox({ url: 'foo.php' }). | |
$.fn.fillbox = function( options ) { | |
This file contains hidden or 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
// Console arguments testing | |
var apc = [].slice; | |
(function(){ | |
console.log( apc.call(arguments) ); | |
})( "false", 1, undefined, null, ["foo","bar","baz"], {a:1,b:2}, false ); | |
(function(){ | |
console.log.call( console, apc.call(arguments) ); |