User:V111P/js/addToolbarButtons.js: Difference between revisions

Content deleted Content added
mNo edit summary
No edit summary
Line 1:
/*
* addToolbarButtons.js
* Add Toolbar Buttons, version 2013-10
*
* This function lets you add function-calling buttons
Line 8 ⟶ 9:
* (The visual editor is not supported).
*
* Home and documentation: //en.wikipedia.org/User:V111P/js/addToolbarButtons
* 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).remove();
 
// 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 () {
var tempButtonId =oldButton.attr('id', button.id + (!button.inserts ? 'TempButton' : '');
button.callback && replaceWith($(oldButton[0].cloneNode()).attr('#id' +, button.id).click(button.callback));
mw.toolbar.addButton(
}
(button.iconUrlClassic || button.iconUrl),
else {
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(
);
if (button.inserts)iconUrlClassic {|| button.iconUrl),
button.tooltip,
button.callback && $('#' + button.id).click(button.callback);
button.before, button.after, button.between,
}
tempButtonId,
else {
var $tempButton = $('#' + tempButtonId);
);
if ($tempButton[0]) {
if (button.inserts) {
// clone the button to remove added event handlers
button.callback && $(newB'#' + button.id).click(button.callback);
var newB = $tempButton[0].cloneNode();
newB.id = button.id;
$tempButton.after(newB).remove();
$(newB).click(button.callback);
}
} else {
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);
}
}
});
}
}