From 673c82c647c694a4c232e23ae100fd889f552f4f Mon Sep 17 00:00:00 2001 From: Artur Arseniev Date: Thu, 10 Nov 2016 14:06:33 +0100 Subject: [PATCH] Hide text nodes inside navigator --- src/dom_components/view/ComponentTextView.js | 6 +++++- src/navigator/config/config.js | 15 ++++++++------- src/navigator/view/ItemsView.js | 4 +++- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/dom_components/view/ComponentTextView.js b/src/dom_components/view/ComponentTextView.js index 75b994748..68d900dd9 100644 --- a/src/dom_components/view/ComponentTextView.js +++ b/src/dom_components/view/ComponentTextView.js @@ -22,12 +22,16 @@ define(['backbone', './ComponentView'], parseRender: function(){ var comps = this.model.get('components'); var opts = {silent: true}; + // Avoid re-render on reset with silent option comps.reset(null, opts); comps.add(this.$el.html(), opts); this.model.set('content', ''); - comps.trigger('resetNavigator'); this.render(); + + // As the reset was in silent mode I need to notify + // the navigator about the change + comps.trigger('resetNavigator'); }, /** diff --git a/src/navigator/config/config.js b/src/navigator/config/config.js index 42de4103f..a1cda5a2c 100644 --- a/src/navigator/config/config.js +++ b/src/navigator/config/config.js @@ -1,10 +1,11 @@ define(function () { return { - stylePrefix : 'nv-', - sortable : true, - hidable : true, - containerId : 'navigator', - itemClass : 'item', - itemsClass : 'items', + stylePrefix: 'nv-', + sortable: 1, + hidable: 1, + hideTextnode: 1, + containerId: 'navigator', + itemClass: 'item', + itemsClass: 'items', }; -}); \ No newline at end of file +}); diff --git a/src/navigator/view/ItemsView.js b/src/navigator/view/ItemsView.js index 788b5fc17..7db4a2390 100644 --- a/src/navigator/view/ItemsView.js +++ b/src/navigator/view/ItemsView.js @@ -78,8 +78,10 @@ define(['backbone','./ItemView'], this.$el.empty(); this.collection.each(function(model){ + if(model.get('type') == 'textnode' && this.config.hideTextnode) + return; this.addToCollection(model, fragment); - },this); + }, this); this.$el.append(fragment); this.$el.attr('class', _.result(this, 'className'));