- https://github.com/coolaj86/futures (been around a while)
- https://github.com/heavylifters/deferred-js
- https://github.com/wookiehangover/underscore.Deferred
- https://github.com/warpdesign/Standalone-Deferred (implementation of jQuery's Deferred API in a standalone form, doesn't include tests but seems to work)
- https://github.com/unscriptable/promises (not compat with CJS Promises/A)
- https://github.com/briancavalier/when.js
- *jQuery of course also includes an implementation of Deferreds.
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
/*! | |
* RequireJS plugin for async dependency load like JSONP and Google Maps | |
* @author Miller Medeiros | |
* @version 0.0.1 (2011/03/23) | |
* Released under the MIT License <http://www.opensource.org/licenses/mit-license.php> | |
*/ | |
define(function(){ | |
function injectScript(src){ | |
var s, t; |
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
$.xhrPool = []; | |
$.xhrPool.abortAll = function() { | |
/* Original example used _underscore api | |
_.each(this, function(jqXHR) { | |
jqXHR.abort(); | |
}); | |
*/ | |
$.each(this, function(jqXHR) { | |
jqXHR.abort(); |
-
pagebeforechange
This event is triggered prior to any page loading or transition -
pagebeforeload
Triggered before any load request is made -
pagebeforecreate
Triggered on the page being initialized, before most plugin auto-initialization occurs -
pageload
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
define(function() { | |
return function Person(fullname) { | |
this.name = fullname; | |
} | |
}); |
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
// google! plugin: | |
var google; // will become defined by googleMain below | |
define({ | |
load: function (resourceId, req, loaded, config) { | |
var googleMain = 'http://www.google.com/jsapi?key=' + config.apikey + 'callback=define', | |
args = resourceId.split('/'); | |
// args = ['module-name', 'version', callbackFunc]; | |
args.push(function () { loaded(google[args[0]]); }); | |
// once main google library is available, get module | |
req([googleMain], function () { |
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
Element = function(){}; |
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
// Taken from: | |
// http://requirejs.org/docs/api.html#jsonp | |
// http://api.twitter.com/1/trends/available.json (seems to return data but is an Array not Object) | |
require(["http://search.twitter.com/trends/current.json?callback=define"], function (trends) { | |
console.log('trends: ', trends); | |
}); | |
// Separate attempt | |
require(['http://twitter.com/statuses/user_timeline/Integralist.json?callback=define'], function(feed) { | |
console.log('feed: ', feed); |
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
<?php | |
header('Content-Type: text/javascript; charset=utf8'); | |
header('Access-Control-Allow-Origin: *'); | |
header('Access-Control-Max-Age: 3628800'); | |
header('Access-Control-Allow-Methods: GET, POST, PUT, DELETE'); | |
// Callback function | |
$callback = $_GET['callback']; | |
// JSON data |
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
/* | |
* Scaffolding | |
* Basic and global styles for generating a grid system, structural layout, and page templates | |
* ------------------------------------------------------------------------------------------- */ | |
.container | |
Sets a width of 940px which also centres the content (clears floated elements before/after) | |
.container-fluid | |
Sets a minimum width of 940px (clears floated elements before/after) |