file rename fix

This commit is contained in:
Antelle 2015-10-27 22:59:04 +03:00
parent d973c9f989
commit c2f6624527
4 changed files with 16 additions and 3 deletions

View File

@ -20,7 +20,10 @@ var MenuItemModel = Backbone.Model.extend({
filterValue: null
},
initialize: function() {
initialize: function(model) {
if (model && model.file) {
this.listenTo(model.file, 'change:name', this.changeTitle, this);
}
},
_loadItemCollectionType: function() {
@ -55,6 +58,10 @@ var MenuItemModel = Backbone.Model.extend({
expanded = true;
}
this.set('expanded', expanded);
},
changeTitle: function(model, newTitle) {
this.set('title', newTitle);
}
});

View File

@ -21,6 +21,7 @@ var MenuItemView = Backbone.View.extend({
initialize: function () {
this.itemViews = [];
this.listenTo(this.model, 'change:title', this.changeTitle);
this.listenTo(this.model, 'change:active', this.changeActive);
this.listenTo(this.model, 'change:expanded', this.changeExpanded);
this.listenTo(this.model, 'change:cls', this.changeCls);
@ -67,6 +68,10 @@ var MenuItemView = Backbone.View.extend({
this.itemViews = [];
},
changeTitle: function(model, title) {
this.$el.find('.menu__item-title').text(title);
},
changeActive: function(model, active) {
this.$el.toggleClass('menu__item--active', active);
},

View File

@ -111,6 +111,7 @@
}
&-title {
padding-left: .4em;
.menu__item-colors & {
display: inline-block;
@include th { color: text-color(); }

View File

@ -5,7 +5,7 @@
cls ? cls : '' %>">
<div class="menu__item-body">
<i class="menu__item-icon fa <%= icon ? 'fa-' + icon : 'menu__item-icon--no-icon' %>"></i><span
class="menu__item-title">&nbsp;<%- title %></span>
class="menu__item-title"><%- title %></span>
<% if (options) { %>
<div class="menu__item-options">
<% options.forEach(function(option) { %>
@ -15,4 +15,4 @@
</div>
<% } %>
</div>
</div>
</div>