From d20092c5b2fd62e13e45077d482934ddaaba4750 Mon Sep 17 00:00:00 2001 From: Maxim Kadushkin Date: Mon, 27 Feb 2017 15:02:37 +0300 Subject: [PATCH] [DE] refactoring --- apps/documenteditor/main/app/view/LeftMenu.js | 2 +- apps/documenteditor/main/app/view/Toolbar.js | 62 ++++++++++++------- 2 files changed, 39 insertions(+), 25 deletions(-) diff --git a/apps/documenteditor/main/app/view/LeftMenu.js b/apps/documenteditor/main/app/view/LeftMenu.js index cb52b3db1..34ff99204 100644 --- a/apps/documenteditor/main/app/view/LeftMenu.js +++ b/apps/documenteditor/main/app/view/LeftMenu.js @@ -257,7 +257,7 @@ define([ /** coauthoring end **/ close: function(menu) { - if ( this.menuFile.$el.is(':visible') ) { + if ( this.menuFile.isVisible() ) { this.menuFile.hide(); Common.NotificationCenter.trigger('layout:changed', 'menufile'); } else { diff --git a/apps/documenteditor/main/app/view/Toolbar.js b/apps/documenteditor/main/app/view/Toolbar.js index ce8ea0d18..e8ba66e9f 100644 --- a/apps/documenteditor/main/app/view/Toolbar.js +++ b/apps/documenteditor/main/app/view/Toolbar.js @@ -65,6 +65,16 @@ define([ var $panels, $marker, $scrollL; var lastPanel; + var config = { + tabs: [ + { caption: 'File', action: 'file'}, + { caption: 'Home', action: 'home'}, + { caption: 'Insert', action: 'ins'}, + { caption: 'Page Layout', action: 'layout'}, + { caption: 'Plugins', action: 'plugins' } + ] + }; + function hasTabInvisible() { var _left_bound_ = $boxTabs.offset().left, _right_bound_ = _left_bound_ + $boxTabs.width(); @@ -109,7 +119,7 @@ define([ el: '#toolbar', // Compile our stats template - template: _.template(template), + // template: _.template(template), // Delegated events for creating new items, and clearing completed ones. events: { @@ -117,6 +127,8 @@ define([ }, initialize: function () { + config.$dom = $(_.template(template, config)); + /** * UI Components */ @@ -1230,29 +1242,7 @@ define([ var value = Common.localStorage.getItem("de-compact-toolbar"); var valueCompact = !!(value !== null && parseInt(value) == 1 || value === null && mode.customization && mode.customization.compactToolbar); - var _tpl_ = this.template({ - tabs: [{ - caption: 'File', - action: 'file' - }, { - caption: 'Home', - action: 'home' - }, { - caption: 'Insert', - action: 'ins' - }, { - caption: 'Page Layout', - action: 'layout' - }, { - caption: 'Review', - action: 'review' - }, { - caption: 'Plugins', - action: 'plugins' - }] - }); - - me.$el.html(me.rendererComponents(_tpl_)); + me.$el.html( me.rendererComponents(config.$dom) ); me.isCompactView = valueCompact; @@ -2286,6 +2276,30 @@ define([ } }, + addTab: function (tab, panel, after) { + var _tplTab = '
  • <%= caption %>
  • '; + + if ( $tabs ) { + // $tabs.find('a[data-tab=' + after + ']').parent() + // .after( _.template(_tpl, tab) ); + } else { + var $toolbar = config.$dom; + + var $el = $toolbar.find('.tabs a[data-tab=' + after + ']'); + if ( $el.length ) { + $el.parent().after( _.template(_tplTab, tab)); + + if ( panel ) { + $el = $toolbar.find('.box-panels > .panel[data-tab=' + after + ']'); + + if ( $el.length ) { + $el.after(panel); + } + } + } + } + }, + textBold: 'Bold', textItalic: 'Italic', textUnderline: 'Underline',