Merge pull request #369 from ONLYOFFICE/feature/sse-print-titles

Feature/sse print titles
Fix Bug 43869
This commit is contained in:
Julia Radzhabova 2020-03-19 16:11:01 +03:00 committed by GitHub
commit 35164b41af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 624 additions and 16 deletions

View file

@ -72,6 +72,7 @@ define([
onAfterRender: function(view) {
this.printSettings.cmbSheet.on('selected', _.bind(this.comboSheetsChange, this, this.printSettings));
this.printSettings.btnOk.on('click', _.bind(this.querySavePrintSettings, this));
this.fillComponents(this.printSettings);
this.registerControlEvents(this.printSettings);
},
@ -110,10 +111,10 @@ define([
},
comboSheetsChange: function(panel, combo, record) {
this.fillPageOptions(panel, this._changedProps[record.value] ? this._changedProps[record.value] : this.api.asc_getPageOptions(record.value));
this.fillPageOptions(panel, this._changedProps[record.value] ? this._changedProps[record.value] : this.api.asc_getPageOptions(record.value, true), record.value);
},
fillPageOptions: function(panel, props) {
fillPageOptions: function(panel, props, sheet) {
var opt = props.asc_getPageSetup();
this._originalPageSettings = opt;
@ -157,6 +158,23 @@ define([
panel.chPrintGrid.setValue(props.asc_getGridLines(), true);
panel.chPrintRows.setValue(props.asc_getHeadings(), true);
var value = props.asc_getPrintTitlesHeight();
panel.txtRangeTop.setValue((value) ? value : '');
panel.txtRangeTop.checkValidate();
panel.dataRangeTop = value;
value = props.asc_getPrintTitlesWidth();
panel.txtRangeLeft.setValue((value) ? value : '');
panel.txtRangeLeft.checkValidate();
panel.dataRangeLeft = value;
value = (this.api.asc_getActiveWorksheetIndex()==sheet);
(panel.btnPresetsTop.menu.items[0].value == 'select') && panel.btnPresetsTop.menu.items[0].setVisible(value);
(panel.btnPresetsLeft.menu.items[0].value == 'select') && panel.btnPresetsLeft.menu.items[0].setVisible(value);
panel.btnPresetsTop.menu.items[panel.btnPresetsTop.menu.items[0].value == 'frozen' ? 0 : 1].setDisabled(!this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.frozen, false, sheet));
panel.btnPresetsLeft.menu.items[panel.btnPresetsLeft.menu.items[0].value == 'frozen' ? 0 : 1].setDisabled(!this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.frozen, true, sheet));
},
fillPrintOptions: function(props) {
@ -214,6 +232,12 @@ define([
props.asc_setPageMargins(opt);
var check = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.PrintTitles, panel.txtRangeTop.getValue(), false) !== Asc.c_oAscError.ID.DataRangeError;
props.asc_setPrintTitlesHeight(check ? panel.txtRangeTop.getValue() : panel.dataRangeTop);
check = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.PrintTitles, panel.txtRangeLeft.getValue(), false) !== Asc.c_oAscError.ID.DataRangeError;
props.asc_setPrintTitlesWidth(check ? panel.txtRangeLeft.getValue() : panel.dataRangeLeft);
return props;
},
@ -253,6 +277,7 @@ define([
this._changedProps = [];
this.updateSettings(this.printSettingsDlg);
this.printSettingsDlg.cmbSheet.on('selected', _.bind(this.comboSheetsChange, this, this.printSettingsDlg));
this.fillComponents(this.printSettingsDlg, true);
this.fillPrintOptions(this.adjPrintParams);
this.registerControlEvents(this.printSettingsDlg);
},this)
@ -353,12 +378,16 @@ define([
panel.spnMarginRight.on('change', _.bind(this.propertyChange, this, panel));
panel.chPrintGrid.on('change', _.bind(this.propertyChange, this, panel));
panel.chPrintRows.on('change', _.bind(this.propertyChange, this, panel));
panel.txtRangeTop.on('changing', _.bind(this.propertyChange, this, panel));
panel.txtRangeLeft.on('changing', _.bind(this.propertyChange, this, panel));
panel.btnPresetsTop.menu.on('item:click', _.bind(this.onPresetSelect, this, panel, 'top'));
panel.btnPresetsLeft.menu.on('item:click', _.bind(this.onPresetSelect, this, panel, 'left'));
},
propertyChange: function(panel, scale, combo, record) {
if (scale === 'scale' && record.value === 'customoptions') {
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());
props = (me._changedProps.length > 0 && me._changedProps[panel.cmbSheet.getValue()]) ? me._changedProps[panel.cmbSheet.getValue()] : me.api.asc_getPageOptions(panel.cmbSheet.getValue(), true);
var win = new SSE.Views.ScaleDialog({
api: me.api,
props: props,
@ -407,9 +436,106 @@ define([
panel.cmbLayout.setValue(value, true);
},
fillComponents: function(panel, selectdata) {
var me = this;
panel.txtRangeTop.validation = function(value) {
me.propertyChange(panel);
if (_.isEmpty(value)) {
return true;
}
var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.PrintTitles, value, false);
return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? me.textInvalidRange : true;
};
panel.txtRangeLeft.validation = function(value) {
me.propertyChange(panel);
if (_.isEmpty(value)) {
return true;
}
var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.PrintTitles, value, false);
return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? me.textInvalidRange : true;
};
var data = ((selectdata) ? [{caption: this.textSelectRange, value: 'select'}] : []).concat([
{caption: this.textFrozenRows, value: 'frozen'},
{caption: this.textFirstRow, value: 'first'},
{caption: '--'},
{caption: this.textNoRepeat, value: 'empty'}
]);
panel.btnPresetsTop.setMenu(new Common.UI.Menu({
style: 'min-width: 100px;',
maxHeight: 200,
items: data
}));
data = ((selectdata) ? [{caption: this.textSelectRange, value: 'select'}] : []).concat([
{caption: this.textFrozenCols, value: 'frozen'},
{caption: this.textFirstCol, value: 'first'},
{caption: '--'},
{caption: this.textNoRepeat, value: 'empty'}
]);
panel.btnPresetsLeft.setMenu(new Common.UI.Menu({
style: 'min-width: 100px;',
maxHeight: 200,
items: data
}));
},
onPresetSelect: function(panel, type, menu, item) {
var txtRange = (type=='top') ? panel.txtRangeTop : panel.txtRangeLeft;
if (item.value == 'select') {
var me = this;
if (me.api) {
var handlerDlg = function(dlg, result) {
if (result == 'ok') {
var valid = dlg.getSettings();
if (type=='top')
panel.dataRangeTop = valid;
else
panel.dataRangeLeft = valid;
txtRange.setValue(valid);
txtRange.checkValidate();
}
};
var win = new SSE.Views.CellRangeDialog({
handler: handlerDlg
}).on('close', function() {
panel.show();
});
var xy = panel.$window.offset();
panel.hide();
win.show(xy.left + 160, xy.top + 125);
win.setSettings({
api : me.api,
range : (!_.isEmpty(txtRange.getValue()) && (txtRange.checkValidate()==true)) ? txtRange.getValue() : ((type=='top') ? panel.dataRangeTop : panel.dataRangeLeft),
type : Asc.c_oAscSelectionDialogType.PrintTitles
});
}
} else {
var value = '';
if (item.value == 'frozen')
value = this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.frozen, type=='left', panel.cmbSheet.getValue());
else if (item.value == 'first')
value = this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.first, type=='left', panel.cmbSheet.getValue());
txtRange.setValue(value);
txtRange.checkValidate();
if (type=='top')
panel.dataRangeTop = value;
else
panel.dataRangeLeft = value;
}
},
warnCheckMargings: 'Margins are incorrect',
strAllSheets: 'All Sheets',
textWarning: 'Warning',
txtCustom: 'Custom'
txtCustom: 'Custom',
textInvalidRange: 'ERROR! Invalid cells range',
textRepeat: 'Repeat...',
textNoRepeat: 'Not repeat',
textSelectRange: 'Select range...',
textFrozenRows: 'Frozen rows',
textFrozenCols: 'Frozen columns',
textFirstRow: 'First row',
textFirstCol: 'First column'
}, SSE.Controllers.Print || {}));
});

View file

@ -150,7 +150,8 @@ define([
onWorkbookLocked: function(locked) {
this.statusbar.tabbar[locked?'addClass':'removeClass']('coauth-locked');
this.statusbar.btnAddWorksheet.setDisabled(locked || this.api.isCellEdited || this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.Chart ||
this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.FormatTable);
this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.FormatTable||
this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.PrintTitles);
var item, i = this.statusbar.tabbar.getCount();
while (i-- > 0) {
item = this.statusbar.tabbar.getAt(i);
@ -170,7 +171,7 @@ define([
tab = this.statusbar.tabbar.getAt(i);
if (index == tab.sheetindex) {
tab[locked?'addClass':'removeClass']('coauth-locked');
tab.isLockTheDrag = locked || (this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.FormatTable);
tab.isLockTheDrag = locked || (this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.FormatTable) || (this.statusbar.rangeSelectionMode==Asc.c_oAscSelectionDialogType.PrintTitles);
tab.$el.children(':first-child').attr('draggable', tab.isLockTheDrag?'false':'true');
break;
}
@ -241,7 +242,7 @@ define([
while (i-- > 0) {
item = this.statusbar.tabbar.getAt(i);
if (item.sheetindex !== currentIdx) {
item.disable(mode==Asc.c_oAscSelectionDialogType.FormatTable);
item.disable(mode==Asc.c_oAscSelectionDialogType.FormatTable || mode==Asc.c_oAscSelectionDialogType.PrintTitles);
}
item.isLockTheDrag = (item.hasClass('coauth-locked') || (mode!=Asc.c_oAscSelectionDialogType.None));
}

View file

@ -57,6 +57,7 @@ define([
'spreadsheeteditor/main/app/view/FormatSettingsDialog',
'spreadsheeteditor/main/app/view/PageMarginsDialog',
'spreadsheeteditor/main/app/view/HeaderFooterDialog',
'spreadsheeteditor/main/app/view/PrintTitlesDialog',
'spreadsheeteditor/main/app/view/ScaleDialog'
], function () { 'use strict';
@ -380,6 +381,7 @@ define([
toolbar.btnsEditHeader.forEach(function(button) {
button.on('click', _.bind(me.onEditHeaderClick, me));
});
toolbar.btnPrintTitles.on('click', _.bind(this.onPrintTitlesClick, this));
Common.Gateway.on('insertimage', _.bind(this.insertImage, this));
@ -1878,14 +1880,14 @@ define([
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.btnScale]});
this.toolbar.lockToolbar(SSE.enumLock.docPropsLock, true, {array: [this.toolbar.btnPageSize, this.toolbar.btnPageMargins, this.toolbar.btnPageOrient, this.toolbar.btnScale, this.toolbar.btnPrintTitles]});
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.btnScale]});
this.toolbar.lockToolbar(SSE.enumLock.docPropsLock, false, {array: [this.toolbar.btnPageSize, this.toolbar.btnPageMargins, this.toolbar.btnPageOrient, this.toolbar.btnScale, this.toolbar.btnPrintTitles]});
this._state.lock_doc = false;
}
},
@ -3453,6 +3455,29 @@ define([
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
},
onPrintTitlesClick: function(btn) {
if (this.api) {
var win, props,
me = this;
win = new SSE.Views.PrintTitlesDialog({
api: me.api,
sheet: me.api.asc_getActiveWorksheetIndex(),
handler: function(dlg, result) {
if (result == 'ok') {
props = dlg.getSettings();
me.api.asc_changePrintTitles(props.width, props.height, me.api.asc_getActiveWorksheetIndex());
Common.NotificationCenter.trigger('edit:complete', me.toolbar);
}
}
});
win.show();
Common.component.Analytics.trackEvent('ToolBar', 'Print Titles');
}
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',

View file

@ -17,6 +17,24 @@
<span id="printadv-dlg-combo-layout" />
</div>
<div id="printadv-dlg-content-to-hide">
<div class="padding-large inner-content" >
<table cols="2" class="no-padding">
<tr>
<td colspan="2" ><label><%= scope.textRepeatTop %></label></td>
</tr>
<tr>
<td class="padding-small"><div id="printadv-dlg-txt-top" style="margin-right: 10px;"></div></td>
<td class="padding-small"><div id="printadv-dlg-presets-top"></div></td>
</tr>
<tr>
<td colspan="2" ><label><%= scope.textRepeatLeft %></label></td>
</tr>
<tr>
<td><div id="printadv-dlg-txt-left" style="margin-right: 10px;"></div></td>
<td><div id="printadv-dlg-presets-left"></div></td>
</tr>
</table>
</div>
<div class="padding-large inner-content" >
<table cols="2" class="no-padding">
<tr>

View file

@ -153,6 +153,7 @@
<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" id="slot-btn-scale"></span>
<span class="btn-slot text x-huge" id="slot-btn-printtitles"></span>
</div>
<div class="separator long"></div>
<div class="group">

View file

@ -273,6 +273,27 @@ define([
'<td class="left"><label><%= scope.textPageScaling %></label></td>',
'<td class="right"><span id="advsettings-print-combo-layout" /></td>',
'</tr>','<tr class="divider"></tr>',
'<tr>',
'<td class="left" style="vertical-align: top;"><label><%= scope.strPrintTitles %></label></td>',
'<td class="right" style="vertical-align: top;"><div id="advsettings-print-titles">',
'<table cols="2" class="no-padding">',
'<tr>',
'<td colspan="2" ><label><%= scope.textRepeatTop %></label></td>',
'</tr>',
'<tr>',
'<td class="padding-small" style="padding-right: 10px;"><div id="advsettings-txt-top"></div></td>',
'<td class="padding-small"><div id="advsettings-presets-top"></div></td>',
'</tr>',
'<tr>',
'<td colspan="2" ><label><%= scope.textRepeatLeft %></label></td>',
'</tr>',
'<tr>',
'<td class="padding-small" style="padding-right: 10px;"><div id="advsettings-txt-left"></div></td>',
'<td class="padding-small"><div id="advsettings-presets-left"></div></td>',
'</tr>',
'</table>',
'</div></td>',
'</tr>','<tr class="divider"></tr>',
'<tr>',
'<td class="left" style="vertical-align: top;"><label><%= scope.strMargins %></label></td>',
'<td class="right" style="vertical-align: top;"><div id="advsettings-margins">',
@ -443,6 +464,36 @@ define([
});
this.spinners.push(this.spnMarginRight);
this.txtRangeTop = new Common.UI.InputField({
el : $markup.findById('#advsettings-txt-top'),
style : 'width: 147px',
allowBlank : true,
validateOnChange: true
});
this.btnPresetsTop = new Common.UI.Button({
cls: 'btn-text-menu-default',
caption: this.textRepeat,
style: 'width: 85px;',
menu: true
});
this.btnPresetsTop.render( $markup.findById('#advsettings-presets-top')) ;
this.txtRangeLeft = new Common.UI.InputField({
el : $markup.findById('#advsettings-txt-left'),
style : 'width: 147px',
allowBlank : true,
validateOnChange: true
});
this.btnPresetsLeft = new Common.UI.Button({
cls: 'btn-text-menu-default',
caption: this.textRepeat,
style: 'width: 85px;',
menu: true
});
this.btnPresetsLeft.render( $markup.findById('#advsettings-presets-left')) ;
this.btnOk = new Common.UI.Button({
el: $markup.findById('#advsettings-print-button-save')
});
@ -539,7 +590,11 @@ define([
textFitCols: 'Fit All Columns on One Page',
textFitRows: 'Fit All Rows on One Page',
textCustomOptions: 'Custom Options',
textCustom: 'Custom'
textCustom: 'Custom',
strPrintTitles: 'Print Titles',
textRepeatTop: 'Repeat rows at top',
textRepeatLeft: 'Repeat columns at left',
textRepeat: 'Repeat...'
}, SSE.Views.MainSettingsPrint || {}));
SSE.Views.FileMenuPanels.MainSettingsGeneral = Common.UI.BaseView.extend(_.extend({

View file

@ -51,7 +51,7 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template',
options: {
alias: 'PrintSettings',
contentWidth: 280,
height: 475,
height: 575,
buttons: null
},
@ -67,6 +67,7 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template',
'<div style="height: 38px; line-height: 38px;" class="div-category">' + this.textPageSize + '</div>',
'<div style="height: 38px; line-height: 38px;" class="div-category">' + this.textPageOrientation + '</div>',
'<div style="height: 38px; line-height: 38px;" class="div-category">' + this.textPageScaling + '</div>',
'<div style="height: 98px; line-height: 33px;" class="div-category">' + this.strPrintTitles + '</div>',
'<div style="height: 108px; line-height: 33px;" class="div-category">' + this.strMargins + '</div>',
'<div style="height: 58px; line-height: 40px;" class="div-category">' + ((this.type == 'print') ? this.strPrint : this.strShow) + '</div>',
'</div>',
@ -228,6 +229,36 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template',
itemsTemplate: itemsTemplate
});
this.txtRangeTop = new Common.UI.InputField({
el : $('#printadv-dlg-txt-top'),
style : 'width: 147px;',
allowBlank : true,
validateOnChange: true
});
this.btnPresetsTop = new Common.UI.Button({
cls: 'btn-text-menu-default',
caption: this.textRepeat,
style: 'width: 85px;',
menu: true
});
this.btnPresetsTop.render( $('#printadv-dlg-presets-top')) ;
this.txtRangeLeft = new Common.UI.InputField({
el : $('#printadv-dlg-txt-left'),
style : 'width: 147px;',
allowBlank : true,
validateOnChange: true
});
this.btnPresetsLeft = new Common.UI.Button({
cls: 'btn-text-menu-default',
caption: this.textRepeat,
style: 'width: 85px;',
menu: true
});
this.btnPresetsLeft.render( $('#printadv-dlg-presets-left')) ;
this.btnHide = new Common.UI.Button({
el: $('#printadv-dlg-btn-hide')
});
@ -314,7 +345,7 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template',
} else {
this.extended = false;
this.panelDetails.css({'display': 'block'});
this.setHeight(475);
this.setHeight(585);
btn.setCaption(this.textHideDetails);
Common.localStorage.setItem("sse-hide-print-settings", 0);
}
@ -355,7 +386,11 @@ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template',
textRange: 'Range',
textIgnore: 'Ignore Print Area',
textCustomOptions: 'Custom Options',
textCustom: 'Custom'
textCustom: 'Custom',
strPrintTitles: 'Print Titles',
textRepeatTop: 'Repeat rows at top',
textRepeatLeft: 'Repeat columns at left',
textRepeat: 'Repeat...'
}, SSE.Views.PrintSettings || {}));
});

View file

@ -0,0 +1,306 @@
/*
*
* (c) Copyright Ascensio System SIA 2010-2020
*
* 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
*
*/
/**
* PrintTitlesDialog.js
*
* Created by Julia Radzhabova on 17.03.2020
* Copyright (c) 2020 Ascensio System SIA. All rights reserved.
*
*/
define([
'common/main/lib/component/Window',
'common/main/lib/component/MetricSpinner'
], function () { 'use strict';
SSE.Views.PrintTitlesDialog = Common.UI.Window.extend(_.extend({
options: {
width: 300,
header: true,
style: 'min-width: 216px;',
cls: 'modal-dlg',
id: 'window-page-margins',
buttons: ['ok', 'cancel']
},
initialize : function(options) {
_.extend(this.options, {
title: this.textTitle
}, options || {});
this.template = [
'<div class="box" style="height: 100px;">',
'<table cols="2" style="width: 100%;margin-bottom: 10px;">',
'<tr>',
'<td colspan="2" style="padding-right: 10px;">',
'<label class="input-label">' + this.textTop + '</label>',
'</td>',
'</tr>',
'<tr>',
'<td style="padding-right: 10px;padding-bottom: 16px;">',
'<div id="print-titles-txt-top"></div>',
'</td>',
'<td style="padding-bottom: 16px;">',
'<div id="print-titles-presets-top"></div>',
'</td>',
'</tr>',
'<tr>',
'<td colspan="2" style="padding-right: 10px;">',
'<label class="input-label">' + this.textLeft + '</label>',
'</td>',
'</tr>',
'<tr>',
'<td style="padding-right: 10px;">',
'<div id="print-titles-txt-left"></div>',
'</td>',
'<td>',
'<div id="print-titles-presets-left"></div>',
'</td>',
'</tr>',
'</table>',
'</div>',
'<div class="separator horizontal"/>'
].join('');
this.options.tpl = _.template(this.template)(this.options);
this.api = this.options.api;
this.sheet = this.options.sheet;
Common.UI.Window.prototype.initialize.call(this, this.options);
this.dataRangeTop = '';
this.dataRangeLeft = '';
},
render: function() {
Common.UI.Window.prototype.render.call(this);
var me = this;
this.menuAddAlign = function(menuRoot, left, top) {
var self = this;
if (!$window.hasClass('notransform')) {
$window.addClass('notransform');
menuRoot.addClass('hidden');
setTimeout(function() {
menuRoot.removeClass('hidden');
menuRoot.css({left: left, top: top});
self.options.additionalAlign = null;
}, 300);
} else {
menuRoot.css({left: left, top: top});
self.options.additionalAlign = null;
}
};
this.txtRangeTop = new Common.UI.InputField({
el : $('#print-titles-txt-top'),
style : 'width: 100%;',
allowBlank : true,
validateOnChange: true,
validation : function(value) {
if (_.isEmpty(value)) {
return true;
}
var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.PrintTitles, value, false);
return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? me.textInvalidRange : true;
}
});
var frozen = this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.frozen, false, this.sheet);
this.btnPresetsTop = new Common.UI.Button({
cls: 'btn-text-menu-default',
caption: this.textRepeat,
style: 'width: 95px;',
menu: new Common.UI.Menu({
style: 'min-width: 100px;',
maxHeight: 200,
additionalAlign: this.menuAddAlign,
items: [
{caption: this.textSelectRange, value: 'select'},
{caption: this.textFrozenRows, value: 'frozen', range: frozen, disabled: !frozen},
{caption: this.textFirstRow, value: 'first', range: this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.first, false, this.sheet)},
{caption: '--'},
{caption: this.textNoRepeat, value: 'empty', range: ''}
]
})
});
this.btnPresetsTop.render( $('#print-titles-presets-top')) ;
this.btnPresetsTop.menu.on('item:click', _.bind(this.onPresetSelect, this, 'top'));
this.txtRangeLeft = new Common.UI.InputField({
el : $('#print-titles-txt-left'),
style : 'width: 100%;',
allowBlank : true,
validateOnChange: true,
validation : function(value) {
if (_.isEmpty(value)) {
return true;
}
var isvalid = me.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.PrintTitles, value, false);
return (isvalid==Asc.c_oAscError.ID.DataRangeError) ? me.textInvalidRange : true;
}
});
frozen = this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.frozen, true, this.sheet);
this.btnPresetsLeft = new Common.UI.Button({
cls: 'btn-text-menu-default',
caption: this.textRepeat,
style: 'width: 95px;',
menu: new Common.UI.Menu({
style: 'min-width: 100px;',
maxHeight: 200,
additionalAlign: this.menuAddAlign,
items: [
{caption: this.textSelectRange, value: 'select'},
{caption: this.textFrozenCols, value: 'frozen', range: frozen, disabled: !frozen},
{caption: this.textFirstCol, value: 'first', range: this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.first, true, this.sheet)},
{caption: '--'},
{caption: this.textNoRepeat, value: 'empty', range: ''}
]
})
});
this.btnPresetsLeft.render( $('#print-titles-presets-left')) ;
this.btnPresetsLeft.menu.on('item:click', _.bind(this.onPresetSelect, this, 'left'));
var $window = this.getChild();
$window.find('.dlg-btn').on('click', _.bind(this.onBtnClick, this));
$window.find('input').on('keypress', _.bind(this.onKeyPress, this));
this.setSettings();
},
isRangeValid: function() {
if (this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.PrintTitles, this.txtRangeTop.getValue(), false) == Asc.c_oAscError.ID.DataRangeError) {
this.txtRangeTop.cmpEl.find('input').focus();
return false;
}
if (this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.PrintTitles, this.txtRangeLeft.getValue(), false) == Asc.c_oAscError.ID.DataRangeError) {
this.txtRangeLeft.cmpEl.find('input').focus();
return false;
}
return true;
},
_handleInput: function(state) {
if (this.options.handler) {
if (state == 'ok') {
if (!this.isRangeValid())
return;
}
this.options.handler.call(this, this, state);
}
this.close();
},
onBtnClick: function(event) {
this._handleInput(event.currentTarget.attributes['result'].value);
},
onKeyPress: function(event) {
if (event.keyCode == Common.UI.Keys.RETURN) {
this._handleInput('ok');
}
},
setSettings: function (props) {
if (this.api) {
var value = this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.current, false, this.sheet);
this.txtRangeTop.setValue((value) ? value : '');
this.dataRangeTop = value;
value = this.api.asc_getPrintTitlesRange(Asc.c_oAscPrintTitlesRangeType.current, true, this.sheet);
this.txtRangeLeft.setValue((value) ? value : '');
this.dataRangeLeft = value;
}
},
getSettings: function() {
return {width: this.txtRangeLeft.getValue(), height: this.txtRangeTop.getValue()};
},
onPresetSelect: function(type, menu, item) {
var txtRange = (type=='top') ? this.txtRangeTop : this.txtRangeLeft;
if (item.value == 'select') {
var me = this;
if (me.api) {
var handlerDlg = function(dlg, result) {
if (result == 'ok') {
var valid = dlg.getSettings();
if (type=='top')
me.dataRangeTop = valid;
else
me.dataRangeLeft = valid;
txtRange.setValue(valid);
txtRange.checkValidate();
}
};
var win = new SSE.Views.CellRangeDialog({
handler: handlerDlg
}).on('close', function() {
me.show();
});
var xy = me.$window.offset();
me.hide();
win.show(xy.left + 160, xy.top + 125);
win.setSettings({
api : me.api,
range : (!_.isEmpty(txtRange.getValue()) && (txtRange.checkValidate()==true)) ? txtRange.getValue() : ((type=='top') ? me.dataRangeTop : me.dataRangeLeft),
type : Asc.c_oAscSelectionDialogType.PrintTitles
});
}
} else {
var value = item.options.range || '';
txtRange.setValue(value);
txtRange.checkValidate();
if (type=='top')
this.dataRangeTop = value;
else
this.dataRangeLeft = value;
}
},
textTitle: 'Print Titles',
textTop: 'Repeat rows at top',
textLeft: 'Repeat columns at left',
textRepeat: 'Repeat...',
textNoRepeat: 'Not repeat',
textSelectRange: 'Select range...',
textFrozenRows: 'Frozen rows',
textFrozenCols: 'Frozen columns',
textFirstRow: 'First row',
textFirstCol: 'First column',
textInvalidRange: 'ERROR! Invalid cells range'
}, SSE.Views.PrintTitlesDialog || {}))
});

View file

@ -179,7 +179,8 @@ define([
'tab:contextmenu' : _.bind(this.onTabMenu, this),
'tab:dblclick' : _.bind(function () {
if (me.editMode && (me.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.Chart) &&
(me.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.FormatTable)) {
(me.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.FormatTable)&&
(me.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.PrintTitles)) {
me.fireEvent('sheet:changename');
}
}, this),
@ -509,6 +510,7 @@ define([
var me = this;
if (this.mode.isEdit && !this.isEditFormula && (this.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.Chart) &&
(this.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.FormatTable) &&
(this.rangeSelectionMode !== Asc.c_oAscSelectionDialogType.PrintTitles) &&
!this.mode.isDisconnected ) {
if (tab && tab.sheetindex >= 0) {
var rect = tab.$el.get(0).getBoundingClientRect(),

View file

@ -1338,6 +1338,14 @@ define([
me.mnuScale = me.btnScale.menu;
me.mnuScale.on('show:after', _.bind(me.onAfterShowMenuScale, me));
me.btnPrintTitles = new Common.UI.Button({
id: 'tlbtn-printtitles',
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-print-titles',
caption: me.capBtnPrintTitles,
lock : [_set.docPropsLock, _set.lostConnect, _set.coAuth]
});
me.btnImgAlign = new Common.UI.Button({
cls: 'btn-toolbar x-huge icon-top',
iconCls: 'toolbar__icon btn-img-align',
@ -1393,7 +1401,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.btnScale
me.btnPageMargins, me.btnPageSize, me.btnPageOrient, me.btnPrintArea, me.btnPrintTitles, me.btnImgAlign, me.btnImgBackward, me.btnImgForward, me.btnImgGroup, me.btnScale
];
_.each(me.lockControls.concat([me.btnSave]), function(cmp) {
@ -1588,6 +1596,7 @@ define([
_injectComponent('#slot-btn-pagemargins', this.btnPageMargins);
_injectComponent('#slot-btn-pagesize', this.btnPageSize);
_injectComponent('#slot-btn-printarea', this.btnPrintArea);
_injectComponent('#slot-btn-printtitles', this.btnPrintTitles);
_injectComponent('#slot-img-align', this.btnImgAlign);
_injectComponent('#slot-img-group', this.btnImgGroup);
_injectComponent('#slot-img-movefrwd', this.btnImgForward);
@ -1664,6 +1673,7 @@ define([
_updateHint(this.btnPageSize, this.tipPageSize);
_updateHint(this.btnPageMargins, this.tipPageMargins);
_updateHint(this.btnPrintArea, this.tipPrintArea);
_updateHint(this.btnPrintTitles, this.tipPrintTitles);
_updateHint(this.btnScale, this.tipScale);
this.btnsEditHeader.forEach(function (btn) {
_updateHint(btn, me.tipEditHeader);
@ -2381,6 +2391,8 @@ define([
capBtnAddComment: 'Add Comment',
capBtnInsSymbol: 'Symbol',
tipInsertSymbol: 'Insert symbol',
txtAutosumTip: 'Summation'
txtAutosumTip: 'Summation',
capBtnPrintTitles: 'Print Titles',
tipPrintTitles: 'Print titles'
}, SSE.Views.Toolbar || {}));
});

View file

@ -789,6 +789,14 @@
"SSE.Controllers.Print.textWarning": "Warning",
"SSE.Controllers.Print.txtCustom": "Custom",
"SSE.Controllers.Print.warnCheckMargings": "Margins are incorrect",
"SSE.Controllers.Print.textInvalidRange": "ERROR! Invalid cells range",
"SSE.Controllers.Print.textRepeat": "Repeat...",
"SSE.Controllers.Print.textNoRepeat": "Not repeat",
"SSE.Controllers.Print.textSelectRange": "Select range...",
"SSE.Controllers.Print.textFrozenRows": "Frozen rows",
"SSE.Controllers.Print.textFrozenCols": "Frozen columns",
"SSE.Controllers.Print.textFirstRow": "First row",
"SSE.Controllers.Print.textFirstCol": "First column",
"SSE.Controllers.Statusbar.errorLastSheet": "Workbook must have at least one visible worksheet.",
"SSE.Controllers.Statusbar.errorRemoveSheet": "Cannot delete the worksheet.",
"SSE.Controllers.Statusbar.strSheet": "Sheet",
@ -1829,6 +1837,10 @@
"SSE.Views.MainSettingsPrint.textPrintGrid": "Print Gridlines",
"SSE.Views.MainSettingsPrint.textPrintHeadings": "Print Row and Column Headings",
"SSE.Views.MainSettingsPrint.textSettings": "Settings for",
"SSE.Views.MainSettingsPrint.strPrintTitles": "Print Titles",
"SSE.Views.MainSettingsPrint.textRepeatTop": "Repeat rows at top",
"SSE.Views.MainSettingsPrint.textRepeatLeft": "Repeat columns at left",
"SSE.Views.MainSettingsPrint.textRepeat": "Repeat...",
"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",
"SSE.Views.NamedRangeEditDlg.notcriticalErrorTitle": "Warning",
@ -2028,6 +2040,21 @@
"SSE.Views.PrintSettings.textShowHeadings": "Show Rows and Columns Headings",
"SSE.Views.PrintSettings.textTitle": "Print Settings",
"SSE.Views.PrintSettings.textTitlePDF": "PDF Settings",
"SSE.Views.PrintSettings.strPrintTitles": "Print Titles",
"SSE.Views.PrintSettings.textRepeatTop": "Repeat rows at top",
"SSE.Views.PrintSettings.textRepeatLeft": "Repeat columns at left",
"SSE.Views.PrintSettings.textRepeat": "Repeat...",
"SSE.Views.PrintTitlesDialog.textTitle": "Print Titles",
"SSE.Views.PrintTitlesDialog.textTop": "Repeat rows at top",
"SSE.Views.PrintTitlesDialog.textLeft": "Repeat columns at left",
"SSE.Views.PrintTitlesDialog.textRepeat": "Repeat...",
"SSE.Views.PrintTitlesDialog.textNoRepeat": "Not repeat",
"SSE.Views.PrintTitlesDialog.textSelectRange": "Select range...",
"SSE.Views.PrintTitlesDialog.textFrozenRows": "Frozen rows",
"SSE.Views.PrintTitlesDialog.textFrozenCols": "Frozen columns",
"SSE.Views.PrintTitlesDialog.textFirstRow": "First row",
"SSE.Views.PrintTitlesDialog.textFirstCol": "First column",
"SSE.Views.PrintTitlesDialog.textInvalidRange": "ERROR! Invalid cells range",
"SSE.Views.RightMenu.txtCellSettings": "Cell settings",
"SSE.Views.RightMenu.txtChartSettings": "Chart settings",
"SSE.Views.RightMenu.txtImageSettings": "Image settings",

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 180 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B