Mercurial > hg > Members > nobuyasu > html > graphViewer
changeset 40:8c3c1059e526 draft
start to implemente context menu
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Sat, 23 Mar 2013 18:26:33 +0900 |
parents | 3b597b795ea8 |
children | d75a3fdcbfdd |
files | show.html |
diffstat | 1 files changed, 69 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/show.html Sat Mar 23 16:47:20 2013 +0900 +++ b/show.html Sat Mar 23 18:26:33 2013 +0900 @@ -68,14 +68,17 @@ </div> </div> -<div class='contextMenu' id='selectMenu'> +<div class='contentMenu' id='selectMenu'> <ul> <div style='text-align:left; font-size:15px; font-width:500;'>State Select</div> - <li id='stateSelect'>accept</li> - <li id='stateSelect'>reject</li> - <li id='stateSelect'>retract</li> + <div id='stateSlectMenu'> + <li id='stateAccept'>accept</li> + <li id='stateReject'>reject</li> + <li id='stateRetract'>retract</li> + </div> <div style='text-align:left; font-size:15px; font-width:500;'>Traverse</div> - <li id='traverseSelect'>Traverse Select</li> + <div id='traverseSelectMenu'> + </div> </ul> </div> @@ -529,17 +532,70 @@ Context:'dashed' }; -function registContextMenu(elem) { - elem.contextMenu('selectMenu',{ +function createContextMenuObj(node, addObj) { + function _updateInfo(node, state) { + postToServer("id="+node.property.id+"&state="+state); + node.property.state = state; + updateNodeElement(node); + } + var bindObj = { bindings: { - 'stateSelect': function(f) { - alert('Trigger was'+f.id+'\nAction was Open'); + 'stateAccept': function(f) { + _updateInfo(node,"Accepted"); }, - 'traverseSelect': function(f) { - alert('traverse select'); + 'stateReject': function(f) { + _updateInfo(node,"Rejected"); + }, + 'stateRetract': function(f) { + _updateInfo(node,"Retracted"); } } - }); + }; + for (var key in addObj['bindings']) { + bindObj['bindings'][key] = addObj['bindings'][key]; + } + return bindObj; +} + +var TRAVERSE_LI_NAME = "traverseList"; +function createTraverseMenuObj(edgeInfo) { + var bindObj = {}; + bindObj.bindings = {}; + for (var i=0; i<edgeInfo.length; i++) { + var idName = TRAVERSE_LI_NAME + i; + bindObj.bindings[idName] = function(f) { + + } + } + +} + +function returnTraverseMenuFunction(state) { + return function(){stateTraversePost(state);}; +} + +function createTraverseMenuAndObj(edgeInfoArray) { + var menu = $('#traverseSelectMenu'); + menu.children().remove(); + var bindObj = {}; + bindObj.bindings = {}; + for (var i=0; i<edgeInfoArray.length; i++) { + var edgeInfo = edgeInfoArray[i]; + var str = edgeInfo.kind +" : " + edgeInfo.num + " : " + edgeInfo.direction; + var idName = TRAVERSE_LI_NAME + i; + var divStr = "<li id="+idName+">"+str+"</li>"; + var div = $(divStr); + appendMenuBody(menu, div); + bindObj.bindings[idName] = returnTraverseMenuFunction(edgeInfo.kind); + } + console.log("bindObj = ",bindObj); + return bindObj; +} + +function setInitContextMenu(node,elem) { + var tObj = createTraverseMenuAndObj(node.property.edgeInfo); + var bindObj = createContextMenuObj(node, tObj); + elem.contextMenu('selectMenu', bindObj); } function updateNodeElement(node) { @@ -549,7 +605,7 @@ createNodeDiv(node); } var div = node.view; - registContextMenu(div); + setInitContextMenu(node,div); div.hover( function(){div.css("box-shadow","white 0 0 50px"); }, function(){div.css("box-shadow","");}