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
addStyle = function( css ) { | |
var styleEl = document.createElement( 'style' ); | |
styleEl.rel = 'stylesheet'; | |
// overwrite the stylesheet if it already exist... | |
if ( styleEl.styleSheet ) { // IE | |
styleEl.styleSheet.cssText = css; | |
} else { // !IE | |
styleEl.appendChild( document.createTextNode( css ) ); | |
} | |
// attach the stylesheet to the page |
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
document.head = document.head || document.getElementsByTagName('head')[0]; |
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
// 1: how could you rewrite the following to make it shorter? | |
if (foo) { | |
bar.doSomething(el); | |
} else { | |
bar.doSomethingElse(el); | |
} | |
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 browsers = [ 'Firefox', 'IEMobile', 'MSIE', 'Android', 'BlackBerry', 'iPhone', 'Chrome', 'Safari', 'Opera Mini', 'Opera' ], | |
thisBrowser = ( function() { | |
for ( var i = 0, bl = browsers.length; i < bl; i++ ) { | |
if ( !!~navigator.userAgent.indexOf( browsers[i] ) ) { | |
return browsers[i]; | |
} | |
} | |
})() || 'Unknown'; |
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
// usage: log('inside coolFunc', this, arguments); | |
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/ | |
window.log = function f() { | |
log.history = log.history || []; | |
log.history.push(arguments); | |
if (this.console) { | |
var args = arguments, | |
newarr; | |
args.callee = args.callee.caller; | |
newarr = [].slice.call(args); |
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 testFont(name) { | |
name = name.replace(/['"<>]/g,''); | |
var body = document.body, | |
test = document.createElement('div'), | |
installed = false, | |
template = | |
'<b style="display:inline !important; width:auto !important; font:normal 10px/1 \'X\',sans-serif !important">ii</b>'+ | |
'<b style="display:inline !important; width:auto !important; font:normal 10px/1 \'X\',monospace !important">ii</b>', | |
ab; |
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 queueFn - v0.5 - 06/18/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 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
Show hidden characters
{ | |
// -------------------------------------------------------------------- | |
// JSHint Configuration, Strict Edition | |
// -------------------------------------------------------------------- | |
// | |
// This is a options template for [JSHint][1], using [JSHint example][2] | |
// and [Ory Band's example][3] as basis and setting config values to | |
// be most strict: | |
// | |
// * set all enforcing options to true |