2011-07-29 18:37:11 +00:00
|
|
|
// vim: et:ts=4:sw=4:sts=4:ft=javascript
|
2011-10-03 13:23:11 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
pandora.ui.item = function() {
|
2011-09-17 07:07:59 +00:00
|
|
|
|
2011-06-19 17:49:25 +00:00
|
|
|
var that = Ox.Element();
|
2011-09-17 07:07:59 +00:00
|
|
|
|
2011-08-06 13:34:56 +00:00
|
|
|
pandora.api.get({
|
|
|
|
id: pandora.user.ui.item,
|
2011-10-22 21:03:28 +00:00
|
|
|
keys: ['video', 'timeline'].indexOf(pandora.user.ui.itemView) > -1 ?
|
2011-10-25 13:59:27 +00:00
|
|
|
[ 'cuts', 'duration', 'layers', 'parts', 'rendered', 'rightslevel', 'size', 'title', 'videoRatio'] : []
|
2011-08-06 13:34:56 +00:00
|
|
|
}, pandora.user.level == 'admin' && pandora.user.ui.itemView == 'info' ? 0 : -1, function(result) {
|
2011-09-17 07:07:59 +00:00
|
|
|
|
|
|
|
if (result.status.code == 200) {
|
2011-10-08 17:22:56 +00:00
|
|
|
// fixme: can the history state title get updated too?
|
2011-10-08 14:52:00 +00:00
|
|
|
document.title = pandora.getPageTitle(result.data.title);
|
2011-09-17 07:07:59 +00:00
|
|
|
}
|
|
|
|
|
2011-09-20 04:11:25 +00:00
|
|
|
/*if (result.status.code != 200) {
|
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
|
|
|
Ox.Element()
|
|
|
|
.css({marginTop: '32px', fontSize: '12px', textAlign: 'center'})
|
|
|
|
.html(
|
|
|
|
'Sorry, we can\'t find the '
|
|
|
|
+ pandora.site.itemName.singular.toLowerCase()
|
|
|
|
+ ' you\'re looking for.'
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}*/
|
|
|
|
|
2011-10-22 21:03:28 +00:00
|
|
|
if (['video', 'timeline'].indexOf(pandora.user.ui.itemView) > -1) {
|
2011-10-23 02:29:20 +00:00
|
|
|
// fixme: layers have value, subtitles has text?
|
2011-10-22 21:03:28 +00:00
|
|
|
var subtitles = result.data.layers.subtitles
|
|
|
|
? result.data.layers.subtitles.map(function(subtitle) {
|
|
|
|
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
|
|
|
|
})
|
|
|
|
: [],
|
2011-10-25 13:59:27 +00:00
|
|
|
canPlayClips = pandora.site.capabilities.canPlayClips[pandora.user.level] >= result.data.rightslevel,
|
|
|
|
canPlayVideo = pandora.site.capabilities.canPlayVideo[pandora.user.level] >= result.data.rightslevel,
|
2011-10-22 21:03:28 +00:00
|
|
|
censored = canPlayVideo ? []
|
|
|
|
: canPlayClips ? (
|
|
|
|
subtitles.length
|
|
|
|
? Ox.merge(
|
|
|
|
subtitles.map(function(subtitle, i) {
|
|
|
|
return {
|
|
|
|
'in': i == 0 ? 0 : subtitles[i - 1].out,
|
|
|
|
out: subtitle['in']
|
|
|
|
};
|
|
|
|
}),
|
|
|
|
[{'in': Ox.last(subtitles).out, out: result.data.duration}]
|
|
|
|
)
|
|
|
|
: Ox.range(0, result.data.duration - 5, 60).map(function(position) {
|
|
|
|
return {
|
|
|
|
'in': position + 5,
|
|
|
|
out: Math.max(position + 60, result.data.duration)
|
|
|
|
};
|
|
|
|
})
|
|
|
|
)
|
2011-10-23 02:29:20 +00:00
|
|
|
: [{'in': 0, out: result.data.duration}],
|
|
|
|
layers = [],
|
|
|
|
video = {};
|
|
|
|
|
|
|
|
pandora.site.layers.forEach(function(layer, i) {
|
|
|
|
layers[i] = Ox.extend({}, layer, {items: result.data.layers[layer.id]});
|
|
|
|
});
|
|
|
|
pandora.site.video.resolutions.forEach(function(resolution) {
|
|
|
|
video[resolution] = Ox.range(result.data.parts).map(function(i) {
|
2011-10-28 12:17:18 +00:00
|
|
|
var part = (i + 1),
|
|
|
|
prefix = pandora.site.site.videoprefix.replace('PART', part);
|
|
|
|
return prefix + '/' + pandora.user.ui.item + '/'
|
|
|
|
+ resolution + 'p' + part + '.' + pandora.user.videoFormat;
|
2011-10-23 02:29:20 +00:00
|
|
|
});
|
|
|
|
});
|
2011-10-22 21:03:28 +00:00
|
|
|
}
|
|
|
|
|
2011-09-20 04:11:25 +00:00
|
|
|
if (!result.data.rendered && [
|
2011-09-22 03:20:55 +00:00
|
|
|
'clips', 'map', 'video', 'timeline'
|
2011-10-22 21:03:28 +00:00
|
|
|
].indexOf(pandora.user.ui.itemView) > -1) {
|
2011-06-27 13:39:35 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
2011-08-24 22:15:50 +00:00
|
|
|
Ox.Element()
|
|
|
|
.css({marginTop: '32px', fontSize: '12px', textAlign: 'center'})
|
|
|
|
.html(
|
2011-10-23 02:29:20 +00:00
|
|
|
'Sorry, <i>' + result.data.title
|
2011-08-24 22:15:50 +00:00
|
|
|
+ '</i> currently doesn\'t have a '
|
|
|
|
+ pandora.user.ui.itemView + ' view.'
|
|
|
|
)
|
|
|
|
);
|
2011-09-17 07:07:59 +00:00
|
|
|
|
2011-06-06 15:48:11 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'info') {
|
2011-05-26 07:34:52 +00:00
|
|
|
//Ox.print('result.data', result.data)
|
2011-08-05 18:26:27 +00:00
|
|
|
if (pandora.user.level == 'admin' && false) {
|
2011-05-25 19:42:45 +00:00
|
|
|
var $form,
|
2011-06-19 17:49:25 +00:00
|
|
|
$edit = Ox.Element()
|
|
|
|
.append($form = Ox.FormElementGroup({
|
2011-06-27 13:39:35 +00:00
|
|
|
elements: Ox.map(pandora.site.sortKeys, function(key) {
|
2011-06-19 17:49:25 +00:00
|
|
|
return Ox.Input({
|
2011-05-25 19:42:45 +00:00
|
|
|
id: key.id,
|
|
|
|
label: key.title,
|
|
|
|
labelWidth: 100,
|
2011-05-26 07:34:52 +00:00
|
|
|
value: result.data[key.id],
|
2011-05-25 19:42:45 +00:00
|
|
|
type: 'text',
|
2011-10-29 17:46:46 +00:00
|
|
|
width: 500
|
2011-05-25 19:42:45 +00:00
|
|
|
});
|
|
|
|
}),
|
|
|
|
separators: [
|
|
|
|
{title: '', width: 0}
|
|
|
|
]
|
|
|
|
}))
|
2011-06-19 17:49:25 +00:00
|
|
|
.append(Ox.Button({
|
2011-05-25 19:42:45 +00:00
|
|
|
title: 'Save',
|
|
|
|
type: 'text'
|
|
|
|
}).bindEvent({
|
2011-09-17 17:40:15 +00:00
|
|
|
click: function(data) {
|
|
|
|
// fixme: cleanup
|
2011-05-25 19:42:45 +00:00
|
|
|
var values = $form.value();
|
|
|
|
var changed = {};
|
2011-06-06 15:48:11 +00:00
|
|
|
Ox.map(pandora.site.itemKeys, function(key, i) {
|
2011-05-26 07:34:52 +00:00
|
|
|
if(values[i] && values[i] != ''+result.data[key.id]) {
|
|
|
|
if(Ox.isArray(key.type) && key.type[0] == 'string') {
|
2011-05-25 19:42:45 +00:00
|
|
|
changed[key.id] = values[i].split(', ');
|
2011-05-26 07:34:52 +00:00
|
|
|
} else {
|
2011-05-25 19:42:45 +00:00
|
|
|
changed[key.id] = values[i];
|
2011-05-26 07:34:52 +00:00
|
|
|
}
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
if(changed) {
|
2011-10-22 22:12:56 +00:00
|
|
|
pandora.api.edit(Ox.extend(changed, {id: pandora.user.ui.item}), function(result) {
|
2011-05-25 19:42:45 +00:00
|
|
|
//fixme just reload parts that need reloading
|
|
|
|
window.location.reload();
|
2011-10-29 17:46:46 +00:00
|
|
|
});
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}));
|
2011-06-06 15:48:11 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.item = $edit);
|
2011-05-25 19:42:45 +00:00
|
|
|
} else {
|
2011-08-05 18:26:27 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
|
|
|
pandora.$ui.item = pandora.ui.infoView(result.data)
|
|
|
|
.bindEvent({
|
|
|
|
resize: function() {
|
|
|
|
pandora.$ui.item.resize();
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
|
|
|
|
2011-09-23 10:44:54 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'clips') {
|
2011-09-30 10:33:45 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
2011-10-30 15:36:14 +00:00
|
|
|
pandora.ui.clipsView(result.data.videoRatio)
|
2011-09-30 10:33:45 +00:00
|
|
|
);
|
2011-09-23 10:44:54 +00:00
|
|
|
|
2011-09-22 03:20:55 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'video') {
|
2011-10-20 19:32:12 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.player = Ox.VideoPanelPlayer({
|
|
|
|
annotationsSize: pandora.user.ui.annotationsSize,
|
2011-10-22 21:03:28 +00:00
|
|
|
censored: censored,
|
2011-10-20 19:32:12 +00:00
|
|
|
cuts: result.data.cuts || [],
|
|
|
|
duration: result.data.duration,
|
2011-10-30 09:49:12 +00:00
|
|
|
find: pandora.user.ui.itemFind.conditions[0]
|
|
|
|
? pandora.user.ui.itemFind.conditions[0].value : '',
|
2011-10-20 19:32:12 +00:00
|
|
|
getTimelineImageURL: function(i) {
|
|
|
|
return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png';
|
|
|
|
},
|
|
|
|
height: pandora.$ui.contentPanel.size(1),
|
|
|
|
'in': pandora.user.ui.videoPoints[pandora.user.ui.item]['in'],
|
|
|
|
muted: pandora.user.ui.videoMuted,
|
|
|
|
out: pandora.user.ui.videoPoints[pandora.user.ui.item].out,
|
|
|
|
position: pandora.user.ui.videoPoints[pandora.user.ui.item].position,
|
|
|
|
scaleToFill: pandora.user.ui.videoScale == 'fill',
|
|
|
|
showAnnotations: pandora.user.ui.showAnnotations,
|
|
|
|
showControls: pandora.user.ui.showControls,
|
2011-10-22 21:03:28 +00:00
|
|
|
subtitles: subtitles,
|
2011-10-20 19:32:12 +00:00
|
|
|
tooltips: true,
|
|
|
|
timeline: '/' + pandora.user.ui.item + '/timeline16p.png',
|
|
|
|
video: video,
|
|
|
|
volume: pandora.user.ui.videoVolume,
|
|
|
|
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1
|
|
|
|
}).bindEvent({
|
2011-10-30 09:49:12 +00:00
|
|
|
find: function(data) {
|
2011-10-30 14:59:54 +00:00
|
|
|
pandora.UI.set('itemFind', data.find ? {
|
2011-10-30 09:49:12 +00:00
|
|
|
conditions: [{key: 'subtitles', value: data.find, operator: '='}],
|
|
|
|
operator: '&'
|
2011-10-30 14:59:54 +00:00
|
|
|
} : pandora.site.user.ui.itemFind);
|
2011-10-30 09:49:12 +00:00
|
|
|
},
|
2011-10-20 19:32:12 +00:00
|
|
|
muted: function(data) {
|
|
|
|
pandora.UI.set('muted', data.muted);
|
|
|
|
},
|
|
|
|
position: function(data) {
|
|
|
|
pandora.UI.set('videoPoints.' + pandora.user.ui.item + '.position', data.position);
|
|
|
|
},
|
|
|
|
resizeannotations: function(data) {
|
|
|
|
pandora.UI.set('annotationsSize', data.annotationsSize);
|
|
|
|
},
|
|
|
|
scale: function(data) {
|
|
|
|
pandora.UI.set('videoScale', data.scale);
|
|
|
|
},
|
|
|
|
toggleannotations: function(data) {
|
|
|
|
pandora.UI.set('showAnnotations', data.showAnnotations);
|
|
|
|
},
|
|
|
|
togglecontrols: function(data) {
|
|
|
|
pandora.UI.set('showControls', data.showControls);
|
|
|
|
},
|
|
|
|
volume: function(data) {
|
|
|
|
pandora.UI.set('volume', data.volume);
|
|
|
|
},
|
|
|
|
pandora_showannotations: function(data) {
|
|
|
|
pandora.$ui.player.options({showAnnotations: data.value});
|
|
|
|
}
|
|
|
|
}));
|
2011-09-17 07:07:59 +00:00
|
|
|
|
2011-06-06 15:48:11 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'timeline') {
|
2011-10-30 09:49:12 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
|
|
|
pandora.$ui.editor = Ox.VideoEditor({
|
|
|
|
annotationsSize: pandora.user.ui.annotationsSize,
|
|
|
|
censored: censored,
|
|
|
|
cuts: result.data.cuts || [],
|
|
|
|
duration: result.data.duration,
|
|
|
|
find: pandora.user.ui.itemFind.conditions[0]
|
|
|
|
? pandora.user.ui.itemFind.conditions[0].value : '',
|
|
|
|
getFrameURL: function(position) {
|
|
|
|
return '/' + pandora.user.ui.item + '/' + Ox.last(pandora.site.video.resolutions) + 'p' + position + '.jpg';
|
|
|
|
},
|
|
|
|
getLargeTimelineImageURL: function(i) {
|
|
|
|
return '/' + pandora.user.ui.item + '/timeline64p' + i + '.png';
|
|
|
|
},
|
|
|
|
getSmallTimelineImageURL: function(i) {
|
|
|
|
return '/' + pandora.user.ui.item + '/timeline16p' + i + '.png';
|
|
|
|
},
|
|
|
|
height: pandora.$ui.contentPanel.size(1),
|
|
|
|
id: 'editor',
|
|
|
|
'in': pandora.user.ui.videoPoints[pandora.user.ui.item]['in'],
|
|
|
|
layers: layers,
|
|
|
|
muted: pandora.user.ui.videoMuted,
|
|
|
|
out: pandora.user.ui.videoPoints[pandora.user.ui.item].out,
|
|
|
|
position: pandora.user.ui.videoPoints[pandora.user.ui.item].position,
|
|
|
|
posterFrame: parseInt(video.duration / 2),
|
|
|
|
showAnnotations: pandora.user.ui.showAnnotations,
|
|
|
|
showLargeTimeline: true,
|
|
|
|
subtitles: subtitles,
|
|
|
|
tooltips: true,
|
|
|
|
video: video,
|
|
|
|
videoRatio: result.data.videoRatio,
|
|
|
|
videoSize: pandora.user.ui.videoSize,
|
|
|
|
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1
|
|
|
|
}).bindEvent({
|
|
|
|
find: function(data) {
|
2011-10-30 14:59:54 +00:00
|
|
|
pandora.UI.set('itemFind', data.find ? {
|
2011-10-30 09:49:12 +00:00
|
|
|
conditions: [{key: 'subtitles', value: data.find, operator: '='}],
|
|
|
|
operator: '&'
|
2011-10-30 14:59:54 +00:00
|
|
|
} : pandora.site.user.ui.itemFind);
|
2011-10-30 09:49:12 +00:00
|
|
|
},
|
|
|
|
points: function(data) {
|
|
|
|
pandora.UI.set('videoPoints.' + pandora.user.ui.item, {
|
|
|
|
'in': data['in'],
|
|
|
|
out: data.out,
|
|
|
|
position: pandora.user.ui.videoPoints[pandora.user.ui.item].position
|
|
|
|
});
|
|
|
|
},
|
|
|
|
position: function(data) {
|
|
|
|
pandora.UI.set('videoPoints.' + pandora.user.ui.item + '.position', data.position);
|
|
|
|
},
|
|
|
|
resize: function(data) {
|
|
|
|
Ox.print('RESIZE!!', data.size)
|
|
|
|
pandora.$ui.editor.options({
|
|
|
|
height: data.size
|
|
|
|
});
|
|
|
|
},
|
|
|
|
resizeend: function(data) {
|
|
|
|
pandora.UI.set({annotationsSize: data.size});
|
|
|
|
},
|
|
|
|
togglesize: function(data) {
|
|
|
|
pandora.UI.set({videoSize: data.size});
|
|
|
|
},
|
|
|
|
addannotation: function(data) {
|
|
|
|
Ox.print('addAnnotation', data);
|
|
|
|
data.item = pandora.user.ui.item;
|
|
|
|
data.value = 'Click to edit';
|
|
|
|
pandora.api.addAnnotation(data, function(result) {
|
|
|
|
pandora.$ui.editor.addAnnotation(data.layer, result.data);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
removeannotations: function(data) {
|
|
|
|
pandora.api.removeAnnotations(data, function(result) {
|
|
|
|
//fixme: check for errors
|
|
|
|
pandora.$ui.editor.removeAnnotations(data.layer, data.ids);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
toggleannotations: function(data) {
|
|
|
|
pandora.UI.set('showAnnotations', data.showAnnotations);
|
|
|
|
},
|
|
|
|
updateannotation: function(data) {
|
|
|
|
//fixme: check that edit was successfull
|
|
|
|
pandora.api.editAnnotation(data, function(result) {
|
|
|
|
Ox.print('done updateAnnotation', result);
|
|
|
|
});
|
|
|
|
},
|
|
|
|
pandora_showannotations: function(data) {
|
|
|
|
pandora.$ui.editor.options({showAnnotations: data.value});
|
|
|
|
}
|
|
|
|
})
|
|
|
|
);
|
2011-10-20 19:32:12 +00:00
|
|
|
that.bindEvent('resize', function(data) {
|
|
|
|
//Ox.print('resize item', data)
|
|
|
|
pandora.$ui.editor.options({
|
|
|
|
height: data.size
|
|
|
|
});
|
|
|
|
});
|
|
|
|
/*
|
|
|
|
pandora.$ui.rightPanel.bindEvent('resize', function(data) {
|
|
|
|
Ox.print('... rightPanel resize', data, pandora.$ui.timelinePanel.size(1))
|
|
|
|
pandora.$ui.editor.options({
|
|
|
|
width: data - pandora.$ui.timelinePanel.size(1) - 1
|
2011-05-25 19:42:45 +00:00
|
|
|
});
|
|
|
|
});
|
2011-10-20 19:32:12 +00:00
|
|
|
*/
|
2011-09-23 10:44:54 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'map') {
|
2011-10-03 13:23:11 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1, pandora.ui.navigationView('map', result.data.videoRatio));
|
2011-09-23 10:44:54 +00:00
|
|
|
|
|
|
|
} else if (pandora.user.ui.itemView == 'calendar') {
|
2011-10-13 12:04:27 +00:00
|
|
|
pandora.$ui.contentPanel.replaceElement(1, pandora.ui.navigationView('calendar', result.data.videoRatio));
|
2011-09-23 10:44:54 +00:00
|
|
|
|
2011-09-28 17:32:03 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'data') {
|
|
|
|
var stats = Ox.Container();
|
|
|
|
Ox.TreeList({
|
|
|
|
data: result.data,
|
|
|
|
width: pandora.$ui.mainPanel.size(1) - Ox.UI.SCROLLBAR_SIZE
|
|
|
|
}).appendTo(stats);
|
|
|
|
pandora.$ui.contentPanel.replaceElement(1, stats);
|
2011-09-23 10:44:54 +00:00
|
|
|
|
2011-06-06 15:48:11 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'files') {
|
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
2011-10-15 15:21:41 +00:00
|
|
|
pandora.$ui.item = pandora.ui.filesView({
|
2011-05-26 07:34:52 +00:00
|
|
|
id: result.data.id
|
2011-05-25 19:42:45 +00:00
|
|
|
})
|
|
|
|
);
|
2011-09-17 07:07:59 +00:00
|
|
|
|
2011-06-06 18:40:24 +00:00
|
|
|
} else if (pandora.user.ui.itemView == 'frames' || pandora.user.ui.itemView == 'posters') {
|
|
|
|
pandora.$ui.contentPanel.replaceElement(1,
|
2011-06-07 03:17:36 +00:00
|
|
|
pandora.$ui.item = pandora.ui.mediaView().bindEvent({
|
|
|
|
resize: function() {
|
|
|
|
pandora.$ui.item.resize();
|
|
|
|
}
|
|
|
|
})
|
2011-06-06 18:40:24 +00:00
|
|
|
);
|
2011-05-25 19:42:45 +00:00
|
|
|
}
|
2011-09-17 07:07:59 +00:00
|
|
|
|
2011-08-25 14:44:22 +00:00
|
|
|
if (result.data) {
|
2011-08-25 02:51:58 +00:00
|
|
|
var director = result.data.director ? ' ('+result.data.director.join(', ') + ')' : '';
|
2011-08-25 14:44:22 +00:00
|
|
|
pandora.$ui.total.html(result.data.title + director);
|
|
|
|
}
|
2011-09-17 07:07:59 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
});
|
2011-09-17 07:07:59 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
return that;
|
2011-09-17 07:07:59 +00:00
|
|
|
|
2011-05-25 19:42:45 +00:00
|
|
|
};
|
|
|
|
|