Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rightMenu #88

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ const Edge = require('./src/edge/baseEdge');
const Endpoint = require('./src/endpoint/baseEndpoint');
const Group = require('./src/group/baseGroup');
const Node = require('./src/node/baseNode');

const ServiceCanvas = require('./src/service/sevice.js');
module.exports = {
Canvas,
Edge,
Endpoint,
Group,
Node
Node,
ServiceCanvas
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个应该叫MenuService

};
74 changes: 73 additions & 1 deletion src/canvas/baseCanvas.less
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,79 @@
display: block;
}
}

.endpoint-tips-menu{
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个menu应该是能支持所有的节点,名字有问题

position: fixed;
background: #fff;
z-index: 1000;
min-width: 220px;
border-radius: 3px;
.endpoint-tips-menu-title{
padding: 3px 10px;
border-bottom: 1px solid #dcdcdc
}
.endpoint-tips-menu-content{
padding: 3px 10px;
.yellow-point{
background: yellowgreen;
display: inline-block;
width: 6px;
height: 6px;
border-radius: 50%;
margin-right: 5px;
}
}
}
.node-menu, .label-menu {
position: fixed;
min-width: 90px;
background-color: #fff;
background-clip: padding-box;
text-align: center;
color:#333333;
z-index: 200;
border-top: 1px solid #DCDCDC;
border-right: 1px solid #DCDCDC;
border-left: 1px solid #DCDCDC;
.link-menu-item:hover{
background: #7C93A0;
color: #fff;
}
.node-menu-item{
text-align: left;
padding: 6px 10px 6px 10px;
cursor: pointer;
width: auto;
min-width: 90px;
height: 30px;
}
.node-menu-item-bottm{
border-bottom: none;
padding: 6px 10px 6px 10px;
height: 30px;
}
.node-menu-item:last-child{
border-bottom: 1px solid #DCDCDC;
}
.node-menu-item:hover{
background: #00C1DE;
color: #fff;
}
&.dag-node-menu{
padding: 3px 0;
border-bottom: 1px solid #DCDCDC;
.node-menu-item{
text-align: left;
padding: 3px 10px 3px 10px;
cursor: pointer;
width: auto;
min-width: 90px;
height: 24px;
}
.node-menu-item:last-child{
border-bottom: none;
}
}
}
.butterfly-gird-canvas {
position: absolute;
top: 0;
Expand Down
55 changes: 55 additions & 0 deletions src/service/sevice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
const $ = require('jquery');
const _ = require('lodash');


function createMenuList(param, callBack, e) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

抽象库不能这样写。。。event是业务或者外部耦合的,不应该传进来处理

/**
* param.type:
* 若tips: param是个对象: {type: 'tips', title: '必须有', contente: '必须有'}
* 其他: param是: {list: [{code: '', title: ''}]} 里面的字段必须传的
*
*/
let evt = e || window.event;
let pos = {
left: evt.clientX,
top: evt.clientY
};
if (param.type === 'tips') {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我建议分开2个方法吧,不要耦合在一起

$(document.body).find('.endpoint-tips-menu').remove();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个使用方法上有问题

let _content = $('<div class="endpoint-tips-menu-content"><div class="content-box"><span class="yellow-point"></span><span class="text">' + param.content + '</span></div></div>');
let _dom = $('<div class="endpoint-tips-menu"></div>').css('top', pos.top + 5).css('left', pos.left - 100);
let _title = $('<div class="endpoint-tips-menu-title"></div>')
.text(param.title);
_title.appendTo(_dom);
_content.appendTo(_dom);
_dom.appendTo($(document.body));
} else {
$(document.body).find('.node-menu').remove();
let nodeMenu = $('<ul class="node-menu"></ul>').css('top', pos.top).css('left', pos.left);
_.get(param, 'list', []).forEach((item) => {
$('<li class="node-menu-item"></li>')
.attr('key', item.code)
.text(item.title)
.on('click', (e) => {
e.stopPropagation();
if (typeof callBack === 'function') {
return callBack(item);
}
})
.appendTo(nodeMenu);
});
nodeMenu.appendTo($(document.body));
}
}
function hideMenuList(type) {
if (type === 'tips') {
$(document.body).find('.endpoint-tips-menu').remove();
} else {
$(document.body).find('.node-menu').remove();
}
}

module.exports = {
createMenuList,
hideMenuList
}