Seite 1 von 1

[GELÖST] Cursor springt nach oben in der BBCode Box

Verfasst: 06.11.2007 00:00
von 4seven
Hallo PHPBB-Freunde,

gibt es eine Möglichkeit, das springen des Cursors nach oben in der Postbox zu unterbinden?

Das Problem tritt auf, sobald der Text länger als die Box ist, also Scrollbalken auftauchen. Ist bei langen Texten halt ziemlich nervig immer wieder nach oben zu scrollen.

Accurate Insertion... und ähnliche Mods greifen nicht, da sie eine Standard posting_body.tpl voraussetzen (die relevanten Stellen sind bei einer mit der Box gemoddeten posting_body.tpl nicht mehr vorhanden). Bei der BBCode Box wird alles über zwei .js Dateien gesteuert, bei denen ich alle anderen Probs schon fixen konnte (caret position etc.)


Hab auch schon versucht die relevante Stellen (<<<< HIER) aus dem Mozilla Fix (unter Snippets) in die .js - Dateien zu integrieren. Ohne Erfolg

Code: Alles auswählen

// Start add - BBCodes & smilies enhancement MOD
function mozInsert(txtarea, openTag, closeTag)
{
        var scrollTop = ( typeof(txtarea.scrollTop) == 'number' ? txtarea.scrollTop : -1 ); <<<< HIER

        if (txtarea.selectionEnd > txtarea.value.length) { txtarea.selectionEnd = txtarea.value.length; }

        var startPos = txtarea.selectionStart;
        var endPos = txtarea.selectionEnd+openTag.length;

        txtarea.value=txtarea.value.slice(0,startPos)+openTag+txtarea.value.slice(startPos);
        txtarea.value=txtarea.value.slice(0,endPos)+closeTag+txtarea.value.slice(endPos);

        txtarea.selectionStart = startPos+openTag.length;
        txtarea.selectionEnd = endPos;
        txtarea.focus();

        if( scrollTop >= 0 ) { txtarea.scrollTop = scrollTop; } <<<< HIER
}
// End add - BBCodes & smilies enhancement MOD 

Vielleicht hat jemand eine Idee?

lg
4seven

Verfasst: 07.11.2007 15:16
von 4seven
..hochschieb..

Gelöst

Verfasst: 08.11.2007 04:13
von 4seven
Hallo Leutz,
hab es gelöst bekommen.

Für interessierte Leidgenossen:

---------------------------------------------------------------
## Frei angepasst nach: Fix BBCode and Emoticon insertion 1.0.1,
## Anteilen vom Accurate BBCode Insertion Mod ( with special thx to bombon)
## und anderen Snippets

Code: Alles auswählen

#
#-----[ OPEN ]----------------------------------------------------------------
#

mods/bbcode_box/add_bbcode.js + mods/bbcode_box/bbcode_box.js 

#
# >>>>    Note: Make all changes in both files <<<<<
# >>>> Wichtig: Alle Aenderungen in beiden Dateien machen <<<<
# 

#
#-----[ FIND ]----------------------------------------------------------------
#

function BBCplain() {

#
#-----[ ADD BEFORE ]--------------------------------------------------------
#

function bbplace(text) {
	var txtarea = document.post.message;
	var scrollTop = (typeof(txtarea.scrollTop) == 'number' ? txtarea.scrollTop : -1);
	if (txtarea.createTextRange && txtarea.caretPos) {
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : 

caretPos.text + text;
		txtarea.focus();
	} else if (txtarea.selectionStart || txtarea.selectionStart == '0') {
		var startPos = txtarea.selectionStart;
		var endPos = txtarea.selectionEnd;
		txtarea.value = txtarea.value.substring(0, startPos)
			+ text
			+ txtarea.value.substring(endPos, txtarea.value.length);
		txtarea.focus();
		txtarea.selectionStart = startPos + text.length;
		txtarea.selectionEnd = startPos + text.length;
	} else {
		txtarea.value  += text;
		txtarea.focus();
	}
	if(scrollTop >= 0 ) { txtarea.scrollTop = scrollTop;}
}

function emoticon(text) {
	text = ' ' + text + ' ';
	bbplace(text);
}

#
#-------[ FIND AND DELETE]--------------------------------------
#

function emoticon(text) {
	var txtarea = document.post.message;
	text = ' ' + text + ' ';
	if (txtarea.createTextRange && txtarea.caretPos) {
		var caretPos = txtarea.caretPos;
		caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? caretPos.text + text + ' ' : 

caretPos.text + text;
		txtarea.focus();
	} else {
		txtarea.value  += text;
		txtarea.focus();
	}
}

#
#-----[ FIND ]----------------------------------------------------------------
#

function mozWrap(txtarea, open, close)
{
	var selLength = txtarea.textLength;
	var selStart = txtarea.selectionStart;
	var selEnd = txtarea.selectionEnd;
	if (selEnd == 1 || selEnd == 2)
		selEnd = selLength;

	var s1 = (txtarea.value).substring(0,selStart);
	var s2 = (txtarea.value).substring(selStart, selEnd)
	var s3 = (txtarea.value).substring(selEnd, selLength);
	txtarea.value = s1 + open + s2 + close + s3;
	return;
}

#
#-----[ REPLACE WITH ]--------------------------------------------------------
#

// From http://www.massless.org/mozedit/
function mozWrap(txtarea, open, close)
{
	if (txtarea.selectionEnd > txtarea.value.length) { txtarea.selectionEnd = txtarea.value.length; }

	var oldPos = txtarea.scrollTop;
	var oldHght = txtarea.scrollHeight;

	var selStart = txtarea.selectionStart;
	var selEnd = txtarea.selectionEnd+open.length;

	txtarea.value = txtarea.value.slice(0,selStart)+open+txtarea.value.slice(selStart);
	txtarea.value = txtarea.value.slice(0,selEnd)+close+txtarea.value.slice(selEnd);

	txtarea.selectionStart = selStart+open.length;
	txtarea.selectionEnd = selEnd;

	var newHght = txtarea.scrollHeight - oldHght;
	txtarea.scrollTop = oldPos + newHght;

	txtarea.focus();
}

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------------
#

Die Anleitung zum Fixing von (m.E.) nunmehr allen BBCodeBox-FireFox-Problemen wurde upgedated.

lg
4seven