summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSzymon Kłos <szymon.klos@collabora.com>2022-09-09 16:17:30 +0200
committerGökay ŞATIR <gokaysatir@gmail.com>2022-09-19 17:37:01 +0300
commitbf0436503a6aa294b69e3d982bae6d4be1cc46a9 (patch)
treef48b6035447ec46fab335c86b57500ceb6b79011
parentsidebar: move sidebar show action to more generic place (diff)
downloadonline-bf0436503a6aa294b69e3d982bae6d4be1cc46a9.tar.gz
online-bf0436503a6aa294b69e3d982bae6d4be1cc46a9.zip
sidebar: show on demand
Previously sidebar was always active on launch. This patch together with core fix changes that so initially it is off and we don't waste resources for rendering sidebar which is hidden just after short time. We don't know the state of sidebar (which deck is activated) on the core side so in some cases we need to switch decks in 2 steps: send SidebarShow, and when we received result we change deck to other one or we do nothing. This allows us to switch correctly the decks. Signed-off-by: Szymon Kłos <szymon.klos@collabora.com> Change-Id: Ib161cae73fd1344d375cb37712c5e805c4d1eefb
-rw-r--r--browser/src/control/Control.Sidebar.js58
-rw-r--r--browser/src/control/Control.UIManager.js19
-rw-r--r--browser/src/control/Toolbar.js23
3 files changed, 80 insertions, 20 deletions
diff --git a/browser/src/control/Control.Sidebar.js b/browser/src/control/Control.Sidebar.js
index 322d0e9480..366aa4e1ce 100644
--- a/browser/src/control/Control.Sidebar.js
+++ b/browser/src/control/Control.Sidebar.js
@@ -3,7 +3,7 @@
* L.Control.Sidebar
*/
-/* global $ */
+/* global $ app */
L.Control.Sidebar = L.Control.extend({
options: {
@@ -12,6 +12,7 @@ L.Control.Sidebar = L.Control.extend({
container: null,
builder: null,
+ targetDeckCommand: null,
onAdd: function (map) {
this.map = map;
@@ -30,6 +31,10 @@ L.Control.Sidebar = L.Control.extend({
this.map.off('jsdialogaction', this.onJSAction, this);
},
+ isVisible: function() {
+ return $('#sidebar-dock-wrapper').is(':visible');
+ },
+
closeSidebar: function() {
$('#sidebar-dock-wrapper').hide();
this.map._onResize();
@@ -39,10 +44,7 @@ L.Control.Sidebar = L.Control.extend({
this.map.focus();
}
- if (window.initSidebarState) {
- this.map.uiManager.setSavedState('ShowSidebar', false);
- window.initSidebarState = false;
- }
+ this.map.uiManager.setSavedState('ShowSidebar', false);
},
onJSUpdate: function (e) {
@@ -123,6 +125,31 @@ L.Control.Sidebar = L.Control.extend({
this.map.uiManager.setSavedState('SdMasterPagesDeck', false);
},
+ commandForDeck: function(deckId) {
+ if (deckId === 'PropertyDeck')
+ return ''; // not important for us
+ else if (deckId === 'SdSlideTransitionDeck')
+ return '.uno:SlideChangeWindow';
+ else if (deckId === 'SdCustomAnimationDeck')
+ return '.uno:CustomAnimation';
+ else if (deckId === 'SdMasterPagesDeck')
+ return '.uno:MasterSlidesPanel';
+ return '';
+ },
+
+ setupTargetDeck: function(unoCommand) {
+ this.targetDeckCommand = unoCommand;
+ },
+
+ getTargetDeck: function() {
+ return this.targetDeckCommand;
+ },
+
+ changeDeck: function(unoCommand) {
+ app.socket.sendMessage('uno ' + unoCommand);
+ this.setupTargetDeck(unoCommand);
+ },
+
onSidebar: function(data) {
var sidebarData = data.data;
this.builder.setWindowId(sidebarData.id);
@@ -143,17 +170,28 @@ L.Control.Sidebar = L.Control.extend({
if (this.map.getDocType() === 'presentation' && sidebarData.children && sidebarData.children[0] && sidebarData.children[0].id) {
this.unsetSelectedSidebar();
- this.map.uiManager.setSavedState(sidebarData.children[0].id, true);
+ var currentDeck = sidebarData.children[0].id;
+ this.map.uiManager.setSavedState(currentDeck, true);
+ if (this.targetDeckCommand) {
+ var stateHandler = this.map['stateChangeHandler'];
+ var isCurrent = stateHandler ?
+ stateHandler.getItemValue(this.targetDeckCommand) : false;
+ // just to be sure chack with other method
+ if (isCurrent === 'false' || !isCurrent)
+ isCurrent = this.targetDeckCommand === this.commandForDeck(currentDeck);
+ if (this.targetDeckCommand &&
+ (isCurrent === 'false' || !isCurrent))
+ this.changeDeck(this.targetDeckCommand);
+ } else {
+ this.changeDeck(this.targetDeckCommand);
+ }
}
this.builder.build(this.container, [sidebarData]);
if (wrapper.style.display === 'none')
$('#sidebar-dock-wrapper').show(this.options.animSpeed);
- if (window.initSidebarState) {
- this.map.uiManager.setSavedState('ShowSidebar', true);
- window.initSidebarState = false;
- }
+ this.map.uiManager.setSavedState('ShowSidebar', true);
} else {
this.closeSidebar();
}
diff --git a/browser/src/control/Control.UIManager.js b/browser/src/control/Control.UIManager.js
index 8e8371ba6e..e1e932f722 100644
--- a/browser/src/control/Control.UIManager.js
+++ b/browser/src/control/Control.UIManager.js
@@ -221,16 +221,27 @@ L.Control.UIManager = L.Control.extend({
if (window.mode.isDesktop() && !window.ThisIsAMobileApp) {
var showSidebar = this.getSavedStateOrDefault('ShowSidebar');
+ if (this.getSavedStateOrDefault('PropertyDeck')) {
+ app.socket.sendMessage('uno .uno:SidebarShow');
+ }
+
if (this.map.getDocType() === 'presentation') {
- if (this.getSavedStateOrDefault('SdSlideTransitionDeck'))
+ if (this.getSavedStateOrDefault('SdSlideTransitionDeck', false)) {
+ app.socket.sendMessage('uno .uno:SidebarShow');
app.socket.sendMessage('uno .uno:SlideChangeWindow');
- else if (this.getSavedStateOrDefault('SdCustomAnimationDeck'))
+ this.map.sidebar.setupTargetDeck('.uno:SlideChangeWindow');
+ } else if (this.getSavedStateOrDefault('SdCustomAnimationDeck', false)) {
+ app.socket.sendMessage('uno .uno:SidebarShow');
app.socket.sendMessage('uno .uno:CustomAnimation');
- else if (this.getSavedStateOrDefault('SdMasterPagesDeck'))
+ this.map.sidebar.setupTargetDeck('.uno:CustomAnimation');
+ } else if (this.getSavedStateOrDefault('SdMasterPagesDeck', false)) {
+ app.socket.sendMessage('uno .uno:SidebarShow');
app.socket.sendMessage('uno .uno:MasterSlidesPanel');
+ this.map.sidebar.setupTargetDeck('.uno:MasterSlidesPanel');
+ }
}
- if (showSidebar === false)
+ if (!showSidebar)
app.socket.sendMessage('uno .uno:SidebarHide');
}
else if (window.mode.isChromebook()) {
diff --git a/browser/src/control/Toolbar.js b/browser/src/control/Toolbar.js
index da57d212a3..4e927e8a54 100644
--- a/browser/src/control/Toolbar.js
+++ b/browser/src/control/Toolbar.js
@@ -323,14 +323,25 @@ L.Map.include({
sendUnoCommand: function (command, json) {
if ((command.startsWith('.uno:Sidebar') && !command.startsWith('.uno:SidebarShow')) ||
- command.startsWith('.uno:SlideMasterPage') ||
- command.startsWith('.uno:ModifyPage') || command.startsWith('.uno:SlideChangeWindow') ||
- command.startsWith('.uno:CustomAnimation') || command.startsWith('.uno:MasterSlidesPanel')) {
+ command.startsWith('.uno:SlideMasterPage') || command.startsWith('.uno:SlideChangeWindow') ||
+ command.startsWith('.uno:CustomAnimation') || command.startsWith('.uno:MasterSlidesPanel') ||
+ command.startsWith('.uno:ModifyPage')) {
+
+ // sidebar control is present only in desktop/tablet case
+ if (this.sidebar) {
+ if (this.sidebar.isVisible()) {
+ this.sidebar.setupTargetDeck(command);
+ } else {
+ // we don't know which deck was active last, show first then switch if needed
+ app.socket.sendMessage('uno .uno:SidebarShow');
- if (!this.uiManager.getSavedStateOrDefault('ShowSidebar', false))
- this.sendUnoCommand('.uno:SidebarShow');
+ if (this.sidebar.getTargetDeck() == null)
+ app.socket.sendMessage('uno ' + command);
- window.initSidebarState = true;
+ this.sidebar.setupTargetDeck(command);
+ return;
+ }
+ }
}
// To exercise the Trace Event functionality, uncomment this