/* * (c) Copyright Ascensio System SIA 2010-2024 * * 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-6 Ernesta Birznieka-Upish * 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 * */ /** * PrintSettings.js * * Created on 4/03/14 * */ define([ 'text!spreadsheeteditor/main/app/template/PrintSettings.template', 'common/main/lib/view/AdvancedSettingsWindow', ], function (contentTemplate) { 'use strict'; SSE.Views.PrintSettings = Common.Views.AdvancedSettingsWindow.extend(_.extend({ options: { alias: 'PrintSettings', contentWidth: 280, contentHeight: 468, buttons: null }, initialize : function(options) { this.type = options.type || 'print'; var txtBtn = (this.type == 'print') ? this.btnPrint : (this.type == 'export') ? this.btnExport : this.btnDownload; _.extend(this.options, { title: (this.type == 'print') ? this.textTitle : this.textTitlePDF, template: [ '
', '', '
' + _.template(contentTemplate)({scope: this}) + '
', '
', '
', '' ].join('') }, options); Common.Views.AdvancedSettingsWindow.prototype.initialize.call(this, this.options); }, render: function() { Common.Views.AdvancedSettingsWindow.prototype.render.call(this); this.cmbRange = new Common.UI.ComboBox({ el : $('#printadv-dlg-combo-range'), style : 'width: 242px;', menuStyle : 'min-width: 100%;max-height: 280px;', editable : false, takeFocusOnClose: true, cls : 'input-group-nr', data : [ { value: Asc.c_oAscPrintType.ActiveSheets, displayValue: this.textActiveSheets }, { value: Asc.c_oAscPrintType.EntireWorkbook, displayValue: this.textAllSheets }, { value: Asc.c_oAscPrintType.Selection, displayValue: this.textSelection } ] }); this.cmbRange.on('selected', _.bind(this.comboRangeChange, this)); this.chIgnorePrintArea = new Common.UI.CheckBox({ el: $('#printadv-dlg-chb-ignore'), labelText: this.textIgnore }); this.spnPagesFrom = new Common.UI.MetricSpinner({ el: $('#printadv-dlg-spin-pages-from'), step: 1, width: 60, defaultUnit : '', value: '', maxValue: 1000000, minValue: 1, allowDecimal: false, allowBlank: true, maskExp: /[0-9]/ }); this.spnPagesTo = new Common.UI.MetricSpinner({ el: $('#printadv-dlg-spin-pages-to'), step: 1, width: 60, defaultUnit : '', value: '', maxValue: 1000000, minValue: 1, allowDecimal: false, allowBlank: true, maskExp: /[0-9]/ }); this.cmbSheet = new Common.UI.ComboBox({ el : $('#printadv-dlg-combo-sheets'), style : 'width: 242px;', menuStyle : 'min-width: 242px;max-height: 280px;', editable : false, cls : 'input-group-nr', data : [], takeFocusOnClose: true }); this.cmbPaperSize = new Common.UI.ComboBox({ el : $('#printadv-dlg-combo-pages'), style : 'width: 242px;', menuStyle : 'max-height: 280px; min-width: 242px;', editable : false, takeFocusOnClose: true, cls : 'input-group-nr', data : [ {value:'215.9|279.4', displayValue:'US Letter (21,59 cm x 27,94 cm)', caption: 'US Letter', size: [215.9, 279.4]}, {value:'215.9|355.6', displayValue:'US Legal (21,59 cm x 35,56 cm)', caption: 'US Legal', size: [215.9, 355.6]}, {value:'210|297', displayValue:'A4 (21 cm x 29,7 cm)', caption: 'A4', size: [210, 297]}, {value:'148|210', displayValue:'A5 (14,8 cm x 21 cm)', caption: 'A5', size: [148, 210]}, {value:'176|250', displayValue:'B5 (17,6 cm x 25 cm)', caption: 'B5', size: [176, 250]}, {value:'104.8|241.3', displayValue:'Envelope #10 (10,48 cm x 24,13 cm)', caption: 'Envelope #10', size: [104.8, 241.3]}, {value:'110|220', displayValue:'Envelope DL (11 cm x 22 cm)', caption: 'Envelope DL', size: [110, 220]}, {value:'279.4|431.8', displayValue:'Tabloid (27,94 cm x 43,18 cm)', caption: 'Tabloid', size: [279.4, 431.8]}, {value:'297|420', displayValue:'A3 (29,7 cm x 42 cm)', caption: 'A3', size: [297, 420]}, {value:'296.9|457.2', displayValue:'Tabloid Oversize (29,69 cm x 45,72 cm)', caption: 'Tabloid Oversize', size: [296.9, 457.2]}, {value:'196.8|273', displayValue:'ROC 16K (19,68 cm x 27,3 cm)', caption: 'ROC 16K', size: [196.8, 273]}, {value:'120|235', displayValue:'Envelope Choukei 3 (12 cm x 23,5 cm)', caption: 'Envelope Choukei 3', size: [120, 235]}, {value:'305|487', displayValue:'Super B/A3 (30,5 cm x 48,7 cm)', caption: 'Super B/A3', size: [305, 487]} ] }); this.cmbPaperOrientation = new Common.UI.ComboBox({ el : $('#printadv-dlg-combo-orient'), style : 'width: 132px;', menuStyle : 'min-width: 132px;', editable : false, takeFocusOnClose: true, cls : 'input-group-nr', data : [ { value: Asc.c_oAscPageOrientation.PagePortrait, displayValue: this.strPortrait }, { value: Asc.c_oAscPageOrientation.PageLandscape, displayValue: this.strLandscape } ] }); this.chPrintGrid = new Common.UI.CheckBox({ el: $('#printadv-dlg-chb-grid'), labelText: (this.type == 'print') ? this.textPrintGrid : this.textShowGrid }); this.chPrintRows = new Common.UI.CheckBox({ el: $('#printadv-dlg-chb-rows'), labelText: (this.type == 'print') ? this.textPrintHeadings : this.textShowHeadings }); this.cmbPaperMargins = new Common.UI.ComboBox({ el: $('#printadv-dlg-combo-margins'), style: 'width: 242px;', menuStyle: 'max-height: 280px; min-width: 242px;', editable: false, takeFocusOnClose: true, cls: 'input-group-nr', data: [ { value: 0, displayValue: this.textMarginsNormal, size: [19.1, 17.8, 19.1, 17.8]}, { value: 1, displayValue: this.textMarginsNarrow, size: [19.1, 6.4, 19.1, 6.4]}, { value: 2, displayValue: this.textMarginsWide, size: [25.4, 25.4, 25.4, 25.4]}, { value: -1, displayValue: this.textCustom, size: null} ], itemsTemplate: _.template([ '<% _.each(items, function(item) { %>', '
  • ', '
    <%= scope.getDisplayValue(item) %>
    ', '<% if (item.size !== null) { %>
    ' + '' + '
    ' + '' + '
    ' + '<% } %>', '<% }); %>' ].join('')) }); var itemsTemplate = _.template([ '<% _.each(items, function(item) { %>', '
  • class="border-top" <% } %> >', '<%= scope.getDisplayValue(item) %>', '
  • ', '<% }); %>' ].join('')); this.cmbLayout = new Common.UI.ComboBox({ el : $('#printadv-dlg-combo-layout'), style : 'width: 242px;', menuStyle : 'min-width: 242px;', editable : false, takeFocusOnClose: true, cls : 'input-group-nr', data : [ { value: 0, displayValue: this.textActualSize }, { value: 1, displayValue: this.textFitPage }, { value: 2, displayValue: this.textFitCols }, { value: 3, displayValue: this.textFitRows }, { value: 'customoptions', displayValue: this.textCustomOptions } ], itemsTemplate: itemsTemplate }); this.txtRangeTop = new Common.UI.InputFieldBtn({ el : $('#printadv-dlg-txt-top'), style : 'width: 137px;', allowBlank : true, validateOnChange: true }); this.btnPresetsTop = new Common.UI.Button({ parentEl: $('#printadv-dlg-presets-top'), cls: 'btn-text-menu-default', caption: this.textRepeat, style: 'width: 95px;', menu: true, takeFocusOnClose: true }); this.txtRangeLeft = new Common.UI.InputFieldBtn({ el : $('#printadv-dlg-txt-left'), style : 'width: 137px;', allowBlank : true, validateOnChange: true }); this.btnPresetsLeft = new Common.UI.Button({ parentEl: $('#printadv-dlg-presets-left'), cls: 'btn-text-menu-default', caption: this.textRepeat, style: 'width: 95px;', menu: true, takeFocusOnClose: true }); this.btnHide = new Common.UI.Button({ el: $('#printadv-dlg-btn-hide') }); this.btnHide.on('click', _.bind(this.handlerShowDetails, this)); this.panelDetails = $('#printadv-dlg-content-to-hide'); this.updateMetricUnit(); this.options.afterrender && this.options.afterrender.call(this); var value = Common.localStorage.getItem("sse-hide-print-settings"); this.extended = (value!==null && parseInt(value)==0); this.handlerShowDetails(this.btnHide); }, getFocusedComponents: function() { return [this.cmbRange, this.chIgnorePrintArea, this.spnPagesFrom, this.spnPagesTo, this.cmbSheet, this.cmbPaperSize, this.cmbPaperOrientation, this.cmbLayout, this.txtRangeTop, this.btnPresetsTop, this.txtRangeLeft, this.btnPresetsLeft, this.cmbPaperMargins, this.chPrintGrid, this.chPrintRows, this.btnHide].concat(this.getFooterButtons()); }, getDefaultFocusableComponent: function () { if (this._alreadyRendered) return; // focus only at first show this._alreadyRendered = true; return this.cmbRange; }, addCustomScale: function (add) { if (add) { this.cmbLayout.setData([ { value: 0, displayValue: this.textActualSize }, { value: 1, displayValue: this.textFitPage }, { value: 2, displayValue: this.textFitCols }, { value: 3, displayValue: this.textFitRows }, { value: 4, displayValue: this.textCustom }, { value: 'customoptions', displayValue: this.textCustomOptions } ]); } else { this.cmbLayout.setData([ { value: 0, displayValue: this.textActualSize }, { value: 1, displayValue: this.textFitPage }, { value: 2, displayValue: this.textFitCols }, { value: 3, displayValue: this.textFitRows }, { value: 'customoptions', displayValue: this.textCustomOptions } ]); } }, setRange: function(value) { this.cmbRange.setValue(value); }, getRange: function() { return this.cmbRange.getValue(); }, setIgnorePrintArea: function(value) { this.chIgnorePrintArea.setValue(value); }, getIgnorePrintArea: function() { return (this.chIgnorePrintArea.getValue()=='checked'); }, getPagesFrom: function () { return this.spnPagesFrom.getNumberValue(); }, getPagesTo: function () { return this.spnPagesTo.getNumberValue(); }, comboRangeChange: function(combo, record) { this.fireEvent('changerange', this); }, updateMetricUnit: function() { var store = this.cmbPaperSize.store; for (var i=0; i