[Libreoffice-commits] online.git: loleaflet/src
Szymon KÅos (via logerrit)
logerrit at kemper.freedesktop.org
Fri Apr 17 13:59:36 UTC 2020
loleaflet/src/control/Control.Menubar.js | 4 -
loleaflet/src/control/Control.Toolbar.js | 2
loleaflet/src/control/Control.UIManager.js | 94 ++++++++++++++++++++++++++++-
loleaflet/src/map/Map.js | 83 -------------------------
loleaflet/src/map/handler/Map.WOPI.js | 8 +-
5 files changed, 101 insertions(+), 90 deletions(-)
New commits:
commit 3a1cd33c9091b7d38a4b467b8e38b9ddface25c8
Author: Szymon Kłos <szymon.klos at collabora.com>
AuthorDate: Fri Apr 17 12:28:03 2020 +0200
Commit: Szymon Kłos <szymon.klos at collabora.com>
CommitDate: Fri Apr 17 15:59:17 2020 +0200
Move ruler & menubar toggling to UIManager
Change-Id: Idaaa90e48bcfb3620e78ad8e4c859eacdb4ff7cc
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/92416
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice at gmail.com>
Reviewed-by: Szymon Kłos <szymon.klos at collabora.com>
diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js
index b0c042d9e..ec5d49457 100644
--- a/loleaflet/src/control/Control.Menubar.js
+++ b/loleaflet/src/control/Control.Menubar.js
@@ -1027,7 +1027,7 @@ L.Control.Menubar = L.Control.extend({
self.options.allowedViewModeActions.splice(index, 1);
}
} else if (id === 'showruler') {
- if (self._map.isRulerVisible()) {
+ if (self._map.uiManager.isRulerVisible()) {
$(aItem).addClass(constChecked);
} else {
$(aItem).removeClass(constChecked);
@@ -1156,7 +1156,7 @@ L.Control.Menubar = L.Control.extend({
} else if (id === 'fullscreen') {
L.toggleFullScreen();
} else if (id === 'showruler') {
- this._map.toggleRuler();
+ this._map.uiManager.toggleRuler();
} else if (id === 'fullscreen-presentation' && this._map.getDocType() === 'presentation') {
this._map.fire('fullscreen');
} else if (id === 'insertpage') {
diff --git a/loleaflet/src/control/Control.Toolbar.js b/loleaflet/src/control/Control.Toolbar.js
index ece25efcb..0dc0264d6 100644
--- a/loleaflet/src/control/Control.Toolbar.js
+++ b/loleaflet/src/control/Control.Toolbar.js
@@ -127,7 +127,7 @@ function onClick(e, id, item) {
onColorPick(id, e.color);
}
else if (id === 'fold' || id === 'hamburger-tablet') {
- map.toggleMenubar();
+ map.uiManager.toggleMenubar();
}
else if (id === 'close' || id === 'closemobile') {
if (window.ThisIsAMobileApp) {
diff --git a/loleaflet/src/control/Control.UIManager.js b/loleaflet/src/control/Control.UIManager.js
index a75481b9f..8e4967481 100644
--- a/loleaflet/src/control/Control.UIManager.js
+++ b/loleaflet/src/control/Control.UIManager.js
@@ -1,6 +1,7 @@
/* -*- js-indent-level: 8 -*- */
/*
- * L.Control.UIManager
+ * L.Control.UIManager - initializes the UI elements like toolbars, menubar or ruler
+ and allows to controll them (show/hide)
*/
/* global $ setupToolbar w2ui w2utils */
@@ -11,6 +12,8 @@ L.Control.UIManager = L.Control.extend({
map.on('updatepermission', this.onUpdatePermission, this);
},
+ // UI initialization
+
initializeBasicUI: function() {
var that = this;
@@ -81,6 +84,80 @@ L.Control.UIManager = L.Control.extend({
}
},
+ // Menubar
+
+ showMenubar: function() {
+ if (!this.isMenubarHidden())
+ return;
+ $('.main-nav').show();
+ if (L.Params.closeButtonEnabled && !window.mode.isTablet()) {
+ $('#closebuttonwrapper').show();
+ }
+
+ var obj = $('.unfold');
+ obj.removeClass('w2ui-icon unfold');
+ obj.addClass('w2ui-icon fold');
+
+ this.moveObjectVertically($('#spreadsheet-row-column-frame'), 36);
+ this.moveObjectVertically($('#document-container'), 36);
+ this.moveObjectVertically($('#presentation-controls-wrapper'), 36);
+ this.moveObjectVertically($('#sidebar-dock-wrapper'), 36);
+ },
+
+ hideMenubar: function() {
+ if (this.isMenubarHidden())
+ return;
+ $('.main-nav').hide();
+ if (L.Params.closeButtonEnabled) {
+ $('#closebuttonwrapper').hide();
+ }
+
+ var obj = $('.fold');
+ obj.removeClass('w2ui-icon fold');
+ obj.addClass('w2ui-icon unfold');
+
+ this.moveObjectVertically($('#spreadsheet-row-column-frame'), -36);
+ this.moveObjectVertically($('#document-container'), -36);
+ this.moveObjectVertically($('#presentation-controls-wrapper'), -36);
+ this.moveObjectVertically($('#sidebar-dock-wrapper'), -36);
+ },
+
+ isMenubarHidden: function() {
+ return $('.main-nav').css('display') === 'none';
+ },
+
+ toggleMenubar: function() {
+ if (this.isMenubarHidden())
+ this.showMenubar();
+ else
+ this.hideMenubar();
+ },
+
+ // Ruler
+
+ showRuler: function() {
+ $('.loleaflet-ruler').show();
+ $('#map').addClass('hasruler');
+ },
+
+ hideRuler: function() {
+ $('.loleaflet-ruler').hide();
+ $('#map').removeClass('hasruler');
+ },
+
+ toggleRuler: function() {
+ if (this.isRulerVisible())
+ this.hideRuler();
+ else
+ this.showRuler();
+ },
+
+ isRulerVisible: function() {
+ return $('.loleaflet-ruler').is(':visible');
+ },
+
+ // Event handlers
+
onUpdatePermission: function(e) {
if (window.mode.isMobile()) {
if (e.perm === 'edit') {
@@ -102,6 +179,21 @@ L.Control.UIManager = L.Control.extend({
toolbarUp.resize();
statusbar.resize();
}
+ },
+
+ // Helper functions
+
+ moveObjectVertically: function(obj, diff) {
+ if (obj) {
+ var prevTop = obj.css('top');
+ if (prevTop) {
+ prevTop = parseInt(prevTop.slice(0, -2)) + diff;
+ }
+ else {
+ prevTop = 0 + diff;
+ }
+ obj.css({'top': String(prevTop) + 'px'});
+ }
}
});
diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js
index b333774da..860117cc5 100644
--- a/loleaflet/src/map/Map.js
+++ b/loleaflet/src/map/Map.js
@@ -3,19 +3,6 @@
* L.Map is the central class of the API - it is used to create a map.
*/
-function moveObjectVertically(obj, diff) {
- if (obj) {
- var prevTop = obj.css('top');
- if (prevTop) {
- prevTop = parseInt(prevTop.slice(0, -2)) + diff;
- }
- else {
- prevTop = 0 + diff;
- }
- obj.css({'top': String(prevTop) + 'px'});
- }
-}
-
function isAnyVexDialogActive() {
var res = false;
for (var vexId in vex.getAll()) {
@@ -53,7 +40,7 @@ L.Map = L.Evented.extend({
cursorURL: 'images/cursors'
},
- // uiManager is set in main.js
+ // Control.UIManager instance, set in main.js
uiManager: null,
// Control.LokDialog instance, is set in Control.UIManager.js
@@ -1764,74 +1751,6 @@ L.Map = L.Evented.extend({
IsFollowEditor: followEditor}});
},
- showMenubar: function() {
- if (!this.isMenubarHidden())
- return;
- $('.main-nav').show();
- if (L.Params.closeButtonEnabled && !window.mode.isTablet()) {
- $('#closebuttonwrapper').show();
- }
-
- var obj = $('.unfold');
- obj.removeClass('w2ui-icon unfold');
- obj.addClass('w2ui-icon fold');
-
- moveObjectVertically($('#spreadsheet-row-column-frame'), 36);
- moveObjectVertically($(this.options.documentContainer), 36);
- moveObjectVertically($('#presentation-controls-wrapper'), 36);
- moveObjectVertically($('#sidebar-dock-wrapper'), 36);
- },
-
- hideMenubar: function() {
- if (this.isMenubarHidden())
- return;
- $('.main-nav').hide();
- if (L.Params.closeButtonEnabled) {
- $('#closebuttonwrapper').hide();
- }
-
- var obj = $('.fold');
- obj.removeClass('w2ui-icon fold');
- obj.addClass('w2ui-icon unfold');
-
- moveObjectVertically($('#spreadsheet-row-column-frame'), -36);
- moveObjectVertically($(this.options.documentContainer), -36);
- moveObjectVertically($('#presentation-controls-wrapper'), -36);
- moveObjectVertically($('#sidebar-dock-wrapper'), -36);
- },
-
- isMenubarHidden: function() {
- return $('.main-nav').css('display') === 'none';
- },
-
- toggleMenubar: function() {
- if (this.isMenubarHidden())
- this.showMenubar();
- else
- this.hideMenubar();
- },
-
- showRuler: function() {
- $('.loleaflet-ruler').show();
- $('#map').addClass('hasruler');
- },
-
- hideRuler: function() {
- $('.loleaflet-ruler').hide();
- $('#map').removeClass('hasruler');
- },
-
- toggleRuler: function() {
- if (this.isRulerVisible())
- this.hideRuler();
- else
- this.showRuler();
- },
-
- isRulerVisible: function() {
- return $('.loleaflet-ruler').is(':visible');
- },
-
hasObjectFocusDarkOverlay: function() {
return !!this.focusLayer;
},
diff --git a/loleaflet/src/map/handler/Map.WOPI.js b/loleaflet/src/map/handler/Map.WOPI.js
index 89f01ec53..b3a4a2fc6 100644
--- a/loleaflet/src/map/handler/Map.WOPI.js
+++ b/loleaflet/src/map/handler/Map.WOPI.js
@@ -247,16 +247,16 @@ L.Map.WOPI = L.Handler.extend({
w2ui['actionbar'].remove(msg.Values.id);
}
else if (msg.MessageId === 'Show_Menubar') {
- this._map.showMenubar();
+ this._map.uiManager.showMenubar();
}
else if (msg.MessageId === 'Hide_Menubar') {
- this._map.hideMenubar();
+ this._map.uiManager.hideMenubar();
}
else if (msg.MessageId === 'Show_Ruler') {
- this._map.showRuler();
+ this._map.uiManager.showRuler();
}
else if (msg.MessageId === 'Hide_Ruler') {
- this._map.hideRuler();
+ this._map.uiManager.hideRuler();
}
else if (msg.MessageId === 'Show_Menu_Item' || msg.MessageId === 'Hide_Menu_Item') {
if (!msg.Values) {
More information about the Libreoffice-commits
mailing list