Editor-buttons not changing scrollbar

Discussion corner for Developers of Serendipity.
Post Reply
onli
Regular
Posts: 2825
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Editor-buttons not changing scrollbar

Post by onli »

When using the non-wysiswygeditor there are these buttons injecting pieces of html-code. That's great, but it changes the position of the scrollbar of the editarea. That's kind of annoying when writing large entries.
This can be solved by changing the serendipity_editor.js:

Code: Select all

function wrapSelection(txtarea, lft, rgt) {
    if (document.all) {
        IEWrap(txtarea, lft, rgt);
    } else if (document.getElementById) {
        mozWrap(txtarea, lft, rgt);
    }
}
to

Code: Select all

function wrapSelection(txtarea, lft, rgt) {
    var scrollPos = txtarea.scrollTop;
    if (document.all) {
        IEWrap(txtarea, lft, rgt);
    } else if (document.getElementById) {
        mozWrap(txtarea, lft, rgt);
    }
    txtarea.focus();
    txtarea.scrollTop = scrollPos;
}
It also refocus the textarea. Tested with Firefox 3 and Opera 9.63
sincerely
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Editor-buttons not changing scrollbar

Post by garvinhicking »

Hi!

Well noticed! I committed your fix with a slight adjustment to first check if scrollTop is available.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
onli
Regular
Posts: 2825
Joined: Tue Sep 09, 2008 10:04 pm
Contact:

Re: Editor-buttons not changing scrollbar

Post by onli »

Thanks Garvin :)
Don Chambers
Regular
Posts: 3652
Joined: Mon Feb 13, 2006 2:40 am
Location: Chicago, IL, USA
Contact:

Re: Editor-buttons not changing scrollbar

Post by Don Chambers »

Thank you, thank you, thank you!!!! :wink:
=Don=
Post Reply