JS for button generation
authorErik Moeller <erik@users.mediawiki.org>
Sun, 18 Jan 2004 08:24:10 +0000 (08:24 +0000)
committerErik Moeller <erik@users.mediawiki.org>
Sun, 18 Jan 2004 08:24:10 +0000 (08:24 +0000)
stylesheets/wikibits.js

index 70f0709..678192c 100644 (file)
@@ -74,6 +74,28 @@ function toggleToc() {
        }
 }
 
+// this function generates the actual toolbar buttons with localized text
+// 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);
+       sampleText=escapeQuotes(sampleText);
+       document.write("<a href=\"#\" onclick=\"javascript:insertTags");
+       document.write("('"+tagOpen+"','"+tagClose+"','"+sampleText+"');\">");
+       document.write("<img width=\"23\" height=\"22\" src=\""+imageFile+"\" border=\"0\" ALT=\""+speedTip+"\" TITLE=\""+speedTip+"\">");
+       document.write("</a>");
+       return;
+}
+
+function escapeQuotes(text) {
+
+       text=text.replace(/'/g,"\\'");
+       text=text.replace(/\n/g,"\\n");
+       return text;
+}
+
 // apply tagOpen/tagClose to selection in textarea,
 // use sampleText instead of selection if there is none
 // copied and adapted from phpBB