UNPKG

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