diff --git a/apps/common/main/lib/component/Window.js b/apps/common/main/lib/component/Window.js index cc4020a78..de1acab33 100644 --- a/apps/common/main/lib/component/Window.js +++ b/apps/common/main/lib/component/Window.js @@ -238,6 +238,14 @@ define([ return {width: width, height: height, top: Common.Utils.InternalSettings.get('window-inactive-area-top')}; } + function _autoSize() { + if (this.initConfig.height == 'auto') { + var height = parseInt(this.$window.find('> .body').css('height')); + this.initConfig.header && (height += parseInt(this.$window.find('> .header').css('height'))); + this.$window.height(height); + } + } + function _centre() { var main_geometry = _readDocumetGeometry(), main_width = main_geometry.width, @@ -658,11 +666,7 @@ define([ }); } - if (this.initConfig.height == 'auto') { - var height = parseInt(this.$window.find('> .body').css('height')); - this.initConfig.header && (height += parseInt(this.$window.find('> .header').css('height'))); - this.$window.height(height); - } else { + if (this.initConfig.height !== 'auto') { this.$window.css('height',this.initConfig.height); } @@ -719,6 +723,7 @@ define([ if (!this.$window) { this.render(); + _autoSize.call(this); if (_.isNumber(x) && _.isNumber(y)) { this.$window.css('left',Math.floor(x)); diff --git a/apps/spreadsheeteditor/main/app/view/CellsAddDialog.js b/apps/common/main/lib/view/OptionsDialog.js similarity index 72% rename from apps/spreadsheeteditor/main/app/view/CellsAddDialog.js rename to apps/common/main/lib/view/OptionsDialog.js index 68fe56f4d..445fabf29 100644 --- a/apps/spreadsheeteditor/main/app/view/CellsAddDialog.js +++ b/apps/common/main/lib/view/OptionsDialog.js @@ -31,9 +31,9 @@ * */ /** - * CellsAddDialog.js + * OptionsDialog.js * - * Created by Julia Radzhabova on 08.05.2020 + * Created by Julia Radzhabova on 15.10.2020 * Copyright (c) 2020 Ascensio System SIA. All rights reserved. * */ @@ -42,13 +42,13 @@ define([ 'common/main/lib/component/RadioBox' ], function () { 'use strict'; - SSE.Views.CellsAddDialog = Common.UI.Window.extend(_.extend({ + Common.Views.OptionsDialog = Common.UI.Window.extend(_.extend({ options: { width: 214, - height: 195, header: true, style: 'min-width: 214px;', cls: 'modal-dlg', + items: [], buttons: ['ok', 'cancel'] }, @@ -57,14 +57,15 @@ define([ this.template = [ '
', - '
', - '
', - '
', - '
', + '<% _.each(items, function(item, index) { %>', + '<% if (!item.id) item.id = Common.UI.getId(); %>', + '
', + '<% }) %>', '
' ].join(''); this.options.tpl = _.template(this.template)(this.options); + this.radio = []; Common.UI.Window.prototype.initialize.call(this, this.options); }, @@ -73,30 +74,32 @@ define([ Common.UI.Window.prototype.render.call(this); var me = this, + $window = me.getChild(), items = this.options.items, - checked = true; + checked = true, + checkedIndex = -1; if (items) { - for (var i=0; i<4; i++) { - var radio = new Common.UI.RadioBox({ - el: $('#cell-ins-radio-' + (i+1)), - labelText: items[i].caption, - name: 'asc-radio-cell-ins', - value: items[i].value, - disabled: items[i].disabled, - checked: checked && !items[i].disabled + for (var i=0; i=0) && this.radio[checkedIndex].setValue(true); } - - var $window = this.getChild(); $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); }, @@ -121,5 +124,5 @@ define([ return false; } - }, SSE.Views.CellsAddDialog || {})) + }, Common.Views.OptionsDialog || {})) }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/controller/DataTab.js b/apps/spreadsheeteditor/main/app/controller/DataTab.js index 46486cd48..bac379324 100644 --- a/apps/spreadsheeteditor/main/app/controller/DataTab.js +++ b/apps/spreadsheeteditor/main/app/controller/DataTab.js @@ -42,9 +42,9 @@ define([ 'core', 'spreadsheeteditor/main/app/view/DataTab', - 'spreadsheeteditor/main/app/view/GroupDialog', 'spreadsheeteditor/main/app/view/SortDialog', - 'spreadsheeteditor/main/app/view/RemoveDuplicatesDialog' + 'spreadsheeteditor/main/app/view/RemoveDuplicatesDialog', + 'common/main/lib/view/OptionsDialog' ], function () { 'use strict'; @@ -131,9 +131,12 @@ define([ } else { var val = me.api.asc_checkAddGroup(true); if (val===null) { - (new SSE.Views.GroupDialog({ + (new Common.Views.OptionsDialog({ title: me.view.capBtnUngroup, - props: 'rows', + items: [ + {caption: this.textRows, value: true, checked: true}, + {caption: this.textColumns, value: false, checked: false} + ], handler: function (dlg, result) { if (result=='ok') { me.api.asc_ungroup(dlg.getSettings()); @@ -160,9 +163,12 @@ define([ var me = this, val = me.api.asc_checkAddGroup(); if (val===null) { - (new SSE.Views.GroupDialog({ + (new Common.Views.OptionsDialog({ title: me.view.capBtnGroup, - props: 'rows', + items: [ + {caption: this.textRows, value: true, checked: true}, + {caption: this.textColumns, value: false, checked: false} + ], handler: function (dlg, result) { if (result=='ok') { me.api.asc_group(dlg.getSettings()); @@ -324,7 +330,9 @@ define([ txtRemDuplicates: 'Remove Duplicates', txtExpandRemDuplicates: 'The data next to the selection will not be removed. Do you want to expand the selection to include the adjacent data or continue with the currently selected cells only?', txtExpand: 'Expand', - txtRemSelected: 'Remove in selected' + txtRemSelected: 'Remove in selected', + textRows: 'Rows', + textColumns: 'Columns' }, SSE.Controllers.DataTab || {})); }); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/app/controller/Toolbar.js b/apps/spreadsheeteditor/main/app/controller/Toolbar.js index f96aecf6a..55e4efeba 100644 --- a/apps/spreadsheeteditor/main/app/controller/Toolbar.js +++ b/apps/spreadsheeteditor/main/app/controller/Toolbar.js @@ -45,6 +45,7 @@ define([ 'common/main/lib/view/ImageFromUrlDialog', 'common/main/lib/view/SelectFileDlg', 'common/main/lib/view/SymbolTableDialog', + 'common/main/lib/view/OptionsDialog', 'common/main/lib/util/define', 'spreadsheeteditor/main/app/view/Toolbar', 'spreadsheeteditor/main/app/collection/TableTemplates', @@ -60,7 +61,6 @@ define([ 'spreadsheeteditor/main/app/view/PrintTitlesDialog', 'spreadsheeteditor/main/app/view/ScaleDialog', 'spreadsheeteditor/main/app/view/SlicerAddDialog', - 'spreadsheeteditor/main/app/view/CellsAddDialog', 'spreadsheeteditor/main/app/view/AdvancedSeparatorDialog' ], function () { 'use strict'; @@ -1571,7 +1571,7 @@ define([ arr = []; for (var i=0; i<4; i++) arr.push({caption: items[i].caption, value: items[i].value, disabled: items[i].isDisabled()}); - (new SSE.Views.CellsAddDialog({ + (new Common.Views.OptionsDialog({ title: me.txtInsertCells, items: arr, handler: function (dlg, result) { @@ -1598,7 +1598,7 @@ define([ arr = []; for (var i=0; i<4; i++) arr.push({caption: items[i].caption, value: items[i].value, disabled: items[i].isDisabled()}); - (new SSE.Views.CellsAddDialog({ + (new Common.Views.OptionsDialog({ title: me.txtDeleteCells, items: arr, handler: function (dlg, result) { diff --git a/apps/spreadsheeteditor/main/app/view/GroupDialog.js b/apps/spreadsheeteditor/main/app/view/GroupDialog.js deleted file mode 100644 index a17971403..000000000 --- a/apps/spreadsheeteditor/main/app/view/GroupDialog.js +++ /dev/null @@ -1,116 +0,0 @@ -/* - * - * (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 - * - */ -/** - * GroupDialog.js - * - * Created by Julia Radzhabova on 30.05.2019 - * Copyright (c) 2019 Ascensio System SIA. All rights reserved. - * - */ -define([ - 'common/main/lib/component/Window', - 'common/main/lib/component/RadioBox' -], function () { 'use strict'; - - SSE.Views.GroupDialog = Common.UI.Window.extend(_.extend({ - options: { - width: 214, - height: 138, - header: true, - style: 'min-width: 214px;', - cls: 'modal-dlg', - buttons: ['ok', 'cancel'] - }, - - initialize : function(options) { - _.extend(this.options, options || {}); - - this.template = [ - '
', - '
', - '
', - '
' - ].join(''); - - this.options.tpl = _.template(this.template)(this.options); - - Common.UI.Window.prototype.initialize.call(this, this.options); - }, - - render: function() { - Common.UI.Window.prototype.render.call(this); - - this.radioRows = new Common.UI.RadioBox({ - el: $('#group-radio-rows'), - labelText: this.textRows, - name: 'asc-radio-group-cells', - checked: this.options.props=='rows' - }); - - this.radioColumns = new Common.UI.RadioBox({ - el: $('#group-radio-cols'), - labelText: this.textColumns, - name: 'asc-radio-group-cells', - checked: this.options.props=='columns' - }); - (this.options.props=='rows') ? this.radioRows.setValue(true) : this.radioColumns.setValue(true); - - var $window = this.getChild(); - $window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this)); - }, - - _handleInput: function(state) { - if (this.options.handler) { - this.options.handler.call(this, this, state); - } - - this.close(); - }, - - onBtnClick: function(event) { - this._handleInput(event.currentTarget.attributes['result'].value); - }, - - getSettings: function() { - return this.radioRows.getValue(); - }, - - onPrimary: function() { - this._handleInput('ok'); - return false; - }, - - textRows: 'Rows', - textColumns: 'Columns' - }, SSE.Views.GroupDialog || {})) -}); \ No newline at end of file diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index 64492ca64..a9209f63f 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -299,6 +299,8 @@ "SSE.Controllers.DataTab.txtExpandRemDuplicates": "The data next to the selection will not be removed. Do you want to expand the selection to include the adjacent data or continue with the currently selected cells only?", "SSE.Controllers.DataTab.txtRemDuplicates": "Remove Duplicates", "SSE.Controllers.DataTab.txtRemSelected": "Remove in selected", + "SSE.Controllers.DataTab.textColumns": "Columns", + "SSE.Controllers.DataTab.textRows": "Rows", "SSE.Controllers.DocumentHolder.alignmentText": "Alignment", "SSE.Controllers.DocumentHolder.centerText": "Center", "SSE.Controllers.DocumentHolder.deleteColumnText": "Delete Column", @@ -1879,8 +1881,8 @@ "SSE.Views.FormulaWizard.textText": "text", "SSE.Views.FormulaWizard.textTitle": "Function Arguments", "SSE.Views.FormulaWizard.textValue": "Formula result", - "SSE.Views.GroupDialog.textColumns": "Columns", - "SSE.Views.GroupDialog.textRows": "Rows", + "del_SSE.Views.GroupDialog.textColumns": "Columns", + "del_SSE.Views.GroupDialog.textRows": "Rows", "SSE.Views.HeaderFooterDialog.textAlign": "Align with page margins", "SSE.Views.HeaderFooterDialog.textAll": "All pages", "SSE.Views.HeaderFooterDialog.textBold": "Bold",