/** * 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.getInterfaceLanguage(); this.contentLanguage = this.getContentLanguage(); this.$imes = null; this.$parent = $parent; this.savedRegistry = $.extend( true, {}, $.ime.preferences.registry ); } InputSettings.prototype = { Constructor: InputSettings, /** * Render the module into a given target */ render: function () { var $enabledOnly; this.$parent.$settingsPanel.empty(); this.$imes = $( 'body' ).data( 'ime' ); this.$parent.$settingsPanel.append( this.$template ); $enabledOnly = this.$template.find( '.enabled-only' ); if ( $.ime.preferences.isEnabled() ) { $enabledOnly.removeClass( 'hide' ); } else { // Hide the language list and ime selector $enabledOnly.addClass( 'hide' ); } this.prepareLanguages(); this.prepareToggleButton(); this.$template.i18n(); this.listen(); }, /** * Enable the apply button. * Useful in many places when something changes. */ enableApplyButton: function () { this.$template.find( 'button.uls-input-settings-apply' ).prop( 'disabled', false ); }, disableApplyButton: function () { this.$template.find( 'button.uls-input-settings-apply' ).prop( 'disabled', true ); }, prepareInputmethods: function ( language ) { var index = 0, inputSettings, $imeListContainer, defaultInputmethod, imes, selected, imeId, $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.find( 'label' ).remove(); if ( !imes ) { $imeListContainer.append( $( '