cockpit/themes/control/theme.js in cpee-2.1.23 vs cockpit/themes/control/theme.js in cpee-2.1.24

- old
+ new

@@ -6,10 +6,11 @@ this.elements = {}; this.events = {}; this.compact = false; this.striped = true; this.endpoints = {}; + this.presstimer; //{{{ transform the details data to description parts based on rng this.source = function(base,opts) { if (base[0].namespaceURI == "http://relaxng.org/ns/structure/1.0") { $('#relaxngworker').empty(); @@ -135,100 +136,111 @@ } ); } } //}}} - // Events - this.events.mousedown = function(svgid, e, child, sibling) { // {{{ - if(e.button == 0) { // left-click - } else if(e.button == 1) { // middle-click - } else if(e.button == 2) { // right-click - if (save['state'] != "ready" && save['state'] != "stopped") { return false; } + function contextMenuHandling(svgid,e,child,sibling) { //{{{ + if (save['state'] != "ready" && save['state'] != "stopped") { return false; } - var xml_node = self.adaptor.description.get_node_by_svg_id(svgid); - var group = null; - var menu = {}; + var xml_node = self.adaptor.description.get_node_by_svg_id(svgid); + var group = null; + var menu = {}; - if (child) { - group = self.elements[xml_node.get(0).tagName].permissible_children(xml_node,'into'); + if (child) { + group = self.elements[xml_node.get(0).tagName].permissible_children(xml_node,'into'); + if(group.length > 0) { + menu['Insert into'] = group; + copyOrMove(menu['Insert into'],group,xml_node,self.adaptor.description.insert_first_into); + } + if (self.elements[xml_node.get(0).tagName].permissible_children_expert) { + group = self.elements[xml_node.get(0).tagName].permissible_children_expert(xml_node,'into'); if(group.length > 0) { - menu['Insert into'] = group; - copyOrMove(menu['Insert into'],group,xml_node,self.adaptor.description.insert_first_into); + menu['Insert into (Experts Only!)'] = group; + copyOrMove(menu['Insert into (Experts Only!)'],group,xml_node,self.adaptor.description.insert_first_into); } - if (self.elements[xml_node.get(0).tagName].permissible_children_expert) { - group = self.elements[xml_node.get(0).tagName].permissible_children_expert(xml_node,'into'); - if(group.length > 0) { - menu['Insert into (Experts Only!)'] = group; - copyOrMove(menu['Insert into (Experts Only!)'],group,xml_node,self.adaptor.description.insert_first_into); - } - } } - if (sibling) { - group = self.elements[xml_node.parent().get(0).tagName].permissible_children(xml_node,'after'); + } + if (sibling) { + group = self.elements[xml_node.parent().get(0).tagName].permissible_children(xml_node,'after'); + if(group.length > 0) { + menu['Insert after'] = group; + copyOrMove(menu['Insert after'],group,xml_node,self.adaptor.description.insert_after); + } + if (self.elements[xml_node.parent().get(0).tagName].permissible_children_expert) { + group = self.elements[xml_node.parent().get(0).tagName].permissible_children_expert(xml_node,'after'); if(group.length > 0) { - menu['Insert after'] = group; - copyOrMove(menu['Insert after'],group,xml_node,self.adaptor.description.insert_after); + menu['Insert after (Experts Only!)'] = group; + copyOrMove(menu['Insert after (Experts Only!)'],group,xml_node,self.adaptor.description.insert_after); } - if (self.elements[xml_node.parent().get(0).tagName].permissible_children_expert) { - group = self.elements[xml_node.parent().get(0).tagName].permissible_children_expert(xml_node,'after'); - if(group.length > 0) { - menu['Insert after (Experts Only!)'] = group; - copyOrMove(menu['Insert after (Experts Only!)'],group,xml_node,self.adaptor.description.insert_after); - } - } } + } - if(xml_node.get(0).tagName != 'description' && !self.elements[xml_node.get(0).tagName].neverdelete) { - var icon = self.elements[xml_node.get(0).tagName].illustrator.svg.clone(); - icon.children('.rfill').addClass('menu'); - menu['Delete'] = [{ - 'label': 'Remove Element', - 'function_call': function(selector,target,selected){ self.adaptor.description.remove(selector,target); self.adaptor.illustrator.get_label_by_svg_id(selected).addClass('selected'); }, - 'menu_icon': icon, - 'type': undefined, - 'params': [null, xml_node, self.selected()] - }]; - } - if($('> code', xml_node).length > 0 && xml_node.get(0).tagName == 'call') { - var icon = self.elements.callmanipulate.illustrator.svg.clone(); - icon.children('.rfill:last').addClass('menu'); - menu['Delete'].push({ - 'label': 'Remove Scripts', - 'function_call': self.adaptor.description.remove, - 'menu_icon': icon, - 'type': undefined, - 'params': ['> code', xml_node] - }); - } - if (xml_node.get(0).tagName == "call" || xml_node.get(0).tagName == "manipulate" || xml_node.get(0).tagName == "stop") { - var icon = self.elements.call.illustrator.svg.clone(); - icon.children('g.replace').addClass('active'); - var vtarget = self.adaptor.illustrator.get_node_by_svg_id(svgid); - if (vtarget.length > 0) { - if (vtarget.parents('g.activities.passive, g.activities.active').length > 0) { - menu['Position'] = [{ - 'label': 'No Execution from here', - 'function_call': del_ui_pos, - 'menu_icon': icon, - 'type': undefined, - 'params': xml_node - }]; - } else { - menu['Position'] = [{ - 'label': 'Execute from here', - 'function_call': add_ui_pos, - 'menu_icon': icon, - 'type': undefined, - 'params': xml_node - }]; - } + if(xml_node.get(0).tagName != 'description' && !self.elements[xml_node.get(0).tagName].neverdelete) { + var icon = self.elements[xml_node.get(0).tagName].illustrator.svg.clone(); + icon.children('.rfill').addClass('menu'); + menu['Delete'] = [{ + 'label': 'Remove Element', + 'function_call': function(selector,target,selected){ self.adaptor.description.remove(selector,target); self.adaptor.illustrator.get_label_by_svg_id(selected).addClass('selected'); }, + 'menu_icon': icon, + 'type': undefined, + 'params': [null, xml_node, self.selected()] + }]; + } + if($('> code', xml_node).length > 0 && xml_node.get(0).tagName == 'call') { + var icon = self.elements.callmanipulate.illustrator.svg.clone(); + icon.children('.rfill:last').addClass('menu'); + menu['Delete'].push({ + 'label': 'Remove Scripts', + 'function_call': self.adaptor.description.remove, + 'menu_icon': icon, + 'type': undefined, + 'params': ['> code', xml_node] + }); + } + if (xml_node.get(0).tagName == "call" || xml_node.get(0).tagName == "manipulate" || xml_node.get(0).tagName == "stop") { + var icon = self.elements.call.illustrator.svg.clone(); + icon.children('g.replace').addClass('active'); + var vtarget = self.adaptor.illustrator.get_node_by_svg_id(svgid); + if (vtarget.length > 0) { + if (vtarget.parents('g.activities.passive, g.activities.active').length > 0) { + menu['Position'] = [{ + 'label': 'No Execution from here', + 'function_call': del_ui_pos, + 'menu_icon': icon, + 'type': undefined, + 'params': xml_node + }]; + } else { + menu['Position'] = [{ + 'label': 'Execute from here', + 'function_call': add_ui_pos, + 'menu_icon': icon, + 'type': undefined, + 'params': xml_node + }]; } } - new CustomMenu(e).contextmenu(menu); } + new CustomMenu(e).contextmenu(menu); + } //}}} + + // Events + this.events.touchend = function(svgid, e) { // {{{ + clearTimeout(self.presstimer); + } // }}} + this.events.touchstart = function(svgid, e, child, sibling) { // {{{ + self.presstimer = window.setTimeout(function() { contextMenuHandling(svgid,e,child,sibling); },1000); return false; } // }}} + this.events.mousedown = function(svgid, e, child, sibling) { // {{{ + if(e.button == 0) { // left-click + } else if(e.button == 1) { // middle-click + } else if(e.button == 2) { // right-click + contextMenuHandling(svgid,e,child,sibling); + } + return false; + } // }}} this.events.suppress = function(svgid, e, child, sibling) { // {{{ return false; } // }}} this.events.click = function(svgid, e) { // {{{ if (self.adaptor.description.get_node_by_svg_id(svgid).length == 0) { @@ -337,10 +349,12 @@ ]; return []; }, //}}} 'adaptor': {//{{{ 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,true,true); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'dragstart': self.events.dragstart, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout }//}}} @@ -363,10 +377,12 @@ 'permissible_children': function(node,mode) { //{{{ return []; }, //}}} 'adaptor': {//{{{ 'mousedown': function (node,e) { self.events.mousedown(node,e,false,true); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,false,true); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout }//}}} }; /*}}}*/ @@ -380,10 +396,12 @@ 'permissible_children': function(node,mode) { //{{{ return []; }, //}}} 'adaptor': {//{{{ 'mousedown': function (node,e) { self.events.mousedown(node,e,false,true); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,false,true); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout }//}}} }; /*}}}*/ @@ -400,10 +418,12 @@ 'permissible_children': function(node,mode) { //{{{ return []; }, //}}} 'adaptor': {//{{{ 'mousedown': function (node,e) { self.events.mousedown(node,e,false,true); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,false,true); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout }//}}} }; /*}}}*/ @@ -418,10 +438,12 @@ 'permissible_children': function(node,mode) { //{{{ return []; }, //}}} 'adaptor': {//{{{ 'mousedown': function (node,e) { self.events.mousedown(node,e,false,false); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,false,false); }, + 'touchend': self.events.touchend, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout }//}}} }; /*}}}*/ this.elements.end = { /*{{{*/ @@ -429,25 +451,21 @@ 'illustrator': {//{{{ 'endnodes': 'this', 'svg': self.adaptor.theme_dir + 'symbols/end.svg' }, //}}} 'adaptor': {//{{{ - 'mousedown': function (node,e) { - self.events.suppress(); - } + 'mousedown': function (node,e) { self.events.suppress(); } }//}}} }; /*}}}*/ this.elements.event_end = { /*{{{*/ 'type': 'primitive', 'illustrator': {//{{{ 'endnodes': 'this', 'svg': self.adaptor.theme_dir + 'symbols/event_end.svg' }, //}}} 'adaptor': {//{{{ - 'mousedown': function (node,e) { - self.events.suppress(); - }, + 'mousedown': function (node,e) { self.events.suppress(); }, 'click': self.events.click, 'dblclick': self.events.dblclick, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout }//}}} @@ -464,13 +482,13 @@ return 'choose_inclusive_finish'; } }, }, //}}} 'adaptor': {//{{{ - 'mousedown': function (node,e) { - self.events.mousedown(node,e,true,true); - }, + 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,true,true); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'dblclick': self.events.dblclick, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout }//}}} @@ -489,13 +507,13 @@ return ret; }, 'svg': self.adaptor.theme_dir + 'symbols/choose_exclusive.svg', }, //}}} 'adaptor': {//{{{ - 'mousedown': function (node,e) { - self.events.mousedown(node,e,true,true); - }, + 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,true,true); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'dblclick': self.events.dblclick, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout }//}}} @@ -516,13 +534,13 @@ return 'parallel_complex'; } }, }, //}}} 'adaptor': {//{{{ - 'mousedown': function (node,e) { - self.events.mousedown(node,e,true,true); - }, + 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,true,true); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'dblclick': self.events.dblclick, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout }//}}} @@ -581,13 +599,13 @@ 'type': 'parallel_branch', 'params': [self.adaptor.description.elements.parallel_branch, node]}); return childs; }, //}}} 'adaptor': {//{{{ - 'mousedown': function (node,e) { - self.events.mousedown(node,e,true,true); - }, + 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,true,true); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'dblclick': self.events.dblclick, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout }//}}} @@ -674,13 +692,13 @@ }); } return childs; }, //}}} 'adaptor': {//{{{ - 'mousedown': function (node,e) { - self.events.mousedown(node,e,true,false); - }, + 'mousedown': function (node,e) { self.events.mousedown(node,e,true,false); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,true,false); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'dblclick': self.events.dblclick, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout, }//}}} @@ -775,13 +793,13 @@ }); } return childs; }, //}}} 'adaptor': {//{{{ - 'mousedown': function (node,e) { - self.events.mousedown(node,e,true,true); - }, + 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,true,true); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'dblclick': self.events.dblclick, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout, }//}}} @@ -876,13 +894,13 @@ ); } return childs; }, //}}} 'adaptor': {//{{{ - 'mousedown': function (node,e) { - self.events.mousedown(node,e,true,true); - }, + 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,true,true); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'dblclick': self.events.dblclick, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout, }//}}} @@ -932,13 +950,13 @@ 'params': [self.adaptor.description.elements.closed_loop_cancel, node]} ]; return childs; }, //}}} 'adaptor': {//{{{ - 'mousedown': function (node,e) { - self.events.mousedown(node,e,true,true); - }, + 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,true,true); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'dblclick': self.events.dblclick, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout, }//}}} @@ -1014,13 +1032,13 @@ 'params': [self.adaptor.description.elements.stop, node]} ]; return childs; }, //}}} 'adaptor': {//{{{ - 'mousedown': function (node,e) { - self.events.mousedown(node,e,true,true); - }, + 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,true,true); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'dblclick': self.events.dblclick, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout, }//}}} @@ -1101,13 +1119,13 @@ 'params': [self.adaptor.description.elements.stop, node]} ]; return childs; }, //}}} 'adaptor': {//{{{ - 'mousedown': function (node,e) { - self.events.mousedown(node,e,true,true); - }, + 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,true,true); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'dblclick': self.events.dblclick, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout, }//}}} @@ -1173,13 +1191,13 @@ 'params': [self.adaptor.description.elements.stop, node]} ]; return childs; }, //}}} 'adaptor': {//{{{ - 'mousedown': function (node,e) { - self.events.mousedown(node,e,true,true); - }, + 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,true,true); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'dblclick': self.events.dblclick, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout, }//}}} @@ -1271,13 +1289,13 @@ 'type': 'parallel', 'params': [self.adaptor.description.elements.parallel, node]}); return childs; }, //}}} 'adaptor': {//{{{ - 'mousedown': function (node,e) { - self.events.mousedown(node,e,true,true); - }, + 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,true,true); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'dblclick': self.events.dblclick, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout, }//}}} @@ -1370,13 +1388,13 @@ 'params': [self.adaptor.description.elements.alternative, node]}]; } return childs; }, //}}} 'adaptor': {//{{{ - 'mousedown': function (node,e) { - self.events.mousedown(node,e,true,true); - }, + 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,true,true); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'dblclick': self.events.dblclick, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout, }//}}} @@ -1457,13 +1475,13 @@ }); } return childs; }, //}}} 'adaptor': {//{{{ - 'mousedown': function (node,e) { - self.events.mousedown(node,e,true,true); - }, + 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,true,true); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'dblclick': self.events.dblclick, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout, }//}}} @@ -1489,13 +1507,13 @@ else { func = self.adaptor.description.insert_after } return [ ]; }, //}}} 'adaptor': {//{{{ - 'mousedown': function (node,e) { - self.events.mousedown(node,e,true,true); - }, + 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,true,true); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'dblclick': self.events.dblclick, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout, }//}}} @@ -1573,12 +1591,12 @@ }); } return childs; }, //}}} 'adaptor': {//{{{ - 'mousedown': function (node,e) { - self.events.mousedown(node,e,true,false); - }, + 'mousedown': function (node,e) { self.events.mousedown(node,e,true,false); }, + 'touchstart': function (node,e) { self.events.touchstart(node,e,true,false); }, + 'touchend': self.events.touchend, 'click': self.events.click, 'dblclick': self.events.dblclick, 'mouseover': self.events.mouseover, 'mouseout': self.events.mouseout, }//}}}