update text panel

This commit is contained in:
rolux 2013-02-22 03:10:14 +00:00
parent 6a0f59acfe
commit 699f0b64a5

View file

@ -56,7 +56,7 @@ pandora.ui.textPanel = function() {
}) })
.bindEvent({ .bindEvent({
click: function() { click: function() {
selectEmbed( that.selectEmbed(
selected < embedURLs.length - 1 ? selected + 1 : 0 selected < embedURLs.length - 1 ? selected + 1 : 0
); );
} }
@ -87,7 +87,7 @@ pandora.ui.textPanel = function() {
}) })
.bindEvent({ .bindEvent({
click: function() { click: function() {
selectEmbed( that.selectEmbed(
selected ? selected - 1 : embedURLs.length - 1 selected ? selected - 1 : embedURLs.length - 1
); );
} }
@ -173,10 +173,14 @@ pandora.ui.textPanel = function() {
return urls; return urls;
} }
function selectEmbed(index) { that.selectEmbed = function(index) {
if (index != selected) {
selected = index; selected = index;
$('.OxSpecialLink').removeClass('OxActive');
$('#embed' + selected).addClass('OxActive');
pandora.$ui.textEmbed.update(embedURLs[selected]); pandora.$ui.textEmbed.update(embedURLs[selected]);
} }
};
return that; return that;
@ -225,13 +229,20 @@ pandora.ui.textHTML = function(text) {
clickLink: pandora.clickLink, clickLink: pandora.clickLink,
editable: text.editable, editable: text.editable,
format: function(text) { format: function(text) {
var index = 0;
return text.replace( return text.replace(
/<a [^<>]*?href="(.+?)".*?>/gi, /<a [^<>]*?href="(.+?)".*?>/gi,
function() { function() {
var link = arguments[0], url = arguments[1]; var link = arguments[0], ret, url = arguments[1];
return pandora.isEmbedURL(url) if (pandora.isEmbedURL(url)) {
? '<a class="OxSpecialLink" href="' + url + '">' ret = '<a id="embed' + index
: link; + '" class="OxSpecialLink" href="' + url
+ '">'
index++;
} else {
ret = link;
}
return ret;
} }
); );
}, },