Use an infobox instead of copy & pasting the toolbar text in browsers
authorErik Moeller <erik@users.mediawiki.org>
Mon, 19 Jan 2004 21:26:20 +0000 (21:26 +0000)
committerErik Moeller <erik@users.mediawiki.org>
Mon, 19 Jan 2004 21:26:20 +0000 (21:26 +0000)
that do not support insertion at caret point

includes/Skin.php
languages/Language.php
stylesheets/wikibits.js
stylesheets/wikistandard.css

index ecdee83..dc8db12 100644 (file)
@@ -2299,6 +2299,7 @@ class Skin {
                        $toolbar.="addButton('$image','$tip','$open','$close','$sample');\n";
                }
 
+               $toolbar.="addInfobox('".wfMsg("infobox")."');\n";
                $toolbar.="document.writeln(\"</div>\");\n</script>";
                return $toolbar;
        }
index 78d2450..addf498 100644 (file)
@@ -617,6 +617,7 @@ Please log in again after you receive it.",
 "media_tip"=>"Media file link",
 "sig_tip"=>"Your signature with timestamp",
 "hr_tip"=>"Horizontal line (use sparingly)",
+"infobox"=>"Click a button to get an example text",
 
 # Edit pages
 #
index 678192c..b5e5de6 100644 (file)
@@ -78,6 +78,7 @@ function toggleToc() {
 // we use it to avoid creating the toolbar where javascript is not enabled
 function addButton(imageFile, speedTip, tagOpen, tagClose, sampleText) {
 
+
        speedTip=escapeQuotes(speedTip);
        tagOpen=escapeQuotes(tagOpen);
        tagClose=escapeQuotes(tagClose);
@@ -89,6 +90,21 @@ function addButton(imageFile, speedTip, tagOpen, tagClose, sampleText) {
        return;
 }
 
+function addInfobox(infoText) {
+
+       // if no support for changing selection, add a small copy & paste field
+       var clientPC = navigator.userAgent.toLowerCase(); // Get client info
+       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));
+       if(!document.selection && !is_nav) {
+               document.write("<form name='infoform' id='infoform'>"+
+                       "<input size=80 id='infobox' name='infobox' value='"+
+                       infoText+"' READONLY></form>");
+       }
+
+}
+
 function escapeQuotes(text) {
 
        text=text.replace(/'/g,"\\'");
@@ -121,9 +137,14 @@ function insertTags(tagOpen, tagClose, sampleText) {
                txtarea.selectionEnd=cPos;
        // All others
        } else {
-               txtarea.value += tagOpen + sampleText + tagClose;
+               // 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,"");
+               document.infoform.infobox.value=tagOpen+sampleText+tagClose;
                txtarea.focus();
        }
        // reposition cursor if possible
        if (txtarea.createTextRange) txtarea.caretPos = document.selection.createRange().duplicate();
-}
\ No newline at end of file
+}
index f167a37..ceb3d2a 100644 (file)
@@ -9,6 +9,7 @@
 #topbar { padding: 4px;font-size:95%; }
 #toc { border:1px solid #8888aa; background-color:#f7f8ff;padding:5px;font-size:95%; }
 #toolbar { padding:0px; }
+#infobox { background:#eeeeff;color:black;;}
 #editform { margin-top:1px; }
 .bodytext { }
 a.interwiki, a.external { color: #3366BB; }