|
|
@ -48,7 +48,7 @@ module.exports = Backbone.View.extend({ |
|
|
this.caretCls = this.ppfx + 'nav-item-caret'; |
|
|
this.caretCls = this.ppfx + 'nav-item-caret'; |
|
|
this.titleCls = this.pfx + 'title'; |
|
|
this.titleCls = this.pfx + 'title'; |
|
|
this.events = {}; |
|
|
this.events = {}; |
|
|
this.events['click > #'+this.pfx+'btn-eye'] = 'toggleVisibility'; |
|
|
this.events['click #'+this.pfx+'btn-eye'] = 'toggleVisibility'; |
|
|
this.events['click .' + this.caretCls] = 'toggleOpening'; |
|
|
this.events['click .' + this.caretCls] = 'toggleOpening'; |
|
|
this.events['click .' + this.titleCls] = 'handleSelect'; |
|
|
this.events['click .' + this.titleCls] = 'handleSelect'; |
|
|
this.events['click .' + this.editBtnCls] = 'handleEdit'; |
|
|
this.events['click .' + this.editBtnCls] = 'handleEdit'; |
|
|
@ -58,7 +58,7 @@ module.exports = Backbone.View.extend({ |
|
|
this.$el.data('collection', this.model.get('components')); |
|
|
this.$el.data('collection', this.model.get('components')); |
|
|
|
|
|
|
|
|
if(o.config.sortable) |
|
|
if(o.config.sortable) |
|
|
this.events['mousedown > #'+this.pfx+'move'] = 'startSort'; |
|
|
this.events['mousedown #'+this.pfx+'move'] = 'startSort'; |
|
|
|
|
|
|
|
|
this.delegateEvents(); |
|
|
this.delegateEvents(); |
|
|
}, |
|
|
}, |
|
|
@ -183,8 +183,11 @@ module.exports = Backbone.View.extend({ |
|
|
* @return void |
|
|
* @return void |
|
|
* */ |
|
|
* */ |
|
|
toggleVisibility(e) { |
|
|
toggleVisibility(e) { |
|
|
|
|
|
e.stopPropagation(); |
|
|
|
|
|
const pfx = this.pfx; |
|
|
|
|
|
|
|
|
if(!this.$eye) |
|
|
if(!this.$eye) |
|
|
this.$eye = this.$el.find('> #'+this.pfx+'btn-eye'); |
|
|
this.$eye = this.$el.children(`#${pfx}btn-eye`); |
|
|
|
|
|
|
|
|
var cCss = _.clone(this.model.get('style')), |
|
|
var cCss = _.clone(this.model.get('style')), |
|
|
hClass = this.pfx + 'hide'; |
|
|
hClass = this.pfx + 'hide'; |
|
|
@ -219,18 +222,23 @@ module.exports = Backbone.View.extend({ |
|
|
* @return void |
|
|
* @return void |
|
|
* */ |
|
|
* */ |
|
|
checkChildren() { |
|
|
checkChildren() { |
|
|
var c = this.countChildren(this.model), |
|
|
const model = this.model; |
|
|
pfx = this.pfx, |
|
|
const c = this.countChildren(model); |
|
|
tC = '> .' + pfx + 'title-c > .' + pfx + 'title'; |
|
|
const pfx = this.pfx; |
|
|
if(!this.$counter) |
|
|
const noChildCls = `${pfx}no-chld`; |
|
|
this.$counter = this.$el.find('> #' + pfx + 'counter'); |
|
|
const title = this.$el.children(`.${pfx}title-c`).children(`.${pfx}title`); |
|
|
if(c){ |
|
|
//tC = `> .${pfx}title-c > .${pfx}title`;
|
|
|
this.$el.find(tC).removeClass(pfx + 'no-chld'); |
|
|
if (!this.$counter) { |
|
|
|
|
|
this.$counter = this.$el.children(`#${pfx}counter`); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (c) { |
|
|
|
|
|
title.removeClass(noChildCls); |
|
|
this.$counter.html(c); |
|
|
this.$counter.html(c); |
|
|
}else{ |
|
|
} else { |
|
|
this.$el.find(tC).addClass(pfx + 'no-chld'); |
|
|
title.addClass(noChildCls); |
|
|
this.$counter.empty(); |
|
|
this.$counter.empty(); |
|
|
this.model.set('open',0); |
|
|
model.set('open', 0); |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
@ -255,8 +263,9 @@ module.exports = Backbone.View.extend({ |
|
|
getCaret() { |
|
|
getCaret() { |
|
|
if (!this.caret) { |
|
|
if (!this.caret) { |
|
|
const pfx = this.pfx; |
|
|
const pfx = this.pfx; |
|
|
this.caret = this.$el.find(`> .${pfx}title-c > .${pfx}title > .${pfx}title-inn > #${pfx}caret`); |
|
|
this.caret = this.$el.find(`.${pfx}title-c > .${pfx}title > .${pfx}title-inn > #${pfx}caret`); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return this.caret; |
|
|
return this.caret; |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
@ -265,9 +274,10 @@ module.exports = Backbone.View.extend({ |
|
|
var pfx = this.pfx; |
|
|
var pfx = this.pfx; |
|
|
var vis = this.isVisible(); |
|
|
var vis = this.isVisible(); |
|
|
var count = this.countChildren(model); |
|
|
var count = this.countChildren(model); |
|
|
|
|
|
const el = this.$el; |
|
|
const level = this.level + 1; |
|
|
const level = this.level + 1; |
|
|
|
|
|
|
|
|
this.$el.html( this.template({ |
|
|
el.html( this.template({ |
|
|
title: model.getName(), |
|
|
title: model.getName(), |
|
|
icon: model.getIcon(), |
|
|
icon: model.getIcon(), |
|
|
addClass: (count ? '' : pfx+'no-chld'), |
|
|
addClass: (count ? '' : pfx+'no-chld'), |
|
|
@ -292,13 +302,15 @@ module.exports = Backbone.View.extend({ |
|
|
parent: model, |
|
|
parent: model, |
|
|
level |
|
|
level |
|
|
}).render().$el; |
|
|
}).render().$el; |
|
|
this.$el.find('.'+ pfx +'children').html(this.$components); |
|
|
el.find(`.${pfx}children`).append(this.$components); |
|
|
if(!model.get('draggable') || !this.config.sortable){ |
|
|
|
|
|
this.$el.find('> #' + pfx + 'move').detach(); |
|
|
if(!model.get('draggable') || !this.config.sortable) { |
|
|
|
|
|
el.children(`#${pfx}move`).remove(); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if(!vis) |
|
|
if(!vis) |
|
|
this.className += ' ' + pfx + 'hide'; |
|
|
this.className += ' ' + pfx + 'hide'; |
|
|
this.$el.attr('class', _.result(this, 'className')); |
|
|
el.attr('class', _.result(this, 'className')); |
|
|
this.updateOpening(); |
|
|
this.updateOpening(); |
|
|
this.updateStatus(); |
|
|
this.updateStatus(); |
|
|
return this; |
|
|
return this; |
|
|
|