Browse Source

Add `appendTo` option to BlockManager

pull/856/head
Artur Arseniev 8 years ago
parent
commit
2cfe8b6a16
  1. 4
      src/block_manager/config/config.js
  2. 13
      src/block_manager/index.js
  3. 4
      src/navigator/config/config.js
  4. 12
      src/styles/scss/_gjs_layers.scss

4
src/block_manager/config/config.js

@ -1,4 +1,8 @@
module.exports = {
// Specify the element to use as a container, string (query) or HTMLElement
// With the empty value, nothing will be rendered
appendTo: '',
blocks: [],
appendTo: ''

13
src/block_manager/index.js

@ -28,6 +28,8 @@
* }
* ...
*/
import { isElement } from 'underscore';
module.exports = () => {
var c = {},
defaults = require('./config/config'),
@ -108,6 +110,15 @@ module.exports = () => {
!blocks.length && blocks.reset(c.blocks);
},
postRender() {
const elTo = this.getConfig().appendTo;
if (elTo) {
const el = isElement(elTo) ? elTo : document.querySelector(elTo);
el.appendChild(this.render());
}
},
/**
* Add new block to the collection.
* @param {string} id Block id
@ -199,6 +210,7 @@ module.exports = () => {
* Render blocks
* @param {Array} blocks Blocks to render, without the argument will render
* all global blocks
* @return {HTMLElement} Rendered element
* @example
* // Render all blocks (inside the global collection)
* blockManager.render();
@ -225,6 +237,7 @@ module.exports = () => {
}
blocksView.collection.reset(toRender);
return this.getContainer();
}
};
};

4
src/navigator/config/config.js

@ -1,8 +1,8 @@
module.exports = {
stylePrefix: '',
// Specify the element to use as layers container, string (query) or HTMLElement
// With the empty value, layers won't be rendered automatically
// Specify the element to use as a container, string (query) or HTMLElement
// With the empty value, nothing will be rendered
appendTo: '',
// Enable/Disable globally the possibility to sort layers

12
src/styles/scss/_gjs_layers.scss

@ -81,18 +81,6 @@
display: block;
}
/*
.#{$nv-prefix}item .#{$nv-prefix}children .#{$nv-prefix}title {
border-left: 1px solid lighten($mainDkColor, 2%);
}
*/
/*
.#{$nv-prefix}item > .#{$nv-prefix}no-chld > ##{$nv-prefix}caret::before {
content: '';
}
*/
&-no-chld > .#{$nv-prefix}layer-title-inn > .#{$nv-prefix}layer-caret {
display: none;
}

Loading…
Cancel
Save