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;