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
// https://github.com/jquery/jquery/blob/master/src/core/init.js#L14 | |
var isHTMLString = (function() { | |
var rHTML = /^(?:\s*(<[\w\W]+>)[^>]*|#([\w-]*))$/; | |
return function(str) { | |
return rHTML.test(str); | |
}; | |
}()); |
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 generateOfficeWebAppURL(url) { | |
return "http://view.officeapps.live.com/op/view.aspx?src=" + encodeURIComponent(url); | |
} |
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
/* | |
Kilo.js | |
#toSize: 2048 => "2 KB" | |
#toBytes: "2 KB" => 2048 | |
*/ | |
var Kilo = (function() { | |
"use strict"; | |
var kilo = 1024; | |
var sizes = { "B": 0, "KB": 1, "MB": 2, "GB": 3, "TB": 4 }; | |
var sizesNames = Object.keys(sizes); |
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 isUsingImperialSystem(countryCode) { | |
return /US|PR|JM|BS|GU|BZ|VI|KY|PW/.test(countryCode); | |
} |
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
_.mixin({ | |
cacheFor: function(wait, fn) { | |
return _.throttle(fn, wait, { trailing: 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
var shadowWrap = (function() { | |
var createShadowRoot = Element.prototype.createShadowRoot || Element.prototype.webkitCreateShadowRoot; | |
function createWrapper(content) { | |
var wrapper = document.createElement("shadow-wrap"); | |
var shadowRoot = createShadowRoot.call(wrapper); | |
wrapper.resetStyleInheritance = true; | |
switch (typeof content) { | |
case "string": |
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 encodeImage = (function() { | |
var DEFAULT_IMAGE = 'data:image/png;base64,', | |
prefix = "_", | |
cache = {}; | |
function encode(url, callback) { | |
var key = prefix + url, value = cache[key]; | |
if (value) { | |
callback(value); | |
} else { |
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
Object.defineProperty(Object, "extend", { | |
enumerable: false, | |
value: function extend(obj) { | |
Array.prototype.slice.call(arguments, 1).forEach(function(current) { | |
Object.getOwnPropertyNames(current).forEach(function(key) { | |
Object.defineProperty(obj, key, Object.getOwnPropertyDescriptor(current, key)); | |
}); | |
}); | |
return obj; | |
} |
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
// 1234567890 => "1,234,567,890" | |
function formatNumber(n) { | |
var a = [], s = String(n), i = l = s.length; | |
while (i--) a.push(s[i]), i && (l - i) % 3 === 0 && a.push(","); | |
return a.reverse().join(""); | |
} |
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
// deparam | |
// | |
// Inverse of $.param() | |
// | |
// Taken from jquery-bbq by Ben Alman | |
// https://github.com/cowboy/jquery-bbq/blob/master/jquery.ba-bbq.js | |
var isArray = Array.isArray || function(obj) { | |
return Object.prototype.toString.call(obj) == '[object Array]'; | |
}; |