From 23bb0084e99995e2af3831a65df648ec5a72e123 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 28 Apr 2017 17:08:11 +0300 Subject: [PATCH 1/5] [SSE] Bug with co-editing in strict mode and icons in the toolbar (border button). --- apps/spreadsheeteditor/main/app/controller/Main.js | 4 ++-- .../spreadsheeteditor/main/app/controller/Toolbar.js | 12 ++++++------ apps/spreadsheeteditor/main/app/view/Toolbar.js | 10 +++++----- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index df5190faf..6eb83d204 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -1298,7 +1298,7 @@ define([ Common.Gateway.setDocumentModified(change); if (this.toolbarView && this.toolbarView.btnSave && this.api) { - var isSyncButton = $('.btn-icon', this.toolbarView.btnSave.cmpEl).hasClass('btn-synch'), + var isSyncButton = $('.icon', this.toolbarView.btnSave.cmpEl).hasClass('btn-synch'), forcesave = this.appOptions.forcesave; var cansave = this.api.asc_isDocumentCanSave(); if (this.toolbarView.btnSave.isDisabled() !== (!cansave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave)) @@ -1308,7 +1308,7 @@ define([ onDocumentCanSaveChanged: function (isCanSave) { if (this.toolbarView && this.toolbarView.btnSave) { - var isSyncButton = $('.btn-icon', this.toolbarView.btnSave.cmpEl).hasClass('btn-synch'), + var isSyncButton = $('.icon', this.toolbarView.btnSave.cmpEl).hasClass('btn-synch'), forcesave = this.appOptions.forcesave; if (this.toolbarView.btnSave.isDisabled() !== (!isCanSave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave)) this.toolbarView.btnSave.setDisabled(!isCanSave && !isSyncButton && !forcesave || this._state.isDisconnected || this._state.fastCoauth && this._state.usersCount>1 && !forcesave); diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 18fa15c63..eee4703fd 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -331,7 +331,7 @@ define([ onSave: function(e) { if (this.api) { var isModified = this.api.asc_isDocumentCanSave(); - var isSyncButton = $('.btn-icon', this.toolbar.btnSave.cmpEl).hasClass('btn-synch'); + var isSyncButton = $('.icon', this.toolbar.btnSave.cmpEl).hasClass('btn-synch'); if (!isModified && !isSyncButton && !this.toolbar.mode.forcesave) return; @@ -506,7 +506,7 @@ define([ bordersColor = btnBorders.options.borderscolor; if (btnBorders.rendered) { - var iconEl = $('.btn-icon', btnBorders.cmpEl); + var iconEl = $('.icon', btnBorders.cmpEl); if (iconEl) { iconEl.removeClass(btnBorders.options.icls); @@ -575,7 +575,7 @@ define([ onHorizontalAlignMenu: function(menu, item) { var btnHorizontalAlign = this.toolbar.btnHorizontalAlign, - iconEl = $('.btn-icon', btnHorizontalAlign.cmpEl); + iconEl = $('.icon', btnHorizontalAlign.cmpEl); if (iconEl) { iconEl.removeClass(btnHorizontalAlign.options.icls); @@ -595,7 +595,7 @@ define([ onVerticalAlignMenu: function(menu, item) { var btnVerticalAlign = this.toolbar.btnVerticalAlign, - iconEl = $('.btn-icon', btnVerticalAlign.cmpEl); + iconEl = $('.icon', btnVerticalAlign.cmpEl); if (iconEl) { iconEl.removeClass(btnVerticalAlign.options.icls); @@ -1891,7 +1891,7 @@ define([ var btnHorizontalAlign = this.toolbar.btnHorizontalAlign; if (btnHorizontalAlign.rendered) { - var hIconEl = $('.btn-icon', btnHorizontalAlign.cmpEl); + var hIconEl = $('.icon', btnHorizontalAlign.cmpEl); if (hIconEl) { hIconEl.removeClass(btnHorizontalAlign.options.icls); @@ -1925,7 +1925,7 @@ define([ var btnVerticalAlign = this.toolbar.btnVerticalAlign; if (btnVerticalAlign.rendered) { - var vIconEl = $('.btn-icon', btnVerticalAlign.cmpEl); + var vIconEl = $('.icon', btnVerticalAlign.cmpEl); if (vIconEl) { vIconEl.removeClass(btnVerticalAlign.options.icls); diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index c896e8cd7..a7c2864b6 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -1478,9 +1478,9 @@ define([ 'data-stopPropagation="true"', '<% } %>', '>', '', - '', + '', '', - '', + '', '' ].join('')), stopPropagation: true, @@ -1779,7 +1779,7 @@ define([ } this._state.hasCollaborativeChanges = true; - var iconEl = $('.btn-icon', this.btnSave.cmpEl); + var iconEl = $('.icon', this.btnSave.cmpEl); iconEl.removeClass(this.btnSaveCls); iconEl.addClass('btn-synch'); @@ -1815,7 +1815,7 @@ define([ synchronizeChanges: function() { if (this.btnSave.rendered) { - var iconEl = $('.btn-icon', this.btnSave.cmpEl); + var iconEl = $('.icon', this.btnSave.cmpEl); if (iconEl.hasClass('btn-synch')) { iconEl.removeClass('btn-synch'); @@ -1841,7 +1841,7 @@ define([ if (cls !== this.btnSaveCls && this.btnSave.rendered) { this.btnSaveTip = ((length>1) ? this.tipSaveCoauth : this.tipSave )+ Common.Utils.String.platformKey('Ctrl+S'); - var iconEl = $('.btn-icon', this.btnSave.cmpEl); + var iconEl = $('.icon', this.btnSave.cmpEl); if (!iconEl.hasClass('btn-synch')) { iconEl.removeClass(this.btnSaveCls); iconEl.addClass(cls); From 59750ed06bfb78249c1ba1c20cd48b51e7b86a63 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 28 Apr 2017 17:12:07 +0300 Subject: [PATCH 2/5] [SSE] Fixed buttons rendering. --- apps/spreadsheeteditor/main/app/view/RightMenu.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/RightMenu.js b/apps/spreadsheeteditor/main/app/view/RightMenu.js index 3e93ce263..c685e418a 100644 --- a/apps/spreadsheeteditor/main/app/view/RightMenu.js +++ b/apps/spreadsheeteditor/main/app/view/RightMenu.js @@ -145,12 +145,12 @@ define([ el.html(this.template({})); - this.btnText.el = $('#id-right-menu-text'); this.btnText.render(); - this.btnImage.el = $('#id-right-menu-image'); this.btnImage.render(); - this.btnChart.el = $('#id-right-menu-chart'); this.btnChart.render(); - this.btnShape.el = $('#id-right-menu-shape'); this.btnShape.render(); - this.btnTextArt.el = $('#id-right-menu-textart'); this.btnTextArt.render(); - this.btnTable.el = $('#id-right-menu-table'); this.btnTable.render(); + this.btnText.setElement($('#id-right-menu-text'), false); this.btnText.render(); + this.btnImage.setElement($('#id-right-menu-image'), false); this.btnImage.render(); + this.btnChart.setElement($('#id-right-menu-chart'), false); this.btnChart.render(); + this.btnShape.setElement($('#id-right-menu-shape'), false); this.btnShape.render(); + this.btnTextArt.setElement($('#id-right-menu-textart'), false); this.btnTextArt.render(); + this.btnTable.setElement($('#id-right-menu-table'), false); this.btnTable.render(); this.btnText.on('click', _.bind(this.onBtnMenuClick, this)); this.btnImage.on('click', _.bind(this.onBtnMenuClick, this)); From b53b32e67f334e59e378662c01c726d1a0332fa5 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 28 Apr 2017 17:28:35 +0300 Subject: [PATCH 3/5] [SSE] Fix loading color palettes in the toolbar menu. --- .../main/app/controller/Toolbar.js | 4 +- .../main/app/view/Toolbar.js | 42 +++++++++++-------- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index eee4703fd..391346256 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -176,7 +176,7 @@ define([ Common.NotificationCenter.on('app:face', this.onAppShowed.bind(this)); }, - onToolbarAfterRender: function(toolbar) { + attachUIEvents: function(toolbar) { var me = this; /** @@ -1331,7 +1331,7 @@ define([ var me = this; this.toolbar.createDelayedElements(); - this.onToolbarAfterRender(this.toolbar); + this.attachUIEvents(this.toolbar); if ( !this.appConfig.isEditDiagram && !this.appConfig.isEditMailMerge ) { this.api.asc_registerCallback('asc_onSheetsChanged', _.bind(this.onApiSheetChanged, this)); diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index a7c2864b6..0459837ac 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -421,14 +421,6 @@ define([ { template: _.template('' + me.textNewColor + '') } ] }) - }).on('render:after', function(btn) { - var colorVal = $('
'); - $('button:first-child', btn.cmpEl).append(colorVal); - colorVal.css('background-color', btn.currentColor || 'transparent'); - - me.mnuTextColorPicker = new Common.UI.ThemeColorPalette({ - el: $('#id-toolbar-menu-fontcolor') - }); }); me.mnuBackColorPicker = dummyCmp(); @@ -444,15 +436,6 @@ define([ { template: _.template('' + me.textNewColor + '') } ] }) - }).on('render:after', function(btn) { - var colorVal = $('
'); - $('button:first-child', btn.cmpEl).append(colorVal); - colorVal.css('background-color', btn.currentColor || 'transparent'); - - me.mnuBackColorPicker = new Common.UI.ThemeColorPalette({ - el: $('#id-toolbar-menu-paracolor'), - transparent: true - }); }); me.btnBorders = new Common.UI.Button({ @@ -1244,6 +1227,8 @@ define([ if (cmp && _.isFunction(cmp.setDisabled)) cmp.setDisabled(true); }); + + this.on('render:after', _.bind(this.onToolbarAfterRender, this)); }, render: function (mode) { @@ -1684,6 +1669,29 @@ define([ } }, + onToolbarAfterRender: function(toolbar) { + // DataView and pickers + // + if (this.btnTextColor.cmpEl) { + var colorVal = $('
'); + $('button:first-child', this.btnTextColor.cmpEl).append(colorVal); + colorVal.css('background-color', this.btnTextColor.currentColor || 'transparent'); + this.mnuTextColorPicker = new Common.UI.ThemeColorPalette({ + el: $('#id-toolbar-menu-fontcolor') + }); + } + if (this.btnBackColor.cmpEl) { + var colorVal = $('
'); + $('button:first-child', this.btnBackColor.cmpEl).append(colorVal); + colorVal.css('background-color', this.btnBackColor.currentColor || 'transparent'); + + this.mnuBackColorPicker = new Common.UI.ThemeColorPalette({ + el: $('#id-toolbar-menu-paracolor'), + transparent: true + }); + } + }, + setApi: function(api) { this.api = api; From 857d688afbd56c3db2ce077e506de1c28bcbc381 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 28 Apr 2017 17:42:09 +0300 Subject: [PATCH 4/5] [SSE] Fix adding chart from DocumentEditor. --- apps/spreadsheeteditor/main/app/view/Toolbar.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/view/Toolbar.js b/apps/spreadsheeteditor/main/app/view/Toolbar.js index 0459837ac..3f1445f69 100644 --- a/apps/spreadsheeteditor/main/app/view/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/view/Toolbar.js @@ -1672,7 +1672,7 @@ define([ onToolbarAfterRender: function(toolbar) { // DataView and pickers // - if (this.btnTextColor.cmpEl) { + if (this.btnTextColor && this.btnTextColor.cmpEl) { var colorVal = $('
'); $('button:first-child', this.btnTextColor.cmpEl).append(colorVal); colorVal.css('background-color', this.btnTextColor.currentColor || 'transparent'); @@ -1680,7 +1680,7 @@ define([ el: $('#id-toolbar-menu-fontcolor') }); } - if (this.btnBackColor.cmpEl) { + if (this.btnBackColor && this.btnBackColor.cmpEl) { var colorVal = $('
'); $('button:first-child', this.btnBackColor.cmpEl).append(colorVal); colorVal.css('background-color', this.btnBackColor.currentColor || 'transparent'); From dead0af353bc8c5ed43a1af7462ee853c7133fe7 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 28 Apr 2017 17:43:12 +0300 Subject: [PATCH 5/5] [SSE] Collapse toolbar when document context menu is opened. --- apps/spreadsheeteditor/main/app/controller/Toolbar.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index 391346256..f86825ee2 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -301,6 +301,7 @@ define([ if ( !config.isEditDiagram && !config.isEditMailMerge ) { this.api.asc_registerCallback('asc_onSendThemeColors', _.bind(this.onSendThemeColors, this)); this.api.asc_registerCallback('asc_onMathTypes', _.bind(this.onMathTypes, this)); + this.api.asc_registerCallback('asc_onContextMenu', _.bind(this.onContextMenu, this)); } this.api.asc_registerCallback('asc_onInitEditorStyles', _.bind(this.onApiInitEditorStyles, this)); @@ -324,6 +325,10 @@ define([ // Common.component.Analytics.trackEvent('ToolBar', 'Open Document'); // }, + onContextMenu: function() { + this.toolbar.collapseToolbar(); + }, + onPrint: function(e) { Common.NotificationCenter.trigger('print', this.toolbar); },