blur editing
This commit is contained in:
parent
b4139a7388
commit
ba9423462f
8 changed files with 180 additions and 91 deletions
|
|
@ -84,6 +84,7 @@ Ox.AnnotationPanel = function(options, self) {
|
|||
items: getAnnotations(),
|
||||
selected: self.options.selected,
|
||||
sort: self.sort,
|
||||
submitOnBlur: false,
|
||||
width: self.options.width,
|
||||
type: self.options.type == 'text' ? 'textarea' : 'input'
|
||||
})
|
||||
|
|
@ -93,29 +94,27 @@ Ox.AnnotationPanel = function(options, self) {
|
|||
value: data.value || ''
|
||||
});
|
||||
},
|
||||
blur: function() {
|
||||
that.triggerEvent('blur');
|
||||
},
|
||||
'delete': function(data) {
|
||||
that.triggerEvent('remove', {id: data.id});
|
||||
},
|
||||
edit: function(data) {
|
||||
that.triggerEvent('edit', data);
|
||||
edit: function() {
|
||||
self.editing = true;
|
||||
that.triggerEvent('edit');
|
||||
},
|
||||
select: selectAnnotation,
|
||||
submit: editAnnotation
|
||||
submit: submitAnnotation
|
||||
});
|
||||
}
|
||||
self.$annotations.appendTo(that.$content);
|
||||
|
||||
Ox.print('SOS', self.options.selected);
|
||||
//Ox.print('SOS', self.options.selected);
|
||||
self.options.selected && setTimeout(function() {
|
||||
selectAnnotation({id: self.options.selected});
|
||||
}, 0);
|
||||
|
||||
function editAnnotation(data) {
|
||||
var item = Ox.getObjectById(self.options.items, data.id);
|
||||
item.value = data.value;
|
||||
that.triggerEvent('submit', item);
|
||||
}
|
||||
|
||||
function getAnnotations() {
|
||||
return self.options.items.filter(function(item) {
|
||||
return self.options.range == 'all' || (
|
||||
|
|
@ -126,12 +125,13 @@ Ox.AnnotationPanel = function(options, self) {
|
|||
self.options.range == 'position'
|
||||
&& item['in'] <= self.options.position
|
||||
&& item.out >= self.options.position
|
||||
)
|
||||
) || self.editing && item.id == self.options.selected
|
||||
});
|
||||
}
|
||||
|
||||
function selectAnnotation(data) {
|
||||
var item = Ox.getObjectById(self.options.items, data.id);
|
||||
self.options.selected = item ? data.id : '';
|
||||
that.triggerEvent('select', Ox.extend({
|
||||
id: data.id
|
||||
}, item ? {
|
||||
|
|
@ -141,27 +141,42 @@ Ox.AnnotationPanel = function(options, self) {
|
|||
} : {}));
|
||||
}
|
||||
|
||||
function submitAnnotation(data) {
|
||||
var item = Ox.getObjectById(self.options.items, data.id);
|
||||
item.value = data.value;
|
||||
self.editing = false;
|
||||
that.triggerEvent('submit', item);
|
||||
}
|
||||
|
||||
function togglePanel() {
|
||||
|
||||
}
|
||||
|
||||
self.setOption = function(key, value) {
|
||||
if (['in', 'out'].indexOf(key) > -1 && self.editing) {
|
||||
var index = Ox.getIndexById(self.options.items, self.options.selected);
|
||||
self.options.items[index][key] = value;
|
||||
self.options.items[index].duration = self.options.out - self.options['in'];
|
||||
}
|
||||
if (key == 'in') {
|
||||
self.options.range == 'selection' && self.$annotations.options({
|
||||
//fixme: array editable should support item updates while editing
|
||||
self.editing || self.options.range == 'selection' && self.$annotations.options({
|
||||
items: getAnnotations()
|
||||
});
|
||||
} else if (key == 'out') {
|
||||
self.options.range == 'selection' && self.$annotations.options({
|
||||
self.editing || self.options.range == 'selection' && self.$annotations.options({
|
||||
items: getAnnotations()
|
||||
});
|
||||
} else if (key == 'position') {
|
||||
self.options.range == 'position' && self.$annotations.options({
|
||||
self.editing || self.options.range == 'position' && self.$annotations.options({
|
||||
items: getAnnotations()
|
||||
});
|
||||
} else if (key == 'range') {
|
||||
self.$annotations.options({
|
||||
items: getAnnotations()
|
||||
});
|
||||
} else if (key == 'selected') {
|
||||
self.$annotations.options('selected', value);
|
||||
} else if (key == 'sort') {
|
||||
self.$annotations.options('sort', value);
|
||||
}
|
||||
|
|
@ -174,14 +189,11 @@ Ox.AnnotationPanel = function(options, self) {
|
|||
var pos = 0;
|
||||
self.options.items.splice(pos, 0, item);
|
||||
self.$annotations.addItem(pos, item);
|
||||
self.$annotations.editItem(pos);
|
||||
self.$annotations.editItem(item.id);
|
||||
};
|
||||
|
||||
/*@
|
||||
deselectItems <f> deselectItems
|
||||
@*/
|
||||
that.deselectItems = function() {
|
||||
self.$annotations.options('selected', '');
|
||||
that.blurItem = function() {
|
||||
self.$annotations.blurItem();
|
||||
};
|
||||
|
||||
/*@
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue