merge app into pandora

This commit is contained in:
j 2011-06-06 17:48:11 +02:00
commit b3769316b3
35 changed files with 735 additions and 734 deletions

View file

@ -1,22 +1,22 @@
// vim: et:ts=4:sw=4:sts=4:ft=js
pandora.ui.item = function() {
var that = new Ox.Element();
pandora.api.getItem(app.user.ui.item, function(result) {
pandora.api.getItem(pandora.user.ui.item, function(result) {
if (result.status.code != 200) {
app.$ui.contentPanel.replaceElement(1,
pandora.$ui.contentPanel.replaceElement(1,
Ox.Element().html(
'The '+app.site.itemName.singular+' you are looking for does not exist.'));
} else if (app.user.ui.itemView == 'calendar') {
app.$ui.contentPanel.replaceElement(1, Ox.Element().html('Calendar'));
} else if (app.user.ui.itemView == 'clips') {
app.$ui.contentPanel.replaceElement(1, Ox.Element().html('Clips'));
} else if (app.user.ui.itemView == 'info') {
'The '+pandora.site.itemName.singular+' you are looking for does not exist.'));
} else if (pandora.user.ui.itemView == 'calendar') {
pandora.$ui.contentPanel.replaceElement(1, Ox.Element().html('Calendar'));
} else if (pandora.user.ui.itemView == 'clips') {
pandora.$ui.contentPanel.replaceElement(1, Ox.Element().html('Clips'));
} else if (pandora.user.ui.itemView == 'info') {
//Ox.print('result.data', result.data)
if (app.user.level == 'admin') {
if (pandora.user.level == 'admin') {
var $form,
$edit = new Ox.Element()
.append($form = new Ox.FormElementGroup({
elements: Ox.map(app.site.itemKeys, function(key) {
elements: Ox.map(pandora.site.itemKeys, function(key) {
return new Ox.Input({
id: key.id,
label: key.title,
@ -37,7 +37,7 @@ pandora.ui.item = function() {
click: function(event, data) {
var values = $form.value();
var changed = {};
Ox.map(app.site.itemKeys, function(key, i) {
Ox.map(pandora.site.itemKeys, function(key, i) {
if(values[i] && values[i] != ''+result.data[key.id]) {
if(Ox.isArray(key.type) && key.type[0] == 'string') {
changed[key.id] = values[i].split(', ');
@ -47,48 +47,48 @@ pandora.ui.item = function() {
}
});
if(changed) {
pandora.api.editItem(Ox.extend(changed, {id: app.user.ui.item}), function(result) {
pandora.api.editItem(Ox.extend(changed, {id: pandora.user.ui.item}), function(result) {
//fixme just reload parts that need reloading
window.location.reload();
});
}
}
}));
app.$ui.contentPanel.replaceElement(1, app.$ui.item = $edit);
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.item = $edit);
} else {
$.get('/static/html/itemInfo.html', {}, function(template) {
//Ox.print(template);
app.$ui.contentPanel.replaceElement(1,
app.$ui.item = new Ox.Element()
pandora.$ui.contentPanel.replaceElement(1,
pandora.$ui.item = new Ox.Element()
.append($.tmpl(template, result.data))
);
});
}
} else if (app.user.ui.itemView == 'map') {
app.$ui.contentPanel.replaceElement(1, Ox.Element().html('Map'));
} else if (app.user.ui.itemView == 'player') {
} else if (pandora.user.ui.itemView == 'map') {
pandora.$ui.contentPanel.replaceElement(1, Ox.Element().html('Map'));
} else if (pandora.user.ui.itemView == 'player') {
var video = result.data.stream,
format = $.support.video.supportedFormat(video.formats);
video.height = video.profiles[0];
video.width = parseInt(video.height * video.aspectRatio / 2) * 2;
video.url = video.baseUrl + '/' + video.height + 'p.' + format;
app.$ui.contentPanel.replaceElement(1, app.$ui.player = new Ox.VideoPanelPlayer({
annotationsSize: app.user.ui.annotationsSize,
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.player = new Ox.VideoPanelPlayer({
annotationsSize: pandora.user.ui.annotationsSize,
duration: video.duration,
height: app.$ui.contentPanel.size(1),
position: app.user.ui.videoPosition[app.user.ui.item] || 0,
showAnnotations: app.user.ui.showAnnotations,
showControls: app.user.ui.showControls,
height: pandora.$ui.contentPanel.size(1),
position: pandora.user.ui.videoPosition[pandora.user.ui.item] || 0,
showAnnotations: pandora.user.ui.showAnnotations,
showControls: pandora.user.ui.showControls,
subtitles: result.data.layers.subtitles.map(function(subtitle) {
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
}),
videoHeight: video.height,
videoId: app.user.ui.item,
videoId: pandora.user.ui.item,
videoWidth: video.width,
videoSize: app.user.ui.videoScreen,
videoSize: pandora.user.ui.videoScreen,
videoURL: video.url,
width: app.$ui.document.width() - app.$ui.mainPanel.size(0) - 1
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1
}).bindEvent({
change: function(event, data) {
// showAnnotations, showControls, videoScreen
@ -99,14 +99,14 @@ pandora.ui.item = function() {
enterfullscreen: pandora.enterFullscreen,
exitfullscreen: pandora.exitFullscreen,
resize: function(event, data) {
app.$ui.player.options({
pandora.$ui.player.options({
height: data
});
}
}));
} else if (app.user.ui.itemView == 'statistics') {
app.$ui.contentPanel.replaceElement(1, Ox.Element().html('Statistics'));
} else if (app.user.ui.itemView == 'timeline') {
} else if (pandora.user.ui.itemView == 'statistics') {
pandora.$ui.contentPanel.replaceElement(1, Ox.Element().html('Statistics'));
} else if (pandora.user.ui.itemView == 'timeline') {
var layers = [],
video = result.data.stream,
cuts = result.data.cuts || [],
@ -117,45 +117,45 @@ pandora.ui.item = function() {
video.profiles.forEach(function(profile) {
streams[profile] = video.baseUrl + '/' + profile + 'p.' + format;
});
$.each(app.site.layers, function(i, layer) {
$.each(pandora.site.layers, function(i, layer) {
layers[i] = $.extend({}, layer, {items: result.data.layers[layer.id]});
});
app.$ui.contentPanel.replaceElement(1, app.$ui.editor = new Ox.VideoEditor({
annotationsSize: app.user.ui.annotationsSize,
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.editor = new Ox.VideoEditor({
annotationsSize: pandora.user.ui.annotationsSize,
cuts: cuts,
duration: video.duration,
find: '',
getFrameURL: function(position) {
return '/' + app.user.ui.item + '/frame/' + video.width.toString() + '/' + position.toString() + '.jpg';
return '/' + pandora.user.ui.item + '/frame/' + video.width.toString() + '/' + position.toString() + '.jpg';
},
getLargeTimelineImageURL: function(i) {
return '/' + app.user.ui.item + '/timelines/timeline.64.' + i + '.png';
return '/' + pandora.user.ui.item + '/timelines/timeline.64.' + i + '.png';
},
getSmallTimelineImageURL: function(i) {
return '/' + app.user.ui.item + '/timelines/timeline.16.' + i + '.png';
return '/' + pandora.user.ui.item + '/timelines/timeline.16.' + i + '.png';
},
height: app.$ui.contentPanel.size(1),
height: pandora.$ui.contentPanel.size(1),
id: 'editor',
'in': 0,
layers: layers,
out: 0,
position: app.user.ui.videoPosition[app.user.ui.item] || 0,
position: pandora.user.ui.videoPosition[pandora.user.ui.item] || 0,
posterFrame: parseInt(video.duration / 2),
showAnnotations: app.user.ui.showAnnotations,
showAnnotations: pandora.user.ui.showAnnotations,
showLargeTimeline: true,
// fixme: layers have value, subtitles has text?
subtitles: result.data.layers.subtitles.map(function(subtitle) {
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
}),
videoHeight: video.height,
videoId: app.user.ui.item,
videoId: pandora.user.ui.item,
videoWidth: video.width,
videoSize: app.user.ui.videoSize,
videoSize: pandora.user.ui.videoSize,
video: streams,
width: app.$ui.document.width() - app.$ui.mainPanel.size(0) - 1
width: pandora.$ui.document.width() - pandora.$ui.mainPanel.size(0) - 1
}).bindEvent({
resize: function(event, data) {
app.$ui.editor.options({
pandora.$ui.editor.options({
height: data
});
},
@ -164,16 +164,16 @@ pandora.ui.item = function() {
},
addAnnotation: function(event, data) {
Ox.print('addAnnotation', data);
data.item = app.user.ui.item;
data.item = pandora.user.ui.item;
data.value = 'Click to edit';
pandora.api.addAnnotation(data, function(result) {
app.$ui.editor.addAnnotation(data.layer, result.data);
pandora.$ui.editor.addAnnotation(data.layer, result.data);
});
},
removeAnnotations: function(event, data) {
pandora.api.removeAnnotations(data, function(result) {
//fixme: check for errors
app.$ui.editor.removeAnnotations(data.layer, data.ids);
pandora.$ui.editor.removeAnnotations(data.layer, data.ids);
});
},
updateAnnotation: function(event, data) {
@ -184,27 +184,27 @@ pandora.ui.item = function() {
}));
that.bindEvent('resize', function(event, data) {
//Ox.print('resize item', data)
app.$ui.editor.options({
pandora.$ui.editor.options({
height: data
});
});
/*
app.$ui.rightPanel.bindEvent('resize', function(event, data) {
Ox.print('... rightPanel resize', data, app.$ui.timelinePanel.size(1))
app.$ui.editor.options({
width: data - app.$ui.timelinePanel.size(1) - 1
pandora.$ui.rightPanel.bindEvent('resize', function(event, data) {
Ox.print('... rightPanel resize', data, pandora.$ui.timelinePanel.size(1))
pandora.$ui.editor.options({
width: data - pandora.$ui.timelinePanel.size(1) - 1
});
});
*/
} else if (app.user.ui.itemView == 'files') {
app.$ui.contentPanel.replaceElement(1,
app.$ui.item = new Ox.FilesView({
} else if (pandora.user.ui.itemView == 'files') {
pandora.$ui.contentPanel.replaceElement(1,
pandora.$ui.item = new Ox.FilesView({
id: result.data.id
})
);
}
var director = result.data.director?' ('+result.data.director.join(', ')+')':'';
app.$ui.total.html(result.data.title + director);
pandora.$ui.total.html(result.data.title + director);
});
return that;
};