From 475a2bcbbe4f8ae80d81d1504aaf06208dacdc56 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Wed, 11 Sep 2019 17:26:20 +0300 Subject: [PATCH 01/13] [DE] Add caption for object --- .../main/app/controller/Links.js | 19 +- .../main/app/template/Toolbar.template | 1 + .../main/app/view/CaptionDialog.js | 285 ++++++++++++++++++ apps/documenteditor/main/app/view/Links.js | 18 +- 4 files changed, 320 insertions(+), 3 deletions(-) create mode 100644 apps/documenteditor/main/app/view/CaptionDialog.js diff --git a/apps/documenteditor/main/app/controller/Links.js b/apps/documenteditor/main/app/controller/Links.js index 1e034c149..aa04c6039 100644 --- a/apps/documenteditor/main/app/controller/Links.js +++ b/apps/documenteditor/main/app/controller/Links.js @@ -45,7 +45,8 @@ define([ 'documenteditor/main/app/view/NoteSettingsDialog', 'documenteditor/main/app/view/HyperlinkSettingsDialog', 'documenteditor/main/app/view/TableOfContentsSettings', - 'documenteditor/main/app/view/BookmarksDialog' + 'documenteditor/main/app/view/BookmarksDialog', + 'documenteditor/main/app/view/CaptionDialog' ], function () { 'use strict'; @@ -66,7 +67,8 @@ define([ 'links:update': this.onTableContentsUpdate, 'links:notes': this.onNotesClick, 'links:hyperlink': this.onHyperlinkClick, - 'links:bookmarks': this.onBookmarksClick + 'links:bookmarks': this.onBookmarksClick, + 'links:caption': this.onCaptionClick }, 'DocumentHolder': { 'links:contents': this.onTableContents, @@ -332,6 +334,19 @@ define([ })).show(); }, + onCaptionClick: function(btn) { + var me = this; + (new DE.Views.CaptionDialog({ + api: me.api, + handler: function (result, settings) { + if (result == 'ok') { + me.api.asc_AddObjectCaption(settings); + } + Common.NotificationCenter.trigger('edit:complete', me.toolbar); + } + })).show(); + }, + onShowContentControlsActions: function(action, x, y) { var menu = (action==1) ? this.view.contentsUpdateMenu : this.view.contentsMenu, documentHolderView = this.getApplication().getController('DocumentHolder').documentHolder, diff --git a/apps/documenteditor/main/app/template/Toolbar.template b/apps/documenteditor/main/app/template/Toolbar.template index e9d7ae2c0..c50e0c0e7 100644 --- a/apps/documenteditor/main/app/template/Toolbar.template +++ b/apps/documenteditor/main/app/template/Toolbar.template @@ -152,6 +152,7 @@
+
diff --git a/apps/documenteditor/main/app/view/CaptionDialog.js b/apps/documenteditor/main/app/view/CaptionDialog.js new file mode 100644 index 000000000..d5b06749c --- /dev/null +++ b/apps/documenteditor/main/app/view/CaptionDialog.js @@ -0,0 +1,285 @@ +/* + * + * (c) Copyright Ascensio System SIA 2010-2019 + * + * This program is a free software product. You can redistribute it and/or + * modify it under the terms of the GNU Affero General Public License (AGPL) + * version 3 as published by the Free Software Foundation. In accordance with + * Section 7(a) of the GNU AGPL its Section 15 shall be amended to the effect + * that Ascensio System SIA expressly excludes the warranty of non-infringement + * of any third-party rights. + * + * This program is distributed WITHOUT ANY WARRANTY; without even the implied + * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. For + * details, see the GNU AGPL at: http://www.gnu.org/licenses/agpl-3.0.html + * + * You can contact Ascensio System SIA at 20A-12 Ernesta Birznieka-Upisha + * street, Riga, Latvia, EU, LV-1050. + * + * The interactive user interfaces in modified source and object code versions + * of the Program must display Appropriate Legal Notices, as required under + * Section 5 of the GNU AGPL version 3. + * + * Pursuant to Section 7(b) of the License you must retain the original Product + * logo when distributing the program. Pursuant to Section 7(e) we decline to + * grant you any rights under trademark law for use of our trademarks. + * + * All the Product's GUI elements, including illustrations and icon sets, as + * well as technical writing content are licensed under the terms of the + * Creative Commons Attribution-ShareAlike 4.0 International. See the License + * terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode + * + */ + +/** + * CaptionDialog.js + * + * Created by Julia Radzhabova on 10.09.2019 + * Copyright (c) 2019 Ascensio System SIA. All rights reserved. + * + */ +define([ + 'common/main/lib/util/utils', + 'common/main/lib/component/MetricSpinner', + 'common/main/lib/component/ComboBox', + 'common/main/lib/view/AdvancedSettingsWindow' +], function () { 'use strict'; + + DE.Views.CaptionDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({ + options: { + contentWidth: 351, + height: 330 + }, + + initialize : function(options) { + var me = this; + + _.extend(this.options, { + title: this.textTitle, + template: [ + '
', + '
', + '
', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '', + '
', + '', + '
', + '
', + '', + '
', + '
', + '', + '
', + '
', + '', + '', + '', + '
', + '', + '
', + '
', + '', + '
', + '
', + '
', + '', + '
', + '
', + '', + '
', + '
', + '', + '
', + '
', + '
', + '
', + '' + ].join('') + }, options); + + this.api = options.api; + this.handler = options.handler; + this.props = options.props; + + Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); + }, + + render: function() { + Common.Views.AdvancedSettingsWindow.prototype.render.call(this); + var me = this; + + this.txtCaption = new Common.UI.InputField({ + el : $('#caption-txt-caption'), + allowBlank : false, + value : '' + }); + + this.cmbPosition = new Common.UI.ComboBox({ + el: $('#caption-combo-position'), + cls: 'input-group-nr', + menuStyle: 'min-width: 75px;', + editable: false, + data: [ + { displayValue: this.textBefore, value: Asc.c_oAscFootnotePos.PageBottom }, + { displayValue: this.textAfter, value: Asc.c_oAscFootnotePos.BeneathText } + ] + }); + this.cmbPosition.setValue(Asc.c_oAscFootnotePos.PageBottom); + + this.cmbLabel = new Common.UI.ComboBox({ + el: $('#caption-combo-label'), + cls: 'input-group-nr', + menuStyle: 'min-width: 150px;', + editable: true, + data: [] + }); + + this.btnAdd = new Common.UI.Button({ + el: $('#caption-btn-add'), + disabled: true + }); + // this.btnAdd.on('click', _.bind(this.addLabel, this)); + + this.btnDelete = new Common.UI.Button({ + el: $('#caption-btn-delete'), + disabled: true + }); + // this.btnDelete.on('click', _.bind(this.deleteLabel, this)); + + this.cmbNumbering = new Common.UI.ComboBox({ + el: $('#caption-combo-numbering'), + cls: 'input-group-nr', + menuStyle: 'min-width: 150px;', + editable: false, + data: [ + { displayValue: '1, 2, 3,...', value: Asc.c_oAscNumberingFormat.Decimal, maskExp: /[0-9]/, defValue: 1 }, + { displayValue: 'a, b, c,...', value: Asc.c_oAscNumberingFormat.LowerLetter, maskExp: /[a-z]/, defValue: 'a' }, + { displayValue: 'A, B, C,...', value: Asc.c_oAscNumberingFormat.UpperLetter, maskExp: /[A-Z]/, defValue: 'A' }, + { displayValue: 'i, ii, iii,...', value: Asc.c_oAscNumberingFormat.LowerRoman, maskExp: /[ivxlcdm]/, defValue: 'i' }, + { displayValue: 'I, II, III,...', value: Asc.c_oAscNumberingFormat.UpperRoman, maskExp: /[IVXLCDM]/, defValue: 'I' } + ] + }); + this.cmbNumbering.setValue(Asc.c_oAscNumberingFormat.Decimal); + // this.cmbNumbering.on('selected', _.bind(this.onFormatSelect, this)); + + this.chChapter = new Common.UI.CheckBox({ + el: $('#caption-checkbox-chapter'), + labelText: this.textChapterInc + }); + this.chChapter.on('change', function(field, newValue, oldValue) { + me.cmbChapter.setDisabled(newValue!=='checked'); + me.cmbSeparator.setDisabled(newValue!=='checked'); + }); + + this.cmbChapter = new Common.UI.ComboBox({ + el: $('#caption-combo-chapter'), + cls: 'input-group-nr', + menuStyle: 'min-width: 150px;', + editable: false, + disabled: true, + data: [] + }); + // this.cmbChapter.setValue(0); + // this.cmbChapter.on('selected', _.bind(this.onFormatSelect, this)); + + this.cmbSeparator = new Common.UI.ComboBox({ + el: $('#caption-combo-separator'), + cls: 'input-group-nr', + menuStyle: 'min-width: 150px;', + editable: false, + disabled: true, + data: [ + { displayValue: '- (' + this.textHyphen + ')', value: Asc.c_oAscTabLeader.Hyphen }, + { displayValue: '. (' + this.textPeriod + ')', value: Asc.c_oAscTabLeader.Dot }, + { displayValue: ': (' + this.textColon + ')', value: Asc.c_oAscTabLeader.Hyphen }, + { displayValue: '-- (' + this.textLongDash + ')', value: Asc.c_oAscTabLeader.Hyphen }, + { displayValue: '-- (' + this.textDash + ')', value: Asc.c_oAscTabLeader.Hyphen } + ] + }); + // this.cmbSeparator.setValue(Asc.c_oAscNumberingFormat.Decimal); + // this.cmbSeparator.on('selected', _.bind(this.onFormatSelect, this)); + + this.lblExample = this.$window.find('#caption-label-example'); + + this.afterRender(); + }, + + afterRender: function() { + this._setDefaults(this.props); + }, + + show: function() { + Common.Views.AdvancedSettingsWindow.prototype.show.apply(this, arguments); + }, + + _setDefaults: function (props) { + if (props) { + } + }, + + getSettings: function () { + return {}; + }, + + onDlgBtnClick: function(event) { + this._handleInput((typeof(event) == 'object') ? event.currentTarget.attributes['result'].value : event); + }, + + onPrimary: function() { + this._handleInput('insert'); + return false; + }, + + _handleInput: function(state) { + this.handler && this.handler.call(this, state, (state == 'ok') ? this.getSettings() : undefined); + this.close(); + }, + + textTitle: 'Insert Caption', + textCaption: 'Caption', + textInsert: 'Insert', + textLabel: 'Label', + textAdd: 'Add label', + textDelete: 'Delete label', + textNumbering: 'Numbering', + textChapterInc: 'Include chapter number', + textChapter: 'Chapter starts with style', + textSeparator: 'Use separator', + textExamples: 'Examples: Table 2-A, Image 1.IV', + textBefore: 'Before', + textAfter: 'After', + textHyphen: 'hyphen', + textPeriod: 'period', + textColon: 'colon', + textLongDash: 'em-dash', + textDash: 'en-dash' + + }, DE.Views.CaptionDialog || {})) +}); \ No newline at end of file diff --git a/apps/documenteditor/main/app/view/Links.js b/apps/documenteditor/main/app/view/Links.js index c9b83f9d4..25792eeab 100644 --- a/apps/documenteditor/main/app/view/Links.js +++ b/apps/documenteditor/main/app/view/Links.js @@ -105,6 +105,10 @@ define([ this.btnBookmarks.on('click', function (b, e) { me.fireEvent('links:bookmarks'); }); + + this.btnCaption.on('click', function (b, e) { + me.fireEvent('links:caption'); + }); } return { @@ -147,6 +151,15 @@ define([ Common.Utils.injectComponent($host.find('#slot-btn-bookmarks'), this.btnBookmarks); this.paragraphControls.push(this.btnBookmarks); + this.btnCaption = new Common.UI.Button({ + cls: 'btn-toolbar x-huge icon-top', + iconCls: 'btn-bookmarks', + caption: this.capBtnCaption, + disabled: true + }); + Common.Utils.injectComponent($host.find('#slot-btn-caption'), this.btnCaption); + this.paragraphControls.push(this.btnCaption); + this._state = {disabled: false}; Common.NotificationCenter.on('app:ready', this.onAppReady.bind(this)); }, @@ -242,6 +255,7 @@ define([ }); me.btnBookmarks.updateHint(me.tipBookmarks); + me.btnCaption.updateHint(me.tipCaption); setEvents.call(me); }); @@ -283,7 +297,9 @@ define([ capBtnInsLink: 'Hyperlink', tipInsertHyperlink: 'Add Hyperlink', capBtnBookmarks: 'Bookmark', - tipBookmarks: 'Create a bookmark' + tipBookmarks: 'Create a bookmark', + capBtnCaption: 'Caption', + tipCaption: 'Insert caption' } }()), DE.Views.Links || {})); }); \ No newline at end of file From a21cb5c6acbe23850170fb6950f672dce35f124e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 12 Sep 2019 11:29:49 +0300 Subject: [PATCH 02/13] [DE] Apply caption properties --- apps/common/main/resources/less/toolbar.less | 1 + .../main/app/view/CaptionDialog.js | 125 ++++++++++++++---- apps/documenteditor/main/app/view/Links.js | 2 +- 3 files changed, 102 insertions(+), 26 deletions(-) diff --git a/apps/common/main/resources/less/toolbar.less b/apps/common/main/resources/less/toolbar.less index 48138ef7b..985dec8ee 100644 --- a/apps/common/main/resources/less/toolbar.less +++ b/apps/common/main/resources/less/toolbar.less @@ -530,6 +530,7 @@ .button-normal-icon(btn-func-math, 73, @toolbar-big-icon-size); .button-normal-icon(btn-more, 74, @toolbar-big-icon-size); .button-normal-icon(btn-pagenum, 75, @toolbar-big-icon-size); +.button-normal-icon(btn-caption, 76, @toolbar-big-icon-size); .button-normal-icon(btn-calculation, 80, @toolbar-big-icon-size); [applang=ru] { diff --git a/apps/documenteditor/main/app/view/CaptionDialog.js b/apps/documenteditor/main/app/view/CaptionDialog.js index d5b06749c..d647b74f9 100644 --- a/apps/documenteditor/main/app/view/CaptionDialog.js +++ b/apps/documenteditor/main/app/view/CaptionDialog.js @@ -147,19 +147,48 @@ define([ menuStyle: 'min-width: 75px;', editable: false, data: [ - { displayValue: this.textBefore, value: Asc.c_oAscFootnotePos.PageBottom }, - { displayValue: this.textAfter, value: Asc.c_oAscFootnotePos.BeneathText } + { displayValue: this.textBefore, value: 1 }, + { displayValue: this.textAfter, value: 0 } ] }); - this.cmbPosition.setValue(Asc.c_oAscFootnotePos.PageBottom); + this.cmbPosition.setValue(0); + this.cmbPosition.on('selected', function(combo, record) { + me.props.put_Before(!!record.value); + }); + + var arr = Common.Utils.InternalSettings.get("de-settings-captions"); + if (arr==null || arr==undefined) { + arr = Common.localStorage.getItem("de-settings-captions") || ''; + Common.Utils.InternalSettings.set("de-settings-captions", arr); + } + arr = arr ? arr.split(';') : []; + arr = _.map(arr, function(str){ return { displayValue: str, value: 1 }; }); + + // 0, -1 - not removable + this.arrLabel = [{ displayValue: this.textNone, value: -1 }].concat(arr) + .concat([{ displayValue: this.textEquation, value: 0 }, + { displayValue: this.textFigure, value: 0 }, + { displayValue: this.textTable, value: 0 } + ]); this.cmbLabel = new Common.UI.ComboBox({ el: $('#caption-combo-label'), cls: 'input-group-nr', - menuStyle: 'min-width: 150px;', + menuStyle: 'min-width: 160px;max-height:135px;', editable: true, - data: [] + data: this.arrLabel }); + this.cmbLabel.on('selected', function(combo, record) { + me.props.put_ExcludeLabel(record.value==-1); + if (record.value>=0) + me.props.put_Label(record.displayValue); + me.props.updateName(); + me.txtCaption.setValue(me.props.get_Name()); + var custom = (record.value==1); + me.btnAdd.setDisabled(true); + me.btnDelete.setDisabled(!custom); + }); + this.cmbLabel.selectRecord(this.cmbLabel.store.at(this.arrLabel.length-1)); this.btnAdd = new Common.UI.Button({ el: $('#caption-btn-add'), @@ -171,12 +200,13 @@ define([ el: $('#caption-btn-delete'), disabled: true }); - // this.btnDelete.on('click', _.bind(this.deleteLabel, this)); + this.btnDelete.on('click', function() { + }); this.cmbNumbering = new Common.UI.ComboBox({ el: $('#caption-combo-numbering'), cls: 'input-group-nr', - menuStyle: 'min-width: 150px;', + menuStyle: 'min-width: 160px;', editable: false, data: [ { displayValue: '1, 2, 3,...', value: Asc.c_oAscNumberingFormat.Decimal, maskExp: /[0-9]/, defValue: 1 }, @@ -187,44 +217,64 @@ define([ ] }); this.cmbNumbering.setValue(Asc.c_oAscNumberingFormat.Decimal); - // this.cmbNumbering.on('selected', _.bind(this.onFormatSelect, this)); + this.cmbNumbering.on('selected', function(combo, record) { + me.props.put_Format(record.value); + me.props.updateName(); + me.txtCaption.setValue(me.props.get_Name()); + }); this.chChapter = new Common.UI.CheckBox({ el: $('#caption-checkbox-chapter'), labelText: this.textChapterInc }); this.chChapter.on('change', function(field, newValue, oldValue) { + me.props.put_IncludeChapterNumber(newValue=='checked'); + me.props.updateName(); + me.txtCaption.setValue(me.props.get_Name()); me.cmbChapter.setDisabled(newValue!=='checked'); me.cmbSeparator.setDisabled(newValue!=='checked'); }); + var _main = DE.getController('Main'); + this._arrLevel = []; + for (var i=0; i<9; i++) { + this._arrLevel.push({displayValue: _main['txtStyle_Heading_' + (i+1)], value: i}); + } this.cmbChapter = new Common.UI.ComboBox({ el: $('#caption-combo-chapter'), cls: 'input-group-nr', - menuStyle: 'min-width: 150px;', + menuStyle: 'min-width: 160px;max-height:135px;', editable: false, disabled: true, - data: [] + data: this._arrLevel + }); + this.cmbChapter.setValue(0); + this.cmbChapter.on('selected', function(combo, record) { + me.props.put_HeadingLvl(record.value); + me.props.updateName(); + me.txtCaption.setValue(me.props.get_Name()); }); - // this.cmbChapter.setValue(0); - // this.cmbChapter.on('selected', _.bind(this.onFormatSelect, this)); this.cmbSeparator = new Common.UI.ComboBox({ el: $('#caption-combo-separator'), cls: 'input-group-nr', - menuStyle: 'min-width: 150px;', + menuStyle: 'min-width: 160px;', editable: false, disabled: true, data: [ - { displayValue: '- (' + this.textHyphen + ')', value: Asc.c_oAscTabLeader.Hyphen }, - { displayValue: '. (' + this.textPeriod + ')', value: Asc.c_oAscTabLeader.Dot }, - { displayValue: ': (' + this.textColon + ')', value: Asc.c_oAscTabLeader.Hyphen }, - { displayValue: '-- (' + this.textLongDash + ')', value: Asc.c_oAscTabLeader.Hyphen }, - { displayValue: '-- (' + this.textDash + ')', value: Asc.c_oAscTabLeader.Hyphen } + { displayValue: '- (' + this.textHyphen + ')', value: '-' }, + { displayValue: '. (' + this.textPeriod + ')', value: '.' }, + { displayValue: ': (' + this.textColon + ')', value: ':' }, + { displayValue: '— (' + this.textLongDash + ')', value: '—' }, + { displayValue: '– (' + this.textDash + ')', value: '–' } ] }); - // this.cmbSeparator.setValue(Asc.c_oAscNumberingFormat.Decimal); - // this.cmbSeparator.on('selected', _.bind(this.onFormatSelect, this)); + this.cmbSeparator.setValue('-'); + this.cmbSeparator.on('selected', function(combo, record) { + me.props.put_Separator(record.value); + me.props.updateName(); + me.txtCaption.setValue(me.props.get_Name()); + }); this.lblExample = this.$window.find('#caption-label-example'); @@ -239,13 +289,34 @@ define([ Common.Views.AdvancedSettingsWindow.prototype.show.apply(this, arguments); }, + close: function() { + var val = _.pluck(_.where(this.arrLabel, {value: 1}), 'displayValue').join(';'); + Common.localStorage.setItem("de-settings-captions", val); + Common.Utils.InternalSettings.set("de-settings-captions", val); + + Common.Views.AdvancedSettingsWindow.prototype.close.apply(this, arguments); + }, + _setDefaults: function (props) { - if (props) { - } + this.props = new Asc.CAscCaptionProperties(); + this.props.put_Before(!!this.cmbPosition.getValue()); + var value = this.cmbLabel.getValue(); + this.props.put_ExcludeLabel(value==-1); + if (value>=0) + this.props.put_Label(this.cmbLabel.getDisplayValue(this.cmbLabel.getSelectedRecord())); + this.btnDelete.setDisabled(value!=1); + + this.props.put_ExcludeLabel = prot["put_ExcludeLabel"] = function(v){this.ExcludeLabel = v;}; + this.props.put_Format(this.cmbNumbering.getValue()); + this.props.put_IncludeChapterNumber(this.chChapter.getValue()=='checked'); + this.props.put_HeadingLvl(this.cmbChapter.getValue()); + this.props.put_Separator(this.cmbSeparator.getValue()); + this.props.updateName(); + this.txtCaption.setValue(this.props.get_Name()); }, getSettings: function () { - return {}; + return this.props ; }, onDlgBtnClick: function(event) { @@ -278,8 +349,12 @@ define([ textHyphen: 'hyphen', textPeriod: 'period', textColon: 'colon', - textLongDash: 'em-dash', - textDash: 'en-dash' + textLongDash: 'long dash', + textDash: 'dash', + textNone: 'None', + textEquation: 'Equation', + textFigure: 'Figure', + textTable: 'Table' }, DE.Views.CaptionDialog || {})) }); \ No newline at end of file diff --git a/apps/documenteditor/main/app/view/Links.js b/apps/documenteditor/main/app/view/Links.js index 25792eeab..1513792fe 100644 --- a/apps/documenteditor/main/app/view/Links.js +++ b/apps/documenteditor/main/app/view/Links.js @@ -153,7 +153,7 @@ define([ this.btnCaption = new Common.UI.Button({ cls: 'btn-toolbar x-huge icon-top', - iconCls: 'btn-bookmarks', + iconCls: 'btn-caption', caption: this.capBtnCaption, disabled: true }); From cf59eb889597fef2ea34cd6ab5c1e897597a1cb5 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 12 Sep 2019 12:20:50 +0300 Subject: [PATCH 03/13] [DE] Change caption settings --- .../main/app/controller/Links.js | 12 +++-- .../main/app/view/CaptionDialog.js | 54 +++++++++++-------- 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/apps/documenteditor/main/app/controller/Links.js b/apps/documenteditor/main/app/controller/Links.js index aa04c6039..f6d37fd4c 100644 --- a/apps/documenteditor/main/app/controller/Links.js +++ b/apps/documenteditor/main/app/controller/Links.js @@ -78,7 +78,8 @@ define([ }, onLaunch: function () { this._state = { - prcontrolsdisable:undefined + prcontrolsdisable:undefined, + in_object: false }; Common.Gateway.on('setactionlink', function (url) { console.log('url with actions: ' + url); @@ -127,7 +128,8 @@ define([ header_locked = false, in_header = false, in_equation = false, - in_image = false; + in_image = false, + in_table = false; while (++i < selectedObjects.length) { type = selectedObjects[i].get_ObjectType(); @@ -142,10 +144,12 @@ define([ in_image = true; } else if (type === Asc.c_oAscTypeSelectElement.Math) { in_equation = true; + } else if (type === Asc.c_oAscTypeSelectElement.Table) { + in_table = true; } } - this._state.prcontrolsdisable = paragraph_locked || header_locked; + this._state.in_object = in_image || in_table || in_equation; var control_props = this.api.asc_IsContentControl() ? this.api.asc_GetContentControlProperties() : null, control_plain = (control_props) ? (control_props.get_ContentControlType()==Asc.c_oAscSdtLevelType.Inline) : false; @@ -337,7 +341,7 @@ define([ onCaptionClick: function(btn) { var me = this; (new DE.Views.CaptionDialog({ - api: me.api, + isObject: this._state.in_object, handler: function (result, settings) { if (result == 'ok') { me.api.asc_AddObjectCaption(settings); diff --git a/apps/documenteditor/main/app/view/CaptionDialog.js b/apps/documenteditor/main/app/view/CaptionDialog.js index d647b74f9..68b63cddc 100644 --- a/apps/documenteditor/main/app/view/CaptionDialog.js +++ b/apps/documenteditor/main/app/view/CaptionDialog.js @@ -48,7 +48,7 @@ define([ DE.Views.CaptionDialog = Common.Views.AdvancedSettingsWindow.extend(_.extend({ options: { contentWidth: 351, - height: 330 + height: 350 }, initialize : function(options) { @@ -83,6 +83,11 @@ define([ '', '', '', + '', + '', + '
', + '', + '', '', '', '', @@ -124,7 +129,7 @@ define([ ].join('') }, options); - this.api = options.api; + this.isObject = options.isObject; this.handler = options.handler; this.props = options.props; @@ -146,6 +151,7 @@ define([ cls: 'input-group-nr', menuStyle: 'min-width: 75px;', editable: false, + disabled: !this.isObject, data: [ { displayValue: this.textBefore, value: 1 }, { displayValue: this.textAfter, value: 0 } @@ -162,14 +168,13 @@ define([ Common.Utils.InternalSettings.set("de-settings-captions", arr); } arr = arr ? arr.split(';') : []; - arr = _.map(arr, function(str){ return { displayValue: str, value: 1 }; }); + arr = _.map(arr, function(str){ return { displayValue: str, value: str, type: 1 }; }); - // 0, -1 - not removable - this.arrLabel = [{ displayValue: this.textNone, value: -1 }].concat(arr) - .concat([{ displayValue: this.textEquation, value: 0 }, - { displayValue: this.textFigure, value: 0 }, - { displayValue: this.textTable, value: 0 } - ]); + // 0 - not removable + this.arrLabel = arr.concat([{ displayValue: this.textEquation, value: this.textEquation, type: 0 }, + { displayValue: this.textFigure, value: this.textFigure, type: 0 }, + { displayValue: this.textTable, value: this.textTable, type: 0 } + ]); this.cmbLabel = new Common.UI.ComboBox({ el: $('#caption-combo-label'), @@ -179,12 +184,10 @@ define([ data: this.arrLabel }); this.cmbLabel.on('selected', function(combo, record) { - me.props.put_ExcludeLabel(record.value==-1); - if (record.value>=0) - me.props.put_Label(record.displayValue); + me.props.put_Label(record.value); me.props.updateName(); me.txtCaption.setValue(me.props.get_Name()); - var custom = (record.value==1); + var custom = (record.type==1); me.btnAdd.setDisabled(true); me.btnDelete.setDisabled(!custom); }); @@ -203,6 +206,16 @@ define([ this.btnDelete.on('click', function() { }); + this.chExclude = new Common.UI.CheckBox({ + el: $('#caption-checkbox-exclude'), + labelText: this.textExclude + }); + this.chExclude.on('change', function(field, newValue, oldValue) { + me.props.put_ExcludeLabel(newValue=='checked'); + me.props.updateName(); + me.txtCaption.setValue(me.props.get_Name()); + }); + this.cmbNumbering = new Common.UI.ComboBox({ el: $('#caption-combo-numbering'), cls: 'input-group-nr', @@ -300,13 +313,10 @@ define([ _setDefaults: function (props) { this.props = new Asc.CAscCaptionProperties(); this.props.put_Before(!!this.cmbPosition.getValue()); - var value = this.cmbLabel.getValue(); - this.props.put_ExcludeLabel(value==-1); - if (value>=0) - this.props.put_Label(this.cmbLabel.getDisplayValue(this.cmbLabel.getSelectedRecord())); - this.btnDelete.setDisabled(value!=1); - - this.props.put_ExcludeLabel = prot["put_ExcludeLabel"] = function(v){this.ExcludeLabel = v;}; + this.props.put_Label(this.cmbLabel.getValue()); + var value = this.cmbLabel.getSelectedRecord(); + this.btnDelete.setDisabled(!value || value.type==0); + this.props.put_ExcludeLabel(this.chExclude.getValue()=='checked'); this.props.put_Format(this.cmbNumbering.getValue()); this.props.put_IncludeChapterNumber(this.chChapter.getValue()=='checked'); this.props.put_HeadingLvl(this.cmbChapter.getValue()); @@ -351,10 +361,10 @@ define([ textColon: 'colon', textLongDash: 'long dash', textDash: 'dash', - textNone: 'None', textEquation: 'Equation', textFigure: 'Figure', - textTable: 'Table' + textTable: 'Table', + textExclude: 'Exclude label from caption' }, DE.Views.CaptionDialog || {})) }); \ No newline at end of file From d62145b4843de64b18ff22185ad20550c5bf0d0c Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Fri, 20 Sep 2019 10:08:10 +0300 Subject: [PATCH 04/13] [DE] Caption Dialog (textcaption, add label, delete label) --- .../main/app/view/CaptionDialog.js | 95 ++++++++++++++++--- 1 file changed, 84 insertions(+), 11 deletions(-) diff --git a/apps/documenteditor/main/app/view/CaptionDialog.js b/apps/documenteditor/main/app/view/CaptionDialog.js index 68b63cddc..5ee7f3958 100644 --- a/apps/documenteditor/main/app/view/CaptionDialog.js +++ b/apps/documenteditor/main/app/view/CaptionDialog.js @@ -145,6 +145,9 @@ define([ allowBlank : false, value : '' }); + var $captionInput = this.txtCaption.$el.find('input'); + $captionInput.on('mouseup', _.bind(this.checkStartPosition, this, 'mouse')); + $captionInput.on('keydown', _.bind(this.checkStartPosition, this, 'key')); this.cmbPosition = new Common.UI.ComboBox({ el: $('#caption-combo-position'), @@ -179,32 +182,72 @@ define([ this.cmbLabel = new Common.UI.ComboBox({ el: $('#caption-combo-label'), cls: 'input-group-nr', - menuStyle: 'min-width: 160px;max-height:135px;', + menuStyle: 'min-width: 160px;max-height:155px;', editable: true, - data: this.arrLabel + data: this.arrLabel, + alwaysVisibleY: true }); + this.cmbLabel.scroller = new Common.UI.Scroller({ + el: this.cmbLabel.$el.find('ul'), + useKeyboard: true, + alwaysVisibleY: true + }); + this.cmbLabel.scroller.update({alwaysVisibleY: true}); this.cmbLabel.on('selected', function(combo, record) { - me.props.put_Label(record.value); + var value = record.value; + me.props.put_Label(value); me.props.updateName(); me.txtCaption.setValue(me.props.get_Name()); - var custom = (record.type==1); - me.btnAdd.setDisabled(true); + var custom = (record.type==1), + find = _.findWhere(me.arrLabel, {value: value}) ? true : false; + me.btnAdd.setDisabled(find); me.btnDelete.setDisabled(!custom); + me.currentLabel = value; + me.positionCaption = me.txtCaption.getValue().length; }); + this.cmbLabel.on('changed:before', _.bind(function(field) { + var value = field.getRawValue(), + disebled = _.findWhere(this.arrLabel, {value: value}) ? true : false; + if (!value) { + Common.UI.error({ + msg : this.textLabelError + }); + this.cmbLabel.setValue(this.currentLabel); + disebled = true; + } + this.btnAdd.setDisabled(disebled); + }, this)); this.cmbLabel.selectRecord(this.cmbLabel.store.at(this.arrLabel.length-1)); this.btnAdd = new Common.UI.Button({ el: $('#caption-btn-add'), disabled: true }); - // this.btnAdd.on('click', _.bind(this.addLabel, this)); + this.btnAdd.on('click', _.bind(function (e) { + var value = this.cmbLabel.getRawValue(); + if (value) { + var rec = { displayValue: value, value: value, type: 1 }; + this.arrLabel.unshift(rec); + this.cmbLabel.setData(this.arrLabel); + this.cmbLabel.setValue(value); + this.cmbLabel.trigger('selected', this.cmbLabel, rec); + this.cmbLabel.scroller.update({alwaysVisibleY: true}); + } + }, this)); this.btnDelete = new Common.UI.Button({ el: $('#caption-btn-delete'), disabled: true }); - this.btnDelete.on('click', function() { - }); + this.btnDelete.on('click', _.bind(function (e) { + var value = this.cmbLabel.getValue(); + this.arrLabel = _.reject(this.arrLabel, function (item) { + return item.value === value; + }); + this.cmbLabel.setData(this.arrLabel); + this.cmbLabel.setValue(this.arrLabel[0].value); + this.cmbLabel.trigger('selected', this.cmbLabel, this.arrLabel[0]); + }, this)); this.chExclude = new Common.UI.CheckBox({ el: $('#caption-checkbox-exclude'), @@ -303,7 +346,7 @@ define([ }, close: function() { - var val = _.pluck(_.where(this.arrLabel, {value: 1}), 'displayValue').join(';'); + var val = _.pluck(_.where(this.arrLabel, {type: 1}), 'displayValue').join(';'); Common.localStorage.setItem("de-settings-captions", val); Common.Utils.InternalSettings.set("de-settings-captions", val); @@ -313,7 +356,8 @@ define([ _setDefaults: function (props) { this.props = new Asc.CAscCaptionProperties(); this.props.put_Before(!!this.cmbPosition.getValue()); - this.props.put_Label(this.cmbLabel.getValue()); + var valueLabel = this.cmbLabel.getValue(); + this.props.put_Label(valueLabel); var value = this.cmbLabel.getSelectedRecord(); this.btnDelete.setDisabled(!value || value.type==0); this.props.put_ExcludeLabel(this.chExclude.getValue()=='checked'); @@ -323,6 +367,8 @@ define([ this.props.put_Separator(this.cmbSeparator.getValue()); this.props.updateName(); this.txtCaption.setValue(this.props.get_Name()); + this.currentLabel = valueLabel; + this.positionCaption = this.txtCaption.getValue().length; }, getSettings: function () { @@ -343,6 +389,32 @@ define([ this.close(); }, + checkStartPosition: function (type, event) { + var me = this, + key = event.key, + start = event.target.selectionStart, + end = event.target.selectionEnd; + if (type === 'mouse' || key === 'ArrowLeft' || key === 'ArrowDown') { + setTimeout(function () { + if (start < me.positionCaption + 1) { + event.target.selectionStart = me.positionCaption; + } + }, ); + } else if (key === 'ArrowUp') { + setTimeout(function () { + event.target.selectionStart = me.positionCaption; + }, ); + } else if (key === 'Backspace') { + if ((start === end && start < me.positionCaption + 1) || start < me.positionCaption - 1) { + event.preventDefault(); + } + } else if (key === 'Delete') { + if (start < me.positionCaption - 1) { + event.preventDefault(); + } + } + }, + textTitle: 'Insert Caption', textCaption: 'Caption', textInsert: 'Insert', @@ -364,7 +436,8 @@ define([ textEquation: 'Equation', textFigure: 'Figure', textTable: 'Table', - textExclude: 'Exclude label from caption' + textExclude: 'Exclude label from caption', + textLabelError: 'The entered value is incorrect.' }, DE.Views.CaptionDialog || {})) }); \ No newline at end of file From 3ee9d83b35a20424b645acabaae3a7aabfafbbf5 Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Fri, 20 Sep 2019 13:16:19 +0300 Subject: [PATCH 05/13] [DE] Caption Dialog --- .../main/app/view/CaptionDialog.js | 57 ++++++++++++------- 1 file changed, 35 insertions(+), 22 deletions(-) diff --git a/apps/documenteditor/main/app/view/CaptionDialog.js b/apps/documenteditor/main/app/view/CaptionDialog.js index 5ee7f3958..bbe613afb 100644 --- a/apps/documenteditor/main/app/view/CaptionDialog.js +++ b/apps/documenteditor/main/app/view/CaptionDialog.js @@ -187,12 +187,6 @@ define([ data: this.arrLabel, alwaysVisibleY: true }); - this.cmbLabel.scroller = new Common.UI.Scroller({ - el: this.cmbLabel.$el.find('ul'), - useKeyboard: true, - alwaysVisibleY: true - }); - this.cmbLabel.scroller.update({alwaysVisibleY: true}); this.cmbLabel.on('selected', function(combo, record) { var value = record.value; me.props.put_Label(value); @@ -205,19 +199,25 @@ define([ me.currentLabel = value; me.positionCaption = me.txtCaption.getValue().length; }); - this.cmbLabel.on('changed:before', _.bind(function(field) { - var value = field.getRawValue(), - disebled = _.findWhere(this.arrLabel, {value: value}) ? true : false; - if (!value) { - Common.UI.error({ - msg : this.textLabelError - }); - this.cmbLabel.setValue(this.currentLabel); - disebled = true; - } - this.btnAdd.setDisabled(disebled); + this.cmbLabel.$el.find('input').on('keyup', _.bind(function() { + var value = this.cmbLabel.getRawValue(), + disabled = _.findWhere(this.arrLabel, {value: value}) ? true : false; + this.btnAdd.setDisabled(disabled); }, this)); - this.cmbLabel.selectRecord(this.cmbLabel.store.at(this.arrLabel.length-1)); + var curLabel = Common.Utils.InternalSettings.get("de-settings-current-label"), + recLabel, + findIndLabel; + if (curLabel) { + findIndLabel = _.findIndex(this.arrLabel, function (item) { + return item.value === curLabel; + }); + } + if (curLabel && findIndLabel !== -1) { + recLabel = this.cmbLabel.store.at(findIndLabel); + } else { + recLabel = this.cmbLabel.store.at(this.arrLabel.length-1); + } + this.cmbLabel.selectRecord(recLabel); this.btnAdd = new Common.UI.Button({ el: $('#caption-btn-add'), @@ -225,7 +225,12 @@ define([ }); this.btnAdd.on('click', _.bind(function (e) { var value = this.cmbLabel.getRawValue(); - if (value) { + if (!value || !(/\S/.test(value))) { + Common.UI.error({ + msg : this.textLabelError + }); + this.cmbLabel.setValue(this.currentLabel); + } else { var rec = { displayValue: value, value: value, type: 1 }; this.arrLabel.unshift(rec); this.cmbLabel.setData(this.arrLabel); @@ -372,6 +377,7 @@ define([ }, getSettings: function () { + this.props.put_Additional(this.txtCaption.getValue().substr(this.positionCaption)); return this.props ; }, @@ -386,6 +392,9 @@ define([ _handleInput: function(state) { this.handler && this.handler.call(this, state, (state == 'ok') ? this.getSettings() : undefined); + if (state == 'ok') { + Common.Utils.InternalSettings.set("de-settings-current-label", this.cmbLabel.getValue()); + } this.close(); }, @@ -399,11 +408,11 @@ define([ if (start < me.positionCaption + 1) { event.target.selectionStart = me.positionCaption; } - }, ); - } else if (key === 'ArrowUp') { + }, 0); + } else if (key === 'ArrowUp' || key === 'Home') { setTimeout(function () { event.target.selectionStart = me.positionCaption; - }, ); + }, 0); } else if (key === 'Backspace') { if ((start === end && start < me.positionCaption + 1) || start < me.positionCaption - 1) { event.preventDefault(); @@ -412,6 +421,10 @@ define([ if (start < me.positionCaption - 1) { event.preventDefault(); } + } else { + if (start !== end && start === 0) { + event.preventDefault(); + } } }, From fc956a7bb78a2c0ebf290e395425e6c51b52008e Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Fri, 20 Sep 2019 14:02:46 +0300 Subject: [PATCH 06/13] Fix combobox scroller --- apps/common/main/lib/component/ComboBox.js | 3 --- 1 file changed, 3 deletions(-) diff --git a/apps/common/main/lib/component/ComboBox.js b/apps/common/main/lib/component/ComboBox.js index 02d7cadde..da7d29ee8 100644 --- a/apps/common/main/lib/component/ComboBox.js +++ b/apps/common/main/lib/component/ComboBox.js @@ -253,7 +253,6 @@ define([ this.scroller = new Common.UI.Scroller(_.extend({ el: $('.dropdown-menu', this.cmpEl), minScrollbarLength: 40, - scrollYMarginOffset: 30, includePadding: true, wheelSpeed: 10, alwaysVisibleY: this.scrollAlwaysVisible @@ -278,7 +277,6 @@ define([ this.scroller = new Common.UI.Scroller(_.extend({ el: $('.dropdown-menu', this.cmpEl), minScrollbarLength: 40, - scrollYMarginOffset: 30, includePadding: true, wheelSpeed: 10, alwaysVisibleY: this.scrollAlwaysVisible @@ -643,7 +641,6 @@ define([ this.scroller = new Common.UI.Scroller(_.extend({ el: $('.dropdown-menu', this.cmpEl), minScrollbarLength : 40, - scrollYMarginOffset: 30, includePadding : true, wheelSpeed: 10, alwaysVisibleY: this.scrollAlwaysVisible From 7b88f2c190f4b1c0c23904c8be957abe9543b65c Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Fri, 20 Sep 2019 14:08:50 +0300 Subject: [PATCH 07/13] [DE] Caption Dialog (removed check for missing characters of label) --- apps/documenteditor/main/app/view/CaptionDialog.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/documenteditor/main/app/view/CaptionDialog.js b/apps/documenteditor/main/app/view/CaptionDialog.js index bbe613afb..6c4040f75 100644 --- a/apps/documenteditor/main/app/view/CaptionDialog.js +++ b/apps/documenteditor/main/app/view/CaptionDialog.js @@ -225,7 +225,7 @@ define([ }); this.btnAdd.on('click', _.bind(function (e) { var value = this.cmbLabel.getRawValue(); - if (!value || !(/\S/.test(value))) { + if (!value) { Common.UI.error({ msg : this.textLabelError }); From cf9b79dd245dc6c1142bd6fab3e47eae5d60a2a7 Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Fri, 20 Sep 2019 14:10:28 +0300 Subject: [PATCH 08/13] [DE] Caption Dialog --- apps/documenteditor/main/app/view/CaptionDialog.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/apps/documenteditor/main/app/view/CaptionDialog.js b/apps/documenteditor/main/app/view/CaptionDialog.js index 6c4040f75..e9dfa007d 100644 --- a/apps/documenteditor/main/app/view/CaptionDialog.js +++ b/apps/documenteditor/main/app/view/CaptionDialog.js @@ -230,6 +230,7 @@ define([ msg : this.textLabelError }); this.cmbLabel.setValue(this.currentLabel); + this.btnAdd.setDisabled(true); } else { var rec = { displayValue: value, value: value, type: 1 }; this.arrLabel.unshift(rec); @@ -400,12 +401,10 @@ define([ checkStartPosition: function (type, event) { var me = this, - key = event.key, - start = event.target.selectionStart, - end = event.target.selectionEnd; + key = event.key; if (type === 'mouse' || key === 'ArrowLeft' || key === 'ArrowDown') { setTimeout(function () { - if (start < me.positionCaption + 1) { + if (event.target.selectionStart < me.positionCaption + 1) { event.target.selectionStart = me.positionCaption; } }, 0); @@ -414,15 +413,15 @@ define([ event.target.selectionStart = me.positionCaption; }, 0); } else if (key === 'Backspace') { - if ((start === end && start < me.positionCaption + 1) || start < me.positionCaption - 1) { + if ((event.target.selectionStart === event.target.selectionEnd && event.target.selectionStart < me.positionCaption + 1) || event.target.selectionStart < me.positionCaption - 1) { event.preventDefault(); } } else if (key === 'Delete') { - if (start < me.positionCaption - 1) { + if (event.target.selectionStart < me.positionCaption - 1) { event.preventDefault(); } } else { - if (start !== end && start === 0) { + if (event.target.selectionStart !== event.target.selectionEnd && event.target.selectionStart === 0) { event.preventDefault(); } } From fcc65c820acd9be49234acc199d739befd6eb5c1 Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Fri, 20 Sep 2019 14:55:09 +0300 Subject: [PATCH 09/13] [DE] Caption Dialog (saving labels in json) --- apps/documenteditor/main/app/view/CaptionDialog.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/apps/documenteditor/main/app/view/CaptionDialog.js b/apps/documenteditor/main/app/view/CaptionDialog.js index e9dfa007d..3085b33c3 100644 --- a/apps/documenteditor/main/app/view/CaptionDialog.js +++ b/apps/documenteditor/main/app/view/CaptionDialog.js @@ -170,8 +170,7 @@ define([ arr = Common.localStorage.getItem("de-settings-captions") || ''; Common.Utils.InternalSettings.set("de-settings-captions", arr); } - arr = arr ? arr.split(';') : []; - arr = _.map(arr, function(str){ return { displayValue: str, value: str, type: 1 }; }); + arr = arr ? JSON.parse(arr) : []; // 0 - not removable this.arrLabel = arr.concat([{ displayValue: this.textEquation, value: this.textEquation, type: 0 }, @@ -352,9 +351,10 @@ define([ }, close: function() { - var val = _.pluck(_.where(this.arrLabel, {type: 1}), 'displayValue').join(';'); - Common.localStorage.setItem("de-settings-captions", val); - Common.Utils.InternalSettings.set("de-settings-captions", val); + var val = _.where(this.arrLabel, {type: 1}), + valJson = JSON.stringify(val); + Common.localStorage.setItem("de-settings-captions", valJson); + Common.Utils.InternalSettings.set("de-settings-captions", valJson); Common.Views.AdvancedSettingsWindow.prototype.close.apply(this, arguments); }, From ab44158ee682cc5d31e23945104f491efdeac625 Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Sat, 21 Sep 2019 11:51:15 +0300 Subject: [PATCH 10/13] [DE] Caption Dialog --- .../main/app/view/CaptionDialog.js | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/apps/documenteditor/main/app/view/CaptionDialog.js b/apps/documenteditor/main/app/view/CaptionDialog.js index 3085b33c3..bf8d97d39 100644 --- a/apps/documenteditor/main/app/view/CaptionDialog.js +++ b/apps/documenteditor/main/app/view/CaptionDialog.js @@ -387,7 +387,7 @@ define([ }, onPrimary: function() { - this._handleInput('insert'); + this._handleInput('ok'); return false; }, @@ -412,6 +412,16 @@ define([ setTimeout(function () { event.target.selectionStart = me.positionCaption; }, 0); + } else if (event.target.selectionStart !== event.target.selectionEnd && key === 'ArrowRight') { + if (event.target.selectionEnd > me.positionCaption) { + setTimeout(function () { + event.target.selectionStart = event.target.selectionEnd; + }, 0); + } else { + setTimeout(function () { + event.target.selectionStart = me.positionCaption; + }, 0); + } } else if (key === 'Backspace') { if ((event.target.selectionStart === event.target.selectionEnd && event.target.selectionStart < me.positionCaption + 1) || event.target.selectionStart < me.positionCaption - 1) { event.preventDefault(); @@ -420,7 +430,7 @@ define([ if (event.target.selectionStart < me.positionCaption - 1) { event.preventDefault(); } - } else { + } else if (key !== 'End') { if (event.target.selectionStart !== event.target.selectionEnd && event.target.selectionStart === 0) { event.preventDefault(); } @@ -449,7 +459,7 @@ define([ textFigure: 'Figure', textTable: 'Table', textExclude: 'Exclude label from caption', - textLabelError: 'The entered value is incorrect.' + textLabelError: 'Label must not be empty.' }, DE.Views.CaptionDialog || {})) }); \ No newline at end of file From c983cd662ca9b5b40c89fd6170ba0ebc0b12eb6c Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Sat, 21 Sep 2019 11:52:21 +0300 Subject: [PATCH 11/13] [DE] Caption Dialog (add Insert Caption in context menu) --- .../main/app/view/DocumentHolder.js | 40 ++++++++++++++++++- 1 file changed, 39 insertions(+), 1 deletion(-) diff --git a/apps/documenteditor/main/app/view/DocumentHolder.js b/apps/documenteditor/main/app/view/DocumentHolder.js index a9344feff..aa8405962 100644 --- a/apps/documenteditor/main/app/view/DocumentHolder.js +++ b/apps/documenteditor/main/app/view/DocumentHolder.js @@ -1908,6 +1908,19 @@ define([ me.fireEvent('editcomplete', me); }, + onInsertCaption: function() { + var me = this; + (new DE.Views.CaptionDialog({ + isObject: true, + handler: function (result, settings) { + if (result == 'ok') { + me.api.asc_AddObjectCaption(settings); + } + me.fireEvent('editcomplete', me); + } + })).show(); + }, + onContinueNumbering: function(item, e) { this.api.asc_ContinueNumbering(); this.fireEvent('editcomplete', this); @@ -2052,6 +2065,16 @@ define([ createDelayedElements: function() { var me = this; + var menuInsertCaption = new Common.UI.MenuItem({ + caption : me.txtInsertCaption + }).on('click', _.bind(me.onInsertCaption, me)); + var menuInsertCaptionSeparator = new Common.UI.MenuItem({ caption: '--' }); + + var menuEquationInsertCaption = new Common.UI.MenuItem({ + caption : me.txtInsertCaption + }).on('click', _.bind(me.onInsertCaption, me)); + var menuEquationInsertCaptionSeparator = new Common.UI.MenuItem({ caption: '--' }); + var menuImageAlign = new Common.UI.MenuItem({ caption : me.textAlign, menu : (function(){ @@ -2572,6 +2595,8 @@ define([ menuSignatureEditSign.cmpEl.attr('data-value', signGuid); // sign menuSignatureEditSetup.cmpEl.attr('data-value', signGuid); // edit signature settings } + + menuInsertCaptionSeparator.setVisible(!value.imgProps.isShape); }, items: [ menuImgCut, @@ -2587,6 +2612,8 @@ define([ me.menuImageWrap, menuImgRotate, { caption: '--' }, + menuInsertCaption, + menuInsertCaptionSeparator, me.menuImgCrop, me.menuOriginalSize, menuImgReplace, @@ -2601,6 +2628,10 @@ define([ /* table menu*/ + var menuTableInsertCaption = new Common.UI.MenuItem({ + caption : me.txtInsertCaption + }).on('click', _.bind(me.onInsertCaption, me)); + var mnuTableMerge = new Common.UI.MenuItem({ caption : me.mergeCellsText }).on('click', function(item) { @@ -3226,6 +3257,8 @@ define([ menuTableCellAlign, menuTableDirection, { caption: '--' }, + menuTableInsertCaption, + { caption: '--' }, menuTableAdvanced, { caption: '--' }, /** coauthoring begin **/ @@ -3678,6 +3711,8 @@ define([ } else me.clearEquationMenu(true, 13); menuEquationSeparator.setVisible(isEquation && eqlen>0); + menuEquationInsertCaption.setVisible(isEquation); + menuEquationInsertCaptionSeparator.setVisible(isEquation); menuFrameAdvanced.setVisible(value.paraProps.value.get_FramePr() !== undefined); @@ -3740,6 +3775,8 @@ define([ menuParaCopy, menuParaPaste, menuParaPrint, + menuEquationInsertCaptionSeparator, + menuEquationInsertCaption, { caption: '--' }, menuEquationSeparator, menuParaRemoveControl, @@ -4159,7 +4196,8 @@ define([ toDictionaryText: 'Add to Dictionary', txtPrintSelection: 'Print Selection', textCells: 'Cells', - textSeveral: 'Several Rows/Columns' + textSeveral: 'Several Rows/Columns', + txtInsertCaption: 'Insert Caption' }, DE.Views.DocumentHolder || {})); }); \ No newline at end of file From 56029d174e996a00944c811a9b166d83a153348b Mon Sep 17 00:00:00 2001 From: Julia Svinareva Date: Sat, 21 Sep 2019 11:53:16 +0300 Subject: [PATCH 12/13] [DE] Caption Dialog (add translations) --- apps/documenteditor/main/locale/en.json | 26 ++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/apps/documenteditor/main/locale/en.json b/apps/documenteditor/main/locale/en.json index 54c1de625..f60bd222b 100644 --- a/apps/documenteditor/main/locale/en.json +++ b/apps/documenteditor/main/locale/en.json @@ -1296,6 +1296,7 @@ "DE.Views.DocumentHolder.vertAlignText": "Vertical Alignment", "DE.Views.DocumentHolder.textCells": "Cells", "DE.Views.DocumentHolder.textSeveral": "Several Rows/Columns", + "DE.Views.DocumentHolder.txtInsertCaption": "Insert Caption", "DE.Views.DropcapSettingsAdvanced.cancelButtonText": "Cancel", "DE.Views.DropcapSettingsAdvanced.okButtonText": "OK", "DE.Views.DropcapSettingsAdvanced.strBorders": "Borders & Fill", @@ -2278,5 +2279,28 @@ "DE.Views.WatermarkSettingsDialog.textTransparency": "Semitransparent", "DE.Views.WatermarkSettingsDialog.textUnderline": "Underline", "DE.Views.WatermarkSettingsDialog.tipFontName": "Font Name", - "DE.Views.WatermarkSettingsDialog.tipFontSize": "Font Size" + "DE.Views.WatermarkSettingsDialog.tipFontSize": "Font Size", + "DE.Views.CaptionDialog.textTitle": "Insert Caption", + "DE.Views.CaptionDialog.textCaption": "Caption", + "DE.Views.CaptionDialog.textInsert": "Insert", + "DE.Views.CaptionDialog.textLabel": "Label", + "DE.Views.CaptionDialog.textAdd": "Add label", + "DE.Views.CaptionDialog.textDelete": "Delete label", + "DE.Views.CaptionDialog.textNumbering": "Numbering", + "DE.Views.CaptionDialog.textChapterInc": "Include chapter number", + "DE.Views.CaptionDialog.textChapter": "Chapter starts with style", + "DE.Views.CaptionDialog.textSeparator": "Use separator", + "DE.Views.CaptionDialog.textExamples": "Examples: Table 2-A, Image 1.IV", + "DE.Views.CaptionDialog.textBefore": "Before", + "DE.Views.CaptionDialog.textAfter": "After", + "DE.Views.CaptionDialog.textHyphen": "hyphen", + "DE.Views.CaptionDialog.textPeriod": "period", + "DE.Views.CaptionDialog.textColon": "colon", + "DE.Views.CaptionDialog.textLongDash": "long dash", + "DE.Views.CaptionDialog.textDash": "dash", + "DE.Views.CaptionDialog.textEquation": "Equation", + "DE.Views.CaptionDialog.textFigure": "Figure", + "DE.Views.CaptionDialog.textTable": "Table", + "DE.Views.CaptionDialog.textExclude": "Exclude label from caption", + "DE.Views.CaptionDialog.textLabelError": "Label must not be empty." } \ No newline at end of file From 47181e6835b3e1da1788b47d5b3d14322c035a55 Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 26 Sep 2019 12:25:13 +0300 Subject: [PATCH 13/13] [DE] Fix context menu --- apps/documenteditor/main/app/view/DocumentHolder.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/apps/documenteditor/main/app/view/DocumentHolder.js b/apps/documenteditor/main/app/view/DocumentHolder.js index aa8405962..a6ac1439f 100644 --- a/apps/documenteditor/main/app/view/DocumentHolder.js +++ b/apps/documenteditor/main/app/view/DocumentHolder.js @@ -2557,7 +2557,7 @@ define([ if (menuChartEdit.isVisible()) menuChartEdit.setDisabled(islocked || value.imgProps.value.get_SeveralCharts()); - me.pictureMenu.items[17].setVisible(menuChartEdit.isVisible()); + me.pictureMenu.items[19].setVisible(menuChartEdit.isVisible()); me.menuOriginalSize.setDisabled(islocked || value.imgProps.value.get_ImageUrl()===null || value.imgProps.value.get_ImageUrl()===undefined); menuImageAdvanced.setDisabled(islocked); @@ -2595,8 +2595,6 @@ define([ menuSignatureEditSign.cmpEl.attr('data-value', signGuid); // sign menuSignatureEditSetup.cmpEl.attr('data-value', signGuid); // edit signature settings } - - menuInsertCaptionSeparator.setVisible(!value.imgProps.isShape); }, items: [ menuImgCut, @@ -2990,7 +2988,7 @@ define([ var isEquation= (value.mathProps && value.mathProps.value); - for (var i = 8; i < 25; i++) { + for (var i = 8; i < 27; i++) { me.tableMenu.items[i].setVisible(!isEquation); } @@ -3707,9 +3705,9 @@ define([ //equation menu var eqlen = 0; if (isEquation) { - eqlen = me.addEquationMenu(true, 13); + eqlen = me.addEquationMenu(true, 15); } else - me.clearEquationMenu(true, 13); + me.clearEquationMenu(true, 15); menuEquationSeparator.setVisible(isEquation && eqlen>0); menuEquationInsertCaption.setVisible(isEquation); menuEquationInsertCaptionSeparator.setVisible(isEquation);