// jQuery
$(document).ready(function() {
// code
})
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
/** | |
* Cross Browser helper to addEventListener. | |
* | |
* @param {HTMLElement} obj The Element to attach event to. | |
* @param {string} evt The event that will trigger the binded function. | |
* @param {function(event)} fnc The function to bind to the element. | |
* @return {boolean} true if it was successfuly binded. | |
*/ | |
var cb_addEventListener = function(obj, evt, fnc) { | |
// W3C model |
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
/* | |
* Minimal classList shim for IE 9 | |
* By Devon Govett | |
* MIT LICENSE | |
*/ | |
if (!("classList" in document.documentElement) && Object.defineProperty && typeof HTMLElement !== 'undefined') { | |
Object.defineProperty(HTMLElement.prototype, 'classList', { | |
get: 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
//addEventListener polyfill 1.0 / Eirik Backer / MIT Licence | |
(function(win, doc){ | |
if(win.addEventListener)return; //No need to polyfill | |
function docHijack(p){var old = doc[p];doc[p] = function(v){return addListen(old(v))}} | |
function addEvent(on, fn, self){ | |
return (self = this).attachEvent('on' + on, function(e){ | |
var e = e || win.event; | |
e.preventDefault = e.preventDefault || function(){e.returnValue = false} | |
e.stopPropagation = e.stopPropagation || function(){e.cancelBubble = true} |
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 whichTransitionEvent(){ | |
var t; | |
var el = document.createElement('fakeelement'); | |
var transitions = { | |
'transition':'transitionend', | |
'MSTransition':'msTransitionEnd', | |
'MozTransition':'transitionend', | |
'WebkitTransition':'webkitTransitionEnd' | |
} |
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($){ | |
$.fn.cache = function (key, create, use){ | |
var data = this.data(key); | |
if (!data){ | |
data = create(); | |
this.data(key, data); | |
} | |
return use(data); | |
}; | |
})(jQuery); |
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
/* | |
* http://christian-fei.com/tutorials/how-to-lazy-load-disqus-comments/ | |
* | |
* <div class="comments"></div> | |
*/ | |
var comments = document.getElementsByClassName('comments')[0], | |
disqusLoaded = false; | |
function loadDisqus() { |
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
/* | |
* Easing Equations ported to CSS by @matthewlein - http://matthewlein.com/ceaser/ | |
* Converted to SCSS vars by @pettpett | |
* | |
* sample usage: | |
* a { | |
* color: #ff0000; | |
* transition: color 0.5s $easeOutQuint; | |
* &:hover, |
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
// Super contrived example. This is an IIFE. It executes immediately so that the | |
// privateProperty is in the nested scope and so that the Module property is | |
// actually assigned the function (named inner) instead. If we didn't make it an | |
// immediately-invoked-function-expression (IIFE) then Module would be a function | |
// that once called would be the new (inner) function. | |
// | |
// I'm returning an object inside inner() that has the scope outside of that function. | |
// That's what makes this a true closure. It's that I'm able to reference variables | |
// from functions outside out of the one I'm currently running. Basically in this | |
// example. Module == inner (they are the same thing). So when we call module, we're |
OlderNewer