Deploy menu style

This commit is contained in:
Nick O'Leary
2015-01-14 22:40:45 +00:00
parent a5afc258b1
commit 687a66344e
10 changed files with 192 additions and 51 deletions

View File

@@ -16,9 +16,9 @@
var RED = (function() {
var deploymentTypes = {
"full":"Deploy",
"nodes":"Deploy changed nodes",
"flows":"Deploy changed flows"
"full":{label:"Deploy",img:"images/deploy-full-o.png"},
"nodes":{label:"Deploy modified nodes",img:"images/deploy-nodes-o.png"},
"flows":{label:"Deploy modified flows",img:"images/deploy-flows-o.png"}
}
var deploymentType = "full";
@@ -294,7 +294,8 @@ var RED = (function() {
function changeDeploymentType(type) {
deploymentType = type;
$("#btn-deploy span").text(deploymentTypes[type]);
$("#btn-deploy img").attr("src",deploymentTypes[type].img);
//$("#btn-deploy span").text(deploymentTypes[type].label);
}
$(function() {
@@ -330,14 +331,13 @@ var RED = (function() {
]
});
//RED.menu.init({id:"btn-deploy-options",
// options: [
// {id:"btn-deploy-select",label:"Select deployment type"},
// {id:"btn-deploy-full",icon:null,label:"Full deploy",tip:"Deploys all nodes",onselect:function() { changeDeploymentType("full")}},
// {id:"btn-deploy-node",icon:null,label:"Deploy changed nodes",tip:"Deploys all nodes that have been changed",onselect:function() { changeDeploymentType("nodes")}},
// {id:"btn-deploy-flow",icon:null,label:"Deploy changed flows",tip:"Deploys all nodes in flows that contain changes",onselect:function() { changeDeploymentType("flows")}}
// ]
//});
RED.menu.init({id:"btn-deploy-options",
options: [
{id:"btn-deploy-full",toggle:"deploy-type",icon:"images/deploy-full.png",label:"Full",sublabel:"Deploys everything in the workspace",onselect:function(s) { if(s){changeDeploymentType("full")}}},
{id:"btn-deploy-flow",toggle:"deploy-type",icon:"images/deploy-flows.png",label:"Modified Flows",sublabel:"Only deploys flows that contain changed nodes", onselect:function(s) {if(s){changeDeploymentType("flows")}}},
{id:"btn-deploy-node",toggle:"deploy-type",icon:"images/deploy-nodes.png",label:"Modified Nodes",sublabel:"Only deploys nodes that have changed",onselect:function(s) { if(s){changeDeploymentType("nodes")}}}
]
});
RED.keyboard.add(/* ? */ 191,{shift:true},function(){showHelp();d3.event.preventDefault();});
loadSettings();

View File

@@ -45,11 +45,27 @@ RED.menu = (function() {
item = $('<li class="divider"></li>');
} else {
item = $('<li></li>');
var link = $('<a '+(opt.id?'id="'+opt.id+'" ':'')+'tabindex="-1" href="#">'+
(opt.toggle?'<i class="fa fa-check pull-right"></i>':'')+
(opt.icon!==undefined?'<i class="'+(opt.icon?opt.icon:'" style="display: inline-block;"')+'"></i> ':"")+
'<span class="menu-label">'+opt.label+'</span>'+
'</a>').appendTo(item);
var linkContent = '<a '+(opt.id?'id="'+opt.id+'" ':'')+'tabindex="-1" href="#">'+
(opt.toggle?'<i class="fa fa-check pull-right"></i>':'');
if (opt.icon !== undefined) {
if (/\.png/.test(opt.icon)) {
linkContent += '<img src="'+opt.icon+'"/> ';
} else {
linkContent += '<i class="'+(opt.icon?opt.icon:'" style="display: inline-block;"')+'"></i> ';
}
}
if (opt.sublabel) {
linkContent += '<span class="menu-label-container"><span class="menu-label">'+opt.label+'</span>'+
'<span class="menu-sublabel">'+opt.sublabel+'</span></span>'
} else {
linkContent += '<span class="menu-label">'+opt.label+'</span>'
}
linkContent += '</a>';
var link = $(linkContent).appendTo(item);
menuItems[opt.id] = opt;
@@ -59,7 +75,22 @@ RED.menu = (function() {
return;
}
if (opt.toggle) {
setSelected(opt.id, !isSelected(opt.id));
var selected = isSelected(opt.id);
if (typeof opt.toggle === "string") {
if (!selected) {
for (var m in menuItems) {
if (menuItems.hasOwnProperty(m)) {
var mi = menuItems[m];
if (mi.id != opt.id && opt.toggle == mi.toggle) {
setSelected(mi.id,false);
}
}
}
setSelected(opt.id,true);
}
} else {
setSelected(opt.id, !selected);
}
} else {
opt.onselect.call(opt);
}