cockpit/themes/labels/theme.js in cpee-1.3.214 vs cockpit/themes/labels/theme.js in cpee-1.3.215

- old
+ new

@@ -15,10 +15,19 @@ var ntxt = nnew.serializeXML(); ntxt = ntxt.replace(/trans-xmlns/,'xmlns'); return($X(ntxt)); }; + this.clicked = function(){ + var svgid = 'unknown'; + _.each(self.adaptor.illustrator.get_elements(),function(value,key) { + if ($(value).hasClass('clicked')) { + svgid = $(value).attr('element-id'); + } + }); + return svgid; + }; // Events this.events.mousedown = function(svgid, e, child, sibling) { // {{{ if(e.button == 0) { // left-click } else if(e.button == 1) { // middle-click @@ -66,15 +75,15 @@ tab.empty(); if (self.adaptor.description.get_node_by_svg_id(svgid).length == 0) { return; } - self.adaptor.illustrator.get_nodes().removeClass('clicked'); + self.adaptor.illustrator.get_elements().removeClass('clicked'); var vtarget = self.adaptor.illustrator.get_node_by_svg_id(svgid); if (vtarget.length > 0) { - vtarget.addClass('clicked'); + vtarget.parents('g.element[element-id]').addClass('clicked'); } if ($('#state').text() != 'finished') $('#main ui-behind button').show(); if ($('#main ui-behind button').hasClass('highlight')) { @@ -108,12 +117,13 @@ // Primitive Elements this.elements.call = { /*{{{*/ 'type': 'primitive', 'illustrator': {//{{{ - 'endnodes' : 'this', - 'resolve_symbol' : function(node) { + 'endnodes': 'this', + 'label': function(node){return $('label',$(node).children('parameters')).text().replace(/^['"]/,'').replace(/['"]$/,'')}, + 'resolve_symbol': function(node) { if($(node).attr('endpoint').match(/^instantiation/)) { return 'callinstantiation'; } else if($(node).attr('endpoint').match(/^correlation_send/)) { return 'callcorrelationsend'; } else if($(node).attr('endpoint').match(/^correlation_receive/)) { @@ -141,64 +151,65 @@ 'menu_icon': self.elements.callmanipulate.illustrator.svg.clone(), 'params': [self.adaptor.description.elements.scripts, node]} ]; return []; }, //}}} - 'adaptor' : {//{{{ + 'adaptor': {//{{{ 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, 'click': self.events.click, 'dragstart': self.events.dragstart, }//}}} }; /*}}}*/ this.elements.manipulate = { /*{{{*/ 'type': 'primitive', 'illustrator': {//{{{ - 'endnodes' : 'this', + 'endnodes': 'this', 'svg': self.adaptor.theme_dir + 'symbols/manipulate.svg' },//}}} 'description': self.adaptor.theme_dir + 'rngs/manipulate.rng', 'permissible_children': function(node) { //{{{ return []; }, //}}} - 'adaptor' : {//{{{ + 'adaptor': {//{{{ 'mousedown': function (node,e) { self.events.mousedown(node,e,false,true); }, 'click': self.events.click, }//}}} }; /*}}}*/ this.elements.escape = { /*{{{*/ 'type': 'primitive', 'illustrator': {//{{{ - 'endnodes' : 'this', + 'endnodes': 'this', 'svg': self.adaptor.theme_dir + 'symbols/escape.svg' },//}}} 'description': self.adaptor.theme_dir + 'rngs/escape.rng', 'permissible_children': function(node) { //{{{ return []; }, //}}} - 'adaptor' : {//{{{ + 'adaptor': {//{{{ 'mousedown': function (node,e) { self.events.mousedown(node,e,false,true); }, 'click': self.events.click, }//}}} }; /*}}}*/ // Complex Elements this.elements.choose = { /*{{{*/ 'type': 'complex', 'illustrator': {//{{{ - 'endnodes' : 'aggregate', + 'label': function(node){return $(node).attr('mode') == 'exclusive' ? 'exclusive' : 'inclusive' }, + 'endnodes': 'aggregate', 'closeblock': false, - 'expansion' : function(node) { + 'expansion': function(node) { return 'horizontal'; }, - 'resolve_symbol' : function(node) { + 'resolve_symbol': function(node) { if($(node).attr('mode') == 'exclusive') { return 'choose_exclusive'; } else { return 'choose_inclusive'; } }, - 'col_shift' : function(node) { + 'col_shift': function(node) { return false; }, 'svg': self.adaptor.theme_dir + 'symbols/choose.svg' },//}}} 'description': self.adaptor.theme_dir + 'rngs/choose.rng', @@ -226,11 +237,11 @@ 'function_call': func, 'menu_icon': self.elements.parallel_branch.illustrator.svg.clone(), 'params': [self.adaptor.description.elements.parallel_branch, node]}); return childs; }, //}}} - 'adaptor' : {//{{{ + 'adaptor': {//{{{ 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, 'click': self.events.click, 'dblclick': self.events.dblclick, @@ -239,16 +250,16 @@ }//}}} }; /*}}}*/ this.elements.otherwise = { /*{{{*/ 'type': 'complex', 'illustrator': {//{{{ - 'endnodes' : 'passthrough', + 'endnodes': 'passthrough', 'closeblock': false, - 'expansion' : function(node) { + 'expansion': function(node) { return 'vertical'; }, - 'col_shift' : function(node) { + 'col_shift': function(node) { return false; }, 'svg': self.adaptor.theme_dir + 'symbols/otherwise.svg' },//}}} 'description': self.adaptor.theme_dir + 'rngs/otherwise.rng', @@ -287,11 +298,11 @@ 'function_call': func, 'menu_icon': self.elements.critical.illustrator.svg.clone(), 'params': [self.adaptor.description.elements.critical, node]} ]; }, //}}} - 'adaptor' : {//{{{ + 'adaptor': {//{{{ 'mousedown': function (node,e) { self.events.mousedown(node,e,true,false); }, 'click': self.events.click, 'dblclick': self.events.dblclick, @@ -300,16 +311,17 @@ }//}}} }; /*}}}*/ this.elements.alternative = { /*{{{*/ 'type': 'complex', 'illustrator': {//{{{ - 'endnodes' : 'passthrough', + 'label': function(node){return $(node).attr('condition')}, + 'endnodes': 'passthrough', 'closeblock':false, - 'expansion' : function(node) { + 'expansion': function(node) { return 'vertical'; }, - 'col_shift' : function(node) { + 'col_shift': function(node) { return false; }, 'svg': self.adaptor.theme_dir + 'symbols/alternative.svg' },//}}} 'description': self.adaptor.theme_dir + 'rngs/alternative.rng', @@ -351,11 +363,11 @@ 'function_call': func, 'menu_icon': self.elements.critical.illustrator.svg.clone(), 'params': [self.adaptor.description.elements.critical, node]} ]; }, //}}} - 'adaptor' : {//{{{ + 'adaptor': {//{{{ 'mousedown': function (node,e) { self.events.mousedown(node,e,true,false); }, 'click': self.events.click, 'dblclick': self.events.dblclick, @@ -364,16 +376,17 @@ }//}}} }; /*}}}*/ this.elements.loop = { /*{{{*/ 'type': 'complex', 'illustrator': {//{{{ - 'endnodes' : 'this', - 'closeblock' : true, - 'expansion' : function(node) { + 'label': function(node){return $(node).attr('condition') + ($(node).attr('mode') == 'pre_test' ? ' (⭱)' : ' (⭳)') }, + 'endnodes': 'this', + 'closeblock': true, + 'expansion': function(node) { return 'vertical'; }, - 'col_shift' : function(node) { + 'col_shift': function(node) { return true; }, 'svg': self.adaptor.theme_dir + 'symbols/loop.svg' },// }}} 'description': self.adaptor.theme_dir + 'rngs/loop.rng', @@ -420,11 +433,11 @@ 'params': [self.adaptor.description.elements.parallel, node]} ); } return childs; }, //}}} - 'adaptor' : {//{{{ + 'adaptor': {//{{{ 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, 'click': self.events.click, 'dblclick': self.events.dblclick, @@ -433,19 +446,19 @@ }//}}} }; /*}}}*/ this.elements.parallel = { /*{{{*/ 'type': 'complex', 'illustrator': {//{{{ - 'endnodes' : 'this', - 'closeblock' : false, + 'endnodes': 'this', + 'closeblock': false, 'border': true, - 'expansion' : function(node) { + 'expansion': function(node) { // check if any sibling other than 'parallel_branch' is present if($(node).children(':not(parallel_branch)').length > 0) return 'vertical'; return 'horizontal'; }, - 'col_shift' : function(node) { + 'col_shift': function(node) { return true; }, 'svg': self.adaptor.theme_dir + 'symbols/parallel.svg' },//}}} 'description': self.adaptor.theme_dir + 'rngs/parallel.rng', @@ -485,11 +498,11 @@ 'function_call': self.adaptor.description.insert_last_into, 'menu_icon': self.elements.parallel.illustrator.svg.clone(), 'params': [self.adaptor.description.elements.parallel, node]}); return childs; }, //}}} - 'adaptor' : {//{{{ + 'adaptor': {//{{{ 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, 'click': self.events.click, 'dblclick': self.events.dblclick, @@ -498,16 +511,16 @@ }//}}} }; /*}}}*/ this.elements.parallel_branch = { /*{{{*/ 'type': 'complex', 'illustrator': {//{{{ - 'endnodes' : 'this', - 'closeblock' : false, - 'expansion' : function(node) { + 'endnodes': 'this', + 'closeblock': false, + 'expansion': function(node) { return 'vertical'; }, - 'col_shift' : function(node) { + 'col_shift': function(node) { if(node.parentNode.tagName == 'choose') return false; if($(node).parents('parallel').first().children(':not(parallel_branch)').length > 0) return true; return false; }, 'svg': self.adaptor.theme_dir + 'symbols/parallel_branch.svg' @@ -554,11 +567,11 @@ 'menu_icon': self.elements.alternative.illustrator.svg.clone(), 'params': [self.adaptor.description.elements.alternative, node]}]; } return childs; }, //}}} - 'adaptor' : {//{{{ + 'adaptor': {//{{{ 'mousedown': function (node,e) { self.events.mousedown(node,e,true,false); }, 'click': self.events.click, 'dblclick': self.events.dblclick, @@ -567,17 +580,17 @@ }//}}} }; /*}}}*/ this.elements.critical = { /*{{{*/ 'type': 'complex', 'illustrator': {//{{{ - 'endnodes' : 'aggregate', - 'closeblock' : false, + 'endnodes': 'aggregate', + 'closeblock': false, 'border': true, - 'expansion' : function(node) { + 'expansion': function(node) { return 'vertical'; }, - 'col_shift' : function(node) { + 'col_shift': function(node) { return true; }, 'svg': self.adaptor.theme_dir + 'symbols/critical.svg' },//}}} 'description': self.adaptor.theme_dir + 'rngs/critical.rng', @@ -614,11 +627,11 @@ 'function_call': func, 'menu_icon': self.elements.critical.illustrator.svg.clone(), 'params': [self.adaptor.description.elements.critical, node]}, ]; }, //}}} - 'adaptor' : {//{{{ + 'adaptor': {//{{{ 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, 'click': self.events.click, 'dblclick': self.events.dblclick, @@ -627,17 +640,17 @@ }//}}} }; /*}}}*/ this.elements.group = { /*{{{*/ 'type': 'complex', 'illustrator': {//{{{ - 'endnodes' : 'aggregate', - 'closeblock' : false, + 'endnodes': 'aggregate', + 'closeblock': false, 'border': 'injectiongroup', // other value than true,false inidcates the used class for the svg-object - 'expansion' : function(node) { + 'expansion': function(node) { return 'vertical'; }, - 'col_shift' : function(node) { + 'col_shift': function(node) { return true; }, 'svg': null },//}}} 'description': self.adaptor.theme_dir + 'rngs/group.rng', @@ -646,11 +659,11 @@ if(node.get(0).tagName == 'group') { func = self.adaptor.description.insert_first_into } else { func = self.adaptor.description.insert_after } return [ ]; }, //}}} - 'adaptor' : {//{{{ + 'adaptor': {//{{{ 'mousedown': function (node,e) { self.events.mousedown(node,e,true,true); }, 'click': self.events.click, 'dblclick': self.events.dblclick, @@ -659,16 +672,16 @@ }//}}} }; /*}}}*/ this.elements.start = this.elements.description = { /*{{{*/ 'type': 'description', 'illustrator': {//{{{ - 'endnodes' : 'passthrough', - 'closeblock' : false, - 'expansion' : function(node) { + 'endnodes': 'passthrough', + 'closeblock': false, + 'expansion': function(node) { return 'vertical'; }, - 'col_shift' : function(node) { + 'col_shift': function(node) { return true; }, 'svg': self.adaptor.theme_dir + 'symbols/start.svg' },//}}} 'description': null, @@ -705,11 +718,11 @@ 'function_call': func, 'menu_icon': self.elements.critical.illustrator.svg.clone(), 'params': [self.adaptor.description.elements.critical, node]} ]; }, //}}} - 'adaptor' : {//{{{ + 'adaptor': {//{{{ 'mousedown': function (node,e) { self.events.mousedown(node,e,true,false); }, 'click': self.events.click, 'dblclick': self.events.dblclick, @@ -724,9 +737,10 @@ this.elements.callmanipulate = { /*{{{*/ 'type': 'abstract', 'parent': 'call', 'description': self.adaptor.theme_dir + 'rngs/callmanipulate.rng', 'illustrator': {//{{{ + 'label': function(node){return $('label',$(node).children('parameters')).text().replace(/^['"]/,'').replace(/['"]$/,'')}, 'svg': self.adaptor.theme_dir + 'symbols/callmanipulate.svg' },//}}} }; /*}}}*/ this.elements.choose_inclusive = { /*{{{*/ 'type': 'abstract',