From 84eb96353b98043206659c38b22ea89c6a045784 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Fri, 28 Nov 2014 20:53:57 +0200 Subject: textanalysis.ui: make typeselection component like --- src/textanalysis.ui.js | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) (limited to 'src/textanalysis.ui.js') diff --git a/src/textanalysis.ui.js b/src/textanalysis.ui.js index a8213421..10007bd7 100644 --- a/src/textanalysis.ui.js +++ b/src/textanalysis.ui.js @@ -8,18 +8,39 @@ var element_name = '#textanalyser'; var element = $(element_name); var suggestionChange; +var typeselection = function TypeSelectionDialog() { + var e = $('.typeselection'), + typeselection = {}; + + typeselection.analysisNodeStart = function() { + typeselection.show(); + e.html('
Use [TAB] key to pick a type
'); + } + typeselection.show = function() { + e.css({ + top: window.innerHeight/2-115, + left: window.innerWidth/2-325}); + } + typeselection.hide = function() { + e.css('top', -300); + e.css('left', 0); + } + typeselection.showChosenType = function(nodetype) { + e.html('
' + "Chosen Type: " + nodetype + '
'); + } + return typeselection; +}(); + function analyzeSentence(sentence, finalize) { var ret = textanalysis.textAnalyser(sentence, finalize); switch (ret.state) { case textanalysis.ANALYSIS_NODE_START: - $('.typeselection').css({top:window.innerHeight/2-115,left:window.innerWidth/2-325}); - $('.typeselection').html('
Use [TAB] key to pick a type
'); + typeselection.analysisNodeStart(); break; case textanalysis.ANALYSIS_LINK: - $('.typeselection').css('top', -300); - $('.typeselection').css('left', 0); + typeselection.hide(); break; } @@ -27,8 +48,7 @@ function analyzeSentence(sentence, finalize) ret.applyToGraph(rz_core.graph, backend_commit); if (finalize || sentence.length == 0) { - $('.typeselection').css('top', -300); - $('.typeselection').css('left', 0); + typeselection.hide(); $('span.ui-helper-hidden-accessible').hide(); } else { $('span.ui-helper-hidden-accessible').show(); @@ -63,11 +83,11 @@ function changeType(arg) { if (arg === 'up') { rz_core.graph.editType(id, null, nodetype); - $('.typeselection').html('
' + "Chosen Type: " + nodetype + '
'); + typeselection.showChosenType(nodetype); rz_core.graph.findCoordinates(id, null); } else { rz_core.graph.editType(id, null, nodetype); - $('.typeselection').html('
' + "Chosen Type: " + nodetype + '
'); + typeselection.showChosenType(nodetype); rz_core.graph.findCoordinates(id, null); } rz_core.update_view__graph(true); -- cgit v1.3.1