'key' => 'R'
)
);
- $toolbar ="<script type='$wgJsMimeType'>\n/*<![CDATA[*/\n";
+ $toolbar = "<div id='toolbar'>\n";
+ $toolbar.="<script type='$wgJsMimeType'>\n/*<![CDATA[*/\n";
- $toolbar.="document.writeln(\"<div id='toolbar'>\");\n";
foreach($toolarray as $tool) {
$image=$wgStylePath.'/common/images/'.$tool['image'];
$toolbar.="addButton('$image','$tip','$open','$close','$sample');\n";
}
- $toolbar.="document.writeln(\"</div>\");\n";
$toolbar.="/*]]>*/\n</script>";
+ $toolbar.="\n</div>";
return $toolbar;
}
<!--[if lt IE 7]><script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath') ?>/common/IEFixes.js"></script>
<meta http-equiv="imagetoolbar" content="no" /><![endif]-->
<script type="<?php $this->text('jsmimetype') ?>">var skin = '<?php $this->text('skinname')?>';var stylepath = '<?php $this->text('stylepath')?>';</script>
- <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath' ) ?>/common/wikibits.js"><!-- wikibits js --></script>
+ <script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('stylepath' ) ?>/common/wikibits.js?1"><!-- wikibits js --></script>
<?php if($this->data['jsvarurl' ]) { ?>
<script type="<?php $this->text('jsmimetype') ?>" src="<?php $this->text('jsvarurl' ) ?>"><!-- site js --></script>
<?php } ?>
}
}
+mwEditButtons = [];
+mwCustomEditButtons = []; // eg to add in MediaWiki:Common.js
+
// 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) {
// Don't generate buttons for browsers which don't fully
// support it.
- if (!document.selection && !is_gecko) {
+ mwEditButtons[mwEditButtons.length] =
+ {"imageFile": imageFile,
+ "speedTip": speedTip,
+ "tagOpen": tagOpen,
+ "tagClose": tagClose,
+ "sampleText": sampleText};
+}
+
+// this function generates the actual toolbar buttons with localized text
+// we use it to avoid creating the toolbar where javascript is not enabled
+function mwInsertEditButton(parent, item) {
+ var image = document.createElement("img");
+ image.width = 23;
+ image.height = 22;
+ image.src = item.imageFile;
+ image.border = 0;
+ image.alt = item.speedTip;
+ image.title = item.speedTip;
+ image.style.cursor = "pointer";
+ image.onclick = function() {
+ insertTags(item.tagOpen, item.tagClose, item.sampleText);
return false;
}
- imageFile = escapeQuotesHTML(imageFile);
- speedTip = escapeQuotesHTML(speedTip);
- tagOpen = escapeQuotes(tagOpen);
- tagClose = escapeQuotes(tagClose);
- sampleText = escapeQuotes(sampleText);
- var mouseOver = "";
+
+ parent.appendChild(image);
+}
- document.write("<a href=\"javascript:insertTags");
- document.write("('"+tagOpen+"','"+tagClose+"','"+sampleText+"');\">");
- document.write("<img width=\"23\" height=\"22\" src=\""+imageFile+"\" border=\"0\" alt=\""+speedTip+"\" title=\""+speedTip+"\""+mouseOver+">");
- document.write("</a>");
- return;
+function mwSetupToolbar() {
+ var toolbar = document.getElementById('toolbar');
+ if (!toolbar) return false;
+
+ var textbox = document.getElementById('wpTextbox1');
+ if (!textbox) return false;
+
+ // Don't generate buttons for browsers which don't fully
+ // support it.
+ if (!document.selection && textbox.selectionStart == null)
+ return false;
+
+ for (var i in mwEditButtons) {
+ mwInsertEditButton(toolbar, mwEditButtons[i]);
+ }
+ for (var i in mwCustomEditButtons) {
+ mwInsertEditButton(toolbar, mwCustomEditButtons[i]);
+ }
}
function escapeQuotes(text) {
}
hookEvent("load", allmessagesshow);
+hookEvent("load", mwSetupToolbar);
\ No newline at end of file