cleaned up synapse editing code - should be bug-free. Famous last words?
This commit is contained in:
parent
e2c408f983
commit
3f1d9ddda5
1 changed files with 21 additions and 14 deletions
|
@ -421,39 +421,46 @@ var nodeSettings = {
|
||||||
}
|
}
|
||||||
|
|
||||||
function editEdge(edge, e) {
|
function editEdge(edge, e) {
|
||||||
|
//reset so we don't interfere with other edges
|
||||||
|
$('#edit_synapse').remove();
|
||||||
|
|
||||||
deselectEdge(edge); //so the label is missing while editing
|
deselectEdge(edge); //so the label is missing while editing
|
||||||
if (!document.getElementById('edit_synapse')) {
|
|
||||||
var edit_div = document.createElement('div');
|
var edit_div = document.createElement('div');
|
||||||
edit_div.setAttribute('id', 'edit_synapse');
|
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);
|
$('.main .wrapper').append(edit_div);
|
||||||
}//if
|
$('#edit_synapse').attr('class', 'best_in_place best_in_place_desc');
|
||||||
|
$('#edit_synapse').attr('data-object', 'synapse');
|
||||||
|
$('#edit_synapse').attr('data-attribute', 'desc');
|
||||||
|
$('#edit_synapse').attr('data-type', 'input');
|
||||||
|
//TODO how to get blank data-nil
|
||||||
|
$('#edit_synapse').attr('data-nil', ' ');
|
||||||
$('#edit_synapse').attr('data-url', '/synapses/' + edge.getData("id"));
|
$('#edit_synapse').attr('data-url', '/synapses/' + edge.getData("id"));
|
||||||
$('#edit_synapse').html(edge.getData("desc"));
|
$('#edit_synapse').html(edge.getData("desc"));
|
||||||
|
|
||||||
$('#edit_synapse').css('position', 'absolute');
|
$('#edit_synapse').css('position', 'absolute');
|
||||||
$('#edit_synapse').css('left', e.clientX);
|
$('#edit_synapse').css('left', e.clientX);
|
||||||
$('#edit_synapse').css('top', e.clientY);
|
$('#edit_synapse').css('top', e.clientY);
|
||||||
|
|
||||||
$('#edit_synapse').bind("ajax:success", function() {
|
$('#edit_synapse').bind("ajax:success", function() {
|
||||||
var desc = $(this).html();
|
var desc = $(this).html();
|
||||||
$('#edit_synapse').hide();
|
|
||||||
edge.setData("desc", desc);
|
edge.setData("desc", desc);
|
||||||
selectEdge(edge);
|
selectEdge(edge);
|
||||||
Mconsole.plot();
|
Mconsole.plot();
|
||||||
|
$('#edit_synapse').remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#edit_synapse').focusout(function() {
|
$('#edit_synapse').focusout(function() {
|
||||||
$('#edit_synapse').hide();
|
//in case they cancel
|
||||||
|
// $('#edit_synapse').hide();
|
||||||
});
|
});
|
||||||
|
|
||||||
//css stuff above moves it, this activates it
|
//css stuff above moves it, this activates it
|
||||||
$('#edit_synapse').click();
|
$('#edit_synapse').click();
|
||||||
|
$('#edit_synapse form').submit(function() {
|
||||||
|
//hide it once form submits.
|
||||||
|
//If you don't do this, and data is unchanged, it'll show up on canvas
|
||||||
|
$('#edit_synapse').hide();
|
||||||
|
});
|
||||||
$('#edit_synapse input').focus();
|
$('#edit_synapse input').focus();
|
||||||
$('#edit_synapse').show();
|
$('#edit_synapse').show();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue