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
/** | |
Code copyright Dustin Diaz and Ross Harmes, Pro JavaScript Design Patterns. | |
**/ | |
// Constructor. | |
var Interface = function (name, methods) { | |
if (arguments.length != 2) { | |
throw new Error("Interface constructor called with " + arguments.length + "arguments, but expected exactly 2."); | |
} | |
this.name = name; |
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
/*! | |
* isVis - v0.5.5 Aug 2011 - Page Visibility API Polyfill | |
* Copyright (c) 2011 Addy Osmani | |
* Dual licensed under the MIT and GPL licenses. | |
*/ | |
(function () { | |
window.visibly = { | |
b: null, | |
q: 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
function getPrefix( prop ){ | |
var vendorPrefixes = ['Moz','Webkit','Khtml','O','ms'], | |
style = document.createElement('div').style, | |
upper = prop.charAt(0).toUpperCase() + prop.slice(1), | |
pref, len = vendorPrefixes.length; | |
while( len-- ){ | |
if((vendorPrefixes[len] + upper) in style){ | |
pref = (vendorPrefixes[len]); | |
} | |
} |
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 getPrefix(prop, context) { | |
var vendorPrefixes = ['moz', 'webkit', 'khtml', 'o', 'ms'], | |
upper = prop.charAt(0).toUpperCase() + prop.slice(1), | |
pref, len = vendorPrefixes.length, | |
q; | |
while (len--) { | |
q = vendorPrefixes[len]; | |
if (context.toString().indexOf('style')) { | |
q = q.charAt(0).toUpperCase() + q.slice(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
/* | |
* objectClone.js (c) Addy Osmani, 2011. | |
* Do whatever license. | |
* Thanks to gf3 and ben_alman for tips that helped improve. | |
*/ | |
function objectClone(q){ | |
var n = (q instanceof Array) ? [] : {},i; | |
for (i in q) { | |
if (Object.prototype.toString.call({}) == Object.prototype.toString.call( q[i] )) { |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
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
////Module Pattern based on a singleton | |
var basketModule = (function() { | |
var basket = []; //private | |
return { //exposed to public | |
addItem: function(values) { | |
basket.push(values); | |
}, | |
getItemCount: function() { | |
return basket.length; |
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
// matchMedia is supported and the device has a small screen | |
if ( "matchMedia" in window | |
&& window.matchMedia( "(max-device-width: 800px)" ) | |
) { | |
Array.prototype.forEach.call( | |
// for each element matching the selector... | |
document.querySelectorAll( | |
"a[href*='youtube.com/watch'], a[href*='flickr.com']" | |
), | |
// ...replace the href with their mobile equivalent |
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
/* | |
* matchMedia() polyfill - test whether a CSS media type or media query applies | |
* authors: Scott Jehl, Paul Irish, Nicholas Zakas | |
* Copyright (c) 2010 Filament Group, Inc | |
* MIT license | |
* dev.w3.org/csswg/cssom-view/#dom-window-matchmedia | |
* in Chrome since m10: http://trac.webkit.org/changeset/72552 | |
*/ |
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
/* | |
Courtesy of Sitepen | |
*/ | |
/* | |
First, let’s look at very lightweight, but powerful boilerplate, an adapter that will let you write a module for both AMD and CommonJS standard module systems, using AMD style dependency declarations. This combination allows us to create modules that can be used both in browser and server environments: | |
*/ |