Content deleted Content added
No edit summary |
No edit summary |
||
Line 43:
$.extend(button, props || {});
if (window.console && console.error)
console.error('addToolbarButtons.js:
}▼
error('No button id specified.');
return;▼
}
error('An element with id ' + button.id + ' already exists on the page.');
return;
}
Line 57 ⟶ 66:
button.inserts = (button.before + button.between + button.after).length > 0;
if (!button.callback && !button.inserts) {
▲ console.error('addToolbarButtons.js: No callback function or characters to insert specified.');
▲ return;
▲ }
▲ var oldButton = $('#' + button.id);
$(oldButton[0].cloneNode()) // clone to remove event handlers▼
▲ .attr('id', button.id)
.click(button.callback)▼
);▼
return;
}
Line 111 ⟶ 108:
// add a button to the classic toolbar
mw.loader.using('mediawiki.action.edit', function () {
▲ var tempButtonId = button.id; //+ (!button.inserts ? 'TempButton' : '');
mw.toolbar.addButton(
(button.iconUrlClassic || button.iconUrl),
Line 120 ⟶ 116:
tempButtonId
);
if (button.
button.callback && $('#' + button.id).click(button.callback);
else {
var $tempButton = $('#' + tempButtonId);
if ($tempButton[0]) {
// if not done the selection in the textarea is collapsed
// before the callback function is called
var newB = $tempButton[0].cloneNode();
newB.id = button.id;
$tempButton.after(newB).remove();
▲ $(newB).click(button.callback);
}
}
});
|