loleaflet/css/toolbar.css | 3 loleaflet/src/control/Control.JSDialogBuilder.js | 2 loleaflet/src/control/Control.Menubar.js | 103 +++++++++++++---------- loleaflet/src/control/Control.Toolbar.js | 17 +++ 4 files changed, 77 insertions(+), 48 deletions(-)
New commits: commit 19de29462a790bca2bfdb91d8a03622674cf4af0 Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Mon Oct 7 18:32:30 2019 +0100 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Mon Oct 7 18:33:29 2019 +0100 mobile: disable insert menus, and various items that create dialogs. Change-Id: I2cc788f251a81f4acd5b0ad578dc1cf73474fffe diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js index 6b9f348c7..fbeba7af1 100644 --- a/loleaflet/src/control/Control.Menubar.js +++ b/loleaflet/src/control/Control.Menubar.js @@ -73,17 +73,17 @@ L.Control.Menubar = L.Control.extend({ {type: 'separator'}, {name: _UNO('.uno:ShowResolvedAnnotations', 'text'), id: 'showresolved', type: 'action'}, {type: 'separator'}, - {uno: '.uno:Sidebar'}, + {uno: '.uno:Sidebar', mobile: false}, {id: 'mobile-wizard', type: 'action', name: _('Mobile Wizard'), mobile: true, desktop: false} ] }, - {name: _UNO('.uno:InsertMenu', 'text'), id: 'insert', type: 'menu', menu: [ + {name: _UNO('.uno:InsertMenu', 'text'), id: 'insert', mobile: false, type: 'menu', menu: [ {name: _('Local Image...'), id: 'insertgraphic', type: 'action'}, {name: _UNO('.uno:InsertGraphic', 'text'), id: 'insertgraphicremote', type: 'action'}, {name: _UNO('.uno:InsertAnnotation', 'text'), id: 'insertcomment', type: 'action'}, {uno: '.uno:InsertObjectChart'}, {type: 'separator'}, - {uno: '.uno:InsertSection', id: 'insertsection'}, + {uno: '.uno:InsertSection', id: 'insertsection', mobile: false }, {name: _UNO('.uno:InsertField', 'text'), type: 'menu', menu: [ {uno: '.uno:InsertPageNumberField'}, {uno: '.uno:InsertPageCountField'}, @@ -106,7 +106,7 @@ L.Control.Menubar = L.Control.extend({ {uno: '.uno:InsertColumnBreak'}, {type: 'separator'}, {name: _UNO('.uno:HyperlinkDialog'), id: 'hyperlink', type: 'action'}, - {uno: '.uno:InsertSymbol'}, + {uno: '.uno:InsertSymbol', mobile: false}, {name: _UNO('.uno:FormattingMarkMenu', 'text'), type: 'menu', menu: [ {uno: '.uno:InsertNonBreakingSpace'}, {uno: '.uno:InsertHardHyphen'}, @@ -115,12 +115,12 @@ L.Control.Menubar = L.Control.extend({ {uno: '.uno:InsertZWNBSP'}, {uno: '.uno:InsertLRM'}, {uno: '.uno:InsertRLM'}]}, - {name: _UNO('.uno:IndexesMenu', 'text'), type: 'menu', menu: [ + {name: _UNO('.uno:IndexesMenu', 'text'), type: 'menu', mobile: false, menu: [ {uno: '.uno:InsertIndexesEntry'}, {uno: '.uno:InsertAuthoritiesEntry'}, {uno: '.uno:InsertMultiIndex'}]}, ]}, - {name: _UNO('.uno:FormatMenu', 'text'), id: 'format', type: 'menu', menu: [ + {name: _UNO('.uno:FormatMenu', 'text'), id: 'format', mobile: false, type: 'menu', menu: [ {name: _UNO('.uno:FormatTextMenu', 'text'), type: 'menu', menu: [ {uno: '.uno:Bold'}, {uno: '.uno:Italic'}, @@ -205,7 +205,7 @@ L.Control.Menubar = L.Control.extend({ {type: 'separator'}, {uno: '.uno:ResetAttributes'} ]}, - {name: _UNO('.uno:TableMenu', 'text'), type: 'menu', menu: [ + {name: _UNO('.uno:TableMenu', 'text'), mobile: false, type: 'menu', menu: [ {name: _UNO('.uno:TableInsertMenu', 'text'), type: 'menu', menu: [ {uno: '.uno:InsertRowsBefore'}, {uno: '.uno:InsertRowsAfter'}, @@ -225,7 +225,7 @@ L.Control.Menubar = L.Control.extend({ {type: 'separator'}, {uno: '.uno:TableDialog'} ]}, - {name: _UNO('.uno:ToolsMenu', 'text'), id: 'tools', type: 'menu', menu: [ + {name: _UNO('.uno:ToolsMenu', 'text'), id: 'tools', mobile: false, type: 'menu', menu: [ {uno: '.uno:SpellingAndGrammarDialog'}, {uno: '.uno:SpellOnline'}, {uno: '.uno:ThesaurusDialog'}, @@ -243,7 +243,7 @@ L.Control.Menubar = L.Control.extend({ {uno: '.uno:OnlineAutoFormat'}]} ]}, {name: _UNO('.uno:HelpMenu', 'text'), id: 'help', type: 'menu', menu: [ - {name: _('Keyboard shortcuts'), id: 'keyboard-shortcuts', type: 'action', mobileapp: false}, + {name: _('Keyboard shortcuts'), id: 'keyboard-shortcuts', type: 'action', mobile: false, mobileapp: false}, {name: _('About'), id: 'about', type: 'action'}] }, {name: _('Last modification'), id: 'last-mod', type: 'action', mobile: false, tablet: false} @@ -290,7 +290,7 @@ L.Control.Menubar = L.Control.extend({ {uno: '.uno:Sidebar'}, {id: 'mobile-wizard', type: 'action', name: _('Mobile Wizard'), mobile: true, desktop: false}] }, - {name: _UNO('.uno:InsertMenu', 'presentation'), id: 'insert', type: 'menu', menu: [ + {name: _UNO('.uno:InsertMenu', 'presentation'), id: 'insert', mobile: false, type: 'menu', menu: [ {name: _('Local Image...'), id: 'insertgraphic', type: 'action'}, {name: _UNO('.uno:InsertGraphic', 'presentation'), id: 'insertgraphicremote', type: 'action'}, {name: _UNO('.uno:InsertAnnotation', 'presentation'), id: 'insertcomment', type: 'action'}, @@ -381,20 +381,20 @@ L.Control.Menubar = L.Control.extend({ {name: _UNO('.uno:ViewMenu', 'spreadsheet'), id: 'view', type: 'menu', menu: [ {name: _UNO('.uno:FullScreen', 'spreadsheet'), id: 'fullscreen', type: 'action', mobileapp: false}, {type: 'separator', mobileapp: false}, - {uno: '.uno:Sidebar'}, + {uno: '.uno:Sidebar', mobile: false}, {id: 'mobile-wizard', type: 'action', name: _('Mobile Wizard'), mobile: true, desktop: false} ]}, - {name: _UNO('.uno:InsertMenu', 'spreadsheet'), id: 'insert', type: 'menu', menu: [ + {name: _UNO('.uno:InsertMenu', 'spreadsheet'), id: 'insert', mobile: false, type: 'menu', menu: [ {name: _('Local Image...'), id: 'insertgraphic', type: 'action'}, {name: _UNO('.uno:InsertGraphic', 'spreadsheet'), id: 'insertgraphicremote', type: 'action'}, {uno: '.uno:InsertObjectChart'}, {name: _UNO('.uno:InsertAnnotation', 'spreadsheet'), id: 'insertcomment', type: 'action'}, {type: 'separator'}, {name: _UNO('.uno:HyperlinkDialog'), id: 'hyperlink', type: 'action'}, - {uno: '.uno:InsertSymbol'}, - {uno: '.uno:EditHeaderAndFooter'} + {uno: '.uno:InsertSymbol', mobile: false}, + {uno: '.uno:EditHeaderAndFooter', mobile: false} ]}, - {name: _UNO('.uno:FormatMenu', 'spreadsheet'), id: 'format', type: 'menu', menu: [ + {name: _UNO('.uno:FormatMenu', 'spreadsheet'), id: 'format', mobile: false, type: 'menu', menu: [ {uno: '.uno:ResetAttributes'}, {uno: '.uno:FormatCellDialog'}, {uno: '.uno:PageFormatDialog'}, @@ -1107,6 +1107,9 @@ L.Control.Menubar = L.Control.extend({ if (menu[i].mobileapp == true && !window.ThisIsAMobileApp) { continue; } + if (menu[i].mobile === false && window.mode.isMobile()) + continue; + var ulItem = L.DomUtil.create('ul', '', liItem); var subitemList = this._createMenu(menu[i].menu); if (!subitemList.length) { commit e330e71189cd840768e60f4fb5292dc2fea6b07c Author: Michael Meeks <michael.me...@collabora.com> AuthorDate: Mon Oct 7 18:07:40 2019 +0100 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Mon Oct 7 18:32:47 2019 +0100 mobile: generate wizard content from JSON rather than the HTML. Change-Id: I3a47abd23de5c8be0ab66cf1295982ff390edf7c diff --git a/loleaflet/src/control/Control.JSDialogBuilder.js b/loleaflet/src/control/Control.JSDialogBuilder.js index 03eb838f2..825112cae 100644 --- a/loleaflet/src/control/Control.JSDialogBuilder.js +++ b/loleaflet/src/control/Control.JSDialogBuilder.js @@ -411,7 +411,7 @@ L.Control.JSDialogBuilder = L.Control.extend({ if (builder.wizard) { $(sectionTitle).click(function() { if (data.executionType === 'action') { - builder.map.menubar._executeAction($(builder.map.menubar._getItem(data.id).children()[0])) + builder.map.menubar._executeAction(undefined, data.id); } else { builder.map.sendUnoCommand(data.command) } diff --git a/loleaflet/src/control/Control.Menubar.js b/loleaflet/src/control/Control.Menubar.js index 7c5184aab..6b9f348c7 100644 --- a/loleaflet/src/control/Control.Menubar.js +++ b/loleaflet/src/control/Control.Menubar.js @@ -832,8 +832,10 @@ L.Control.Menubar = L.Control.extend({ }); }, - _executeAction: function(item) { - var id = $(item).data('id'); + _executeAction: function(item, id) { + if (!id) + id = $(item).data('id'); + if (id === 'save') { // Save only when not read-only. if (map._permission !== 'readonly') { @@ -1190,48 +1192,58 @@ L.Control.Menubar = L.Control.extend({ }, generateMenuStructureFor: function(targetId) { - var item = this._getItem(targetId); - if (item === null) { + var docType = this._map.getDocType(); + var items = this.options[docType]; + var target = items.find(function(item) { return item.id === targetId; }); + + if (!target) { + console.log('Cannot find item ' + targetId); return ''; } - var menuStructure = this._generateMenuStructure(item, true) + var menuStructure = this._generateMenuStructure(target, docType, true) return menuStructure }, - _generateMenuStructure: function(item, mainMenu) { - var itemText = $($(item).children()[0]).text(); - if (itemText.endsWith('›')) - itemText = itemText.substring(0, itemText.length - 1); - - var children = $(item).children('ul').children('li'); - var itemEnabled = true; - if ($($(item).children()[0]).hasClass('disabled')) { - itemEnabled = false; - } - var itemType = 'submenu'; + _generateMenuStructure: function(item, docType, mainMenu) { + var itemType; if (mainMenu) { itemType = 'mainmenu'; - } else if (!children.length) { - itemType = 'menuitem'; - } - var itemID = $(item).attr('id'); - if (itemID && itemID.length > 5) { - itemID = itemID.substring(5); + } else { + if (item.mobile === false) + return undefined; + if (!item.menu) { + itemType = 'menuitem'; + } else { + itemType = 'submenu'; + } } + var itemName; + if (item.name) + itemName = item.name; + else if (item.uno) + itemName = _UNO(item.uno, docType); + else + return undefined; // separator + var menuStructure = { - id : itemID, + id : item.id, type : itemType, - enabled : itemEnabled, - text : itemText, - command : $($(item).children()[0]).data('uno'), - executionType : $($(item).children()[0]).data('type'), + enabled : !item.disabled, + text : itemName, + command : item.uno, + executionType : item.type, children : [] }; - for (var i = 0; i < children.length; i++) { - menuStructure['children'].push(this._generateMenuStructure(children[i], false)); + if (item.menu) + { + for (var i = 0; i < item.menu.length; i++) { + var element = this._generateMenuStructure(item.menu[i], docType, false); + if (element) + menuStructure['children'].push(element); + } } return menuStructure; } commit 2b35db0c8573e98cf614b201bc2d6757eea53bda Author: merttumer <mert.tu...@collabora.com> AuthorDate: Thu Jul 11 14:21:35 2019 +0300 Commit: Michael Meeks <michael.me...@collabora.com> CommitDate: Mon Oct 7 18:32:47 2019 +0100 Use Vex Dialog for insertshapes on mobile Change-Id: I1cdd5dca2efd54fef4fb17ef379ad8988794afa0 Signed-off-by: merttumer <mert.tu...@collabora.com> diff --git a/loleaflet/css/toolbar.css b/loleaflet/css/toolbar.css index f48094231..9aeffbb5a 100644 --- a/loleaflet/css/toolbar.css +++ b/loleaflet/css/toolbar.css @@ -728,7 +728,8 @@ button.leaflet-control-search-next padding: 2px; display: block; overflow: auto; /* child margins otherwise don't expand *this* element (parent) */ - width: 344px; + width: 100%; + height: 100%; } .insertshape-grid .row { diff --git a/loleaflet/src/control/Control.Toolbar.js b/loleaflet/src/control/Control.Toolbar.js index c70e94d68..b5571e387 100644 --- a/loleaflet/src/control/Control.Toolbar.js +++ b/loleaflet/src/control/Control.Toolbar.js @@ -624,7 +624,7 @@ var shapes = { ] }; -function insertShapes() { +function insertShapes(mobile) { var width = 10; var $grid = $('.insertshape-grid'); @@ -658,7 +658,10 @@ function insertShapes() { $grid.on({ click: function(e) { map.sendUnoCommand('.uno:' + $(e.target).data().uno); - closePopup(); + if (mobile) + vex.close(); + else + closePopup(); } }); } @@ -733,6 +736,15 @@ function createToolbar() { } } +function openInsertShapesDialog() { + vex.open({ + content: '<div id="insertshape-wrapper"><div id="insertshape-popup" class="insertshape-pop ui-widget ui-corner-all"><div class="insertshape-grid"></div></div></div>', + afterOpen: function() { + insertShapes(true); + } + }); +} + function initNormalToolbar() { var toolItems = [ {type: 'button', id: 'closemobile', img: 'closemobile', desktop: false, mobile: false, tablet: true, hidden: true}, @@ -862,6 +874,7 @@ function initNormalToolbar() { {type: 'button', id: 'insertobjectchart', img: 'insertobjectchart', hint: _UNO('.uno:InsertObjectChart', '', true), uno: 'InsertObjectChart'}, {type: 'drop', id: 'insertshapes', img: 'basicshapes_ellipse', hint: _('Insert shapes'), overlay: {onShow: insertShapes}, html: '<div id="insertshape-wrapper"><div id="insertshape-popup" class="insertshape-pop ui-widget ui-corner-all"><div class="insertshape-grid"></div></div></div>'}, + {type: 'button', id: 'insertshapesMobile', img: 'basicshapes_ellipse', desktop: false, mobile: true, tablet: true, hint: _('Insert shapes'), onClick: openInsertShapesDialog}, {type: 'button', id: 'link', img: 'link', hint: _UNO('.uno:HyperlinkDialog', '', true), disabled: true}, {type: 'button', id: 'insertsymbol', img: 'insertsymbol', hint: _UNO('.uno:InsertSymbol', '', true), uno: 'InsertSymbol'}, _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits