Skip to content

Instantly share code, notes, and snippets.


Addy Osmani addyosmani

View GitHub Profile
cowboy / jquery_plugin_org_1.js
Created Jan 8, 2010
View revisions from oldest -> newest
View jquery_plugin_org_1.js
// Creating a plugin with $.myNS.public_method1() and $.myNS.public_method2() methods, a few different ways.
var private_var,
myNS = $.myNS = {},
myNS.public_method1 = function(){
View hashchange.js
var supported;
if (document.body.setAttribute) {
var el = document.createElement('div');
supported = typeof el.onhashchange == 'function';
} else {
supported = 'onhashchange' in document.documentElement;
if (!supported) {
ebello / gist:330358
Created Mar 12, 2010 — forked from remy/gist:330318
Placeholder fixer
View gist:330358
* Add this script to the end of your document that use <input autofocus type="text" />
* or <input type="text" placeholder="username" /> and it'll plug support for browser
* without these attributes
* Minified version at the bottom
(function () {
function each(list, fn) {
var l = list.length;
paulirish / gist:366184
Created Apr 14, 2010
html5 geolocation with fallback.
View gist:366184
// geo-location shim
// currentely only serves lat/long
// depends on jQuery
// doublecheck the ClientLocation results because it may returning null results
if (geolocation) return;
remy / details.js
Created Apr 18, 2010
Add <details> support - includes stylesheet
View details.js
* Note that this script is intended to be included at the *end* of the document, before </body>
(function (window, document) {
if ('open' in document.createElement('details')) return;
// made global by myself to be reused elsewhere
var addEvent = (function () {
if (document.addEventListener) {
return function (el, type, fn) {
mattmccray / jquery.anim8.js
Created Apr 25, 2010
platform.js -- Memoize functions base on browser type.
View jquery.anim8.js
// (Simple example of using platform.js in a jQuery plugin.)
// Usage: $('#block').anim8({ top:50, left:350 }, 250);
$.fn.anim8 = (function($){ return platform({
// For Webkit browsers it will use CSS animations
webkit: function(props, speed, transition) {
return this.each(function(){
var elem = $(this),
transition = transition || 'ease-out',
jlsync / Javascript MVC for Ruby-on-Rails.txt
Created Jun 17, 2010
Javascript MVC patterns and implementations
View Javascript MVC for Ruby-on-Rails.txt
Controllers: - Sammy is a tiny javascript framework built on top of jQuery. It’s RESTful Evented JavaScript.
keeto / Mediator.js
Created Jun 26, 2010
Mediator: Object grouping and brokering
View Mediator.js
Script: Mediator
Object grouping and brokering
Copyright and License:
Copyright 2010, Mark Obcena. MIT-Style License
cowboy / newtwitter-hashchange.js
Created Sep 16, 2010
How does IE6/7 "back button" support work?
View newtwitter-hashchange.js
// From
(function (B) {
var A = (function () {
var E = {
select: "input",
change: "input",
submit: "form",
reset: "form",
error: "img",
View hash_history.js
// Handles JavaScript history management and callbacks. To use, register a
// regexp that matches the history hash with its corresponding callback.
window.HashHistory = {
// The interval at which the window location is polled.
// We need to use an iFrame to save history if we're in an old version of IE.
USE_IFRAME : jQuery.browser.msie && jQuery.browser.version < 8,
You can’t perform that action at this time.