diff --git a/src/navigator/view/ItemView.js b/src/navigator/view/ItemView.js index 8933ba6bb..b641879f0 100644 --- a/src/navigator/view/ItemView.js +++ b/src/navigator/view/ItemView.js @@ -1,3 +1,4 @@ +import { isUndefined } from 'underscore'; const ComponentView = require('dom_components/view/ComponentView'); let ItemsView; @@ -12,28 +13,36 @@ module.exports = require('backbone').View.extend({ 'focusout input': 'handleEditEnd', }, - template: _.template(` - <% if (hidable) { %> - - <% } %> - -
-
-
- - <%= icon %> - -
-
-
- -
<%= (count ? count : '') %>
-
- -
+ template(model) { + const pfx = this.pfx; + const ppfx = this.ppfx; + const hidable = this.config.hidable; + const count = this.countChildren(model); + const addClass = !count ? `${pfx}no-chld` : ''; + const level = this.level + 1; + return ` + ${ hidable ? + `` + : ''} + +
+
+
+ + ${model.getIcon()} + +
+
+
+
${ count ? count : '' }
+
+ +
+
+ `; + }, -
`), initialize(o = {}) { this.opt = o; @@ -290,29 +299,14 @@ module.exports = require('backbone').View.extend({ }, render() { - let model = this.model; + const model = this.model; var pfx = this.pfx; var vis = this.isVisible(); - var count = this.countChildren(model); const el = this.$el; const level = this.level + 1; + el.html(this.template(model)); - el.html(this.template({ - title: model.getName(), - icon: model.getIcon(), - addClass: (count ? '' : pfx+'no-chld'), - editBtnCls: this.editBtnCls, - inputNameCls: this.inputNameCls, - caretCls: this.caretCls, - count, - visible: vis, - hidable: this.config.hidable, - prefix: pfx, - ppfx: this.ppfx, - level - })); - - if (typeof ItemsView == 'undefined') { + if (isUndefined(ItemsView)) { ItemsView = require('./ItemsView'); } @@ -330,9 +324,8 @@ module.exports = require('backbone').View.extend({ el.children(`#${pfx}move`).remove(); } - if(!vis) - this.className += ' ' + pfx + 'hide'; - el.attr('class', _.result(this, 'className')); + !vis && (this.className += ` ${pfx}hide`); + el.attr('class', this.className); this.updateOpening(); this.updateStatus(); this.updateVisibility();