From 5e051ebff26158703b71c6db26a9586779205d06 Mon Sep 17 00:00:00 2001 From: Devin Howard Date: Thu, 14 Feb 2013 22:23:14 -0500 Subject: [PATCH] allow showcards to disappear when you click on the canvas. also fixed a couple other bugs related to showcards that make code a little more logical --- .../javascripts/Jit/graphsettings-model.js | 1 + app/assets/javascripts/Jit/graphsettings.js | 13 +++++++++---- .../javascripts/Jit/onCreateLabelHandler.js | 16 +++++++++++++--- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/Jit/graphsettings-model.js b/app/assets/javascripts/Jit/graphsettings-model.js index c67de017..30b639cc 100644 --- a/app/assets/javascripts/Jit/graphsettings-model.js +++ b/app/assets/javascripts/Jit/graphsettings-model.js @@ -7,6 +7,7 @@ var MetamapsModel = new Object(); MetamapsModel.selectedEdges = new Array(); +MetamapsModel.showcardInUse = null; MetamapsModel.lastCanvasClick = 0; MetamapsModel.DOUBLE_CLICK_TOLERANCE = 300; MetamapsModel.edgeHoveringOver = false; diff --git a/app/assets/javascripts/Jit/graphsettings.js b/app/assets/javascripts/Jit/graphsettings.js index 74cf5105..8b3b4165 100644 --- a/app/assets/javascripts/Jit/graphsettings.js +++ b/app/assets/javascripts/Jit/graphsettings.js @@ -75,8 +75,8 @@ function graphSettings(type) { onClick: function (node, eventInfo, e) { if (e.target.id != "infovis-canvas") return false; - //hide synapse editing dialog - $('#edit_synapse').hide(); + //topic and synapse editing cards + hideCards(); //clicking on a node, or clicking on blank part of canvas? if (node.nodeFrom) { @@ -123,8 +123,8 @@ function graphSettings(type) { //this is handled mostly differently than in arranged/chaotic if (e.target.id != "infovis-canvas") return false; - //hide synapse editing dialog - $('#edit_synapse').hide(); + //hide synapse and topic editing dialog + hideCards(); //clicking on an edge, a node, or clicking on blank part of canvas? if (node.nodeFrom) { @@ -151,6 +151,11 @@ function graphSettings(type) { return t; }//graphSettings +function hideCards() { + $('#edit_synapse').hide(); + hideCurrentCard(); +} + // defining code to draw edges with arrows pointing in one direction var renderMidArrow = function(from, to, dim, swap, canvas){ var ctx = canvas.getCtx(); diff --git a/app/assets/javascripts/Jit/onCreateLabelHandler.js b/app/assets/javascripts/Jit/onCreateLabelHandler.js index 616c609b..7910fe2e 100644 --- a/app/assets/javascripts/Jit/onCreateLabelHandler.js +++ b/app/assets/javascripts/Jit/onCreateLabelHandler.js @@ -255,6 +255,13 @@ function generateLittleHTML(node) { return littleHTML; } +function hideCurrentCard() { + if (MetamapsModel.showcardInUse) { + var node = Mconsole.graph.getNode(MetamapsModel.showcardInUse); + hideCard(node); + } +} + function hideCard(node) { var card = '.showcard'; if (node != null) { @@ -263,13 +270,14 @@ function hideCard(node) { $(card).fadeOut('fast', function(){ node.setData('dim', 25, 'current'); - $('.name').show(); + $('.name.topic_' + node.id).show(); Mconsole.plot(); }); + + MetamapsModel.showcardInUse = null; } function bindCallbacks(showCard, nameContainer, node) { - // add some events to the label $(showCard).find('img.icon').click(function(){ hideCard(node); @@ -279,12 +287,14 @@ function bindCallbacks(showCard, nameContainer, node) { // add some events to the label $(nameContainer).find('.label').click(function(e){ - $('.showcard').css('display','none'); $('.name').css('display','block'); $('.name.topic_' + node.id).css('display','none'); $('.showcard.topic_' + node.id).fadeIn('fast'); $('.showcard.topic_' + node.id).find('.scroll').mCustomScrollbar("update"); node.setData('dim', 1, 'current'); + + hideCurrentCard(); + MetamapsModel.showcardInUse = node.id; Mconsole.plot(); });