dont fail if selected annotation is not present

This commit is contained in:
j 2012-02-21 17:00:35 +05:30
parent db6f68681a
commit 01d975878b

View file

@ -215,21 +215,23 @@ Ox.AnnotationPanel = function(options, self) {
function renderEditMenu() { function renderEditMenu() {
var annotation, annotationTitle, folder, var annotation, annotationTitle, folder,
isDefined, isEditable, isEvent, isEventOrPlace, isPlace, isString, isDefined, isEditable, isEvent, isEventOrPlace, isPlace, isString,
key, manageTitle, type, value key, manageTitle, type, value;
if (self.options.selected) { if (self.options.selected) {
annotation = getAnnotation(self.options.selected); annotation = getAnnotation(self.options.selected);
folder = getFolder(self.options.selected); folder = getFolder(self.options.selected);
key = folder.options('id'); if(annotation && folder) {
type = folder.options('type'); key = folder.options('id');
value = annotation.value; type = folder.options('type');
isEditable = annotation.editable; value = annotation.value;
isEvent = type == 'event'; isEditable = annotation.editable;
isPlace = type == 'place'; isEvent = type == 'event';
isEventOrPlace = isEvent || isPlace; isPlace = type == 'place';
isString = type != 'text'; isEventOrPlace = isEvent || isPlace;
// fixme: absence of annotation[type] may be an error isString = type != 'text';
isDefined = isEventOrPlace && !!annotation[type] && !!annotation[type].type; // fixme: absence of annotation[type] may be an error
annotationTitle = folder.options('item') + ': "' + value + '"'; isDefined = isEventOrPlace && !!annotation[type] && !!annotation[type].type;
annotationTitle = folder.options('item') + ': "' + value + '"';
}
} }
manageTitle = (isDefined ? 'Edit' : 'Define') + ' ' manageTitle = (isDefined ? 'Edit' : 'Define') + ' '
+ (isPlace ? 'Place' : isEvent ? 'Event' : 'Place or Event') + '...' + (isPlace ? 'Place' : isEvent ? 'Event' : 'Place or Event') + '...'