Special:Import: Select first subproject if first project was empty
authorgeorggi <bmp2558@gmail.com>
Sat, 16 Jan 2016 13:00:39 +0000 (15:00 +0200)
committerTTO <at.light@live.com.au>
Sat, 16 Jan 2016 13:08:24 +0000 (13:08 +0000)
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

resources/src/mediawiki.special/mediawiki.special.import.js

index 5622b32..3357461 100644 (file)
@@ -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' ),
                                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 ) );