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
smoothScroll=function(b){var c="pageYOffset" in window?window.pageYOffset:document.documentElement.scrollTop,d=+new Date(),e=d+1000,f=document.height<(b.offsetTop+window.innerHeight)?document.height-window.innerHeight:b.offsetTop,s=f-c<0?true:false,g=setInterval(function(){var h=+new Date();if(h<=e){scrollTo(0,s?(c-(((h-d)/(e-d)*c)+f)):c+(h-d)/(e-d)*(f-c))}else{clearInterval(g)}},10)}; | |
// smoothScroll(elementToReach) |
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
// a = element | |
// b = event (string) | |
// c = function to call | |
addEvent = function(a, b, c) { | |
if ("addEventListener" in window) { // !(IE) | |
a.addEventListener(b, function(d){ | |
d.preventDefault(); | |
c.call(a); | |
}, false) |
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
addEvent = function(a, b, c) { | |
if ("addEventListener" in window) { // !(IE) | |
a.addEventListener(b, function(d){ | |
d.preventDefault(); | |
c.call(a); | |
}, false) | |
} else { // IE | |
a.attachEvent("on" + b, function() { | |
c.call(a); | |
return false |
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 (destination, duration) { | |
// destination (relative to window top) in px | |
// duration in ms | |
/* Variables */ | |
var startPosition = "pageYOffset" in window ? window.pageYOffset : document.documentElement.scrollTop, | |
startTime = +new Date(), | |
endTime = startTime + duration, | |
// if top of element is outside the document, then define end point to document limit | |
// elsewhere, go the the top of the element | |
destinationSafe = document.height < (destination + window.innerHeight) ? document.height - window.innerHeight : destination, |
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
// middle between two colors | |
middle(first, second) | |
rgb((red(first) + red(second)) / 2, (green(first) + green(second)) / 2, (blue(first) + blue(second)) / 2) | |
// simple gradients | |
linear-gradient(start, end) | |
// fallback using the intermediate color | |
background: middle(start, end) |
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
/* | |
Simple browser detection script. | |
Returns an object. | |
*/ | |
var Browser = new function() { | |
this.UA = window.navigator.userAgent.toLowerCase(); | |
this.isChrome = !!(this.UA.indexOf("chrome") + 1); | |
this.isSafari = !!(this.UA.indexOf("safari") + 1); | |
this.isIE = !!(this.UA.indexOf("msie") + 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
/* toHandler function | |
* returns a handler with cross browser preventDefault and cancelPropagation options | |
* @func : function called with eventObject and the handler itself | |
* @preventDefault : boolean | |
* @cancelPropagation : boolean | |
*/ | |
function toHandler(func, preventDefault, cancelPropagation){ | |
var cache; | |
return cache = function(object){ |
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
String.prototype.toElement = function() { | |
var childNodes, fragment, i, item, sandbox, _i, _len; | |
sandbox = document.createElement("div"); | |
fragment = document.createDocumentFragment(); | |
sandbox.innerHTML = this; | |
childNodes = $A(sandbox.childNodes); | |
for (i = _i = 0, _len = childNodes.length; _i < _len; i = ++_i) { | |
item = childNodes[i]; | |
fragment.appendChild(item); | |
} |
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
DOM.prototype.transition = function(transition, persistent){ | |
var element = this, | |
hash = new Hash, | |
prop = "TransitionEvent" in window ? 0 : // FF >= 16 | |
"WebKitTransitionEvent" in window ? 1 : // webkit | |
+opera.version() > 10.49 ? 2 : // Opera | |
"mozTransitionEvent" in window ? 3 : // FF <= 15 | |
"msTransitionEvent" in window ? 4 : // IE | |
-1, // nope | |
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
// requires Array.range mixin | |
function paginate(list, itemsPerPage){ | |
// @list : Array, what to paginate | |
// @itemsPerPage : Number | |
var fragment = DOM.createFragment(); | |
Array.range(0, Math.ceil(list.length / itemsPerPage)).forEach(function(item){ |
OlderNewer