add option to find selected annotation in _this_ video; make sure focus returns after hiding menus

This commit is contained in:
rlx 2012-02-16 12:32:52 +00:00
parent 2bd8c8d13f
commit 73bd672b15
3 changed files with 50 additions and 18 deletions

View file

@ -578,6 +578,11 @@ Ox.AnnotationFolder = function(options, self) {
return that; return that;
}; };
that.gainFocus = function() {
self.$annotations.gainFocus();
return that;
};
that.removeItem = function() { that.removeItem = function() {
self.$annotations.removeItem(); self.$annotations.removeItem();
}; };

View file

@ -106,8 +106,11 @@ Ox.AnnotationPanel = function(options, self) {
}); });
that.triggerEvent('annotations' + data.id, set); 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); .appendTo(self.$menubar);
@ -257,7 +260,7 @@ Ox.AnnotationPanel = function(options, self) {
function renderEditMenu() { function renderEditMenu() {
Ox.print('RENDER EDIT MENU') Ox.print('RENDER EDIT MENU')
var annotation, findTitle, folder, var annotation, annotationTitle, folder,
isDefined, isEditable, isEvent, isEventOrPlace, isPlace, isString, isDefined, isEditable, isEvent, isEventOrPlace, isPlace, isString,
key, manageTitle, type, value key, manageTitle, type, value
if (self.options.selected) { if (self.options.selected) {
@ -273,13 +276,14 @@ Ox.AnnotationPanel = function(options, self) {
isString = type != 'text'; isString = type != 'text';
// fixme: absence of annotation[type] may be an error // fixme: absence of annotation[type] may be an error
isDefined = isEventOrPlace && !!annotation[type] && !!annotation[type].type; isDefined = isEventOrPlace && !!annotation[type] && !!annotation[type].type;
annotationTitle = folder.options('item') + ': "' + value + '"';
} }
findTitle = 'Find ' + (isString ? '"' + value + '"' : 'Annotation');
manageTitle = (isDefined ? 'Edit' : 'Define') + ' ' manageTitle = (isDefined ? 'Edit' : 'Define') + ' '
+ (isPlace ? 'Place' : isEvent ? 'Event' : 'Place or Event') + '...' + (isPlace ? 'Place' : isEvent ? 'Event' : 'Place or Event') + '...'
self.$editMenuButton && self.$editMenuButton.remove(); self.$editMenuButton && self.$editMenuButton.remove();
self.$editMenuButton = Ox.MenuButton({ self.$editMenuButton = Ox.MenuButton({
items: [ items: Ox.merge(
[
{id: 'deselect', title: 'Deselect Annotation', disabled: !self.options.selected || self.editing, keyboard: 'escape'}, {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: '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: 'delete', title: 'Delete Annotation', disabled: !self.options.selected || !isEditable, keyboard: 'delete'},
@ -287,10 +291,18 @@ Ox.AnnotationPanel = function(options, self) {
{id: 'insert', title: 'Insert...', disabled: isString || !self.editing}, {id: 'insert', title: 'Insert...', disabled: isString || !self.editing},
{id: 'undo', title: 'Undo Changes', disabled: !self.editing, keyboard: 'escape'}, {id: 'undo', title: 'Undo Changes', disabled: !self.editing, keyboard: 'escape'},
{id: 'save', title: 'Save Changes', disabled: !self.editing, keyboard: isString ? 'return' : 'shift return'}, {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}, {id: 'manage', title: manageTitle, disabled: !self.options.selected || !isEventOrPlace},
{id: 'find', title: findTitle, disabled: !self.options.selected || !isString} ] : [],
], 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, maxWidth: 256,
style: 'square', style: 'square',
title: 'edit', title: 'edit',
@ -307,7 +319,9 @@ Ox.AnnotationPanel = function(options, self) {
} else if (data.id == 'edit') { } else if (data.id == 'edit') {
getFolder(self.options.selected).editItem(); getFolder(self.options.selected).editItem();
} else if (data.id == 'find') { } 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') { } else if (data.id == 'manage') {
that.triggerEvent('define', { that.triggerEvent('define', {
id: self.options.selected, id: self.options.selected,
@ -318,6 +332,11 @@ Ox.AnnotationPanel = function(options, self) {
} else if (data.id == 'undo') { } else if (data.id == 'undo') {
// ... // ...
} }
},
hide: function() {
self.options.selected
? getFolder(self.options.selected).gainFocus()
: that.triggerEvent('focus');
} }
}) })
.appendTo(self.$menubar); .appendTo(self.$menubar);

View file

@ -484,6 +484,9 @@ Ox.VideoEditor = function(options, self) {
} else if (id == 'size') { } else if (id == 'size') {
toggleSize(); toggleSize();
} }
},
hide: function() {
that.gainFocus();
} }
}) })
.appendTo(self.$menubar); .appendTo(self.$menubar);
@ -622,8 +625,13 @@ Ox.VideoEditor = function(options, self) {
setTimelineState(); setTimelineState();
}, },
find: function(data) { 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) { info: function(data) {
that.triggerEvent('info', data); that.triggerEvent('info', data);
}, },