/*!
* 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 ) {
'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
+ '
'
+ ''
+ '
'
+ ''
+ '
'
+ '
';
function InputSettings( $parent ) {
this.nameI18n = 'ext-uls-input-settings-title-short';
this.descriptionI18n = 'ext-uls-input-settings-desc';
this.$template = $( template );
this.uiLanguage = this.getInterfaceLanguage();
this.contentLanguage = this.getContentLanguage();
this.$imes = null;
this.$parent = $parent;
// ime system is lazy loaded, make sure it is initialized
mw.ime.init();
this.savedRegistry = $.extend( true, {}, $.ime.preferences.registry );
}
InputSettings.prototype = {
constructor: InputSettings,
/**
* Render the module into a given target
*/
render: function () {
var $enabledOnly,
webfonts = $( 'body' ).data( 'webfonts' );
this.dirty = false;
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.$parent.i18n();
if ( webfonts ) {
webfonts.refresh();
}
this.listen();
},
/**
* Mark dirty, there are unsaved changes. Enable the apply button.
* Useful in many places when something changes.
*/
markDirty: function () {
this.dirty = true;
this.$parent.$window.find( 'button.uls-settings-apply' ).prop( 'disabled', false );
},
prepareInputmethods: function ( language ) {
var index, inputSettings, $imeListContainer, defaultInputmethod,
imes, selected, imeId, $imeListTitle;
imes = $.ime.languages[ language ];
$imeListTitle = this.$template.find( '.ext-uls-input-settings-imes-title' );
$imeListContainer = this.$template.find( '.uls-input-settings-inputmethods-list' );
$imeListContainer.empty();
if ( !imes ) {
$imeListContainer.append( $( '