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