forked from 0x2620/oxjs
make annotations sortable
This commit is contained in:
parent
11d9b63dba
commit
43d04f242d
2 changed files with 22 additions and 18 deletions
|
|
@ -39,19 +39,7 @@ Ox.AnnotationPanel = function(options, self) {
|
|||
})
|
||||
.options(options || {});
|
||||
|
||||
self.sort = self.options.sort == 'duration' ? [
|
||||
{key: 'duration', operator: '-'},
|
||||
{key: 'position', operator: '+'},
|
||||
{key: 'value', operator: '+'}
|
||||
] : self.options.sort == 'position' ? [
|
||||
{key: 'position', operator: '+'},
|
||||
{key: 'duration', operator: '-'},
|
||||
{key: 'value', operator: '+'}
|
||||
] : [ // 'text'
|
||||
{key: 'value', operator: '+'},
|
||||
{key: 'position', operator: '+'},
|
||||
{key: 'duration', operator: '-'}
|
||||
];
|
||||
self.sort = getSort();
|
||||
|
||||
that.setElement(
|
||||
Ox.CollapsePanel({
|
||||
|
|
@ -132,6 +120,14 @@ Ox.AnnotationPanel = function(options, self) {
|
|||
});
|
||||
}
|
||||
|
||||
function getSort() {
|
||||
return ({
|
||||
duration: ['-duration', '+in', '+value'],
|
||||
position: ['+in', '-duration', '+value'],
|
||||
text: ['+value', '+in', '-duration']
|
||||
})[self.options.sort];
|
||||
}
|
||||
|
||||
function selectAnnotation(data) {
|
||||
var item = Ox.getObjectById(self.options.items, data.id);
|
||||
self.options.selected = item ? data.id : '';
|
||||
|
|
@ -156,9 +152,9 @@ Ox.AnnotationPanel = function(options, self) {
|
|||
|
||||
self.setOption = function(key, value) {
|
||||
if (['in', 'out'].indexOf(key) > -1 && self.editing) {
|
||||
var item = Ox.getObjectById(self.options.items, self.options.selected);
|
||||
items[key] = value;
|
||||
items.duration = self.options.out - self.options['in'];
|
||||
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') {
|
||||
//fixme: array editable should support item updates while editing
|
||||
|
|
@ -180,7 +176,8 @@ Ox.AnnotationPanel = function(options, self) {
|
|||
} else if (key == 'selected') {
|
||||
self.$annotations.options('selected', value);
|
||||
} else if (key == 'sort') {
|
||||
self.$annotations.options('sort', value);
|
||||
self.sort = getSort();
|
||||
self.$annotations.options('sort', self.sort);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue