[DE] Refactoring print preview, hide preview for mac os

This commit is contained in:
Julia Radzhabova 2022-10-24 19:02:05 +03:00
parent 229e55811e
commit d8600b8a2a
6 changed files with 42 additions and 10 deletions

View file

@ -113,6 +113,7 @@ define([
if ( !this.leftMenu.panelHistory.isVisible() )
this.clickMenuFileItem(null, 'history');
}, this));
Common.NotificationCenter.on('file:print', _.bind(this.clickToolbarPrint, this));
},
onLaunch: function() {
@ -549,6 +550,13 @@ define([
this.leftMenu.menuFile.hide();
},
clickToolbarPrint: function () {
if (this.mode.canPreviewPrint)
this.leftMenu.showMenu('file:printpreview');
else if (this.mode.canPrint)
this.clickMenuFileItem(null, 'print');
},
changeToolbarSaveState: function (state) {
var btnSave = this.leftMenu.menuFile.getButton('save');
btnSave && btnSave.setDisabled(state);

View file

@ -1494,6 +1494,7 @@ define([
}
this.appOptions.canEditStyles = this.appOptions.canLicense && this.appOptions.canEdit;
this.appOptions.canPrint = (this.permissions.print !== false);
this.appOptions.canPreviewPrint = this.appOptions.canPrint && !Common.Utils.isMac;
this.appOptions.canRename = this.editorConfig.canRename;
this.appOptions.buildVersion = params.asc_getBuildVersion();
this.appOptions.canForcesave = this.appOptions.isEdit && !this.appOptions.isOffline && (typeof (this.editorConfig.customization) == 'object' && !!this.editorConfig.customization.forcesave);
@ -2618,9 +2619,7 @@ define([
onPrint: function() {
if (!this.appOptions.canPrint || Common.Utils.ModalWindow.isVisible()) return;
if (this.api)
this.api.asc_Print(new Asc.asc_CDownloadOptions(null, Common.Utils.isChrome || Common.Utils.isOpera || Common.Utils.isGecko && Common.Utils.firefoxVersion>86)); // if isChrome or isOpera == true use asc_onPrintUrl event
Common.NotificationCenter.trigger('file:print');
Common.component.Analytics.trackEvent('Print');
},

View file

@ -75,8 +75,8 @@ define([
onAfterRender: function(view) {
var me = this;
this.printSettings.menu.on('menu:hide', _.bind(this.onHidePrintMenu, this));
// this.printSettings.btnPrint.on('click', _.bind(me.onBtnPrint, me));
// this.printSettings.btnPrintPdf.on('click', _.bind(me.onBtnPrintPdf, me));
this.printSettings.btnPrint.on('click', _.bind(this.onBtnPrint, this, true));
this.printSettings.btnPrintPdf.on('click', _.bind(this.onBtnPrint, this, false));
this.printSettings.btnPrevPage.on('click', _.bind(this.onChangePreviewPage, this, false));
this.printSettings.btnNextPage.on('click', _.bind(this.onChangePreviewPage, this, true));
this.printSettings.txtNumberPage.on({
@ -431,6 +431,19 @@ define([
this.printSettings.btnNextPage.setDisabled(curPage > pageCount - 2);
},
onBtnPrint: function(print) {
if ( print ) {
var opts = new Asc.asc_CDownloadOptions(null, Common.Utils.isChrome || Common.Utils.isOpera || Common.Utils.isGecko && Common.Utils.firefoxVersion>86);
opts.asc_setAdvancedOptions(this.adjPrintParams);
this.api.asc_Print(opts);
} else {
var opts = new Asc.asc_CDownloadOptions(Asc.c_oAscFileType.PDF);
opts.asc_setAdvancedOptions(this.adjPrintParams);
this.api.asc_DownloadAs(opts);
}
this.printSettings.menu.hide();
},
textWarning: 'Warning',
txtCustom: 'Custom'
}, DE.Controllers.Print || {}));

View file

@ -1057,9 +1057,7 @@ define([
},
onPrint: function(e) {
if (this.api)
this.api.asc_Print(new Asc.asc_CDownloadOptions(null, Common.Utils.isChrome || Common.Utils.isOpera || Common.Utils.isGecko && Common.Utils.firefoxVersion>86)); // if isChrome or isOpera == true use asc_onPrintUrl event
Common.NotificationCenter.trigger('file:print', this.toolbar);
Common.NotificationCenter.trigger('edit:complete', this.toolbar);
Common.component.Analytics.trackEvent('Print');

View file

@ -7,6 +7,7 @@
<li id="fm-btn-download" class="fm-btn"></li>
<li id="fm-btn-save-copy" class="fm-btn"></li>
<li id="fm-btn-save-desktop" class="fm-btn"></li>
<li id="fm-btn-print" class="fm-btn"></li>
<li id="fm-btn-print-with-preview" class="fm-btn"></li>
<li id="fm-btn-rename" class="fm-btn"></li>
<li id="fm-btn-protect" class="fm-btn"></li>

View file

@ -169,6 +169,17 @@ define([
dataHintTitle: 'P'
});
this.miPrint = new Common.UI.MenuItem({
el : $markup.elementById('#fm-btn-print'),
action : 'print',
caption : this.btnPrintCaption,
canFocused: false,
dataHint: 1,
dataHintDirection: 'left-top',
dataHintOffset: [2, 14],
dataHintTitle: 'P'
});
this.miRename = new Common.UI.MenuItem({
el : $markup.elementById('#fm-btn-rename'),
action : 'rename',
@ -291,6 +302,7 @@ define([
this.miDownload,
this.miSaveCopyAs,
this.miSaveAs,
this.miPrint,
this.miPrintWithPreview,
this.miRename,
this.miProtect,
@ -381,7 +393,8 @@ define([
this.miSaveAs[((this.mode.canDownload || this.mode.canDownloadOrigin) && this.mode.isDesktopApp && this.mode.isOffline)?'show':'hide']();
this.miSave[this.mode.isEdit && Common.UI.LayoutManager.isElementVisible('toolbar-file-save') ?'show':'hide']();
this.miEdit[!this.mode.isEdit && this.mode.canEdit && this.mode.canRequestEditRights ?'show':'hide']();
this.miPrintWithPreview[this.mode.canPrint?'show':'hide']();
this.miPrint[this.mode.canPrint && !this.mode.canPreviewPrint ?'show':'hide']();
this.miPrintWithPreview[this.mode.canPreviewPrint?'show':'hide']();
this.miRename[(this.mode.canRename && !this.mode.isDesktopApp) ?'show':'hide']();
this.miProtect[this.mode.canProtect ?'show':'hide']();
separatorVisible = (this.mode.canDownload || this.mode.canDownloadOrigin || this.mode.isEdit && Common.UI.LayoutManager.isElementVisible('toolbar-file-save') || this.mode.canPrint || this.mode.canProtect ||
@ -463,7 +476,7 @@ define([
this.panels['help'].setLangConfig(this.mode.lang);
}
if (this.mode.canPrint) {
if (this.mode.canPreviewPrint) {
var printPanel = DE.getController('Print').getView('PrintWithPreview');
printPanel.menu = this;
!this.panels['printpreview'] && (this.panels['printpreview'] = printPanel.render(this.$el.find('#panel-print')));