Skip to content

Commit

Permalink
issue/1821: restore loadJQuery & checkJQueryStatus
Browse files Browse the repository at this point in the history
  • Loading branch information
moloko authored and oliverfoster committed Oct 2, 2017
1 parent 20b3dd5 commit 468606d
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions src/core/js/scriptLoader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
(function() {

//2. Setup require for old style module declarations
//2. Setup require for old-style module declarations (some code still uses these), configure paths then load JQuery
function setupRequireJS() {
requirejs.config({
map: {
Expand All @@ -27,13 +27,31 @@
jqueryMobile: 'libraries/jquery.mobile.custom'
}
});
loadFoundationLibraries();
loadJQuery();
}

// 3. start loading JQuery, wait for it to be loaded
function loadJQuery() {
Modernizr.load([
{
load: 'libraries/jquery.v2.min.js',
complete: checkJQueryStatus
}
]);
}

//4. Wait until JQuery gets loaded completely then load foundation libraries
function checkJQueryStatus() {
if(window.jQuery === undefined) {
setTimeout(checkJQueryStatus, 100);
} else {
loadFoundationLibraries();
}
}

//3. Load foundation libraries and templates
//5. Load foundation libraries and templates then load Adapt itself
function loadFoundationLibraries() {
require([
'jquery',
'underscore',
'backbone',
'backbone.controller',
Expand All @@ -50,15 +68,15 @@
], loadAdapt);
}

//4. Load adapt
//6. Allow cross-domain AJAX then load Adapt
function loadAdapt() {
$.ajaxPrefilter(function( options ) {
options.crossDomain = true;
});
Modernizr.load('adapt/js/adapt.min.js');
}

//1. Load foundation libraries, requirejs
//1. Load requirejs then set it up
Modernizr.load([
{
load: 'libraries/require.min.js',
Expand Down

0 comments on commit 468606d

Please sign in to comment.