various fixes related to adding place annotations

This commit is contained in:
rlx 2012-02-18 09:56:58 +00:00
parent bbdbaf86da
commit a66c7c9bdd
2 changed files with 46 additions and 21 deletions

View file

@ -55,7 +55,6 @@ Ox.IconItem = function(options, self) {
}); });
self.title = formatText(self.options.title, self.lines - 1 - self.infoIsObject, self.lineLength); self.title = formatText(self.options.title, self.lines - 1 - self.infoIsObject, self.lineLength);
Ox.print('ST::::', self.title)
if (!self.infoIsObject) { if (!self.infoIsObject) {
self.info = formatText(self.options.info, 5 - self.title.split('<br/>').length, self.lineLength); self.info = formatText(self.options.info, 5 - self.title.split('<br/>').length, self.lineLength);
} else { } else {

View file

@ -333,9 +333,7 @@ Ox.AnnotationFolder = function(options, self) {
self.options.users == 'all' self.options.users == 'all'
|| self.options.users.indexOf(item.user) > -1 || self.options.users.indexOf(item.user) > -1
) )
) ? Ox.extend({ ) ? item : null;
date: Ox.formatDate(item.modified.substr(0, 10), '%B %e, %Y')
}, item) : null;
}); });
} }
@ -401,14 +399,15 @@ Ox.AnnotationFolder = function(options, self) {
item = Ox.getObjectById(self.options.items, data.id); item = Ox.getObjectById(self.options.items, data.id);
if (isDefined(item)) { if (isDefined(item)) {
if (self.options.type == 'event') { if (self.options.type == 'event') {
self.$calendar.removeEvent(data.id); self.$calendar.options({selected: ''})
.options({events: getEvents()});
} else { } else {
self.$map.removePlace(data.id) self.$map.options({selected: ''})
.options({selected: ''}) // deselect resultPlace .options({places: getPlaces()});
.triggerEvent('key_escape'); // remove resultPlace
} }
} }
} }
showWarnings();
that.triggerEvent('remove', {id: data.id}); that.triggerEvent('remove', {id: data.id});
} }
@ -448,6 +447,8 @@ Ox.AnnotationFolder = function(options, self) {
) )
) { ) {
$element.addClass('OxWarning'); $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); var item = Ox.getObjectById(self.options.items, data.id);
item.value = data.value; item.value = data.value;
self.editing = false; self.editing = false;
//self.$annotations.options({items: self.options.items});
self.options.sort == 'text' && self.$annotations.reloadItems(); self.options.sort == 'text' && self.$annotations.reloadItems();
that.triggerEvent('submit', item); that.triggerEvent('submit', item);
} }
@ -537,7 +537,6 @@ Ox.AnnotationFolder = function(options, self) {
} else if (key == 'users') { } else if (key == 'users') {
updateAnnotations(); updateAnnotations();
} else if (key == 'width') { } else if (key == 'width') {
Ox.print('RESIZE!!!!')
if (self.widget) { if (self.widget) {
self.$outer.options({width: self.options.width}); self.$outer.options({width: self.options.width});
self.$inner.options({width: self.options.width}); self.$inner.options({width: self.options.width});
@ -553,7 +552,6 @@ Ox.AnnotationFolder = function(options, self) {
addItem <f> addItem addItem <f> addItem
@*/ @*/
that.addItem = function(item) { that.addItem = function(item) {
Ox.Log('AF', 'FOLDER ADD ITEM', item)
var pos = 0; var pos = 0;
self.options.items.splice(pos, 0, item); self.options.items.splice(pos, 0, item);
self.$panel.options({collapsed: false}); self.$panel.options({collapsed: false});
@ -616,22 +614,50 @@ Ox.AnnotationFolder = function(options, self) {
*/ */
that.updateItem = function(id, data) { that.updateItem = function(id, data) {
Ox.print('-- UPDATE ITEM', id, data);
var item = Ox.getObjectById(self.options.items, id); var item = Ox.getObjectById(self.options.items, id);
Ox.forEach(data, function(value, key) { Ox.forEach(data, function(value, key) {
item[key] = value; item[key] = value;
}); });
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; self.options.selected = item.id;
self.$annotations.options({selected: self.options.selected}); }
if (self.widget) { 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' self.options.type == 'event'
? self.$calendar.options({events: getEvents()}) ? {events: getEvents()}
: self.$map.options({places: getPlaces()}); : {places: getPlaces()}
// if updating has made the item match )
// an event or place, then select it .options({
isDefined(item) && self.$widget.options({
selected: item[self.options.type].id 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; return that;
}; };