From 6a77790aef16d2e6ab6b37e239d54699aca3e5cc Mon Sep 17 00:00:00 2001 From: Niklas Berg Date: Wed, 14 Feb 2018 23:35:05 +0100 Subject: [PATCH 1/2] load.plugin now accepts class as an argument besides an url-string --- src/loader/File.js | 4 ++-- src/loader/filetypes/PluginFile.js | 7 +++++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/loader/File.js b/src/loader/File.js index 9b69aedd1..83b39495c 100644 --- a/src/loader/File.js +++ b/src/loader/File.js @@ -65,7 +65,7 @@ var File = new Class({ { this.url = GetFastValue(fileConfig, 'path', '') + this.key + '.' + GetFastValue(fileConfig, 'extension', ''); } - else + else if(typeof(this.url) !== "function") { this.url = GetFastValue(fileConfig, 'path', '').concat(this.url); } @@ -118,7 +118,7 @@ var File = new Class({ * @type {integer} * @since 3.0.0 */ - this.state = CONST.FILE_PENDING; + this.state = typeof(this.url) === "function" ? CONST.FILE_POPULATED : CONST.FILE_PENDING; /** * The total size of this file. diff --git a/src/loader/filetypes/PluginFile.js b/src/loader/filetypes/PluginFile.js index c05a07428..1ca0f0e86 100644 --- a/src/loader/filetypes/PluginFile.js +++ b/src/loader/filetypes/PluginFile.js @@ -34,6 +34,13 @@ var PluginFile = new Class({ function PluginFile (key, url, path, xhrSettings) { + // If the url variable refers to a class, add the plugin directly + if(typeof url === "function"){ + this.key = key; + window[key] = url; + window[key].register(PluginManager); + } + var fileKey = (typeof key === 'string') ? key : GetFastValue(key, 'key', ''); var fileConfig = { From 6dde7002dcfd64b13f68c762e6ed20f8ae682fd2 Mon Sep 17 00:00:00 2001 From: Niklas Berg Date: Thu, 15 Feb 2018 18:11:55 +0100 Subject: [PATCH 2/2] fixed formatting --- src/loader/File.js | 2 +- src/loader/filetypes/PluginFile.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/loader/File.js b/src/loader/File.js index 83b39495c..d68655f67 100644 --- a/src/loader/File.js +++ b/src/loader/File.js @@ -65,7 +65,7 @@ var File = new Class({ { this.url = GetFastValue(fileConfig, 'path', '') + this.key + '.' + GetFastValue(fileConfig, 'extension', ''); } - else if(typeof(this.url) !== "function") + else if (typeof(this.url) !== 'function') { this.url = GetFastValue(fileConfig, 'path', '').concat(this.url); } diff --git a/src/loader/filetypes/PluginFile.js b/src/loader/filetypes/PluginFile.js index 1ca0f0e86..81ab63fb1 100644 --- a/src/loader/filetypes/PluginFile.js +++ b/src/loader/filetypes/PluginFile.js @@ -35,7 +35,8 @@ var PluginFile = new Class({ function PluginFile (key, url, path, xhrSettings) { // If the url variable refers to a class, add the plugin directly - if(typeof url === "function"){ + if (typeof url === 'function') + { this.key = key; window[key] = url; window[key].register(PluginManager);