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
const overload = (() => { | |
const noop = () => {}; | |
const typeOf = (p) => (Object.prototype.toString.call(p).slice(8,-1)); | |
return (fns) => (function (...args) { | |
const key = args.map(typeOf).join('_'); | |
return (fns[key] || noop).apply(this, 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 compile (pattern, mapping) { | |
pattern = pattern || ''; | |
var i, | |
ch, | |
last, | |
attrName, | |
sequenceLength = 0, | |
len = pattern.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
(function(){ | |
var globals = [], | |
pageProps = {}, | |
nativeProps = {}, | |
v; | |
for (v in window) { | |
pageProps[v] = 1; | |
} | |
var ifrm = document.createElement("IFRAME"); | |
document.body.appendChild(ifrm); |
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
/** | |
* assumption: path contains only key names and dots (.), doesn't handle function calls or array indices | |
*/ | |
function getVal (obj, path) { | |
if (path) { | |
var s = path.split('.'), | |
cur = s.shift(); | |
if (obj.hasOwnProperty(cur)) { | |
return getVal(obj[cur], s.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
"use strict"; | |
define([ | |
'jquery', | |
'underscore' | |
], function ($, _) { | |
$.fn.loadImg = function (options) { | |
// var opts = $.extend({}, $.fn.loadImg.defaults, options); |
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 formatFileSize(bytes) { | |
var val = bytes / 1024, | |
suffix; | |
if (val < 1000) { | |
suffix = 'KB'; | |
} else { | |
val = val / 1024; | |
if (val < 1000) { | |
suffix = 'MB'; | |
} 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
function formatPrice(val, fixedDecimals, currencyCode) { | |
var absVal = Math.abs(val), | |
parts = absVal.toString().split('.'), | |
res; | |
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ","); | |
if (fixedDecimals) { | |
parts[1] = absVal.toFixed(fixedDecimals).split('.')[1]; | |
} | |
res = parts.join("."); | |
return (val < 0 ? '-' : '') + (currencyCode || '') + res; |
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 roundNumber(val, maxDecimals) { | |
return (Math.round(val * Math.pow(10, maxDecimals))) / Math.pow(10, maxDecimals); | |
} |
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.loadSvg = function (options) { | |
var opts = $.extend({}, $.fn.loadSvg.defaults, options); | |
return this.each(function () { | |
var $stage = $(this); | |
$stage.load($stage.data('src'), function (response) { | |
$stage.addClass(opts.loadedCls); |
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.linkOut = function (options) { | |
return this.each(function () { | |
$(this).on('mouseenter', options.mouseEnterToSelector, function () { | |
var $el = $(this), | |
$target = $el.find(options.targetAppendSelector); | |
if ($target.length) { | |
var $linkout = $('<a />', {class: 'linkout sprite', rel: 'nofollow', css: {opacity: 0}, href: $target.data('href')}).appendTo($target); |
NewerOlder