From ed09cac20bc26ac85418dbd80788bee43087500d Mon Sep 17 00:00:00 2001 From: Julia Radzhabova Date: Thu, 20 Jul 2017 16:46:45 +0300 Subject: [PATCH] [PE] Move function StartDemostration to viewport. --- .../main/app/controller/Statusbar.js | 40 +------------ .../main/app/controller/Toolbar.js | 36 +----------- .../main/app/controller/Viewport.js | 40 +++++++++++++ .../main/app/view/DocumentHolder.js | 58 +------------------ 4 files changed, 46 insertions(+), 128 deletions(-) diff --git a/apps/presentationeditor/main/app/controller/Statusbar.js b/apps/presentationeditor/main/app/controller/Statusbar.js index b3c170b87..65d8f2816 100644 --- a/apps/presentationeditor/main/app/controller/Statusbar.js +++ b/apps/presentationeditor/main/app/controller/Statusbar.js @@ -128,44 +128,8 @@ define([ }, onPreview: function(btn, e) { - var previewPanel = PE.getController('Viewport').getView('DocumentPreview'), - me = this, - isResized = false; - if (previewPanel && me.api) { - previewPanel.show(); - var onWindowResize = function() { - if (isResized) return; - isResized = true; - Common.NotificationCenter.off('window:resize', onWindowResize); - - var current = me.api.getCurrentPage(); - me.api.StartDemonstration('presentation-preview', _.isNumber(current) ? current : 0); - - Common.component.Analytics.trackEvent('Status Bar', 'Preview'); - }; - if (!me.statusbar.mode.isDesktopApp && !Common.Utils.isIE11) { - Common.NotificationCenter.on('window:resize', onWindowResize); - me.fullScreen(document.documentElement); - setTimeout(function(){ - onWindowResize(); - }, 100); - } else - onWindowResize(); - } - }, - - fullScreen: function(element) { - if (element) { - if(element.requestFullscreen) { - element.requestFullscreen(); - } else if(element.webkitRequestFullscreen) { - element.webkitRequestFullscreen(); - } else if(element.mozRequestFullScreen) { - element.mozRequestFullScreen(); - } else if(element.msRequestFullscreen) { - element.msRequestFullscreen(); - } - } + var current = this.api.getCurrentPage(); + Common.NotificationCenter.trigger('preview:start', _.isNumber(current) ? current : 0); }, /* diff --git a/apps/presentationeditor/main/app/controller/Toolbar.js b/apps/presentationeditor/main/app/controller/Toolbar.js index 90d4b21de..1d01ca13f 100644 --- a/apps/presentationeditor/main/app/controller/Toolbar.js +++ b/apps/presentationeditor/main/app/controller/Toolbar.js @@ -800,41 +800,7 @@ define([ }, onPreview: function(slidenum) { - var previewPanel = PE.getController('Viewport').getView('DocumentPreview'), - me = this, - isResized = false; - if (previewPanel && me.api) { - previewPanel.show(); - var onWindowResize = function() { - if (isResized) return; - isResized = true; - Common.NotificationCenter.off('window:resize', onWindowResize); - me.api.StartDemonstration('presentation-preview', _.isNumber(slidenum) ? slidenum : 0, PE.getController('Main').document); - Common.component.Analytics.trackEvent('ToolBar', 'Preview'); - }; - if (!me.toolbar.mode.isDesktopApp && !Common.Utils.isIE11) { - Common.NotificationCenter.on('window:resize', onWindowResize); - me.fullScreen(document.documentElement); - setTimeout(function(){ - onWindowResize(); - }, 100); - } else - onWindowResize(); - } - }, - - fullScreen: function(element) { - if (element) { - if(element.requestFullscreen) { - element.requestFullscreen(); - } else if(element.webkitRequestFullscreen) { - element.webkitRequestFullscreen(); - } else if(element.mozRequestFullScreen) { - element.mozRequestFullScreen(); - } else if(element.msRequestFullscreen) { - element.msRequestFullscreen(); - } - } + Common.NotificationCenter.trigger('preview:start', _.isNumber(slidenum) ? slidenum : 0); }, onPreviewBtnClick: function(btn, e) { diff --git a/apps/presentationeditor/main/app/controller/Viewport.js b/apps/presentationeditor/main/app/controller/Viewport.js index d35e86f09..08cf40de3 100644 --- a/apps/presentationeditor/main/app/controller/Viewport.js +++ b/apps/presentationeditor/main/app/controller/Viewport.js @@ -84,6 +84,7 @@ define([ } }); + Common.NotificationCenter.on('preview:start', this.onPreviewStart.bind(this)); }, setApi: function(api) { @@ -151,6 +152,45 @@ define([ onWindowResize: function(e) { this.onLayoutChanged('window'); Common.NotificationCenter.trigger('window:resize'); + }, + + onPreviewStart: function(slidenum) { + this.previewPanel = this.previewPanel || PE.getController('Viewport').getView('DocumentPreview'); + var me = this, + isResized = false; + if (this.previewPanel && !this.previewPanel.isVisible() && this.api) { + this.previewPanel.show(); + var _onWindowResize = function() { + if (isResized) return; + isResized = true; + Common.NotificationCenter.off('window:resize', _onWindowResize); + me.api.StartDemonstration('presentation-preview', _.isNumber(slidenum) ? slidenum : 0, PE.getController('Main').document); + Common.component.Analytics.trackEvent('Viewport', 'Preview'); + }; + if (!me.viewport.mode.isDesktopApp && !Common.Utils.isIE11) { + Common.NotificationCenter.on('window:resize', _onWindowResize); + me.fullScreen(document.documentElement); + setTimeout(function(){ + _onWindowResize(); + }, 100); + } else + _onWindowResize(); + } + }, + + fullScreen: function(element) { + if (element) { + if(element.requestFullscreen) { + element.requestFullscreen(); + } else if(element.webkitRequestFullscreen) { + element.webkitRequestFullscreen(); + } else if(element.mozRequestFullScreen) { + element.mozRequestFullScreen(); + } else if(element.msRequestFullscreen) { + element.msRequestFullscreen(); + } + } } + }); }); diff --git a/apps/presentationeditor/main/app/view/DocumentHolder.js b/apps/presentationeditor/main/app/view/DocumentHolder.js index a4e2c1ab0..71ec44c2c 100644 --- a/apps/presentationeditor/main/app/view/DocumentHolder.js +++ b/apps/presentationeditor/main/app/view/DocumentHolder.js @@ -1455,24 +1455,7 @@ define([ e.preventDefault(); e.stopPropagation(); if (me.slidesCount>0) { - var previewPanel = PE.getController('Viewport').getView('DocumentPreview'); - if (previewPanel && !previewPanel.isVisible() && me.api) { - previewPanel.show(); - var onWindowResize = function() { - if (isResized) return; - isResized = true; - Common.NotificationCenter.off('window:resize', onWindowResize); - me.api.StartDemonstration('presentation-preview', 0); - }; - if (!me.mode.isDesktopApp && !Common.Utils.isIE11) { - Common.NotificationCenter.on('window:resize', onWindowResize); - me.fullScreen(document.documentElement); - setTimeout(function(){ - onWindowResize(); - }, 100); - } else - onWindowResize(); - } + Common.NotificationCenter.trigger('preview:start', 0); } }; Common.util.Shortcuts.delegateShortcuts({shortcuts:keymap}); @@ -1657,20 +1640,6 @@ define([ me.fireEvent('editcomplete', me); }, - fullScreen: function(element) { - if (element) { - if(element.requestFullscreen) { - element.requestFullscreen(); - } else if(element.webkitRequestFullscreen) { - element.webkitRequestFullscreen(); - } else if(element.mozRequestFullScreen) { - element.mozRequestFullScreen(); - } else if(element.msRequestFullscreen) { - element.msRequestFullscreen(); - } - } - }, - onSlidePickerShowAfter: function(picker) { if (!picker._needRecalcSlideLayout) return; @@ -1773,29 +1742,8 @@ define([ var mnuPreview = new Common.UI.MenuItem({ caption : me.txtPreview }).on('click', function(item) { - var previewPanel = PE.getController('Viewport').getView('DocumentPreview'), - isResized = false; - if (previewPanel && me.api) { - previewPanel.show(); - var onWindowResize = function() { - if (isResized) return; - isResized = true; - Common.NotificationCenter.off('window:resize', onWindowResize); - - var current = me.api.getCurrentPage(); - me.api.StartDemonstration('presentation-preview', _.isNumber(current) ? current : 0); - - Common.component.Analytics.trackEvent('DocumentHolder', 'Preview'); - }; - if (!me.mode.isDesktopApp && !Common.Utils.isIE11) { - Common.NotificationCenter.on('window:resize', onWindowResize); - me.fullScreen(document.documentElement); - setTimeout(function(){ - onWindowResize(); - }, 100); - } else - onWindowResize(); - } + var current = this.api.getCurrentPage(); + Common.NotificationCenter.trigger('preview:start', _.isNumber(current) ? current : 0); }); var mnuSelectAll = new Common.UI.MenuItem({