From 5f849abee33008c10051ff77b072d7b69a0bf586 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 24 Jan 2012 15:29:29 +0530 Subject: [PATCH] update item by reference not index --- source/Ox.UI/js/Video/Ox.AnnotationFolder.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/source/Ox.UI/js/Video/Ox.AnnotationFolder.js b/source/Ox.UI/js/Video/Ox.AnnotationFolder.js index 6db524a9..ca1245b6 100644 --- a/source/Ox.UI/js/Video/Ox.AnnotationFolder.js +++ b/source/Ox.UI/js/Video/Ox.AnnotationFolder.js @@ -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;