pass sort and item updates

This commit is contained in:
j 2013-07-14 14:56:41 +00:00
parent d7786e79a5
commit cae1875f44
2 changed files with 36 additions and 10 deletions

View file

@ -19,7 +19,18 @@ Ox.ClipPanel = function(options, self) {
.options(options || {}) .options(options || {})
.update({ .update({
clips: function() { clips: function() {
self.$list.options({items: self.options.clips}); self.$list.options({
items: Ox.clone(self.options.clips),
sort: self.options.sort,
sortable: isSortable()
});
},
sort: function() {
updateSortElement();
self.$list.options({
sort: self.options.sort,
sortable: isSortable(),
});
} }
}); });
@ -74,12 +85,14 @@ Ox.ClipPanel = function(options, self) {
}) })
.bindEvent({ .bindEvent({
change: function(data) { change: function(data) {
that.triggerEvent('sort', [{ self.options.sort = [{
key: data.value, key: data.value,
operator: Ox.getObjectById( operator: Ox.getObjectById(
self.options.sortOptions, data.value self.options.sortOptions, data.value
).operator ).operator
}]); }];
updateSortElement();
that.triggerEvent('sort', self.options.sort);
} }
}); });
@ -91,10 +104,12 @@ Ox.ClipPanel = function(options, self) {
}) })
.bindEvent({ .bindEvent({
click: function() { click: function() {
that.triggerEvent('sort', [{ self.options.sort = [{
key: self.options.sort[0].key, key: self.options.sort[0].key,
operator: self.options.sort[0].operator == '+' ? '-' : '+' operator: self.options.sort[0].operator == '+' ? '-' : '+'
}]); }];
updateSortElement();
that.triggerEvent('sort', self.options.sort);
} }
}); });
@ -220,7 +235,7 @@ Ox.ClipPanel = function(options, self) {
columnsRemovable: true, columnsRemovable: true,
columnsResizable: true, columnsResizable: true,
columnsVisible: true, columnsVisible: true,
items: self.options.clips, items: Ox.clone(self.options.clips),
scrollbarVisible: true, scrollbarVisible: true,
sort: self.options.sort, sort: self.options.sort,
sortable: isSortable(), sortable: isSortable(),
@ -253,9 +268,10 @@ Ox.ClipPanel = function(options, self) {
that.triggerEvent('select', data); that.triggerEvent('select', data);
}, },
sort: function(data) { sort: function(data) {
self.options.sort = self.$list.options('sort'); self.options.sort = [data];
updateSortElement();
self.$list.options({sortable: isSortable()}); self.$list.options({sortable: isSortable()});
that.triggerEvent('sort', [data]); that.triggerEvent('sort', self.options.sort);
}, },
submit: function(data) { submit: function(data) {
data.value = Ox.parseDuration(data.value); data.value = Ox.parseDuration(data.value);
@ -278,7 +294,13 @@ Ox.ClipPanel = function(options, self) {
} }
function updateSortElement() { function updateSortElement() {
self.$sortSelect.options({
value: self.options.sort[0].key,
});
self.$orderButton.options({
title: getButtonTitle(),
tooltip: getButtonTooltip(),
});
} }
that.updateItem = function(id, data) { that.updateItem = function(id, data) {

View file

@ -43,7 +43,10 @@ Ox.VideoEditPanel = function(options, self) {
.options(options || {}) .options(options || {})
.update({ .update({
clips: function() { clips: function() {
self.$clipPanel.options({clips: Ox.clone(self.options.clips)}); self.$clipPanel.options({
clips: Ox.clone(self.options.clips),
sort: self.options.clipSort
});
}, },
duration: function() { duration: function() {
self.$timeline && self.$timeline.replaceWith( self.$timeline && self.$timeline.replaceWith(
@ -252,6 +255,7 @@ Ox.VideoEditPanel = function(options, self) {
that.triggerEvent('select', data); that.triggerEvent('select', data);
}, },
sort: function(data) { sort: function(data) {
self.options.clipSort = data;
that.triggerEvent('sort', data); that.triggerEvent('sort', data);
}, },
toggle: toggleClips, toggle: toggleClips,