cancel synapse creation with esc, backspace, or delete

This commit is contained in:
Devin Howard 2016-02-12 11:21:22 +08:00
parent 056ef2b5b6
commit 9469b08ffa

View file

@ -791,16 +791,22 @@ Metamaps.Create = {
}]
);
$('#synapse_desc').keyup(function () {
$('#synapse_desc').keyup(function (e) {
var ESC = 27, BACKSPACE = 8, DELETE = 46;
if (e.keyCode === BACKSPACE && $(this).val() === "" ||
e.keyCode === DELETE && $(this).val() === "" ||
e.keyCode === ESC) {
Metamaps.Create.newSynapse.hide();
}//if
Metamaps.Create.newSynapse.description = $(this).val();
});
$('#synapse_desc').focusout(function() {
// Metamaps.Create.newSynapse.description = $(this).val();
Metamaps.Synapse.createSynapseLocally();
if (Metamaps.Create.newSynapse.beingCreated) {
Metamaps.Synapse.createSynapseLocally();
}
});
$('#synapse_desc').bind('typeahead:select', function (event, datum, dataset) {
if (datum.id) { // if they clicked on an existing synapse get it
Metamaps.Synapse.getSynapseFromAutocomplete(datum.id);