diff --git a/static/js/pandora/embedDialog.js b/static/js/pandora/embedDialog.js
index 70d6c42e5..7fe4d47b0 100644
--- a/static/js/pandora/embedDialog.js
+++ b/static/js/pandora/embedDialog.js
@@ -3,8 +3,8 @@
pandora.ui.embedDialog = function(data) {
var content = Ox.Element().css({margin: '16px'}),
- height = 240,
- width = 320,
+ height = 360,
+ width = 640,
that = Ox.Dialog({
buttons: [
Ox.Button({
@@ -18,15 +18,15 @@ pandora.ui.embedDialog = function(data) {
],
closeButton: true,
content: content,
- height: Math.round((window.innerHeight - 24) * 0.75),
+ height: height,
keys: {
'escape': 'close'
},
maximizeButton: true,
- minHeight: 256,
- minWidth: 640,
+ minHeight: height,
+ minWidth: width,
title: 'Embed Video',
- width: Math.round(window.innerWidth * 0.75)
+ width: width
})
.bindEvent({
close: function(data) {
diff --git a/static/js/pandora/importSubtitles.js b/static/js/pandora/importSubtitles.js
new file mode 100644
index 000000000..d805263ac
--- /dev/null
+++ b/static/js/pandora/importSubtitles.js
@@ -0,0 +1,93 @@
+// vim: et:ts=4:sw=4:sts=4:ft=javascript
+'use strict';
+
+pandora.ui.importSubtitles = function(data) {
+ var content = Ox.Element().css({margin: '16px'}),
+ file,
+ height = 240,
+ width = 640,
+ that = Ox.Dialog({
+ buttons: [
+ Ox.Button({
+ id: 'close',
+ title: 'Close'
+ }).bindEvent({
+ click: function() {
+ that.close();
+ }
+ })
+ ],
+ closeButton: true,
+ content: content,
+ keys: {
+ 'escape': 'close'
+ },
+ maximizeButton: true,
+ height: height,
+ width: width,
+ title: 'Import Subtitles',
+ })
+ .bindEvent({
+ close: function(data) {
+ }
+ });
+ Ox.Select({
+ items: Ox.merge([{id: '', title: 'Select Layer'}], pandora.site.layers),
+ value: '',
+ })
+ .bindEvent({
+ change: function(data) {
+ var layer = data.value;
+ $('')
+ .attr({
+ type: 'file'
+ })
+ .css({
+ padding: '8px'
+ })
+ .bind({
+ change: function(event) {
+ file = this.files[0];
+ var reader = new FileReader();
+ reader.onloadend = function(event) {
+ var srt = Ox.parseSRT(this.result),
+ total = srt.length;
+ function addAnnotation() {
+ if(srt.length>0) {
+ var data = srt.shift();
+ data.text = Ox.parseHTML(data.text);
+ content.html('Importing '+total+' '+ layer +':
\n'
+ + Ox.formatDuration(data['in'])
+ + ' to ' + Ox.formatDuration(data.out) + '
\n'
+ + data.text);
+ pandora.api.addAnnotation({
+ 'in': data['in'],
+ out: data.out,
+ value: data.text,
+ item: pandora.user.ui.item,
+ layer: layer
+ }, function(result) {
+ if (result.status.code == 200) {
+ pandora.$ui.editor && pandora.$ui.editor.addAnnotation(layer, result.data);
+ addAnnotation();
+ } else {
+ content.html('Failed');
+ }
+ });
+ } else {
+ content.html('Done');
+ Ox.Request.clearCache();
+ //fixme, somehow reload timeline view here
+ }
+ }
+ addAnnotation();
+ };
+ reader.readAsText(file);
+ }
+ })
+ .appendTo(content);
+ }
+ })
+ .appendTo(content);
+ return that;
+};