Added release notes for 'ContentHandler::runLegacyHooks' removal
[mediawiki.git] / resources / src / mediawiki.special / mediawiki.special.import.js
blob3357461f2a2a3ce44226a1cddb9bf76d2a456c62
1 /*!
2  * JavaScript for Special:Import
3  */
4 ( function ( $ ) {
5         var subprojectListAlreadyShown;
6         function updateImportSubprojectList() {
7                 var $projectField = $( '#mw-import-table-interwiki #interwiki' ),
8                         $subprojectField = $projectField.parent().find( '#subproject' ),
9                         $selected = $projectField.find( ':selected' ),
10                         oldValue = $subprojectField.val(),
11                         option, options;
13                 if ( $selected.attr( 'data-subprojects' ) ) {
14                         options = $.map( $selected.attr( 'data-subprojects' ).split( ' ' ), function ( el ) {
15                                 option = document.createElement( 'option' );
16                                 option.appendChild( document.createTextNode( el ) );
17                                 option.setAttribute( 'value', el );
18                                 if ( oldValue === el && subprojectListAlreadyShown === true ) {
19                                         option.setAttribute( 'selected', 'selected' );
20                                 }
21                                 return option;
22                         } );
23                         $subprojectField.show().empty().append( options );
24                         subprojectListAlreadyShown = true;
25                 } else {
26                         $subprojectField.hide();
27                 }
28         }
30         $( function () {
31                 var $projectField = $( '#mw-import-table-interwiki #interwiki' );
32                 if ( $projectField.length ) {
33                         $projectField.change( updateImportSubprojectList );
34                         updateImportSubprojectList();
35                 }
36         } );
37 }( jQuery ) );