]>
Commit | Line | Data |
---|---|---|
1 | /*\r | |
2 | Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.\r | |
3 | For licensing, see LICENSE.html or http://ckeditor.com/license\r | |
4 | */\r | |
5 | \r | |
6 | CKEDITOR.dialog.add( 'scaytDialog', function( editor ) {\r | |
7 | var scayt_instance = editor.scayt;\r | |
8 | \r | |
9 | var aboutTabDefinition = '<p><img src="' + scayt_instance.getLogo() + '" /></p>' +\r | |
10 | '<p>' + scayt_instance.getLocal('version') + scayt_instance.getVersion() + '</p>' +\r | |
11 | '<p>' + scayt_instance.getLocal('text_copyrights') + '</p>';\r | |
12 | \r | |
13 | var doc = CKEDITOR.document;\r | |
14 | \r | |
15 | var optionGenerator = function() {\r | |
16 | var scayt_instance_ = editor.scayt,\r | |
17 | applicationConfig = scayt_instance.getApplicationConfig(),\r | |
18 | optionArrayUiCheckboxes = [],\r | |
19 | optionLocalizationList = {\r | |
20 | "ignore-all-caps-words" : "label_allCaps",\r | |
21 | "ignore-domain-names" : "label_ignoreDomainNames",\r | |
22 | "ignore-words-with-mixed-cases" : "label_mixedCase",\r | |
23 | "ignore-words-with-numbers" : "label_mixedWithDigits"\r | |
24 | };\r | |
25 | \r | |
26 | for(var option in applicationConfig) {\r | |
27 | \r | |
28 | var checkboxConfig = {\r | |
29 | type: "checkbox"\r | |
30 | };\r | |
31 | \r | |
32 | checkboxConfig.id = option;\r | |
33 | checkboxConfig.label = scayt_instance.getLocal(optionLocalizationList[option]);\r | |
34 | \r | |
35 | optionArrayUiCheckboxes.push(checkboxConfig);\r | |
36 | }\r | |
37 | \r | |
38 | return optionArrayUiCheckboxes;\r | |
39 | };\r | |
40 | \r | |
41 | var languageModelState = {\r | |
42 | isChanged : function() {\r | |
43 | return (this.newLang === null || this.currentLang === this.newLang) ? false : true;\r | |
44 | },\r | |
45 | currentLang: scayt_instance.getLang(),\r | |
46 | newLang: null,\r | |
47 | reset: function() {\r | |
48 | this.currentLang = scayt_instance.getLang();\r | |
49 | this.newLang = null;\r | |
50 | },\r | |
51 | id: 'lang'\r | |
52 | };\r | |
53 | \r | |
54 | var generateDialogTabs = function(tabsList, editor) {\r | |
55 | var tabs = [],\r | |
56 | uiTabs = editor.config.scayt_uiTabs;\r | |
57 | \r | |
58 | if(!uiTabs) {\r | |
59 | return tabsList;\r | |
60 | } else {\r | |
61 | for(var i in uiTabs) {\r | |
62 | (uiTabs[i] == 1) && tabs.push(tabsList[i]);\r | |
63 | }\r | |
64 | \r | |
65 | tabs.push(tabsList[tabsList.length - 1]);\r | |
66 | }\r | |
67 | \r | |
68 | return tabs;\r | |
69 | };\r | |
70 | \r | |
71 | var dialogTabs = [{\r | |
72 | id : 'options',\r | |
73 | label : scayt_instance.getLocal('tab_options'),\r | |
74 | onShow: function() {\r | |
75 | // console.log("tab show");\r | |
76 | },\r | |
77 | elements : [\r | |
78 | {\r | |
79 | type: 'vbox',\r | |
80 | id: 'scaytOptions',\r | |
81 | children: optionGenerator(),\r | |
82 | onShow: function() {\r | |
83 | var optionsTab = this.getChild(),\r | |
84 | scayt_instance = editor.scayt;\r | |
85 | for(var i = 0; i < this.getChild().length; i++) {\r | |
86 | this.getChild()[i].setValue(scayt_instance.getApplicationConfig()[this.getChild()[i].id]);\r | |
87 | }\r | |
88 | \r | |
89 | }\r | |
90 | }\r | |
91 | \r | |
92 | ]\r | |
93 | },\r | |
94 | {\r | |
95 | id : 'langs',\r | |
96 | label : scayt_instance.getLocal('tab_languages'),\r | |
97 | elements : [\r | |
98 | {\r | |
99 | id: "leftLangColumn",\r | |
100 | type: 'vbox',\r | |
101 | align: 'left',\r | |
102 | widths: ['100'],\r | |
103 | children: [\r | |
104 | {\r | |
105 | type: 'html',\r | |
106 | id: 'langBox',\r | |
107 | style: 'overflow: hidden; white-space: normal;margin-bottom:15px;',\r | |
108 | html: '<div><div style="float:left;width:45%;margin-left:5px;" id="left-col-' + editor.name + '"></div><div style="float:left;width:45%;margin-left:15px;" id="right-col-' + editor.name + '"></div></div>',\r | |
109 | onShow: function() {\r | |
110 | var scayt_instance = editor.scayt;\r | |
111 | var lang = scayt_instance.getLang(),\r | |
112 | prefix_id = "scaytLang_",\r | |
113 | radio = doc.getById(prefix_id + editor.name + '_' + lang);\r | |
114 | \r | |
115 | radio.$.checked = true;\r | |
116 | }\r | |
117 | },\r | |
118 | {\r | |
119 | type: 'html',\r | |
120 | id: 'graytLanguagesHint',\r | |
121 | html: '<div style="margin:5px auto; width:95%;white-space:normal;" id="' + editor.name + 'graytLanguagesHint"><span style="width:10px;height:10px;display: inline-block; background:#02b620;vertical-align:top;margin-top:2px;"></span> - This languages are supported by Grammar As You Type(GRAYT).</div>',\r | |
122 | onShow: function() {\r | |
123 | var graytLanguagesHint = doc.getById(editor.name + 'graytLanguagesHint');\r | |
124 | \r | |
125 | if (!editor.config.grayt_autoStartup) {\r | |
126 | graytLanguagesHint.$.style.display = 'none';\r | |
127 | }\r | |
128 | }\r | |
129 | }\r | |
130 | ]\r | |
131 | }\r | |
132 | ]\r | |
133 | },\r | |
134 | {\r | |
135 | id : 'dictionaries',\r | |
136 | label : scayt_instance.getLocal('tab_dictionaries'),\r | |
137 | elements : [\r | |
138 | {\r | |
139 | type: 'vbox',\r | |
140 | id: 'rightCol_col__left',\r | |
141 | children: [\r | |
142 | {\r | |
143 | type: 'html',\r | |
144 | id: 'dictionaryNote',\r | |
145 | html: ''\r | |
146 | },\r | |
147 | {\r | |
148 | type: 'text',\r | |
149 | id: 'dictionaryName',\r | |
150 | label: scayt_instance.getLocal('label_fieldNameDic') || 'Dictionary name',\r | |
151 | onShow: function(data) {\r | |
152 | var dialog = data.sender,\r | |
153 | scayt_instance = editor.scayt;\r | |
154 | \r | |
155 | // IE7 specific fix\r | |
156 | setTimeout(function() {\r | |
157 | // clear dictionaryNote field\r | |
158 | dialog.getContentElement("dictionaries", "dictionaryNote").getElement().setText('');\r | |
159 | \r | |
160 | // restore/clear dictionaryName field\r | |
161 | if(scayt_instance.getUserDictionaryName() != null && scayt_instance.getUserDictionaryName() != '') {\r | |
162 | dialog.getContentElement("dictionaries", "dictionaryName").setValue(scayt_instance.getUserDictionaryName());\r | |
163 | }\r | |
164 | }, 0);\r | |
165 | }\r | |
166 | },\r | |
167 | {\r | |
168 | type: 'hbox',\r | |
169 | id: 'notExistDic',\r | |
170 | align: 'left',\r | |
171 | style: 'width:auto;',\r | |
172 | widths: [ '50%', '50%' ],\r | |
173 | children: [\r | |
174 | {\r | |
175 | type: 'button',\r | |
176 | id: 'createDic',\r | |
177 | label: scayt_instance.getLocal('btn_createDic'),\r | |
178 | title: scayt_instance.getLocal('btn_createDic'),\r | |
179 | onClick: function() {\r | |
180 | var dialog = this.getDialog(),\r | |
181 | self = dialogDefinition,\r | |
182 | scayt_instance = editor.scayt,\r | |
183 | name = dialog.getContentElement("dictionaries", "dictionaryName").getValue();\r | |
184 | \r | |
185 | scayt_instance.createUserDictionary(name, function(response) {\r | |
186 | if(!response.error) {\r | |
187 | self.toggleDictionaryButtons.call(dialog, true);\r | |
188 | }\r | |
189 | response.dialog = dialog;\r | |
190 | response.command = "create";\r | |
191 | response.name = name;\r | |
192 | editor.fire("scaytUserDictionaryAction", response);\r | |
193 | }, function(error) {\r | |
194 | error.dialog = dialog;\r | |
195 | error.command = "create";\r | |
196 | error.name = name;\r | |
197 | editor.fire("scaytUserDictionaryActionError", error);\r | |
198 | });\r | |
199 | }\r | |
200 | },\r | |
201 | {\r | |
202 | type: 'button',\r | |
203 | id: 'restoreDic',\r | |
204 | label: scayt_instance.getLocal('btn_restoreDic'),\r | |
205 | title: scayt_instance.getLocal('btn_restoreDic'),\r | |
206 | onClick: function() {\r | |
207 | var dialog = this.getDialog(),\r | |
208 | scayt_instance = editor.scayt,\r | |
209 | self = dialogDefinition,\r | |
210 | name = dialog.getContentElement("dictionaries", "dictionaryName").getValue();\r | |
211 | \r | |
212 | scayt_instance.restoreUserDictionary(name, function(response) {\r | |
213 | response.dialog = dialog;\r | |
214 | if(!response.error) {\r | |
215 | self.toggleDictionaryButtons.call(dialog, true);\r | |
216 | }\r | |
217 | response.command = "restore";\r | |
218 | response.name = name;\r | |
219 | editor.fire("scaytUserDictionaryAction", response);\r | |
220 | }, function(error) {\r | |
221 | error.dialog = dialog;\r | |
222 | error.command = "restore";\r | |
223 | error.name = name;\r | |
224 | editor.fire("scaytUserDictionaryActionError", error);\r | |
225 | });\r | |
226 | }\r | |
227 | }\r | |
228 | ]\r | |
229 | },\r | |
230 | {\r | |
231 | type: 'hbox',\r | |
232 | id: 'existDic',\r | |
233 | align: 'left',\r | |
234 | style: 'width:auto;',\r | |
235 | widths: [ '50%', '50%' ],\r | |
236 | children: [\r | |
237 | {\r | |
238 | type: 'button',\r | |
239 | id: 'removeDic',\r | |
240 | label: scayt_instance.getLocal('btn_deleteDic'),\r | |
241 | title: scayt_instance.getLocal('btn_deleteDic'),\r | |
242 | onClick: function() {\r | |
243 | var dialog = this.getDialog(),\r | |
244 | scayt_instance = editor.scayt,\r | |
245 | self = dialogDefinition,\r | |
246 | dictionaryNameField = dialog.getContentElement("dictionaries", "dictionaryName"),\r | |
247 | name = dictionaryNameField.getValue();\r | |
248 | \r | |
249 | scayt_instance.removeUserDictionary(name, function(response) {\r | |
250 | dictionaryNameField.setValue("");\r | |
251 | if(!response.error) {\r | |
252 | self.toggleDictionaryButtons.call(dialog, false);\r | |
253 | }\r | |
254 | response.dialog = dialog;\r | |
255 | response.command = "remove";\r | |
256 | response.name = name;\r | |
257 | editor.fire("scaytUserDictionaryAction", response);\r | |
258 | }, function(error) {\r | |
259 | error.dialog = dialog;\r | |
260 | error.command = "remove";\r | |
261 | error.name = name;\r | |
262 | editor.fire("scaytUserDictionaryActionError", error);\r | |
263 | });\r | |
264 | }\r | |
265 | },\r | |
266 | {\r | |
267 | type: 'button',\r | |
268 | id: 'renameDic',\r | |
269 | label: scayt_instance.getLocal('btn_renameDic'),\r | |
270 | title: scayt_instance.getLocal('btn_renameDic'),\r | |
271 | onClick: function() {\r | |
272 | var dialog = this.getDialog(),\r | |
273 | scayt_instance = editor.scayt,\r | |
274 | name = dialog.getContentElement("dictionaries", "dictionaryName").getValue();\r | |
275 | \r | |
276 | scayt_instance.renameUserDictionary(name, function(response) {\r | |
277 | response.dialog = dialog;\r | |
278 | response.command = "rename";\r | |
279 | response.name = name;\r | |
280 | editor.fire("scaytUserDictionaryAction", response);\r | |
281 | }, function(error) {\r | |
282 | error.dialog = dialog;\r | |
283 | error.command = "rename";\r | |
284 | error.name = name;\r | |
285 | editor.fire("scaytUserDictionaryActionError", error);\r | |
286 | });\r | |
287 | }\r | |
288 | }\r | |
289 | ]\r | |
290 | },\r | |
291 | {\r | |
292 | type: 'html',\r | |
293 | id: 'dicInfo',\r | |
294 | html: '<div id="dic_info_editor1" style="margin:5px auto; width:95%;white-space:normal;">' + scayt_instance.getLocal('text_descriptionDic') + '</div>'\r | |
295 | }\r | |
296 | ]\r | |
297 | }\r | |
298 | ]\r | |
299 | },\r | |
300 | {\r | |
301 | id : 'about',\r | |
302 | label : scayt_instance.getLocal('tab_about'),\r | |
303 | elements : [\r | |
304 | {\r | |
305 | type : 'html',\r | |
306 | id : 'about',\r | |
307 | style : 'margin: 5px 5px;',\r | |
308 | html : '<div><div id="scayt_about_">' +\r | |
309 | aboutTabDefinition +\r | |
310 | '</div></div>'\r | |
311 | }\r | |
312 | ]\r | |
313 | }];\r | |
314 | \r | |
315 | editor.on("scaytUserDictionaryAction", function(event) {\r | |
316 | var UILib = SCAYT.prototype.UILib,\r | |
317 | dialog = event.data.dialog,\r | |
318 | dictionaryNote = dialog.getContentElement("dictionaries", "dictionaryNote").getElement(),\r | |
319 | scayt_instance = event.editor.scayt,\r | |
320 | messageTemplate;\r | |
321 | \r | |
322 | if(event.data.error === undefined) {\r | |
323 | \r | |
324 | // success message\r | |
325 | messageTemplate = scayt_instance.getLocal("message_success_" + event.data.command + "Dic");\r | |
326 | messageTemplate = messageTemplate.replace('%s', event.data.name);\r | |
327 | dictionaryNote.setText(messageTemplate);\r | |
328 | UILib.css(dictionaryNote.$, {color: 'blue'});\r | |
329 | } else {\r | |
330 | \r | |
331 | // error message\r | |
332 | if(event.data.name === '') {\r | |
333 | \r | |
334 | // empty dictionary name\r | |
335 | dictionaryNote.setText(scayt_instance.getLocal('message_info_emptyDic'));\r | |
336 | } else {\r | |
337 | messageTemplate = scayt_instance.getLocal("message_error_" + event.data.command + "Dic");\r | |
338 | messageTemplate = messageTemplate.replace('%s', event.data.name);\r | |
339 | dictionaryNote.setText(messageTemplate);\r | |
340 | }\r | |
341 | UILib.css(dictionaryNote.$, {color: 'red'});\r | |
342 | \r | |
343 | if(scayt_instance.getUserDictionaryName() != null && scayt_instance.getUserDictionaryName() != '') {\r | |
344 | dialog.getContentElement("dictionaries", "dictionaryName").setValue(scayt_instance.getUserDictionaryName());\r | |
345 | } else {\r | |
346 | dialog.getContentElement("dictionaries", "dictionaryName").setValue("");\r | |
347 | }\r | |
348 | }\r | |
349 | });\r | |
350 | \r | |
351 | editor.on("scaytUserDictionaryActionError", function(event) {\r | |
352 | var UILib = SCAYT.prototype.UILib,\r | |
353 | dialog = event.data.dialog,\r | |
354 | dictionaryNote = dialog.getContentElement("dictionaries", "dictionaryNote").getElement(),\r | |
355 | scayt_instance = event.editor.scayt,\r | |
356 | messageTemplate;\r | |
357 | \r | |
358 | if(event.data.name === '') {\r | |
359 | \r | |
360 | // empty dictionary name\r | |
361 | dictionaryNote.setText(scayt_instance.getLocal('message_info_emptyDic'));\r | |
362 | } else {\r | |
363 | messageTemplate = scayt_instance.getLocal("message_error_" + event.data.command + "Dic");\r | |
364 | messageTemplate = messageTemplate.replace('%s', event.data.name);\r | |
365 | dictionaryNote.setText(messageTemplate);\r | |
366 | }\r | |
367 | UILib.css(dictionaryNote.$, {color: 'red'});\r | |
368 | \r | |
369 | \r | |
370 | if(scayt_instance.getUserDictionaryName() != null && scayt_instance.getUserDictionaryName() != '') {\r | |
371 | dialog.getContentElement("dictionaries", "dictionaryName").setValue(scayt_instance.getUserDictionaryName());\r | |
372 | } else {\r | |
373 | dialog.getContentElement("dictionaries", "dictionaryName").setValue("");\r | |
374 | }\r | |
375 | \r | |
376 | });\r | |
377 | \r | |
378 | var plugin = CKEDITOR.plugins.scayt;\r | |
379 | \r | |
380 | var dialogDefinition = {\r | |
381 | title: scayt_instance.getLocal('text_title'),\r | |
382 | resizable: CKEDITOR.DIALOG_RESIZE_BOTH,\r | |
383 | minWidth: 340,\r | |
384 | minHeight: 260,\r | |
385 | onLoad: function() {\r | |
386 | if(editor.config.scayt_uiTabs[1] == 0) {\r | |
387 | return;\r | |
388 | }\r | |
389 | \r | |
390 | var dialog = this,\r | |
391 | self = dialogDefinition,\r | |
392 | langBoxes = self.getLangBoxes.call(dialog);\r | |
393 | \r | |
394 | langBoxes.getParent().setStyle("white-space", "normal");\r | |
395 | \r | |
396 | //dialog.data = editor.fire( 'scaytDialog', {} );\r | |
397 | self.renderLangList(langBoxes);\r | |
398 | \r | |
399 | var scayt_instance = editor.scayt;\r | |
400 | \r | |
401 | this.definition.minWidth = this.getSize().width;\r | |
402 | this.resize(this.definition.minWidth, this.definition.minHeight);\r | |
403 | },\r | |
404 | onCancel: function() {\r | |
405 | languageModelState.reset();\r | |
406 | },\r | |
407 | onHide: function() {\r | |
408 | editor.unlockSelection();\r | |
409 | },\r | |
410 | onShow: function() {\r | |
411 | editor.fire("scaytDialogShown", this);\r | |
412 | \r | |
413 | if(editor.config.scayt_uiTabs[2] == 0) {\r | |
414 | return;\r | |
415 | }\r | |
416 | \r | |
417 | var scayt_instance = editor.scayt,\r | |
418 | self = dialogDefinition,\r | |
419 | dialog = this,\r | |
420 | dictionaryNameField = dialog.getContentElement("dictionaries", "dictionaryName"),\r | |
421 | existance = dialog.getContentElement("dictionaries", "existDic").getElement().getParent(),\r | |
422 | notExistance = dialog.getContentElement("dictionaries", "notExistDic").getElement().getParent();\r | |
423 | \r | |
424 | existance.hide();\r | |
425 | notExistance.hide();\r | |
426 | \r | |
427 | if(scayt_instance.getUserDictionaryName() != null && scayt_instance.getUserDictionaryName() != '') {\r | |
428 | dialog.getContentElement("dictionaries", "dictionaryName").setValue(scayt_instance.getUserDictionaryName());\r | |
429 | existance.show();\r | |
430 | } else {\r | |
431 | dictionaryNameField.setValue("");\r | |
432 | notExistance.show();\r | |
433 | }\r | |
434 | },\r | |
435 | onOk: function() {\r | |
436 | var dialog = this,\r | |
437 | self = dialogDefinition,\r | |
438 | scayt_instance = editor.scayt,\r | |
439 | scaytOptions = dialog.getContentElement("options", "scaytOptions"),\r | |
440 | changedOptions = self.getChangedOption.call(dialog);\r | |
441 | \r | |
442 | scayt_instance.commitOption({ changedOptions: changedOptions });\r | |
443 | },\r | |
444 | toggleDictionaryButtons: function(exist) {\r | |
445 | var existance = this.getContentElement("dictionaries", "existDic").getElement().getParent(),\r | |
446 | notExistance = this.getContentElement("dictionaries", "notExistDic").getElement().getParent();\r | |
447 | \r | |
448 | if(exist) {\r | |
449 | existance.show();\r | |
450 | notExistance.hide();\r | |
451 | } else {\r | |
452 | existance.hide();\r | |
453 | notExistance.show();\r | |
454 | }\r | |
455 | \r | |
456 | },\r | |
457 | getChangedOption: function() {\r | |
458 | var changedOption = {};\r | |
459 | \r | |
460 | if(editor.config.scayt_uiTabs[0] == 1) {\r | |
461 | var dialog = this,\r | |
462 | scaytOptions = dialog.getContentElement("options", "scaytOptions").getChild();\r | |
463 | \r | |
464 | for(var i = 0; i < scaytOptions.length; i++) {\r | |
465 | if(scaytOptions[i].isChanged()) {\r | |
466 | changedOption[scaytOptions[i].id] = scaytOptions[i].getValue();\r | |
467 | }\r | |
468 | }\r | |
469 | }\r | |
470 | \r | |
471 | if(languageModelState.isChanged()) {\r | |
472 | changedOption[languageModelState.id] = editor.config.scayt_sLang = languageModelState.currentLang = languageModelState.newLang;\r | |
473 | }\r | |
474 | \r | |
475 | return changedOption;\r | |
476 | },\r | |
477 | buildRadioInputs: function(key, value, isSupportedByGrayt) {\r | |
478 | var divContainer = new CKEDITOR.dom.element( 'div' ),\r | |
479 | doc = CKEDITOR.document,\r | |
480 | id = "scaytLang_" + editor.name + '_' + value,\r | |
481 | radio = CKEDITOR.dom.element.createFromHtml( '<input id="' +\r | |
482 | id + '" type="radio" ' +\r | |
483 | ' value="' + value + '" name="scayt_lang" />' ),\r | |
484 | \r | |
485 | radioLabel = new CKEDITOR.dom.element( 'label' ),\r | |
486 | scayt_instance = editor.scayt;\r | |
487 | \r | |
488 | divContainer.setStyles({\r | |
489 | "white-space": "normal",\r | |
490 | 'position': 'relative',\r | |
491 | 'padding-bottom': '2px'\r | |
492 | });\r | |
493 | \r | |
494 | radio.on( 'click', function(data) {\r | |
495 | languageModelState.newLang = data.sender.getValue();\r | |
496 | });\r | |
497 | \r | |
498 | radioLabel.appendText(key);\r | |
499 | radioLabel.setAttribute("for", id);\r | |
500 | \r | |
501 | if(isSupportedByGrayt && editor.config.grayt_autoStartup) {\r | |
502 | radioLabel.setStyles({\r | |
503 | 'color': '#02b620'\r | |
504 | });\r | |
505 | }\r | |
506 | \r | |
507 | divContainer.append(radio);\r | |
508 | divContainer.append(radioLabel);\r | |
509 | \r | |
510 | if(value === scayt_instance.getLang()) {\r | |
511 | radio.setAttribute("checked", true);\r | |
512 | radio.setAttribute('defaultChecked', 'defaultChecked');\r | |
513 | }\r | |
514 | \r | |
515 | return divContainer;\r | |
516 | },\r | |
517 | renderLangList: function(langBoxes) {\r | |
518 | var dialog = this,\r | |
519 | leftCol = langBoxes.find('#left-col-' + editor.name).getItem(0),\r | |
520 | rightCol = langBoxes.find('#right-col-' + editor.name).getItem(0),\r | |
521 | scaytLangList = scayt_instance.getScaytLangList(),\r | |
522 | graytLangList = scayt_instance.getGraytLangList(),\r | |
523 | mergedLangList = {},\r | |
524 | sortable = [],\r | |
525 | counter = 0,\r | |
526 | isSupportedByGrayt = false,\r | |
527 | half, lang;\r | |
528 | \r | |
529 | for(lang in scaytLangList.ltr) {\r | |
530 | mergedLangList[lang] = scaytLangList.ltr[lang];\r | |
531 | }\r | |
532 | \r | |
533 | for(lang in scaytLangList.rtl) {\r | |
534 | mergedLangList[lang] = scaytLangList.rtl[lang];\r | |
535 | }\r | |
536 | \r | |
537 | // sort alphabetically lang list\r | |
538 | for(lang in mergedLangList) {\r | |
539 | sortable.push([lang, mergedLangList[lang]]);\r | |
540 | }\r | |
541 | sortable.sort(function(a, b) {\r | |
542 | var result = 0;\r | |
543 | if(a[1] > b[1]) {\r | |
544 | result = 1;\r | |
545 | } else if(a[1] < b[1]) {\r | |
546 | result = -1;\r | |
547 | }\r | |
548 | return result;\r | |
549 | });\r | |
550 | mergedLangList = {};\r | |
551 | for(var i = 0; i < sortable.length; i++) {\r | |
552 | mergedLangList[sortable[i][0]] = sortable[i][1];\r | |
553 | }\r | |
554 | \r | |
555 | half = Math.round(sortable.length / 2);\r | |
556 | \r | |
557 | for(lang in mergedLangList) {\r | |
558 | counter++;\r | |
559 | isSupportedByGrayt = (lang in graytLangList.ltr) || (lang in graytLangList.rtl);\r | |
560 | dialog.buildRadioInputs(mergedLangList[lang], lang, isSupportedByGrayt).appendTo(counter <= half ? leftCol : rightCol);\r | |
561 | }\r | |
562 | },\r | |
563 | getLangBoxes: function() {\r | |
564 | var dialog = this,\r | |
565 | langboxes = dialog.getContentElement("langs", "langBox").getElement();\r | |
566 | \r | |
567 | return langboxes;\r | |
568 | },\r | |
569 | contents: generateDialogTabs(dialogTabs, editor)\r | |
570 | };\r | |
571 | \r | |
572 | return dialogDefinition;\r | |
573 | });\r |