From ed4f7f0c2de11a0417fc5f013ebc8a6f107bb746 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Fri, 27 Jan 2012 23:58:44 +0530 Subject: [PATCH] various focus/selection fixes --- source/Ox.UI/js/Core/Ox.Focus.js | 1 - source/Ox.UI/js/List/Ox.TextList.js | 8 ++++---- source/Ox.UI/js/Video/Ox.AnnotationFolder.js | 12 ++++++++++-- source/Ox.UI/js/Video/Ox.VideoEditor.js | 3 +-- 4 files changed, 15 insertions(+), 9 deletions(-) diff --git a/source/Ox.UI/js/Core/Ox.Focus.js b/source/Ox.UI/js/Core/Ox.Focus.js index e3c385c5..f23b7a9a 100644 --- a/source/Ox.UI/js/Core/Ox.Focus.js +++ b/source/Ox.UI/js/Core/Ox.Focus.js @@ -45,7 +45,6 @@ Ox.Focus = (function() { index > -1 && stack.splice(index, 1); stack.push(id); if (stack.length > 1) { - Ox.print('...', Object.keys(Ox.UI.elements[stack[stack.length - 2]])) Ox.UI.elements[stack[stack.length - 2]] .removeClass('OxFocus') .triggerEvent('losefocus') diff --git a/source/Ox.UI/js/List/Ox.TextList.js b/source/Ox.UI/js/List/Ox.TextList.js index f7dcf2e4..0b6164ef 100644 --- a/source/Ox.UI/js/List/Ox.TextList.js +++ b/source/Ox.UI/js/List/Ox.TextList.js @@ -849,22 +849,22 @@ Ox.TextList = function(options, self) { width: width }) .bind({ - blur: submit, mousedown: function(e) { // keep mousedown from reaching list e.stopPropagation(); - } + }, }) .bindEvent({ blur: submit, + cancel: submit, + submit: submit }) .appendTo($cell); //.focusInput(true); setTimeout($input.focusInput, 0); // fixme: strange function submit() { var value = $input.value(); - //$input.loseFocus().remove(); - // fixme: leaky, inputs remain in focus stack + $input.remove(); $cell.removeClass('OxEdit') .css({ // account for padding diff --git a/source/Ox.UI/js/Video/Ox.AnnotationFolder.js b/source/Ox.UI/js/Video/Ox.AnnotationFolder.js index 2ce48fa1..71850c3c 100644 --- a/source/Ox.UI/js/Video/Ox.AnnotationFolder.js +++ b/source/Ox.UI/js/Video/Ox.AnnotationFolder.js @@ -140,7 +140,6 @@ Ox.AnnotationFolder = function(options, self) { }) .bindEvent({ select: function(data) { - Ox.print('SELECT >>> ', data) if (!data.id && self.options.selected && Ox.getObjectById(self.options.items, self.options.selected).event) { // only deselect annotation if the event deselect was not // caused by switching to an annotation without event @@ -246,6 +245,10 @@ Ox.AnnotationFolder = function(options, self) { ); self.options.selected && setTimeout(function() { + // need timeout in order to trigger events + if (self.options.collapsed) { + self.$panel.options({collapsed: false}); + } selectAnnotation({id: self.options.selected}); }, 0); @@ -435,6 +438,10 @@ Ox.AnnotationFolder = function(options, self) { function toggleLayer() { self.options.collapsed = !self.options.collapsed; + if (self.options.collapsed) { + self.editing && that.blurItem(); + self.$annotations.loseFocus(); + } that.triggerEvent('togglelayer', {collapsed: self.options.collapsed}); } @@ -484,7 +491,6 @@ Ox.AnnotationFolder = function(options, self) { self.editing = false; } if (value && self.options.collapsed) { - Ox.print('HELLO??') self.$panel.options({collapsed: false}); } self.$annotations.options({selected: value}); @@ -514,6 +520,7 @@ Ox.AnnotationFolder = function(options, self) { Ox.print('FOLDER ADD ITEM', item) var pos = 0; self.options.items.splice(pos, 0, item); + self.$panel.options({collapsed: false}); self.$annotations .addItem(pos, item) .options({selected: item.id}) @@ -532,6 +539,7 @@ Ox.AnnotationFolder = function(options, self) { that.editItem = function() { self.editing = true; + self.$panel.options({collapsed: false}); self.$annotations.editItem(); return that; }; diff --git a/source/Ox.UI/js/Video/Ox.VideoEditor.js b/source/Ox.UI/js/Video/Ox.VideoEditor.js index eda749b7..68b8a246 100644 --- a/source/Ox.UI/js/Video/Ox.VideoEditor.js +++ b/source/Ox.UI/js/Video/Ox.VideoEditor.js @@ -210,7 +210,6 @@ Ox.VideoEditor = function(options, self) { // the following is needed to determine // how to handle annotation input blur if (self.editing) { - Ox.print('FOCUSED') self.focused = true; setTimeout(function() { // annotation folder will gain focus on blur @@ -397,7 +396,7 @@ Ox.VideoEditor = function(options, self) { {key: 'S', action: 'Select Current Annotation'}, {key: 'E', action: 'Edit Selected Annotation'}, {key: Ox.UI.symbols['return'], action: 'Submit'}, - {key: Ox.UI.symbols.escape, action: 'Cancel'}, + {key: Ox.UI.symbols.escape, action: 'Cancel'} ].forEach(function(shortcut) { self.$keyboardShortcuts.append( $('
').css({display: 'table-row'})