2011-11-05 16:46:53 +00:00
|
|
|
'use strict';
|
|
|
|
|
2013-10-22 17:43:38 +00:00
|
|
|
// FIXME: should be Ox.AnnotationFolders
|
|
|
|
|
2011-05-16 08:24:46 +00:00
|
|
|
/*@
|
2012-05-31 10:32:54 +00:00
|
|
|
Ox.AnnotationPanel <f> Video Annotation Panel
|
2012-05-21 19:23:16 +00:00
|
|
|
options <o> Options object
|
2018-10-09 16:29:13 +00:00
|
|
|
calendarSize <n|256> calendar size
|
|
|
|
clickLink <f|null> click link callback
|
|
|
|
editable <b|false> if true, annotations can be edited
|
|
|
|
highlight <s|''> highlight given string in annotations
|
|
|
|
highlightAnnotations <b|false> highlight annotations that match selection
|
|
|
|
highlightLayer <s|'*'> l limit highlight to specific layer
|
|
|
|
layers <a|[]> array with annotation objects
|
|
|
|
mapSize <n|256> map size
|
|
|
|
range <s|'all'> all, position, selection
|
|
|
|
selected <s|''> selected annotation
|
|
|
|
showCalendar <b|false> if true, calendar is shown
|
|
|
|
showLayers <o|{}> object with layers to show
|
|
|
|
showMap <b|false> if true, show map
|
|
|
|
showUsers <b|false> if true show user
|
|
|
|
sort <s|'position'> position, start, text
|
|
|
|
width <n|256> panel width
|
2012-07-04 11:29:18 +00:00
|
|
|
self <o> Shared private variable
|
|
|
|
([options[, self]]) -> <o:Ox.SplitPanel> AnnotationPanel Object
|
|
|
|
add <!> add
|
|
|
|
annotationsID <!> annotationsID
|
|
|
|
blur <!> blur
|
|
|
|
change <!> change
|
|
|
|
define <!> define
|
|
|
|
edit <!> edit
|
|
|
|
findannotations <!> findannotations
|
|
|
|
find <!> find
|
|
|
|
focus <!> focus
|
|
|
|
info <!> info
|
|
|
|
open <!> open
|
|
|
|
remove <!> remove
|
|
|
|
resize <!> resize
|
|
|
|
submit <!> submit
|
|
|
|
togglelayer <!> togglelayer
|
|
|
|
toggle* <!> toggle*
|
2011-05-16 08:24:46 +00:00
|
|
|
@*/
|
|
|
|
|
2011-04-22 22:03:10 +00:00
|
|
|
Ox.AnnotationPanel = function(options, self) {
|
|
|
|
|
2011-06-19 17:48:32 +00:00
|
|
|
self = self || {};
|
|
|
|
var that = Ox.Element({}, self)
|
2012-01-02 14:05:14 +00:00
|
|
|
.defaults({
|
2012-01-13 16:25:47 +00:00
|
|
|
calendarSize: 256,
|
2012-01-17 15:43:46 +00:00
|
|
|
clickLink: null,
|
2012-01-02 19:06:36 +00:00
|
|
|
editable: false,
|
2014-09-18 12:27:27 +00:00
|
|
|
enableExport: false,
|
|
|
|
enableImport: false,
|
2012-02-01 05:21:29 +00:00
|
|
|
highlight: '',
|
2018-10-12 12:46:38 +00:00
|
|
|
highlightAnnotations: 'none',
|
2018-08-07 16:12:22 +00:00
|
|
|
highlightLayer: '*',
|
2014-01-19 06:28:59 +00:00
|
|
|
itemName: {singular: 'video', plural: 'videos'},
|
2012-01-12 10:39:05 +00:00
|
|
|
layers: [],
|
2012-01-13 16:25:47 +00:00
|
|
|
mapSize: 256,
|
2012-01-02 19:06:36 +00:00
|
|
|
range: 'all',
|
2012-01-04 17:27:32 +00:00
|
|
|
selected: '',
|
2018-09-12 16:47:34 +00:00
|
|
|
separator: ';',
|
2012-01-13 16:25:47 +00:00
|
|
|
showCalendar: false,
|
2018-10-09 18:06:14 +00:00
|
|
|
showFind: false,
|
2012-01-12 10:39:05 +00:00
|
|
|
showLayers: {},
|
2012-01-13 16:25:47 +00:00
|
|
|
showMap: false,
|
2012-01-12 10:39:05 +00:00
|
|
|
showUsers: false,
|
2012-01-03 19:41:50 +00:00
|
|
|
sort: 'position',
|
2012-01-12 10:39:05 +00:00
|
|
|
width: 256
|
2012-01-02 14:05:14 +00:00
|
|
|
})
|
2012-01-12 10:39:05 +00:00
|
|
|
.options(options || {})
|
2012-05-28 19:35:41 +00:00
|
|
|
.update(function(key, value) {
|
2018-08-07 16:12:22 +00:00
|
|
|
if (key == 'highlight' || key == 'highlightLayer') {
|
2012-05-28 19:35:41 +00:00
|
|
|
self.$folder.forEach(function($folder) {
|
2018-08-07 16:12:22 +00:00
|
|
|
$folder.options({
|
|
|
|
highlight: getHighlight($folder.options('id'))
|
|
|
|
});
|
2012-05-28 19:35:41 +00:00
|
|
|
});
|
2018-10-09 16:29:13 +00:00
|
|
|
} else if (key == 'highlightAnnotations') {
|
|
|
|
self.$folder.forEach(function($folder) {
|
|
|
|
$folder.options({
|
|
|
|
highlightAnnotations: self.options.highlightAnnotations
|
|
|
|
});
|
|
|
|
});
|
2012-05-28 19:35:41 +00:00
|
|
|
} else if (['in', 'out', 'position'].indexOf(key) > -1) {
|
|
|
|
self.$folder.forEach(function($folder) {
|
|
|
|
$folder.options(key, value);
|
|
|
|
});
|
2014-01-22 13:44:20 +00:00
|
|
|
} else if (key == 'layers') {
|
|
|
|
renderFolders();
|
2012-05-28 19:35:41 +00:00
|
|
|
} else if (key == 'selected') {
|
|
|
|
self.options.editable && updateEditMenu();
|
|
|
|
if (value) {
|
2018-08-07 16:12:22 +00:00
|
|
|
var folder = getFolder(value)
|
|
|
|
folder && folder.options({selected: value});
|
2012-05-28 19:35:41 +00:00
|
|
|
} else {
|
|
|
|
self.$folder.forEach(function($folder) {
|
|
|
|
$folder.options({selected: ''});
|
|
|
|
});
|
|
|
|
}
|
2015-03-23 11:56:41 +00:00
|
|
|
} else if (key == 'showLayers') {
|
|
|
|
self.options.layers.forEach(function(layer, index) {
|
|
|
|
self.$folder[index].options({
|
|
|
|
collapsed: !self.options.showLayers[layer.id]
|
|
|
|
});
|
|
|
|
});
|
2012-05-28 19:35:41 +00:00
|
|
|
} else if (key == 'width') {
|
|
|
|
self.$folder.forEach(function($folder) {
|
|
|
|
$folder.options({width: self.options.width - Ox.UI.SCROLLBAR_SIZE});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
})
|
2012-01-12 10:39:05 +00:00
|
|
|
.addClass('OxAnnotationPanel');
|
2011-04-22 22:03:10 +00:00
|
|
|
|
2012-02-16 11:35:03 +00:00
|
|
|
self.editing = false;
|
|
|
|
|
2014-07-23 13:55:09 +00:00
|
|
|
self.languages = getLanguages();
|
|
|
|
self.enabledLanguages = self.languages.map(function(language) {
|
|
|
|
return language.code;
|
|
|
|
});
|
|
|
|
|
2012-01-12 10:39:05 +00:00
|
|
|
if (self.options.showUsers) {
|
2012-02-19 08:59:27 +00:00
|
|
|
self.users = getUsers();
|
|
|
|
self.enabledUsers = self.users;
|
2012-05-30 15:20:58 +00:00
|
|
|
} else {
|
|
|
|
self.enabledUsers = 'all';
|
2012-01-12 10:39:05 +00:00
|
|
|
}
|
2011-04-22 22:03:10 +00:00
|
|
|
|
2012-01-12 10:39:05 +00:00
|
|
|
self.$menubar = Ox.Bar({
|
|
|
|
size: 16
|
2011-04-22 22:03:10 +00:00
|
|
|
})
|
2013-07-08 10:52:11 +00:00
|
|
|
.addClass('OxVideoPlayer')
|
|
|
|
.bindEvent({
|
|
|
|
doubleclick: function(e) {
|
|
|
|
if ($(e.target).is('.OxBar')) {
|
|
|
|
self.$folders.animate({scrollTop: 0}, 250);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2012-01-12 10:39:05 +00:00
|
|
|
|
2013-03-07 12:49:20 +00:00
|
|
|
self.$folders = Ox.Element().css({overflowY: 'scroll'});
|
2012-01-12 10:39:05 +00:00
|
|
|
self.$folder = [];
|
|
|
|
|
2013-03-07 12:49:20 +00:00
|
|
|
renderFolders();
|
2012-02-19 08:59:27 +00:00
|
|
|
renderOptionsMenu();
|
|
|
|
self.options.editable && renderEditMenu();
|
|
|
|
|
2012-01-12 10:39:05 +00:00
|
|
|
that.setElement(
|
2013-07-14 11:39:20 +00:00
|
|
|
self.$panel = Ox.SplitPanel({
|
2012-01-12 10:39:05 +00:00
|
|
|
elements: [
|
|
|
|
{
|
|
|
|
element: self.$menubar,
|
|
|
|
size: 16
|
|
|
|
},
|
|
|
|
{
|
|
|
|
element: self.$folders
|
|
|
|
}
|
|
|
|
],
|
|
|
|
orientation: 'vertical'
|
|
|
|
})
|
|
|
|
);
|
|
|
|
|
2012-02-16 11:35:03 +00:00
|
|
|
function getAnnotation(annotationId) {
|
|
|
|
var found = false, annotation;
|
|
|
|
Ox.forEach(self.options.layers, function(layer, i) {
|
|
|
|
Ox.forEach(layer.items, function(item) {
|
|
|
|
if (item.id == annotationId) {
|
|
|
|
annotation = item;
|
|
|
|
found = true;
|
2012-07-05 08:58:08 +00:00
|
|
|
return false; // break
|
2012-02-16 11:35:03 +00:00
|
|
|
}
|
|
|
|
});
|
2012-07-05 08:58:08 +00:00
|
|
|
if (found) {
|
|
|
|
return false; // break
|
2018-09-12 16:47:34 +00:00
|
|
|
}
|
2012-02-16 11:35:03 +00:00
|
|
|
});
|
|
|
|
return annotation;
|
|
|
|
}
|
|
|
|
|
2012-01-12 10:39:05 +00:00
|
|
|
function getFolder(annotationId) {
|
|
|
|
var found = false, folder;
|
|
|
|
Ox.forEach(self.options.layers, function(layer, i) {
|
|
|
|
Ox.forEach(layer.items, function(item) {
|
|
|
|
if (item.id == annotationId) {
|
|
|
|
folder = self.$folder[i];
|
|
|
|
found = true;
|
2012-07-05 08:58:08 +00:00
|
|
|
return false; // break
|
2012-01-11 12:04:49 +00:00
|
|
|
}
|
2012-01-03 19:41:50 +00:00
|
|
|
});
|
2012-07-05 08:58:08 +00:00
|
|
|
if (found) {
|
|
|
|
return false; // break
|
|
|
|
}
|
2012-01-02 19:06:36 +00:00
|
|
|
});
|
2012-01-12 10:39:05 +00:00
|
|
|
return folder;
|
|
|
|
}
|
|
|
|
|
2018-08-07 16:12:22 +00:00
|
|
|
function getHighlight(layer) {
|
|
|
|
return Ox.contains(['*', layer], self.options.highlightLayer) ? self.options.highlight : '';
|
|
|
|
}
|
|
|
|
|
2014-07-23 13:55:09 +00:00
|
|
|
function getLanguages() {
|
|
|
|
return Ox.sortBy(Ox.map(Ox.unique(Ox.flatten(
|
|
|
|
self.options.layers.map(function(layer) {
|
|
|
|
return layer.items.map(function(item) {
|
|
|
|
return item.languages;
|
|
|
|
});
|
|
|
|
})
|
|
|
|
)), function(language) {
|
|
|
|
return {
|
|
|
|
code: language,
|
|
|
|
name: Ox.getLanguageNameByCode(language)
|
|
|
|
};
|
|
|
|
}), 'name');
|
|
|
|
}
|
|
|
|
|
2012-02-19 08:59:27 +00:00
|
|
|
function getUsers() {
|
|
|
|
return Ox.sort(Ox.unique(Ox.flatten(
|
|
|
|
self.options.layers.map(function(layer) {
|
|
|
|
return layer.items.map(function(item) {
|
|
|
|
return item.user;
|
|
|
|
});
|
|
|
|
})
|
|
|
|
)));
|
|
|
|
}
|
|
|
|
|
2012-02-16 16:35:59 +00:00
|
|
|
function insert(data) {
|
|
|
|
var id = data.id;
|
|
|
|
Ox.InsertHTMLDialog(Ox.extend({
|
|
|
|
callback: function(data) {
|
2014-09-25 16:47:29 +00:00
|
|
|
Ox.$elements[id]
|
2012-02-16 16:35:59 +00:00
|
|
|
.value(data.value)
|
|
|
|
.focusInput(data.position)
|
|
|
|
.triggerEvent('change', data.value);
|
|
|
|
}
|
|
|
|
}, data)).open();
|
|
|
|
}
|
|
|
|
|
2012-02-16 11:35:03 +00:00
|
|
|
function renderEditMenu() {
|
2014-01-19 06:34:03 +00:00
|
|
|
var annotation, annotationTitle, folder, hasManualCalendarOrMap,
|
2015-04-16 20:03:38 +00:00
|
|
|
isDefined, isEditable, isEntity, isEvent, isEventOrPlace, isPlace, isString,
|
2012-02-21 11:30:35 +00:00
|
|
|
key, manageTitle, type, value;
|
2012-02-16 11:35:03 +00:00
|
|
|
if (self.options.selected) {
|
|
|
|
annotation = getAnnotation(self.options.selected);
|
|
|
|
folder = getFolder(self.options.selected);
|
2012-06-10 18:18:03 +00:00
|
|
|
if (annotation && folder) {
|
2012-02-21 11:30:35 +00:00
|
|
|
key = folder.options('id');
|
|
|
|
type = folder.options('type');
|
2014-12-23 10:57:01 +00:00
|
|
|
value = annotation.entity ? annotation.entity.name : annotation.value;
|
2012-02-21 11:30:35 +00:00
|
|
|
isEditable = annotation.editable;
|
2015-04-16 20:03:38 +00:00
|
|
|
isEntity = !!annotation.entity;
|
2012-02-21 11:30:35 +00:00
|
|
|
isEvent = type == 'event';
|
|
|
|
isPlace = type == 'place';
|
|
|
|
isEventOrPlace = isEvent || isPlace;
|
|
|
|
isString = type != 'text';
|
|
|
|
// fixme: absence of annotation[type] may be an error
|
|
|
|
isDefined = isEventOrPlace && !!annotation[type] && !!annotation[type].type;
|
2014-12-16 16:35:39 +00:00
|
|
|
annotationTitle = folder.options('item') + ': "' + Ox.stripTags(value) + '"';
|
2012-02-21 11:30:35 +00:00
|
|
|
}
|
2014-01-19 06:34:03 +00:00
|
|
|
}
|
|
|
|
hasManualCalendarOrMap = self.options.layers.some(function(layer) {
|
|
|
|
return layer.type == 'event' || layer.type == 'place';
|
|
|
|
});
|
2013-05-09 13:03:33 +00:00
|
|
|
manageTitle = Ox._((isDefined ? 'Edit' : 'Define') + ' '
|
|
|
|
+ (isPlace ? 'Place' : isEvent ? 'Event' : 'Place or Event') + '...');
|
2012-02-16 11:35:03 +00:00
|
|
|
self.$editMenuButton && self.$editMenuButton.remove();
|
|
|
|
self.$editMenuButton = Ox.MenuButton({
|
2012-05-24 07:45:33 +00:00
|
|
|
items: [].concat(
|
2014-01-18 01:35:21 +00:00
|
|
|
self.options.layers.map(function(layer, i) {
|
2017-02-15 15:31:25 +00:00
|
|
|
return {
|
|
|
|
id: 'add' + layer.id,
|
|
|
|
disabled: !layer.editable,
|
|
|
|
title: Ox._('Add {0}', [layer.item]),
|
|
|
|
keyboard: i < 9 ? i + 1 + '' : null
|
|
|
|
}
|
2014-01-18 01:35:21 +00:00
|
|
|
}),
|
2012-02-16 12:32:52 +00:00
|
|
|
[
|
2014-01-18 01:35:21 +00:00
|
|
|
{},
|
2013-05-09 13:03:33 +00:00
|
|
|
{id: 'deselect', title: Ox._('Deselect Annotation'), disabled: !self.options.selected || self.editing, keyboard: 'escape'},
|
|
|
|
{id: 'edit', title: Ox._('Edit Annotation'), disabled: !self.options.selected || !isEditable || self.editing, keyboard: 'return'},
|
|
|
|
{id: 'delete', title: Ox._('Delete Annotation'), disabled: !self.options.selected || !isEditable, keyboard: 'delete'},
|
2012-02-16 12:32:52 +00:00
|
|
|
{},
|
2013-05-09 13:03:33 +00:00
|
|
|
{id: 'insert', title: Ox._('Insert...'), disabled: isString || !self.editing, keyboard: 'control i'},
|
|
|
|
{id: 'undo', title: Ox._('Undo Changes'), disabled: !self.editing, keyboard: 'escape'},
|
|
|
|
{id: 'save', title: Ox._('Save Changes'), disabled: !self.editing, keyboard: isString ? 'return' : 'shift return'},
|
2012-02-16 12:32:52 +00:00
|
|
|
],
|
2014-01-19 06:34:03 +00:00
|
|
|
hasManualCalendarOrMap ? [
|
2012-02-16 12:32:52 +00:00
|
|
|
{},
|
|
|
|
{id: 'manage', title: manageTitle, disabled: !self.options.selected || !isEventOrPlace},
|
|
|
|
] : [],
|
|
|
|
isString ? [
|
|
|
|
{},
|
2015-04-16 20:03:38 +00:00
|
|
|
{id: 'annotation', title: annotationTitle, disabled: true}
|
|
|
|
].concat(
|
|
|
|
isEntity ? [
|
2015-04-17 07:36:35 +00:00
|
|
|
{id: 'showentityinfo', title: Ox._('Show Entity Info'), keyboard: 'e'}
|
2015-04-16 20:03:38 +00:00
|
|
|
] : [],
|
|
|
|
[
|
|
|
|
{id: 'findannotations', title: Ox._('Find in All {0}', [Ox.toTitleCase(self.options.itemName.plural)])},
|
|
|
|
{id: 'find', title: Ox._('Find in This {0}', [Ox.toTitleCase(self.options.itemName.singular)])}
|
|
|
|
]
|
|
|
|
) : [],
|
2014-09-18 12:27:27 +00:00
|
|
|
[
|
|
|
|
{},
|
|
|
|
{id: 'import', title: Ox._('Import Annotations...'), disabled: !self.options.enableImport},
|
|
|
|
{id: 'export', title: Ox._('Export Annotations...'), disabled: !self.options.enableExport},
|
|
|
|
]
|
2012-02-16 12:32:52 +00:00
|
|
|
),
|
2012-02-16 11:35:03 +00:00
|
|
|
maxWidth: 256,
|
|
|
|
style: 'square',
|
|
|
|
title: 'edit',
|
2013-05-09 13:03:33 +00:00
|
|
|
tooltip: Ox._('Editing Options'),
|
2012-02-16 11:35:03 +00:00
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'right'})
|
|
|
|
.bindEvent({
|
|
|
|
click: function(data) {
|
2014-01-17 15:10:02 +00:00
|
|
|
if (Ox.startsWith(data.id, 'add')) {
|
|
|
|
that.triggerEvent('add', {layer: data.id.slice(3), value: ''});
|
|
|
|
} else if (data.id == 'delete') {
|
2012-02-16 11:35:03 +00:00
|
|
|
getFolder(self.options.selected).removeItem();
|
|
|
|
} else if (data.id == 'deselect') {
|
|
|
|
getFolder(self.options.selected).options({selected: ''});
|
|
|
|
} else if (data.id == 'edit') {
|
|
|
|
getFolder(self.options.selected).editItem();
|
2014-09-18 12:27:27 +00:00
|
|
|
} else if (data.id == 'export') {
|
|
|
|
that.triggerEvent('exportannotations');
|
2012-02-16 11:35:03 +00:00
|
|
|
} else if (data.id == 'find') {
|
2012-02-16 12:32:52 +00:00
|
|
|
that.triggerEvent('find', {value: value});
|
|
|
|
} else if (data.id == 'findannotations') {
|
|
|
|
that.triggerEvent('findannotations', {key: key, value: value});
|
2014-09-18 12:27:27 +00:00
|
|
|
} else if (data.id == 'import') {
|
|
|
|
that.triggerEvent('importannotations');
|
2012-02-16 16:35:59 +00:00
|
|
|
} else if (data.id == 'insert') {
|
2012-02-16 18:04:25 +00:00
|
|
|
var id = $('.OxEditableElement div.OxInput').data('oxid'),
|
|
|
|
element = $('.OxEditableElement textarea.OxInput')[0];
|
|
|
|
insert({
|
|
|
|
end: element.selectionEnd,
|
|
|
|
id: id,
|
2012-05-24 09:47:33 +00:00
|
|
|
selection: element.value.slice(
|
|
|
|
element.selectionStart, element.selectionEnd
|
|
|
|
),
|
2012-02-16 18:04:25 +00:00
|
|
|
start: element.selectionStart,
|
|
|
|
value: element.value
|
|
|
|
});
|
2012-02-16 11:35:03 +00:00
|
|
|
} else if (data.id == 'manage') {
|
|
|
|
that.triggerEvent('define', {
|
2012-02-21 10:10:39 +00:00
|
|
|
id: getAnnotation(self.options.selected)[type].id,
|
2012-02-16 11:35:03 +00:00
|
|
|
type: type
|
|
|
|
});
|
|
|
|
} else if (data.id == 'save') {
|
|
|
|
// ...
|
2015-04-16 20:03:38 +00:00
|
|
|
} else if (data.id == 'showentityinfo') {
|
|
|
|
that.triggerEvent('showentityinfo', annotation.entity);
|
2012-02-16 11:35:03 +00:00
|
|
|
} else if (data.id == 'undo') {
|
|
|
|
// ...
|
|
|
|
}
|
2012-02-16 12:32:52 +00:00
|
|
|
},
|
|
|
|
hide: function() {
|
2016-03-16 07:28:12 +00:00
|
|
|
var folder = self.options.selected
|
|
|
|
? getFolder(self.options.selected)
|
|
|
|
: null;
|
|
|
|
folder ? folder.gainFocus() : that.triggerEvent('focus');
|
2012-02-16 11:35:03 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo(self.$menubar);
|
|
|
|
}
|
2013-03-07 12:49:20 +00:00
|
|
|
function renderFolder(layer) {
|
|
|
|
var index = Ox.getIndexById(self.options.layers, layer.id),
|
|
|
|
item = Ox.getObjectById(layer.items, self.options.selected),
|
|
|
|
selected = item ? item.id : '';
|
|
|
|
self.$folder[index] = Ox.AnnotationFolder(
|
|
|
|
Ox.extend({
|
|
|
|
clickLink: self.options.clickLink,
|
|
|
|
collapsed: !self.options.showLayers[layer.id],
|
|
|
|
editable: self.options.editable,
|
2018-08-07 16:12:22 +00:00
|
|
|
highlight: getHighlight(layer.id),
|
2018-10-09 16:29:13 +00:00
|
|
|
highlightAnnotations: self.options.highlightAnnotations,
|
2014-12-16 13:02:18 +00:00
|
|
|
id: layer.id,
|
2013-03-07 12:49:20 +00:00
|
|
|
'in': self.options['in'],
|
2015-04-15 17:56:18 +00:00
|
|
|
keyboard: index < 9 ? index + 1 + '' : '',
|
2013-03-07 12:49:20 +00:00
|
|
|
out: self.options.out,
|
|
|
|
position: self.options.position,
|
|
|
|
range: self.options.range,
|
|
|
|
selected: selected,
|
2018-09-12 16:47:34 +00:00
|
|
|
separator: self.options.separator,
|
2013-03-07 12:49:20 +00:00
|
|
|
sort: self.options.sort,
|
|
|
|
width: self.options.width - Ox.UI.SCROLLBAR_SIZE
|
2015-04-14 18:48:10 +00:00
|
|
|
}, layer, layer.type == 'event' ? {
|
2013-03-07 12:49:20 +00:00
|
|
|
showWidget: self.options.showCalendar,
|
|
|
|
widgetSize: self.options.calendarSize
|
|
|
|
} : layer.type == 'place' ? {
|
|
|
|
showWidget: self.options.showMap,
|
|
|
|
widgetSize: self.options.mapSize
|
|
|
|
} : {})
|
|
|
|
)
|
|
|
|
.bindEvent({
|
|
|
|
add: function(data) {
|
|
|
|
that.triggerEvent('add', Ox.extend({layer: layer.id}, data));
|
|
|
|
},
|
|
|
|
blur: function() {
|
|
|
|
that.triggerEvent('blur');
|
|
|
|
},
|
|
|
|
change: function(data) {
|
|
|
|
that.triggerEvent('change', Ox.extend({layer: layer.id}, data));
|
|
|
|
},
|
|
|
|
edit: function() {
|
|
|
|
self.editing = true;
|
|
|
|
renderEditMenu();
|
|
|
|
that.triggerEvent('edit');
|
|
|
|
},
|
|
|
|
info: function(data) {
|
|
|
|
that.triggerEvent('info', {layer: layer.id});
|
|
|
|
},
|
|
|
|
insert: insert,
|
2015-04-17 07:36:35 +00:00
|
|
|
key_e: function(data) {
|
|
|
|
var entity = getAnnotation(self.options.selected).entity;
|
|
|
|
entity && that.triggerEvent('showentityinfo', entity);
|
|
|
|
},
|
2013-03-07 12:49:20 +00:00
|
|
|
open: function() {
|
|
|
|
that.triggerEvent('open');
|
|
|
|
},
|
|
|
|
remove: function(data) {
|
|
|
|
that.triggerEvent('remove', Ox.extend({layer: layer.id}, data));
|
|
|
|
},
|
|
|
|
resizewidget: function(data) {
|
|
|
|
that.triggerEvent('resize' + (
|
|
|
|
layer.type == 'event' ? 'calendar' : 'map'
|
|
|
|
), data);
|
|
|
|
},
|
|
|
|
select: function(data) {
|
|
|
|
selectAnnotation(data, index);
|
|
|
|
},
|
2013-05-08 16:53:33 +00:00
|
|
|
selectnext: function() {
|
2013-03-07 12:49:20 +00:00
|
|
|
selectNext(layer.id, 1);
|
|
|
|
},
|
2013-05-08 16:53:33 +00:00
|
|
|
selectprevious: function() {
|
2013-03-07 12:49:20 +00:00
|
|
|
selectNext(layer.id, -1);
|
|
|
|
},
|
|
|
|
selectnone: selectNone,
|
|
|
|
submit: function(data) {
|
|
|
|
that.triggerEvent('submit', Ox.extend({layer: layer.id}, data));
|
|
|
|
},
|
|
|
|
togglelayer: function(data) {
|
|
|
|
self.options.showLayers[layer.id] = !data.collapsed;
|
|
|
|
that.triggerEvent('togglelayer', Ox.extend({layer: layer.id}, data));
|
|
|
|
},
|
|
|
|
togglewidget: function(data) {
|
|
|
|
that.triggerEvent('toggle' + (
|
|
|
|
layer.type == 'event' ? 'calendar' : 'map'
|
|
|
|
), data);
|
|
|
|
}
|
2015-02-06 10:16:13 +00:00
|
|
|
})
|
|
|
|
.appendTo(self.$folders);
|
2013-03-07 12:49:20 +00:00
|
|
|
[
|
|
|
|
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9',
|
|
|
|
'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',
|
2023-07-09 09:31:37 +00:00
|
|
|
'slash', 'space',
|
|
|
|
'control_c', 'control_v',
|
2013-03-07 12:49:20 +00:00
|
|
|
].forEach(function(key) {
|
2015-02-06 10:16:13 +00:00
|
|
|
key = 'key.' + key;
|
2013-03-07 12:49:20 +00:00
|
|
|
self.$folder[index].bindEvent(key, function() {
|
|
|
|
that.triggerEvent(key);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderFolders() {
|
|
|
|
self.$folders.empty();
|
|
|
|
self.options.layers.forEach(function(layer, index) {
|
|
|
|
renderFolder(layer);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2012-02-19 08:59:27 +00:00
|
|
|
function renderOptionsMenu() {
|
|
|
|
self.$optionsMenuButton && self.$optionsMenuButton.remove();
|
|
|
|
self.$optionsMenuButton = Ox.MenuButton({
|
2012-05-24 07:45:33 +00:00
|
|
|
items: [].concat(
|
2012-02-19 08:59:27 +00:00
|
|
|
[
|
2013-05-09 13:03:33 +00:00
|
|
|
{id: 'showannotations', title: Ox._('Show Annotations'), disabled: true},
|
2012-02-19 08:59:27 +00:00
|
|
|
{group: 'range', min: 1, max: 1, items: [
|
2013-05-09 13:03:33 +00:00
|
|
|
{id: 'all', title: Ox._('All'), checked: self.options.range == 'all'},
|
|
|
|
{id: 'selection', title: Ox._('In Current Selection'), checked: self.options.range == 'selection'},
|
|
|
|
{id: 'position', title: Ox._('At Current Position'), checked: self.options.range == 'position'}
|
2012-02-19 08:59:27 +00:00
|
|
|
]},
|
|
|
|
{},
|
2013-05-09 13:03:33 +00:00
|
|
|
{id: 'sortannotations', title: Ox._('Sort Annotations'), disabled: true},
|
2012-02-19 08:59:27 +00:00
|
|
|
{group: 'sort', min: 1, max: 1, items: [
|
2013-05-09 13:03:33 +00:00
|
|
|
{id: 'position', title: Ox._('By Position'), checked: self.options.sort == 'position'},
|
|
|
|
{id: 'duration', title: Ox._('By Duration'), checked: self.options.sort == 'duration'},
|
2015-12-14 12:16:13 +00:00
|
|
|
{id: 'text', title: Ox._('By Text'), checked: self.options.sort == 'text'},
|
|
|
|
{id: 'created', title: Ox._('By Creation Time'), checked: self.options.sort == 'created'}
|
2018-10-09 18:06:14 +00:00
|
|
|
]}
|
|
|
|
],
|
|
|
|
self.options.showFind ? [
|
2018-08-07 16:46:33 +00:00
|
|
|
{},
|
|
|
|
{id: 'results', title: Ox._('Find Annotations'), disabled: true},
|
|
|
|
{group: 'results', max: 1, items: [
|
|
|
|
{
|
|
|
|
id: 'result_*',
|
|
|
|
title: Ox._('All'),
|
|
|
|
checked: self.options.highlightLayer == '*'
|
|
|
|
}
|
|
|
|
].concat(self.options.layers.map(function(result) {
|
|
|
|
return {
|
|
|
|
id: 'result_' + result.id,
|
|
|
|
title: result.title,
|
|
|
|
checked: result.id == self.options.highlightLayer
|
|
|
|
};
|
|
|
|
}))}
|
2018-10-09 18:06:14 +00:00
|
|
|
] : [],
|
2018-10-09 16:29:13 +00:00
|
|
|
self.options.editable ? [
|
|
|
|
{},
|
|
|
|
{id: 'highlightannotations', title: Ox._('Highlight Annotations'), disabled: true},
|
|
|
|
{group: 'highlight', max: 1, items: [
|
2018-10-12 12:46:38 +00:00
|
|
|
{id: 'none', title: Ox._('None'), checked: self.options.highlightAnnotations == 'none'},
|
|
|
|
{id: 'value', title: Ox._('Same Value'), checked: self.options.highlightAnnotations == 'value'},
|
|
|
|
{id: 'selection', title: Ox._('Same Selection'), checked: self.options.highlightAnnotations == 'selection'}
|
2018-10-09 16:29:13 +00:00
|
|
|
]}
|
|
|
|
] : [],
|
|
|
|
self.languages.length > 1 ? [
|
|
|
|
{},
|
|
|
|
{id: 'languages', title: Ox._('Show Languages'), disabled: true},
|
|
|
|
{group: 'languages', min: 1, max: -1, items: self.languages.map(function(language) {
|
|
|
|
return {
|
|
|
|
id: language.code,
|
|
|
|
title: Ox._(language.name),
|
|
|
|
checked: Ox.contains(self.enabledLanguages, language.code)
|
|
|
|
};
|
|
|
|
})}
|
|
|
|
] : [],
|
2012-02-19 09:01:13 +00:00
|
|
|
self.options.showUsers && self.users.length ? [
|
2012-02-19 08:59:27 +00:00
|
|
|
{},
|
2013-05-09 13:03:33 +00:00
|
|
|
{id: 'users', title: Ox._('Show Users'), disabled: true},
|
2015-04-16 19:02:06 +00:00
|
|
|
{group: 'users', min: 0, max: -1, items: self.users.map(function(user) {
|
2015-04-15 17:20:07 +00:00
|
|
|
return {
|
|
|
|
id: 'user_' + user,
|
|
|
|
title: Ox.encodeHTMLEntities(user),
|
|
|
|
checked: self.enabledUsers == 'all' || Ox.contains(self.enabledUsers, user)
|
2012-02-19 08:59:27 +00:00
|
|
|
};
|
|
|
|
})}
|
2015-04-15 17:20:07 +00:00
|
|
|
] : [],
|
|
|
|
self.options.showUsers && self.users.length > 1 ? [
|
|
|
|
{},
|
|
|
|
{id: 'allusers', title: Ox._('Show All Users')},
|
|
|
|
{id: 'nousers', title: Ox._('Show No Users')}
|
2012-02-19 08:59:27 +00:00
|
|
|
] : []
|
|
|
|
),
|
|
|
|
style: 'square',
|
|
|
|
title: 'set',
|
2013-05-09 13:03:33 +00:00
|
|
|
tooltip: Ox._('Options'),
|
2012-02-19 08:59:27 +00:00
|
|
|
type: 'image'
|
|
|
|
})
|
|
|
|
.css({float: 'left'})
|
|
|
|
.bindEvent({
|
|
|
|
change: function(data) {
|
|
|
|
var set = {};
|
2014-07-23 13:55:09 +00:00
|
|
|
if (data.id == 'languages') {
|
|
|
|
self.enabledLanguages = data.checked.map(function(checked) {
|
|
|
|
return checked.id;
|
|
|
|
});
|
|
|
|
self.$folder.forEach(function($folder) {
|
|
|
|
$folder.options({languages: self.enabledLanguages});
|
|
|
|
});
|
|
|
|
} else if (data.id == 'users') {
|
2012-02-19 08:59:27 +00:00
|
|
|
self.enabledUsers = data.checked.map(function(checked) {
|
2015-04-15 17:20:07 +00:00
|
|
|
return checked.id.slice(5);
|
2012-02-19 08:59:27 +00:00
|
|
|
});
|
|
|
|
self.$folder.forEach(function($folder) {
|
|
|
|
$folder.options({users: self.enabledUsers});
|
|
|
|
});
|
2018-08-07 16:46:33 +00:00
|
|
|
} else if (data.id == 'results') {
|
|
|
|
var layer = data.checked[0].id.split('_').pop()
|
2018-10-09 16:29:13 +00:00
|
|
|
that.options({highlightLayer: layer});
|
2018-08-07 16:46:33 +00:00
|
|
|
that.triggerEvent('highlightlayer', self.options.highlightLayer);
|
2018-10-09 16:29:13 +00:00
|
|
|
} else if (data.id == 'highlight') {
|
2018-10-12 12:46:38 +00:00
|
|
|
var value = data.checked[0].id
|
2018-10-09 16:29:13 +00:00
|
|
|
that.options({highlightAnnotations: value});
|
|
|
|
that.triggerEvent('highlightannotations', self.options.highlightAnnotations);
|
2015-04-16 13:59:02 +00:00
|
|
|
} else {
|
|
|
|
self.options[data.id] = data.checked[0].id;
|
|
|
|
set[data.id] = self.options[data.id];
|
|
|
|
self.$folder.forEach(function($folder) {
|
|
|
|
$folder.options(set);
|
|
|
|
});
|
|
|
|
that.triggerEvent('annotations' + data.id, set);
|
|
|
|
}
|
|
|
|
},
|
|
|
|
click: function(data) {
|
|
|
|
if (data.id == 'allusers') {
|
2015-04-15 18:01:51 +00:00
|
|
|
self.enabledUsers = Ox.clone(self.users);
|
2015-04-15 17:20:07 +00:00
|
|
|
self.users.forEach(function(user) {
|
|
|
|
self.$optionsMenuButton.checkItem('user_' + user);
|
|
|
|
});
|
2015-04-15 18:01:51 +00:00
|
|
|
self.$folder.forEach(function($folder) {
|
|
|
|
$folder.options({users: self.enabledUsers});
|
|
|
|
});
|
2015-04-15 17:20:07 +00:00
|
|
|
} else if (data.id == 'nousers') {
|
2015-04-15 18:01:51 +00:00
|
|
|
self.enabledUsers = [];
|
2015-04-15 17:20:07 +00:00
|
|
|
self.users.forEach(function(user) {
|
|
|
|
self.$optionsMenuButton.uncheckItem('user_' + user);
|
|
|
|
});
|
2015-04-15 18:01:51 +00:00
|
|
|
self.$folder.forEach(function($folder) {
|
|
|
|
$folder.options({users: self.enabledUsers});
|
|
|
|
});
|
2012-02-19 08:59:27 +00:00
|
|
|
}
|
|
|
|
},
|
|
|
|
hide: function() {
|
2015-04-15 09:10:46 +00:00
|
|
|
var folder = self.options.selected
|
|
|
|
? getFolder(self.options.selected)
|
|
|
|
: null;
|
|
|
|
folder ? folder.gainFocus() : that.triggerEvent('focus');
|
2012-02-19 08:59:27 +00:00
|
|
|
}
|
|
|
|
})
|
|
|
|
.appendTo(self.$menubar);
|
|
|
|
}
|
|
|
|
|
2012-01-17 09:25:58 +00:00
|
|
|
function scrollToSelected(type) {
|
2012-02-05 11:08:56 +00:00
|
|
|
var $item = that.find('.OxEditableElement.OxSelected'),
|
|
|
|
itemHeight = $item.height() + (type == 'text' ? 8 : 0),
|
2012-03-13 12:26:13 +00:00
|
|
|
itemTop = ($item.offset() || {}).top,
|
2012-02-05 11:08:56 +00:00
|
|
|
itemBottom = itemTop + itemHeight,
|
|
|
|
height = self.$folders.height(),
|
|
|
|
scrollTop = self.$folders.scrollTop(),
|
|
|
|
top = self.$folders.offset().top;
|
|
|
|
if (itemTop < top || itemBottom > top + height) {
|
|
|
|
if (itemTop < top) {
|
|
|
|
scrollTop += itemTop - top;
|
|
|
|
} else {
|
|
|
|
scrollTop += itemBottom - top - height;
|
2012-01-17 09:25:58 +00:00
|
|
|
}
|
2012-02-05 11:08:56 +00:00
|
|
|
self.$folders.animate({
|
|
|
|
scrollTop: scrollTop + 'px'
|
|
|
|
}, 0);
|
|
|
|
}
|
2012-01-17 09:25:58 +00:00
|
|
|
}
|
|
|
|
|
2012-01-12 10:39:05 +00:00
|
|
|
function selectAnnotation(data, index) {
|
|
|
|
if (data.id) {
|
2012-02-16 11:35:03 +00:00
|
|
|
Ox.forEach(self.$folder, function($folder, i) {
|
|
|
|
if (i != index && $folder.options('selected')) {
|
|
|
|
self.deselecting = true;
|
|
|
|
$folder.options({selected: ''});
|
|
|
|
self.deselecting = false;
|
2012-07-05 08:58:08 +00:00
|
|
|
return false; // break
|
2012-02-16 11:35:03 +00:00
|
|
|
}
|
2012-01-12 10:39:05 +00:00
|
|
|
});
|
2012-01-17 09:25:58 +00:00
|
|
|
scrollToSelected(self.options.layers[index].type);
|
2012-01-12 10:39:05 +00:00
|
|
|
}
|
2012-02-16 11:35:03 +00:00
|
|
|
if (!self.deselecting) {
|
|
|
|
self.options.selected = data.id;
|
|
|
|
self.options.editable && renderEditMenu();
|
|
|
|
that.triggerEvent('select', data);
|
|
|
|
}
|
2012-01-02 19:06:36 +00:00
|
|
|
}
|
|
|
|
|
2012-02-01 19:33:10 +00:00
|
|
|
function selectNone() {
|
|
|
|
if (self.options.selected) {
|
|
|
|
getFolder(self.options.selected).options({selected: ''});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function selectNext(layer, direction) {
|
|
|
|
var index = Ox.mod(
|
|
|
|
Ox.getIndexById(self.options.layers, layer) + direction,
|
|
|
|
self.options.layers.length
|
|
|
|
);
|
|
|
|
self.$folder[index].selectItem(direction == 1 ? 0 : -1);
|
|
|
|
}
|
|
|
|
|
2012-01-12 10:39:05 +00:00
|
|
|
function updateEditMenu() {
|
|
|
|
var action = self.options.selected ? 'enableItem' : 'disableItem';
|
|
|
|
self.$editMenuButton[action]('edit');
|
|
|
|
self.$editMenuButton[action]('delete');
|
2011-04-22 22:03:10 +00:00
|
|
|
}
|
|
|
|
|
2014-09-02 14:12:55 +00:00
|
|
|
function updateLanguages() {
|
|
|
|
var languages = self.languages,
|
|
|
|
enabledLanguages = self.enabledLanguages;
|
|
|
|
self.languages = getLanguages();
|
|
|
|
self.enabledLanguages = self.languages.filter(function(language) {
|
2014-09-03 11:23:19 +00:00
|
|
|
// enabled if it was enabled, was just added, or is the only
|
|
|
|
// language
|
2014-09-02 14:12:55 +00:00
|
|
|
return Ox.contains(enabledLanguages, language)
|
2014-09-03 11:23:19 +00:00
|
|
|
|| !Ox.contains(languages, language)
|
|
|
|
|| self.languages.length == 1;
|
2014-09-02 14:12:55 +00:00
|
|
|
}).map(function(language) {
|
|
|
|
return language.code;
|
|
|
|
});
|
2014-09-03 11:23:19 +00:00
|
|
|
if (
|
|
|
|
self.languages.length == 1
|
|
|
|
&& !Ox.contains(enabledLanguages, self.languages[0].code)
|
|
|
|
) {
|
|
|
|
// last remaining language was enabled by removing all other
|
|
|
|
// languages
|
|
|
|
self.$folder.forEach(function($folder) {
|
|
|
|
$folder.options({languages: self.enabledLanguages});
|
|
|
|
});
|
|
|
|
}
|
2014-09-02 14:12:55 +00:00
|
|
|
}
|
|
|
|
|
2012-05-21 10:38:18 +00:00
|
|
|
/*@
|
|
|
|
addItem <f> add item
|
2013-03-07 12:49:20 +00:00
|
|
|
(layer, item) -> <o> AnnotationPanel
|
2012-05-21 10:38:18 +00:00
|
|
|
@*/
|
2012-01-12 10:39:05 +00:00
|
|
|
that.addItem = function(layer, item) {
|
2012-02-16 11:35:03 +00:00
|
|
|
// called from addannotation callback
|
2012-01-12 10:39:05 +00:00
|
|
|
var i = Ox.getIndexById(self.options.layers, layer);
|
|
|
|
self.$folder[i].addItem(item);
|
2014-09-02 14:12:55 +00:00
|
|
|
updateLanguages();
|
2012-02-19 08:59:27 +00:00
|
|
|
self.users = getUsers();
|
|
|
|
if (self.enabledUsers != 'all' && self.enabledUsers.indexOf(item.user) == -1) {
|
|
|
|
self.enabledUsers.push(item.user);
|
|
|
|
self.$folder[i].options({users: self.enabledUsers});
|
|
|
|
}
|
|
|
|
renderOptionsMenu();
|
2012-02-17 12:18:26 +00:00
|
|
|
renderEditMenu();
|
2013-03-07 12:49:20 +00:00
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*@
|
|
|
|
addLayer <f> Add a layer
|
|
|
|
(layer[, index]) -> <o> AnnotationPanel
|
|
|
|
@*/
|
|
|
|
that.addLayer = function(layer, index) {
|
|
|
|
// FIXME: add/remove/updateLayer don't update users yet
|
|
|
|
index = index || self.options.layers.length;
|
|
|
|
self.options.layers.splice(index, 0, layer);
|
|
|
|
renderFolders();
|
|
|
|
return that;
|
2011-06-15 14:36:01 +00:00
|
|
|
};
|
2011-04-22 22:03:10 +00:00
|
|
|
|
2012-05-21 10:38:18 +00:00
|
|
|
/*@
|
2018-09-12 16:47:34 +00:00
|
|
|
blurItem <f> Blur selected item
|
2013-03-07 12:49:20 +00:00
|
|
|
() -> <o> AnnotationPanel
|
2012-05-21 10:38:18 +00:00
|
|
|
@*/
|
2012-01-09 20:25:38 +00:00
|
|
|
that.blurItem = function() {
|
2012-02-16 11:35:03 +00:00
|
|
|
self.editing = false;
|
2020-09-22 10:48:08 +00:00
|
|
|
var $folder = getFolder(self.options.selected)
|
|
|
|
if ($folder) {
|
|
|
|
$folder.blurItem();
|
|
|
|
}
|
2012-02-17 12:18:26 +00:00
|
|
|
renderEditMenu();
|
2013-03-07 12:49:20 +00:00
|
|
|
return that;
|
2011-06-15 14:36:01 +00:00
|
|
|
};
|
2011-05-16 10:49:48 +00:00
|
|
|
|
2012-05-21 10:38:18 +00:00
|
|
|
/*@
|
2013-03-07 12:49:20 +00:00
|
|
|
editItem <f> Put selected item into edit mode
|
|
|
|
() -> <o> AnnotationPanel
|
2012-05-21 10:38:18 +00:00
|
|
|
@*/
|
2012-01-12 10:39:05 +00:00
|
|
|
that.editItem = function() {
|
2012-02-16 11:35:03 +00:00
|
|
|
self.editing = true;
|
2012-01-12 10:39:05 +00:00
|
|
|
getFolder(self.options.selected).editItem();
|
2012-02-17 12:18:26 +00:00
|
|
|
renderEditMenu();
|
2013-03-07 12:49:20 +00:00
|
|
|
return that;
|
2011-06-19 17:48:32 +00:00
|
|
|
};
|
2011-05-19 10:18:39 +00:00
|
|
|
|
2014-09-18 14:43:00 +00:00
|
|
|
that.getCurrentAnnotations = function() {
|
|
|
|
var annotations = {};
|
|
|
|
self.options.layers.forEach(function(layer) {
|
|
|
|
annotations[layer.id] = self.$folder[
|
|
|
|
Ox.getIndexById(self.options.layers, layer.id)
|
|
|
|
].getCurrentAnnotations();
|
|
|
|
});
|
|
|
|
return annotations;
|
|
|
|
};
|
|
|
|
|
2012-05-21 10:38:18 +00:00
|
|
|
/*@
|
2018-09-12 16:47:34 +00:00
|
|
|
removeItem <f> Remove selected item
|
2013-03-07 12:49:20 +00:00
|
|
|
() -> <o> AnnotationPanel
|
2012-05-21 10:38:18 +00:00
|
|
|
@*/
|
2012-02-19 14:37:55 +00:00
|
|
|
that.removeItem = function(remove) {
|
|
|
|
if (remove) {
|
|
|
|
// remove initiated by video editor
|
|
|
|
getFolder(self.options.selected).removeItem();
|
|
|
|
} else {
|
|
|
|
// called from removeannotation callback
|
|
|
|
self.options.selected = '';
|
2014-09-02 14:12:55 +00:00
|
|
|
updateLanguages();
|
2012-02-19 14:37:55 +00:00
|
|
|
self.users = getUsers();
|
|
|
|
renderOptionsMenu();
|
|
|
|
renderEditMenu();
|
|
|
|
}
|
2013-03-07 12:49:20 +00:00
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*@
|
|
|
|
removeLayer <f> Remove a layer
|
|
|
|
(id) -> <o> AnnotationPanel
|
|
|
|
@*/
|
|
|
|
that.removeLayer = function(id) {
|
|
|
|
var $folder = getFolder(self.options.selected),
|
|
|
|
index = Ox.getIndexById(self.options.layers, id);
|
|
|
|
if (self.$folder[index] == $folder) {
|
|
|
|
$folder.blurItem();
|
|
|
|
}
|
|
|
|
self.options.layers.splice(index, 1);
|
|
|
|
renderFolders();
|
|
|
|
return that;
|
2012-02-19 08:59:27 +00:00
|
|
|
};
|
|
|
|
|
2012-05-21 10:38:18 +00:00
|
|
|
/*@
|
2013-03-07 12:49:20 +00:00
|
|
|
updateItem <f> Update an item
|
|
|
|
(id, item) -> <o> AnnotationPanel
|
2012-05-21 10:38:18 +00:00
|
|
|
@*/
|
2012-01-31 10:57:09 +00:00
|
|
|
that.updateItem = function(id, item) {
|
2012-02-16 11:35:03 +00:00
|
|
|
// called from editannotation callback
|
2012-02-17 12:18:26 +00:00
|
|
|
// on the first update of a new annotation, the id will change
|
2012-01-31 10:57:09 +00:00
|
|
|
self.options.selected = item.id;
|
2020-09-18 08:41:13 +00:00
|
|
|
var $folder = getFolder(id);
|
|
|
|
if ($folder) {
|
|
|
|
$folder.updateItem(id, item);
|
|
|
|
}
|
2014-09-02 14:12:55 +00:00
|
|
|
updateLanguages();
|
|
|
|
renderOptionsMenu();
|
2012-02-17 12:18:26 +00:00
|
|
|
renderEditMenu();
|
2014-09-02 14:12:55 +00:00
|
|
|
return that;
|
2012-01-13 16:25:47 +00:00
|
|
|
};
|
|
|
|
|
2013-03-07 12:49:20 +00:00
|
|
|
/*@
|
|
|
|
updateLayer <f> Update a layer
|
|
|
|
(id, items) -> <o> AnnotationPanel
|
|
|
|
@*/
|
|
|
|
that.updateLayer = function(id, items) {
|
|
|
|
var $folder = getFolder(self.options.selected),
|
|
|
|
index = Ox.getIndexById(self.options.layers, id);
|
|
|
|
if (self.$folder[index] == $folder) {
|
|
|
|
$folder.blurItem();
|
2018-09-12 16:47:34 +00:00
|
|
|
}
|
2013-03-07 12:49:20 +00:00
|
|
|
self.options.layers[index].items = items;
|
2013-03-09 13:02:30 +00:00
|
|
|
self.$folder[index].replaceWith(
|
|
|
|
self.$folder[index] = renderFolder(self.options.layers[index])
|
2013-03-07 12:49:20 +00:00
|
|
|
);
|
|
|
|
return that;
|
|
|
|
};
|
|
|
|
|
2011-04-22 22:03:10 +00:00
|
|
|
return that;
|
2018-09-12 16:47:34 +00:00
|
|
|
|
2012-01-13 16:25:47 +00:00
|
|
|
};
|