Don't auto-select first alphabetical item in import subproject list
authorThis, that and the other <at.light@live.com.au>
Sat, 30 Aug 2014 05:18:46 +0000 (15:18 +1000)
committerOri.livneh <ori@wikimedia.org>
Tue, 13 Jan 2015 06:08:11 +0000 (06:08 +0000)
Currently when you load Special:Import, the first subproject in
alphabetical order gets selected. Instead, the first subproject in the
list should be selected by default (i.e. no <option> element should be
given the "selected" attribute).

Change-Id: I442a9afadc75f42f63d8c9c32ee2920374ceb26d

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

index a9a985e..5622b32 100644 (file)
@@ -2,7 +2,7 @@
  * JavaScript for Special:Import
  */
 ( function ( $ ) {
-       function updateImportSubprojectList() {
+       function updateImportSubprojectList( firstTime ) {
                var $projectField = $( '#mw-import-table-interwiki #interwiki' ),
                        $subprojectField = $projectField.parent().find( '#subproject' ),
                        $selected = $projectField.find( ':selected' ),
@@ -14,7 +14,7 @@
                                option = document.createElement( 'option' );
                                option.appendChild( document.createTextNode( el ) );
                                option.setAttribute( 'value', el );
-                               if ( oldValue === el ) {
+                               if ( oldValue === el && firstTime !== true ) {
                                        option.setAttribute( 'selected', 'selected' );
                                }
                                return option;
@@ -29,7 +29,7 @@
                var $projectField = $( '#mw-import-table-interwiki #interwiki' );
                if ( $projectField.length ) {
                        $projectField.change( updateImportSubprojectList );
-                       updateImportSubprojectList();
+                       updateImportSubprojectList( true );
                }
        } );
 }( jQuery ) );