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
|
@ -342,12 +342,21 @@ Ox.AnnotationFolder = function(options, self) {
|
||||||
? self.$outer : that.$content
|
? self.$outer : that.$content
|
||||||
);
|
);
|
||||||
|
|
||||||
|
self.loaded = false;
|
||||||
setTimeout(function() {
|
setTimeout(function() {
|
||||||
self.$annotations.options({
|
self.$annotations.options({
|
||||||
items: self.annotations,
|
items: self.annotations,
|
||||||
placeholder: getPlaceholder(),
|
placeholder: getPlaceholder(),
|
||||||
selected: self.options.selected
|
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',
|
'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();
|
showWarnings();
|
||||||
|
|
||||||
|
@ -537,26 +539,28 @@ Ox.AnnotationFolder = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectAnnotation(data) {
|
function selectAnnotation(data) {
|
||||||
var item = Ox.getObjectById(self.options.items, data.id);
|
if (self.loaded) {
|
||||||
self.options.selected = item ? data.id : '';
|
var item = Ox.getObjectById(self.options.items, data.id);
|
||||||
if (self.widget) {
|
self.options.selected = item ? data.id : '';
|
||||||
if (self.options.type == 'event') {
|
if (self.widget) {
|
||||||
self.$calendar.options({
|
if (self.options.type == 'event') {
|
||||||
selected: item && isDefined(item) ? item.event.id : ''
|
self.$calendar.options({
|
||||||
})
|
selected: item && isDefined(item) ? item.event.id : ''
|
||||||
.panToEvent();
|
})
|
||||||
} else {
|
.panToEvent();
|
||||||
self.$map.options({
|
} else {
|
||||||
selected: item && isDefined(item) ? item.place.id : ''
|
self.$map.options({
|
||||||
})
|
selected: item && isDefined(item) ? item.place.id : ''
|
||||||
.panToPlace();
|
})
|
||||||
|
.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() {
|
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) {
|
function getAnnotation(annotationId) {
|
||||||
var found = false, annotation;
|
var found = false, annotation;
|
||||||
Ox.forEach(self.options.layers, function(layer, i) {
|
Ox.forEach(self.options.layers, function(layer, i) {
|
||||||
|
|
Loading…
Reference in a new issue