Merge branch 'master' of github.com:Connoropolous/metamaps_gen002
This commit is contained in:
commit
759e6aa0bd
6 changed files with 67 additions and 28 deletions
app
assets/javascripts
views/topics
|
@ -163,14 +163,34 @@ function onCanvasSearch(name,mapID,mapperID) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function clearCanvas() {
|
function clearCanvas() {
|
||||||
Mconsole.graph.eachNode( function(n) { Mconsole.graph.removeNode(n.id); Mconsole.labels.disposeLabel(n.id); });
|
Mconsole.graph.eachNode(function(n) {
|
||||||
Mconsole.plot();
|
Mconsole.graph.removeNode(n.id);
|
||||||
|
Mconsole.labels.disposeLabel(n.id);
|
||||||
|
});
|
||||||
|
Mconsole.plot();
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearCanvasExceptRoot() {
|
||||||
|
var ids = new Array();
|
||||||
|
Mconsole.graph.eachNode(function(n) {
|
||||||
|
ids.push(n.id);
|
||||||
|
});
|
||||||
|
|
||||||
|
var root = Mconsole.graph.nodes[Mconsole.root];
|
||||||
|
ids.forEach(function(id, index) {
|
||||||
|
if (id != root.id) {
|
||||||
|
Mconsole.graph.removeNode(id);
|
||||||
|
//OK I feel bad about this, but not too bad
|
||||||
|
//TODO: this leaves labels hidden on the map
|
||||||
|
Mconsole.labels.hideLabel(id);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fetchRelatives(root); //also runs Mconsole.plot()
|
||||||
}
|
}
|
||||||
|
|
||||||
function clearFoundData() {
|
function clearFoundData() {
|
||||||
Mconsole.graph.eachNode( function(n) {
|
Mconsole.graph.eachNode( function(n) {
|
||||||
if (n.getData('inCommons') === true) {
|
if (n.getData('inCommons') === true) {
|
||||||
Mconsole.graph.removeNode(n.id);
|
Mconsole.graph.removeNode(n.id);
|
||||||
Mconsole.labels.disposeLabel(n.id);
|
Mconsole.labels.disposeLabel(n.id);
|
||||||
|
@ -557,4 +577,4 @@ function closeFind() {
|
||||||
width: '45px',
|
width: '45px',
|
||||||
height: '32px'
|
height: '32px'
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
var MetamapsModel = new Object();
|
var MetamapsModel = new Object();
|
||||||
MetamapsModel.selectedEdges = new Array();
|
MetamapsModel.selectedEdges = new Array();
|
||||||
|
MetamapsModel.showcardInUse = null;
|
||||||
MetamapsModel.lastCanvasClick = 0;
|
MetamapsModel.lastCanvasClick = 0;
|
||||||
MetamapsModel.DOUBLE_CLICK_TOLERANCE = 300;
|
MetamapsModel.DOUBLE_CLICK_TOLERANCE = 300;
|
||||||
MetamapsModel.edgeHoveringOver = false;
|
MetamapsModel.edgeHoveringOver = false;
|
||||||
|
|
|
@ -75,8 +75,8 @@ function graphSettings(type) {
|
||||||
onClick: function (node, eventInfo, e) {
|
onClick: function (node, eventInfo, e) {
|
||||||
if (e.target.id != "infovis-canvas") return false;
|
if (e.target.id != "infovis-canvas") return false;
|
||||||
|
|
||||||
//hide synapse editing dialog
|
//topic and synapse editing cards
|
||||||
$('#edit_synapse').hide();
|
hideCards();
|
||||||
|
|
||||||
//clicking on a node, or clicking on blank part of canvas?
|
//clicking on a node, or clicking on blank part of canvas?
|
||||||
if (node.nodeFrom) {
|
if (node.nodeFrom) {
|
||||||
|
@ -122,6 +122,10 @@ function graphSettings(type) {
|
||||||
t.Events.onClick = function(node, eventInfo, e) {
|
t.Events.onClick = function(node, eventInfo, e) {
|
||||||
//this is handled mostly differently than in arranged/chaotic
|
//this is handled mostly differently than in arranged/chaotic
|
||||||
if (e.target.id != "infovis-canvas") return false;
|
if (e.target.id != "infovis-canvas") return false;
|
||||||
|
|
||||||
|
//hide synapse and topic editing dialog
|
||||||
|
hideCards();
|
||||||
|
|
||||||
//clicking on an edge, a node, or clicking on blank part of canvas?
|
//clicking on an edge, a node, or clicking on blank part of canvas?
|
||||||
if (node.nodeFrom) {
|
if (node.nodeFrom) {
|
||||||
selectEdgeOnClickHandler(node, e);
|
selectEdgeOnClickHandler(node, e);
|
||||||
|
@ -147,6 +151,11 @@ function graphSettings(type) {
|
||||||
return t;
|
return t;
|
||||||
}//graphSettings
|
}//graphSettings
|
||||||
|
|
||||||
|
function hideCards() {
|
||||||
|
$('#edit_synapse').hide();
|
||||||
|
hideCurrentCard();
|
||||||
|
}
|
||||||
|
|
||||||
// defining code to draw edges with arrows pointing in one direction
|
// defining code to draw edges with arrows pointing in one direction
|
||||||
var renderMidArrow = function(from, to, dim, swap, canvas){
|
var renderMidArrow = function(from, to, dim, swap, canvas){
|
||||||
var ctx = canvas.getCtx();
|
var ctx = canvas.getCtx();
|
||||||
|
|
|
@ -255,6 +255,13 @@ function generateLittleHTML(node) {
|
||||||
return littleHTML;
|
return littleHTML;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function hideCurrentCard() {
|
||||||
|
if (MetamapsModel.showcardInUse) {
|
||||||
|
var node = Mconsole.graph.getNode(MetamapsModel.showcardInUse);
|
||||||
|
hideCard(node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function hideCard(node) {
|
function hideCard(node) {
|
||||||
var card = '.showcard';
|
var card = '.showcard';
|
||||||
if (node != null) {
|
if (node != null) {
|
||||||
|
@ -263,13 +270,14 @@ function hideCard(node) {
|
||||||
|
|
||||||
$(card).fadeOut('fast', function(){
|
$(card).fadeOut('fast', function(){
|
||||||
node.setData('dim', 25, 'current');
|
node.setData('dim', 25, 'current');
|
||||||
$('.name').show();
|
$('.name.topic_' + node.id).show();
|
||||||
Mconsole.plot();
|
Mconsole.plot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
MetamapsModel.showcardInUse = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function bindCallbacks(showCard, nameContainer, node) {
|
function bindCallbacks(showCard, nameContainer, node) {
|
||||||
|
|
||||||
// add some events to the label
|
// add some events to the label
|
||||||
$(showCard).find('img.icon').click(function(){
|
$(showCard).find('img.icon').click(function(){
|
||||||
hideCard(node);
|
hideCard(node);
|
||||||
|
@ -279,12 +287,14 @@ function bindCallbacks(showCard, nameContainer, node) {
|
||||||
|
|
||||||
// add some events to the label
|
// add some events to the label
|
||||||
$(nameContainer).find('.label').click(function(e){
|
$(nameContainer).find('.label').click(function(e){
|
||||||
$('.showcard').css('display','none');
|
|
||||||
$('.name').css('display','block');
|
$('.name').css('display','block');
|
||||||
$('.name.topic_' + node.id).css('display','none');
|
$('.name.topic_' + node.id).css('display','none');
|
||||||
$('.showcard.topic_' + node.id).fadeIn('fast');
|
$('.showcard.topic_' + node.id).fadeIn('fast');
|
||||||
$('.showcard.topic_' + node.id).find('.scroll').mCustomScrollbar("update");
|
$('.showcard.topic_' + node.id).find('.scroll').mCustomScrollbar("update");
|
||||||
node.setData('dim', 1, 'current');
|
node.setData('dim', 1, 'current');
|
||||||
|
|
||||||
|
hideCurrentCard();
|
||||||
|
MetamapsModel.showcardInUse = node.id;
|
||||||
Mconsole.plot();
|
Mconsole.plot();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,15 @@ function saveToMap() {
|
||||||
var nodes_data = "", synapses_data = "";
|
var nodes_data = "", synapses_data = "";
|
||||||
var synapses_array = new Array();
|
var synapses_array = new Array();
|
||||||
Mconsole.graph.eachNode(function(n) {
|
Mconsole.graph.eachNode(function(n) {
|
||||||
nodes_data += n.id + '/' + n.pos.x + '/' + n.pos.y + ',';
|
var x, y;
|
||||||
|
if (n.pos.x && n.pos.y) {
|
||||||
|
x = n.pos.x;
|
||||||
|
y = n.pos.y;
|
||||||
|
} else {
|
||||||
|
var x = Math.cos(n.pos.theta) * n.pos.rho;
|
||||||
|
var y = Math.sin(n.pos.theta) * n.pos.rho;
|
||||||
|
}
|
||||||
|
nodes_data += n.id + '/' + x + '/' + y + ',';
|
||||||
n.eachAdjacency(function(adj) {
|
n.eachAdjacency(function(adj) {
|
||||||
synapses_array.push(adj.getData("id"));
|
synapses_array.push(adj.getData("id"));
|
||||||
});
|
});
|
||||||
|
|
|
@ -14,23 +14,13 @@
|
||||||
#
|
#
|
||||||
#%>
|
#%>
|
||||||
|
|
||||||
<!--<div class="focus topic_<%= @topic.id %>">
|
<div class="headertop">
|
||||||
<div class="focusleft">
|
<% if authenticated? %>
|
||||||
<p><%= @topic.metacode.name %></p>
|
<button onclick="saveToMap();">Save to Map</button>
|
||||||
<%= image_tag @topic.metacode.icon, :class => 'icon', :size => '50x50' %>
|
<% end %>
|
||||||
</div>
|
<button onclick='clearCanvasExceptRoot();'>Clear Canvas</button>
|
||||||
<div class="focusmiddle">
|
|
||||||
<h1 class="title"><span class="title-text"><%= @topic.name %></span> <% if (@topic.permission == "commons" && authenticated?) || @topic.user == user %><%= link_to "[edit]", edit_topic_path(@topic) %><% end %></h1>
|
|
||||||
<div class="desc">
|
|
||||||
<p><%= @topic.desc %></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="focusright">
|
|
||||||
<p>Link</p>
|
|
||||||
<%= link_to @topic.link, @topic.link, :class => 'link', :target => '_blank' %>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="clearfloat nodemargin"></div>-->
|
<div class="clearfloat"></div>
|
||||||
|
|
||||||
<h1 class="index">
|
<h1 class="index">
|
||||||
Viewing Topic: <%= @topic.name %>
|
Viewing Topic: <%= @topic.name %>
|
||||||
|
@ -53,6 +43,7 @@
|
||||||
|
|
||||||
<% if authenticated? %>
|
<% if authenticated? %>
|
||||||
<%= render :partial => 'topics/new' %>
|
<%= render :partial => 'topics/new' %>
|
||||||
<%= render :partial => 'synapses/new' %>
|
<%= render :partial => 'synapses/new' %>
|
||||||
|
<%= render :partial => 'maps/new' %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue