update text panel

This commit is contained in:
rolux 2013-02-21 16:55:24 +05:30
parent 5151cb42cb
commit 23777b54c6

View file

@ -16,6 +16,7 @@ pandora.ui.textPanel = function() {
pandora.api.getText({id: pandora.user.ui.text}, function(result) { pandora.api.getText({id: pandora.user.ui.text}, function(result) {
var text = result.data, var text = result.data,
embedsURLs = getEmbedsURLs(),
$toolbar = Ox.Bar({size 24}), $toolbar = Ox.Bar({size 24}),
@ -39,6 +40,7 @@ pandora.ui.textPanel = function() {
.appendTo($toolbar), .appendTo($toolbar),
$nextButton = Ox.Button({ $nextButton = Ox.Button({
disabled: embedURLs.length < 2,
title: 'arrowRight', title: 'arrowRight',
tooltip: 'Next Clip', tooltip: 'Next Clip',
type: 'image' type: 'image'
@ -50,6 +52,7 @@ pandora.ui.textPanel = function() {
.appendTo($toolbar), .appendTo($toolbar),
$currentButton = Ox.Button({ $currentButton = Ox.Button({
disabled: embedURLs.length < 1,
title: 'center', title: 'center',
tooltip: 'Current Reference', tooltip: 'Current Reference',
type: 'image' type: 'image'
@ -61,6 +64,7 @@ pandora.ui.textPanel = function() {
.appendTo($toolbar), .appendTo($toolbar),
$previousButton = Ox.Button({ $previousButton = Ox.Button({
disabled: embedURLs.length < 2,
title: 'arrowLeft', title: 'arrowLeft',
tooltip: 'Previous Clip', tooltip: 'Previous Clip',
type: 'image' type: 'image'
@ -81,7 +85,7 @@ pandora.ui.textPanel = function() {
: pandora.ui.textPDF(text) : pandora.ui.textPDF(text)
}, },
{ {
element: pandora.$ui.textEmbed = pandora.ui.textEmbed(), element: pandora.$ui.textEmbed = pandora.ui.textEmbed(embedURLs[0]),
size: pandora.user.ui.embedSize, size: pandora.user.ui.embedSize,
resizable: true, resizable: true,
resize: [192, 256, 320, 384, 448, 512] resize: [192, 256, 320, 384, 448, 512]
@ -131,8 +135,15 @@ pandora.ui.textPanel = function() {
}); });
function getEmbeds(text) { function getEmbedURLs(text) {
var matches = text.match(/<span data-video=".+?">/g),
urls = [];
if (matches) {
matches.forEach(function(match) {
urls.push(match.match(/"(.+?)"/)[1]);
});
}
return urls;
} }
return that; return that;
@ -254,16 +265,18 @@ pandora.ui.textPDF = function(text) {
pandora.ui.textEmbed = function(url) { pandora.ui.textEmbed = function(url) {
var that = Ox.Element() var that = Ox.Element()
.css({padding: '16px'})
.html('No Embeds')
.bindEvent({ .bindEvent({
resizestart: function() { resizestart: function() {
$overlay.show(); url && $overlay.show();
}, },
resize: function(data) { resize: function(data) {
pandora.user.ui.embedSize = data.size; pandora.user.ui.embedSize = data.size;
pandora.$ui.text.updateSize(); pandora.$ui.text.updateSize();
}, },
resizeend: function() { resizeend: function() {
$overlay.hide(); url && $overlay.hide();
} }
}), }),
@ -271,9 +284,10 @@ pandora.ui.textEmbed = function(url) {
.attr({ .attr({
height: '100%', height: '100%',
frameborder: 0, frameborder: 0,
src: url, src: '',
width: '100%' width: '100%'
}) })
.hide()
.appendTo($element), .appendTo($element),
$overlay = $('<div>') $overlay = $('<div>')
@ -288,10 +302,16 @@ pandora.ui.textEmbed = function(url) {
.appendTo($element); .appendTo($element);
that.update = function(url) { that.update = function(url) {
$iframe.attr({src: url}); if (url) {
$iframe.attr({src: url}).show();
} else {
$iframe.hide();
}
return that; return that;
}; };
that.update(url);
return that; return that;
}; };