Content deleted Content added
mNo edit summary |
No edit summary |
||
Line 1:
/*
* addToolbarButtons.js
*
*
* This function lets you add function-calling buttons
Line 8 ⟶ 9:
* (The visual editor is not supported).
*
* You can use this code under the license CC0
▲ * Home and documentation: //en.wikipedia.org/User:V111P/js/addToolbarButtons
*/
Line 61 ⟶ 62:
}
var oldButton = $('#' + button.id
// add button to the new, WikiEditor, toolbar
Line 80 ⟶ 81:
}
};
oldButton.remove();
$('#wpTextbox1').wikiEditor('addToToolbar', {
'section': button.section,
Line 100 ⟶ 102:
if ($('#' + button.id).size() == 0) {
// add a button to the classic toolbar
if (!button.inserts && oldButton[0]) {
mw.loader.using('mediawiki.action.edit', function () {▼
mw.toolbar.addButton(▼
button.tooltip,▼
▲ mw.loader.using('mediawiki.action.edit', function () {
button.before, button.after, button.between,▼
oldButton.remove();
tempButtonId,▼
var tempButtonId = button.id + (!button.inserts ? 'TempButton' : '');
▲ mw.toolbar.addButton(
);▼
▲ button.tooltip,
▲ button.callback && $('#' + button.id).click(button.callback);
▲ button.before, button.after, button.between,
▲ }
▲ tempButtonId,
▲ else {
▲ );
if ($tempButton[0]) {▼
if (button.inserts) {
// clone the button to remove added event handlers▼
var newB = $tempButton[0].cloneNode();▼
newB.id = button.id;▼
$tempButton.after(newB).remove();▼
▲ $(newB).click(button.callback);
}
var $tempButton = $('#' + tempButtonId);
});▼
▲ if ($tempButton[0]) {
▲ // clone the button to remove added event handlers
▲ var newB = $tempButton[0].cloneNode();
▲ newB.id = button.id;
▲ $tempButton.after(newB).remove();
$(newB).click(button.callback);
}
}
▲ });
}
}
|