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
// Iterations, anyone? AKA | |
// How I wrote a walk_dom method. | |
// | |
// A JavaScript poem by | |
// | |
// "Cowboy" Ben Alman | |
// 11/21/2009 | |
// A starting point. |
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
// Going into jQuery BBQ soon! | |
// http://github.com/cowboy/jquery-bbq | |
(function($){ | |
// Method: jQuery.bbq.removeState | |
// | |
// Remove one or more keys from the current browser history 'state', creating | |
// a new state, setting location.hash and triggering any bound | |
// <window.onhashchange> event callbacks (provided the new state is different |
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
<!-- | |
IE conditional comment <body> tag in XSLT | |
5/28/2010 "Cowboy" Ben Alman | |
http://benalman.com | |
See: | |
http://paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ | |
--> | |
<xsl:template name="html_body"> |
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
For jQuery 1.4 $.param() | |
See http://benalman.com/news/2009/12/jquery-14-param-demystified/ | |
========== | |
PHP 5.2.11 | |
========== | |
# print_r( $_GET ); | |
?a=1&a=2&a=3 |
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
(function($){ | |
$.each( $.expr[":"], function(k){ | |
$.fn[k] = $.fn[k] || function(v){ | |
return this.pushStack( this.filter( ':' + k + '(' + v + ')' ), k ); | |
}; | |
}); | |
}(jQuery); |
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
(function($){ | |
var private1, | |
myNS = $.myNS = {}, | |
method2; | |
$.myNS.method1 = function(){ | |
private2(); | |
}; | |
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
// Creating a plugin with $.myNS.public_method1() and $.myNS.public_method2() methods, a few different ways. | |
(function($){ | |
var private_var, | |
myNS = $.myNS = {}, | |
public_method2; | |
myNS.public_method1 = function(){ | |
private_method(); |
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
function jquery_14_useragent_test( ua ) { | |
var ret = { browser: "" }; | |
ua = ua.toLowerCase(); | |
if ( /webkit/.test( ua ) ) { | |
ret = { browser: "webkit", version: /webkit[\/ ]([\w.]+)/ }; | |
} else if ( /opera/.test( ua ) ) { |
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
// based on http://zaa.ch/1q | |
$.isType = function( obj, type ) { | |
var opt = Object.prototype.toString, | |
result = opt.call( obj ).slice( 8, -1 ).toLowerCase(); | |
if ( type === 'null' || type === 'undefined' ) { | |
type = type === 'null' ? opt.call( null ) : opt.call( undefined ); | |
type = type.slice( 8, -1 ).toLowerCase(); | |
} |
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
var foo = { | |
context: 'obj', | |
func: function(){ | |
console.log( this.context ); | |
} | |
}; | |
var bar = foo.func; | |
window.context = 'global'; |