diff --git a/src/commands/view/OpenLayers.js b/src/commands/view/OpenLayers.js index 31b2ba8d1..4741293db 100644 --- a/src/commands/view/OpenLayers.js +++ b/src/commands/view/OpenLayers.js @@ -3,7 +3,7 @@ var Layers = require('navigator'); module.exports = { run(em, sender) { - if (!this.$layers) { + if (!this.toAppend) { var collection = em.DomComponents.getComponent().get('components'); var config = em.getConfig(); var pfx = config.stylePrefix; @@ -14,8 +14,6 @@ module.exports = { config.layers.pStylePrefix = config.stylePrefix; config.layers.em = em.editor; config.layers.opened = em.editor.get('opened'); - var layers = new Layers().init(collection, config.layers); - this.$layers = layers.render(); // Check if panel exists otherwise crate it if(!panels.getPanel('views-container')) @@ -24,14 +22,17 @@ module.exports = { this.panel = panels.getPanel('views-container'); const toAppend = $(`
`); - toAppend.append(this.$layers); this.panel.set('appendContent', toAppend).trigger('change:appendContent'); + config.layers.sortContainer = toAppend.get(0); + const layers = new Layers().init(collection, config.layers); + this.$layers = layers.render(); + toAppend.append(this.$layers); + this.toAppend = toAppend; } - this.$layers.show(); + this.toAppend.show(); }, stop() { - if(this.$layers) - this.$layers.hide(); + this.toAppend && this.toAppend.hide(); } }; diff --git a/src/navigator/view/ItemsView.js b/src/navigator/view/ItemsView.js index f94da8c5c..58dc8d3c0 100644 --- a/src/navigator/view/ItemsView.js +++ b/src/navigator/view/ItemsView.js @@ -3,22 +3,23 @@ var ItemView = require('./ItemView'); module.exports = Backbone.View.extend({ - initialize(o) { + initialize(o = {}) { this.opt = o; - this.config = o.config; + const config = o.config || {}; + this.config = config; this.preview = o.preview; - this.ppfx = o.config.pStylePrefix || ''; - this.pfx = o.config.stylePrefix || ''; + this.ppfx = config.pStylePrefix || ''; + this.pfx = config.stylePrefix || ''; this.parent = o.parent; this.listenTo(this.collection, 'add', this.addTo); this.listenTo(this.collection, 'reset resetNavigator', this.render); this.className = this.pfx + 'items'; - if(this.config.sortable && !this.opt.sorter){ + if (config.sortable && !this.opt.sorter) { var pfx = this.pfx; - var utils = this.config.em.get('Utils'); + var utils = config.em.get('Utils'); this.opt.sorter = new utils.Sorter({ - container: this.el, + container: config.sortContainer || this.el, containerSel: '.' + pfx + 'items', itemSel: '.' + pfx + 'item', ppfx: this.ppfx,