less requests
This commit is contained in:
parent
19d390e561
commit
95ce013aa4
1 changed files with 171 additions and 174 deletions
|
@ -6,7 +6,8 @@ pandora.ui.item = function() {
|
|||
|
||||
pandora.api.get({
|
||||
id: pandora.user.ui.item,
|
||||
keys: []
|
||||
keys: ['video', 'timeline'].indexOf(pandora.user.ui.itemView)>-1 ?
|
||||
['rendered', 'cuts', 'videoRatio', 'duration', 'layers', 'parts', 'size'] : []
|
||||
}, pandora.user.level == 'admin' && pandora.user.ui.itemView == 'info' ? 0 : -1, function(result) {
|
||||
|
||||
if (result.status.code == 200) {
|
||||
|
@ -102,190 +103,186 @@ pandora.ui.item = function() {
|
|||
);
|
||||
|
||||
} else if (pandora.user.ui.itemView == 'video') {
|
||||
pandora.api.get({id: pandora.user.ui.item, keys: ['layers']}, function(r) {
|
||||
// fixme: duplicated
|
||||
var clipsQuery = pandora.getClipsQuery(),
|
||||
isClipsQuery = !!clipsQuery.conditions.length,
|
||||
layers = [],
|
||||
video = {};
|
||||
pandora.site.layers.forEach(function(layer, i) {
|
||||
layers[i] = Ox.extend({}, layer, {items: r.data.layers[layer.id]});
|
||||
});
|
||||
pandora.site.video.resolutions.forEach(function(resolution) {
|
||||
video[resolution] = Ox.range(result.data.parts).map(function(i) {
|
||||
return '/' + pandora.user.ui.item + '/'
|
||||
+ resolution + 'p' + (i + 1) + '.' + pandora.user.videoFormat;
|
||||
});
|
||||
});
|
||||
//
|
||||
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.player = Ox.VideoPanelPlayer({
|
||||
annotationsSize: pandora.user.ui.annotationsSize,
|
||||
cuts: result.data.cuts || [],
|
||||
duration: result.data.duration,
|
||||
find: isClipsQuery ? clipsQuery.conditions[0].value : '',
|
||||
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,
|
||||
subtitles: r.data.layers.subtitles ?
|
||||
r.data.layers.subtitles.map(function(subtitle) {
|
||||
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
|
||||
}) : [],
|
||||
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({
|
||||
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});
|
||||
}
|
||||
}));
|
||||
// fixme: duplicated
|
||||
var clipsQuery = pandora.getClipsQuery(),
|
||||
isClipsQuery = !!clipsQuery.conditions.length,
|
||||
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) {
|
||||
return '/' + pandora.user.ui.item + '/'
|
||||
+ resolution + 'p' + (i + 1) + '.' + pandora.user.videoFormat;
|
||||
});
|
||||
});
|
||||
//
|
||||
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.player = Ox.VideoPanelPlayer({
|
||||
annotationsSize: pandora.user.ui.annotationsSize,
|
||||
cuts: result.data.cuts || [],
|
||||
duration: result.data.duration,
|
||||
find: isClipsQuery ? clipsQuery.conditions[0].value : '',
|
||||
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,
|
||||
subtitles: result.data.layers.subtitles ?
|
||||
result.data.layers.subtitles.map(function(subtitle) {
|
||||
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
|
||||
}) : [],
|
||||
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({
|
||||
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});
|
||||
}
|
||||
}));
|
||||
|
||||
} else if (pandora.user.ui.itemView == 'timeline') {
|
||||
pandora.api.get({id: pandora.user.ui.item, keys: ['layers']}, function(r) {
|
||||
var clipsQuery = pandora.getClipsQuery(),
|
||||
isClipsQuery = !!clipsQuery.conditions.length,
|
||||
layers = [],
|
||||
video = {};
|
||||
pandora.site.layers.forEach(function(layer) {
|
||||
layers.push(Ox.extend({items: r.data.layers[layer.id]}, layer));
|
||||
var clipsQuery = pandora.getClipsQuery(),
|
||||
isClipsQuery = !!clipsQuery.conditions.length,
|
||||
layers = [],
|
||||
video = {};
|
||||
pandora.site.layers.forEach(function(layer) {
|
||||
layers.push(Ox.extend({items: result.data.layers[layer.id]}, layer));
|
||||
});
|
||||
pandora.site.video.resolutions.forEach(function(resolution) {
|
||||
video[resolution] = Ox.range(result.data.parts).map(function(i) {
|
||||
return '/' + pandora.user.ui.item + '/'
|
||||
+ resolution + 'p' + (i + 1) + '.' + pandora.user.videoFormat;
|
||||
});
|
||||
pandora.site.video.resolutions.forEach(function(resolution) {
|
||||
video[resolution] = Ox.range(result.data.parts).map(function(i) {
|
||||
return '/' + pandora.user.ui.item + '/'
|
||||
+ resolution + 'p' + (i + 1) + '.' + pandora.user.videoFormat;
|
||||
});
|
||||
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.editor = Ox.VideoEditor({
|
||||
annotationsSize: pandora.user.ui.annotationsSize,
|
||||
cuts: result.data.cuts || [],
|
||||
duration: result.data.duration,
|
||||
find: isClipsQuery ? clipsQuery.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,
|
||||
// fixme: layers have value, subtitles has text?
|
||||
subtitles: result.data.layers.subtitles ?
|
||||
result.data.layers.subtitles.map(function(subtitle) {
|
||||
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
|
||||
}) : [],
|
||||
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({
|
||||
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
|
||||
});
|
||||
});
|
||||
pandora.$ui.contentPanel.replaceElement(1, pandora.$ui.editor = Ox.VideoEditor({
|
||||
annotationsSize: pandora.user.ui.annotationsSize,
|
||||
cuts: result.data.cuts || [],
|
||||
duration: result.data.duration,
|
||||
find: isClipsQuery ? clipsQuery.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,
|
||||
// fixme: layers have value, subtitles has text?
|
||||
subtitles: r.data.layers.subtitles ?
|
||||
r.data.layers.subtitles.map(function(subtitle) {
|
||||
return {'in': subtitle['in'], out: subtitle.out, text: subtitle.value};
|
||||
}) : [],
|
||||
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({
|
||||
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});
|
||||
}
|
||||
}));
|
||||
that.bindEvent('resize', function(data) {
|
||||
//Ox.print('resize item', data)
|
||||
},
|
||||
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
|
||||
});
|
||||
});
|
||||
/*
|
||||
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
|
||||
},
|
||||
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});
|
||||
}
|
||||
}));
|
||||
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
|
||||
});
|
||||
});
|
||||
*/
|
||||
} else if (pandora.user.ui.itemView == 'map') {
|
||||
pandora.$ui.contentPanel.replaceElement(1, pandora.ui.navigationView('map', result.data.videoRatio));
|
||||
|
||||
|
|
Loading…
Reference in a new issue