annotations are loaded asynchronously: dont fire select event before they are loaded.
This commit is contained in:
parent
acbb56da65
commit
4aba1474d6
2 changed files with 30 additions and 30 deletions
|
@ -341,13 +341,22 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
['event', 'place'].indexOf(self.options.type) > -1
|
||||
? self.$outer : that.$content
|
||||
);
|
||||
|
||||
|
||||
self.loaded = false;
|
||||
setTimeout(function() {
|
||||
self.$annotations.options({
|
||||
items: self.annotations,
|
||||
placeholder: getPlaceholder(),
|
||||
selected: self.options.selected
|
||||
});
|
||||
self.loaded = true;
|
||||
if (self.options.selected) {
|
||||
// need timeout in order to trigger events
|
||||
if (self.options.collapsed) {
|
||||
self.$panel.options({collapsed: false});
|
||||
}
|
||||
selectAnnotation({id: self.options.selected});
|
||||
};
|
||||
});
|
||||
[
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
||||
|
@ -363,13 +372,6 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
});
|
||||
});
|
||||
|
||||
self.options.selected && setTimeout(function() {
|
||||
// need timeout in order to trigger events
|
||||
if (self.options.collapsed) {
|
||||
self.$panel.options({collapsed: false});
|
||||
}
|
||||
selectAnnotation({id: self.options.selected});
|
||||
}, 0);
|
||||
|
||||
showWarnings();
|
||||
|
||||
|
@ -537,26 +539,28 @@ Ox.AnnotationFolder = function(options, self) {
|
|||
}
|
||||
|
||||
function selectAnnotation(data) {
|
||||
var item = Ox.getObjectById(self.options.items, data.id);
|
||||
self.options.selected = item ? data.id : '';
|
||||
if (self.widget) {
|
||||
if (self.options.type == 'event') {
|
||||
self.$calendar.options({
|
||||
selected: item && isDefined(item) ? item.event.id : ''
|
||||
})
|
||||
.panToEvent();
|
||||
} else {
|
||||
self.$map.options({
|
||||
selected: item && isDefined(item) ? item.place.id : ''
|
||||
})
|
||||
.panToPlace();
|
||||
if (self.loaded) {
|
||||
var item = Ox.getObjectById(self.options.items, data.id);
|
||||
self.options.selected = item ? data.id : '';
|
||||
if (self.widget) {
|
||||
if (self.options.type == 'event') {
|
||||
self.$calendar.options({
|
||||
selected: item && isDefined(item) ? item.event.id : ''
|
||||
})
|
||||
.panToEvent();
|
||||
} else {
|
||||
self.$map.options({
|
||||
selected: item && isDefined(item) ? item.place.id : ''
|
||||
})
|
||||
.panToPlace();
|
||||
}
|
||||
}
|
||||
that.triggerEvent('select', Ox.extend(data, item ? {
|
||||
'in': item['in'],
|
||||
out: item.out,
|
||||
layer: self.options.id
|
||||
} : {}));
|
||||
}
|
||||
that.triggerEvent('select', Ox.extend(data, item ? {
|
||||
'in': item['in'],
|
||||
out: item.out,
|
||||
layer: self.options.id
|
||||
} : {}));
|
||||
}
|
||||
|
||||
function showWarnings() {
|
||||
|
|
|
@ -139,10 +139,6 @@ Ox.AnnotationPanel = function(options, self) {
|
|||
})
|
||||
);
|
||||
|
||||
self.options.selected && getFolder(self.options.selected) && scrollToSelected(
|
||||
getFolder(self.options.selected).options('type')
|
||||
);
|
||||
|
||||
function getAnnotation(annotationId) {
|
||||
var found = false, annotation;
|
||||
Ox.forEach(self.options.layers, function(layer, i) {
|
||||
|
|
Loading…
Reference in a new issue