From a66c7c9bdd642287950442cfa100f05ac9233c98 Mon Sep 17 00:00:00 2001 From: rlx <0x0073@0x2620.org> Date: Sat, 18 Feb 2012 09:56:58 +0000 Subject: [PATCH] various fixes related to adding place annotations --- source/Ox.UI/js/List/Ox.IconItem.js | 1 - source/Ox.UI/js/Video/Ox.AnnotationFolder.js | 66 ++++++++++++++------ 2 files changed, 46 insertions(+), 21 deletions(-) diff --git a/source/Ox.UI/js/List/Ox.IconItem.js b/source/Ox.UI/js/List/Ox.IconItem.js index c0daa63e..a27d35f1 100644 --- a/source/Ox.UI/js/List/Ox.IconItem.js +++ b/source/Ox.UI/js/List/Ox.IconItem.js @@ -55,7 +55,6 @@ Ox.IconItem = function(options, self) { }); self.title = formatText(self.options.title, self.lines - 1 - self.infoIsObject, self.lineLength); - Ox.print('ST::::', self.title) if (!self.infoIsObject) { self.info = formatText(self.options.info, 5 - self.title.split('
').length, self.lineLength); } else { diff --git a/source/Ox.UI/js/Video/Ox.AnnotationFolder.js b/source/Ox.UI/js/Video/Ox.AnnotationFolder.js index f18fc7fa..bfe0051a 100644 --- a/source/Ox.UI/js/Video/Ox.AnnotationFolder.js +++ b/source/Ox.UI/js/Video/Ox.AnnotationFolder.js @@ -333,9 +333,7 @@ Ox.AnnotationFolder = function(options, self) { self.options.users == 'all' || self.options.users.indexOf(item.user) > -1 ) - ) ? Ox.extend({ - date: Ox.formatDate(item.modified.substr(0, 10), '%B %e, %Y') - }, item) : null; + ) ? item : null; }); } @@ -401,14 +399,15 @@ Ox.AnnotationFolder = function(options, self) { item = Ox.getObjectById(self.options.items, data.id); if (isDefined(item)) { if (self.options.type == 'event') { - self.$calendar.removeEvent(data.id); + self.$calendar.options({selected: ''}) + .options({events: getEvents()}); } else { - self.$map.removePlace(data.id) - .options({selected: ''}) // deselect resultPlace - .triggerEvent('key_escape'); // remove resultPlace + self.$map.options({selected: ''}) + .options({places: getPlaces()}); } } } + showWarnings(); that.triggerEvent('remove', {id: data.id}); } @@ -448,6 +447,8 @@ Ox.AnnotationFolder = function(options, self) { ) ) { $element.addClass('OxWarning'); + } else { + $element.removeClass('OxWarning'); } }); } @@ -457,7 +458,6 @@ Ox.AnnotationFolder = function(options, self) { var item = Ox.getObjectById(self.options.items, data.id); item.value = data.value; self.editing = false; - //self.$annotations.options({items: self.options.items}); self.options.sort == 'text' && self.$annotations.reloadItems(); that.triggerEvent('submit', item); } @@ -537,7 +537,6 @@ Ox.AnnotationFolder = function(options, self) { } else if (key == 'users') { updateAnnotations(); } else if (key == 'width') { - Ox.print('RESIZE!!!!') if (self.widget) { self.$outer.options({width: self.options.width}); self.$inner.options({width: self.options.width}); @@ -553,7 +552,6 @@ Ox.AnnotationFolder = function(options, self) { addItem addItem @*/ that.addItem = function(item) { - Ox.Log('AF', 'FOLDER ADD ITEM', item) var pos = 0; self.options.items.splice(pos, 0, item); self.$panel.options({collapsed: false}); @@ -616,22 +614,50 @@ Ox.AnnotationFolder = function(options, self) { */ that.updateItem = function(id, data) { + Ox.print('-- UPDATE ITEM', id, data); var item = Ox.getObjectById(self.options.items, id); Ox.forEach(data, function(value, key) { item[key] = value; }); - self.options.selected = item.id; - self.$annotations.options({selected: self.options.selected}); - if (self.widget) { - self.options.type == 'event' - ? self.$calendar.options({events: getEvents()}) - : self.$map.options({places: getPlaces()}); - // if updating has made the item match - // an event or place, then select it - isDefined(item) && self.$widget.options({ - selected: item[self.options.type].id + if (id != item.id) { + self.$annotations.find('.OxEditableElement').each(function() { + var $element = $(this); + if ($element.data('id') == self.options.selected) { + $element.data({id: item.id}); + } }); + self.options.selected = item.id; } + if (self.$widget) { + // update may have made the item match, + // or no longer match, an event or place + if (isDefined(item)) { + self.$widget.options( + self.options.type == 'event' + ? {events: getEvents()} + : {places: getPlaces()} + ) + .options({ + selected: item[self.options.type].id + }); + self.$widget[ + self.options.type == 'event' ? 'panToEvent' : 'panToPlace' + ](); + } else { + self.$widget.options({ + selected: '' + }) + .options( + self.options.type == 'event' + ? {events: getEvents()} + : {places: getPlaces()} + ); + } + } + if (id != item.id) { + self.$annotations.options({selected: self.options.selected}); + } + showWarnings(); return that; };