This file contains hidden or 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
| define(["jquery/1.5.1/jquery"], function($) { | |
| // | |
| // This function executes a list of promise returning functions all given the same args | |
| // If you specify a scope, the list may contain string names instead of function references. | |
| // It returns a Promise | |
| // | |
| var executeDeferredStack = $.executeDeferredStack = function(functionStack, args, scope) { | |
| var dfd = $.Deferred(); | |
| var lastFunc = function() { | |
| dfd.resolve(arguments); |
This file contains hidden or 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
| define(["jquery"], | |
| function($) { | |
| var addTimeout = $.addTimeoutToDeferred = function(promise, timeout) { | |
| if (promise.isResolved() || promise.isRejected()) | |
| return promise; | |
| var withTimeout = $.Deferred(); | |
| promise.then(function(){withTimeout.resolve(arguments);}, function(){withTimeout.reject(arguments);}); | |
| setTimeout(function() {withTimeout.reject();}, maxWait); | |
| return withTimeout.promise(); | |
| } |
This file contains hidden or 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
| define(["jquery", "jquery.addTimeoutToDeferred"], | |
| function($, addTimeoutToDeferred) { | |
| var cache = $.cache = Class.extend({ | |
| cache: {}, | |
| ready: {}, | |
| init: function(args) { | |
| this.getput = this.putget; | |
| }, | |
| contains: function(key) { | |
| return this.ready[key] !== undefined; |
This file contains hidden or 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
| define(["jquery", "jquery.jqote2", "jquery.deferredPipeline", "jquery.cache"], | |
| function($, jqote2, deferredPipeline, cache) { | |
| // | |
| // This is a wrapper around the jqote2 template library. | |
| // | |
| // The function to notice is: | |
| // applyTemplate(data/{}, target/DOMNode, keepPreviousTemplate/boolean) | |
| // | |
| var templateCache = null; | |
| $.template = Class.extend({ |
This file contains hidden or 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
| define(["jquery/1.5.1/jquery", "Class", "jquery.store", "jquery.executeDeferredStack", "jquery.templater"], | |
| function($, Class, Store, executeDeferredStack, Templater) { | |
| //TODO: somehow let widget state be exposed without depending on widget internals | |
| // | |
| // This is a widget state implementation. | |
| // | |
| // args: | |
| // Recommended: | |
| // templateName/String - should map to a widget.templates[templateName] | |
| // actions/{} - map of action String to either a String or function()->String. |
This file contains hidden or 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 exampleFunction = function(a, b, c) { | |
| $(a).append("<p>" + b + "->" + c + "</p>"); | |
| }; | |
| exampleFunction("#a", "example", 1); | |
| // | |
| // This function goes through each entry in the array values | |
| // and if it is an array, Calls func once per value in the array. | |
| // | |
| // The real use of this function is to easily allow functions that normally take | |
| // single values to be expanded without any real work. See Ruleset.addValidator |
This file contains hidden or 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
| <!doctype html> | |
| <html> | |
| <head> | |
| <title>onbeforeunload ajax test</title> | |
| <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> | |
| <script> | |
| $(function() { | |
| window.onbeforeunload = function() { | |
| console.log("saving"); | |
| $.ajax("saved", {async:false}); |
This file contains hidden or 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
| //Work around to force refresh of #pains in chrome | |
| var pains = $("#pains"); | |
| console.log($("#pains").css("-webkit-transform")); | |
| if ($("#pains").css("-webkit-transform") == "translateZ(1px)") { | |
| $("#pains").css("-webkit-transform","none"); | |
| } | |
| else { | |
| $("#pains").css("-webkit-transform",'translateZ(1px)'); | |
| } |
This file contains hidden or 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
| # reflexive layout based on em's | |
| (($el, scale) -> | |
| win = $(window) | |
| # simplified version of fittext.js | |
| resize = -> | |
| $el.css 'font-size', win.width()/scale | |
| resize() | |
| win.on 'resize', resize | |
| ) $("body"), 80.0 |