From 73bd672b1571c0b43d610b42c214063953da53df Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Thu, 16 Feb 2012 12:32:52 +0000 Subject: [PATCH] add option to find selected annotation in _this_ video; make sure focus returns after hiding menus --- source/Ox.UI/js/Video/Ox.AnnotationFolder.js | 5 ++ source/Ox.UI/js/Video/Ox.AnnotationPanel.js | 53 +++++++++++++------- source/Ox.UI/js/Video/Ox.VideoEditor.js | 10 +++- 3 files changed, 50 insertions(+), 18 deletions(-) diff --git a/source/Ox.UI/js/Video/Ox.AnnotationFolder.js b/source/Ox.UI/js/Video/Ox.AnnotationFolder.js index fa99a395..ac2c3c8e 100644 --- a/source/Ox.UI/js/Video/Ox.AnnotationFolder.js +++ b/source/Ox.UI/js/Video/Ox.AnnotationFolder.js @@ -578,6 +578,11 @@ Ox.AnnotationFolder = function(options, self) { return that; }; + that.gainFocus = function() { + self.$annotations.gainFocus(); + return that; + }; + that.removeItem = function() { self.$annotations.removeItem(); }; diff --git a/source/Ox.UI/js/Video/Ox.AnnotationPanel.js b/source/Ox.UI/js/Video/Ox.AnnotationPanel.js index 6851fa96..6d3d936d 100644 --- a/source/Ox.UI/js/Video/Ox.AnnotationPanel.js +++ b/source/Ox.UI/js/Video/Ox.AnnotationPanel.js @@ -106,8 +106,11 @@ Ox.AnnotationPanel = function(options, self) { }); that.triggerEvent('annotations' + data.id, set); } - // FIXME: this does not work - self.options.selected && getFolder(self.options.selected).gainFocus(); + }, + hide: function() { + self.options.selected + ? getFolder(self.options.selected).gainFocus() + : that.triggerEvent('focus'); } }) .appendTo(self.$menubar); @@ -257,7 +260,7 @@ Ox.AnnotationPanel = function(options, self) { function renderEditMenu() { Ox.print('RENDER EDIT MENU') - var annotation, findTitle, folder, + var annotation, annotationTitle, folder, isDefined, isEditable, isEvent, isEventOrPlace, isPlace, isString, key, manageTitle, type, value if (self.options.selected) { @@ -273,24 +276,33 @@ Ox.AnnotationPanel = function(options, self) { isString = type != 'text'; // fixme: absence of annotation[type] may be an error isDefined = isEventOrPlace && !!annotation[type] && !!annotation[type].type; + annotationTitle = folder.options('item') + ': "' + value + '"'; } - findTitle = 'Find ' + (isString ? '"' + value + '"' : 'Annotation'); manageTitle = (isDefined ? 'Edit' : 'Define') + ' ' + (isPlace ? 'Place' : isEvent ? 'Event' : 'Place or Event') + '...' self.$editMenuButton && self.$editMenuButton.remove(); self.$editMenuButton = Ox.MenuButton({ - items: [ - {id: 'deselect', title: 'Deselect Annotation', disabled: !self.options.selected || self.editing, keyboard: 'escape'}, - {id: 'edit', title: 'Edit Annotation', disabled: !self.options.selected || !isEditable || self.editing, keyboard: 'return'}, - {id: 'delete', title: 'Delete Annotation', disabled: !self.options.selected || !isEditable, keyboard: 'delete'}, - {}, - {id: 'insert', title: 'Insert...', disabled: isString || !self.editing}, - {id: 'undo', title: 'Undo Changes', disabled: !self.editing, keyboard: 'escape'}, - {id: 'save', title: 'Save Changes', disabled: !self.editing, keyboard: isString ? 'return' : 'shift return'}, - {}, - {id: 'manage', title: manageTitle, disabled: !self.options.selected || !isEventOrPlace}, - {id: 'find', title: findTitle, disabled: !self.options.selected || !isString} - ], + items: Ox.merge( + [ + {id: 'deselect', title: 'Deselect Annotation', disabled: !self.options.selected || self.editing, keyboard: 'escape'}, + {id: 'edit', title: 'Edit Annotation', disabled: !self.options.selected || !isEditable || self.editing, keyboard: 'return'}, + {id: 'delete', title: 'Delete Annotation', disabled: !self.options.selected || !isEditable, keyboard: 'delete'}, + {}, + {id: 'insert', title: 'Insert...', disabled: isString || !self.editing}, + {id: 'undo', title: 'Undo Changes', disabled: !self.editing, keyboard: 'escape'}, + {id: 'save', title: 'Save Changes', disabled: !self.editing, keyboard: isString ? 'return' : 'shift return'}, + ], + pandora.site.map == 'manual' ? [ + {}, + {id: 'manage', title: manageTitle, disabled: !self.options.selected || !isEventOrPlace}, + ] : [], + isString ? [ + {}, + {id: 'annotation', title: annotationTitle, disabled: true}, + {id: 'find', title: 'Find in This ' + pandora.site.itemName.singular}, + {id: 'findannotations', title: 'Find in All ' + pandora.site.itemName.plural} + ] : [] + ), maxWidth: 256, style: 'square', title: 'edit', @@ -307,7 +319,9 @@ Ox.AnnotationPanel = function(options, self) { } else if (data.id == 'edit') { getFolder(self.options.selected).editItem(); } else if (data.id == 'find') { - that.triggerEvent('find', {key: key, value: value}); + that.triggerEvent('find', {value: value}); + } else if (data.id == 'findannotations') { + that.triggerEvent('findannotations', {key: key, value: value}); } else if (data.id == 'manage') { that.triggerEvent('define', { id: self.options.selected, @@ -318,6 +332,11 @@ Ox.AnnotationPanel = function(options, self) { } else if (data.id == 'undo') { // ... } + }, + hide: function() { + self.options.selected + ? getFolder(self.options.selected).gainFocus() + : that.triggerEvent('focus'); } }) .appendTo(self.$menubar); diff --git a/source/Ox.UI/js/Video/Ox.VideoEditor.js b/source/Ox.UI/js/Video/Ox.VideoEditor.js index e458b3d9..2efa597b 100644 --- a/source/Ox.UI/js/Video/Ox.VideoEditor.js +++ b/source/Ox.UI/js/Video/Ox.VideoEditor.js @@ -484,6 +484,9 @@ Ox.VideoEditor = function(options, self) { } else if (id == 'size') { toggleSize(); } + }, + hide: function() { + that.gainFocus(); } }) .appendTo(self.$menubar); @@ -622,8 +625,13 @@ Ox.VideoEditor = function(options, self) { setTimelineState(); }, find: function(data) { - that.triggerEvent('findannotation', data); + self.$findInput.options({value: data.value}); + submitFindInput(data.value, true); }, + findannotations: function(data) { + that.triggerEvent('findannotations', data); + }, + focus: that.gainFocus, info: function(data) { that.triggerEvent('info', data); },