Replace $LAB with path aware loadScript that uses jQuery

This commit is contained in:
Robin Ward
2015-03-09 12:49:11 -04:00
parent fb726cfa0c
commit de4e4f2b98
17 changed files with 110 additions and 141 deletions

View File

@ -1,5 +1,17 @@
/* global assetPath */
const _loaded = {};
export default function loadScript(url) {
return new Ember.RSVP.Promise(function(resolve) {
$LAB.script(Discourse.getURL(url)).wait(() => resolve());
url = Discourse.getURL((assetPath && assetPath(url)) || url);
// If we already loaded this url
if (_loaded[url]) { return resolve(); }
$.getScript(url).then(function() {
_loaded[url] = true;
resolve();
});
});
}