Commit c31ff231 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

open molart is first on the context menu list

parent e9637324
......@@ -69,14 +69,24 @@ ContextMenu.prototype.destroy = function () {
/**
*
* @param {string|SubMenu} name
* @param {function} [handler]
* @param {function| number} [handler]
* @param {boolean} [disabled]
* @param {number} [position]
*/
ContextMenu.prototype.addOption = function (name, handler, disabled) {
ContextMenu.prototype.addOption = function (name, handler, disabled, position) {
if (!disabled) disabled = false;
var self = this;
var self = this, child;
if (name instanceof SubMenu) {
self.getElement().appendChild(name.getElement());
if (handler !== undefined && handler !== null) {
child = self.getElement().childNodes[handler];
if (child !== null && child !== undefined) {
self.getElement().insertBefore(name.getElement(), child);
} else {
self.getElement().appendChild(name.getElement());
}
} else {
self.getElement().appendChild(name.getElement());
}
} else {
var option = Functions.createElement({
type: "li"
......@@ -92,7 +102,16 @@ ContextMenu.prototype.addOption = function (name, handler, disabled) {
}
$(link).data("handler", handler);
option.appendChild(link);
self.getElement().appendChild(option);
if (Functions.isInt(position)) {
child = self.getElement().childNodes[position];
if (child !== null && child !== undefined) {
self.getElement().insertBefore(option, child);
} else {
self.getElement().appendChild(option);
}
} else {
self.getElement().appendChild(option);
}
}
};
......
......@@ -86,7 +86,7 @@ MolArt.prototype.activateInContextMenu = function (uniprotIds, alias) {
self._activate(uniprotId);
}, false);
});
menu.addOption(submenu);
menu.addOption(submenu, 0);
};
......@@ -97,7 +97,7 @@ MolArt.prototype.deactivateInContextMenu = function () {
var menu = this._customMap.getContextMenu();
removeFromContextMenu(menu);
menu.addOption("Open MolArt (no UniProt ID available)", function () {
}, true);
}, true, 0);
};
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment