[PE] Move function StartDemostration to viewport.

This commit is contained in:
Julia Radzhabova 2017-07-20 16:46:45 +03:00
parent 684264e27a
commit ed09cac20b
4 changed files with 46 additions and 128 deletions

View file

@ -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);
},
/*

View file

@ -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) {

View file

@ -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();
}
}
}
});
});

View file

@ -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({