From df4f380e420359e067fcd707e2f0e9099c55ba34 Mon Sep 17 00:00:00 2001 From: Erik Moeller Date: Mon, 19 Jan 2004 21:26:20 +0000 Subject: [PATCH] Use an infobox instead of copy & pasting the toolbar text in browsers that do not support insertion at caret point --- includes/Skin.php | 1 + languages/Language.php | 1 + stylesheets/wikibits.js | 25 +++++++++++++++++++++++-- stylesheets/wikistandard.css | 1 + 4 files changed, 26 insertions(+), 2 deletions(-) diff --git a/includes/Skin.php b/includes/Skin.php index ecdee838d5..dc8db12d2d 100644 --- a/includes/Skin.php +++ b/includes/Skin.php @@ -2299,6 +2299,7 @@ class Skin { $toolbar.="addButton('$image','$tip','$open','$close','$sample');\n"; } + $toolbar.="addInfobox('".wfMsg("infobox")."');\n"; $toolbar.="document.writeln(\"\");\n"; return $toolbar; } diff --git a/languages/Language.php b/languages/Language.php index 78d2450e9d..addf498093 100644 --- a/languages/Language.php +++ b/languages/Language.php @@ -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 # diff --git a/stylesheets/wikibits.js b/stylesheets/wikibits.js index 678192cf46..b5e5de6c4a 100644 --- a/stylesheets/wikibits.js +++ b/stylesheets/wikibits.js @@ -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("
"+ + "
"); + } + +} + 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 +} diff --git a/stylesheets/wikistandard.css b/stylesheets/wikistandard.css index f167a3717e..ceb3d2a8ad 100644 --- a/stylesheets/wikistandard.css +++ b/stylesheets/wikistandard.css @@ -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; } -- 2.20.1