Compatibility fixes for edit toolbar:
authorBrion Vibber <brion@users.mediawiki.org>
Mon, 1 Mar 2004 00:25:57 +0000 (00:25 +0000)
committerBrion Vibber <brion@users.mediawiki.org>
Mon, 1 Mar 2004 00:25:57 +0000 (00:25 +0000)
* Use infobox mode for Gecko. Inline direct editing is neat, but because of
  a Mozilla bug that induces weird scrolling it's confusing and unusable.
  When Mozilla fixes the bug and we can detect it, we'll enable it for
  fixed versions only.
* Use 'new RegExp()' instead of '//' to avoid ugly JS parse errors when
  viewing pages in Netscape 3. There are still runtime errors in NS3 at
  edit time, but this lets people read in peace.

stylesheets/wikibits.js

index d7dcf7a..237b85c 100644 (file)
@@ -99,7 +99,7 @@ function addInfobox(infoText) {
        var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
                 && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
                 && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1)
-               && (clientPC.indexOf('khtml')==-1));
+               && (clientPC.indexOf('khtml')==-1) && (clientPC.indexOf('gecko')==-1));
        if(!document.selection && !is_nav) {
                document.write("<form name='infoform' id='infoform'>"+
                        "<input size=80 id='infobox' name='infobox' value='"+
@@ -109,9 +109,10 @@ function addInfobox(infoText) {
 }
 
 function escapeQuotes(text) {
-
-       text=text.replace(/'/g,"\\'");
-       text=text.replace(/\n/g,"\\n");
+       var re=new RegExp("'","g");
+       text=text.replace(re,"\\'");
+       re=new RegExp("\\n","g");
+       text=text.replace(re,"\\n");
        return text;
 }
 
@@ -132,8 +133,8 @@ function insertTags(tagOpen, tagClose, sampleText) {
                } else {
                        document.selection.createRange().text = tagOpen + theSelection + tagClose;
                }
-       // Mozilla
-       } else if(txtarea.selectionStart || txtarea.selectionStart == '0') {
+       // Mozilla -- disabled because it induces a scrolling bug which makes it virtually unusable
+       } else if(false && txtarea.selectionStart || txtarea.selectionStart == '0') {
                var startPos = txtarea.selectionStart;
                var endPos = txtarea.selectionEnd;
                var myText = (txtarea.value).substring(startPos, endPos);
@@ -153,8 +154,9 @@ function insertTags(tagOpen, tagClose, sampleText) {
                // Append at the end: Some people find that annoying
                //txtarea.value += tagOpen + sampleText + tagClose;
                //txtarea.focus();
-               tagOpen=tagOpen.replace(/\n/g,"");
-               tagClose=tagClose.replace(/\n/g,"");
+               var re=new RegExp("\\n","g");
+               tagOpen=tagOpen.replace(re,"");
+               tagClose=tagClose.replace(re,"");
                document.infoform.infobox.value=tagOpen+sampleText+tagClose;
                txtarea.focus();
        }