/** * ULS-based ime settings panel * * Copyright (C) 2012 Alolita Sharma, Amir Aharoni, Arun Ganesh, Brandon Harris, * Niklas Laxström, Pau Giner, Santhosh Thottingal, Siebrand Mazeland and other * contributors. See CREDITS for a list. * * UniversalLanguageSelector is dual licensed GPLv2 or later and MIT. You don't * have to do anything special to choose one license or the other and you don't * have to notify anyone which license you are using. You are free to use * UniversalLanguageSelector in commercial projects as long as the copyright * header is left intact. See files GPL-LICENSE and MIT-LICENSE for details. * * @file * @ingroup Extensions * @licence GNU General Public Licence 2.0 or later * @licence MIT License */ ( function ( $, mw, undefined ) { 'use strict'; var template = '
' + '
' // Top "Display settings" title + '
' + '

' + '
' + '
' // "Language for ime", title above the buttons row + '
' + '
' + '

' + '
' + '
' // UI languages buttons row + '
' + '
' + '
' // Web IMEs enabling chechbox with label + '
' + '
' // "Input settings for language xyz" title + '

' + '
' + '
' // Disable IME system button + '
' + '
' + '
' + '' + '
' + '
' // Separator + '
' // Apply and Cancel buttons + '
' + '
' + '' + '' + '
' + '
' + '
'; function InputSettings( $parent ) { this.name = $.i18n( 'ext-uls-input-settings-title-short' ); this.description = $.i18n( 'ext-uls-input-settings-desc' ); this.$template = $( template ); this.imeLanguage = this.getImeLanguage(); this.contentLanguage = this.getContentLanguage(); this.$imes = null; this.$parent = $parent; } InputSettings.prototype = { Constructor: InputSettings, /** * Render the module into a given target */ render: function () { this.$parent.$settingsPanel.empty(); this.$imes = $( 'body' ).data( 'ime' ); this.$parent.$settingsPanel.append( this.$template ); if ( $.ime.preferences.isEnabled() ) { this.prepareLanguages(); this.prepareInputmethods( this.imeLanguage ); } else { // Hide the language list this.$template.find( 'div.uls-input-settings-languages-title' ).hide(); this.$template.find( 'div.uls-ui-languages' ).hide(); // Hide input methods this.$template.find( 'div.uls-input-settings-inputmethods-list' ).hide(); } this.prepareToggleButton(); this.$template.i18n(); this.listen(); }, prepareInputmethods: function ( language ) { var inputsettings, $imeListContainer, defaultInputmethod, imes, selected, imeId, index = 0, $imeListTitle; imes = $.ime.languages[language]; this.imeLanguage = language; $imeListTitle = this.$template.find( '.ext-uls-input-settings-imes-title' ); $imeListContainer = this.$template.find( '.uls-input-settings-inputmethods-list' ); $imeListContainer.show(); $imeListContainer.find( 'label' ).remove(); if ( !imes ) { $imeListTitle.text( '' ); return; } inputsettings = this; $imeListTitle.text( $.i18n( 'ext-uls-input-settings-ime-settings', $.uls.data.getAutonym( language ) ) ); defaultInputmethod = $.ime.preferences.getIM( language ) || imes.inputmethods[0]; for ( index in imes.inputmethods ) { imeId = imes.inputmethods[index]; selected = defaultInputmethod === imeId; //$.ime.load( imeId, function () { $imeListContainer.append( inputsettings.renderInputmethodOption( imeId, selected ) ); //} ); } $imeListContainer.append( inputsettings.renderInputmethodOption( 'system', defaultInputmethod === 'system' ) ); }, renderInputmethodOption: function ( imeId, selected ) { var $imeLabel, name, description, inputmethod, $inputMethodItem; $imeLabel = $( '