This commit is contained in:
rolux 2012-06-10 20:31:02 +02:00
parent 41cd72d37e
commit 453f83e067
15 changed files with 108 additions and 93 deletions

View file

@ -26,9 +26,10 @@ var app = new Ox.App({
app.api.api({docs: true, code: true}, function(results) { app.api.api({docs: true, code: true}, function(results) {
app.actions = results.data.actions; app.actions = results.data.actions;
if (document.location.hash) { if (document.location.hash) {
app.$ui.actionList.triggerEvent('select', {ids: document.location.hash.substring(1).split(',')}); app.$ui.actionList.triggerEvent('select', {
ids: document.location.hash.substring(1).split(',')
});
} }
}); });
@ -84,11 +85,7 @@ function constructList() {
id: 'actionList', id: 'actionList',
items: function(data, callback) { items: function(data, callback) {
function _sort(a, b) { function _sort(a, b) {
if(a.name > b.name) return a.name > b.name ? 1 : a.name == b.name ? 0 : -1;
return 1;
else if(a.name == b.name)
return 0;
return -1;
} }
if (!data.keys) { if (!data.keys) {
app.api.api(function(results) { app.api.api(function(results) {
@ -126,7 +123,7 @@ function constructList() {
if (data.ids.length) if (data.ids.length)
data.ids.forEach(function(id) { data.ids.forEach(function(id) {
info.append( info.append(
$("<h2>") $('<h2>')
.html(id) .html(id)
.css({ .css({
marginBottom: '8px' marginBottom: '8px'

View file

@ -57,8 +57,10 @@ Ox.load('UI', {
Ox.UI.hideLoadingScreen(); Ox.UI.hideLoadingScreen();
function checkRange(data) { function checkRange(data) {
if(data.position < options['in'] - 0.04 if (
|| data.position > options.out) { data.position < options['in'] - 0.04
|| data.position > options.out
) {
if (!pandora.player.options('paused')) { if (!pandora.player.options('paused')) {
pandora.player.togglePaused(); pandora.player.togglePaused();
} }

View file

@ -323,9 +323,9 @@ appPanel
if (localStorage && localStorage['pandora.onload']) { if (localStorage && localStorage['pandora.onload']) {
try { try {
eval(localStorage['pandora.onload']) eval(localStorage['pandora.onload'])
} catch(e) { } catch(e) {}
}
} }
}); });
} }

View file

@ -2,6 +2,7 @@
'use strict'; 'use strict';
pandora.ui.embedDialog = function(data) { pandora.ui.embedDialog = function(data) {
var content = Ox.Element().css({margin: '16px'}), var content = Ox.Element().css({margin: '16px'}),
height = 360, height = 360,
width = 640, width = 640,
@ -33,18 +34,6 @@ pandora.ui.embedDialog = function(data) {
data.view = 'video'; data.view = 'video';
function constructUrl(data) {
var url = document.location.protocol
+ '//' + document.location.host
+ '/' + pandora.user.ui.item + '/embed?',
query = [];
Ox.forEach(data, function(value, key) {
if(key[0] != '_') {
query.push(encodeURIComponent(key) + '=' + encodeURIComponent(value));
}
});
return url + query.join('&');
}
content.html('To embed this video use this code on your page:<br>'); content.html('To embed this video use this code on your page:<br>');
content.append( content.append(
$('<textarea>') $('<textarea>')
@ -55,7 +44,7 @@ pandora.ui.embedDialog = function(data) {
}).val( }).val(
'<iframe width="' + width '<iframe width="' + width
+ '" height="' + height + '" height="' + height
+ '" src="' + constructUrl(data) + '" src="' + constructURL(data)
+ '" frameborder="0" allowfullscreen></iframe>' + '" frameborder="0" allowfullscreen></iframe>'
).on({ ).on({
click: function() { click: function() {
@ -64,5 +53,22 @@ pandora.ui.embedDialog = function(data) {
} }
}) })
); );
function constructURL(data) {
var url = document.location.protocol
+ '//' + document.location.host
+ '/' + pandora.user.ui.item + '/embed?',
query = [];
Ox.forEach(data, function(value, key) {
if (key[0] != '_') {
query.push(
encodeURIComponent(key) + '=' + encodeURIComponent(value)
);
}
});
return url + query.join('&');
}
return that; return that;
}; };

View file

@ -220,7 +220,6 @@ pandora.ui.filesView = function(options, self) {
return self.$filesList.value(id, 'instances').length == 0; return self.$filesList.value(id, 'instances').length == 0;
}); });
if (ids.length > 0 && pandora.user.level == 'admin') { if (ids.length > 0 && pandora.user.level == 'admin') {
Ox.print('delete', ids);
pandora.api.removeFiles({ pandora.api.removeFiles({
ids: ids ids: ids
}, function(result) { }, function(result) {
@ -439,7 +438,10 @@ pandora.ui.filesView = function(options, self) {
data[key] = self['$' + key + 'Input'].value(); data[key] = self['$' + key + 'Input'].value();
}); });
pandora.api.moveFiles(data, function(result) { pandora.api.moveFiles(data, function(result) {
if(pandora.user.ui.item == self.options.id && pandora.user.ui.itemView == 'files') { if (
pandora.user.ui.item == self.options.id
&& pandora.user.ui.itemView == 'files'
) {
Ox.Request.clearCache(); // fixme: remove Ox.Request.clearCache(); // fixme: remove
if (self.$checkbox.value()) { if (self.$checkbox.value()) {
pandora.UI.set({item: result.data.itemId}); pandora.UI.set({item: result.data.itemId});

View file

@ -64,9 +64,10 @@ pandora.ui.importAnnotations = function(data) {
.replace(/<br[ /]*?>\n/g, '\n') .replace(/<br[ /]*?>\n/g, '\n')
.replace(/\n\n/g, '<br>\n') .replace(/\n\n/g, '<br>\n')
.replace(/\n/g, '<br>\n'); .replace(/\n/g, '<br>\n');
$status.html(Ox.formatDuration(data['in']) $status.html(
+ ' to ' + Ox.formatDuration(data.out) + '<br>\n' Ox.formatDuration(data['in']) + ' to '
+ data.text); + Ox.formatDuration(data.out) + '<br>\n' + data.text
);
pandora.api.addAnnotation({ pandora.api.addAnnotation({
'in': data['in'], 'in': data['in'],
out: data.out, out: data.out,
@ -119,12 +120,11 @@ pandora.ui.importAnnotations = function(data) {
reader.onloadend = function(event) { reader.onloadend = function(event) {
srt = Ox.parseSRT(this.result); srt = Ox.parseSRT(this.result);
total = srt.length; total = srt.length;
if(total) { total && importButton.options({disabled: false});
importButton.options({ $status.html(
disabled: false 'File contains ' + total + ' annotation'
}); + (total == 1 ? '' : 's') + '.'
} );
$status.html('File contains '+ total + ' annotations.');
}; };
reader.readAsText(file); reader.readAsText(file);
} else { } else {

View file

@ -552,7 +552,8 @@ pandora.ui.infoView = function(data) {
['', '%Y', '%B %Y', '%B %e, %Y'][value.split('-').length] ['', '%Y', '%B %Y', '%B %e, %Y'][value.split('-').length]
) : ''; ) : '';
} else if (key == 'duration') { } else if (key == 'duration') {
return value < 60 ? Math.round(value) + ' sec' : Math.round(value / 60) + ' min'; return value < 60 ? Math.round(value) + ' sec'
: Math.round(value / 60) + ' min';
} }
return (Ox.isArray(value) ? value : [value]).map(function(value) { return (Ox.isArray(value) ? value : [value]).map(function(value) {
return key ? return key ?

View file

@ -3,7 +3,7 @@
pandora.ui.uploadDialog = function(data) { pandora.ui.uploadDialog = function(data) {
var content = Ox.Element().css({margin: '16px'}), var content = Ox.Element().css({margin: '16px'}),
canceled = false, cancelled = false,
file, file,
closeButton, closeButton,
actionButton, actionButton,
@ -30,7 +30,7 @@ pandora.ui.uploadDialog = function(data) {
} else if (actionButton.options('title') == 'Close') { } else if (actionButton.options('title') == 'Close') {
that.close(); that.close();
} else if (actionButton.options('title') == 'Cancel') { } else if (actionButton.options('title') == 'Cancel') {
canceled = true; cancelled = true;
pandora.firefogg && pandora.firefogg.cancel(); pandora.firefogg && pandora.firefogg.cancel();
pandora.$ui.upload && pandora.$ui.upload.abort(); pandora.$ui.upload && pandora.$ui.upload.abort();
actionButton.options('title', 'Select Video'); actionButton.options('title', 'Select Video');
@ -166,8 +166,8 @@ pandora.ui.uploadDialog = function(data) {
function(result, file) { function(result, file) {
result = JSON.parse(result); result = JSON.parse(result);
if (result.progress != 1) { if (result.progress != 1) {
if(canceled) { if (cancelled) {
$status.html('Encoding canceled.'); $status.html('Encoding cancelled.');
} else { } else {
$status.html('Encoding failed.'); $status.html('Encoding failed.');
} }
@ -296,12 +296,14 @@ pandora.ui.uploadDialog = function(data) {
options.noUpscaling = true; options.noUpscaling = true;
if((!info.video.length || (info.video[0].codec == options.videoCodec if (
&& info.video[0].height <= options.height)) (!info.video.length || (
&& (!info.audio.length || info.audio[0].codec == options.audioCodec)) { info.video[0].codec == options.videoCodec
options = { && info.video[0].height <= options.height
passthrough: true ))
}; && (!info.audio.length || info.audio[0].codec == options.audioCodec)
) {
options = {passthrough: true};
} }
return JSON.stringify(options); return JSON.stringify(options);
} }
@ -314,7 +316,10 @@ pandora.ui.uploadDialog = function(data) {
var video = info.video[0]; var video = info.video[0];
html += video.width + 'x' + video.height + ' (' + video.codec + ')'; html += video.width + 'x' + video.height + ' (' + video.codec + ')';
} }
if(info.video && info.video.length>0 && info.audio && info.audio.length>0) { if (
info.video && info.video.length > 0
&& info.audio && info.audio.length > 0
) {
html += ' / '; html += ' / ';
} }
if (info.audio && info.audio.length > 0) { if (info.audio && info.audio.length > 0) {
@ -335,7 +340,7 @@ pandora.ui.uploadDialog = function(data) {
} }
function selectVideo() { function selectVideo() {
canceled = false; cancelled = false;
pandora.firefogg = new Firefogg(); pandora.firefogg = new Firefogg();
pandora.firefogg.setFormat(pandora.site.video.formats[0]); pandora.firefogg.setFormat(pandora.site.video.formats[0]);
if (pandora.firefogg.selectVideo()) { if (pandora.firefogg.selectVideo()) {
@ -350,7 +355,9 @@ pandora.ui.uploadDialog = function(data) {
}, },
keys: ['id', 'available'] keys: ['id', 'available']
}, function(result) { }, function(result) {
if(result.data.items.length === 0 || !result.data.items[0].available) { if (
result.data.items.length === 0 || !result.data.items[0].available
) {
$info.html(formatInfo(info)); $info.html(formatInfo(info));
$status.html( $status.html(
options.passthrough options.passthrough