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 getGlobalOffset(el) { | |
var x = 0, y = 0 | |
while (el) { | |
x += el.offsetLeft | |
y += el.offsetTop | |
el = el.offsetParent | |
} | |
return { left: x, top: y } | |
} |
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
leftPad = function leftPad(value, size, pad) { // very very fast | |
if (value.length < size) { | |
size -= value.length; | |
var res = ''; | |
for(;;) { | |
if (size & 1) res += pad; | |
size >>= 1; | |
if (size) pad += pad; | |
else break; | |
} |
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-z\u00C0-\u00ff]+/g) |
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 parseNumber(str) | |
{ | |
str = (str + '').replace(/[^\d,.-]/g, '') // just digits, separators and sign | |
var sign = str.charAt(0) === '-' ? '-' : '+' // store sign | |
var minor = str.match(/[.,](\d+)$/) // filter decimals | |
str = str.replace(/[.,]\d*$/, '').replace(/\D/g, '') // remove decimals and any integer separator | |
return Number(sign + str + (minor ? '.' + minor[1] : '')) // build number | |
} |
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://paulirish.com/2011/requestanimationframe-for-smart-animating/ | |
// http://my.opera.com/emoller/blog/2011/12/20/requestanimationframe-for-smart-er-animating | |
// requestAnimationFrame polyfill by Erik Möller | |
// fixes from Paul Irish and Tino Zijdel | |
(function() { | |
var lastTime = 0; | |
var vendors = ['ms', 'moz', 'webkit', 'o']; | |
for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) { |
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 getAbsolutePath(url) { | |
return url.match(/^\w+:\/\/[^\/]+\/*(?:[^\/\.]+(?:\r|\/+))*/)[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
function removeComments(html) { | |
return (''+html) | |
.replace/*HTMLComments*/(/<!-[\S\s]*?-->/gm, '') | |
.replace/*JSBlockComments*/(/\/\*[\S\s]*?\*\//gm,'') | |
.replace/*JSLineComments*/(/^.*?\/\/.*/gm, '$1') // FIXME | |
} |
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 toUnicode(val/* :Array|Number|String */) { | |
var res = ''; | |
var type = $.type(val); | |
var i; | |
switch(type) { | |
case 'array': | |
val = s.join(''); | |
case 'string': | |
case 'number': | |
i = (val + '').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
JAVASCRIPT, CSS, HTML5 AND WEB RELATED REFERENCES | |
================================================= | |
FIXES AND HACKS | |
--------------- | |
HTML5 DOCTYPE <------------ HTML5 DOCTYPE IS TOTALLY CROSS-COMPATIBLE WITH IE 5.5, 6, 7, 8, 9, 10, 11, ... !!! | |
<!DOCTYPE html> | |
(yeah! just that!) |
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 htmlSpecialCharsEntityEncode(str) { | |
return str.replace(/[<>&\r\n"']/gm, function (match) { | |
return '&' + { | |
'<': 'lt;', | |
'>': 'gt;', | |
'&': 'amp;', | |
'\r': "#13;", | |
'\n': "#10;", | |
'"': 'quot;', | |
"'": 'apos;' /*single quotes just to be safe*/ |
OlderNewer