From 8e9d5dcea0327ec5865e0f6f6ff18910f66e22af Mon Sep 17 00:00:00 2001 From: JuliaSvinareva Date: Thu, 21 Oct 2021 15:20:32 +0300 Subject: [PATCH] [SSE] Add handler for print button in print preview menu --- .../main/app/controller/Print.js | 19 +++++++++++++++++-- .../main/app/view/FileMenuPanels.js | 18 +++++++++++------- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/apps/spreadsheeteditor/main/app/controller/Print.js b/apps/spreadsheeteditor/main/app/controller/Print.js index e4f654201..9e71204ef 100644 --- a/apps/spreadsheeteditor/main/app/controller/Print.js +++ b/apps/spreadsheeteditor/main/app/controller/Print.js @@ -78,7 +78,9 @@ define([ onAfterRender: function(view) { this.printSettings.cmbSheet.on('selected', _.bind(this.comboSheetsChange, this, this.printSettings)); - this.printSettings.btnSave.on('click', _.bind(this.querySavePrintSettings, this)); + this.printSettings.btnSave.on('click', _.bind(this.querySavePrintSettings, this, false)); + this.printSettings.btnPrint.on('click', _.bind(this.querySavePrintSettings, this, true)); + this.fillComponents(this.printSettings); this.registerControlEvents(this.printSettings); }, @@ -335,10 +337,23 @@ define([ this.printSettingsDlg = null; }, - querySavePrintSettings: function() { + querySavePrintSettings: function(print) { if ( this.checkMargins(this.printSettings) ) { this.savePageOptions(this.printSettings); this.printSettings.applySettings(); + + if (print) { + var printType = this.printSettings.getRange(); + this.adjPrintParams.asc_setPrintType(printType); + this.adjPrintParams.asc_setPageOptionsMap(this._changedProps); + this.adjPrintParams.asc_setIgnorePrintArea(this.printSettings.getIgnorePrintArea()); + Common.localStorage.setItem("sse-print-settings-range", printType); + + var opts = new Asc.asc_CDownloadOptions(null, Common.Utils.isChrome || Common.Utils.isSafari || Common.Utils.isOpera || Common.Utils.isGecko && Common.Utils.firefoxVersion>86); + opts.asc_setAdvancedOptions(this.adjPrintParams); + this.api.asc_Print(opts); + Common.NotificationCenter.trigger('edit:complete', view); + } } }, diff --git a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js index a462092b5..091f655ef 100644 --- a/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js +++ b/apps/spreadsheeteditor/main/app/view/FileMenuPanels.js @@ -2745,8 +2745,8 @@ define([ '', '', '', '', '', @@ -2754,8 +2754,8 @@ define([ '', '', '', @@ -2868,7 +2868,7 @@ define([ itemsTemplate: itemsTemplate }); - this.txtRangeTop = new Common.UI.InputFieldBtn({ + this.txtRangeTop = new Common.UI.InputField({ el: $markup.findById('#print-txt-top'), allowBlank: true, validateOnChange: true @@ -2882,7 +2882,7 @@ define([ menu: true }); - this.txtRangeLeft = new Common.UI.InputFieldBtn({ + this.txtRangeLeft = new Common.UI.InputField({ el: $markup.findById('#print-txt-left'), allowBlank: true, validateOnChange: true @@ -2960,7 +2960,11 @@ define([ this.trApply = $markup.find('.fms-btn-apply'); this.btnSave = new Common.UI.Button({ - el: $markup.findById('#print-button-save') + el: $markup.findById('#print-btn-save') + }); + + this.btnPrint = new Common.UI.Button({ + el: $markup.findById('#print-btn-print') }); this.$el = $(node).html($markup);