/*! * JS for special page. * @author Niklas Laxström * @author Sucheta Ghoshal * @author Amir E. Aharoni * @author Pau Giner * @license GPL-2.0-or-later */ ( function () { 'use strict'; var delay; /** * A callback for sorting translations. * * @param {Object} translationA Object loaded from translation stash * @param {Object} translationB Object loaded from translation stash * @return {number} String comparison of language codes */ function sortTranslationsByLanguage( translationA, translationB ) { var a = translationA.title.split( '/' ).pop(), b = translationB.title.split( '/' ).pop(); return a.localeCompare( b ); } function doApiAction( options ) { var api = new mw.Api(); options = $.extend( {}, { action: 'translatesandbox' }, options ); return api.postWithToken( 'csrf', options ).promise(); } function removeSelectedRequests() { var $nextRequest, $selectedRequests = $( '.request-selector:checked' ); $nextRequest = $selectedRequests .first() // First selected request .closest( '.request' ) // The request corresponds that checkbox .prevAll( ':not(.hide)' ) // Go back till a non-hidden request .first(); // The above selecter gives list from bottom to top. Select the bottom one. $selectedRequests.closest( '.request' ).remove(); updateRequestCount(); if ( !$nextRequest.length ) { // If there's no request above the first checked request, // try to get the first request in the column $nextRequest = $( '.requests .request:not(.hide)' ).first(); } if ( $nextRequest.length ) { $nextRequest.click(); updateSelectedIndicator( 1 ); } else { updateSelectedIndicator( 0 ); } } /** * Display the request details when user clicks on a request item * * @param {Object} request The request data set from backend on request items */ function displayRequestDetails( request ) { var storage, $reminderStatus = $( '' ).addClass( 'reminder-status' ), $detailsPane = $( '.details.pane' ); if ( request.reminderscount ) { $reminderStatus.text( mw.msg( 'tsb-reminder-sent', request.reminderscount, request.lastreminder ) ); } $detailsPane.empty().append( $( '
' ) .addClass( 'tsb-header row' ) .text( request.username ), $( '
' ) .addClass( 'reminder-email row' ) .append( $( '' ).text( request.email ), $( '' ) .prop( 'href', '#' ) .addClass( 'send-reminder link' ) .text( mw.msg( 'tsb-reminder-link-text' ) ) .on( 'click', function ( e ) { e.preventDefault(); $reminderStatus .text( mw.msg( 'tsb-reminder-sending' ) ); doApiAction( { do: 'remind', userid: request.userid } ).done( function () { $reminderStatus.text( mw.msg( 'tsb-reminder-sent-new' ) ); } ).fail( function () { $reminderStatus.text( mw.msg( 'tsb-reminder-failed' ) ); } ); } ), $reminderStatus ), $( '
' ) .addClass( 'languages row autonym' ), $( '
' ) .addClass( 'signup-comment row' ), $( '
' ) .addClass( 'actions row' ) .append( $( '