various focus/selection fixes

This commit is contained in:
j 2012-01-27 23:58:44 +05:30
parent a7a3f167c9
commit ed4f7f0c2d
4 changed files with 15 additions and 9 deletions

View file

@ -45,7 +45,6 @@ Ox.Focus = (function() {
index > -1 && stack.splice(index, 1); index > -1 && stack.splice(index, 1);
stack.push(id); stack.push(id);
if (stack.length > 1) { if (stack.length > 1) {
Ox.print('...', Object.keys(Ox.UI.elements[stack[stack.length - 2]]))
Ox.UI.elements[stack[stack.length - 2]] Ox.UI.elements[stack[stack.length - 2]]
.removeClass('OxFocus') .removeClass('OxFocus')
.triggerEvent('losefocus') .triggerEvent('losefocus')

View file

@ -849,22 +849,22 @@ Ox.TextList = function(options, self) {
width: width width: width
}) })
.bind({ .bind({
blur: submit,
mousedown: function(e) { mousedown: function(e) {
// keep mousedown from reaching list // keep mousedown from reaching list
e.stopPropagation(); e.stopPropagation();
} },
}) })
.bindEvent({ .bindEvent({
blur: submit, blur: submit,
cancel: submit,
submit: submit
}) })
.appendTo($cell); .appendTo($cell);
//.focusInput(true); //.focusInput(true);
setTimeout($input.focusInput, 0); // fixme: strange setTimeout($input.focusInput, 0); // fixme: strange
function submit() { function submit() {
var value = $input.value(); var value = $input.value();
//$input.loseFocus().remove(); $input.remove();
// fixme: leaky, inputs remain in focus stack
$cell.removeClass('OxEdit') $cell.removeClass('OxEdit')
.css({ .css({
// account for padding // account for padding

View file

@ -140,7 +140,6 @@ Ox.AnnotationFolder = function(options, self) {
}) })
.bindEvent({ .bindEvent({
select: function(data) { select: function(data) {
Ox.print('SELECT >>> ', data)
if (!data.id && self.options.selected && Ox.getObjectById(self.options.items, self.options.selected).event) { if (!data.id && self.options.selected && Ox.getObjectById(self.options.items, self.options.selected).event) {
// only deselect annotation if the event deselect was not // only deselect annotation if the event deselect was not
// caused by switching to an annotation without event // caused by switching to an annotation without event
@ -246,6 +245,10 @@ Ox.AnnotationFolder = function(options, self) {
); );
self.options.selected && setTimeout(function() { 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}); selectAnnotation({id: self.options.selected});
}, 0); }, 0);
@ -435,6 +438,10 @@ Ox.AnnotationFolder = function(options, self) {
function toggleLayer() { function toggleLayer() {
self.options.collapsed = !self.options.collapsed; self.options.collapsed = !self.options.collapsed;
if (self.options.collapsed) {
self.editing && that.blurItem();
self.$annotations.loseFocus();
}
that.triggerEvent('togglelayer', {collapsed: self.options.collapsed}); that.triggerEvent('togglelayer', {collapsed: self.options.collapsed});
} }
@ -484,7 +491,6 @@ Ox.AnnotationFolder = function(options, self) {
self.editing = false; self.editing = false;
} }
if (value && self.options.collapsed) { if (value && self.options.collapsed) {
Ox.print('HELLO??')
self.$panel.options({collapsed: false}); self.$panel.options({collapsed: false});
} }
self.$annotations.options({selected: value}); self.$annotations.options({selected: value});
@ -514,6 +520,7 @@ Ox.AnnotationFolder = function(options, self) {
Ox.print('FOLDER ADD ITEM', item) Ox.print('FOLDER ADD ITEM', item)
var pos = 0; var pos = 0;
self.options.items.splice(pos, 0, item); self.options.items.splice(pos, 0, item);
self.$panel.options({collapsed: false});
self.$annotations self.$annotations
.addItem(pos, item) .addItem(pos, item)
.options({selected: item.id}) .options({selected: item.id})
@ -532,6 +539,7 @@ Ox.AnnotationFolder = function(options, self) {
that.editItem = function() { that.editItem = function() {
self.editing = true; self.editing = true;
self.$panel.options({collapsed: false});
self.$annotations.editItem(); self.$annotations.editItem();
return that; return that;
}; };

View file

@ -210,7 +210,6 @@ Ox.VideoEditor = function(options, self) {
// the following is needed to determine // the following is needed to determine
// how to handle annotation input blur // how to handle annotation input blur
if (self.editing) { if (self.editing) {
Ox.print('FOCUSED')
self.focused = true; self.focused = true;
setTimeout(function() { setTimeout(function() {
// annotation folder will gain focus on blur // annotation folder will gain focus on blur
@ -397,7 +396,7 @@ Ox.VideoEditor = function(options, self) {
{key: 'S', action: 'Select Current Annotation'}, {key: 'S', action: 'Select Current Annotation'},
{key: 'E', action: 'Edit Selected Annotation'}, {key: 'E', action: 'Edit Selected Annotation'},
{key: Ox.UI.symbols['return'], action: 'Submit'}, {key: Ox.UI.symbols['return'], action: 'Submit'},
{key: Ox.UI.symbols.escape, action: 'Cancel'}, {key: Ox.UI.symbols.escape, action: 'Cancel'}
].forEach(function(shortcut) { ].forEach(function(shortcut) {
self.$keyboardShortcuts.append( self.$keyboardShortcuts.append(
$('<div>').css({display: 'table-row'}) $('<div>').css({display: 'table-row'})