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,6 +539,7 @@ Ox.AnnotationFolder = function(options, self) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function selectAnnotation(data) {
|
function selectAnnotation(data) {
|
||||||
|
if (self.loaded) {
|
||||||
var item = Ox.getObjectById(self.options.items, data.id);
|
var item = Ox.getObjectById(self.options.items, data.id);
|
||||||
self.options.selected = item ? data.id : '';
|
self.options.selected = item ? data.id : '';
|
||||||
if (self.widget) {
|
if (self.widget) {
|
||||||
|
@ -558,6 +561,7 @@ Ox.AnnotationFolder = function(options, self) {
|
||||||
layer: self.options.id
|
layer: self.options.id
|
||||||
} : {}));
|
} : {}));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function showWarnings() {
|
function showWarnings() {
|
||||||
if (self.widget && self.options.items.length) {
|
if (self.widget && self.options.items.length) {
|
||||||
|
|
|
@ -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