Merge branch 'feature/new-settings' into develop
[SSE] Add scaling options
This commit is contained in:
commit
5e38d632a4
Binary file not shown.
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |
Binary file not shown.
Before Width: | Height: | Size: 51 KiB After Width: | Height: | Size: 51 KiB |
|
@ -57,6 +57,9 @@
|
|||
margin-left: -18px;
|
||||
background-position: @menu-check-offset-x @menu-check-offset-y;
|
||||
}
|
||||
&.custom-scale:before {
|
||||
margin-top: 3px;
|
||||
}
|
||||
}
|
||||
|
||||
.menu-item-icon {
|
||||
|
|
|
@ -531,6 +531,7 @@
|
|||
.button-normal-icon(btn-more, 74, @toolbar-big-icon-size);
|
||||
.button-normal-icon(btn-pagenum, 75, @toolbar-big-icon-size);
|
||||
.button-normal-icon(btn-calculation, 80, @toolbar-big-icon-size);
|
||||
.button-normal-icon(btn-scale, 81, @toolbar-big-icon-size);
|
||||
|
||||
[applang=ru] {
|
||||
.btn-toolbar {
|
||||
|
|
|
@ -142,11 +142,9 @@ define([
|
|||
parseFloat(Common.Utils.Metric.fnRecalcFromMM(h).toFixed(2)) + Common.Utils.Metric.getCurrentMetricName() + ')');
|
||||
|
||||
var fitwidth = opt.asc_getFitToWidth(),
|
||||
fitheight = opt.asc_getFitToHeight();
|
||||
if (!fitwidth && !fitheight) panel.cmbLayout.setValue(0);
|
||||
else if (fitwidth && fitheight) panel.cmbLayout.setValue(1);
|
||||
else if (fitwidth && !fitheight) panel.cmbLayout.setValue(2);
|
||||
else panel.cmbLayout.setValue(3);
|
||||
fitheight = opt.asc_getFitToHeight(),
|
||||
fitscale = opt.asc_getScale();
|
||||
this.setScaling(panel, fitwidth, fitheight, fitscale);
|
||||
|
||||
item = panel.cmbPaperOrientation.store.findWhere({value: opt.asc_getOrientation()});
|
||||
if (item) panel.cmbPaperOrientation.setValue(item.get('value'));
|
||||
|
@ -194,9 +192,17 @@ define([
|
|||
opt.asc_setHeight(pageh? parseFloat(pageh[0]) : (this._originalPageSettings ? this._originalPageSettings.asc_getHeight() : undefined));
|
||||
|
||||
var value = panel.cmbLayout.getValue();
|
||||
opt.asc_setFitToWidth(value==1 || value==2);
|
||||
opt.asc_setFitToHeight(value==1 || value==3);
|
||||
|
||||
if (value !== 4) {
|
||||
var fitToWidth = (value==1 || value==2) ? 1 : 0,
|
||||
fitToHeight = (value==1 || value==3) ? 1 : 0;
|
||||
opt.asc_setFitToWidth(fitToWidth);
|
||||
opt.asc_setFitToHeight(fitToHeight);
|
||||
!fitToWidth && !fitToHeight && opt.asc_setScale(100);
|
||||
} else {
|
||||
opt.asc_setFitToWidth(this.fitWidth);
|
||||
opt.asc_setFitToHeight(this.fitHeight);
|
||||
opt.asc_setScale(this.fitScale);
|
||||
}
|
||||
props.asc_setPageSetup(opt);
|
||||
|
||||
opt = new Asc.asc_CPageMargins();
|
||||
|
@ -339,7 +345,7 @@ define([
|
|||
registerControlEvents: function(panel) {
|
||||
panel.cmbPaperSize.on('selected', _.bind(this.propertyChange, this, panel));
|
||||
panel.cmbPaperOrientation.on('selected', _.bind(this.propertyChange, this, panel));
|
||||
panel.cmbLayout.on('selected', _.bind(this.propertyChange, this, panel));
|
||||
panel.cmbLayout.on('selected', _.bind(this.propertyChange, this, panel, 'scale'));
|
||||
panel.spnMarginTop.on('change', _.bind(this.propertyChange, this, panel));
|
||||
panel.spnMarginBottom.on('change', _.bind(this.propertyChange, this, panel));
|
||||
panel.spnMarginLeft.on('change', _.bind(this.propertyChange, this, panel));
|
||||
|
@ -348,9 +354,40 @@ define([
|
|||
panel.chPrintRows.on('change', _.bind(this.propertyChange, this, panel));
|
||||
},
|
||||
|
||||
propertyChange: function(panel) {
|
||||
if (this._changedProps) {
|
||||
this._changedProps[panel.cmbSheet.getValue()] = this.getPageOptions(panel);
|
||||
propertyChange: function(panel, scale, combo, record) {
|
||||
if (scale === 'scale' && record.value === 4) {
|
||||
var me = this,
|
||||
props = (me._changedProps.length > 0 && me._changedProps[panel.cmbSheet.getValue()]) ? me._changedProps[panel.cmbSheet.getValue()] : me.api.asc_getPageOptions(panel.cmbSheet.getValue());
|
||||
var win = new SSE.Views.ScaleDialog({
|
||||
api: me.api,
|
||||
props: props,
|
||||
handler: function(dlg, result) {
|
||||
if (dlg == 'ok') {
|
||||
if (me.api && result) {
|
||||
me.fitWidth = result.width;
|
||||
me.fitHeight = result.height;
|
||||
me.fitScale = result.scale;
|
||||
me.setScaling(panel, me.fitWidth, me.fitHeight, me.fitScale);
|
||||
if (me._changedProps) {
|
||||
me._changedProps[panel.cmbSheet.getValue()] = me.getPageOptions(panel);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var opt = props.asc_getPageSetup(),
|
||||
fitwidth = opt.asc_getFitToWidth(),
|
||||
fitheight = opt.asc_getFitToHeight(),
|
||||
fitscale = opt.asc_getScale();
|
||||
me.setScaling(panel, fitwidth, fitheight, fitscale);
|
||||
}
|
||||
Common.NotificationCenter.trigger('edit:complete');
|
||||
}
|
||||
});
|
||||
win.show();
|
||||
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
|
||||
} else {
|
||||
if (this._changedProps) {
|
||||
this._changedProps[panel.cmbSheet.getValue()] = this.getPageOptions(panel);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -358,6 +395,14 @@ define([
|
|||
return this.adjPrintParams;
|
||||
},
|
||||
|
||||
setScaling: function (panel, width, height, scale) {
|
||||
if (!width && !height && scale === 100) panel.cmbLayout.setValue(0, true);
|
||||
else if (width === 1 && height === 1) panel.cmbLayout.setValue(1, true);
|
||||
else if (width === 1 && !height) panel.cmbLayout.setValue(2, true);
|
||||
else if (!width && height === 1) panel.cmbLayout.setValue(3, true);
|
||||
else panel.cmbLayout.setValue(4, true);
|
||||
},
|
||||
|
||||
warnCheckMargings: 'Margins are incorrect',
|
||||
strAllSheets: 'All Sheets',
|
||||
textWarning: 'Warning',
|
||||
|
|
|
@ -55,7 +55,8 @@ define([
|
|||
'spreadsheeteditor/main/app/view/NameManagerDlg',
|
||||
'spreadsheeteditor/main/app/view/FormatSettingsDialog',
|
||||
'spreadsheeteditor/main/app/view/PageMarginsDialog',
|
||||
'spreadsheeteditor/main/app/view/HeaderFooterDialog'
|
||||
'spreadsheeteditor/main/app/view/HeaderFooterDialog',
|
||||
'spreadsheeteditor/main/app/view/ScaleDialog'
|
||||
], function () { 'use strict';
|
||||
|
||||
SSE.Controllers.Toolbar = Backbone.Controller.extend(_.extend({
|
||||
|
@ -70,7 +71,9 @@ define([
|
|||
|
||||
this.addListeners({
|
||||
'Toolbar': {
|
||||
'change:compact': this.onClickChangeCompact.bind(me)
|
||||
'change:compact': this.onClickChangeCompact.bind(me),
|
||||
'change:scalespn': this.onClickChangeScaleInMenu.bind(me),
|
||||
'click:customscale': this.onScaleClick.bind(me)
|
||||
},
|
||||
'FileMenu': {
|
||||
'menu:hide': me.onFileMenu.bind(me, 'hide'),
|
||||
|
@ -357,6 +360,7 @@ define([
|
|||
toolbar.btnPageOrient.menu.on('item:click', _.bind(this.onPageOrientSelect, this));
|
||||
toolbar.btnPageMargins.menu.on('item:click', _.bind(this.onPageMarginsSelect, this));
|
||||
toolbar.mnuPageSize.on('item:click', _.bind(this.onPageSizeClick, this));
|
||||
toolbar.mnuScale.on('item:click', _.bind(this.onScaleClick, this));
|
||||
toolbar.btnPrintArea.menu.on('item:click', _.bind(this.onPrintAreaClick, this));
|
||||
toolbar.btnPrintArea.menu.on('show:after', _.bind(this.onPrintAreaMenuOpen, this));
|
||||
toolbar.btnImgGroup.menu.on('item:click', _.bind(this.onImgGroupSelect, this));
|
||||
|
@ -1760,6 +1764,7 @@ define([
|
|||
this.onApiPageOrient(opt.asc_getOrientation());
|
||||
this.onApiPageSize(opt.asc_getWidth(), opt.asc_getHeight());
|
||||
this.onApiPageMargins(props.asc_getPageMargins());
|
||||
this.onChangeScaleSettings(opt.asc_getFitToWidth(),opt.asc_getFitToHeight(),opt.asc_getScale());
|
||||
|
||||
this.api.asc_isLayoutLocked(currentSheet) ? this.onApiLockDocumentProps(currentSheet) : this.onApiUnLockDocumentProps(currentSheet);
|
||||
this.toolbar.lockToolbar(SSE.enumLock.printAreaLock, this.api.asc_isPrintAreaLocked(currentSheet), {array: [this.toolbar.btnPrintArea]});
|
||||
|
@ -1822,16 +1827,47 @@ define([
|
|||
}
|
||||
},
|
||||
|
||||
onChangeScaleSettings: function(width, height, scale) {
|
||||
var me = this;
|
||||
if (this.toolbar.btnScale.menu) {
|
||||
this.toolbar.btnScale.menu.clearAll();
|
||||
if (width !== undefined) {
|
||||
if ((width === 0 || width === null) && (height === 0 || height === null) && scale === 100) {
|
||||
this._state.scale = 0;
|
||||
} else if (width === 1 && height === 1) {
|
||||
this._state.scale = 1;
|
||||
} else if (width === 1 && (height === 0 || height === null)) {
|
||||
this._state.scale = 2;
|
||||
} else if ((width === 0 || width === null) && height === 1) {
|
||||
this._state.scale = 3;
|
||||
} else if ((width === 0 || width === null) && (height === 0 || height === null)) {
|
||||
this._state.scale = 4;
|
||||
} else {
|
||||
this._state.scale = 5;
|
||||
}
|
||||
this.toolbar.setValueCustomScale(scale);
|
||||
} else if (scale === undefined) {
|
||||
this.toolbar.setValueCustomScale(this.api.asc_getPageOptions().asc_getPageSetup().asc_getScale());
|
||||
}
|
||||
_.each(this.toolbar.btnScale.menu.items, function(item){
|
||||
if (item.value === me._state.scale) {
|
||||
item.setChecked(true);
|
||||
return false;
|
||||
}
|
||||
}, this);
|
||||
}
|
||||
},
|
||||
|
||||
onApiLockDocumentProps: function(nIndex) {
|
||||
if (this._state.lock_doc!==true && nIndex == this.api.asc_getActiveWorksheetIndex()) {
|
||||
this.toolbar.lockToolbar(SSE.enumLock.docPropsLock, true, {array: [this.toolbar.btnPageSize, this.toolbar.btnPageMargins, this.toolbar.btnPageOrient]});
|
||||
this.toolbar.lockToolbar(SSE.enumLock.docPropsLock, true, {array: [this.toolbar.btnPageSize, this.toolbar.btnPageMargins, this.toolbar.btnPageOrient, this.toolbar.btnScale]});
|
||||
this._state.lock_doc = true;
|
||||
}
|
||||
},
|
||||
|
||||
onApiUnLockDocumentProps: function(nIndex) {
|
||||
if (this._state.lock_doc!==false && nIndex == this.api.asc_getActiveWorksheetIndex()) {
|
||||
this.toolbar.lockToolbar(SSE.enumLock.docPropsLock, false, {array: [this.toolbar.btnPageSize, this.toolbar.btnPageMargins, this.toolbar.btnPageOrient]});
|
||||
this.toolbar.lockToolbar(SSE.enumLock.docPropsLock, false, {array: [this.toolbar.btnPageSize, this.toolbar.btnPageMargins, this.toolbar.btnPageOrient, this.toolbar.btnScale]});
|
||||
this._state.lock_doc = false;
|
||||
}
|
||||
},
|
||||
|
@ -3360,6 +3396,82 @@ define([
|
|||
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
|
||||
},
|
||||
|
||||
onClickChangeScaleInMenu: function(type, curScale) {
|
||||
if (this.api) {
|
||||
var scale;
|
||||
if (type === 'up') {
|
||||
if (curScale % 5 > 0.001) {
|
||||
scale = Math.ceil(curScale / 5) * 5;
|
||||
} else {
|
||||
scale = curScale + 5;
|
||||
}
|
||||
} else {
|
||||
if (curScale % 5 > 0.001) {
|
||||
scale = Math.floor(curScale / 5) * 5;
|
||||
} else {
|
||||
scale = curScale - 5;
|
||||
}
|
||||
}
|
||||
if (scale > 400) {
|
||||
scale = 400;
|
||||
} else if (scale < 10) {
|
||||
scale = 10;
|
||||
}
|
||||
this.api.asc_SetPrintScale(0, 0, scale);
|
||||
this.onChangeScaleSettings(0, 0, scale);
|
||||
}
|
||||
},
|
||||
|
||||
onScaleClick: function(menu, item, event, scale) {
|
||||
var me = this;
|
||||
if (me.api) {
|
||||
if (scale !== undefined) {
|
||||
me.api.asc_SetPrintScale(0, 0, scale);
|
||||
me._state.scale = 4;
|
||||
} else {
|
||||
switch (item.value) {
|
||||
case 0:
|
||||
me.api.asc_SetPrintScale(0, 0, 100);
|
||||
me._state.scale = 0;
|
||||
break;
|
||||
case 1:
|
||||
me.api.asc_SetPrintScale(1, 1, 100);
|
||||
me._state.scale = 1;
|
||||
break;
|
||||
case 2:
|
||||
me.api.asc_SetPrintScale(1, 0, 100);
|
||||
me._state.scale = 2;
|
||||
break;
|
||||
case 3:
|
||||
me.api.asc_SetPrintScale(0, 1, 100);
|
||||
me._state.scale = 3;
|
||||
break;
|
||||
case 5:
|
||||
var win = new SSE.Views.ScaleDialog({
|
||||
api: me.api,
|
||||
props: null,
|
||||
handler: function (dlg, result) {
|
||||
if (dlg == 'ok') {
|
||||
if (me.api && result) {
|
||||
me.api.asc_SetPrintScale(result.width, result.height, result.scale);
|
||||
me.onChangeScaleSettings(result.width, result.height, result.scale);
|
||||
}
|
||||
me._state.scale = 5;
|
||||
} else {
|
||||
me.onChangeScaleSettings();
|
||||
}
|
||||
Common.NotificationCenter.trigger('edit:complete');
|
||||
}
|
||||
});
|
||||
win.show();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
|
||||
},
|
||||
|
||||
textEmptyImgUrl : 'You need to specify image URL.',
|
||||
warnMergeLostData : 'Operation can destroy data in the selected cells.<br>Continue?',
|
||||
textWarning : 'Warning',
|
||||
|
|
|
@ -151,6 +151,7 @@
|
|||
<span class="btn-slot text x-huge" id="slot-btn-pagesize"></span>
|
||||
<span class="btn-slot text x-huge" id="slot-btn-printarea"></span>
|
||||
<span class="btn-slot text x-huge slot-editheader"></span>
|
||||
<span class="btn-slot text x-huge" id="slot-btn-scale"></span>
|
||||
</div>
|
||||
<div class="separator long"></div>
|
||||
<div class="group">
|
||||
|
|
|
@ -361,7 +361,8 @@ define([
|
|||
{ value: 0, displayValue: this.textActualSize },
|
||||
{ value: 1, displayValue: this.textFitPage },
|
||||
{ value: 2, displayValue: this.textFitCols },
|
||||
{ value: 3, displayValue: this.textFitRows }
|
||||
{ value: 3, displayValue: this.textFitRows },
|
||||
{ value: 4, displayValue: this.textCustomOptions}
|
||||
]
|
||||
});
|
||||
|
||||
|
@ -489,7 +490,8 @@ define([
|
|||
textActualSize: 'Actual Size',
|
||||
textFitPage: 'Fit Sheet on One Page',
|
||||
textFitCols: 'Fit All Columns on One Page',
|
||||
textFitRows: 'Fit All Rows on One Page'
|
||||
textFitRows: 'Fit All Rows on One Page',
|
||||
textCustomOptions: 'Custom Options'
|
||||
}, SSE.Views.MainSettingsPrint || {}));
|
||||
|
||||
SSE.Views.FileMenuPanels.MainSettingsGeneral = Common.UI.BaseView.extend(_.extend({
|
||||
|
|
|
@ -213,7 +213,8 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template',
|
|||
{ value: 0, displayValue: this.textActualSize },
|
||||
{ value: 1, displayValue: this.textFitPage },
|
||||
{ value: 2, displayValue: this.textFitCols },
|
||||
{ value: 3, displayValue: this.textFitRows }
|
||||
{ value: 3, displayValue: this.textFitRows },
|
||||
{ value: 4, displayValue: this.textCustomOptions}
|
||||
]
|
||||
});
|
||||
|
||||
|
@ -322,7 +323,8 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template',
|
|||
strShow: 'Show',
|
||||
btnDownload: 'Save & Download',
|
||||
textRange: 'Range',
|
||||
textIgnore: 'Ignore Print Area'
|
||||
textIgnore: 'Ignore Print Area',
|
||||
textCustomOptions: 'Custom Options'
|
||||
|
||||
}, SSE.Views.PrintSettings || {}));
|
||||
});
|
328
apps/spreadsheeteditor/main/app/view/ScaleDialog.js
Normal file
328
apps/spreadsheeteditor/main/app/view/ScaleDialog.js
Normal file
|
@ -0,0 +1,328 @@
|
|||
/*
|
||||
*
|
||||
* (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
|
||||
*
|
||||
*/
|
||||
/**
|
||||
* ScaleDialog.js
|
||||
*
|
||||
* Created by Julia Svinareva on 21/08/19
|
||||
* Copyright (c) 2019 Ascensio System SIA. All rights reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
define([
|
||||
'common/main/lib/component/Window',
|
||||
'common/main/lib/component/MetricSpinner'
|
||||
], function () { 'use strict';
|
||||
|
||||
SSE.Views.ScaleDialog = Common.UI.Window.extend(_.extend({
|
||||
options: {
|
||||
width: 215,
|
||||
header: true,
|
||||
style: 'min-width: 215px;',
|
||||
cls: 'modal-dlg'
|
||||
},
|
||||
|
||||
initialize : function(options) {
|
||||
_.extend(this.options, {
|
||||
title: this.textTitle
|
||||
}, options || {});
|
||||
|
||||
this._state = {
|
||||
width: null,
|
||||
height: null
|
||||
};
|
||||
|
||||
this.template = [
|
||||
'<div class="box">',
|
||||
'<div id="radio-fit-to" style="margin-bottom: 4px;"></div>',
|
||||
'<div style="padding-left: 22px;">',
|
||||
'<div>',
|
||||
'<label style="height: 22px;width: 45px;padding-top: 4px;display: inline-block;margin-bottom: 4px;">' + this.textWidth + '</label>',
|
||||
'<div id="scale-width" style="display: inline-block;margin-bottom: 4px;"></div>',
|
||||
'</div>',
|
||||
'<div>',
|
||||
'<label style="height: 22px;width: 45px;padding-top: 4px;display: inline-block;margin-bottom: 16px;">' + this.textHeight + '</label>',
|
||||
'<div id="scale-height" style="display: inline-block;margin-bottom: 16px;"></div>',
|
||||
'</div>',
|
||||
'</div>',
|
||||
'<div id="radio-scale-to" style="margin-bottom: 6px;"></div>',
|
||||
'<div id="scale" style="padding-left: 22px; margin-bottom: 6px;"></div>',
|
||||
'</div>',
|
||||
'<div class="footer center">',
|
||||
'<button class="btn normal dlg-btn primary" result="ok" style="margin-right: 10px;">' + this.okButtonText + '</button>',
|
||||
'<button class="btn normal dlg-btn" result="cancel">' + this.cancelButtonText + '</button>',
|
||||
'</div>'
|
||||
].join('');
|
||||
|
||||
this.options.tpl = _.template(this.template)(this.options);
|
||||
|
||||
this.api = this.options.api;
|
||||
this._originalProps = this.options.props;
|
||||
|
||||
this.arrDataScale = [
|
||||
{displayValue: this.textAuto, value: 0},
|
||||
{displayValue: '1 ' + this.textOnePage, value: 1},
|
||||
{displayValue: '2 ' + this.textFewPages, value: 2},
|
||||
{displayValue: '3 ' + this.textFewPages, value: 3},
|
||||
{displayValue: '4 ' + this.textFewPages, value: 4},
|
||||
{displayValue: '5 ' + this.textManyPages, value: 5},
|
||||
{displayValue: '6 ' + this.textManyPages, value: 6},
|
||||
{displayValue: '7 ' + this.textManyPages, value: 7},
|
||||
{displayValue: '8 ' + this.textManyPages, value: 8},
|
||||
{displayValue: '9 ' + this.textManyPages, value: 9}
|
||||
];
|
||||
|
||||
Common.UI.Window.prototype.initialize.call(this, this.options);
|
||||
},
|
||||
|
||||
render: function() {
|
||||
Common.UI.Window.prototype.render.call(this);
|
||||
|
||||
this.radioFitTo = new Common.UI.RadioBox({
|
||||
el: $('#radio-fit-to'),
|
||||
labelText: this.textFitTo,
|
||||
name: 'asc-radio-scale'
|
||||
});
|
||||
this.radioFitTo.on('change', _.bind(this.onRadioScale, this, 'fitto'));
|
||||
|
||||
this.radioScaleTo = new Common.UI.RadioBox({
|
||||
el: $('#radio-scale-to'),
|
||||
labelText: this.textScaleTo,
|
||||
name: 'asc-radio-scale'
|
||||
});
|
||||
this.radioScaleTo.on('change', _.bind(this.onRadioScale, this, 'scaleto'));
|
||||
|
||||
this.cmbScaleWidth = new Common.UI.ComboBox({
|
||||
el: $('#scale-width'),
|
||||
cls: 'input-group-nr',
|
||||
style: 'width: 90px;',
|
||||
menuStyle : 'min-width: 90px;',
|
||||
editable: true,
|
||||
data: this.arrDataScale,
|
||||
scrollAlwaysVisible: true
|
||||
}).on('selected', _.bind(function (field) {
|
||||
this._state.width = field.getValue();
|
||||
if ((this._state.width === 0 || this._state.width === null) && (this._state.height === 0 || this._state.height === null)) {
|
||||
this.radioScaleTo.setValue(true, true);
|
||||
} else {
|
||||
this.radioFitTo.setValue(true, true);
|
||||
}
|
||||
}, this))
|
||||
.on('changed:before', _.bind(this.onChangeComboScale, this, 'width'));
|
||||
|
||||
this.cmbScaleHeight = new Common.UI.ComboBox({
|
||||
el: $('#scale-height'),
|
||||
cls: 'input-group-nr',
|
||||
style: 'width: 90px;',
|
||||
menuStyle : 'min-width: 90px;',
|
||||
editable: true,
|
||||
data: this.arrDataScale,
|
||||
scrollAlwaysVisible: true
|
||||
}).on('selected', _.bind(function (field) {
|
||||
this._state.height = field.getValue();
|
||||
if ((this._state.width === 0 || this._state.width === null) && (this._state.height === 0 || this._state.height === null)) {
|
||||
this.radioScaleTo.setValue(true, true);
|
||||
} else {
|
||||
this.radioFitTo.setValue(true, true);
|
||||
}
|
||||
}, this))
|
||||
.on('changed:before', _.bind(this.onChangeComboScale, this, 'height'));
|
||||
|
||||
this.spnScale = new Common.UI.MetricSpinner({
|
||||
el : $('#scale'),
|
||||
step : 1,
|
||||
width : 75,
|
||||
defaultUnit : "%",
|
||||
maxValue : 400,
|
||||
minValue : 10,
|
||||
defaultValue: '100 %'
|
||||
}).on('change', _.bind(function (field) {
|
||||
this.radioScaleTo.setValue(true, true);
|
||||
this.cmbScaleHeight.setValue(0,true);
|
||||
this.cmbScaleWidth.setValue(0,true);
|
||||
this._state.width = 0;
|
||||
this._state.height = 0;
|
||||
}, this));
|
||||
|
||||
var $window = this.getChild();
|
||||
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
|
||||
|
||||
this.afterRender();
|
||||
},
|
||||
|
||||
afterRender: function() {
|
||||
this._setDefaults(this._originalProps);
|
||||
},
|
||||
|
||||
_handleInput: function(state) {
|
||||
if (this.options.handler) {
|
||||
this.options.handler.call(this, state, (state == 'ok') ? this.getSettings() : undefined);
|
||||
}
|
||||
this.close();
|
||||
},
|
||||
|
||||
onBtnClick: function(event) {
|
||||
this._handleInput(event.currentTarget.attributes['result'].value);
|
||||
},
|
||||
|
||||
onPrimary: function() {
|
||||
this._handleInput('ok');
|
||||
return false;
|
||||
},
|
||||
|
||||
onRadioScale: function(type, field, newValue) {
|
||||
if (type === 'scaleto') {
|
||||
this.cmbScaleHeight.setValue(0,true);
|
||||
this._state.height = 0;
|
||||
this.cmbScaleWidth.setValue(0,true);
|
||||
this._state.width = 0;
|
||||
} else {
|
||||
this.cmbScaleHeight.setValue(0,true);
|
||||
this._state.height = 0;
|
||||
this.cmbScaleWidth.setValue(1,true);
|
||||
this._state.width = 1;
|
||||
}
|
||||
},
|
||||
|
||||
_setDefaults: function (props) {
|
||||
if (this.api) {
|
||||
var pageProps = props ? props : this.api.asc_getPageOptions();
|
||||
var pageSetup = pageProps.asc_getPageSetup(),
|
||||
width = pageSetup.asc_getFitToWidth(),
|
||||
height = pageSetup.asc_getFitToHeight(),
|
||||
scale = pageSetup.asc_getScale();
|
||||
this._state.width = (width !== null && width !== 0) ? width : null;
|
||||
this._state.height = (height !== null && height !== 0) ? height : null;
|
||||
|
||||
width = (width !== null) ? width : 0;
|
||||
height = (height !== null) ? height : 0;
|
||||
|
||||
if (width === 0 && height === 0) {
|
||||
this.radioScaleTo.setValue(true,true);
|
||||
} else {
|
||||
this.radioFitTo.setValue(true,true);
|
||||
}
|
||||
|
||||
if (_.findWhere(this.arrDataScale, {value: width})) {
|
||||
this.cmbScaleWidth.setValue(width);
|
||||
} else {
|
||||
this.cmbScaleWidth.setRawValue(width.toString() + ' ' + this.getTextPages(width));
|
||||
}
|
||||
if (_.findWhere(this.arrDataScale, {value: height})) {
|
||||
this.cmbScaleHeight.setValue(height);
|
||||
} else {
|
||||
this.cmbScaleHeight.setRawValue(height.toString() + ' ' + this.getTextPages(height));
|
||||
}
|
||||
|
||||
this.spnScale.setValue((scale !== null) ? scale : '', true);
|
||||
}
|
||||
},
|
||||
|
||||
getSettings: function () {
|
||||
var props = {};
|
||||
props.width = (this._state.width === null) ? null : this._state.width;
|
||||
props.height = (this._state.height === null) ? null : this._state.height;
|
||||
props.scale = this.spnScale.getNumberValue();
|
||||
return props;
|
||||
},
|
||||
|
||||
getTextPages: function (val) {
|
||||
var lastNum = val % 10,
|
||||
textPage;
|
||||
if (lastNum > 0 && lastNum < 1.001) {
|
||||
textPage = this.textOnePage;
|
||||
} else if (lastNum > 0 && lastNum < 4.001) {
|
||||
textPage = this.textFewPages;
|
||||
} else {
|
||||
textPage = this.textManyPages;
|
||||
}
|
||||
return textPage;
|
||||
},
|
||||
|
||||
onChangeComboScale: function(type, combo, record, e) {
|
||||
var me = this,
|
||||
textPage,
|
||||
value = record.value.toLowerCase();
|
||||
var exprAuto = new RegExp('^\\s*(' + me.textAuto.toLowerCase() + ')\\s*$');
|
||||
if (exprAuto.exec(value)) {
|
||||
value = 0;
|
||||
} else {
|
||||
value = parseInt(value);
|
||||
!isNaN(value) && (textPage = me.getTextPages(value));
|
||||
}
|
||||
if (isNaN(value) || value < 0 || value > 32767) {
|
||||
Common.UI.error({
|
||||
msg: me.textError,
|
||||
callback: function() {
|
||||
_.defer(function(btn) {
|
||||
Common.NotificationCenter.trigger('edit:complete', me);
|
||||
})
|
||||
}
|
||||
});
|
||||
value = (type === 'width') ? me._state.width : me._state.height;
|
||||
textPage = me.getTextPages(value);
|
||||
}
|
||||
if (value === null) value = 0;
|
||||
if (type === 'width') {
|
||||
if (_.findWhere(me.arrDataScale, {value: value})) {
|
||||
me.cmbScaleWidth.setValue(value);
|
||||
} else {
|
||||
me.cmbScaleWidth.setValue('');
|
||||
me.cmbScaleWidth.setRawValue(value.toString() + ' ' + textPage);
|
||||
}
|
||||
me._state.width = value;
|
||||
} else if (type === 'height') {
|
||||
if (_.findWhere(me.arrDataScale, {value: value})) {
|
||||
me.cmbScaleHeight.setValue(value);
|
||||
} else {
|
||||
me.cmbScaleHeight.setValue('');
|
||||
me.cmbScaleHeight.setRawValue(value.toString() + ' ' + textPage);
|
||||
}
|
||||
me._state.height = value;
|
||||
}
|
||||
},
|
||||
|
||||
textTitle: 'Scale Settings',
|
||||
cancelButtonText: 'Cancel',
|
||||
okButtonText: 'Ok',
|
||||
textWidth: 'Width',
|
||||
textHeight: 'Height',
|
||||
textAuto: 'Auto',
|
||||
textOnePage: 'page',
|
||||
textFewPages: 'pages',
|
||||
textManyPages: 'pages',
|
||||
textError: 'The entered value is incorrect.',
|
||||
textScaleTo: 'Scale To',
|
||||
textFitTo: 'Fit To'
|
||||
|
||||
}, SSE.Views.ScaleDialog || {}))
|
||||
});
|
|
@ -1337,6 +1337,68 @@ define([
|
|||
})
|
||||
});
|
||||
|
||||
me.mnuCustomScale = new Common.UI.MenuItem({
|
||||
template: _.template([
|
||||
'<div class="checkable custom-scale" style="padding: 5px 20px;font-weight: normal;line-height: 1.42857143;color: #444444;font-size: 11px;height: 32px;"',
|
||||
'<% if(!_.isUndefined(options.stopPropagation)) { %>',
|
||||
'data-stopPropagation="true"',
|
||||
'<% } %>', '>',
|
||||
'<label class="title" style="padding-top: 3px;">' + me.textScale + '</label>',
|
||||
'<button id="custom-scale-up" type="button" style="float:right;" class="btn small btn-toolbar"><i class="icon btn-zoomin"> </i></button>',
|
||||
'<label id="value-custom-scale" style="float:right;padding: 3px 3px;min-width: 40px; text-align: center;"></label>',
|
||||
'<button id="custom-scale-down" type="button" style="float:right;" class="btn small btn-toolbar"><i class="icon btn-zoomout"> </i></button>',
|
||||
'</div>'
|
||||
].join('')),
|
||||
stopPropagation: true,
|
||||
toggleGroup: 'menuScale',
|
||||
checkable: true,
|
||||
value: 4
|
||||
});
|
||||
|
||||
me.btnScale = new Common.UI.Button({
|
||||
id: 'tlbtn-scale',
|
||||
cls: 'btn-toolbar x-huge icon-top',
|
||||
iconCls: 'btn-scale',
|
||||
caption: me.capBtnScale,
|
||||
lock: [_set.docPropsLock, _set.lostConnect, _set.coAuth],
|
||||
menu: new Common.UI.Menu({
|
||||
items: [
|
||||
{
|
||||
caption: me.textActualSize,
|
||||
checkable: true,
|
||||
toggleGroup: 'menuScale',
|
||||
value: 0
|
||||
},
|
||||
{
|
||||
caption: me.textFitSheetOnOnePage,
|
||||
checkable: true,
|
||||
toggleGroup: 'menuScale',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
caption: me.textFitAllColumnsOnOnePage,
|
||||
checkable: true,
|
||||
toggleGroup: 'menuScale',
|
||||
value: 2
|
||||
},
|
||||
{
|
||||
caption: me.textFitAllRowsOnOnePage,
|
||||
checkable: true,
|
||||
toggleGroup: 'menuScale',
|
||||
value: 3
|
||||
},
|
||||
me.mnuCustomScale,
|
||||
{caption: '--'},
|
||||
{ caption: me.textScaleCustom,
|
||||
checkable: true,
|
||||
toggleGroup: 'menuScale',
|
||||
value: 5
|
||||
}
|
||||
]})
|
||||
});
|
||||
me.mnuScale = me.btnScale.menu;
|
||||
me.mnuScale.on('show:after', _.bind(me.onAfterShowMenuScale, me));
|
||||
|
||||
me.btnImgAlign = new Common.UI.Button({
|
||||
cls: 'btn-toolbar x-huge icon-top',
|
||||
iconCls: 'btn-img-align',
|
||||
|
@ -1392,7 +1454,7 @@ define([
|
|||
me.btnInsertChart, me.btnColorSchemas,
|
||||
me.btnCopy, me.btnPaste, me.listStyles, me.btnPrint,
|
||||
/*me.btnSave,*/ me.btnClearStyle, me.btnCopyStyle,
|
||||
me.btnPageMargins, me.btnPageSize, me.btnPageOrient, me.btnPrintArea, me.btnImgAlign, me.btnImgBackward, me.btnImgForward, me.btnImgGroup
|
||||
me.btnPageMargins, me.btnPageSize, me.btnPageOrient, me.btnPrintArea, me.btnImgAlign, me.btnImgBackward, me.btnImgForward, me.btnImgGroup, me.btnScale
|
||||
];
|
||||
|
||||
_.each(me.lockControls.concat([me.btnSave]), function(cmp) {
|
||||
|
@ -1406,6 +1468,43 @@ define([
|
|||
return this;
|
||||
},
|
||||
|
||||
onAfterShowMenuScale: function () {
|
||||
var me = this;
|
||||
if (me.api) {
|
||||
var scale = me.api.asc_getPageOptions().asc_getPageSetup().asc_getScale();
|
||||
$('#value-custom-scale', me.mnuCustomScale.$el).html(scale + '%');
|
||||
me.valueCustomScale = scale;
|
||||
}
|
||||
if (!me.itemCustomScale) {
|
||||
me.itemCustomScale = $('.custom-scale', me.mnuCustomScale.$el).on('click', _.bind(function () {
|
||||
me.fireEvent('click:customscale', [undefined, undefined, undefined, me.valueCustomScale], this);
|
||||
}, this));
|
||||
}
|
||||
if (!me.btnCustomScaleUp) {
|
||||
me.btnCustomScaleUp = new Common.UI.Button({
|
||||
el: $('#custom-scale-up', me.mnuCustomScale.$el),
|
||||
cls: 'btn-toolbar'
|
||||
}).on('click', _.bind(function () {
|
||||
me.fireEvent('change:scalespn', ['up', me.valueCustomScale], this);
|
||||
}, this));
|
||||
}
|
||||
if (!me.btnCustomScaleDown) {
|
||||
me.btnCustomScaleDown = new Common.UI.Button({
|
||||
el: $('#custom-scale-down', me.mnuCustomScale.$el),
|
||||
cls: 'btn-toolbar'
|
||||
}).on('click', _.bind(function () {
|
||||
me.fireEvent('change:scalespn', ['down', me.valueCustomScale], this);
|
||||
}, this));
|
||||
}
|
||||
},
|
||||
|
||||
setValueCustomScale: function(val) {
|
||||
if (this.api && val !== null && val !== undefined) {
|
||||
$('#value-custom-scale', this.mnuCustomScale.$el).html(val + '%');
|
||||
this.valueCustomScale = val;
|
||||
}
|
||||
},
|
||||
|
||||
render: function (mode) {
|
||||
var me = this;
|
||||
|
||||
|
@ -1552,7 +1651,7 @@ define([
|
|||
_injectComponent('#slot-img-group', this.btnImgGroup);
|
||||
_injectComponent('#slot-img-movefrwd', this.btnImgForward);
|
||||
_injectComponent('#slot-img-movebkwd', this.btnImgBackward);
|
||||
|
||||
_injectComponent('#slot-btn-scale', this.btnScale);
|
||||
this.btnsEditHeader = Common.Utils.injectButtons($host.find('.slot-editheader'), 'tlbtn-editheader-', 'btn-editheader', this.capBtnInsHeader,
|
||||
[SSE.enumLock.editCell, SSE.enumLock.selRangeEdit, SSE.enumLock.headerLock, SSE.enumLock.lostConnect, SSE.enumLock.coAuth]);
|
||||
Array.prototype.push.apply(this.lockControls, this.btnsEditHeader);
|
||||
|
@ -1628,6 +1727,7 @@ define([
|
|||
_updateHint(this.btnPageSize, this.tipPageSize);
|
||||
_updateHint(this.btnPageMargins, this.tipPageMargins);
|
||||
_updateHint(this.btnPrintArea, this.tipPrintArea);
|
||||
_updateHint(this.btnScale, this.tipScale);
|
||||
this.btnsEditHeader.forEach(function (btn) {
|
||||
_updateHint(btn, me.tipEditHeader);
|
||||
});
|
||||
|
@ -2354,6 +2454,14 @@ define([
|
|||
textTabData: 'Data',
|
||||
capInsertTable: 'Table',
|
||||
tipInsertTable: 'Insert table',
|
||||
textTabFormula: 'Formula'
|
||||
textTabFormula: 'Formula',
|
||||
capBtnScale: 'Scale to Fit',
|
||||
tipScale: 'Scale to Fit',
|
||||
textActualSize: 'Actual Size',
|
||||
textFitSheetOnOnePage: 'Fit sheet on One Page',
|
||||
textFitAllColumnsOnOnePage: 'Fit All Columns on One Page',
|
||||
textFitAllRowsOnOnePage: 'Fit All Rows on One Page',
|
||||
textScaleCustom: 'Custom',
|
||||
textScale: 'Scale'
|
||||
}, SSE.Views.Toolbar || {}));
|
||||
});
|
|
@ -1759,6 +1759,7 @@
|
|||
"SSE.Views.MainSettingsPrint.textPrintGrid": "Print Gridlines",
|
||||
"SSE.Views.MainSettingsPrint.textPrintHeadings": "Print Row and Column Headings",
|
||||
"SSE.Views.MainSettingsPrint.textSettings": "Settings for",
|
||||
"SSE.Views.MainSettingsPrint.textCustomOptions": "Custom Options",
|
||||
"SSE.Views.NamedRangeEditDlg.cancelButtonText": "Cancel",
|
||||
"SSE.Views.NamedRangeEditDlg.errorCreateDefName": "The existing named ranges cannot be edited and the new ones cannot be created<br>at the moment as some of them are being edited.",
|
||||
"SSE.Views.NamedRangeEditDlg.namePlaceholder": "Defined name",
|
||||
|
@ -1947,6 +1948,7 @@
|
|||
"SSE.Views.PrintSettings.textShowHeadings": "Show Rows and Columns Headings",
|
||||
"SSE.Views.PrintSettings.textTitle": "Print Settings",
|
||||
"SSE.Views.PrintSettings.textTitlePDF": "PDF Settings",
|
||||
"SSE.Views.PrintSettings.textCustomOptions": "Custom Options",
|
||||
"SSE.Views.RightMenu.txtCellSettings": "Cell settings",
|
||||
"SSE.Views.RightMenu.txtChartSettings": "Chart settings",
|
||||
"SSE.Views.RightMenu.txtImageSettings": "Image settings",
|
||||
|
@ -2431,6 +2433,8 @@
|
|||
"SSE.Views.Toolbar.txtTime": "Time",
|
||||
"SSE.Views.Toolbar.txtUnmerge": "Unmerge Cells",
|
||||
"SSE.Views.Toolbar.txtYen": "¥ Yen",
|
||||
"SSE.Views.Toolbar.capBtnScale": "Scale to Fit",
|
||||
"SSE.Views.Toolbar.tipScale": "Scale to Fit",
|
||||
"SSE.Views.Top10FilterDialog.cancelButtonText": "Cancel",
|
||||
"SSE.Views.Top10FilterDialog.okButtonText": "OK",
|
||||
"SSE.Views.Top10FilterDialog.textType": "Show",
|
||||
|
@ -2438,5 +2442,17 @@
|
|||
"SSE.Views.Top10FilterDialog.txtItems": "Item",
|
||||
"SSE.Views.Top10FilterDialog.txtPercent": "Percent",
|
||||
"SSE.Views.Top10FilterDialog.txtTitle": "Top 10 AutoFilter",
|
||||
"SSE.Views.Top10FilterDialog.txtTop": "Top"
|
||||
"SSE.Views.Top10FilterDialog.txtTop": "Top",
|
||||
"SSE.Views.ScaleDialog.textTitle": "Scale Settings",
|
||||
"SSE.Views.ScaleDialog.cancelButtonText": "Cancel",
|
||||
"SSE.Views.ScaleDialog.okButtonText": "Ok",
|
||||
"SSE.Views.ScaleDialog.textWidth": "Width",
|
||||
"SSE.Views.ScaleDialog.textHeight": "Height",
|
||||
"SSE.Views.ScaleDialog.textAuto": "Auto",
|
||||
"SSE.Views.ScaleDialog.textOnePage": "page",
|
||||
"SSE.Views.ScaleDialog.textFewPages": "pages",
|
||||
"SSE.Views.ScaleDialog.textManyPages": "pages",
|
||||
"SSE.Views.ScaleDialog.textError": "The entered value is incorrect.",
|
||||
"SSE.Views.ScaleDialog.textScaleTo": "Scale To",
|
||||
"SSE.Views.ScaleDialog.textFitTo": "Fit To"
|
||||
}
|
Loading…
Reference in a new issue