From ca46cf41b090c8f39f8fc0ebae6c1380fe773ecb Mon Sep 17 00:00:00 2001 From: maxkadushkin Date: Tue, 25 Feb 2020 18:23:38 +0300 Subject: [PATCH] Update Desktop.js (#349) --- apps/common/main/lib/controller/Desktop.js | 31 +++++++++++++--------- 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/apps/common/main/lib/controller/Desktop.js b/apps/common/main/lib/controller/Desktop.js index ea67d6ad9..e43a59968 100644 --- a/apps/common/main/lib/controller/Desktop.js +++ b/apps/common/main/lib/controller/Desktop.js @@ -193,24 +193,31 @@ define([ } var header = webapp.getController('Viewport').getView('Common.Views.Header'); - titlebuttons = { - 'save': {btn: header.btnSave, disabled:false}, - 'print': {btn: header.btnPrint, disabled:false}, - 'undo': {btn: header.btnUndo, disabled:false}, - 'redo': {btn: header.btnRedo, disabled:false} - }; + titlebuttons = {}; + if ( !!header.btnSave ) { + titlebuttons['save'] = {btn: header.btnSave, disabled:false}; + + header.btnSave.options.signals.push('icon:changed'); + header.btnSave.on('icon:changed', _onSaveIconChanged.bind(this)); + + var iconname = /\s?([^\s]+)$/.exec(titlebuttons.save.btn.$icon.attr('class')); + !!iconname && iconname.length && (titlebuttons.save.icon = btnsave_icons[iconname]); + } + + if ( !!header.btnPrint ) + titlebuttons['print'] = {btn: header.btnPrint, disabled:false}; + + if ( !!header.btnUndo ) + titlebuttons['undo'] = {btn: header.btnUndo, disabled:false}; + + if ( !!header.btnRedo ) + titlebuttons['redo'] = {btn: header.btnRedo, disabled:false}; for (var i in titlebuttons) { titlebuttons[i].btn.options.signals = ['disabled']; titlebuttons[i].btn.on('disabled', _onTitleButtonDisabled.bind(this, i)); } - header.btnSave.options.signals.push('icon:changed'); - header.btnSave.on('icon:changed', _onSaveIconChanged.bind(this)); - - var iconname = /\s?([^\s]+)$/.exec(titlebuttons.save.btn.$icon.attr('class')); - !!iconname && iconname.length && (titlebuttons.save.icon = btnsave_icons[iconname]); - if ( !!config.callback_editorconfig ) { config.callback_editorconfig(); delete config.callback_editorconfig;