cockpit/themes/model/theme.js in cpee-2.0.24 vs cockpit/themes/model/theme.js in cpee-2.0.25
- old
+ new
@@ -47,10 +47,20 @@
svgid.push($(value).attr('element-id'));
}
});
return svgid;
}; //}}}
+ //{{{ Return the json for all marked tasks
+ this.marked_text = function(){
+ var nodes = [];
+ var markymark = _.uniq(self.marked());
+ $(markymark).each(function(key,svgid){
+ var node = self.adaptor.description.get_node_by_svg_id(svgid);
+ nodes.push($(node).serializePrettyXML());
+ });
+ return JSON.stringify(nodes);
+ }; //}}}
//{{{ Render the details from rng (right hand side of graph tab)
this.update_details = function(svgid){
var tab = $('#dat_details');
var node = self.adaptor.description.get_node_by_svg_id(svgid).get(0);
tab.empty();
@@ -74,40 +84,51 @@
format_visual_forms();
}
}; //}}}
function copyOrMove(menu,group,xml_node,mode) { //{{{
- var markymark = _.uniq(self.marked());
+ var nodes = localStorage.getItem('marked');
+
+ if (typeof(nodes) != "string") { return; }
+
+ nodes = JSON.parse(nodes);
+ $(nodes).each(function(key,str) {
+ nodes[key] = $X(str);;
+ });
+
var check1 = [];
var check2 = [];
- $(markymark).each(function(key,svgid){
- var node = self.adaptor.description.get_node_by_svg_id(svgid);
+ $(nodes).each(function(key,node){
check1.push($(node).attr('svg-type'));
});
$(group).each(function(key,value){
check2.push(value.type);
});
- if (markymark.length > 0 && _.uniq(check1).length == _.intersection(check1,check2).length) {
- var nodes = [];
- $(markymark).each(function(key,svgid){
- var node = self.adaptor.description.get_node_by_svg_id(svgid);
- nodes.unshift(node);
- });
-
+ if (nodes.length > 0 && _.uniq(check1).length == _.intersection(check1,check2).length) {
+ if (myid == localStorage.getItem('marked_from')) {
+ $(nodes).each(function(key,node){
+ nodes[key] = self.adaptor.description.get_node_by_svg_id($(node).attr('svg-id'));
+ });
+ }
+ nodes.reverse();
var iconm = self.resources['arrow'].clone();
var iconc = self.resources['arrow'].clone();
iconm.children('.rfill').addClass('menu');
+ if (myid == localStorage.getItem('marked_from')) {
+ menu.push(
+ {
+ 'label': '<em>Move Marked Elements</em>',
+ 'function_call': mode,
+ 'menu_icon': iconm,
+ 'type': undefined,
+ 'params': [nodes, xml_node]
+ }
+ );
+ }
menu.push(
{
- 'label': '<em>Move Marked Elements</em>',
- 'function_call': mode,
- 'menu_icon': iconm,
- 'type': undefined,
- 'params': [nodes, xml_node]
- },
- {
'label': '<em>Copy Marked Elements</em>',
'function_call': mode,
'menu_icon': iconc,
'type': undefined,
'params': [nodes, xml_node, 'clone']
@@ -191,20 +212,30 @@
}
self.adaptor.illustrator.get_elements().removeClass('selected');
self.adaptor.illustrator.get_labels().removeClass('selected');
- if (e && e.ctrlKey) {
+ if (e && (e.ctrlKey || e.metaKey)) {
if (save['state'] != "ready" && save['state'] != "stopped") { return false; }
var tab = $('#dat_details');
tab.empty();
var vtarget = self.adaptor.illustrator.get_node_by_svg_id(svgid);
if (vtarget.length > 0) {
- vtarget.parents('g.element[element-id]').toggleClass('marked');
+ var vt = vtarget.parents('g.element[element-id]');
+ vt.toggleClass('marked');
+ if (vt.hasClass('marked')) {
+ localStorage.setItem('marked',self.marked_text());
+ localStorage.setItem('marked_from',myid);
+ } else {
+ localStorage.removeItem('marked');
+ localStorage.removeItem('marked_from');
+ }
}
} else {
self.adaptor.illustrator.get_elements().removeClass('marked');
+ localStorage.removeItem('marked');
+ localStorage.removeItem('marked_from');
var vtarget = self.adaptor.illustrator.get_node_by_svg_id(svgid);
if (vtarget.length > 0) {
vtarget.parents('g.element[element-id]').addClass('selected');
}
@@ -239,10 +270,10 @@
'illustrator': {//{{{
'endnodes': 'this',
'label': function(node){
var ret;
if ($('> url',$(node).children('parameters').children('arguments')).length > 0) {
- ret = [ { column: 'Label', value: $('> label',$(node).children('parameters')).text().replace(/^['"]/,'').replace(/['"]$/,'') + ' <a target="_blank" href="' + $('> url',$(node).children('parameters').children('arguments')).text() + '"></a>' } ];
+ ret = [ { column: 'Label', value: $('> label',$(node).children('parameters')).text().replace(/^['"]/,'').replace(/['"]$/,'') + ' <a target="_blank" href="' + $('> url',$(node).children('parameters').children('arguments')).text() + '/open"></a>' } ];
} else {
ret = [ { column: 'Label', value: $('> label',$(node).children('parameters')).text().replace(/^['"]/,'').replace(/['"]$/,'') } ];
}
return ret;
},