mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 14:12:10 +08:00
Replace $LAB with path aware loadScript
that uses jQuery
This commit is contained in:
@ -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();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user