Moved: getMenuStructureForMobileWizard

moved the getMenuStructureForMobileWizard from map
to more appropriate place in JSDialogBuilder.js

Change-Id: I366b8317c6469652ee9469746ae7b78c2c3a1f7f
Reviewed-on: https://gerrit.libreoffice.org/c/online/+/87169
Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoffice@gmail.com>
Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
This commit is contained in:
Pranam Lashkari 2020-01-22 04:29:52 +05:30 committed by Michael Meeks
parent 9a92cd2415
commit 8add3d1274
4 changed files with 54 additions and 56 deletions

View file

@ -114,7 +114,7 @@ L.Control.ContextMenu = L.Control.extend({
}
if (window.mode.isMobile()) {
window.contextMenuWizard = true;
var menuData = this._map.getMenuStructureForMobileWizard(contextMenu, true, '');
var menuData = L.Control.JSDialogBuilder.getMenuStructureForMobileWizard(contextMenu, true, '');
if (spellingContextMenu === true) {
vex.timer = setInterval(function() {
map.fire('mobilewizard', menuData);

View file

@ -1549,6 +1549,58 @@ L.Control.JSDialogBuilder = L.Control.extend({
}
});
L.Control.JSDialogBuilder.getMenuStructureForMobileWizard = function(menu, mainMenu, itemCommand) {
if (itemCommand.includes('sep'))
return null;
var itemText = '';
if (menu.name)
itemText = menu.name;
var itemType = 'submenu';
var executionType = 'menu';
if (mainMenu) {
itemType = 'mainmenu';
executionType = 'menu';
} else if (menu.callback) {
itemType = 'menuitem';
executionType = 'callback';
} else if (!menu.items) {
itemType = 'menuitem';
executionType = 'command';
}
var menuStructure = {
type : itemType,
enabled : true,
text : itemText,
executionType : executionType,
children : []
};
if (itemCommand)
menuStructure['command'] = itemCommand;
if (menu.icon)
menuStructure['checked'] = true;
if (menu.callback)
menuStructure['callback'] = menu.callback;
if (mainMenu) {
for (var menuItem in menu) {
var element = this.getMenuStructureForMobileWizard(menu[menuItem], false, menuItem);
if (element)
menuStructure['children'].push(element);
}
} else if (itemType == 'submenu') {
for (menuItem in menu.items) {
element = this.getMenuStructureForMobileWizard(menu.items[menuItem], false, menuItem);
if (element)
menuStructure['children'].push(element);
}
}
return menuStructure;
};
L.control.jsDialogBuilder = function (options) {
var builder = new L.Control.JSDialogBuilder(options);
builder._setup(options);

View file

@ -82,7 +82,6 @@ L.Control.Tabs = L.Control.extend({
var parts = e.parts;
var selectedPart = e.selectedPart;
var docType = e.docType;
var map = this._map;
if (docType === 'text') {
return;
@ -107,7 +106,7 @@ L.Control.Tabs = L.Control.extend({
ssTabScroll.id = 'spreadsheet-tab-scroll';
if (window.mode.isMobile()) {
var menuData = map.getMenuStructureForMobileWizard(this._menuItem, true, '');
var menuData = L.Control.JSDialogBuilder.getMenuStructureForMobileWizard(this._menuItem, true, '');
}
for (var i = 0; i < parts; i++) {
@ -198,7 +197,6 @@ L.Control.Tabs = L.Control.extend({
_hideSheet: function() {
this._map.hidePage();
}
});
L.control.tabs = function (options) {

View file

@ -1755,58 +1755,6 @@ L.Map = L.Evented.extend({
this.removeLayer(this.focusLayer);
this.focusLayer = null;
}
},
getMenuStructureForMobileWizard: function(menu, mainMenu, itemCommand) {
if (itemCommand.includes('sep'))
return null;
var itemText = '';
if (menu.name)
itemText = menu.name;
var itemType = 'submenu';
var executionType = 'menu';
if (mainMenu) {
itemType = 'mainmenu';
executionType = 'menu';
} else if (menu.callback) {
itemType = 'menuitem';
executionType = 'callback';
} else if (!menu.items) {
itemType = 'menuitem';
executionType = 'command';
}
var menuStructure = {
type : itemType,
enabled : true,
text : itemText,
executionType : executionType,
children : []
};
if (itemCommand)
menuStructure['command'] = itemCommand;
if (menu.icon)
menuStructure['checked'] = true;
if (menu.callback)
menuStructure['callback'] = menu.callback;
if (mainMenu) {
for (var menuItem in menu) {
var element = this.getMenuStructureForMobileWizard(menu[menuItem], false, menuItem);
if (element)
menuStructure['children'].push(element);
}
} else if (itemType == 'submenu') {
for (menuItem in menu.items) {
element = this.getMenuStructureForMobileWizard(menu.items[menuItem], false, menuItem);
if (element)
menuStructure['children'].push(element);
}
}
return menuStructure;
}
});