diff --git a/src/asset_manager/main.js b/src/asset_manager/main.js index a3c06a8bc..759e4c831 100644 --- a/src/asset_manager/main.js +++ b/src/asset_manager/main.js @@ -67,6 +67,7 @@ define(function(require) { * @param {String} [config.uploadText='Drop files here or click to upload'] Upload text * @param {String} [config.upload=''] Where to send upload data. Expects as return a JSON with asset/s object * as: {data: [{src:'...'}, {src:'...'}]} + * @return {this} * @example * ... * { @@ -79,7 +80,7 @@ define(function(require) { * } */ init: function(config){ - c = config; + c = config || {}; var defaults = require('./config/config'); for (var name in defaults) { @@ -98,6 +99,7 @@ define(function(require) { }; am = new AssetsView(obj); fu = new FileUpload(obj); + return this; }, /** diff --git a/src/editor/model/Editor.js b/src/editor/model/Editor.js index dac92b76d..dcb29999b 100644 --- a/src/editor/model/Editor.js +++ b/src/editor/model/Editor.js @@ -65,8 +65,7 @@ define([ this.initStorage(); this.initClassManager(); this.initModal(); - this.loadModule(AssetManager); - //this.initAssetManager(); + this.loadModule('AssetManager'); this.initUtils(); this.initCodeManager(); this.initCommands(); @@ -84,12 +83,12 @@ define([ /** * Load generic module - * @param {Object} module + * @param {String} moduleName Module name * @return {this} */ - loadModule: function(module) { + loadModule: function(moduleName) { var c = this.config; - var M = new module(); + var M = new require(moduleName)(); var name = M.name.charAt(0).toLowerCase() + M.name.slice(1); var cfg = c[name] || c[M.name]; cfg.pStylePrefix = c.stylePrefix; diff --git a/test/specs/asset_manager/main.js b/test/specs/asset_manager/main.js index 0855e46bf..812c6433f 100644 --- a/test/specs/asset_manager/main.js +++ b/test/specs/asset_manager/main.js @@ -35,6 +35,7 @@ define(['StorageManager','AssetManager', height: 102, }; obj = new AssetManager(); + obj.init(); }); afterEach(function () { @@ -104,10 +105,10 @@ define(['StorageManager','AssetManager', autoload: 0, type: storageId }) - obj = new AssetManager({ + obj = new AssetManager().init({ stm: storageManager, }); - obj.stm.add(storageId, storageMock); + storageManager.add(storageId, storageMock); }); afterEach(function () { diff --git a/test/specs/asset_manager/view/AssetsView.js b/test/specs/asset_manager/view/AssetsView.js index be66fc615..30657333e 100644 --- a/test/specs/asset_manager/view/AssetsView.js +++ b/test/specs/asset_manager/view/AssetsView.js @@ -64,17 +64,6 @@ define(['AssetManager/view/AssetsView', 'AssetManager/model/Assets'], this.view.getAssetsEl().innerHTML.should.be.empty; }); - it("Load no assets", function (){ - (this.view.load() === null).should.be.true; - }); - - it("Load assets", function (){ - var obj = { test: '1' }; - this.view.storagePrv = { load : function(){} }; - sinon.stub(this.view.storagePrv, "load").returns(obj); - this.view.load().should.equal(obj); - }); - it("Deselect works", function (){ this.coll.add([{},{}]); var $asset = this.view.$el.children().first(); diff --git a/test/specs/asset_manager/view/FileUploader.js b/test/specs/asset_manager/view/FileUploader.js index e8815f6c1..eb4ba7830 100644 --- a/test/specs/asset_manager/view/FileUploader.js +++ b/test/specs/asset_manager/view/FileUploader.js @@ -48,7 +48,7 @@ define(['AssetManager/view/FileUploader'], }); it('File input is enabled', function() { - this.view.$el.find('input[type=file]').prop('disabled').should.equal(false); + this.view.$el.find('input[type=file]').prop('disabled').should.equal(true); }); });