diff --git a/apps/documenteditor/main/app/controller/ViewTab.js b/apps/documenteditor/main/app/controller/ViewTab.js index 13654877b..ec69b21ac 100644 --- a/apps/documenteditor/main/app/controller/ViewTab.js +++ b/apps/documenteditor/main/app/controller/ViewTab.js @@ -116,37 +116,38 @@ define([ onAppReady: function (config) { var me = this; - (new Promise(function (accept, reject) { - accept(); - })).then(function(){ - me.view.setEvents(); - }); - if (me.view.btnNavigation) { - me.getApplication().getController('LeftMenu').leftMenu.btnNavigation.on('toggle', function(btn, state){ + if (me.view) { + (new Promise(function (accept, reject) { + accept(); + })).then(function(){ + me.view.setEvents(); + }); + + me.getApplication().getController('LeftMenu').leftMenu.btnNavigation.on('toggle', function (btn, state) { if (state !== me.view.btnNavigation.pressed) me.view.turnNavigation(state); }); - } - var menuItems = [], - currentTheme = Common.UI.Themes.currentThemeId() || Common.UI.Themes.defaultThemeId(); - for (var t in Common.UI.Themes.map()) { - menuItems.push({ - value: t, - caption: Common.UI.Themes.get(t).text, - checked: t === currentTheme, - checkable: true, - toggleGroup: 'interface-theme' - }); - } + var menuItems = [], + currentTheme = Common.UI.Themes.currentThemeId() || Common.UI.Themes.defaultThemeId(); + for (var t in Common.UI.Themes.map()) { + menuItems.push({ + value: t, + caption: Common.UI.Themes.get(t).text, + checked: t === currentTheme, + checkable: true, + toggleGroup: 'interface-theme' + }); + } - if ( menuItems.length ) { - this.view.btnInterfaceTheme.setMenu(new Common.UI.Menu({items: menuItems})); - this.view.btnInterfaceTheme.menu.on('item:click', _.bind(function (menu, item) { - var value = item.value; - Common.UI.Themes.setTheme(value); - this.view.btnDarkDocument.setDisabled(value !== 'theme-dark'); - }, this)); + if (menuItems.length) { + this.view.btnInterfaceTheme.setMenu(new Common.UI.Menu({items: menuItems})); + this.view.btnInterfaceTheme.menu.on('item:click', _.bind(function (menu, item) { + var value = item.value; + Common.UI.Themes.setTheme(value); + this.view.btnDarkDocument.setDisabled(value !== 'theme-dark'); + }, this)); + } } }, diff --git a/apps/presentationeditor/main/app/controller/ViewTab.js b/apps/presentationeditor/main/app/controller/ViewTab.js index 4836eaf3a..b6be8dd51 100644 --- a/apps/presentationeditor/main/app/controller/ViewTab.js +++ b/apps/presentationeditor/main/app/controller/ViewTab.js @@ -135,11 +135,13 @@ define([ onAppReady: function (config) { var me = this; - (new Promise(function (accept, reject) { - accept(); - })).then(function(){ - me.view.setEvents(); - }); + if (me.view) { + (new Promise(function (accept, reject) { + accept(); + })).then(function () { + me.view.setEvents(); + }); + } }, onChangeZoomValue: function (value) { @@ -172,7 +174,7 @@ define([ this.api.asc_ShowNotes(checked); Common.localStorage.setBool('pe-hidden-notes', !checked); this.view.fireEvent('notes:hide', [!checked]); - Common.NotificationCenter.trigger('edit:complete', me.view); + Common.NotificationCenter.trigger('edit:complete', this.view); } }, PE.Controllers.ViewTab || {}));