11// @flow
22
3- var spellers = { } , spellerData = { } ;
3+ var spellers = ( { } /*: {[string]: string[]} */ ) , spellerData = { } ;
44var currentSpellCheckerRequest ;
55
66/* exported getSpellers, populateSecondarySpellCheckerList */
77/* global config, modeEnabled, persistChoices, readCache, ajaxSend, ajaxComplete, filterLangList, allowedLang, analyzers, cache,
88 localizeInterface, getLangByCode, restoreChoices, callApy */
99/* global ENTER_KEY_CODE */
1010
11- function getSpellers ( ) {
11+ function getSpellers ( ) /*: JQueryPromise<any> */ {
1212 var deferred = $ . Deferred ( ) ;
1313
1414 if ( config . SPELLERS ) {
@@ -20,7 +20,7 @@ function getSpellers() {
2020 var spellers = readCache ( 'spellers' , 'LIST_REQUEST' ) ;
2121 if ( spellers ) {
2222 spellerData = spellers ;
23- populatePrimarySpellCheckerList ( spellerData ) ;
23+ populatePrimarySpellCheckerList ( spellerData /*: {} */ ) ;
2424 deferred . resolve ( ) ;
2525 }
2626 else {
@@ -78,7 +78,7 @@ if(modeEnabled('spellchecking')) {
7878 persistChoices ( 'spellchecker' ) ;
7979 } ) ;
8080
81- $ ( '#spellCheckerInput' ) . keydown ( function ( e ) {
81+ $ ( '#spellCheckerInput' ) . keydown ( function ( e /*: JQueryKeyEventObject */ ) {
8282 if ( e . keyCode === ENTER_KEY_CODE && ! e . shiftKey ) {
8383 e . preventDefault ( ) ;
8484 check ( ) ;
@@ -163,7 +163,8 @@ function populateSecondarySpellCheckerList() {
163163 $ ( '#secondarySpellCheckerMode' ) . fadeOut ( 'fast' ) ;
164164 }
165165}
166- function populatePrimarySpellCheckerList ( data ) {
166+
167+ function populatePrimarySpellCheckerList ( data /*: {} */ ) {
167168 $ ( '.spellCheckerMode' ) . empty ( ) ;
168169
169170 spellers = { } ;
@@ -178,11 +179,11 @@ function populatePrimarySpellCheckerList(data) {
178179 }
179180 }
180181
181- var spellerArray = [ ] ;
182- $ . each ( spellers , function ( spellerLang , lang ) {
182+ var spellerArray /*: [string, string][] */ = [ ] ;
183+ $ . each ( spellers , function ( spellerLang /*: string */ , lang /*: string */ ) {
183184 spellerArray . push ( [ spellerLang , lang ] ) ;
184185 } ) ;
185- spellerArray = filterLangList ( spellerArray , function ( speller ) {
186+ spellerArray = filterLangList ( spellerArray , function ( speller /*: [string, string] */ ) {
186187 return allowedLang ( speller [ 0 ] ) ;
187188 } ) ;
188189 spellerArray . sort ( function ( a , b ) {
@@ -231,8 +232,13 @@ function check() {
231232 }
232233 $ ( '.spellError' ) . each ( function ( ) {
233234 var currentTokenId = this . id ;
234- $ ( this ) . popover ( { animation : false , placement : 'bottom' , trigger : 'manual' , html : true ,
235- content : content [ currentTokenId ] } ) ;
235+ $ ( this ) . popover ( {
236+ animation : false ,
237+ placement : 'bottom' ,
238+ trigger : 'manual' ,
239+ html : true ,
240+ content : content [ currentTokenId ]
241+ } ) ;
236242 } ) ;
237243 originalWordsIndex ++ ;
238244 }
@@ -254,6 +260,10 @@ function spellCheckerNotAvailable(data) {
254260 $ ( '#spellCheckerInput' ) . append ( $ ( '<div></div>' ) . text ( data . explanation ) ) ;
255261}
256262
257- /*:: import {modeEnabled, ajaxSend, ajaxComplete, filterLangList, callApy} from "./util.js" */
263+ /*:: export {getSpellers, populateSecondarySpellCheckerList} */
264+
265+ /*:: import {modeEnabled, ajaxSend, ajaxComplete, allowedLang, filterLangList, callApy, ENTER_KEY_CODE} from "./util.js" */
258266/*:: import {persistChoices, restoreChoices} from "./persistence.js" */
267+ /*:: import {localizeInterface, getLangByCode} from "./localization.js" */
259268/*:: import {readCache, cache} from "./persistence.js" */
269+ /*:: import {analyzers} from "./analyzer.js" */
0 commit comments