diff --git a/source/UI/js/Form/ArrayEditable.js b/source/UI/js/Form/ArrayEditable.js index ea890b1e..f361569d 100644 --- a/source/UI/js/Form/ArrayEditable.js +++ b/source/UI/js/Form/ArrayEditable.js @@ -220,10 +220,11 @@ Ox.ArrayEditable = function(options, self) { }, 250); }, cancel: function(data) { + var id = $(this).data('id'); self.editing = false; that.gainFocus(); data.value === '' - ? submitItem(i, '') + ? submitItem(id, '') : that.triggerEvent('blur', data); }, change: function(data) { @@ -247,9 +248,10 @@ Ox.ArrayEditable = function(options, self) { that.triggerEvent('open'); }, submit: function(data) { + var id = $(this).data('id'); self.editing = false; that.gainFocus(); - submitItem(i, data.value); + submitItem(id, data.value); } }) .appendTo(that); @@ -364,8 +366,9 @@ Ox.ArrayEditable = function(options, self) { } } - function submitItem(position, value) { - var item = self.options.items[position]; + function submitItem(id, value) { + var item = Ox.getObjectById(self.options.items, id); + Ox.Log('AE', 'submitItem', id, item) if (value === '') { deleteItem(item.id); } else { diff --git a/source/UI/js/Video/AnnotationFolder.js b/source/UI/js/Video/AnnotationFolder.js index c392ce8d..f6fb3127 100644 --- a/source/UI/js/Video/AnnotationFolder.js +++ b/source/UI/js/Video/AnnotationFolder.js @@ -71,8 +71,10 @@ Ox.AnnotationFolder = function(options, self) { } if (['in', 'out'].indexOf(key) > -1 && self.editing) { var item = Ox.getObjectById(self.options.items, self.options.selected); - item[key] = value; - item.duration = self.options.out - self.options['in']; + if (item) { + item[key] = value; + item.duration = self.options.out - self.options['in']; + } self.points = getPoints(); } if (key == 'in') { @@ -620,10 +622,12 @@ Ox.AnnotationFolder = function(options, self) { function submitAnnotation(data) { var item = Ox.getObjectById(self.options.items, data.id); - item.value = data.value; - self.editing = false; - self.options.sort == 'text' && self.$annotations.reloadItems(); - that.triggerEvent('submit', item); + if (item) { + item.value = data.value; + self.editing = false; + self.options.sort == 'text' && self.$annotations.reloadItems(); + that.triggerEvent('submit', item); + } } function toggleLayer() { @@ -749,6 +753,7 @@ Ox.AnnotationFolder = function(options, self) { (id, data) -> update item @*/ that.updateItem = function(id, data) { + Ox.Log('AF', 'updateItem', id, data) var item = Ox.getObjectById(self.options.items, id); Ox.forEach(data, function(value, key) { item[key] = value; @@ -760,7 +765,7 @@ Ox.AnnotationFolder = function(options, self) { if (id != item.id) { self.$annotations.find('.OxEditableElement').each(function() { var $element = $(this); - if ($element.data('id') == self.options.selected) { + if ($element.data('id') == id) { $element.data({id: item.id}); } }); diff --git a/source/UI/js/Video/AnnotationPanel.js b/source/UI/js/Video/AnnotationPanel.js index cfe75a03..83036b77 100644 --- a/source/UI/js/Video/AnnotationPanel.js +++ b/source/UI/js/Video/AnnotationPanel.js @@ -737,7 +737,10 @@ Ox.AnnotationPanel = function(options, self) { @*/ that.blurItem = function() { self.editing = false; - getFolder(self.options.selected).blurItem(); + var $folder = getFolder(self.options.selected) + if ($folder) { + $folder.blurItem(); + } renderEditMenu(); return that; };