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);
Ox.print('ST::::', self.title)
if (!self.infoIsObject) {
self.info = formatText(self.options.info, 5 - self.title.split('<br/>').length, self.lineLength);
} else {

View file

@ -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 <f> 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;
});
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.$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.$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({
? {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;
};