MediaWiki:Gadget-newPage.js: Difference between revisions
Jump to navigation
Jump to search
(Created page with "$(function () { var $button, $window; function createWindow(modal){ modal.content = new OO.ui.PanelLayout({ padded: true, expanded: false }); var pagenameInput = new OO.ui.TextInputWidget({placeholder: 'Full page name including namespace', type: 'text', id: 'gadget-newpage-pagename'}); var submitButton = new OO.ui.ButtonInputWidget({ label: 'Create', flags: ['primary', 'progressive']}); var cancelButton = new OO.ui.ButtonInputWidget({ label: 'Cancel', flags:...") |
No edit summary Tag: Manual revert |
(One intermediate revision by the same user not shown) | |
(No difference)
|
Latest revision as of 17:15, 17 October 2024
$(function () {
var $button, $window;
function createWindow(modal){
modal.content = new OO.ui.PanelLayout({ padded: true, expanded: false });
var pagenameInput = new OO.ui.TextInputWidget({placeholder: 'Full page name including namespace', type: 'text', id: 'gadget-newpage-pagename'});
var submitButton = new OO.ui.ButtonInputWidget({ label: 'Create', flags: ['primary', 'progressive']});
var cancelButton = new OO.ui.ButtonInputWidget({ label: 'Cancel', flags: 'destructive'});
var submitAction = function(modal) {
var page = pagenameInput.getValue();
if (page == '') return;
var url = mw.util.getUrl(page, {action: 'edit'});
window.location.assign(url);
};
submitButton.on('click', submitAction);
pagenameInput.on('enter', submitAction);
cancelButton.on('click', function(modal){window.OOUIWindowManager.closeWindow(modal);}, [modal]);
var fieldset = new OO.ui.FieldsetLayout({});
fieldset.addItems([
new OO.ui.FieldLayout(pagenameInput, { label: 'Page name', help: 'Full page name of the page to created, including namespace' })
]);
modal.content.$element.append(fieldset.$element, '<br>', cancelButton.$element, submitButton.$element);
modal.$body.append(modal.content.$element);
}
function openWindow(e){
e.preventDefault();
if ($window == undefined) {
rswiki.createOOUIWindow('gadget-newpage-window', 'Create new page', {}, createWindow, true).then(function(w){
$window = w;
});
} else {
window.OOUIWindowManager.openWindow('gadget-newpage-window');
}
}
function init(){
$button = $('<li>').attr('id', 't-gadget-newpage').append($('<a>').attr('href', '#').text('Make new page'));
$button.click(openWindow);
$('#p-tb .vector-menu-content ul').append($button);
}
init();
})