diff --git a/frontend-js/src/main/js/gui/ContextMenu.js b/frontend-js/src/main/js/gui/ContextMenu.js index ed0ce3c782b4ee12f04e7895d059d04e29fa6eb9..3850ff4af1f77e107e3083e967ca8ab38e2c87fa 100644 --- a/frontend-js/src/main/js/gui/ContextMenu.js +++ b/frontend-js/src/main/js/gui/ContextMenu.js @@ -29,7 +29,7 @@ ContextMenu.prototype.constructor = ContextMenu; ContextMenu.prototype.addOption = function(name, handler) { var self = this; if (name instanceof SubMenu) { - self.addSubMenu(name); + self.getElement().appendChild(name.getElement()); } else { var option = Functions.createElement({ type : "li", diff --git a/frontend-js/src/main/js/gui/MapContextMenu.js b/frontend-js/src/main/js/gui/MapContextMenu.js index 52207e7c18f929745c3cc0312257e55206fd3c0b..c43bd9621104f9c6d782458f5225d6920a8b1c21 100644 --- a/frontend-js/src/main/js/gui/MapContextMenu.js +++ b/frontend-js/src/main/js/gui/MapContextMenu.js @@ -3,8 +3,9 @@ /* exported logger */ var ContextMenu = require('./ContextMenu'); -var Functions = require('../Functions'); +var SubMenu = require('./SubMenu'); +var Functions = require('../Functions'); var logger = require('../logger'); function MapContextMenu(params) { @@ -17,6 +18,20 @@ function MapContextMenu(params) { MapContextMenu.prototype = Object.create(ContextMenu.prototype); MapContextMenu.prototype.constructor = MapContextMenu; +MapContextMenu.prototype.init = function() { + var li = Functions.createElement({ + type : "li" + }); + var submenu = new SubMenu({ + element : li, + name : "test", + customMap : self.getMap() + }); + submenu.addOption("Option A"); + submenu.addOption("Option B"); + self.addOption(submenu); +}; + MapContextMenu.prototype._createMapContextMenuGui = function() { var self = this; self.addOption("Add comment", function() { @@ -25,6 +40,7 @@ MapContextMenu.prototype._createMapContextMenuGui = function() { self.addOption("Select mode", function() { return self.getMap().turnOnOffDrawing(); }); + }; module.exports = MapContextMenu; diff --git a/frontend-js/src/main/js/gui/SubMenu.js b/frontend-js/src/main/js/gui/SubMenu.js index bd79c5232a53758009cecb1bd13047b21f32d6d6..dc943a491a253fe65e3c8b952c508f05a76eaf24 100644 --- a/frontend-js/src/main/js/gui/SubMenu.js +++ b/frontend-js/src/main/js/gui/SubMenu.js @@ -43,7 +43,7 @@ SubMenu.prototype._createGui = function(params) { SubMenu.prototype.addOption = function(name, handler) { var self = this; if (name instanceof SubMenu) { - self.addSubMenu(name); + self.getElement().appendChild(name.getElement()); } else { var option = Functions.createElement({ type : "li",