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
/* | |
Copyright 2014 Paul Bjorkstrand | |
Licensed under the Apache License, Version 2.0 (the "License"); | |
you may not use this file except in compliance with the License. | |
You may obtain a copy of the License at | |
http://www.apache.org/licenses/LICENSE-2.0 | |
Unless required by applicable law or agreed to in writing, software |
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($) { | |
"use strict"; | |
var readys = {}; | |
function newReady(name) { | |
Object.defineProperty( | |
$, | |
name, { | |
enumerable: false, | |
configurable: 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
/* | |
* Requires a minimal change to the $.ajax calls, adding: | |
* globalAjax: true | |
* globalAjax: { | |
* name: "" // optional | |
* usePostData: true // optional | |
* } | |
* As long as the globalAjax object is "truthy", it will store the response, | |
* at bare minimum using options.type + "|" + options.url as the key | |
*/ |
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.prototype.promisify | |
(function() { | |
"use strict"; | |
if (Function.prototype.promisify) { | |
console.error("Function.prototype.promisify() already exists"); | |
return; | |
} | |
var promiseFactory = function(context, f) { |
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() { | |
if (!Function.prototype.callFn) { | |
Function.prototype.callFn = function(scope/*, args */) { | |
var args = Array.prototype.slice.call(arguments, 1); | |
return this.applyFn(scope, args); | |
}; | |
} | |
if (!Function.prototype.applyFn) { | |
Function.prototype.applyFn = function(scope, 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($) { | |
$.fn.showWhile = function(fn) { | |
var obj = this.show(); | |
var result = fn(); | |
if (typeof result.then !== "function") { | |
result = $.Deferred.resolve(fn).promise(); | |
} | |
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($, window) { | |
var $w = $(window); | |
$.fn.center = function() { | |
this.css({ | |
position: "absolute", | |
left: Math.max(0, ($w.width() - this.outerWidth()) / 2 + $(window).scrollTop()) + "px", | |
top: Math.max(0, ($w.height() - this.outerHeight()) / 2 + $(window).scrollTop()) + "px" | |
}); | |
}; |
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
if (!Math.minMax) { | |
Math.minMax = function(min, max, val) { | |
return Math.max(min, Math.min(max, val)); | |
}; | |
} |
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($) { | |
$.expr[":"].parents = $.expr.createPseudo(function(arg) { | |
return function( elem ) { | |
return $(elem).parents(arg).length > 0; | |
}; | |
}); | |
})(jQuery); |
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
window.addEventListener('storage', function(e) { | |
if (e.storageArea === localStorage) { | |
var key = e.key; | |
if (data) { | |
$(document).trigger('storage.' + e.key, data); | |
} | |
} | |
}); | |
$(document).on("storage.test", function(e, data) { |
OlderNewer