From 99d5da945de001f5d6eddaf93e12ed474c869bb1 Mon Sep 17 00:00:00 2001 From: georggi Date: Sat, 16 Jan 2016 15:00:39 +0200 Subject: [PATCH] Special:Import: Select first subproject if first project was empty Previously, the first subproject in alphabetical order would be selected the first time the subproject dropdown was shown. Now, the first subproject in the list is selected, making it easier for common selections to be placed at the top of the list. Change-Id: Id6b9c6076630e4dad70ebe0f1185a59015b9a01f --- .../src/mediawiki.special/mediawiki.special.import.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/resources/src/mediawiki.special/mediawiki.special.import.js b/resources/src/mediawiki.special/mediawiki.special.import.js index 5622b32a38..3357461f2a 100644 --- a/resources/src/mediawiki.special/mediawiki.special.import.js +++ b/resources/src/mediawiki.special/mediawiki.special.import.js @@ -2,7 +2,8 @@ * JavaScript for Special:Import */ ( function ( $ ) { - function updateImportSubprojectList( firstTime ) { + var subprojectListAlreadyShown; + function updateImportSubprojectList() { var $projectField = $( '#mw-import-table-interwiki #interwiki' ), $subprojectField = $projectField.parent().find( '#subproject' ), $selected = $projectField.find( ':selected' ), @@ -14,12 +15,13 @@ option = document.createElement( 'option' ); option.appendChild( document.createTextNode( el ) ); option.setAttribute( 'value', el ); - if ( oldValue === el && firstTime !== true ) { + if ( oldValue === el && subprojectListAlreadyShown === true ) { option.setAttribute( 'selected', 'selected' ); } return option; } ); $subprojectField.show().empty().append( options ); + subprojectListAlreadyShown = true; } else { $subprojectField.hide(); } @@ -29,7 +31,7 @@ var $projectField = $( '#mw-import-table-interwiki #interwiki' ); if ( $projectField.length ) { $projectField.change( updateImportSubprojectList ); - updateImportSubprojectList( true ); + updateImportSubprojectList(); } } ); }( jQuery ) ); -- 2.20.1