From 40d6b927e67a6a8a9da5d0e4746d07ff22abcd31 Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Mon, 4 Nov 2013 14:10:13 +0000 Subject: [PATCH] fix text scrolling --- static/js/textPanel.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/static/js/textPanel.js b/static/js/textPanel.js index f79bb9987..94c4a7d4b 100644 --- a/static/js/textPanel.js +++ b/static/js/textPanel.js @@ -168,8 +168,9 @@ pandora.ui.textPanel = function() { that.replaceElement(1, $panel); that.replaceElement(2, $statusbar); - embedURLs.length && that.selectEmbed(0); - + embedURLs.length && that.selectEmbed(0, false); + pandora.user.ui.texts[pandora.user.ui.text] && + pandora.$ui.text.scrollTo(pandora.user.ui.texts[pandora.user.ui.text].position || 0); }); function getEmbedURLs(text) { @@ -192,14 +193,15 @@ pandora.ui.textPanel = function() { pandora.$ui.text.scrollTo(position); } - that.selectEmbed = function(index) { + that.selectEmbed = function(index, scroll) { + scroll = arguments.length == 1 || scroll; if (index != selected) { selected = index; selectedURL = embedURLs[selected] $('.OxSpecialLink').removeClass('OxActive'); selected > -1 && $('#embed' + selected).addClass('OxActive'); pandora.$ui.textEmbed.update(selectedURL); - scrollToSelectedEmbed(); + scroll && scrollToSelectedEmbed(); } }; @@ -229,7 +231,8 @@ pandora.ui.textHTML = function(text) { scroll: function(event) { var position = Math.round(100 * that[0].scrollTop / that[0].scrollHeight) position = position - position % 10; - if (position != pandora.user.ui.texts[pandora.user.ui.text].position) { + if (pandora.user.ui.texts[pandora.user.ui.text] + && position != pandora.user.ui.texts[pandora.user.ui.text].position) { pandora.UI.set( 'texts.' + pandora.UI.encode(pandora.user.ui.text) + '.position', position ? position : 0 @@ -322,9 +325,6 @@ pandora.ui.textHTML = function(text) { }) .appendTo($content); - pandora.user.ui.texts[pandora.user.ui.text] && - scrollTo(pandora.user.ui.texts[pandora.user.ui.text].position || 0); - function getHeight() { // 24 menu + 24 toolbar + 16 statusbar + 32 title + 32 margins // + 1px to ge trid of scrollbar