loleaflet/html/framed.html | 17 ++++++++- loleaflet/reference.html | 14 +++++++ loleaflet/src/map/Map.js | 63 ++++++++++++++++++++-------------- loleaflet/src/map/handler/Map.WOPI.js | 6 +++ 4 files changed, 74 insertions(+), 26 deletions(-)
New commits: commit 9e529e84bf1c4d22066cf5431427658068b2ac3d Author: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> AuthorDate: Mon May 13 17:29:02 2019 +0200 Commit: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> CommitDate: Tue May 14 08:19:41 2019 +0200 Add UI customizing example to framed.html Change-Id: I137edcaf9b46f4bff4c30204174215d170abc1eb Reviewed-on: https://gerrit.libreoffice.org/72241 Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> Tested-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> diff --git a/loleaflet/html/framed.html b/loleaflet/html/framed.html index c3f46f39b..ee216ce14 100644 --- a/loleaflet/html/framed.html +++ b/loleaflet/html/framed.html @@ -117,6 +117,12 @@ '*'); } + function ShowMenubar(visible) { + var messageId = visible ? 'Show_Menubar' : 'Hide_Menubar'; + window.frames[0].postMessage(JSON.stringify({'MessageId': 'Host_PostmessageReady'}), '*'); + window.frames[0].postMessage(JSON.stringify({'MessageId': messageId}), '*'); + } + // This function is invoked when the iframe posts a message back. function receiveMessage(event) { @@ -172,7 +178,7 @@ </head> <body style="user-select: none;"> - + <h3>Calc functions</h3> <p> <form id="cell-colour-form"> Cell: (<input type="number" name="x" min="0" max="20" value="0">, <input type="number" name="y" min="0" max="20" value="0">), @@ -199,6 +205,15 @@ Click <button onclick="callDeleteNamedRange(); return false;">here</button> to delete the named range called <input type="text" name="name"> </form> + <h3>UI modification</h3> + <form id="menubar-toggle"> + <button onclick="ShowMenubar(false); return false;">Hide Menubar</button> + <button onclick="ShowMenubar(true); return false;">Show Menubar</button> + </form> + + + <h3>Document frame</h3> + <!-- The hostname and pathnames below are obviously specific to my personal environment and need to be changed appropriately. Also the hex string needs to be changed of course, to the right one as commit 0010ca1fb74112ecede1d520cbf0e5e12fe69655 Author: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> AuthorDate: Mon May 13 17:08:24 2019 +0200 Commit: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> CommitDate: Tue May 14 08:19:30 2019 +0200 Add API methods to hide/show menu bar Change-Id: I6b0731dbeda29edb311b460e1356fc6b97b9cebe Reviewed-on: https://gerrit.libreoffice.org/72239 Reviewed-by: Jan Holesovsky <ke...@collabora.com> Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> Tested-by: Samuel Mehrbrodt <samuel.mehrbr...@cib.de> diff --git a/loleaflet/reference.html b/loleaflet/reference.html index 2fb7c801f..e08bfa453 100644 --- a/loleaflet/reference.html +++ b/loleaflet/reference.html @@ -3143,6 +3143,20 @@ WOPI host to editor function in <a href="https://opengrok.libreoffice.org/xref/online/loleaflet/js/toolbar.js">loleaflet/js/toolbar.js</a>. </td> </tr> + <tr> + <td><code><b>Hide_Menubar</b></code></td> + <td></td> + <td> + Hides the menu bar. + </td> + </tr> + <tr> + <td><code><b>Show_Menubar</b></code></td> + <td></td> + <td> + Shows the menu bar. + </td> + </tr> </table> Editor to WOPI host <table data-id='postmessage-misc-to-host'> diff --git a/loleaflet/src/map/Map.js b/loleaflet/src/map/Map.js index 3f2ee86ee..34aa358e2 100644 --- a/loleaflet/src/map/Map.js +++ b/loleaflet/src/map/Map.js @@ -1457,36 +1457,49 @@ L.Map = L.Evented.extend({ IsFollowEditor: followEditor}}); }, - toggleMenubar: function() { - var obj = null; - if ($('.main-nav').css('display') === 'none') { - $('.main-nav').css({'display': ''}); - if (closebutton && !window.mode.isTablet()) { - $('#closebuttonwrapper').css({'display': ''}); - } + showMenubar: function() { + if (!this.isMenubarHidden()) + return; + $('.main-nav').css({'display': ''}); + if (closebutton && !window.mode.isTablet()) { + $('#closebuttonwrapper').css({'display': ''}); + } - obj = $('.unfold'); - obj.removeClass('w2ui-icon unfold'); - obj.addClass('w2ui-icon fold'); + var obj = $('.unfold'); + obj.removeClass('w2ui-icon unfold'); + obj.addClass('w2ui-icon fold'); - moveObjectVertically($('#spreadsheet-row-column-frame'), 36); - moveObjectVertically($('#document-container'), 36); - moveObjectVertically($('#presentation-controls-wrapper'), 36); + moveObjectVertically($('#spreadsheet-row-column-frame'), 36); + moveObjectVertically($('#document-container'), 36); + moveObjectVertically($('#presentation-controls-wrapper'), 36); + }, + + hideMenubar: function() { + if (this.isMenubarHidden()) + return; + $('.main-nav').css({'display': 'none'}); + if (closebutton) { + $('#closebuttonwrapper').css({'display': 'none'}); } - else { - $('.main-nav').css({'display': 'none'}); - if (closebutton) { - $('#closebuttonwrapper').css({'display': 'none'}); - } - obj = $('.fold'); - obj.removeClass('w2ui-icon fold'); - obj.addClass('w2ui-icon unfold'); + var obj = $('.fold'); + obj.removeClass('w2ui-icon fold'); + obj.addClass('w2ui-icon unfold'); - moveObjectVertically($('#spreadsheet-row-column-frame'), -36); - moveObjectVertically($('#document-container'), -36); - moveObjectVertically($('#presentation-controls-wrapper'), -36); - } + moveObjectVertically($('#spreadsheet-row-column-frame'), -36); + moveObjectVertically($('#document-container'), -36); + moveObjectVertically($('#presentation-controls-wrapper'), -36); + }, + + isMenubarHidden: function() { + return $('.main-nav').css('display') === 'none'; + }, + + toggleMenubar: function() { + if (this.isMenubarHidden()) + this.showMenubar(); + else + this.hideMenubar(); } }); diff --git a/loleaflet/src/map/handler/Map.WOPI.js b/loleaflet/src/map/handler/Map.WOPI.js index ff9200086..57f41b31f 100644 --- a/loleaflet/src/map/handler/Map.WOPI.js +++ b/loleaflet/src/map/handler/Map.WOPI.js @@ -218,6 +218,12 @@ L.Map.WOPI = L.Handler.extend({ w2ui['editbar'].hide(msg.Values.id); } } + else if (msg.MessageId === 'Show_Menubar') { + this._map.showMenubar(); + } + else if (msg.MessageId === 'Hide_Menubar') { + this._map.hideMenubar(); + } else if (msg.MessageId === 'Set_Settings') { if (msg.Values) { var alwaysActive = msg.Values.AlwaysActive; _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits