[Snippet] Firefox Fixes für die Advanced BBCodeBox v 5.1.0x

Snippet-Area for phpBB 2.0.x

[Snippet] Firefox Fixes für die Advanced BBCodeBox v 5.1.0x

Postby 4seven » Fri 11. Apr 2008, 00:45 | Userzeit: +1.00 / Fr 11. Apr 2008, 01:45

Der erste Fix löst das Problem in der BBCode Box,

das BB-Codes nicht an der Cursorposition eingefügt werden
und
das der Cursor nach oben springt.

---------------------------------------------------------------
## 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: Select all
#
#-----[ 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() {

#
#-----[ BEFORE, ADD ]-------------! Updated !-----------------
#

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]-------! Updated !--------------------
#

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();
}

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

document.post.message.value+=ToAdd;

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

bbplace(ToAdd);

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

txtarea.value += bbopen + bbclose;

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

bbplace(bbopen + bbclose);

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

document.post.message.value += text;

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

bbplace(text);

#
#-----[ THATS IT ]---------------------------------------------
#


_____________________________

Der zweite Fix löst das Problem, das man im Postbereich einen bestimmten Schrifttyp (Font Type), sowie eine bestimmte Schriftgröße (Font Size) und Schriftfarbe (Font Color) nicht zweimal hintereinander auswählen kann.

Code: Select all
#
#-----[ OPEN ]------------------------------------------
#

templates/your_template/posting_body.tpl

#
#-----[ After this.. ]------------------------------------------
#

<!--
//====================================================================== |
//==== Start Advanced BBCode Box MOD =================================== |
//==== v5.1.0 ========================================================== |
//====
-->

#
#-----[ ..Find ]------------------------------------------
#

<select style="height: 20px;" name="ft" onChange="BBCft()" onMouseOver="helpline('ft')">
<option style="font-weight : bold;" selected="selected">Font type</option>
<option value="Arial">Default font</option>

#
#-----[ Replace with ]------------------------------------------
#

<select style="height: 20px;" name="ft" onChange="BBCft();this.selectedIndex=0" onMouseOver="helpline('ft')">
<option style="font-weight : bold;" selected="selected">Font type</option>
<option value="Arial">Default font</option>

#
#-----[ ..Find ]------------------------------------------
#

<select style="height: 20px;" name="fs" onChange="BBCfs()" onMouseOver="helpline('fs')">
<option style="font-weight : bold;" selected="selected">Font Size</option>

#
#-----[ Replace with ]------------------------------------------
#

<select style="height: 20px;" name="fs" onChange="BBCfs();this.selectedIndex=0" onMouseOver="helpline('fs')">
<option style="font-weight : bold;" selected="selected">Font Size</option>

#
#-----[ ..Find ]------------------------------------------
#

<select style="height: 20px;" name="fc" onChange="BBCfc()" onMouseOver="helpline('fc')">
<option style="font-weight : bold;" selected>Font Color</option>

#
#-----[ Replace with ]------------------------------------------
#

<select style="height: 20px;" name="fc" onChange="BBCfc();this.selectedIndex=0" onMouseOver="helpline('fc')">
<option style="font-weight : bold;" selected>Font Color</option>

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



lg
4seven
User avatar
4seven
Administrator
 
Posts: 427
 
Last 3 Topics:
Tabmenu Test
[Snippet] Avatar Ev...
[DEV] Zero and X-P...
 
Joined:
Sun 13. Jan 2008, 23:44
 
Letzter Login:
Mon 1. Aug 2022, 16:40
 
Posted:
Fri 11. Apr 2008, 00:45 +1.00
Userzeit: Fr 11. Apr 2008, 01:45

Return to [Snippet] for 2.0.x



Who is online

Users browsing this forum: No registered users and 8 guests

cron