From 56ab1b3ce809a8fb9f5025d9a81ddd5a6d5ceeac Mon Sep 17 00:00:00 2001 From: ivanPozdnyakov Date: Wed, 6 Jan 2016 14:18:45 -0500 Subject: [PATCH] quick fix and refactoring for searching --- VQI_PathwayEditor.js | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/VQI_PathwayEditor.js b/VQI_PathwayEditor.js index 961d916..d208b2e 100755 --- a/VQI_PathwayEditor.js +++ b/VQI_PathwayEditor.js @@ -318,31 +318,38 @@ var VQI_PathwayEditor = function (parent) { dialogNewPathway.dialog("close"); } + function focus(name){ + var cy = $('#' + parent + '-cy').cytoscape('get'); + cy.elements("node[name = \"" + name + "\"]").select(); + cy.$('node').style("opacity", 0.2); + cy.$('edge').style("opacity", 0.2); + cy.$('node:selected').style("opacity", 1.0); + cy.$('edge:selected').style("opacity", 1.0); + } + + function unFocus(){ + var cy = $('#' + parent + '-cy').cytoscape('get'); + cy.$('node').unselect(); + cy.$('node').removeStyle("opacity"); + cy.$('edge').removeStyle("opacity"); + cy.$('node:selected').removeStyle("opacity"); + cy.$('edge:selected').removeStyle("opacity"); + } + function search(event){ var cy = $('#' + parent + '-cy').cytoscape('get'); var name = document.getElementById(parent + "-search-node-name").value; + unFocus(); if(name != ""){ - cy.elements("node[name = \"" + name + "\"]").select(); - cy.$('node').style("opacity", 0.2); - cy.$('edge').style("opacity", 0.2); - cy.$('node:selected').style("opacity", 1.0); - cy.$('edge:selected').style("opacity", 1.0); + focus(name); } else { - cy.$('node').unselect(); - cy.$('node').removeStyle("opacity"); - cy.$('edge').removeStyle("opacity"); - cy.$('node:selected').removeStyle("opacity"); - cy.$('edge:selected').removeStyle("opacity"); + unFocus(); } } function exitSearch(event){ var cy = $('#' + parent + '-cy').cytoscape('get'); - cy.$('node').unselect(); - cy.$('node').removeStyle("opacity"); - cy.$('edge').removeStyle("opacity"); - cy.$('node:selected').removeStyle("opacity"); - cy.$('edge:selected').removeStyle("opacity"); + unFocus(); } function onChangePathwayFile(event) {