# HG changeset patch # User Nobuyasu Oshiro # Date 1364065380 -32400 # Node ID 0f624dc3664df53863fced99e36d91f5b42d9cde # Parent a5c65ac33c760acf0549acc6809752bf90f503f8 insert inspect menu in contextMenu diff -r a5c65ac33c76 -r 0f624dc3664d show.html --- a/show.html Sun Mar 24 02:43:58 2013 +0900 +++ b/show.html Sun Mar 24 04:03:00 2013 +0900 @@ -78,6 +78,9 @@
Traverse
+
Inspect
+
+
@@ -428,12 +431,13 @@ function getInspect(id) { $.ajax({ url:"/aat/aaevidencesiftingmodel.userdesktops/inspect?id="+id, - success:function(o) { document.location = o; }, + success:function(o) { console.log("getInspect:"+this.url,o); }, type:"GET", cache:true, error:function(o) { console.log("getEvidence error : ", o); } }); } + function getEvidence(nodeId, edgeInfo) { $.ajax({ url:"/aat/aaevidencesiftingmodel.userdesktops/get?desktopid="+desktopid() +"&id="+nodeId+"&edgeinfoid="+edgeInfo.id, @@ -495,7 +499,7 @@ Context:'dashed' }; -function createContextMenuObj(node, addObj) { +function createContextMenuObj(node) { function _updateInfo(node, state) { postToServer("id="+node.property.id+"&state="+state); node.property.state = state; @@ -517,12 +521,12 @@ return bindObj; } -function returnTraverseMenuFunction(edgeInfo) { - return function(f){var id = CURRENT_DATA.nodeId; getEvidence(id, edgeInfo); }; +function returnTraverseMenuFunction(id, edgeInfo) { + return function(f){ getEvidence(id, edgeInfo); }; } var TRAVERSE_LI_ID_NAME = "traverseList"; -function createTraverseMenuAndObj(edgeInfoArray) { +function createTraverseMenuAndObj(id, edgeInfoArray) { var menu = $('#traverseSelectMenu'); menu.children().remove(); var bindObj = {}; @@ -531,32 +535,56 @@ var edgeInfo = edgeInfoArray[i]; var str = edgeInfo.kind +" : " + edgeInfo.num + " : " + edgeInfo.direction; var idName = TRAVERSE_LI_ID_NAME + i; - var divStr = "
  • "+str+"
  • "; + var divStr = "
  • "+str+"
  • "; var div = $(divStr); appendElement(menu, div); - bindObj.bindings[idName] = returnTraverseMenuFunction(edgeInfo); + bindObj.bindings[idName] = returnTraverseMenuFunction(id, edgeInfo); } return bindObj; } -function plusMenuObj(obj1, obj2) { +function returnInspectMenuFunction(id) { + return function(f) { getInspect(id); }; +} + +var INSPECT_LI_ID_NAME = 'inspectId' +function createInspectMenuAndObj(node) { + var bindObj = {}; + bindObj.bindings = {}; + if (node.property.kind != 'Document') return bindObj; + var menu = $('#inspectMenu'); + menu.children().remove(); + var idName = INSPECT_LI_ID_NAME; + var str = "access"; + var divStr = "
  • "+str+"
  • "; + var div = $(divStr); + appendElement(menu,div); + bindObj.bindings[idName] = returnInspectMenuFunction(node.property.id); + return bindObj; +} + +function plusBindingsObject(obj1, obj2) { var newObj = {}; newObj.bindings = {}; - var bindings1 = obj1['bindings']; - for (var key in bindings1) { - newObj.bindings[key] = bindings1[key]; + var o1 = obj1.bindings; + var o2 = obj2.bindings; + if (!o1) return o2; + if (!o2) return o1; + for (var key in o1 ) { + newObj.bindings[key] = o1[key]; } - var bindings2 = obj2['bindings']; - for (var key in bindings2) { - newObj.bindings[key] = bindings2[key]; + for (var key in o2 ) { + newObj.bindings[key] = o2[key] } return newObj; } function setInitContextMenu(node,elem) { - var tObj = createTraverseMenuAndObj(node.property.edgeInfo); - var bindObj = createContextMenuObj(node, tObj); - var newObj = plusMenuObj(bindObj, tObj); + var bindObj = createContextMenuObj(node); + var tObj = createTraverseMenuAndObj(node.property.id, node.property.edgeInfo); + var inspectObj = createInspectMenuAndObj(node); + var o = plusBindingsObject(bindObj, tObj); + var newObj = plusBindingsObject(o, inspectObj); elem.bindObj = newObj; elem.menuHTML = $('#selectMenu').clone()[0].innerHTML; } @@ -584,7 +612,7 @@ var div = node.view; setInitContextMenu(node,div); div.hover( - function(){CURRENT_DATA.nodeId = node.property.id; div.css("box-shadow","white 0 0 50px"); updateContextMenu(div); }, + function(){ CURRENT_DATA.nodeId = node.property.id; div.css("box-shadow","white 0 0 50px"); updateContextMenu(div); }, function(){div.css("box-shadow","");} ); node.view[0].nodeId = node.property.id; @@ -592,7 +620,8 @@ DragHandler.attach($(node.view)[0]); div.css('border-style',borderStyle[node.property.kind]); div.css("background", StateColor[node.property.state]||"white"); -// var kindBorder = {agree:"#66a", rejected:"#a66"}; + /* graphNode border color setting */ +// var kindBorder = {agreeed:"#66a", rejected:"#a66", retracted:#6a6 }; // div.css("border-color", kindBorder[node.property.state] ||"#58f"); div.css("border-color","#444"); div.css({ @@ -739,11 +768,11 @@ } function showAllEdge(graphData) { + jsPlumb.removeAllEndpoints(); var edges = graphData.edges; for (var id in edges) { showEdge(graphData, edges[id]); } - jsPlumb.removeAllEndpoints(); jsPlumb.draggable($('.graphNode')); }