From 4134badf9d08ddd8b4610990140a345fdd201f7b Mon Sep 17 00:00:00 2001 From: rolux Date: Fri, 6 Feb 2015 10:16:13 +0000 Subject: [PATCH] editor view: fix invalid entity inputs; fix keyboard focus --- source/UI/js/Form/Editable.js | 1 + source/UI/js/Video/AnnotationFolder.js | 34 ++++++++++++++-------- source/UI/js/Video/AnnotationPanel.js | 6 ++-- source/UI/js/Video/VideoAnnotationPanel.js | 2 +- 4 files changed, 27 insertions(+), 16 deletions(-) diff --git a/source/UI/js/Form/Editable.js b/source/UI/js/Form/Editable.js index 5539e02e..3d528bc9 100644 --- a/source/UI/js/Form/Editable.js +++ b/source/UI/js/Form/Editable.js @@ -66,6 +66,7 @@ Ox.Editable = function(options, self) { }, value: function() { self.$value.html(formatValue()); + self.$input && self.$input.options({value: formatInputValue()}); } }) .addClass( diff --git a/source/UI/js/Video/AnnotationFolder.js b/source/UI/js/Video/AnnotationFolder.js index 1ccbb55c..5bc8bb8c 100644 --- a/source/UI/js/Video/AnnotationFolder.js +++ b/source/UI/js/Video/AnnotationFolder.js @@ -341,7 +341,21 @@ Ox.AnnotationFolder = function(options, self) { ['event', 'place'].indexOf(self.options.type) > -1 ? self.$outer : that.$content ); - + + [ + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', + 'b', 'backslash', 'closebracket', 'comma', 'dot', + 'equal', 'f', 'g', 'h', 'i', 'minus', 'n', 'o', + 'openbracket', 'p', 'shift_0', 'shift_equal', + 'shift_g', 'shift_i', 'shift_minus', 'shift_o', + 'slash', 'space' + ].forEach(function(key) { + key = 'key.' + key; + self.$annotations.bindEvent(key, function() { + that.triggerEvent(key); + }); + }); + self.loaded = false; setTimeout(function() { self.$annotations.options({ @@ -445,14 +459,6 @@ Ox.AnnotationFolder = function(options, self) { ) ); }); - if (self.options.type == 'entity') { - annotations = annotations.map(function(annotation) { - annotation.value = '' - + annotation.value + ''; - return annotation; - }); - } return annotations; } @@ -723,9 +729,13 @@ Ox.AnnotationFolder = function(options, self) { }); self.options.selected = item.id; } - if (self.options.type == 'entity' && Ox.isEmpty(data)) { - // did not match any existing entity - self.$annotations.updateItem(''); + if (self.options.type == 'entity') { + // data.value is missing if input did not match any existing entity + if (data.value) { + self.$annotations.updateItem(data.value); + } else { + that.removeItem(); + } } if (self.$widget) { // update may have made the item match, diff --git a/source/UI/js/Video/AnnotationPanel.js b/source/UI/js/Video/AnnotationPanel.js index 13f99f99..0c6f1794 100644 --- a/source/UI/js/Video/AnnotationPanel.js +++ b/source/UI/js/Video/AnnotationPanel.js @@ -406,7 +406,8 @@ Ox.AnnotationPanel = function(options, self) { layer.type == 'event' ? 'calendar' : 'map' ), data); } - }); + }) + .appendTo(self.$folders); [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'b', 'backslash', 'closebracket', 'comma', 'dot', @@ -415,12 +416,11 @@ Ox.AnnotationPanel = function(options, self) { 'shift_g', 'shift_i', 'shift_minus', 'shift_o', 'slash', 'space' ].forEach(function(key) { - key = 'key_' + key; + key = 'key.' + key; self.$folder[index].bindEvent(key, function() { that.triggerEvent(key); }); }); - self.$folder[index].appendTo(self.$folders); } function renderFolders() { diff --git a/source/UI/js/Video/VideoAnnotationPanel.js b/source/UI/js/Video/VideoAnnotationPanel.js index e5b5d2cb..ab51c81b 100644 --- a/source/UI/js/Video/VideoAnnotationPanel.js +++ b/source/UI/js/Video/VideoAnnotationPanel.js @@ -911,7 +911,7 @@ Ox.VideoAnnotationPanel = function(options, self) { 'shift_g', 'shift_i', 'shift_minus', 'shift_o', 'slash', 'space' ].forEach(function(key) { - key = 'key_' + key; + key = 'key.' + key; self.$annotationPanel.bindEvent(key, function() { that.triggerEvent(key); });