ಮೀಡಿಯವಿಕಿ:Gadget-IndexFormTools.js
ಗೋಚರ
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
/*
* Simple JS to provide some reactivity to the index page form
*/
/* eslint-disable one-var, vars-on-top */
( function ( mw, $ ) {
// only in edit of Index NS
if ( mw.config.get( 'wgCanonicalNamespace' ) !== 'Index' ||
[ 'edit', 'submit' ].indexOf( mw.config.get( 'wgAction' ) ) === -1 ) {
return;
}
$( function () {
// eslint-disable-next-line no-jquery/no-global-selector
var progWidget = OO.ui.infuse( $( '#wpprpindex-Progress' ).parent() );
// eslint-disable-next-line no-jquery/no-global-selector
var validDateWidget = OO.ui.infuse( $( '#wpprpindex-Validation_date' ).parent() );
function isValidated() {
return progWidget.getValue() === 'T';
}
/**
* Update the status of the validated date widget
*/
function updateValidDate() {
var canSetDate = isValidated();
validDateWidget.setDisabled( !canSetDate );
var placeholder;
if ( !canSetDate ) {
placeholder = 'Validation date cannot be set before the work is validated.';
} else {
var now = new Date();
// don't use wgMonthNames, the categories are fixed as English
var months = [ 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December' ];
placeholder = months[ now.getMonth() ] + ' ' + now.getFullYear();
}
validDateWidget.$input.attr( 'placeholder', placeholder );
}
function getCheckerUrl() {
var pageName = mw.config.get( 'wgPageName' );
return 'https://checker.toolforge.org/?db=enwikisource_p&title=' + pageName;
}
function addLinkToFieldLabel( id, link ) {
$( id )
.closest( '.oo-ui-fieldLayout-body' )
.find( 'label' )
.append( link
.css( { 'font-size': '92%', float: 'right' } )
);
}
updateValidDate();
progWidget.on( 'change', function () {
updateValidDate();
} );
addLinkToFieldLabel( '#wpprpindex-Transclusion', $( '<a>' )
.attr( 'href', getCheckerUrl() )
.attr( 'target', '_blank' )
.append( 'Check transclusion' )
);
} );
// eslint-disable-next-line no-undef
}( mediaWiki, jQuery ) );