update item by reference not index

This commit is contained in:
j 2012-01-24 15:29:29 +05:30
parent 129b8154fb
commit 5f849abee3

View file

@ -336,7 +336,7 @@ Ox.AnnotationFolder = function(options, self) {
if (index == -1) {
places.push(Ox.extend({
annotationIds: [item.id]
}, item.place))
}, item.place));
} else {
places[index].annotationIds.push(item.id);
}
@ -449,9 +449,9 @@ Ox.AnnotationFolder = function(options, self) {
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'];
var item = Ox.getObjectById(self.options.items, self.options.selected);
item[key] = value;
item.duration = self.options.out - self.options['in'];
self.points = getPoints();
}
if (key == 'in') {
@ -534,9 +534,11 @@ Ox.AnnotationFolder = function(options, self) {
};
*/
that.updateItem = function(item) {
var index = Ox.getIndexById(self.options.items, item.id);
self.options.items[index] = item;
that.updateItem = function(data) {
var item = Ox.getObjectById(self.options.items, data.id);
Ox.forEach(data, function(value, key) {
item[key] = value;
});
updateAnnotations();
if (self.widget && item[self.options.type]) {
// if updating has made the item match
@ -544,7 +546,7 @@ Ox.AnnotationFolder = function(options, self) {
self.$widget.options({selected: item[self.options.type].id});
}
return that;
}
};
return that;