postal.js/example/amd/js/libs/require/require.js

621 lines
19 KiB
JavaScript

/*
RequireJS 1.0.2 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
Available via the MIT or new BSD license.
see: http://github.com/jrburke/requirejs for details
*/
var requirejs, require, define;
(function () {
function J( a ) {
return M.call( a ) === "[object Function]"
}
function E( a ) {
return M.call( a ) === "[object Array]"
}
function Z( a, c, h ) {
for ( var k in c ) {
if ( !(k in K) && (!(k in a) || h) ) {
a[k] = c[k];
}
}
return d
}
function N( a, c, d ) {
a = Error( c + "\nhttp://requirejs.org/docs/errors.html#" + a );
if ( d ) {
a.originalError = d;
}
return a
}
function $( a, c, d ) {
var k, j, q;
for ( k = 0; q = c[k]; k++ ) {
q = typeof q === "string" ? {name : q} : q;
j = q.location;
if ( d && (!j || j.indexOf( "/" ) !== 0 && j.indexOf( ":" ) === -1) ) {
j = d + "/" + (j || q.name);
}
a[q.name] = {name : q.name, location : j ||
q.name, main : (q.main || "main").replace( ea, "" ).replace( aa, "" )}
}
}
function V( a, c ) {
a.holdReady ? a.holdReady( c ) : c ? a.readyWait += 1 : a.ready( !0 )
}
function fa( a ) {
function c( b, l ) {
var f, a;
if ( b && b.charAt( 0 ) === "." ) {
if ( l ) {
p.pkgs[l] ? l = [l] : (l = l.split( "/" ), l = l.slice( 0, l.length - 1 ));
f = b = l.concat( b.split( "/" ) );
var c;
for ( a = 0; c = f[a]; a++ ) {
if ( c === "." ) {
f.splice( a, 1 ), a -= 1;
} else if ( c === ".." ) {
if ( a === 1 && (f[2] === ".." || f[0] === "..") ) {
break;
} else {
a > 0 && (f.splice( a - 1, 2 ), a -= 2);
}
}
}
a = p.pkgs[f = b[0]];
b = b.join( "/" );
a && b === f + "/" + a.main && (b = f)
} else {
b.indexOf( "./" ) ===
0 && (b = b.substring( 2 ));
}
}
return b
}
function h( b, l ) {
var f = b ? b.indexOf( "!" ) : -1, a = null, d = l ? l.name : null, i = b, e, h;
f !== -1 && (a = b.substring( 0, f ), b = b.substring( f + 1, b.length ));
a && (a = c( a, d ));
b && (a ? e = (f = m[a]) && f.normalize ? f.normalize( b, function ( b ) {
return c( b, d )
} ) : c( b, d ) : (e = c( b, d ), h = E[e], h || (h = g.nameToUrl( e, null, l ), E[e] = h)));
return{prefix : a, name : e, parentMap : l, url : h, originalName : i, fullName : a ? a + "!" + (e || "") : e}
}
function k() {
var b = !0, l = p.priorityWait, f, a;
if ( l ) {
for ( a = 0; f = l[a]; a++ ) {
if ( !s[f] ) {
b = !1;
break
}
}
b && delete p.priorityWait
}
return b
}
function j( b, l, f ) {
return function () {
var a = ga.call( arguments, 0 ), c;
if ( f && J( c = a[a.length - 1] ) ) {
c.__requireJsBuild = !0;
}
a.push( l );
return b.apply( null, a )
}
}
function q( b, l ) {
var a = j( g.require, b, l );
Z( a, {nameToUrl : j( g.nameToUrl, b ), toUrl : j( g.toUrl, b ), defined : j( g.requireDefined, b ), specified : j( g.requireSpecified, b ), isBrowser : d.isBrowser} );
return a
}
function o( b ) {
var l, a, c, C = b.callback, i = b.map, e = i.fullName, ba = b.deps;
c = b.listeners;
if ( C && J( C ) ) {
if ( p.catchError.define ) {
try {
a = d.execCb( e, b.callback, ba, m[e] )
} catch ( k ) {
l = k
}
} else {
a =
d.execCb( e, b.callback, ba, m[e] );
}
if ( e ) {
(C = b.cjsModule) && C.exports !== void 0 && C.exports !== m[e] ? a = m[e] = b.cjsModule.exports : a === void 0 && b.usingExports ? a = m[e] : (m[e] = a, F[e] && (Q[e] = !0))
}
} else {
e && (a = m[e] = C, F[e] && (Q[e] = !0));
}
if ( D[b.id] ) {
delete D[b.id], b.isDone = !0, g.waitCount -= 1, g.waitCount === 0 && (I = []);
}
delete R[e];
if ( d.onResourceLoad && !b.placeholder ) {
d.onResourceLoad( g, i, b.depArray );
}
if ( l ) {
return a = (e ? h( e ).url : "") || l.fileName || l.sourceURL, c = l.moduleTree, l = N( "defineerror", 'Error evaluating module "' + e + '" at location "' +
a + '":\n' + l + "\nfileName:" + a + "\nlineNumber: " + (l.lineNumber || l.line), l ), l.moduleName = e, l.moduleTree = c, d.onError( l );
}
for ( l = 0; C = c[l]; l++ ) {
C( a )
}
}
function r( b, a ) {
return function ( f ) {
b.depDone[a] || (b.depDone[a] = !0, b.deps[a] = f, b.depCount -= 1, b.depCount || o( b ))
}
}
function u( b, a ) {
var f = a.map, c = f.fullName, h = f.name, i = L[b] || (L[b] = m[b]), e;
if ( !a.loading ) {
a.loading = !0, e = function ( b ) {
a.callback = function () {
return b
};
o( a );
s[a.id] = !0;
w()
}, e.fromText = function ( b, a ) {
var l = O;
s[b] = !1;
g.scriptCount += 1;
g.fake[b] = !0;
l && (O = !1);
d.exec( a );
l && (O = !0);
g.completeLoad( b )
}, c in m ? e( m[c] ) : i.load( h, q( f.parentMap, !0 ), e, p )
}
}
function v( b ) {
D[b.id] || (D[b.id] = b, I.push( b ), g.waitCount += 1)
}
function B( b ) {
this.listeners.push( b )
}
function t( b, a ) {
var f = b.fullName, c = b.prefix, d = c ? L[c] || (L[c] = m[c]) : null, i, e;
f && (i = R[f]);
if ( !i && (e = !0, i = {id : (c && !d ? M++ + "__p@:" : "") + (f || "__r@" + M++), map : b, depCount : 0, depDone : [], depCallbacks : [], deps : [], listeners : [], add : B}, y[i.id] = !0, f && (!c || L[c])) ) {
R[f] = i;
}
c && !d ? (f = t( h( c ), !0 ), f.add( function () {
var a = h( b.originalName, b.parentMap ), a = t( a,
!0 );
i.placeholder = !0;
a.add( function ( b ) {
i.callback = function () {
return b
};
o( i )
} )
} )) : e && a && (s[i.id] = !1, g.paused.push( i ), v( i ));
return i
}
function x( b, a, f, c ) {
var b = h( b, c ), d = b.name, i = b.fullName, e = t( b ), k = e.id, j = e.deps, n;
if ( i ) {
if ( i in m || s[k] === !0 || i === "jquery" && p.jQuery && p.jQuery !== f().fn.jquery ) {
return;
}
y[k] = !0;
s[k] = !0;
i === "jquery" && f && S( f() )
}
e.depArray = a;
e.callback = f;
for ( f = 0; f < a.length; f++ ) {
if ( k = a[f] ) {
k = h( k, d ? b : c ), n = k.fullName, a[f] = n, n === "require" ? j[f] = q( b ) : n === "exports" ? (j[f] = m[i] = {}, e.usingExports = !0) : n ===
"module" ? e.cjsModule = j[f] = {id : d, uri : d ? g.nameToUrl( d, null, c ) : void 0, exports : m[i]} : n in m && !(n in D) && (!(i in F) || i in F && Q[n]) ? j[f] = m[n] : (i in F && (F[n] = !0, delete m[n], T[k.url] = !1), e.depCount += 1, e.depCallbacks[f] = r( e, f ), t( k, !0 ).add( e.depCallbacks[f] ));
}
}
e.depCount ? v( e ) : o( e )
}
function n( b ) {
x.apply( null, b )
}
function z( b, a ) {
if ( !b.isDone ) {
var c = b.map.fullName, d = b.depArray, g, i, e, k;
if ( c ) {
if ( a[c] ) {
return m[c];
}
a[c] = !0
}
if ( d ) {
for ( g = 0; g < d.length; g++ ) {
if ( i = d[g] ) {
if ( (e = h( i ).prefix) && (k = D[e]) && z( k, a ), (e = D[i]) && !e.isDone &&
s[i] ) {
i = z( e, a ), b.depCallbacks[g]( i );
}
}
}
}
return c ? m[c] : void 0
}
}
function A() {
var b = p.waitSeconds * 1E3, a = b && g.startTime + b < (new Date).getTime(), b = "", c = !1, h = !1, j;
if ( !(g.pausedCount > 0) ) {
if ( p.priorityWait ) {
if ( k() ) {
w();
} else {
return;
}
}
for ( j in s ) {
if ( !(j in K) && (c = !0, !s[j]) ) {
if ( a ) {
b += j + " ";
} else {
h = !0;
break
}
}
}
if ( c || g.waitCount ) {
if ( a && b ) {
return j = N( "timeout", "Load timeout for modules: " + b ), j.requireType = "timeout", j.requireModules = b, d.onError( j );
}
if ( h || g.scriptCount ) {
if ( (G || ca) && !W ) {
W = setTimeout( function () {
W = 0;
A()
}, 50 )
}
} else {
if ( g.waitCount ) {
for ( H =
0; b = I[H]; H++ ) {
z( b, {} );
}
g.paused.length && w();
X < 5 && (X += 1, A())
}
X = 0;
d.checkReadyState()
}
}
}
}
var g, w, p = {waitSeconds : 7, baseUrl : "./", paths : {}, pkgs : {}, catchError : {}}, P = [], y = {require : !0, exports : !0, module : !0}, E = {}, m = {}, s = {}, D = {}, I = [], T = {}, M = 0, R = {}, L = {}, F = {}, Q = {}, Y = 0;
S = function ( b ) {
if ( !g.jQuery && (b = b || (typeof jQuery !== "undefined" ? jQuery : null)) && !(p.jQuery && b.fn.jquery !== p.jQuery) && ("holdReady"in b || "readyWait"in b) ) {
if ( g.jQuery = b, n( ["jquery", [], function () {
return jQuery
}] ), g.scriptCount ) {
V( b, !0 ), g.jQueryIncremented =
!0
}
}
};
w = function () {
var b, a, c, h, j, i;
Y += 1;
if ( g.scriptCount <= 0 ) {
g.scriptCount = 0;
}
for ( ; P.length; ) {
if ( b = P.shift(), b[0] === null ) {
return d.onError( N( "mismatch", "Mismatched anonymous define() module: " + b[b.length - 1] ) );
} else {
n( b );
}
}
if ( !p.priorityWait || k() ) {
for ( ; g.paused.length; ) {
j = g.paused;
g.pausedCount += j.length;
g.paused = [];
for ( h = 0; b = j[h]; h++ ) {
a = b.map, c = a.url, i = a.fullName, a.prefix ? u( a.prefix, b ) : !T[c] && !s[i] && (d.load( g, i, c ), c.indexOf( "empty:" ) !== 0 && (T[c] = !0));
}
g.startTime = (new Date).getTime();
g.pausedCount -= j.length
}
}
Y ===
1 && A();
Y -= 1
};
g = {contextName : a, config : p, defQueue : P, waiting : D, waitCount : 0, specified : y, loaded : s, urlMap : E, urlFetched : T, scriptCount : 0, defined : m, paused : [], pausedCount : 0, plugins : L, needFullExec : F, fake : {}, fullExec : Q, managerCallbacks : R, makeModuleMap : h, normalize : c, configure : function ( b ) {
var a, c, d;
b.baseUrl && b.baseUrl.charAt( b.baseUrl.length - 1 ) !== "/" && (b.baseUrl += "/");
a = p.paths;
d = p.pkgs;
Z( p, b, !0 );
if ( b.paths ) {
for ( c in b.paths ) {
c in K || (a[c] = b.paths[c]);
}
p.paths = a
}
if ( (a = b.packagePaths) || b.packages ) {
if ( a ) {
for ( c in a ) {
c in
K || $( d, a[c], c );
}
}
b.packages && $( d, b.packages );
p.pkgs = d
}
if ( b.priority ) {
c = g.requireWait, g.requireWait = !1, g.takeGlobalQueue(), w(), g.require( b.priority ), w(), g.requireWait = c, p.priorityWait = b.priority;
}
if ( b.deps || b.callback ) {
g.require( b.deps || [], b.callback )
}
}, requireDefined : function ( b, a ) {
return h( b, a ).fullName in m
}, requireSpecified : function ( b, a ) {
return h( b, a ).fullName in y
}, require : function ( b, c, f ) {
if ( typeof b === "string" ) {
if ( J( c ) ) {
return d.onError( N( "requireargs", "Invalid require call" ) );
}
if ( d.get ) {
return d.get( g,
b, c );
}
c = h( b, c );
b = c.fullName;
return!(b in m) ? d.onError( N( "notloaded", "Module name '" + c.fullName + "' has not been loaded yet for context: " + a ) ) : m[b]
}
(b && b.length || c) && x( null, b, c, f );
if ( !g.requireWait ) {
for ( ; !g.scriptCount && g.paused.length; ) {
g.takeGlobalQueue(), w();
}
}
return g.require
}, takeGlobalQueue : function () {
U.length && (ha.apply( g.defQueue, [g.defQueue.length - 1, 0].concat( U ) ), U = [])
}, completeLoad : function ( b ) {
var a;
for ( g.takeGlobalQueue(); P.length; ) {
if ( a = P.shift(), a[0] === null ) {
a[0] = b;
break
} else if ( a[0] === b ) {
break;
}
else {
n( a ), a = null;
}
}
a ? n( a ) : n( [b, [], b === "jquery" && typeof jQuery !== "undefined" ? function () {
return jQuery
} : null] );
S();
d.isAsync && (g.scriptCount -= 1);
w();
d.isAsync || (g.scriptCount -= 1)
}, toUrl : function ( a, c ) {
var d = a.lastIndexOf( "." ), h = null;
d !== -1 && (h = a.substring( d, a.length ), a = a.substring( 0, d ));
return g.nameToUrl( a, h, c )
}, nameToUrl : function ( a, h, f ) {
var j, k, i, e, m = g.config, a = c( a, f && f.fullName );
if ( d.jsExtRegExp.test( a ) ) {
h = a + (h ? h : "");
} else {
j = m.paths;
k = m.pkgs;
f = a.split( "/" );
for ( e = f.length; e > 0; e-- ) {
if ( i = f.slice( 0, e ).join( "/" ),
j[i] ) {
f.splice( 0, e, j[i] );
break
} else if ( i = k[i] ) {
a = a === i.name ? i.location + "/" + i.main : i.location;
f.splice( 0, e, a );
break
}
}
h = f.join( "/" ) + (h || ".js");
h = (h.charAt( 0 ) === "/" || h.match( /^\w+:/ ) ? "" : m.baseUrl) + h
}
return m.urlArgs ? h + ((h.indexOf( "?" ) === -1 ? "?" : "&") + m.urlArgs) : h
}};
g.jQueryCheck = S;
g.resume = w;
return g
}
function ia() {
var a, c, d;
if ( n && n.readyState === "interactive" ) {
return n;
}
a = document.getElementsByTagName( "script" );
for ( c = a.length - 1; c > -1 && (d = a[c]); c-- ) {
if ( d.readyState === "interactive" ) {
return n = d;
}
}
return null
}
var ja =
/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg, ka = /require\(\s*["']([^'"\s]+)["']\s*\)/g, ea = /^\.\//, aa = /\.js$/, M = Object.prototype.toString, r = Array.prototype, ga = r.slice, ha = r.splice, G = !!(typeof window !== "undefined" && navigator && document), ca = !G && typeof importScripts !== "undefined", la = G && navigator.platform === "PLAYSTATION 3" ? /^complete$/ : /^(complete|loaded)$/, da = typeof opera !== "undefined" && opera.toString() === "[object Opera]", K = {}, t = {}, U = [], n = null, X = 0, O = !1, d, r = {}, I, v, x, y, u, z, A, H, B, S, W;
if ( typeof define === "undefined" ) {
if ( typeof requirejs !==
"undefined" ) {
if ( J( requirejs ) ) {
return;
} else {
r = requirejs, requirejs = void 0;
}
}
typeof require !== "undefined" && !J( require ) && (r = require, require = void 0);
d = requirejs = function ( a, c, d ) {
var k = "_", j;
!E( a ) && typeof a !== "string" && (j = a, E( c ) ? (a = c, c = d) : a = []);
if ( j && j.context ) {
k = j.context;
}
d = t[k] || (t[k] = fa( k ));
j && d.configure( j );
return d.require( a, c )
};
d.config = function ( a ) {
return d( a )
};
require || (require = d);
d.toUrl = function ( a ) {
return t._.toUrl( a )
};
d.version = "1.0.2";
d.jsExtRegExp = /^\/|:|\?|\.js$/;
v = d.s = {contexts : t, skipAsync : {}};
if ( d.isAsync =
d.isBrowser = G ) {
if ( x = v.head = document.getElementsByTagName( "head" )[0], y = document.getElementsByTagName( "base" )[0] ) {
x = v.head = y.parentNode;
}
}
d.onError = function ( a ) {
throw a;
};
d.load = function ( a, c, h ) {
d.resourcesReady( !1 );
a.scriptCount += 1;
d.attach( h, a, c );
if ( a.jQuery && !a.jQueryIncremented ) {
V( a.jQuery, !0 ), a.jQueryIncremented = !0
}
};
define = function ( a, c, d ) {
var k, j;
typeof a !== "string" && (d = c, c = a, a = null);
E( c ) || (d = c, c = []);
!c.length && J( d ) && d.length && (d.toString().replace( ja, "" ).replace( ka, function ( a, d ) {
c.push( d )
} ), c = (d.length ===
1 ? ["require"] : ["require", "exports", "module"]).concat( c ));
if ( O && (k = I || ia()) ) {
a || (a = k.getAttribute( "data-requiremodule" )), j = t[k.getAttribute( "data-requirecontext" )];
}
(j ? j.defQueue : U).push( [a, c, d] )
};
define.amd = {multiversion : !0, plugins : !0, jQuery : !0};
d.exec = function ( a ) {
return eval( a )
};
d.execCb = function ( a, c, d, k ) {
return c.apply( k, d )
};
d.addScriptToDom = function ( a ) {
I = a;
y ? x.insertBefore( a, y ) : x.appendChild( a );
I = null
};
d.onScriptLoad = function ( a ) {
var c = a.currentTarget || a.srcElement, h;
if ( a.type === "load" || c && la.test( c.readyState ) ) {
n =
null, a = c.getAttribute( "data-requirecontext" ), h = c.getAttribute( "data-requiremodule" ), t[a].completeLoad( h ), c.detachEvent && !da ? c.detachEvent( "onreadystatechange", d.onScriptLoad ) : c.removeEventListener( "load", d.onScriptLoad, !1 )
}
};
d.attach = function ( a, c, h, k, j, n ) {
var o;
if ( G ) {
return k = k || d.onScriptLoad, o = c && c.config && c.config.xhtml ? document.createElementNS( "http://www.w3.org/1999/xhtml", "html:script" ) : document.createElement( "script" ), o.type = j || "text/javascript", o.charset = "utf-8", o.async = !v.skipAsync[a], c && o.setAttribute( "data-requirecontext",
c.contextName ), o.setAttribute( "data-requiremodule", h ), o.attachEvent && !da ? (O = !0, n ? o.onreadystatechange = function () {
if ( o.readyState === "loaded" ) {
o.onreadystatechange = null, o.attachEvent( "onreadystatechange", k ), n( o )
}
} : o.attachEvent( "onreadystatechange", k )) : o.addEventListener( "load", k, !1 ), o.src = a, n || d.addScriptToDom( o ), o;
} else {
ca && (importScripts( a ), c.completeLoad( h ));
}
return null
};
if ( G ) {
u = document.getElementsByTagName( "script" );
for ( H = u.length - 1; H > -1 && (z = u[H]); H-- ) {
if ( !x ) {
x = z.parentNode;
}
if ( A = z.getAttribute( "data-main" ) ) {
if ( !r.baseUrl ) {
u =
A.split( "/" ), z = u.pop(), u = u.length ? u.join( "/" ) + "/" : "./", r.baseUrl = u, A = z.replace( aa, "" );
}
r.deps = r.deps ? r.deps.concat( A ) : [A];
break
}
}
}
d.checkReadyState = function () {
var a = v.contexts, c;
for ( c in a ) {
if ( !(c in K) && a[c].waitCount ) {
return;
}
}
d.resourcesReady( !0 )
};
d.resourcesReady = function ( a ) {
var c, h;
d.resourcesDone = a;
if ( d.resourcesDone ) {
for ( h in a = v.contexts, a ) {
if ( !(h in K) && (c = a[h], c.jQueryIncremented) ) {
V( c.jQuery, !1 ), c.jQueryIncremented = !1
}
}
}
};
d.pageLoaded = function () {
if ( document.readyState !== "complete" ) {
document.readyState =
"complete"
}
};
if ( G && document.addEventListener && !document.readyState ) {
document.readyState = "loading", window.addEventListener( "load", d.pageLoaded, !1 );
}
d( r );
if ( d.isAsync && typeof setTimeout !== "undefined" ) {
B = v.contexts[r.context || "_"], B.requireWait = !0, setTimeout( function () {
B.requireWait = !1;
B.takeGlobalQueue();
B.jQueryCheck();
B.scriptCount || B.resume();
d.checkReadyState()
}, 0 )
}
}
})();