mw.loader.implement("ext.uls.ime",function(){(function($,mw,document,undefined){'use strict';var mwImeRulesPath,inputSelector,inputPreferences,ulsIMEPreferences,customHelpLink;mwImeRulesPath=mw.config.get('wgExtensionAssetsPath')+'/UniversalLanguageSelector/lib/jquery.ime/';inputSelector='input:not([type]), input[type=text], input[type=search], textarea, [contenteditable]';inputPreferences=mw.uls.preferences();mw.ime=mw.ime||{};mw.ime.getLanguagesWithIME=function(){var language,ulsLanguages=mw.config.get('wgULSLanguages'),availableLanguages={};for(language in $.ime.languages){availableLanguages[language]=ulsLanguages[language];}return availableLanguages;};mw.ime.getIMELanguageList=function(){var unique=[],imeLanguageList,previousIMELanguages;previousIMELanguages=$.ime.preferences.getPreviousLanguages()||[];imeLanguageList=previousIMELanguages.concat(mw.uls.getFrequentLanguageList());$.each(imeLanguageList,function(i,v){if($.inArray(v,unique)===-1){unique.push(v);}});return unique.slice (0,6);};ulsIMEPreferences={save:function(callback){if(!this.registry.isDirty){if(callback){callback.call(this,true);}return;}this.registry.isDirty=undefined;inputPreferences=mw.uls.preferences();inputPreferences.set('ime',this.registry);inputPreferences.save(callback);this.registry.isDirty=false;},load:function(){this.registry=inputPreferences.get('ime')||this.registry;},disable:function(){this.registry.isDirty=true;this.registry.enable=false;},enable:function(){this.registry.isDirty=true;this.registry.enable=true;},isEnabled:function(){if(this.registry.enable===undefined){return mw.config.get('wgULSIMEEnabled');}else{return this.registry.enable;}},getDefaultLanguage:function(){return mw.config.get('wgContentLanguage');}};customHelpLink=function(){var $disableInputToolsLink,$moreSettingsLink,imeselector=this;$disableInputToolsLink=$('').addClass('uls-ime-disable-link').attr('data-i18n','ext-uls-input-disable');$moreSettingsLink=$('').addClass('uls-ime-more-settings-link'); mw.loader.using(mw.uls.languageSettingsModules,function(){$moreSettingsLink.languagesettings({defaultModule:'input',onClose:function(){imeselector.$element.focus();},top:imeselector.$element.offset().top});});$moreSettingsLink.on('click',function(e){var languageSettings=$(this).data('languagesettings');imeselector.hide();if(!languageSettings){$(this).languagesettings({defaultModule:'input',onClose:function(){imeselector.$element.focus();},top:imeselector.$element.offset().top}).click();}e.stopPropagation();});$disableInputToolsLink.i18n();$disableInputToolsLink.on('click',function(e){$.ime.preferences.disable();imeselector.hide();imeselector.$imeSetting.hide();$.ime.preferences.save(function(){mw.ime.disable();imeNotification();mw.hook('mw.uls.ime.disable').fire('menu');});e.stopPropagation();});imeselector.$menu.webfonts();return $('
').addClass('uls-ime-menu-settings-item').append($disableInputToolsLink,$moreSettingsLink);};mw.ime.disable=function(){$(inputSelector).trigger( 'destroy.ime');};mw.ime.init=function(){if(!$.ime){return;}if($.ime.preferences.isEnabled){return;}$.extend($.ime.preferences,ulsIMEPreferences);$.extend($.ime.defaults,{imePath:mwImeRulesPath});$.ime.preferences.load();$.fn.imeselector.Constructor.prototype.helpLink=customHelpLink;$.fn.imeselector.Constructor.prototype.getAutonym=function(languageCode){return $.uls.data.getAutonym(languageCode);};};mw.ime.setup=function(){var imeSelectors=mw.config.get('wgULSImeSelectors').join(', ');mw.ime.init();$('body').on('focus.ime',imeSelectors,function(){mw.ime.handleFocus($(this));});};mw.ime.handleFocus=function($input){var noImeSelectors;if($input.is('.noime')||$input.data('ime')){return;}noImeSelectors=mw.config.get('wgULSNoImeSelectors').join(', ');if(noImeSelectors.length&&$input.is(noImeSelectors)){$input.addClass('noime');return;}if(!$.ime.preferences.isEnabled()){return;}if($input.is('[contenteditable]')&&!window.rangy){mw.loader.using('rangy.core',function(){mw.ime.addIme($input);}); return;}mw.ime.addIme($input);};mw.ime.addIme=function($input){var imeselector;$input.ime({languages:mw.ime.getIMELanguageList(),languageSelector:function(){var $ulsTrigger;$ulsTrigger=$('').text('...').addClass('ime-selector-more-languages selectable-row selectable-row-item').attr({title:$.i18n('ext-uls-input-settings-more-languages-tooltip')});$ulsTrigger.uls({onSelect:function(language){$input.data('imeselector').selectLanguage(language);$input.focus();},languages:mw.ime.getLanguagesWithIME(),top:$input.offset().top});return $ulsTrigger;},helpHandler:function(ime){return $('').attr({href:mw.msg('uls-ime-helppage').replace('$1',ime),target:'_blank',title:$.i18n('ext-uls-ime-help')}).addClass('ime-perime-help').click(function(event){event.stopPropagation();});}});imeselector=$input.data('imeselector');if(imeselector){imeselector.selectLanguage(imeselector.decideLanguage());imeselector.$element.on('setim.ime',function(event,inputMethod){mw.hook('mw.uls.ime.change').fire( inputMethod);});}};function imeNotification(){var notificationMsg=(mw.config.get('wgULSPosition')==='personal')?'ext-uls-input-disable-notification-info-personal':'ext-uls-input-disable-notification-info-interlanguage',$notification=$('
').addClass('uls-ime-notification-bubble').append($('
').attr('data-i18n','ext-uls-input-disable-notification'),$('
').addClass('link').attr('data-i18n','ext-uls-input-disable-notification-undo').on('click',function(){$.ime.preferences.enable();$.ime.preferences.save(function(){mw.ime.setup();});}),$('
').attr('data-i18n',notificationMsg));mw.notify($notification.i18n());}}(jQuery,mediaWiki,document));;},{},{"uls-ime-helppage":"https://www.mediawiki.org/wiki/Special:MyLanguage/Help:Extension:UniversalLanguageSelector/Input_methods/$1"});mw.loader.implement("ext.uls.languagenames",function(){mw.config.set("wgULSLanguages",{"ab":"Abkhazian","ace":"Achinese","af":"Afrikaans","ak":"Akan","aln":"Gheg Albanian","am":"Amharic","an":"Aragonese", "ang":"Old English","anp":"Angika","ar":"Arabic","arc":"Aramaic","arn":"Mapuche","ary":"Moroccan Spoken Arabic","arz":"Egyptian Spoken Arabic","as":"Assamese","ast":"Asturian","av":"Avaric","avk":"Kotava","ay":"Aymara","az":"Azerbaijani","azb":"South Azerbaijani","ba":"Bashkir","bar":"Bavarian","bbc":"Batak Toba","bbc-latn":"Batak Toba","bcc":"Southern Balochi","bcl":"Bikol Central","be":"Belarusian","be-tarask":"Belarusian (Taraškievica orthography)","bg":"Bulgarian","bh":"Bihari","bho":"Bhojpuri","bi":"Bislama","bjn":"Banjar","bm":"Bambara","bn":"Bengali","bo":"Tibetan","bpy":"Bishnupria Manipuri","bqi":"Bakhtiari","br":"Breton","brh":"Brahui","bs":"Bosnian","bug":"Buginese","bxr":"буряад","ca":"Catalan","cbk-zam":"Chavacano de Zamboanga","cdo":"Min Dong Chinese","ce":"Chechen","ceb":"Cebuano","ch":"Chamorro","chr":"Cherokee","ckb":"Sorani Kurdish","co":"Corsican","cps":"Capiznon","crh":"Crimean Turkish","crh-latn":"Crimean Turkish (Latin script)","crh-cyrl": "Crimean Turkish (Cyrillic script)","cs":"Czech","csb":"Kashubian","cu":"Church Slavic","cv":"Chuvash","cy":"Welsh","da":"Danish","de":"German","de-at":"Austrian German","de-ch":"Swiss High German","de-formal":"German (formal address)","diq":"Zazaki","dsb":"Lower Sorbian","dtp":"Central Dusun","dv":"Divehi","dz":"Dzongkha","ee":"Ewe","egl":"Emiliàn","el":"Greek","eml":"Emiliano-Romagnolo","en":"English","en-ca":"Canadian English","en-gb":"British English","eo":"Esperanto","es":"Spanish","et":"Estonian","eu":"Basque","ext":"Extremaduran","fa":"Persian","ff":"Fulah","fi":"Finnish","fit":"meänkieli","fj":"Fijian","fo":"Faroese","fr":"French","frc":"Cajun French","frp":"Franco-Provençal","frr":"Northern Frisian","fur":"Friulian","fy":"Western Frisian","ga":"Irish","gag":"Gagauz","gan":"Gan","gan-hans":"Simplified Gan script","gan-hant":"Traditional Gan script","gd":"Scottish Gaelic","gl":"Galician","glk":"Gilaki","gn":"Guarani","gom-latn":"Goan Konkani (Latin script)","got":"Gothic", "grc":"Ancient Greek","gsw":"Swiss German","gu":"Gujarati","gv":"Manx","ha":"Hausa","hak":"Hakka","haw":"Hawaiian","he":"Hebrew","hi":"Hindi","hif":"Fiji Hindi","hif-latn":"Fiji Hindi (Latin script)","hil":"Hiligaynon","hr":"Croatian","hsb":"Upper Sorbian","ht":"Haitian","hu":"Hungarian","hy":"Armenian","ia":"Interlingua","id":"Indonesian","ie":"Interlingue","ig":"Igbo","ii":"Sichuan Yi","ik":"Inupiaq","ike-cans":"Eastern Canadian (Aboriginal syllabics)","ike-latn":"Eastern Canadian (Latin script)","ilo":"Iloko","inh":"Ingush","io":"Ido","is":"Icelandic","it":"Italian","iu":"Inuktitut","ja":"Japanese","jam":"Jamaican Creole English","jbo":"Lojban","jut":"Jutish","jv":"Javanese","ka":"Georgian","kaa":"Kara-Kalpak","kab":"Kabyle","kbd":"Kabardian","kbd-cyrl":"Адыгэбзэ","kg":"Kongo","khw":"Khowar","kiu":"Kirmanjki","kk":"Kazakh","kk-arab":"Kazakh (Arabic script)","kk-cyrl":"Kazakh (Cyrillic script)","kk-latn":"Kazakh (Latin script)","kk-cn":"Kazakh (China)","kk-kz": "Kazakh (Kazakhstan)","kk-tr":"Kazakh (Turkey)","kl":"Kalaallisut","km":"Khmer","kn":"Kannada","ko":"Korean","ko-kp":"한국어 (조선)","koi":"Komi-Permyak","krc":"Karachay-Balkar","kri":"Krio","krj":"Kinaray-a","ks":"Kashmiri","ks-arab":"Kashmiri (Arabic script)","ks-deva":"Kashmiri (Devanagari script)","ksh":"Colognian","ku":"Kurdish","ku-latn":"Kurdish (Latin script)","ku-arab":"كوردي (عەرەبی)‏","kv":"Komi","kw":"Cornish","ky":"Kyrgyz","la":"Latin","lad":"Ladino","lb":"Luxembourgish","lbe":"лакку","lez":"Lezghian","lfn":"Lingua Franca Nova","lg":"Ganda","li":"Limburgish","lij":"Ligure","liv":"Līvõ kēļ","lmo":"lumbaart","ln":"Lingala","lo":"Lao","lrc":"لوری","loz":"Lozi","lt":"Lithuanian","ltg":"Latgalian","lus":"Mizo","lv":"Latvian","lzh":"Literary Chinese","lzz":"Lazuri","mai":"Maithili","map-bms":"Basa Banyumasan","mdf":"Moksha","mg":"Malagasy","mhr":"Eastern Mari","mi":"Maori","min":"Minangkabau","mk":"Macedonian","ml":"Malayalam","mn":"Mongolian","mo" :"Moldavian","mr":"Marathi","mrj":"Hill Mari","ms":"Malay","mt":"Maltese","mwl":"Mirandese","my":"Burmese","myv":"Erzya","mzn":"Mazanderani","na":"Nauru","nah":"Nahuatl","nan":"Min Nan Chinese","nap":"Neapolitan","nb":"Norwegian Bokmål","nds":"Low German","nds-nl":"Low Saxon (Netherlands)","ne":"Nepali","new":"Newari","niu":"Niuean","nl":"Dutch","nl-informal":"Nederlands (informeel)‎","nn":"Norwegian Nynorsk","nov":"Novial","nso":"Northern Sotho","nv":"Navajo","ny":"Nyanja","oc":"Occitan","om":"Oromo","or":"Oriya","os":"Ossetic","pa":"Punjabi","pag":"Pangasinan","pam":"Pampanga","pap":"Papiamento","pcd":"Picard","pdc":"Deitsch","pdt":"Plautdietsch","pfl":"Pälzisch","pi":"Pali","pih":"Norfuk / Pitkern","pl":"Polish","pms":"Piedmontese","pnb":"Western Punjabi","pnt":"Pontic","prg":"Prussian","ps":"Pashto","pt":"Portuguese","pt-br":"Brazilian Portuguese","qu":"Quechua","qug":"Runa shimi","rgn":"Romagnol","rif":"Tarifit","rm":"Romansh","rmy":"Romani","ro":"Romanian","roa-tara": "tarandíne","ru":"Russian","rue":"Rusyn","rup":"Aromanian","ruq":"Megleno-Romanian","ruq-cyrl":"Megleno-Romanian (Cyrillic script)","ruq-latn":"Megleno-Romanian (Latin script)","sa":"Sanskrit","sah":"Sakha","sat":"Santali","sc":"Sardinian","scn":"Sicilian","sco":"Scots","sd":"Sindhi","sdc":"Sassaresu","se":"Northern Sami","sei":"Cmique Itom","sg":"Sango","sgs":"Samogitian","sh":"Serbo-Croatian","shi":"Tachelhit","si":"Sinhala","sk":"Slovak","sl":"Slovenian","sli":"Lower Silesian","sm":"Samoan","sma":"Southern Sami","sn":"Shona","so":"Somali","sq":"Albanian","sr":"Serbian","sr-ec":"Serbian (Cyrillic script)","sr-el":"Serbian (Latin script)","srn":"Sranan Tongo","ss":"Swati","st":"Southern Sotho","stq":"Seeltersk","su":"Sundanese","sv":"Swedish","sw":"Swahili","szl":"Silesian","ta":"Tamil","tcy":"Tulu","te":"Telugu","tet":"Tetum","tg":"Tajik","tg-cyrl":"Tajik (Cyrillic script)","tg-latn":"Tajik (Latin script)","th":"Thai","ti":"Tigrinya","tk":"Turkmen","tl":"Tagalog","tly": "толышә зывон","tn":"Tswana","to":"Tongan","tokipona":"Toki Pona","tpi":"Tok Pisin","tr":"Turkish","tru":"Turoyo","ts":"Tsonga","tt":"Tatar","tt-cyrl":"Tatar (Cyrillic script)","tt-latn":"Tatar (Latin script)","ty":"Tahitian","tyv":"Tuvinian","udm":"Udmurt","ug":"Uyghur","ug-arab":"Uyghur (Arabic script)","ug-latn":"Uyghur (Latin script)","uk":"Ukrainian","ur":"Urdu","uz":"Uzbek","ve":"Venda","vec":"vèneto","vep":"Veps","vi":"Vietnamese","vls":"West-Vlams","vmf":"Upper Franconian","vo":"Volapük","vot":"Votic","vro":"Võro","wa":"Walloon","war":"Waray","wo":"Wolof","wuu":"Wu","xal":"Kalmyk","xh":"Xhosa","xmf":"Mingrelian","yi":"Yiddish","yo":"Yoruba","yue":"Cantonese","za":"Zhuang","zea":"Zeeuws","zh":"Chinese","zh-cn":"Chinese (China)","zh-hans":"Simplified Chinese","zh-hant":"Traditional Chinese","zh-hk":"Chinese (Hong Kong)","zh-mo":"中文(澳門)‎","zh-my":"中文(马来西亚)‎","zh-sg":"Chinese (Singapore)","zh-tw":"Chinese (Taiwan)","zu":"Zulu"});},{},{} );mw.loader.implement("ext.uls.mediawiki",function(){(function($,mw){'use strict';$.fn.uls.defaults=$.extend($.fn.uls.defaults,{languages:mw.config.get('wgULSLanguages'),searchAPI:mw.util.wikiScript('api')+'?action=languagesearch'});$.fn.uls.Constructor.prototype.render=function(){this.$languageFilter.addClass('noime');};$.uls.data.addLanguage('als',{target:'gsw'});}(jQuery,mediaWiki));;},{},{});mw.loader.implement("jquery.ime",function(){(function($){'use strict';function IME(element,options){this.$element=$(element);$.ime.defaults.languages=arrayKeys($.ime.languages);this.options=$.extend({},$.ime.defaults,options);this.active=false;this.shifted=false;this.inputmethod=null;this.language=null;this.context='';this.selector=this.$element.imeselector(this.options);this.listen();}IME.prototype={constructor:IME,listen:function(){this.$element.on('keypress.ime',$.proxy(this.keypress,this));this.$element.on('keyup.ime',$.proxy(this.keyup,this));this.$element.on('keydown.ime',$.proxy(this. keydown,this));this.$element.on('destroy.ime',$.proxy(this.destroy,this));this.$element.on('enable.ime',$.proxy(this.enable,this));this.$element.on('disable.ime',$.proxy(this.disable,this));},transliterate:function(input,context,altGr){var patterns,regex,rule,replacement,i,retval;if(altGr){patterns=this.inputmethod.patterns_x||[];}else{patterns=this.inputmethod.patterns||[];}if(this.shifted){patterns=(this.inputmethod.patterns_shift||[]).concat(patterns);}if($.isFunction(patterns)){retval=patterns.call(this,input,context);if(typeof retval==='string'){return{noop:input===retval,output:retval};}return retval;}for(i=0;ithis.inputmethod.contextLength){this.context=this.context.substring(this.context.length-this.inputmethod.contextLength);}if(replacement.noop){return true;}divergingPos=this.firstDivergence(input,replacement.output);input=input.substring(divergingPos);replacement.output= replacement.output.substring(divergingPos);replaceText(this.$element,replacement.output,startPos-input.length+1,endPos);e.stopPropagation();return false;},isActive:function(){return this.active;},disable:function(){this.active=false;$.ime.preferences.setIM('system');},enable:function(){this.active=true;},toggle:function(){this.active=!this.active;},destroy:function(){$('body').off('.ime');this.$element.off('.ime').removeData('ime').removeData('imeselector');},getIM:function(){return this.inputmethod;},setIM:function(inputmethodId){this.inputmethod=$.ime.inputmethods[inputmethodId];$.ime.preferences.setIM(inputmethodId);},setLanguage:function(languageCode){if(!$.ime.languages[languageCode]){debug('Language '+languageCode+' is not known to jquery.ime.');return false;}this.language=languageCode;$.ime.preferences.setLanguage(languageCode);return true;},getLanguage:function(){return this.language;},load:function(inputmethodId){var ime=this,deferred=$.Deferred(),dependency;if($.ime. inputmethods[inputmethodId]){return deferred.resolve();}dependency=$.ime.sources[inputmethodId].depends;if(dependency&&!$.ime.inputmethods[dependency]){ime.load(dependency).done(function(){ime.load(inputmethodId).done(function(){deferred.resolve();});});return deferred;}debug('Loading '+inputmethodId);deferred=$.getScript(ime.options.imePath+$.ime.sources[inputmethodId].source).done(function(){debug(inputmethodId+' loaded');}).fail(function(jqxhr,settings,exception){debug('Error in loading inputmethod '+inputmethodId+' Exception: '+exception);});return deferred.promise();},getCaretPosition:function($element){return getCaretPosition($element);},setCaretPosition:function($element,position){return setCaretPosition($element,position);},firstDivergence:function(a,b){return firstDivergence(a,b);},lastNChars:function(str,pos,n){return lastNChars(str,pos,n);}};$.fn.ime=function(option){return this.each(function(){var data,$this=$(this),options=typeof option==='object'&&option;if($this.prop( 'readonly')||$this.prop('disabled')||$this.hasClass('noime')){return;}data=$this.data('ime');if(!data){data=new IME(this,options);$this.data('ime',data);}if(typeof option==='string'){data[option]();}});};$.ime={};$.ime.inputmethods={};$.ime.sources={};$.ime.preferences={};$.ime.languages={};var defaultInputMethod={contextLength:0,maxKeyLength:1};$.ime.register=function(inputMethod){$.ime.inputmethods[inputMethod.id]=$.extend({},defaultInputMethod,inputMethod);};$.ime.defaults={imePath:'../',languages:[],helpHandler:null};function debug($obj){if(window.console&&window.console.log){window.console.log($obj);}}function getCaretPosition($element){var el=$element.get(0),start=0,end=0,normalizedValue,range,textInputRange,len,newLines,endRange;if($element.is('[contenteditable]')){return getDivCaretPosition(el);}if(typeof el.selectionStart==='number'&&typeof el.selectionEnd==='number'){start=el.selectionStart;end=el.selectionEnd;}else{range=document.selection.createRange();if(range&&range. parentElement()===el){len=el.value.length;normalizedValue=el.value.replace(/\r\n/g,'\n');newLines=normalizedValue.match(/\n/g);textInputRange=el.createTextRange();textInputRange.moveToBookmark(range.getBookmark());endRange=el.createTextRange();endRange.collapse(false);if(textInputRange.compareEndPoints('StartToEnd',endRange)>-1){if(newLines){start=end=len-newLines.length;}else{start=end=len;}}else{start=-textInputRange.moveStart('character',-len);if(textInputRange.compareEndPoints('EndToEnd',endRange)>-1){end=len;}else{end=-textInputRange.moveEnd('character',-len);}}}}return[start,end];}function rangeForElementIE(element){var selection;if(element.nodeName.toLowerCase()==='input'){selection=element.createTextRange();}else{selection=document.body.createTextRange();selection.moveToElementText(element);}return selection;}function replaceText($element,replacement,start,end){var selection,length,newLines,scrollTop,range,correction,textNode,element=$element.get(0);if($element.is( '[contenteditable]')){correction=setCaretPosition($element,{start:start,end:end});selection=rangy.getSelection();range=selection.getRangeAt(0);if(correction[0]>0){replacement=selection.toString().substring(0,correction[0])+replacement;}textNode=document.createTextNode(replacement);range.deleteContents();range.insertNode(textNode);range.commonAncestorContainer.normalize();start=end=start+replacement.length-correction[0];setCaretPosition($element,{start:start,end:end});return;}if(typeof element.selectionStart==='number'&&typeof element.selectionEnd==='number'){scrollTop=element.scrollTop;element.value=element.value.substring(0,start)+replacement+element.value.substring(end,element.value.length);element.scrollTop=scrollTop;element.selectionStart=element.selectionEnd=start+replacement.length;}else{selection=rangeForElementIE(element);length=element.value.length;newLines=element.value.match(/\n/g);if(newLines){length=length-newLines.length;}selection.moveStart('character',start);selection. moveEnd('character',end-length);selection.text=replacement;selection.collapse(false);selection.select();}}function getDivCaretPosition(element){var charIndex=0,start=0,end=0,foundStart=false,foundEnd=false,sel=rangy.getSelection();function traverseTextNodes(node,range){var i,childNodesCount;if(node.nodeType===Node.TEXT_NODE){if(!foundStart&&node===range.startContainer){start=charIndex+range.startOffset;foundStart=true;}if(foundStart&&node===range.endContainer){end=charIndex+range.endOffset;foundEnd=true;}charIndex+=node.length;}else{childNodesCount=node.childNodes.length;for(i=0;i10){break;}}return[startCorrection,endCorrection];}function setDivCaretPosition(element,position){var nextCharIndex,charIndex=0,range=rangy.createRange(),foundStart=false,foundEnd=false;range.collapseToPoint(element,0);function traverseTextNodes(node){var i,len;if(node.nodeType===3){nextCharIndex=charIndex+node.length;if(!foundStart&&position.start>=charIndex&&position.start<=nextCharIndex){range.setStart(node,position.start-charIndex);foundStart=true;}if(foundStart&&position.end>=charIndex&&position.end<=nextCharIndex){range.setEnd(node,position.end-charIndex);foundEnd=true;}charIndex=nextCharIndex;}else{for(i=0,len=node.childNodes.length;i');this.$menu.append(imeListTitle(),imeList(),toggleMenuItem(),languageListTitle());this.prepareLanguageList();this.$menu.append(this.helpLink());if($.i18n){this.$menu.i18n();}this.$imeSetting.append(this.$menu);$('body').append(this.$imeSetting);},stopTimer:function(){if(this.timer){clearTimeout(this.timer);this.timer=null;}this.$imeSetting.stop(true,true);},resetTimer:function(){var imeselector=this;this.stopTimer();this.timer=setTimeout(function(){imeselector.$imeSetting.animate({'opacity':0,'marginTop':'-20px'},500,function(){imeselector.$imeSetting.hide();imeselector.$imeSetting.css('opacity',1);imeselector.$imeSetting.css('margin-top',0);});},this.options.timeout);},focus:function(){$('div.imeselector').hide();$('div.imeselector-menu').removeClass('ime-open');this.$imeSetting.show();this.resetTimer();},show:function(){this.$menu.addClass('ime-open');this.stopTimer();this.$imeSetting.show(); return false;},hide:function(){this.$menu.removeClass('ime-open');this.resetTimer();return false;},toggle:function(){if(this.$menu.hasClass('ime-open')){this.hide();}else{this.show();}},listen:function(){var imeselector=this;imeselector.$imeSetting.on('click.ime',function(e){var t=$(e.target);if(t.hasClass('imeselector-toggle')){imeselector.toggle();}return false;});imeselector.$element.on('blur.ime',function(){if(!imeselector.$imeSetting.hasClass('ime-onfocus')){imeselector.$imeSetting.hide();imeselector.hide();}});$('html').click(function(){imeselector.hide();});this.$menu.on('click',function(event){event.stopPropagation();});imeselector.$imeSetting.mouseenter(function(){imeselector.stopTimer();imeselector.$imeSetting.addClass('ime-onfocus');}).mouseleave(function(){imeselector.resetTimer();imeselector.$imeSetting.removeClass('ime-onfocus');});imeselector.$menu.on('click.ime','li',function(){imeselector.$element.focus();return false;});imeselector.$menu.on('click.ime','li.ime-im', function(){imeselector.selectIM($(this).data('ime-inputmethod'));imeselector.$element.trigger('setim.ime',$(this).data('ime-inputmethod'));return false;});imeselector.$menu.on('click.ime','li.ime-lang',function(){var im=imeselector.selectLanguage($(this).attr('lang'));imeselector.$element.trigger('setim.ime',im);return false;});imeselector.$menu.on('click.ime','div.ime-disable',function(){imeselector.disableIM();return false;});imeselector.$menu.on('click.ime','.ime-help-link',function(e){e.stopPropagation();});imeselector.$element.on('focus.ime',function(e){imeselector.selectLanguage(imeselector.decideLanguage());imeselector.focus();e.stopPropagation();});imeselector.$element.attrchange(function(){if(imeselector.$element.is(':hidden')){imeselector.$imeSetting.hide();}});imeselector.$element.on('mouseup.ime',$.proxy(this.position,this));imeselector.$element.on('keydown.ime',$.proxy(this.keydown,this));$(window).resize(function(){imeselector.position();});},keydown:function(e){var ime=$ (e.target).data('ime'),firstInputmethod,previousInputMethods,languageCode;this.focus();if(isShortcutKey(e)){if(ime.isActive()){this.disableIM();this.$element.trigger('setim.ime','system');}else{if(this.inputmethod!==null){this.selectIM(this.inputmethod.id);this.$element.trigger('setim.ime',this.inputmethod.id);}else{languageCode=this.decideLanguage();this.selectLanguage(languageCode);if(!ime.isActive()&&$.ime.languages[languageCode]){previousInputMethods=$.ime.preferences.getPreviousInputMethods();if(previousInputMethods[0]){this.selectIM(previousInputMethods[0]);}else{firstInputmethod=$.ime.languages[languageCode].inputmethods[0];this.selectIM(firstInputmethod);}}}}e.preventDefault();e.stopPropagation();return false;}return true;},position:function(){var menuWidth,menuTop,menuLeft,elementPosition,top,left,verticalRoom,overflowsOnRight,imeSelector=this,rtlElement=this.$element.css('direction')==='rtl',$window=$(window);this.focus();elementPosition=this.$element.offset();top= elementPosition.top+this.$element.outerHeight();left=elementPosition.left;if(!rtlElement){left=elementPosition.left+this.$element.outerWidth()-this.$imeSetting.outerWidth();}verticalRoom=$window.height()+$(document).scrollTop()-top;if(verticalRoom$window.width();if(menuWidth>left||rtlElement&&overflowsOnRight){if(rtlElement){if(overflowsOnRight){this.$menu.addClass('ime-right');menuLeft=this.$imeSetting.outerWidth()-menuWidth;}else{menuLeft=0;}}else{this.$menu.addClass('ime-right');menuLeft=elementPosition.left;}this .$menu.css('left',menuLeft);}},selectLanguage:function(languageCode){var ime,imePref,language;languageCode=languageCode&&languageCode.toLowerCase();ime=this.$element.data('ime');imePref=$.ime.preferences.getIM(languageCode);language=$.ime.languages[languageCode];this.setMenuTitle(this.getAutonym(languageCode));if(!language){return false;}if(ime.getLanguage()===languageCode){if(ime.inputmethod&&ime.inputmethod.id!==imePref){this.selectIM($.ime.preferences.getIM(languageCode));}return $.ime.preferences.getIM(languageCode);}this.$menu.find('li.ime-lang').show();this.$menu.find('li[lang='+languageCode+']').hide();this.prepareInputMethods(languageCode);this.hide();ime.setLanguage(languageCode);this.inputmethod=null;this.selectIM($.ime.preferences.getIM(languageCode));return $.ime.preferences.getIM(languageCode);},getAutonym:function(languageCode){return $.ime.languages[languageCode].autonym;},setMenuTitle:function(title){this.$menu.find('.ime-list-title').text(title);},decideLanguage: function(){if($.ime.preferences.getLanguage()){return $.ime.preferences.getLanguage();}if(this.$element.attr('lang')&&$.ime.languages[this.$element.attr('lang')]){return this.$element.attr('lang');}return $.ime.preferences.getDefaultLanguage();},selectIM:function(inputmethodId){var imeselector=this,ime;if(!inputmethodId){return;}this.$menu.find('.ime-checked').removeClass('ime-checked');this.$menu.find('li[data-ime-inputmethod='+inputmethodId+']').addClass('ime-checked');ime=this.$element.data('ime');if(inputmethodId==='system'){this.disableIM();return;}ime.load(inputmethodId).done(function(){imeselector.inputmethod=$.ime.inputmethods[inputmethodId];imeselector.hide();ime.enable();ime.setIM(inputmethodId);imeselector.$imeSetting.find('a.ime-name').text($.ime.sources[inputmethodId].name);imeselector.position();$.ime.preferences.save();});},disableIM:function(){this.$menu.find('.ime-checked').removeClass('ime-checked');this.$menu.find('div.ime-disable').addClass('ime-checked');this. $element.data('ime').disable();this.$imeSetting.find('a.ime-name').text('');this.hide();this.position();$.ime.preferences.save();},prepareLanguageList:function(){var languageCodeIndex,$languageListWrapper,$languageList,languageList,$languageItem,$language,languageCode,language;$languageListWrapper=$('
');$languageList=$('
    ');if($.isFunction(this.options.languages)){languageList=this.options.languages();}else{languageList=this.options.languages;}for(languageCodeIndex in languageList){languageCode=languageList[languageCodeIndex];language=$.ime.languages[languageCode];if(!language){continue;}$languageItem=$('').attr('href','#').text(this.getAutonym(languageCode)).addClass('selectable-row-item autonym');$language=$('
  • ').attr('lang',languageCode);$language.append($languageItem);$languageList.append($language);}$languageListWrapper.append($languageList);this.$menu.append( $languageListWrapper);if(this.options.languageSelector){this.$menu.append(this.options.languageSelector());}},prepareInputMethods:function(languageCode){var language=$.ime.languages[languageCode],$imeList=this.$menu.find('.ime-list'),imeSelector=this;$imeList.empty();$.each(language.inputmethods,function(index,inputmethod){var $imeItem,$inputMethod,source,name;source=$.ime.sources[inputmethod];if(!source){return;}name=source.name;$imeItem=$('').attr('href','#').text(name).addClass('selectable-row-item');$inputMethod=$('
  • ').attr('data-ime-inputmethod',inputmethod).addClass('ime-im selectable-row').append('',$imeItem);if(imeSelector.options.helpHandler){$inputMethod.append(imeSelector.options.helpHandler.call(imeSelector,inputmethod));}$imeList.append($inputMethod);});},helpLink:function(){return $('