add layer option to populate default value for new annotations

This commit is contained in:
j 2018-10-09 16:32:35 +02:00
parent 1d40ceca8f
commit d7fa7efcbc
3 changed files with 15 additions and 2 deletions

View file

@ -864,6 +864,8 @@ examples (config.SITENAME.jsonc) that are part of this pan.do/ra distribution.
"canPlayClips": If true, clips from this layer will play for users "canPlayClips": If true, clips from this layer will play for users
with canPlayClips access with canPlayClips access
"entity": ID of the referenced entity (if type is "entity") "entity": ID of the referenced entity (if type is "entity")
"getDefaults": function in pandora namespace that gets called
to populate defaults for new annotations. i.e. getCurrentFrameAnnotation
"hasEvents": If true, the calendar will be populated with matches from "hasEvents": If true, the calendar will be populated with matches from
this layer this layer
"hasPlaces": If true, the map will be populated with matches from this "hasPlaces": If true, the map will be populated with matches from this

View file

@ -114,7 +114,8 @@ pandora.ui.editor = function(data) {
// async to not capture keyboard input // async to not capture keyboard input
setTimeout(function() { setTimeout(function() {
var created = Ox.formatDate(new Date(), '%Y-%m-%dT%H:%M:%SZ'), var created = Ox.formatDate(new Date(), '%Y-%m-%dT%H:%M:%SZ'),
type = Ox.getObjectById(pandora.site.layers, data.layer).type; layer = Ox.getObjectById(pandora.site.layers, data.layer),
type = layer.type;
that.addAnnotation(data.layer, Ox.extend( that.addAnnotation(data.layer, Ox.extend(
{ {
created: created, created: created,
@ -131,7 +132,8 @@ pandora.ui.editor = function(data) {
place: {lat: null, lng: null} place: {lat: null, lng: null}
} : type == 'event' ? { } : type == 'event' ? {
event: {start: '', end: ''} event: {start: '', end: ''}
} : {} } : {},
layer.getDefaults ? pandora[layer.getDefaults](data) : {}
)); ));
Ox.Request.clearCache(); Ox.Request.clearCache();
}); });

View file

@ -1274,6 +1274,15 @@ pandora.getClipVideos = function(clip, resolution) {
})); }));
}; };
pandora.getCurrentFrameAnnotation = function(data) {
var ui = pandora.user.ui,
position = ui.videoPoints[ui.item].position,
resolution = Ox.max(pandora.site.video.resolutions);
return {
value: '<img src="/' + ui.item + '/' + resolution + 'p' + position + '.jpg">\n\n'
};
};
(function() { (function() {
var itemTitles = {}, documentTitles = {}; var itemTitles = {}, documentTitles = {};
pandora.getWindowTitle = function(itemData) { pandora.getWindowTitle = function(itemData) {