subset of synapse creation changes (#970)

* esc cancels topic and synapse creation now

* close topic/synapse creation on right click

* backspace and delete don't close synapse creation anymore

* hitting tab saves the synapse you're creating
This commit is contained in:
Devin Howard 2016-12-11 17:15:09 -05:00 committed by GitHub
parent 6129a27ecf
commit 1ba339b3be
2 changed files with 23 additions and 7 deletions

View file

@ -140,7 +140,13 @@ const Create = {
}, },
newTopic: { newTopic: {
init: function() { init: function() {
$('#topic_name').keyup(function() { $('#topic_name').keyup(function(e) {
const ESC = 27
if (e.keyCode === ESC) {
Create.newTopic.hide()
} // if
Create.newTopic.name = $(this).val() Create.newTopic.name = $(this).val()
}) })
@ -301,13 +307,11 @@ const Create = {
$('#synapse_desc').keyup(function(e) { $('#synapse_desc').keyup(function(e) {
const ESC = 27 const ESC = 27
const BACKSPACE = 8
const DELETE = 46 if (e.keyCode === ESC) {
if (e.keyCode === BACKSPACE && $(this).val() === '' ||
e.keyCode === DELETE && $(this).val() === '' ||
e.keyCode === ESC) {
Create.newSynapse.hide() Create.newSynapse.hide()
} // if } // if
Create.newSynapse.description = $(this).val() Create.newSynapse.description = $(this).val()
}) })
@ -317,6 +321,14 @@ const Create = {
} }
}) })
$('#synapse_desc').keydown(function(e) {
const TAB = 9
if (Create.newSynapse.beingCreated && e.keyCode === TAB) {
e.preventDefault()
Synapse.createSynapseLocally()
}
})
$('#synapse_desc').bind('typeahead:select', function(event, datum, dataset) { $('#synapse_desc').bind('typeahead:select', function(event, datum, dataset) {
if (datum.id) { // if they clicked on an existing synapse get it if (datum.id) { // if they clicked on an existing synapse get it
Synapse.getSynapseFromAutocomplete(datum.id) Synapse.getSynapseFromAutocomplete(datum.id)

View file

@ -420,6 +420,8 @@ const JIT = {
$('.rightclickmenu').remove() $('.rightclickmenu').remove()
if (Mouse.boxStartCoordinates) { if (Mouse.boxStartCoordinates) {
Create.newSynapse.hide()
Create.newTopic.hide()
Visualize.mGraph.busy = false Visualize.mGraph.busy = false
Mouse.boxEndCoordinates = eventInfo.getPos() Mouse.boxEndCoordinates = eventInfo.getPos()
JIT.selectWithBox(e) JIT.selectWithBox(e)
@ -434,7 +436,9 @@ const JIT = {
} else if (node && !node.nodeFrom) { } else if (node && !node.nodeFrom) {
JIT.selectNodeOnRightClickHandler(node, e) JIT.selectNodeOnRightClickHandler(node, e)
} else { } else {
// console.log('right clicked on open space') // right click open space
Create.newSynapse.hide()
Create.newTopic.hide()
} }
} }
}, },