Skip to content

Instantly share code, notes, and snippets.

View Integralist's full-sized avatar
🎯
Making an impact

Mark McDonnell Integralist

🎯
Making an impact
View GitHub Profile
@Integralist
Integralist / deferredImplems.md
Created October 25, 2011 19:44 — forked from addyosmani/deferredImplems.md
Deferred implementations
@Integralist
Integralist / gist:1316940
Created October 26, 2011 16:42 — forked from millermedeiros/gist:882682
RequireJS Async Load Plugin
/*!
* 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;
@Integralist
Integralist / cancelAJAX.js
Created November 3, 2011 11:17
Try to cancel all jQuery AJAX requests currently running
$.xhrPool = [];
$.xhrPool.abortAll = function() {
/* Original example used _underscore api
_.each(this, function(jqXHR) {
jqXHR.abort();
});
*/
$.each(this, function(jqXHR) {
jqXHR.abort();
@Integralist
Integralist / jQueryMobileEvents.md
Created November 3, 2011 11:53
The list of events that are triggered in a jQuery Mobile application (in the relevant order)
  • 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

@Integralist
Integralist / Person.js
Created November 11, 2011 09:24
Curl Example
define(function() {
return function Person(fullname) {
this.name = fullname;
}
});
@Integralist
Integralist / Curl Google Plugin
Created November 14, 2011 13:19
Curl Google Plugin Example
// 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 () {
@Integralist
Integralist / IE7.js
Created November 14, 2011 13:36
Attempt at polyfilling addEventListener in IE7 via .htc hack
Element = function(){};
@Integralist
Integralist / require.js
Created November 16, 2011 14:07
Examples of jsonp loading via RequireJs
// 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);
@Integralist
Integralist / JSON-P.php
Created November 16, 2011 17:25
JSONP Async Loading via RequireJs
<?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
@Integralist
Integralist / bootstrap.css
Created November 24, 2011 14:16
List of Twitter Bootstrap CSS classes
/*
* 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)