UNPKG

1.04 kBJavaScriptView Raw
1/*eslint-env browser, node*/
2
3'use strict';
4
5// Node.js built-ins
6
7var path = require('path');
8
9// our modules
10
11var FetcherIndex = require(path.join(__dirname, 'fetcher-index'));
12
13// this module
14
15var appCacheIndex = process.browser ? window.appCacheIndex : {};
16
17var fetcherIndex = new FetcherIndex({ index: appCacheIndex });
18
19var isAMD = typeof window.define === 'function' && typeof window.define.amd !== 'undefined';
20
21var isRequireJS = isAMD && typeof window.require === 'function' && typeof window.require.load === 'function';
22
23(function () {
24 var oldLoad;
25
26 if (isRequireJS) {
27 oldLoad = window.require.load;
28
29 window.require.load = function (context, moduleId, moduleUrl) {
30 var localUrl = fetcherIndex.resolveLocalUrl(moduleUrl);
31 oldLoad.call(window.require, context, moduleId, localUrl);
32 };
33 }
34}());
35
36(function (fn) {
37 if (isAMD) {
38 window.require(['jquery'], fn);
39 } else {
40 fn(window.$);
41 }
42}(function ($) {
43
44 require(path.join(__dirname, 'shims', 'jquery.ajax'))(fetcherIndex, $, 'ajax');
45
46}));