/*
This file is part of CPEE.
CPEE is free software: you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation,
either version 3 of the License, or (at your option) any later version.
CPEE is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with
CPEE (file COPYING in the main directory). If not, see
.
*/
function CustomMenu(e) {
var target = $(e.target);
var x = e.pageX;
var y = e.pageY;
var remove = function(event) {};
this.remove = remove;
e.stopPropagation();
this.contextmenu = function(items) {
remove = function(event) {
if (!event) {
$('.contextmenu:first').remove();
$('body', document).unbind('mousedown',remove);
return;
}
if($(event.target).parent('tr.contextmenuitem') && (event.button == 0)) { $(event.target).click(); }
$('.contextmenu:first').remove();
$('body', document).unbind('mousedown',remove);
}
$('body', document).bind('mousedown',remove);
if($('div.contextmenu').length > 0) remove();
var div = $('
');
for(head in items) {
div.children(':first').append('
' + head + '
');
for(item in items[head]) {
var icon = null;
if(items[head][item].menu_icon) {
icon = $X('');
icon.children('g').append(items[head][item].menu_icon.clone().children());
icon = icon.serializeXML();
}
if(items[head][item].text_icon) {
icon = items[head][item].text_icon;
}
var row = $('