2014-02-14 16:49:01 +00:00
|
|
|
|
'use strict';
|
|
|
|
|
|
|
|
|
|
pandora.ui.embedDialog = function(/*[url, ]callback*/) {
|
|
|
|
|
|
|
|
|
|
if (arguments.length == 1) {
|
|
|
|
|
var url, callback = arguments[0];
|
|
|
|
|
} else {
|
|
|
|
|
var url = arguments[0], callback = arguments[1];
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 09:42:48 +00:00
|
|
|
|
var api,
|
|
|
|
|
defaults = {},
|
2014-02-14 16:49:01 +00:00
|
|
|
|
duration,
|
|
|
|
|
formWidth = 612,
|
|
|
|
|
iframeHeight = Ox.last(pandora.site.video.resolutions),
|
|
|
|
|
iframeWidth = Math.round(iframeHeight * pandora.site.video.previewRatio),
|
2014-09-26 12:12:25 +00:00
|
|
|
|
listWidth = 128 + Ox.UI.SCROLLBAR_SIZE,
|
2014-02-14 16:49:01 +00:00
|
|
|
|
labelWidth = 192,
|
2014-09-26 12:12:25 +00:00
|
|
|
|
dialogWidth = listWidth + formWidth + 32 + Ox.UI.SCROLLBAR_SIZE,
|
2014-02-16 06:47:09 +00:00
|
|
|
|
dialogHeight = 384,
|
2014-02-16 11:02:30 +00:00
|
|
|
|
linkPlaceholder = '...',
|
2014-02-16 12:04:52 +00:00
|
|
|
|
options = {},
|
2014-02-14 16:49:01 +00:00
|
|
|
|
positionPlaceholder = '00:00:00.000',
|
|
|
|
|
sites = [pandora.site.site].concat(pandora.site.sites).map(function(site) {
|
|
|
|
|
return {id: site.url, title: site.url, https: site.https};
|
|
|
|
|
}),
|
2014-02-16 06:47:09 +00:00
|
|
|
|
ui = pandora.user.ui,
|
2014-02-16 09:42:48 +00:00
|
|
|
|
videoRatio,
|
2014-02-14 16:49:01 +00:00
|
|
|
|
|
|
|
|
|
views = [
|
|
|
|
|
{
|
|
|
|
|
id: 'info',
|
2014-02-16 07:20:52 +00:00
|
|
|
|
title: Ox._('Info'),
|
2014-02-16 12:04:52 +00:00
|
|
|
|
description: Ox._('Embed a Poster and Basic Metadata'),
|
2014-02-14 16:49:01 +00:00
|
|
|
|
inputs: ['item']
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'video',
|
2014-02-16 07:20:52 +00:00
|
|
|
|
title: Ox._('Video'),
|
2014-02-16 12:04:52 +00:00
|
|
|
|
description: Ox._('Embed a Clip or a Full Video'),
|
2014-02-14 16:49:01 +00:00
|
|
|
|
inputs: [
|
|
|
|
|
'item', 'position', 'in', 'out', 'annotation', 'title',
|
|
|
|
|
'showTimeline', 'showAnnotations', 'matchRatio'
|
|
|
|
|
]
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'timeline',
|
2014-02-16 07:20:52 +00:00
|
|
|
|
title: Ox._('Timeline'),
|
2014-02-16 12:04:52 +00:00
|
|
|
|
description: Ox._('Embed a Timeline'),
|
2014-02-14 16:49:01 +00:00
|
|
|
|
inputs: ['item', 'position', 'title']
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'list',
|
2014-02-16 07:20:52 +00:00
|
|
|
|
title: Ox._('List'),
|
2014-02-16 12:35:23 +00:00
|
|
|
|
description: Ox._('Embed a List Icon with Description'),
|
2014-02-14 16:49:01 +00:00
|
|
|
|
inputs: ['list']
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'grid',
|
2014-02-16 07:20:52 +00:00
|
|
|
|
title: Ox._('Grid'),
|
2014-02-16 12:04:52 +00:00
|
|
|
|
description: Ox._('Embed Movies as a Grid'),
|
2014-02-14 16:49:01 +00:00
|
|
|
|
inputs: ['find', 'sort', 'title']
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'map',
|
2014-02-16 07:20:52 +00:00
|
|
|
|
title: Ox._('Map'),
|
2014-02-16 12:04:52 +00:00
|
|
|
|
description: Ox._('Embed a Map View'),
|
2014-02-16 12:35:23 +00:00
|
|
|
|
inputs: ['mapMode', 'item', 'find', 'sort', 'title']
|
2014-02-14 16:49:01 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'calendar',
|
2014-02-16 07:20:52 +00:00
|
|
|
|
title: Ox._('Calendar'),
|
2014-02-16 12:35:23 +00:00
|
|
|
|
description: Ox._('Embed a Calendar View'),
|
|
|
|
|
inputs: ['mapMode', 'item', 'find', 'sort', 'title']
|
2014-02-14 16:49:01 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'document',
|
2014-02-16 07:20:52 +00:00
|
|
|
|
title: Ox._('Document'),
|
2014-02-16 12:04:52 +00:00
|
|
|
|
description: Ox._('Embed a Document'),
|
2014-02-15 10:57:04 +00:00
|
|
|
|
inputs: ['document']
|
2014-02-14 16:49:01 +00:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
id: 'edit',
|
2014-02-16 07:20:52 +00:00
|
|
|
|
title: Ox._('Edit'),
|
2014-02-16 12:04:52 +00:00
|
|
|
|
description: Ox._('Embed an Edited Video'),
|
2014-02-15 10:57:04 +00:00
|
|
|
|
inputs: [
|
2014-02-16 12:35:23 +00:00
|
|
|
|
'edit', 'editMode', 'position',
|
2014-02-15 10:57:04 +00:00
|
|
|
|
'showTimeline', 'showAnnotations', 'matchRatio'
|
|
|
|
|
]
|
2014-02-14 16:49:01 +00:00
|
|
|
|
}
|
|
|
|
|
].map(function(item, index) {
|
|
|
|
|
return Ox.extend(item, {index: index});
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
viewInputs = Ox.unique(Ox.flatten(views.map(function(view) {
|
|
|
|
|
return view.inputs;
|
|
|
|
|
}))),
|
|
|
|
|
|
|
|
|
|
$list = Ox.TableList({
|
|
|
|
|
columns: [
|
|
|
|
|
{
|
|
|
|
|
id: 'title',
|
|
|
|
|
visible: true,
|
2014-09-26 12:12:25 +00:00
|
|
|
|
width: 128 - Ox.UI.SCROLLBAR_SIZE
|
2014-02-14 16:49:01 +00:00
|
|
|
|
}
|
|
|
|
|
],
|
|
|
|
|
items: views,
|
|
|
|
|
max: 1,
|
|
|
|
|
min: 1,
|
|
|
|
|
scrollbarVisible: true,
|
|
|
|
|
selected: ['info'],
|
|
|
|
|
sort: [{key: 'index', operator: '+'}],
|
|
|
|
|
unique: 'id'
|
|
|
|
|
})
|
|
|
|
|
.bindEvent({
|
|
|
|
|
select: function() {
|
|
|
|
|
updateHTML();
|
|
|
|
|
updateForm();
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
$input = {
|
|
|
|
|
advanced: Ox.Checkbox({
|
|
|
|
|
title: Ox._('Show Advanced Options'),
|
|
|
|
|
value: pandora.user.ui.showAdvancedEmbedOptions
|
|
|
|
|
})
|
|
|
|
|
.css({float: 'left', margin: '4px'})
|
|
|
|
|
.bindEvent({
|
|
|
|
|
change: function(data) {
|
|
|
|
|
pandora.UI.set({showAdvancedEmbedOptions: data.value});
|
|
|
|
|
updateForm();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
|
2014-02-16 11:02:30 +00:00
|
|
|
|
$form = getForm(),
|
|
|
|
|
|
2014-02-14 16:49:01 +00:00
|
|
|
|
$panel = Ox.SplitPanel({
|
|
|
|
|
elements: [
|
2014-09-26 12:12:25 +00:00
|
|
|
|
{element: $list, size: 128 + Ox.UI.SCROLLBAR_SIZE},
|
2014-02-14 16:49:01 +00:00
|
|
|
|
{element: $form}
|
|
|
|
|
],
|
|
|
|
|
orientation: 'horizontal'
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
that = Ox.Dialog({
|
|
|
|
|
buttons: [
|
|
|
|
|
Ox.Button({
|
|
|
|
|
id: 'cancel',
|
|
|
|
|
title: Ox._('Cancel'),
|
|
|
|
|
width: 64
|
|
|
|
|
})
|
|
|
|
|
.bindEvent({
|
|
|
|
|
click: function() {
|
|
|
|
|
that.close();
|
|
|
|
|
}
|
|
|
|
|
}),
|
|
|
|
|
Ox.Button({
|
|
|
|
|
id: 'insert',
|
|
|
|
|
title: Ox._('Insert'),
|
|
|
|
|
width: 64
|
|
|
|
|
})
|
|
|
|
|
.bindEvent({
|
|
|
|
|
click: function() {
|
2014-02-19 06:02:04 +00:00
|
|
|
|
callback && callback($input.html.options('value'));
|
2014-02-14 16:49:01 +00:00
|
|
|
|
that.close();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
],
|
|
|
|
|
closeButton: true,
|
2014-02-16 11:02:30 +00:00
|
|
|
|
content: $panel,
|
2014-02-14 16:49:01 +00:00
|
|
|
|
fixedSize: true,
|
|
|
|
|
height: dialogHeight,
|
|
|
|
|
removeOnClose: true,
|
|
|
|
|
title: Ox._('Embed'),
|
|
|
|
|
width: dialogWidth
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
$($input.advanced.find('.OxButton')[0]).css({margin: 0});
|
|
|
|
|
$(that.find('.OxBar')[1]).append($input.advanced);
|
|
|
|
|
|
2014-02-16 12:04:52 +00:00
|
|
|
|
updateOptions();
|
|
|
|
|
updateAPI(function() {
|
|
|
|
|
updateDefaults(true);
|
|
|
|
|
});
|
2014-02-16 09:42:48 +00:00
|
|
|
|
|
2014-02-17 06:15:24 +00:00
|
|
|
|
function formatCondition(condition) {
|
|
|
|
|
// See Ox.URL (constructCondition)
|
|
|
|
|
var key = condition.key == '*' ? '' : condition.key,
|
|
|
|
|
operator = condition.operator,
|
|
|
|
|
value = (
|
|
|
|
|
Ox.isArray(condition.value) ? condition.value : [condition.value]
|
|
|
|
|
).map(formatValue).join(',');
|
|
|
|
|
if (!key) {
|
|
|
|
|
operator = operator.replace('=', '');
|
|
|
|
|
} else if (operator.indexOf('^') > -1) {
|
|
|
|
|
operator = operator.replace('^', '=');
|
|
|
|
|
value += '*';
|
|
|
|
|
} else if (operator.indexOf('$') > -1) {
|
|
|
|
|
operator = operator.replace('$', '=');
|
|
|
|
|
value = '*' + value;
|
|
|
|
|
}
|
|
|
|
|
return [key, operator, value].join('');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatFind(find) {
|
|
|
|
|
// See Ox.URL (constructFind)
|
|
|
|
|
return find.conditions.map(function(condition) {
|
|
|
|
|
return condition.conditions
|
|
|
|
|
? '(' + formatFind(condition) + ')'
|
|
|
|
|
: formatCondition(condition);
|
|
|
|
|
}).join(find.operator);
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-14 16:49:01 +00:00
|
|
|
|
function formatHTML() {
|
|
|
|
|
var type = $input.type.value();
|
|
|
|
|
return type == 'link'
|
|
|
|
|
? '<a href="' + formatURL()
|
2014-02-16 12:04:52 +00:00
|
|
|
|
+ '">' + $input.link.value()
|
2014-02-14 16:49:01 +00:00
|
|
|
|
+ '</a>'
|
|
|
|
|
: '<iframe src="' + formatURL()
|
|
|
|
|
+ '" width="' + $input.width.value()
|
|
|
|
|
+ '" height="' + $input.height.value()
|
|
|
|
|
+ '" frameborder="0" allowfullscreen></iframe>';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function formatURL() {
|
2014-02-15 11:53:32 +00:00
|
|
|
|
var type = $input.type.value(),
|
2014-02-14 16:49:01 +00:00
|
|
|
|
view = $list.options('selected')[0],
|
2014-02-15 11:53:32 +00:00
|
|
|
|
data = Ox.map($input, function($element, key) {
|
|
|
|
|
return Ox.contains(Ox.getObjectById(views, view).inputs, key)
|
2014-02-17 08:24:01 +00:00
|
|
|
|
&& (
|
|
|
|
|
!Ox.contains(['map', 'calendar'], view)
|
|
|
|
|
|| ($input.mapMode.value() == 'item' && key != 'find')
|
|
|
|
|
|| ($input.mapMode.value() == 'find' && key != 'item')
|
|
|
|
|
)
|
2014-02-15 11:53:32 +00:00
|
|
|
|
&& $element.value ? $element.value() : void 0;
|
|
|
|
|
}),
|
2014-02-14 16:49:01 +00:00
|
|
|
|
options = Ox.serialize({
|
|
|
|
|
title: data.title || void 0,
|
|
|
|
|
showTimeline: data.showTimeline || void 0,
|
2014-02-17 06:27:18 +00:00
|
|
|
|
timeline: data.timeline || void 0,
|
2014-02-14 16:49:01 +00:00
|
|
|
|
showAnnotations: data.showAnnotations || void 0,
|
|
|
|
|
showLayers: data.showAnnotations && data.showLayers ? data.showLayers : void 0,
|
2014-02-16 12:35:23 +00:00
|
|
|
|
matchRatio: Ox.contains(['video', 'edit'], view) ? data.matchRatio || void 0 : void 0,
|
|
|
|
|
showInfo: Ox.contains(['list', 'text'], view) || (view == 'edit' && !!$input.editMode.value()) || void 0
|
2014-02-14 16:49:01 +00:00
|
|
|
|
}, true),
|
|
|
|
|
position = (
|
|
|
|
|
data.position ? [data.position] : []
|
|
|
|
|
).concat(
|
|
|
|
|
data['in'] || data.out ? [data['in'], data.out] : []
|
|
|
|
|
).join(',')
|
2014-02-15 11:53:32 +00:00
|
|
|
|
+ (data['annotation'] || '');
|
2014-02-14 16:49:01 +00:00
|
|
|
|
return Ox.encodeHTMLEntities(
|
|
|
|
|
(
|
|
|
|
|
type == 'iframe'
|
|
|
|
|
? (pandora.site.site.https ? 'https' : 'http')
|
|
|
|
|
+ '://' + pandora.site.site.url + '/'
|
|
|
|
|
: '/'
|
|
|
|
|
)
|
|
|
|
|
+ (
|
2014-02-16 12:35:23 +00:00
|
|
|
|
Ox.contains(['info', 'video', 'timeline'], view) || data.mapMode == 'item' ? data.item
|
2014-02-14 16:49:01 +00:00
|
|
|
|
: view == 'list' ? 'list==' + data.list
|
|
|
|
|
: view == 'document' ? 'documents/' + data.document
|
|
|
|
|
: view == 'edit' ? 'edits/' + data.edit
|
|
|
|
|
: view == 'text' ? 'texts/' + data.text
|
|
|
|
|
: ''
|
|
|
|
|
)
|
|
|
|
|
+ (
|
2014-02-15 11:53:32 +00:00
|
|
|
|
Ox.contains(['info', 'timeline'], view) ? '/' + view
|
2014-02-17 08:24:01 +00:00
|
|
|
|
: view == 'video' ? '/player'
|
2014-02-16 12:35:23 +00:00
|
|
|
|
: Ox.contains(['grid', 'map', 'calendar'], view) ? (data.mapMode == 'item' ? '/' : '') + view
|
2014-02-14 16:49:01 +00:00
|
|
|
|
: ''
|
|
|
|
|
)
|
2014-02-17 08:24:01 +00:00
|
|
|
|
+ (data.sort ? '/' + data.sort : '')
|
2014-02-17 07:23:41 +00:00
|
|
|
|
+ (data.find ? '/' + formatFind(data.find) : '')
|
2014-02-14 16:49:01 +00:00
|
|
|
|
+ (position ? '/' + position : '')
|
|
|
|
|
+ '#embed'
|
|
|
|
|
+ (options ? '?' + options : '')
|
|
|
|
|
).replace(/ /g, '_');
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-17 06:15:24 +00:00
|
|
|
|
function formatValue(value) {
|
|
|
|
|
// See Ox.URL (encodeValue)
|
2014-02-17 06:27:18 +00:00
|
|
|
|
var chars = '*=&|()#%',
|
2014-02-17 06:15:24 +00:00
|
|
|
|
ret = '';
|
|
|
|
|
value.toString().split('').forEach(function(char) {
|
|
|
|
|
var index = chars.indexOf(char);
|
|
|
|
|
ret += index > -1
|
|
|
|
|
? '%' + char.charCodeAt(0).toString(16).toUpperCase()
|
|
|
|
|
: char;
|
|
|
|
|
});
|
2014-02-17 06:27:18 +00:00
|
|
|
|
return ret.replace(/_/g, '%09')
|
|
|
|
|
.replace(/\s/g, '_')
|
|
|
|
|
.replace(/</g, '%0E')
|
|
|
|
|
.replace(/>/g, '%0F');
|
2014-02-17 06:15:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-14 16:49:01 +00:00
|
|
|
|
function getForm() {
|
|
|
|
|
|
|
|
|
|
var css = {display: 'inline-block', margin: '4px 0'},
|
|
|
|
|
view = $list.options('selected')[0];
|
|
|
|
|
|
|
|
|
|
$form = Ox.Element()
|
|
|
|
|
.attr({id: 'form'})
|
|
|
|
|
.css({padding: '16px', overflowY: 'auto'});
|
|
|
|
|
|
2014-02-16 11:02:30 +00:00
|
|
|
|
$input.description = Ox.Label({
|
|
|
|
|
textAlign: 'center',
|
|
|
|
|
title: '',
|
|
|
|
|
width: formWidth
|
|
|
|
|
})
|
|
|
|
|
.css(css)
|
|
|
|
|
.appendTo($form);
|
2014-02-14 16:49:01 +00:00
|
|
|
|
|
|
|
|
|
$input.type = Ox.ButtonGroup({
|
|
|
|
|
buttons: [
|
2017-01-25 20:48:44 +00:00
|
|
|
|
{id: 'link', title: Ox._('Embed in Text'), width: formWidth / 2, selected: true},
|
2014-02-16 07:20:52 +00:00
|
|
|
|
{id: 'iframe', title: Ox._('Embed in External Site'), width: formWidth / 2}
|
2014-02-14 16:49:01 +00:00
|
|
|
|
],
|
|
|
|
|
selectable: true
|
|
|
|
|
})
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
|
|
|
|
change: function() {
|
|
|
|
|
updateForm();
|
2014-02-16 11:02:30 +00:00
|
|
|
|
updateHTML();
|
2014-02-14 16:49:01 +00:00
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
$input.html = Ox.Input({
|
|
|
|
|
height: 64,
|
|
|
|
|
type: 'textarea',
|
|
|
|
|
width: formWidth
|
|
|
|
|
})
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
|
|
|
|
change: function(data) {
|
|
|
|
|
// ...
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
2014-02-16 11:02:30 +00:00
|
|
|
|
$input.link = Ox.Input({
|
2014-02-14 16:49:01 +00:00
|
|
|
|
label: Ox._('Link Text'),
|
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
|
width: formWidth,
|
2014-02-16 11:02:30 +00:00
|
|
|
|
value: linkPlaceholder
|
2014-02-14 16:49:01 +00:00
|
|
|
|
})
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
|
|
|
|
change: function(data) {
|
2014-02-16 11:02:30 +00:00
|
|
|
|
$input.link.options({
|
|
|
|
|
value: Ox.sanitizeHTML(data.value).trim() || linkPlaceholder
|
2014-02-14 16:49:01 +00:00
|
|
|
|
});
|
|
|
|
|
updateHTML();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
$input.size = Ox.FormElementGroup({
|
|
|
|
|
elements: [
|
|
|
|
|
Ox.Label({
|
|
|
|
|
overlap: 'right',
|
|
|
|
|
textAlign: 'right',
|
|
|
|
|
title: Ox._('Frame Size'),
|
|
|
|
|
width: labelWidth
|
|
|
|
|
}),
|
|
|
|
|
Ox.InputGroup({
|
|
|
|
|
inputs: [
|
|
|
|
|
$input.width = Ox.Input({id: 'width', placeholder: 'Width', value: iframeWidth, width: (formWidth - labelWidth - 16) / 2}),
|
|
|
|
|
$input.height = Ox.Input({id: 'height', placeholder: 'Height', value: iframeHeight, width: (formWidth - labelWidth - 16) / 2})
|
|
|
|
|
],
|
|
|
|
|
separators: [{title: '×', width: 16}]
|
|
|
|
|
})
|
|
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
|
|
|
|
change: updateHTML
|
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
space().appendTo($form);
|
|
|
|
|
|
|
|
|
|
$input.site = Ox.FormElementGroup({
|
|
|
|
|
elements: [
|
|
|
|
|
Ox.Label({
|
|
|
|
|
overlap: 'right',
|
|
|
|
|
textAlign: 'right',
|
|
|
|
|
title: Ox._('Site'),
|
|
|
|
|
width: labelWidth
|
|
|
|
|
}),
|
|
|
|
|
$input.protocol = Ox.Select({
|
|
|
|
|
id: 'protocol',
|
|
|
|
|
items: [
|
|
|
|
|
{id: 'http', title: 'http://'},
|
|
|
|
|
{id: 'https', title: 'https://', disabled: !pandora.site.site.https}
|
|
|
|
|
],
|
|
|
|
|
overlap: 'right',
|
|
|
|
|
value: pandora.site.site.https ? 'https' : 'http',
|
|
|
|
|
width: 80
|
|
|
|
|
}),
|
|
|
|
|
$input.hostname = Ox.SelectInput({
|
2014-02-16 07:39:18 +00:00
|
|
|
|
inputWidth: 192,
|
2014-02-14 16:49:01 +00:00
|
|
|
|
id: 'hostname',
|
|
|
|
|
items: sites.concat([{id: 'other', title: Ox._('Other...')}]),
|
|
|
|
|
max: 1,
|
|
|
|
|
min: 1,
|
|
|
|
|
placeholder: 'example.com',
|
|
|
|
|
value: pandora.site.site.url,
|
|
|
|
|
width: formWidth - labelWidth - 80
|
|
|
|
|
})
|
|
|
|
|
]
|
|
|
|
|
})
|
|
|
|
|
.addClass('advanced')
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
2014-02-16 09:42:48 +00:00
|
|
|
|
change: function() {
|
|
|
|
|
updateHTML();
|
2014-02-16 12:04:52 +00:00
|
|
|
|
updateAPI(updateDefaults);
|
2014-02-16 09:42:48 +00:00
|
|
|
|
}
|
2014-02-14 16:49:01 +00:00
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
2014-02-16 12:35:23 +00:00
|
|
|
|
$input.mapMode = Ox.Select({
|
2014-02-16 06:47:09 +00:00
|
|
|
|
items: [
|
|
|
|
|
{id: 'item', title: Ox._(pandora.site.itemName.singular)},
|
|
|
|
|
{id: 'find', title: Ox._('Query')}
|
|
|
|
|
],
|
2014-02-16 07:20:52 +00:00
|
|
|
|
label: ' ',
|
2014-02-16 06:47:09 +00:00
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
|
width: formWidth
|
|
|
|
|
})
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
|
|
|
|
change: function() {
|
|
|
|
|
updateForm();
|
|
|
|
|
updateHTML();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
2014-02-14 16:49:01 +00:00
|
|
|
|
$input.item = Ox.Input({
|
|
|
|
|
label: Ox._(pandora.site.itemName.singular),
|
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
|
width: formWidth,
|
2014-02-16 11:02:30 +00:00
|
|
|
|
value: ''
|
2014-02-14 16:49:01 +00:00
|
|
|
|
})
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
2014-02-16 09:42:48 +00:00
|
|
|
|
change: function() {
|
|
|
|
|
updateHTML();
|
|
|
|
|
validateId('item');
|
|
|
|
|
}
|
2014-02-14 16:49:01 +00:00
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
$input.list = Ox.Input({
|
|
|
|
|
label: Ox._('List'),
|
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
|
width: formWidth,
|
2014-02-16 11:02:30 +00:00
|
|
|
|
value: ''
|
2014-02-14 16:49:01 +00:00
|
|
|
|
})
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
2014-02-16 09:42:48 +00:00
|
|
|
|
change: function() {
|
|
|
|
|
updateHTML();
|
|
|
|
|
validateId('list');
|
|
|
|
|
}
|
2014-02-14 16:49:01 +00:00
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
$input.document = Ox.Input({
|
|
|
|
|
label: Ox._('Document'),
|
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
|
width: formWidth,
|
2014-02-16 11:02:30 +00:00
|
|
|
|
value: ''
|
2014-02-14 16:49:01 +00:00
|
|
|
|
})
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
2014-02-16 09:42:48 +00:00
|
|
|
|
change: function() {
|
|
|
|
|
updateHTML();
|
|
|
|
|
validateId('document');
|
|
|
|
|
}
|
2014-02-14 16:49:01 +00:00
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
$input.edit = Ox.Input({
|
|
|
|
|
label: Ox._('Edit{noun}'),
|
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
|
width: formWidth,
|
2014-02-16 11:02:30 +00:00
|
|
|
|
value: ''
|
2014-02-14 16:49:01 +00:00
|
|
|
|
})
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
2014-02-16 09:42:48 +00:00
|
|
|
|
change: function() {
|
|
|
|
|
updateHTML();
|
|
|
|
|
validateId('edit');
|
|
|
|
|
}
|
2014-02-14 16:49:01 +00:00
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
$input.text = Ox.Input({
|
|
|
|
|
label: Ox._('Text'),
|
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
|
width: formWidth,
|
2014-02-16 11:02:30 +00:00
|
|
|
|
value: ''
|
2014-02-14 16:49:01 +00:00
|
|
|
|
})
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
2014-02-16 09:42:48 +00:00
|
|
|
|
change: function() {
|
|
|
|
|
updateHTML();
|
|
|
|
|
validateId('text');
|
|
|
|
|
}
|
2014-02-14 16:49:01 +00:00
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
2014-02-16 12:35:23 +00:00
|
|
|
|
$input.editMode = Ox.Select({
|
|
|
|
|
items: [
|
|
|
|
|
{id: 'icon', title: Ox._('Icon and Description')},
|
|
|
|
|
{id: 'video', title: Ox._('Video')}
|
|
|
|
|
],
|
|
|
|
|
label: 'Embed',
|
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
|
width: formWidth
|
|
|
|
|
})
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
|
|
|
|
change: function() {
|
|
|
|
|
updateForm();
|
|
|
|
|
updateHTML();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
2014-02-14 16:49:01 +00:00
|
|
|
|
$input.position = Ox.Input({
|
|
|
|
|
label: Ox._('Position'),
|
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
|
placeholder: positionPlaceholder,
|
|
|
|
|
width: formWidth
|
|
|
|
|
})
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
|
|
|
|
change: function(data) {
|
2014-02-16 12:04:52 +00:00
|
|
|
|
validatePoint('position');
|
2014-02-14 16:49:01 +00:00
|
|
|
|
updateHTML()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
$input['in'] = Ox.Input({
|
|
|
|
|
label: Ox._('In Point'),
|
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
|
placeholder: positionPlaceholder,
|
|
|
|
|
width: formWidth
|
|
|
|
|
})
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
|
|
|
|
change: function(data) {
|
2014-02-16 12:04:52 +00:00
|
|
|
|
validatePoint('in');
|
2014-02-14 16:49:01 +00:00
|
|
|
|
updateHTML();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
$input.out = Ox.Input({
|
|
|
|
|
label: Ox._('Out Point'),
|
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
|
placeholder: positionPlaceholder,
|
|
|
|
|
width: formWidth
|
|
|
|
|
})
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
|
|
|
|
change: function(data) {
|
2014-02-16 12:04:52 +00:00
|
|
|
|
validatePoint('out');
|
2014-02-14 16:49:01 +00:00
|
|
|
|
updateHTML();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
$input.annotation = Ox.Input({
|
|
|
|
|
label: Ox._('Annotation'),
|
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
|
width: formWidth
|
|
|
|
|
})
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
|
|
|
|
change: function(data) {
|
2014-02-16 12:04:52 +00:00
|
|
|
|
validatePoint('annotation');
|
2014-02-14 16:49:01 +00:00
|
|
|
|
updateHTML();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
$input.find = pandora.ui.filterForm({mode: 'embed'})
|
|
|
|
|
.css(css)
|
2014-02-17 06:15:24 +00:00
|
|
|
|
.bindEvent({
|
|
|
|
|
change: updateHTML
|
|
|
|
|
})
|
2014-02-14 16:49:01 +00:00
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
$input.sort = Ox.Select({
|
|
|
|
|
items: (
|
|
|
|
|
Ox.contains(['map', 'calendar'], view)
|
|
|
|
|
? pandora.site.clipKeys.map(function(key) {
|
|
|
|
|
return Ox.extend(Ox.clone(key), {
|
|
|
|
|
title: Ox._('Clip {0}', [Ox._(key.title)])
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
: []
|
|
|
|
|
).concat(
|
|
|
|
|
pandora.site.sortKeys.map(function(key) {
|
|
|
|
|
return Ox.extend(Ox.clone(key), {
|
|
|
|
|
title: Ox._(key.title)
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
),
|
|
|
|
|
label: Ox._('Sort by'),
|
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
|
width: formWidth
|
|
|
|
|
})
|
|
|
|
|
.addClass('advanced')
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
|
|
|
|
change: updateHTML
|
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
$input.title = Ox.Input({
|
|
|
|
|
label: Ox._('Title'),
|
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
|
width: formWidth,
|
|
|
|
|
value: ''
|
|
|
|
|
})
|
|
|
|
|
.addClass('advanced')
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
|
|
|
|
change: updateHTML
|
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
$input.showTimeline = Ox.Checkbox({
|
|
|
|
|
label: Ox._('Show Timeline'),
|
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
|
value: false,
|
|
|
|
|
width: formWidth
|
|
|
|
|
})
|
|
|
|
|
.addClass('advanced')
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
|
|
|
|
change: function() {
|
|
|
|
|
updateForm();
|
|
|
|
|
updateHTML();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
$input.timeline = Ox.Select({
|
2014-02-17 06:27:18 +00:00
|
|
|
|
items: pandora.site.timelines,
|
2014-02-14 16:49:01 +00:00
|
|
|
|
label: Ox._('Timeline'),
|
|
|
|
|
labelWidth: labelWidth,
|
2014-02-17 06:27:18 +00:00
|
|
|
|
value: pandora.site.user.ui.videoTimeline,
|
2014-02-14 16:49:01 +00:00
|
|
|
|
width: formWidth
|
|
|
|
|
})
|
|
|
|
|
.addClass('advanced')
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
|
|
|
|
change: updateHTML
|
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
$input.showAnnotations = Ox.Checkbox({
|
|
|
|
|
label: Ox._('Show Annotations'),
|
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
|
value: false,
|
|
|
|
|
width: formWidth
|
|
|
|
|
})
|
|
|
|
|
.addClass('advanced')
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
|
|
|
|
change: function() {
|
|
|
|
|
updateForm();
|
|
|
|
|
updateHTML();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
$input.showLayersLabel = Ox.Label({
|
|
|
|
|
title: Ox._('Show Layers'),
|
|
|
|
|
width: formWidth
|
|
|
|
|
})
|
|
|
|
|
.addClass('advanced')
|
|
|
|
|
.css(css)
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
$input.showLayers = Ox.CheckboxGroup({
|
|
|
|
|
checkboxes: pandora.site.layers.map(function(layer) {
|
|
|
|
|
return {id: layer.id, title: layer.title};
|
|
|
|
|
}),
|
|
|
|
|
max: pandora.site.layers.length,
|
|
|
|
|
min: 0,
|
|
|
|
|
type: 'list',
|
|
|
|
|
value: pandora.site.layers.map(function(layer) {
|
|
|
|
|
return layer.id;
|
|
|
|
|
}),
|
|
|
|
|
width: formWidth - labelWidth
|
|
|
|
|
})
|
|
|
|
|
.addClass('advanced')
|
|
|
|
|
.css({display: 'inline-block', margin: '4px 0 4px ' + labelWidth + 'px'})
|
|
|
|
|
.bindEvent({
|
|
|
|
|
change: updateHTML
|
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
$input.matchRatio = Ox.Checkbox({
|
|
|
|
|
label: Ox._('Match Video Ratio'),
|
|
|
|
|
labelWidth: labelWidth,
|
|
|
|
|
value: true,
|
|
|
|
|
width: formWidth
|
|
|
|
|
})
|
|
|
|
|
.addClass('advanced')
|
|
|
|
|
.css(css)
|
|
|
|
|
.bindEvent({
|
|
|
|
|
change: updateHTML
|
|
|
|
|
})
|
|
|
|
|
.appendTo($form);
|
|
|
|
|
|
|
|
|
|
updateHTML();
|
|
|
|
|
updateForm();
|
|
|
|
|
|
|
|
|
|
function space() {
|
|
|
|
|
return $('<div>').css({height: '16px', width: formWidth + 'px'});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $form;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 09:42:48 +00:00
|
|
|
|
function limitPoint(value, min, max) {
|
|
|
|
|
if (Ox.typeOf(min) == 'number') {
|
|
|
|
|
min = Ox.formatDuration(min)
|
|
|
|
|
}
|
|
|
|
|
if (Ox.typeOf(max) == 'number') {
|
|
|
|
|
max = Ox.formatDuration(max)
|
|
|
|
|
}
|
|
|
|
|
return Ox.formatDuration(
|
|
|
|
|
Ox.limit(
|
|
|
|
|
Ox.parseDuration(value),
|
|
|
|
|
Ox.parseDuration(min),
|
|
|
|
|
Ox.parseDuration(max)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function parseURL(callback) {
|
|
|
|
|
var parsed = Ox.parseURL(url),
|
|
|
|
|
protocol = parsed.protocol.replace(/:$/, ''),
|
|
|
|
|
hostname = parsed.hostname,
|
|
|
|
|
isSameSite = hostname == $input.hostname.value();
|
|
|
|
|
(isSameSite ? Ox.noop : updateAPI)(site, function() {
|
|
|
|
|
pandora.URL.parse(parsed.pathname + parsed.search + parsed.hash, function(state) {
|
|
|
|
|
var isSameItem = isSameSite && state.item == $input.item.value(),
|
|
|
|
|
query = {};
|
|
|
|
|
if (state.hash && state.hash.query) {
|
|
|
|
|
state.hash.query.forEach(function(condition) {
|
|
|
|
|
query[condition.key] = condition.value;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
(isSameItem ? Ox.noop : updateDuration)(function() {
|
|
|
|
|
if (duration) {
|
|
|
|
|
item = $input.item.value();
|
|
|
|
|
}
|
|
|
|
|
Ox.forEach({
|
|
|
|
|
protocol: protocol,
|
|
|
|
|
site: site,
|
|
|
|
|
item: item,
|
|
|
|
|
position: Ox.isArray(state.span) && state.span.length == 3
|
|
|
|
|
? Ox.formatDuration(state.span[0]) : '',
|
|
|
|
|
'in': Ox.isArray(state.span)
|
|
|
|
|
? Ox.formatDuration(state.span[state.span.length - 2]) : '',
|
|
|
|
|
out: Ox.isArray(state.span)
|
|
|
|
|
? Ox.formatDuration(state.span[state.span.length - 1]) : '',
|
|
|
|
|
annotation: Ox.isString(state.span) ? state.span : '',
|
|
|
|
|
title: query.title || '',
|
|
|
|
|
showTimeline: query.showTimeline || false,
|
|
|
|
|
timeline: query.timeline || pandora.site.user.ui.videoTimeline,
|
|
|
|
|
showAnnotations: query.showAnnotations || false,
|
|
|
|
|
showLayers: query.showLayers || pandora.site.layers.map(function(layer) {
|
|
|
|
|
return layer.id;
|
|
|
|
|
})
|
|
|
|
|
}, function(value, key) {
|
|
|
|
|
$input[key].options({value: value});
|
|
|
|
|
});
|
|
|
|
|
callback();
|
|
|
|
|
})
|
|
|
|
|
});
|
2014-02-14 16:49:01 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 09:42:48 +00:00
|
|
|
|
function updateAPI(callback) {
|
|
|
|
|
api = Ox.API({
|
|
|
|
|
url: $input.protocol.value() + '://' + $input.hostname.value() + '/api/'
|
|
|
|
|
}, function() {
|
|
|
|
|
api.getEmbedDefaults(function(result) {
|
|
|
|
|
defaults = result.data;
|
|
|
|
|
callback && callback();
|
|
|
|
|
});
|
|
|
|
|
});
|
2014-02-16 06:47:09 +00:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 12:04:52 +00:00
|
|
|
|
function updateDefaults(keepValues) {
|
|
|
|
|
$input.width.options({value: Math.round(defaults.videoResolution * defaults.videoRatio)});
|
|
|
|
|
$input.height.options({value: defaults.videoResolution});
|
|
|
|
|
['item', 'document', 'list', 'edit', 'text'].forEach(function(key) {
|
|
|
|
|
if (!keepValues || !$input[key].options('value')) {
|
|
|
|
|
$input[key].options({value: defaults[key]});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
['position', 'in', 'out'].forEach(function(key) {
|
|
|
|
|
validatePoint(key);
|
|
|
|
|
});
|
|
|
|
|
updateHTML();
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-14 16:49:01 +00:00
|
|
|
|
function updateForm() {
|
|
|
|
|
var advanced = $input.advanced.value(),
|
|
|
|
|
type = $input.type.value(),
|
|
|
|
|
view = $list.options('selected')[0];
|
2014-02-16 11:02:30 +00:00
|
|
|
|
$input.description.options({title: Ox.getObjectById(views, view).description});
|
|
|
|
|
$input.link[type == 'link' ? 'show' : 'hide']();
|
2014-02-16 07:39:18 +00:00
|
|
|
|
$input.size[type == 'iframe' ? 'show' : 'hide']();
|
2014-02-16 07:20:52 +00:00
|
|
|
|
$input.site[advanced ? 'show' : 'hide']();
|
2014-02-15 11:53:32 +00:00
|
|
|
|
viewInputs.forEach(function(key) {
|
|
|
|
|
$input[key][
|
|
|
|
|
Ox.contains(Ox.getObjectById(views, view).inputs, key)
|
2014-02-16 05:45:43 +00:00
|
|
|
|
&& (advanced || !$input[key].is('.advanced')) ? 'show' : 'hide'
|
2014-02-14 16:49:01 +00:00
|
|
|
|
]();
|
|
|
|
|
});
|
|
|
|
|
$input.timeline[
|
2014-02-15 10:57:04 +00:00
|
|
|
|
advanced && view == 'video' && $input.showTimeline.options('value') ? 'show' : 'hide'
|
2014-02-14 16:49:01 +00:00
|
|
|
|
]();
|
|
|
|
|
$input.showLayersLabel[
|
2014-02-15 10:57:04 +00:00
|
|
|
|
advanced && view == 'video' && $input.showAnnotations.options('value') ? 'show' : 'hide'
|
2014-02-14 16:49:01 +00:00
|
|
|
|
]();
|
|
|
|
|
$input.showLayers[
|
2014-02-15 10:57:04 +00:00
|
|
|
|
advanced && view == 'video' && $input.showAnnotations.options('value') ? 'show' : 'hide'
|
2014-02-14 16:49:01 +00:00
|
|
|
|
]();
|
2014-02-16 06:47:09 +00:00
|
|
|
|
if (Ox.contains(['map', 'calendar'], view)) {
|
2014-02-16 12:35:23 +00:00
|
|
|
|
$input.mapMode.options({
|
2014-02-16 07:20:52 +00:00
|
|
|
|
label: Ox._('{0} for', [
|
|
|
|
|
Ox.getObjectById(views, $list.options('selected')[0]).title
|
|
|
|
|
])
|
|
|
|
|
});
|
2014-02-16 12:35:23 +00:00
|
|
|
|
$input.item[$input.mapMode.value() == 'item' ? 'show' : 'hide']();
|
|
|
|
|
$input.find[$input.mapMode.value() == 'find' ? 'show' : 'hide']();
|
|
|
|
|
} else if (view == 'edit') {
|
|
|
|
|
[
|
|
|
|
|
'position', 'showTimeline', 'timeline', 'showAnnotations',
|
|
|
|
|
'showLayersLabel', 'showLayers', 'matchRatio'
|
|
|
|
|
].forEach(function(key) {
|
|
|
|
|
$input[key][$input.editMode.value() == 'video' ? 'show' : 'hide'];
|
|
|
|
|
});
|
2014-02-16 06:47:09 +00:00
|
|
|
|
}
|
2014-02-14 16:49:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function updateHTML() {
|
|
|
|
|
$input.html.options({value: formatHTML()});
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 12:04:52 +00:00
|
|
|
|
function updateOptions() {
|
|
|
|
|
if (ui.section == 'items') {
|
|
|
|
|
if (!ui.item) {
|
|
|
|
|
if (ui.listView == 'map') {
|
|
|
|
|
options.view = 'map';
|
|
|
|
|
} else if (ui.listView == 'calendar') {
|
|
|
|
|
options.view = 'calendar';
|
|
|
|
|
} else if (
|
|
|
|
|
ui.find.conditions.length == 1
|
|
|
|
|
&& ui.find.conditions[0].key == 'list'
|
|
|
|
|
&& ui.find.conditions[0].operator == '=='
|
|
|
|
|
) {
|
|
|
|
|
options.view = 'list';
|
|
|
|
|
} else {
|
|
|
|
|
options.view = 'grid';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
if (ui.itemView == 'documents') {
|
|
|
|
|
options.view = 'document';
|
|
|
|
|
} else if (Ox.contains(['player', 'editor'], ui.itemView)) {
|
|
|
|
|
options.view = 'video';
|
|
|
|
|
} else if (ui.itemView == 'timeline') {
|
|
|
|
|
options.view = 'timeline';
|
|
|
|
|
} else if (ui.itemView == 'map') {
|
|
|
|
|
options.view = 'map';
|
|
|
|
|
} else if (ui.itemView == 'calendar') {
|
|
|
|
|
options.view = 'calendar';
|
|
|
|
|
} else {
|
|
|
|
|
options.view = 'info';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if (ui.section == 'edits') {
|
|
|
|
|
options.view = 'edit';
|
|
|
|
|
} else {
|
|
|
|
|
options.view = 'text';
|
|
|
|
|
}
|
2014-02-17 07:23:41 +00:00
|
|
|
|
options.mapMode = !ui.item ? 'find' : 'item';
|
2014-02-16 12:04:52 +00:00
|
|
|
|
options.item = ui.item;
|
2014-02-18 09:41:23 +00:00
|
|
|
|
options.document = ui.documentsSelection[ui.item] && ui.documentsSelection[ui.item].length
|
|
|
|
|
? ui.documentsSelection[ui.item][0]
|
|
|
|
|
: '';
|
2014-02-16 12:04:52 +00:00
|
|
|
|
options.list = ui._list;
|
|
|
|
|
options.edit = ui.edit;
|
|
|
|
|
options.text = ui.text;
|
|
|
|
|
options.find = ui.find;
|
|
|
|
|
if (ui.item && ui.videoPoints[ui.item]) {
|
|
|
|
|
if (ui.videoPoints[ui.item].annotation) {
|
|
|
|
|
options.annotation = ui.videoPoints[ui.item].annotation;
|
|
|
|
|
} else {
|
|
|
|
|
['position', 'in', 'out'].forEach(function(key) {
|
|
|
|
|
options[key] = ui.videoPoints[ui.item][key] || '';
|
|
|
|
|
});
|
|
|
|
|
}
|
2014-02-18 09:41:23 +00:00
|
|
|
|
if (pandora.$ui[pandora.user.ui.videoView]) {
|
|
|
|
|
duration = pandora.$ui[pandora.user.ui.videoView].options('duration');
|
|
|
|
|
}
|
2014-02-16 12:04:52 +00:00
|
|
|
|
}
|
|
|
|
|
Ox.forEach(options, function(value, key) {
|
|
|
|
|
if (key == 'view') {
|
|
|
|
|
$list.options({selected: [value]});
|
|
|
|
|
} else {
|
|
|
|
|
$input[key].options({value: value});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
updateForm();
|
|
|
|
|
updateHTML();
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 09:42:48 +00:00
|
|
|
|
function validateId(key) {
|
|
|
|
|
// key can be item, document, list, edit, text
|
|
|
|
|
pandora.api['get' + (key == 'item' ? '' : Ox.toTitleCase(key))]({
|
2014-02-16 11:02:30 +00:00
|
|
|
|
id: $input[key].value(),
|
|
|
|
|
keys: key == 'item' ? ['aspectratio', 'duration']
|
|
|
|
|
: key == 'edit' ? ['duration']
|
|
|
|
|
: []
|
2014-02-16 09:42:48 +00:00
|
|
|
|
}, function(result) {
|
2014-02-16 11:02:30 +00:00
|
|
|
|
if (result.status == 200) {
|
|
|
|
|
if (key == 'item' || key == 'edit') {
|
|
|
|
|
duration = result.data.duration;
|
|
|
|
|
['position', 'in', 'out'].forEach(function(key) {
|
2014-02-16 12:04:52 +00:00
|
|
|
|
validatePoint(key);
|
2014-02-16 11:02:30 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
if (key == 'item') {
|
|
|
|
|
videoRatio = result.data.aspectratio;
|
|
|
|
|
// ...
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2014-02-16 09:42:48 +00:00
|
|
|
|
$input[key].value(defaults[key]);
|
|
|
|
|
updateHTML();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-16 12:04:52 +00:00
|
|
|
|
function validatePoint(key) {
|
2014-02-16 11:02:30 +00:00
|
|
|
|
// key can be position, in, out, annotation
|
2014-02-16 12:35:23 +00:00
|
|
|
|
var hasInAndOut = $input['in'].options('value') !== '',
|
|
|
|
|
value = $input[key].value();
|
|
|
|
|
if (value) {
|
2014-02-16 11:02:30 +00:00
|
|
|
|
if (key == 'position') {
|
|
|
|
|
$input.position.options({
|
|
|
|
|
value: limitPoint(
|
2014-02-16 12:35:23 +00:00
|
|
|
|
value,
|
2014-02-16 11:02:30 +00:00
|
|
|
|
hasInAndOut ? $input['in'].options('value') : 0,
|
|
|
|
|
hasInAndOut ? $input.out.options('value') : duration
|
|
|
|
|
)
|
|
|
|
|
});
|
|
|
|
|
$input.annotation.options({value: ''});
|
|
|
|
|
} else if (key == 'in') {
|
|
|
|
|
$input['in'].options({
|
2014-02-16 12:35:23 +00:00
|
|
|
|
value: limitPoint(value, 0, duration)
|
2014-02-16 11:02:30 +00:00
|
|
|
|
});
|
|
|
|
|
if ($input.out.options('value') === '') {
|
|
|
|
|
$input.out.options({value: Ox.formatDuration(duration)});
|
|
|
|
|
} else if (
|
|
|
|
|
Ox.parseDuration($input.out.options('value'))
|
2014-02-16 12:35:23 +00:00
|
|
|
|
< Ox.parseDuration(value)
|
2014-02-16 11:02:30 +00:00
|
|
|
|
) {
|
2014-02-16 12:35:23 +00:00
|
|
|
|
$input.out.options({value: value});
|
2014-02-16 11:02:30 +00:00
|
|
|
|
}
|
|
|
|
|
$input.annotation.options({value: ''});
|
|
|
|
|
} else if (key == 'out') {
|
|
|
|
|
$input.out.options({
|
2014-02-16 12:35:23 +00:00
|
|
|
|
value: limitPoint(value, 0, duration)
|
2014-02-16 11:02:30 +00:00
|
|
|
|
});
|
|
|
|
|
if ($input['in'].options('value') === '') {
|
|
|
|
|
$input['in'].options({value: Ox.formatDuration(0)});
|
|
|
|
|
} else if (
|
|
|
|
|
Ox.parseDuration($input['in'].options('value'))
|
2014-02-16 12:35:23 +00:00
|
|
|
|
> Ox.parseDuration(value)
|
2014-02-16 11:02:30 +00:00
|
|
|
|
) {
|
2014-02-16 12:35:23 +00:00
|
|
|
|
$input['in'].options({value: value});
|
2014-02-16 11:02:30 +00:00
|
|
|
|
}
|
|
|
|
|
$input.annotation.options({value: ''});
|
|
|
|
|
} else if (key == 'annotation') {
|
|
|
|
|
// TODO: validate
|
|
|
|
|
['position', 'in', 'out'].forEach(function(key) {
|
|
|
|
|
$input[key].options({value: ''});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-02-14 16:49:01 +00:00
|
|
|
|
return that;
|
|
|
|
|
|
2014-02-18 09:41:23 +00:00
|
|
|
|
};
|