Merge branch 'master' of github.com:Connoropolous/metamaps_gen002
This commit is contained in:
commit
bf957617da
3 changed files with 82 additions and 24 deletions
|
@ -408,26 +408,78 @@ var nodeSettings = {
|
|||
}
|
||||
}
|
||||
|
||||
function editEdge(edge, e) {
|
||||
deselectEdge(edge); //so the label is missing while editing
|
||||
if (!document.getElementById('edit_synapse')) {
|
||||
var edit_div = document.createElement('div');
|
||||
edit_div.setAttribute('id', 'edit_synapse');
|
||||
edit_div.setAttribute('class', 'best_in_place best_in_place_desc');
|
||||
edit_div.setAttribute('data-object', 'synapse');
|
||||
edit_div.setAttribute('data-attribute', 'desc');
|
||||
edit_div.setAttribute('data-type', 'input');
|
||||
//TODO how to get blank data-nil
|
||||
edit_div.setAttribute('data-nil', ' ');
|
||||
$('.main .wrapper').append(edit_div);
|
||||
}//if
|
||||
|
||||
$('#edit_synapse').attr('data-url', '/synapses/' + edge.getData("id"));
|
||||
$('#edit_synapse').html(edge.getData("desc"));
|
||||
$('#edit_synapse').css('position', 'absolute');
|
||||
$('#edit_synapse').css('left', e.clientX);
|
||||
$('#edit_synapse').css('top', e.clientY);
|
||||
|
||||
$('#edit_synapse').bind("ajax:success", function() {
|
||||
var desc = $(this).html();
|
||||
$('#edit_synapse').hide();
|
||||
edge.setData("desc", desc);
|
||||
selectEdge(edge);
|
||||
Mconsole.plot();
|
||||
});
|
||||
|
||||
$('#edit_synapse').focusout(function() {
|
||||
$('#edit_synapse').hide();
|
||||
});
|
||||
|
||||
//css stuff above moves it, this activates it
|
||||
$('#edit_synapse').click();
|
||||
$('#edit_synapse input').focus();
|
||||
$('#edit_synapse').show();
|
||||
}
|
||||
|
||||
function selectEdgeOnClickHandler(adj, e) {
|
||||
//editing overrides everything else
|
||||
if (e.altKey) {
|
||||
editEdge(adj, e);
|
||||
return;
|
||||
}
|
||||
|
||||
var showDesc = adj.getData("showDesc");
|
||||
if (showDesc) {
|
||||
if (showDesc && e.shiftKey) {
|
||||
//deselecting an edge with shift
|
||||
deselectEdge(adj);
|
||||
Mconsole.plot();
|
||||
}
|
||||
if (!e.shiftKey) {
|
||||
for (var i = 0; i < selectedEdges.length; i += 1) {
|
||||
var edge = selectedEdges[i];
|
||||
deselectEdge(edge);
|
||||
}
|
||||
}
|
||||
if (!showDesc) {
|
||||
} else if (!showDesc && e.shiftKey) {
|
||||
//selecting an edge with shift
|
||||
selectEdge(adj);
|
||||
} else if (showDesc && !e.shiftKey) {
|
||||
//deselecting an edge without shift - unselect all
|
||||
deselectAllEdges();
|
||||
} else if (!showDesc && !e.shiftKey) {
|
||||
//selecting an edge without shift - unselect all but new one
|
||||
deselectAllEdges();
|
||||
selectEdge(adj);
|
||||
Mconsole.plot();
|
||||
}
|
||||
|
||||
Mconsole.plot();
|
||||
}//selectEdgeOnClickHandler
|
||||
|
||||
function deselectAllEdges() {
|
||||
for (var i = 0; i < selectedEdges.length; i += 1) {
|
||||
var edge = selectedEdges[i];
|
||||
deselectEdge(edge);
|
||||
}
|
||||
}
|
||||
|
||||
function selectNodeOnClickHandler(node, e) {
|
||||
|
||||
//set final styles
|
||||
if (!e.shiftKey) {
|
||||
Mconsole.graph.eachNode(function (n) {
|
||||
|
|
|
@ -100,20 +100,27 @@ class SynapsesController < ApplicationController
|
|||
|
||||
# PUT synapses/:id
|
||||
def update
|
||||
@current = current_user
|
||||
@current = current_user
|
||||
@synapse = Synapse.find(params[:id]).authorize_to_edit(@current)
|
||||
|
||||
if @synapse
|
||||
@synapse.desc = params[:synapse][:desc]
|
||||
@synapse.category = params[:synapse][:category]
|
||||
@synapse.topic1 = Topic.find(params[:node1_id][:node1])
|
||||
@synapse.topic2 = Topic.find(params[:node2_id][:node2])
|
||||
@synapse.permission = params[:synapse][:permission]
|
||||
@synapse.save
|
||||
if @synapse
|
||||
if params[:synapse]
|
||||
@synapse.desc = params[:synapse][:desc] if params[:synapse][:desc]
|
||||
@synapse.category = params[:synapse][:category] if params[:synapse][:category]
|
||||
@synapse.permission = params[:synapse][:permission] if params[:synapse][:permission]
|
||||
end
|
||||
if params[:node1_id] and params[:node1_id][:node1]
|
||||
@synapse.topic1 = Topic.find(params[:node1_id][:node1])
|
||||
end
|
||||
if params[:node1_id] and params[:node1_id][:node1]
|
||||
@synapse.topic2 = Topic.find(params[:node2_id][:node2])
|
||||
end
|
||||
@synapse.save
|
||||
end
|
||||
|
||||
respond_with(@user, location: synapse_url(@synapse)) do |format|
|
||||
end
|
||||
respond_with @synapse
|
||||
#respond_with(@user, location: synapse_url(@synapse)) do |format|
|
||||
#end
|
||||
end
|
||||
|
||||
# POST mappings/:map_id/:synapse_id/removefrommap
|
||||
|
|
|
@ -10,7 +10,6 @@ if ( Mconsole != null) {
|
|||
temp2 = Mconsole.graph.getNode(<%= @synapse.topic2.id %>);
|
||||
Mconsole.graph.addAdjacence(temp1, temp2, {});
|
||||
temp = Mconsole.graph.getAdjacence(temp1.id, temp2.id);
|
||||
console.log(temp);
|
||||
temp.setDataset('start', {
|
||||
lineWidth: 0.4
|
||||
});
|
||||
|
@ -20,7 +19,7 @@ if ( Mconsole != null) {
|
|||
var d = new Array(<%= @synapse.node1_id.to_s() %>, <%= @synapse.node2_id.to_s() %>);
|
||||
temp.setDataset('current', {
|
||||
desc: '<%= @synapse.desc %>',
|
||||
showDesc: true,
|
||||
showDesc: false, //will be changed by selectEdge
|
||||
category: '<%= @synapse.category %>',
|
||||
id: '<%= @synapse.id %>',
|
||||
userid: '<%= @synapse.user.id %>',
|
||||
|
|
Loading…
Reference in a new issue