const Layers = require('navigator');
const $ = Backbone.$;

module.exports = {
  /*
  run(em, sender) {
    if (!this.toAppend) {
      var collection = em.DomComponents.getComponent().get('components');
      var config = em.getConfig();
      var pfx = config.stylePrefix;
      var panels = em.Panels;
      const cLayers = { ...config.layers };
      var lyStylePfx = cLayers.stylePrefix || 'nv-';

      cLayers.stylePrefix = config.stylePrefix + lyStylePfx;
      cLayers.pStylePrefix = config.stylePrefix;
      cLayers.em = em.editor;
      cLayers.opened = em.editor.get('opened');

      // Check if panel exists otherwise crate it
      if (!panels.getPanel('views-container'))
        this.panel = panels.addPanel({ id: 'views-container' });
      else this.panel = panels.getPanel('views-container');

      const toAppend = $(`<div class="${pfx}layers"></div>`);
      this.panel.set('appendContent', toAppend).trigger('change:appendContent');
      cLayers.sortContainer = toAppend.get(0);
      const layers = new Layers().init(collection, cLayers);
      this.$layers = layers.render();
      toAppend.append(this.$layers);
      this.toAppend = toAppend;
    }
    this.toAppend.show();
  },

  stop() {
    this.toAppend && this.toAppend.hide();
  },
  */

  run(editor) {
    const lm = editor.LayerManager;
    const pn = editor.Panels;

    if (!this.layers) {
      const id = 'views-container';
      const layers = document.createElement('div');
      const panels = pn.getPanel(id) || pn.addPanel({ id });
      layers.appendChild(lm.render());
      panels.set('appendContent', layers).trigger('change:appendContent');
      this.layers = layers;
    }

    this.layers.style.display = 'block';
  },

  stop() {
    const layers = this.layers;
    layers && (layers.style.display = 'none');
  }
};

@@ -76,1205 +76,8 @@
 = %7B%0A
-  /*%0A  run(em, sender) %7B%0A    if (!this.toAppend) %7B%0A      var collection = em.DomComponents.getComponent().get('components');%0A      var config = em.getConfig();%0A      var pfx = config.stylePrefix;%0A      var panels = em.Panels;%0A      const cLayers = %7B ...config.layers %7D;%0A      var lyStylePfx = cLayers.stylePrefix %7C%7C 'nv-';%0A%0A      cLayers.stylePrefix = config.stylePrefix + lyStylePfx;%0A      cLayers.pStylePrefix = config.stylePrefix;%0A      cLayers.em = em.editor;%0A      cLayers.opened = em.editor.get('opened');%0A%0A      // Check if panel exists otherwise crate it%0A      if (!panels.getPanel('views-container'))%0A        this.panel = panels.addPanel(%7B id: 'views-container' %7D);%0A      else this.panel = panels.getPanel('views-container');%0A%0A      const toAppend = $(%60%3Cdiv class=%22$%7Bpfx%7Dlayers%22%3E%3C/div%3E%60);%0A      this.panel.set('appendContent', toAppend).trigger('change:appendContent');%0A      cLayers.sortContainer = toAppend.get(0);%0A      const layers = new Layers().init(collection, cLayers);%0A      this.$layers = layers.render();%0A      toAppend.append(this.$layers);%0A      this.toAppend = toAppend;%0A    %7D%0A    this.toAppend.show();%0A  %7D,%0A%0A  stop() %7B%0A    this.toAppend && this.toAppend.hide();%0A  %7D,%0A  */%0A%0A
   ru

Clean OpenLayers