2012-01-12 10:39:05 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
/*@
|
2012-05-31 10:32:54 +00:00
|
|
|
Ox.AnnotationFolder <f> AnnotationFolder Object
|
2012-07-04 11:29:18 +00:00
|
|
|
options <o> Options object
|
|
|
|
editable <b|false> If true, annotations can be added
|
|
|
|
id <s> id
|
|
|
|
items <a|[]> items
|
|
|
|
title <s> title
|
|
|
|
type <s|'text'> panel type
|
|
|
|
width <n|0>
|
|
|
|
self <o> Shared private variable
|
2012-05-31 10:32:54 +00:00
|
|
|
([options[, self]]) -> <o:Ox.CollapsePanel> AnnotationFolder Object
|
2012-06-17 22:38:26 +00:00
|
|
|
add <!> add
|
|
|
|
blur <!> blur
|
|
|
|
change <!> change
|
|
|
|
edit <!> edit
|
|
|
|
info <!> info
|
|
|
|
insert <!> insert
|
|
|
|
key_* <!> key_*
|
|
|
|
open <!> open
|
|
|
|
remove <!> remove
|
2013-05-08 16:53:33 +00:00
|
|
|
selectnext <!> selectnext
|
|
|
|
selectprevious <!> selectprevious
|
2012-06-17 22:38:26 +00:00
|
|
|
selectnone <!> selectnone
|
|
|
|
select <!> select
|
|
|
|
submit <!> submit
|
|
|
|
togglelayer <!> togglelayer
|
|
|
|
togglewidget <!> togglewidget
|
2012-01-12 10:39:05 +00:00
|
|
|
@*/
|
|
|
|
|
|
|
|
Ox.AnnotationFolder = function(options, self) {
|
|
|
|
|
|
|
|
self = self || {};
|
|
|
|
var that = Ox.Element({}, self)
|
|
|
|
.defaults({
|
2012-01-17 15:43:46 +00:00
|
|
|
clickLink: null,
|
2012-01-12 10:39:05 +00:00
|
|
|
collapsed: false,
|
|
|
|
editable: false,
|
2012-02-01 05:21:29 +00:00
|
|
|
highlight: '',
|
2018-10-12 12:46:38 +00:00
|
|
|
highlightAnnotations: 'none',
|
2012-01-12 10:39:05 +00:00
|
|
|
id: '',
|
|
|
|
'in': 0,
|
|
|
|
item: '',
|
|
|
|
items: [],
|
2014-02-05 14:03:42 +00:00
|
|
|
keyboard: '',
|
2014-07-23 13:55:09 +00:00
|
|
|
languages: 'all',
|
2012-01-12 10:39:05 +00:00
|
|
|
out: 0,
|
|
|
|
position: 0,
|
|
|
|
range: 'all',
|
|
|
|
selected: '',
|
2018-09-12 16:47:34 +00:00
|
|
|
separator: ';',
|
2012-02-05 11:08:56 +00:00
|
|
|
showInfo: false,
|
2012-01-13 16:25:47 +00:00
|
|
|
showWidget: false,
|
2012-01-12 10:39:05 +00:00
|
|
|
sort: 'position',
|
2018-08-13 20:28:33 +00:00
|
|
|
translate: false,
|
2012-01-12 10:39:05 +00:00
|
|
|
title: '',
|
|
|
|
type: 'text',
|
|
|
|
users: 'all',
|
2012-01-13 16:25:47 +00:00
|
|
|
widgetSize: 256,
|
2012-01-12 10:39:05 +00:00
|
|
|
width: 0
|
|
|
|
})
|
2012-05-28 19:35:41 +00:00
|
|
|
.options(options || {})
|
|
|
|
.update(function(key, value) {
|
|
|
|
if (key == 'highlight') {
|
|
|
|
self.$annotations.options({highlight: value});
|
|
|
|
}
|
2018-10-09 16:29:13 +00:00
|
|
|
if (key == 'highlightAnnotations') {
|
|
|
|
self.$annotations.options({highlightGroup: value});
|
|
|
|
updateAnnotations();
|
|
|
|
}
|
2012-05-28 19:35:41 +00:00
|
|
|
if (['in', 'out'].indexOf(key) > -1 && self.editing) {
|
|
|
|
var item = Ox.getObjectById(self.options.items, self.options.selected);
|
2020-09-22 10:48:08 +00:00
|
|
|
if (item) {
|
|
|
|
item[key] = value;
|
|
|
|
item.duration = self.options.out - self.options['in'];
|
|
|
|
}
|
2012-05-28 19:35:41 +00:00
|
|
|
self.points = getPoints();
|
|
|
|
}
|
|
|
|
if (key == 'in') {
|
|
|
|
//fixme: array editable should support item updates while editing
|
|
|
|
self.options.range == 'selection' && updateAnnotations();
|
|
|
|
} else if (key == 'out') {
|
|
|
|
self.options.range == 'selection' && updateAnnotations();
|
|
|
|
} else if (key == 'position') {
|
|
|
|
if (self.options.range == 'position') {
|
|
|
|
crossesPoint() && updateAnnotations();
|
|
|
|
self.position = self.options.position;
|
|
|
|
}
|
2015-03-23 11:56:08 +00:00
|
|
|
} else if (key == 'collapsed') {
|
2015-03-23 12:30:25 +00:00
|
|
|
self.options.collapsed = !self.options.collapsed;
|
|
|
|
self.$panel.options({collapsed: !self.options.collapsed});
|
2015-03-23 11:56:08 +00:00
|
|
|
self.options.type == 'event' && self.$calendar.resizeCalendar()
|
|
|
|
self.options.type == 'map' && self.$map.resizeMap()
|
2014-07-24 17:14:34 +00:00
|
|
|
} else if (key == 'languages') {
|
|
|
|
updateAnnotations();
|
2012-05-28 19:35:41 +00:00
|
|
|
} else if (key == 'range') {
|
|
|
|
updateAnnotations();
|
2013-03-08 11:20:53 +00:00
|
|
|
self.$annotations.options({placeholder: getPlaceholder()});
|
2012-05-28 19:35:41 +00:00
|
|
|
} else if (key == 'selected') {
|
|
|
|
if (value === '') {
|
|
|
|
self.editing = false;
|
|
|
|
}
|
|
|
|
if (value && self.options.collapsed) {
|
|
|
|
self.$panel.options({animate: false});
|
|
|
|
self.$panel.options({collapsed: false});
|
|
|
|
self.$panel.options({animate: true});
|
|
|
|
}
|
|
|
|
self.$annotations.options({selected: value});
|
|
|
|
} else if (key == 'sort') {
|
|
|
|
self.sort = getSort();
|
|
|
|
self.$annotations.options({sort: self.sort});
|
|
|
|
showWarnings();
|
|
|
|
} else if (key == 'users') {
|
|
|
|
updateAnnotations();
|
|
|
|
} else if (key == 'width') {
|
|
|
|
if (self.widget) {
|
|
|
|
self.$outer.options({width: self.options.width});
|
|
|
|
self.$inner.options({width: self.options.width});
|
|
|
|
self.$widget.options({width: self.options.width});
|
|
|
|
}
|
|
|
|
self.$annotations.options({
|
2014-09-18 14:43:00 +00:00
|
|
|
width: self.options.type == 'text'
|
|
|
|
? self.options.width + 8
|
|
|
|
: self.options.width
|
2012-05-28 19:35:41 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
2012-01-12 10:39:05 +00:00
|
|
|
|
2012-02-19 10:49:52 +00:00
|
|
|
if (self.options.selected) {
|
|
|
|
self.options.collapsed = false;
|
|
|
|
}
|
|
|
|
|
2012-01-17 11:50:31 +00:00
|
|
|
self.annotations = getAnnotations();
|
2012-01-16 17:51:53 +00:00
|
|
|
self.points = getPoints();
|
|
|
|
self.position = self.options.position;
|
2012-01-12 10:39:05 +00:00
|
|
|
self.sort = getSort();
|
2012-01-13 16:25:47 +00:00
|
|
|
self.widget = self.options.type == 'event' ? 'Calendar'
|
|
|
|
: self.options.type == 'place' ? 'Map' : '';
|
2012-01-12 10:39:05 +00:00
|
|
|
|
2012-01-14 11:39:55 +00:00
|
|
|
self.$addButton = Ox.Button({
|
2012-01-27 14:29:11 +00:00
|
|
|
id: 'add',
|
|
|
|
style: 'symbol',
|
|
|
|
title: 'add',
|
2014-02-05 14:03:42 +00:00
|
|
|
tooltip: Ox._('Add {0}', [self.options.item])
|
|
|
|
+ (self.options.keyboard ? ' [' + self.options.keyboard + ']' : ''),
|
2012-01-27 14:29:11 +00:00
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
that.triggerEvent('add', {value: ''});
|
|
|
|
}
|
2017-02-15 15:31:25 +00:00
|
|
|
});
|
2012-01-27 14:29:11 +00:00
|
|
|
|
|
|
|
self.$infoButton = Ox.Button({
|
|
|
|
style: 'symbol',
|
|
|
|
title: 'info',
|
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
click: function() {
|
|
|
|
that.triggerEvent('info');
|
|
|
|
}
|
|
|
|
});
|
2012-01-14 11:39:55 +00:00
|
|
|
|
2012-01-17 09:25:58 +00:00
|
|
|
self.$panel = Ox.CollapsePanel({
|
2012-01-12 10:39:05 +00:00
|
|
|
collapsed: self.options.collapsed,
|
2012-02-16 11:35:03 +00:00
|
|
|
extras: [self.options.editable ? self.$addButton : self.$infoButton],
|
2012-01-12 10:39:05 +00:00
|
|
|
size: 16,
|
|
|
|
title: self.options.title
|
|
|
|
})
|
|
|
|
.addClass('OxAnnotationFolder')
|
|
|
|
.bindEvent({
|
2012-01-14 11:39:55 +00:00
|
|
|
toggle: toggleLayer
|
2012-01-17 09:25:58 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
that.setElement(self.$panel);
|
2014-09-24 18:18:58 +00:00
|
|
|
that.$content = self.$panel.$content;
|
2012-01-12 10:39:05 +00:00
|
|
|
|
2012-01-13 16:25:47 +00:00
|
|
|
if (self.widget) {
|
|
|
|
self.widgetSize = self.options.showWidget * self.options.widgetSize;
|
|
|
|
self.$outer = Ox.Element()
|
2012-01-12 19:04:32 +00:00
|
|
|
.css({
|
2012-01-13 16:25:47 +00:00
|
|
|
display: 'table-cell',
|
2012-01-14 11:39:55 +00:00
|
|
|
width: self.options.width + 'px'
|
2012-01-13 16:25:47 +00:00
|
|
|
})
|
|
|
|
.appendTo(that.$content);
|
|
|
|
self.$inner = Ox.Element()
|
2012-01-14 11:39:55 +00:00
|
|
|
.css({
|
|
|
|
height: self.widgetSize + 'px',
|
|
|
|
overflow: 'hidden'
|
2012-01-12 19:04:32 +00:00
|
|
|
})
|
2012-01-14 11:39:55 +00:00
|
|
|
.appendTo(self.$outer);
|
|
|
|
if (options.type == 'event') {
|
|
|
|
self.$widget = self.$calendar = Ox.Calendar({
|
|
|
|
events: getEvents(),
|
|
|
|
height: self.widgetSize,
|
|
|
|
showZoombar: true,
|
2012-01-27 14:29:11 +00:00
|
|
|
width: self.options.width,
|
|
|
|
zoomOnlyWhenFocused: true
|
2012-01-14 11:39:55 +00:00
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: self.options.width + 'px',
|
|
|
|
height: self.widgetSize + 'px'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
|
|
|
select: function(data) {
|
2012-02-02 02:32:41 +00:00
|
|
|
if (
|
|
|
|
!data.id && self.options.selected
|
|
|
|
&& isDefined(Ox.getObjectById(self.options.items, self.options.selected))
|
|
|
|
) {
|
2012-01-17 12:10:50 +00:00
|
|
|
// only deselect annotation if the event deselect was not
|
|
|
|
// caused by switching to an annotation without event
|
|
|
|
self.$annotations.options({selected: ''});
|
2012-02-02 02:32:41 +00:00
|
|
|
} else if (
|
|
|
|
data.annotationIds
|
|
|
|
&& data.annotationIds.indexOf(self.options.selected) == -1
|
|
|
|
) {
|
2012-01-17 12:10:50 +00:00
|
|
|
// only select a new annotation if the currently selected
|
|
|
|
// annotation does not match the selected event
|
|
|
|
self.$annotations.options({selected: data.annotationIds[0]});
|
2012-01-17 09:25:58 +00:00
|
|
|
}
|
2012-01-14 11:39:55 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo(self.$inner);
|
|
|
|
} else { // place
|
|
|
|
self.$widget = self.$map = Ox.Map({
|
|
|
|
places: getPlaces(),
|
2012-01-15 15:05:17 +00:00
|
|
|
showTypes: true,
|
2012-01-14 11:39:55 +00:00
|
|
|
// FIXME: should be showZoombar
|
2012-01-27 14:29:11 +00:00
|
|
|
zoombar: true,
|
|
|
|
zoomOnlyWhenFocused: true
|
2012-01-14 11:39:55 +00:00
|
|
|
// showLabels: true
|
|
|
|
})
|
|
|
|
.css({
|
|
|
|
width: self.options.width + 'px',
|
|
|
|
height: self.widgetSize + 'px'
|
|
|
|
})
|
|
|
|
.bindEvent({
|
2012-06-30 14:59:52 +00:00
|
|
|
// FIXME: duplicated!
|
|
|
|
select: function(data) {
|
2012-02-02 02:32:41 +00:00
|
|
|
if (
|
2017-02-25 15:58:32 +00:00
|
|
|
(!data || !data.id) && self.options.selected
|
2012-02-02 02:32:41 +00:00
|
|
|
&& isDefined(Ox.getObjectById(self.options.items, self.options.selected))
|
|
|
|
) {
|
2012-01-17 12:10:50 +00:00
|
|
|
// only deselect annotation if the place deselect was not
|
|
|
|
// caused by switching to an annotation without place
|
|
|
|
self.$annotations.options({selected: ''});
|
2012-02-02 02:32:41 +00:00
|
|
|
} else if (
|
2017-02-25 15:58:32 +00:00
|
|
|
data
|
|
|
|
&& data.annotationIds
|
2012-02-02 02:32:41 +00:00
|
|
|
&& data.annotationIds.indexOf(self.options.selected) == -1
|
|
|
|
) {
|
2012-01-17 12:10:50 +00:00
|
|
|
// only select a new annotation if the currently selected
|
|
|
|
// annotation does not match the selected place
|
|
|
|
self.$annotations.options({selected: data.annotationIds[0]});
|
2012-01-17 09:25:58 +00:00
|
|
|
}
|
2012-01-14 11:39:55 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo(self.$inner);
|
|
|
|
}
|
2012-01-13 16:25:47 +00:00
|
|
|
self.$resizebar = Ox.Element({
|
2013-05-09 13:03:33 +00:00
|
|
|
tooltip: Ox._('Drag to resize or click to toggle map') // fixme: update as w/ splitpanels
|
2012-01-13 16:25:47 +00:00
|
|
|
})
|
|
|
|
.addClass('OxResizebar OxHorizontal')
|
|
|
|
.css({
|
|
|
|
position: 'absolute',
|
2012-01-14 11:39:55 +00:00
|
|
|
top: self.widgetSize + 'px',
|
2012-01-13 16:25:47 +00:00
|
|
|
cursor: 'ns-resize'
|
2012-01-12 10:39:05 +00:00
|
|
|
})
|
2012-01-13 16:25:47 +00:00
|
|
|
.append($('<div>').addClass('OxSpace'))
|
|
|
|
.append($('<div>').addClass('OxLine'))
|
|
|
|
.append($('<div>').addClass('OxSpace'))
|
2012-01-12 10:39:05 +00:00
|
|
|
.bindEvent({
|
2012-01-13 16:25:47 +00:00
|
|
|
anyclick: toggleWidget,
|
|
|
|
dragstart: dragstart,
|
|
|
|
drag: drag,
|
|
|
|
dragend: dragend
|
|
|
|
})
|
2018-09-12 16:47:34 +00:00
|
|
|
.appendTo(self.$outer);
|
2012-01-12 10:39:05 +00:00
|
|
|
}
|
2014-12-16 13:02:18 +00:00
|
|
|
self.$annotations = Ox.ArrayEditable(Ox.extend({
|
2012-01-17 15:43:46 +00:00
|
|
|
clickLink: self.options.clickLink,
|
2012-01-13 16:25:47 +00:00
|
|
|
editable: self.options.editable,
|
2012-03-20 09:34:50 +00:00
|
|
|
getSortValue: self.options.type == 'text'
|
|
|
|
? function(value) {
|
|
|
|
return Ox.stripTags(value);
|
|
|
|
}
|
|
|
|
: null,
|
2014-12-21 13:53:29 +00:00
|
|
|
globalAttributes: ['data', 'lang'],
|
2018-08-13 20:28:33 +00:00
|
|
|
highlight: self.options.translate ? Ox._(self.options.highlight) : self.options.highlight,
|
2018-10-09 16:29:13 +00:00
|
|
|
highlightGroup: self.options.highlightAnnotations,
|
2014-02-01 20:13:55 +00:00
|
|
|
placeholder: Ox._('Loading...'),
|
2018-09-12 16:47:34 +00:00
|
|
|
separator: self.options.separator,
|
2012-01-13 16:25:47 +00:00
|
|
|
sort: self.sort,
|
|
|
|
submitOnBlur: false,
|
2012-02-22 10:14:25 +00:00
|
|
|
tooltipText: self.options.showInfo ? function(item) {
|
2012-06-16 16:17:28 +00:00
|
|
|
return Ox.encodeHTMLEntities(item.user) + ', '
|
|
|
|
+ Ox.formatDate(item.modified.slice(0, 10), '%B %e, %Y');
|
2012-02-22 10:14:25 +00:00
|
|
|
} : '',
|
2012-01-16 11:22:34 +00:00
|
|
|
width: self.options.width,
|
2012-01-21 14:58:32 +00:00
|
|
|
maxHeight: self.options.type == 'text' ? Infinity : void 0,
|
2012-01-13 16:25:47 +00:00
|
|
|
type: self.options.type == 'text' ? 'textarea' : 'input'
|
2015-04-14 18:48:10 +00:00
|
|
|
}, self.options.autocomplete ? {
|
2014-12-16 13:02:18 +00:00
|
|
|
autocomplete: function(value, callback) {
|
|
|
|
self.options.autocomplete(self.options.id, value, callback);
|
|
|
|
},
|
2015-04-14 18:48:10 +00:00
|
|
|
autocompleteReplace: self.options.type == 'entity',
|
2014-12-16 18:43:18 +00:00
|
|
|
//autocompleteReplaceCorrect: true,
|
2014-12-16 13:02:18 +00:00
|
|
|
autocompleteSelect: true,
|
|
|
|
autocompleteSelectHighlight: true,
|
2014-12-16 20:23:29 +00:00
|
|
|
autocompleteSelectMaxWidth: 256,
|
2014-12-17 14:36:58 +00:00
|
|
|
autocompleteSelectOffset: {left: 0, top: 0},
|
2014-12-17 14:37:14 +00:00
|
|
|
autocompleteSelectUpdate: true,
|
2018-08-13 20:28:33 +00:00
|
|
|
format: self.options.translate ? function(value) {
|
|
|
|
return Ox._(value);
|
|
|
|
} : null,
|
2014-12-16 20:38:41 +00:00
|
|
|
unformat: function(value) {
|
2015-04-16 19:39:36 +00:00
|
|
|
return Ox.decodeHTMLEntities(Ox.stripTags(value));
|
2014-12-16 20:23:29 +00:00
|
|
|
}
|
2014-12-16 13:02:18 +00:00
|
|
|
} : {}))
|
2012-01-13 16:25:47 +00:00
|
|
|
.bindEvent({
|
|
|
|
add: function(data) {
|
2012-01-15 15:05:17 +00:00
|
|
|
if (self.editing) {
|
|
|
|
// FIXME: changed value will not be saved!
|
|
|
|
}
|
2018-09-12 16:47:34 +00:00
|
|
|
that.triggerEvent('add', {value: data.value || ''});
|
2012-01-13 16:25:47 +00:00
|
|
|
},
|
2018-10-09 14:25:41 +00:00
|
|
|
blur: function(data) {
|
2020-09-21 12:02:57 +00:00
|
|
|
if (data && data.id && data.id[0] == '_') {
|
2018-10-09 14:25:41 +00:00
|
|
|
changeAnnotation(data);
|
2018-12-10 15:18:17 +00:00
|
|
|
that.triggerEvent('blur');
|
2018-10-09 14:25:41 +00:00
|
|
|
} else {
|
|
|
|
// the video editor will, if it has not received focus,
|
|
|
|
// call blurItem
|
|
|
|
that.triggerEvent('blur');
|
|
|
|
}
|
2012-01-13 16:25:47 +00:00
|
|
|
},
|
2012-01-15 15:05:17 +00:00
|
|
|
change: changeAnnotation,
|
2012-01-17 11:50:31 +00:00
|
|
|
'delete': removeAnnotation,
|
2012-01-13 16:25:47 +00:00
|
|
|
edit: function() {
|
|
|
|
self.editing = true;
|
|
|
|
that.triggerEvent('edit');
|
|
|
|
},
|
2012-02-16 16:35:59 +00:00
|
|
|
insert: function(data) {
|
|
|
|
that.triggerEvent('insert', data);
|
|
|
|
},
|
2012-02-19 11:06:03 +00:00
|
|
|
open: function() {
|
|
|
|
that.triggerEvent('open');
|
|
|
|
},
|
2012-01-13 16:25:47 +00:00
|
|
|
select: selectAnnotation,
|
2013-05-08 16:53:33 +00:00
|
|
|
selectnext: function() {
|
|
|
|
that.triggerEvent('selectnext');
|
2012-02-01 19:33:10 +00:00
|
|
|
},
|
2013-05-08 16:53:33 +00:00
|
|
|
selectprevious: function() {
|
|
|
|
that.triggerEvent('selectprevious');
|
2012-02-01 19:33:10 +00:00
|
|
|
},
|
|
|
|
selectnone: function() {
|
|
|
|
that.triggerEvent('selectnone');
|
|
|
|
},
|
2012-02-15 22:20:19 +00:00
|
|
|
submit: submitAnnotation
|
2012-01-13 16:25:47 +00:00
|
|
|
})
|
|
|
|
.appendTo(
|
|
|
|
['event', 'place'].indexOf(self.options.type) > -1
|
|
|
|
? self.$outer : that.$content
|
|
|
|
);
|
2015-02-06 10:16:13 +00:00
|
|
|
|
|
|
|
[
|
|
|
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
|
|
|
'b', 'backslash', 'closebracket', 'comma', 'dot',
|
2015-04-17 07:36:35 +00:00
|
|
|
'equal', 'e', 'f', 'g', 'h', 'i', 'minus', 'n', 'o',
|
2015-02-06 10:16:13 +00:00
|
|
|
'openbracket', 'p', 'shift_0', 'shift_equal',
|
|
|
|
'shift_g', 'shift_i', 'shift_minus', 'shift_o',
|
|
|
|
'slash', 'space'
|
|
|
|
].forEach(function(key) {
|
|
|
|
key = 'key.' + key;
|
|
|
|
self.$annotations.bindEvent(key, function() {
|
|
|
|
that.triggerEvent(key);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2014-12-26 12:08:35 +00:00
|
|
|
self.loaded = false;
|
2014-02-01 09:39:05 +00:00
|
|
|
setTimeout(function() {
|
|
|
|
self.$annotations.options({
|
2014-12-16 18:28:02 +00:00
|
|
|
items: self.annotations,
|
2014-02-01 09:39:05 +00:00
|
|
|
placeholder: getPlaceholder(),
|
|
|
|
selected: self.options.selected
|
|
|
|
});
|
2014-12-26 12:08:35 +00:00
|
|
|
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});
|
|
|
|
};
|
2014-02-01 09:39:05 +00:00
|
|
|
});
|
2012-02-15 22:20:19 +00:00
|
|
|
[
|
2012-02-15 22:41:49 +00:00
|
|
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
2012-02-19 11:21:52 +00:00
|
|
|
'b', 'backslash', 'closebracket', 'comma', 'dot',
|
|
|
|
'equal', 'f', 'g', 'h', 'i', 'minus', 'n', 'o',
|
|
|
|
'openbracket', 'p', 'shift_0', 'shift_equal',
|
|
|
|
'shift_g', 'shift_i', 'shift_minus', 'shift_o',
|
|
|
|
'slash', 'space'
|
2012-02-15 22:20:19 +00:00
|
|
|
].forEach(function(key) {
|
|
|
|
key = 'key_' + key;
|
|
|
|
self.$annotations.bindEvent(key, function() {
|
|
|
|
that.triggerEvent(key);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2012-01-14 11:39:55 +00:00
|
|
|
showWarnings();
|
2012-01-13 16:25:47 +00:00
|
|
|
|
2012-01-15 15:05:17 +00:00
|
|
|
function changeAnnotation(data) {
|
|
|
|
var item = Ox.getObjectById(self.options.items, data.id);
|
2018-12-10 15:18:17 +00:00
|
|
|
if (item.value != data.value) {
|
|
|
|
item.value = data.value;
|
|
|
|
that.triggerEvent('change', item);
|
|
|
|
}
|
2012-01-15 15:05:17 +00:00
|
|
|
}
|
|
|
|
|
2012-01-16 17:51:53 +00:00
|
|
|
function crossesPoint() {
|
2015-06-25 12:28:56 +00:00
|
|
|
var positions = Ox.sort([self.position, self.options.position]);
|
2012-01-16 17:51:53 +00:00
|
|
|
return self.points.some(function(point) {
|
2012-05-10 10:12:34 +00:00
|
|
|
return point >= positions[0] && point <= positions[1];
|
2012-01-16 17:51:53 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-01-13 16:25:47 +00:00
|
|
|
function dragstart() {
|
2012-01-14 11:39:55 +00:00
|
|
|
if (self.options.showWidget) {
|
2013-07-19 08:42:25 +00:00
|
|
|
Ox.$body.addClass('OxDragging');
|
2012-01-14 11:39:55 +00:00
|
|
|
self.drag = {
|
|
|
|
startSize: self.options.widgetSize
|
|
|
|
};
|
|
|
|
}
|
2012-01-13 16:25:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function drag(e) {
|
2012-01-14 11:39:55 +00:00
|
|
|
if (self.options.showWidget) {
|
|
|
|
self.options.widgetSize = Ox.limit(
|
|
|
|
self.drag.startSize + e.clientDY, 128, 384
|
|
|
|
);
|
|
|
|
if (self.options.widgetSize >= 248 && self.options.widgetSize <= 264) {
|
|
|
|
self.options.widgetSize = 256;
|
|
|
|
}
|
|
|
|
self.$resizebar.css({top: self.options.widgetSize + 'px'});
|
|
|
|
self.$inner.css({height: self.options.widgetSize + 'px'});
|
2012-01-16 14:02:30 +00:00
|
|
|
self.$widget.options({height: self.options.widgetSize});
|
2012-01-14 11:39:55 +00:00
|
|
|
}
|
2012-01-13 16:25:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function dragend(e) {
|
2012-01-14 11:39:55 +00:00
|
|
|
if (self.options.showWidget) {
|
2013-07-19 08:42:25 +00:00
|
|
|
Ox.$body.removeClass('OxDragging');
|
2012-01-30 22:11:05 +00:00
|
|
|
self.options.type == 'event'
|
|
|
|
? self.$calendar.resizeCalendar()
|
|
|
|
: self.$map.resizeMap();
|
2012-01-14 11:39:55 +00:00
|
|
|
that.triggerEvent('resizewidget', {size: self.options.widgetSize});
|
|
|
|
}
|
2012-01-13 16:25:47 +00:00
|
|
|
}
|
|
|
|
|
2012-01-12 10:39:05 +00:00
|
|
|
function getAnnotations() {
|
2014-12-16 19:39:57 +00:00
|
|
|
var annotations = Ox.filter(self.options.items, function(item) {
|
2012-01-12 10:39:05 +00:00
|
|
|
return self.editing && item.id == self.options.selected || (
|
|
|
|
(
|
|
|
|
self.options.range == 'all' || (
|
|
|
|
self.options.range == 'selection'
|
2012-02-01 18:04:42 +00:00
|
|
|
&& item['in'] <= self.options.out
|
|
|
|
&& item.out >= self.options['in']
|
2012-01-12 10:39:05 +00:00
|
|
|
) || (
|
|
|
|
self.options.range == 'position'
|
|
|
|
&& item['in'] <= self.options.position
|
|
|
|
&& item.out >= self.options.position
|
|
|
|
)
|
2014-07-23 13:55:09 +00:00
|
|
|
) && (
|
|
|
|
self.options.languages == 'all'
|
2014-07-24 17:14:34 +00:00
|
|
|
|| self.options.languages.some(function(language) {
|
2017-02-15 15:31:25 +00:00
|
|
|
return item.languages && item.languages.indexOf(language) > -1;
|
2014-07-24 17:14:34 +00:00
|
|
|
})
|
2012-01-12 10:39:05 +00:00
|
|
|
) && (
|
|
|
|
self.options.users == 'all'
|
|
|
|
|| self.options.users.indexOf(item.user) > -1
|
|
|
|
)
|
2012-05-22 14:29:37 +00:00
|
|
|
);
|
2018-10-09 16:29:13 +00:00
|
|
|
}).map(function(item) {
|
|
|
|
return Ox.extend(item, {
|
2018-10-12 12:46:38 +00:00
|
|
|
group: self.options.highlightAnnotations == 'none' ? ''
|
|
|
|
: self.options.highlightAnnotations == 'value' ? item.value
|
|
|
|
: item['in'] + '-' + item.out
|
2018-10-09 16:29:13 +00:00
|
|
|
});
|
2012-01-12 10:39:05 +00:00
|
|
|
});
|
2014-12-16 19:39:57 +00:00
|
|
|
return annotations;
|
2012-01-12 10:39:05 +00:00
|
|
|
}
|
|
|
|
|
2012-01-13 16:25:47 +00:00
|
|
|
function getEvents() {
|
|
|
|
var events = [];
|
2012-01-17 11:50:31 +00:00
|
|
|
self.annotations.filter(function(item) {
|
2012-02-02 02:32:41 +00:00
|
|
|
return isDefined(item);
|
2012-01-17 09:25:58 +00:00
|
|
|
}).forEach(function(item) {
|
|
|
|
var index = Ox.getIndexById(events, item.event.id);
|
|
|
|
if (index == -1) {
|
2012-01-13 16:25:47 +00:00
|
|
|
events.push(Ox.extend({
|
2012-01-17 09:25:58 +00:00
|
|
|
annotationIds: [item.id]
|
|
|
|
}, item.event))
|
|
|
|
} else {
|
|
|
|
events[index].annotationIds.push(item.id);
|
2012-01-13 16:25:47 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return events;
|
|
|
|
}
|
|
|
|
|
2013-03-08 11:18:20 +00:00
|
|
|
function getPlaceholder() {
|
|
|
|
return 'No ' + self.options.title.toLowerCase() + (
|
|
|
|
self.options.range == 'position' ? ' at current position'
|
|
|
|
: self.options.range == 'selection' ? ' in current selection'
|
|
|
|
: ''
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2012-01-12 19:04:32 +00:00
|
|
|
function getPlaces() {
|
|
|
|
var places = [];
|
2012-01-17 11:50:31 +00:00
|
|
|
self.annotations.filter(function(item) {
|
2012-02-02 02:32:41 +00:00
|
|
|
return isDefined(item);
|
2012-01-17 09:25:58 +00:00
|
|
|
}).forEach(function(item) {
|
|
|
|
var index = Ox.getIndexById(places, item.place.id);
|
|
|
|
if (index == -1) {
|
2012-01-12 19:04:32 +00:00
|
|
|
places.push(Ox.extend({
|
2012-01-17 09:25:58 +00:00
|
|
|
annotationIds: [item.id]
|
2012-01-24 09:59:29 +00:00
|
|
|
}, item.place));
|
2012-01-17 09:25:58 +00:00
|
|
|
} else {
|
|
|
|
places[index].annotationIds.push(item.id);
|
2012-01-12 19:04:32 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
return places;
|
|
|
|
}
|
|
|
|
|
2012-02-01 18:04:42 +00:00
|
|
|
function getPoints() {
|
|
|
|
return Ox.unique(Ox.flatten(
|
|
|
|
self.options.items.map(function(item) {
|
|
|
|
return [item['in'], item.out];
|
|
|
|
})
|
|
|
|
));
|
|
|
|
}
|
|
|
|
|
2012-01-12 10:39:05 +00:00
|
|
|
function getSort() {
|
|
|
|
return ({
|
2012-09-18 19:26:53 +00:00
|
|
|
duration: ['-duration', '+in', self.options.type == 'text' ? '+created' : '+value'],
|
|
|
|
position: ['+in', '+duration', self.options.type == 'text' ? '+created' : '+value'],
|
2015-12-14 12:16:13 +00:00
|
|
|
text: ['+value', '+in', '+duration'],
|
|
|
|
created: ['+created', '+in', '+duration', '+value']
|
2012-01-12 10:39:05 +00:00
|
|
|
})[self.options.sort];
|
|
|
|
}
|
|
|
|
|
2012-02-02 02:32:41 +00:00
|
|
|
function isDefined(item) {
|
2012-02-04 08:58:46 +00:00
|
|
|
return !!item[self.options.type]
|
|
|
|
&& !!item[self.options.type].type;
|
2012-02-02 02:32:41 +00:00
|
|
|
}
|
|
|
|
|
2012-01-17 11:50:31 +00:00
|
|
|
function removeAnnotation(data) {
|
|
|
|
var item;
|
|
|
|
self.editing = false;
|
|
|
|
if (self.widget) {
|
|
|
|
item = Ox.getObjectById(self.options.items, data.id);
|
2012-02-02 02:32:41 +00:00
|
|
|
if (isDefined(item)) {
|
2012-01-17 11:50:31 +00:00
|
|
|
if (self.options.type == 'event') {
|
2012-02-18 09:56:58 +00:00
|
|
|
self.$calendar.options({selected: ''})
|
|
|
|
.options({events: getEvents()});
|
2012-01-17 11:50:31 +00:00
|
|
|
} else {
|
2012-02-18 09:56:58 +00:00
|
|
|
self.$map.options({selected: ''})
|
|
|
|
.options({places: getPlaces()});
|
2012-01-17 11:50:31 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2012-02-18 09:56:58 +00:00
|
|
|
showWarnings();
|
2012-01-17 11:50:31 +00:00
|
|
|
that.triggerEvent('remove', {id: data.id});
|
|
|
|
}
|
|
|
|
|
2012-01-12 10:39:05 +00:00
|
|
|
function selectAnnotation(data) {
|
2014-12-26 12:08:35 +00:00
|
|
|
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();
|
|
|
|
}
|
2012-01-17 09:25:58 +00:00
|
|
|
}
|
2014-12-26 12:08:35 +00:00
|
|
|
that.triggerEvent('select', Ox.extend(data, item ? {
|
|
|
|
'in': item['in'],
|
|
|
|
out: item.out,
|
|
|
|
layer: self.options.id
|
|
|
|
} : {}));
|
2012-01-13 16:25:47 +00:00
|
|
|
}
|
2012-01-12 10:39:05 +00:00
|
|
|
}
|
|
|
|
|
2012-01-14 11:39:55 +00:00
|
|
|
function showWarnings() {
|
2012-01-15 15:05:17 +00:00
|
|
|
if (self.widget && self.options.items.length) {
|
2012-01-17 11:50:31 +00:00
|
|
|
self.$annotations.find('.OxEditableElement').each(function() {
|
2012-01-14 11:39:55 +00:00
|
|
|
var $element = $(this);
|
2012-01-19 16:37:39 +00:00
|
|
|
// We don't want to catch an eventual placeholder,
|
|
|
|
// which is an EditableElement without .data('id')
|
|
|
|
if (
|
|
|
|
$element.data('id')
|
2012-02-02 02:32:41 +00:00
|
|
|
&& !isDefined(
|
|
|
|
Ox.getObjectById(self.options.items, $element.data('id'))
|
|
|
|
)
|
2012-01-19 16:37:39 +00:00
|
|
|
) {
|
2012-01-17 11:50:31 +00:00
|
|
|
$element.addClass('OxWarning');
|
2012-02-18 09:56:58 +00:00
|
|
|
} else {
|
|
|
|
$element.removeClass('OxWarning');
|
2012-01-17 11:50:31 +00:00
|
|
|
}
|
2012-01-14 11:39:55 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-01-12 10:39:05 +00:00
|
|
|
function submitAnnotation(data) {
|
|
|
|
var item = Ox.getObjectById(self.options.items, data.id);
|
2020-09-22 10:48:08 +00:00
|
|
|
if (item) {
|
|
|
|
item.value = data.value;
|
|
|
|
self.editing = false;
|
|
|
|
self.options.sort == 'text' && self.$annotations.reloadItems();
|
|
|
|
that.triggerEvent('submit', item);
|
|
|
|
}
|
2012-01-12 10:39:05 +00:00
|
|
|
}
|
|
|
|
|
2012-01-14 11:39:55 +00:00
|
|
|
function toggleLayer() {
|
2012-01-12 10:39:05 +00:00
|
|
|
self.options.collapsed = !self.options.collapsed;
|
2012-01-30 22:11:05 +00:00
|
|
|
if (
|
|
|
|
!self.options.collapsed
|
|
|
|
&& self.options.type == 'place'
|
|
|
|
&& self.options.showWidget
|
|
|
|
) {
|
|
|
|
self.$map.resizeMap();
|
|
|
|
}
|
2012-01-27 18:28:44 +00:00
|
|
|
if (self.options.collapsed) {
|
|
|
|
self.editing && that.blurItem();
|
|
|
|
self.$annotations.loseFocus();
|
|
|
|
}
|
2012-01-14 11:39:55 +00:00
|
|
|
that.triggerEvent('togglelayer', {collapsed: self.options.collapsed});
|
2012-01-12 10:39:05 +00:00
|
|
|
}
|
|
|
|
|
2012-01-13 16:25:47 +00:00
|
|
|
function toggleWidget() {
|
|
|
|
self.options.showWidget = !self.options.showWidget;
|
|
|
|
self.widgetSize = self.options.showWidget * self.options.widgetSize;
|
|
|
|
self.$resizebar.animate({top: self.widgetSize + 'px'}, 250);
|
|
|
|
self.$inner.animate({height: self.widgetSize + 'px'}, 250);
|
2012-01-14 11:39:55 +00:00
|
|
|
self.$widget.animate({height: self.widgetSize + 'px'}, 250, function() {
|
|
|
|
self.$widget.options({height: self.widgetSize});
|
2012-01-13 16:25:47 +00:00
|
|
|
});
|
2012-01-14 11:39:55 +00:00
|
|
|
that.triggerEvent('togglewidget', {collapsed: !self.options.showWidget});
|
2012-01-13 16:25:47 +00:00
|
|
|
}
|
|
|
|
|
2012-01-15 15:05:17 +00:00
|
|
|
function updateAnnotations() {
|
2012-01-17 11:50:31 +00:00
|
|
|
self.annotations = getAnnotations();
|
2018-10-12 12:46:38 +00:00
|
|
|
self.$annotations.options({highlightGroup: self.options.highlightAnnotations != 'none'});
|
2012-01-17 11:50:31 +00:00
|
|
|
self.$annotations.options({items: self.annotations});
|
2018-10-12 12:46:38 +00:00
|
|
|
self.$annotations.updateItemGroup();
|
2012-01-15 15:05:17 +00:00
|
|
|
showWarnings();
|
2012-01-17 11:50:31 +00:00
|
|
|
if (self.widget) {
|
|
|
|
self.options.type == 'event'
|
|
|
|
? self.$calendar.options({events: getEvents()})
|
|
|
|
: self.$map.options({places: getPlaces()});
|
|
|
|
}
|
2012-01-15 15:05:17 +00:00
|
|
|
}
|
|
|
|
|
2012-01-12 10:39:05 +00:00
|
|
|
/*@
|
|
|
|
addItem <f> addItem
|
|
|
|
@*/
|
|
|
|
that.addItem = function(item) {
|
|
|
|
var pos = 0;
|
|
|
|
self.options.items.splice(pos, 0, item);
|
2012-01-27 18:28:44 +00:00
|
|
|
self.$panel.options({collapsed: false});
|
2012-01-15 15:05:17 +00:00
|
|
|
self.$annotations
|
2018-10-09 16:29:13 +00:00
|
|
|
.addItem(pos, Ox.extend(item, {
|
|
|
|
group: item['in'] + '-' + item.out
|
|
|
|
}))
|
2012-01-15 15:05:17 +00:00
|
|
|
.options({selected: item.id})
|
|
|
|
.editItem();
|
2012-01-17 11:50:31 +00:00
|
|
|
showWarnings();
|
2012-02-15 22:31:37 +00:00
|
|
|
self.points = getPoints();
|
2012-01-15 15:05:17 +00:00
|
|
|
return that;
|
2012-01-12 10:39:05 +00:00
|
|
|
};
|
|
|
|
|
2012-05-21 10:38:18 +00:00
|
|
|
/*@
|
|
|
|
blurItem <f> blur item
|
|
|
|
() -> <o> blur selected item
|
|
|
|
@*/
|
2012-01-12 10:39:05 +00:00
|
|
|
that.blurItem = function() {
|
2012-01-16 14:02:30 +00:00
|
|
|
self.editing = false;
|
2012-01-12 10:39:05 +00:00
|
|
|
self.$annotations.blurItem();
|
2012-01-15 15:05:17 +00:00
|
|
|
return that;
|
2012-01-12 10:39:05 +00:00
|
|
|
};
|
|
|
|
|
2012-05-21 10:38:18 +00:00
|
|
|
/*@
|
|
|
|
editItem <f> edit item
|
|
|
|
() -> <o> edit selected item
|
|
|
|
@*/
|
2012-01-12 10:39:05 +00:00
|
|
|
that.editItem = function() {
|
2012-01-16 14:02:30 +00:00
|
|
|
self.editing = true;
|
2012-01-27 18:28:44 +00:00
|
|
|
self.$panel.options({collapsed: false});
|
2012-01-12 10:39:05 +00:00
|
|
|
self.$annotations.editItem();
|
2012-01-15 15:05:17 +00:00
|
|
|
return that;
|
2012-01-12 10:39:05 +00:00
|
|
|
};
|
|
|
|
|
2012-05-21 10:38:18 +00:00
|
|
|
/*@
|
|
|
|
gainFocus <f> gain focus
|
2018-09-12 16:47:34 +00:00
|
|
|
() -> <o> gain focus
|
2012-05-21 10:38:18 +00:00
|
|
|
@*/
|
2012-02-16 12:32:52 +00:00
|
|
|
that.gainFocus = function() {
|
|
|
|
self.$annotations.gainFocus();
|
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|
2014-09-18 14:43:00 +00:00
|
|
|
that.getCurrentAnnotations = function() {
|
|
|
|
return getAnnotations();
|
|
|
|
};
|
|
|
|
|
2012-05-21 10:38:18 +00:00
|
|
|
/*@
|
2018-09-12 16:47:34 +00:00
|
|
|
removeItem <f> remove item
|
2012-05-21 10:38:18 +00:00
|
|
|
() -> <o> remove selected item
|
|
|
|
@*/
|
2012-02-16 11:35:03 +00:00
|
|
|
that.removeItem = function() {
|
|
|
|
self.$annotations.removeItem();
|
|
|
|
};
|
|
|
|
|
2012-05-21 10:38:18 +00:00
|
|
|
/*@
|
|
|
|
selectItem <f> select item
|
|
|
|
(position) -> <o> select item at position
|
|
|
|
@*/
|
2012-02-01 19:33:10 +00:00
|
|
|
that.selectItem = function(position) {
|
|
|
|
// selects the first (0) or last (-1) visible annotation
|
|
|
|
if (self.annotations.length) {
|
|
|
|
that.options({selected: self.annotations[
|
|
|
|
position == 0 ? 0 : self.annotations.length - 1
|
|
|
|
].id});
|
|
|
|
self.$annotations.gainFocus();
|
|
|
|
} else {
|
|
|
|
that.triggerEvent(
|
2013-05-08 16:53:33 +00:00
|
|
|
position == 0 ? 'selectnext' : 'selectprevious'
|
2012-02-01 19:33:10 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-05-21 10:38:18 +00:00
|
|
|
/*@
|
2018-09-12 16:47:34 +00:00
|
|
|
updateItem <f> update item
|
2012-05-21 10:38:18 +00:00
|
|
|
(id, data) -> <o> update item
|
|
|
|
@*/
|
2012-01-31 10:57:09 +00:00
|
|
|
that.updateItem = function(id, data) {
|
2020-09-22 10:48:08 +00:00
|
|
|
Ox.Log('AF', 'updateItem', id, data)
|
2012-01-31 10:57:09 +00:00
|
|
|
var item = Ox.getObjectById(self.options.items, id);
|
2012-01-24 09:59:29 +00:00
|
|
|
Ox.forEach(data, function(value, key) {
|
|
|
|
item[key] = value;
|
|
|
|
});
|
2018-10-12 12:46:38 +00:00
|
|
|
item.group = self.options.highlightAnnotations == 'none' ? ''
|
|
|
|
: self.options.highlightAnnotations == 'value' ? item.value
|
|
|
|
: item['in'] + '-' + item.out;
|
|
|
|
self.$annotations.updateItemGroup();
|
2012-02-18 09:56:58 +00:00
|
|
|
if (id != item.id) {
|
|
|
|
self.$annotations.find('.OxEditableElement').each(function() {
|
|
|
|
var $element = $(this);
|
2020-09-22 10:48:08 +00:00
|
|
|
if ($element.data('id') == id) {
|
2012-02-18 09:56:58 +00:00
|
|
|
$element.data({id: item.id});
|
|
|
|
}
|
2012-02-15 16:13:09 +00:00
|
|
|
});
|
2012-02-18 09:56:58 +00:00
|
|
|
self.options.selected = item.id;
|
2012-01-17 11:50:31 +00:00
|
|
|
}
|
2015-02-06 10:16:13 +00:00
|
|
|
if (self.options.type == 'entity') {
|
|
|
|
// data.value is missing if input did not match any existing entity
|
|
|
|
if (data.value) {
|
|
|
|
self.$annotations.updateItem(data.value);
|
|
|
|
} else {
|
|
|
|
that.removeItem();
|
|
|
|
}
|
2014-12-17 19:36:13 +00:00
|
|
|
}
|
2012-02-18 09:56:58 +00:00
|
|
|
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'
|
|
|
|
? {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()}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2018-03-31 08:30:15 +00:00
|
|
|
if (!self.editing && id != item.id) {
|
2012-02-18 09:56:58 +00:00
|
|
|
self.$annotations.options({selected: self.options.selected});
|
|
|
|
}
|
|
|
|
showWarnings();
|
2012-01-15 15:05:17 +00:00
|
|
|
return that;
|
2012-01-24 09:59:29 +00:00
|
|
|
};
|
2012-01-15 15:05:17 +00:00
|
|
|
|
2012-01-12 10:39:05 +00:00
|
|
|
return that;
|
|
|
|
|
|
|
|
};
|