Skip to content

Instantly share code, notes, and snippets.

(function ($) {
$.fn.stickyHeader = function (options) {
var $window = $(window);
var settings = $.extend({}, $.fn.stickyHeader.defaults, options);
return $(this).each(function () {
var $table = $(this),
(function ($) {
var idx = 0;
$.fn.dotsLoader = function (cmd, options) {
var api = {
toggle: function () {
api[this.data('loader-id') ? 'hide' : 'show'].apply(this, arguments);
},
(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);
(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);
function roundNumber(val, maxDecimals) {
return (Math.round(val * Math.pow(10, maxDecimals))) / Math.pow(10, maxDecimals);
}
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;
function formatFileSize(bytes) {
var val = bytes / 1024,
suffix;
if (val < 1000) {
suffix = 'KB';
} else {
val = val / 1024;
if (val < 1000) {
suffix = 'MB';
} else {
"use strict";
define([
'jquery',
'underscore'
], function ($, _) {
$.fn.loadImg = function (options) {
// var opts = $.extend({}, $.fn.loadImg.defaults, options);
@ewebdev
ewebdev / RecursiveObjectPathResolver.js
Created December 24, 2014 16:05
Returns the value in within a requested path in a nested object (tree traversal), without using "eval" / "new Function".
/**
* 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('.'));
}
(function(){
var globals = [],
pageProps = {},
nativeProps = {},
v;
for (v in window) {
pageProps[v] = 1;
}
var ifrm = document.createElement("IFRAME");
document.body.appendChild(ifrm);