]> git.immae.eu Git - perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git/blob - sources/plugins/wsc/dialogs/wsc.js
Initial commit
[perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git] / sources / plugins / wsc / dialogs / wsc.js
1 /**
2 * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.html or http://ckeditor.com/license
4 */
5 (function() {
6 // Create support tools
7 var appTools = (function(){
8 var inited = {};
9
10 var _init = function(handler) {
11 if (window.addEventListener) {
12 window.addEventListener('message', handler, false);
13 } else {
14 window.attachEvent("onmessage", handler);
15 }
16 };
17
18 var unbindHandler = function(handler) {
19 if (window.removeEventListener) {
20 window.removeEventListener('message', handler, false);
21 } else {
22 window.detachEvent('onmessage', handler);
23 }
24 };
25
26 var _sendCmd = function(o) {
27 var str,
28 type = Object.prototype.toString,
29 objObject = "[object Object]",
30 fn = o.fn || null,
31 id = o.id || '',
32 target = o.target || window,
33 message = o.message || {
34 'id': id
35 };
36
37 if (o.message && type.call(o.message) == objObject) {
38 (o.message.id) ? o.message.id : o.message.id = id;
39 message = o.message;
40 }
41
42 str = window.JSON.stringify(message, fn);
43 target.postMessage(str, '*');
44 };
45
46 var _hashCreate = function(o, fn) {
47 fn = fn || null;
48 var str = window.JSON.stringify(o, fn);
49 return str;
50 };
51
52 var _hashParse = function(str, fn) {
53 fn = fn || null;
54 return window.JSON.parse(str, fn);
55 };
56
57 var setCookie = function(name, value, options) {
58 options = options || {};
59
60 var expires = options.expires;
61
62 if (typeof expires == "number" && expires) {
63 var d = new Date();
64 d.setTime(d.getTime() + expires*1000);
65 expires = options.expires = d;
66 }
67 if (expires && expires.toUTCString) {
68 options.expires = expires.toUTCString();
69 }
70
71 value = encodeURIComponent(value);
72 var updatedCookie = name + "=" + value;
73
74 for(var propName in options) {
75 var propValue = options[propName];
76 updatedCookie += "; " + propName;
77 if (propValue !== true) {
78 updatedCookie += "=" + propValue;
79 }
80 }
81 document.cookie = updatedCookie;
82 };
83
84 var getCookie = function(name) {
85 var matches = document.cookie.match(new RegExp(
86 "(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"
87 ));
88 return matches ? decodeURIComponent(matches[1]) : undefined;
89 };
90
91 var deleteCookie = function(name) {
92 setCookie(name, "", { expires: -1 });
93 };
94
95 var findFocusable = function(ckEl) {
96 var result = null,
97 focusableSelectors = 'a[href], area[href], input, select, textarea, button, *[tabindex], *[contenteditable]';
98
99 if(ckEl) {
100 result = ckEl.find(focusableSelectors);
101 }
102
103 return result;
104 };
105
106 var getStyle = function(el, prop) {
107 if(document.defaultView && document.defaultView.getComputedStyle) {
108 return document.defaultView.getComputedStyle(el, null)[prop];
109 } else if(el.currentStyle) {
110 return el.currentStyle[prop];
111 } else {
112 return el.style[prop];
113 }
114 };
115
116 var isHidden = function(el) {
117 return el.offsetWidth === 0 || el.offsetHeight == 0 || getStyle(el, 'display') === 'none';
118 };
119
120 var isVisible = function(el) {
121 return !isHidden(el);
122 };
123
124 var hasClass = function (obj, cname) {
125 return !!(obj.className ? obj.className.match(new RegExp('(\\s|^)'+cname+'(\\s|$)')) : false);
126 };
127
128 return {
129 postMessage: {
130 init: _init,
131 send: _sendCmd,
132 unbindHandler: unbindHandler
133 },
134 hash: {
135 create: function() {
136
137 },
138
139 parse: function() {
140
141 }
142 },
143 cookie: {
144 set: setCookie,
145 get: getCookie,
146 remove: deleteCookie
147 },
148 misc: {
149 findFocusable: findFocusable,
150 isVisible: isVisible,
151 hasClass: hasClass
152 }
153 };
154 })();
155
156 var NS = NS || {};
157 NS.TextAreaNumber = null;
158 NS.load = true;
159 NS.cmd = {
160 "SpellTab": 'spell',
161 "Thesaurus": 'thes',
162 "GrammTab": 'grammar'
163 };
164 NS.dialog = null;
165 NS.optionNode = null;
166 NS.selectNode = null;
167 NS.grammerSuggest = null;
168 NS.textNode = {};
169 NS.iframeMain = null;
170 NS.dataTemp = '';
171 NS.div_overlay = null;
172 NS.textNodeInfo = {};
173 NS.selectNode = {};
174 NS.selectNodeResponce = {};
175 NS.langList = null;
176 NS.langSelectbox = null;
177 NS.banner = '';
178 NS.show_grammar = null;
179 NS.div_overlay_no_check = null;
180 NS.targetFromFrame = {};
181 NS.onLoadOverlay = null;
182 NS.LocalizationComing = {};
183 NS.OverlayPlace = null;
184 NS.sessionid = '';
185 NS.LocalizationButton = {
186 'ChangeTo_button': {
187 'instance' : null,
188 'text' : 'Change to',
189 'localizationID': 'ChangeTo'
190 },
191
192 'ChangeAll': {
193 'instance' : null,
194 'text' : 'Change All'
195 },
196
197 'IgnoreWord': {
198 'instance' : null,
199 'text' : 'Ignore word'
200 },
201
202 'IgnoreAllWords': {
203 'instance' : null,
204 'text' : 'Ignore all words'
205 },
206
207 'Options': {
208 'instance' : null,
209 'text' : 'Options',
210 'optionsDialog': {
211 'instance' : null
212 }
213 },
214
215 'AddWord': {
216 'instance' : null,
217 'text' : 'Add word'
218 },
219
220 'FinishChecking_button': {
221 'instance' : null,
222 'text' : 'Finish Checking',
223 'localizationID': 'FinishChecking'
224 },
225
226 'FinishChecking_button_block': {
227 'instance' : null,
228 'text' : 'Finish Checking',
229 'localizationID': 'FinishChecking'
230 }
231 };
232
233 NS.LocalizationLabel = {
234 'ChangeTo_label': {
235 'instance' : null,
236 'text' : 'Change to',
237 'localizationID': 'ChangeTo'
238 },
239
240 'Suggestions': {
241 'instance' : null,
242 'text' : 'Suggestions'
243 },
244
245 'Categories': {
246 'instance' : null,
247 'text' : 'Categories'
248 },
249
250 'Synonyms': {
251 'instance' : null,
252 'text' : 'Synonyms'
253 }
254 };
255
256 var SetLocalizationButton = function(obj) {
257 var el, localizationID;
258
259 for(var i in obj) {
260 el = NS.dialog.getContentElement(NS.dialog._.currentTabId, i);
261
262 if(el) {
263 el = el.getElement();
264 } else {
265 el = obj[i].instance.getElement().getFirst() || obj[i].instance.getElement();
266 }
267
268 localizationID = obj[i].localizationID || i;
269 el.setText(NS.LocalizationComing[localizationID]);
270 }
271 };
272
273 var SetLocalizationLabel = function(obj) {
274 var el, localizationID;
275
276 for(var i in obj) {
277 el = NS.dialog.getContentElement(NS.dialog._.currentTabId, i);
278
279 if(!el) {
280 el = obj[i].instance;
281 }
282
283 if(el.setLabel) {
284 localizationID = obj[i].localizationID || i;
285 el.setLabel(NS.LocalizationComing[localizationID] + ':');
286 }
287 }
288 };
289 var OptionsConfirm = function(state) {
290 if (state) {
291 nameNode.setValue('');
292 }
293 };
294
295 var iframeOnload = false;
296 var nameNode, selectNode, frameId;
297
298 NS.framesetHtml = function(tab) {
299 var str = '<iframe id=' + NS.iframeNumber + '_' + tab + ' frameborder="0" allowtransparency="1" style="width:100%;border: 1px solid #AEB3B9;overflow: auto;background:#fff; border-radius: 3px;"></iframe>';
300 return str;
301 };
302
303 NS.setIframe = function(that, nameTab) {
304 var iframe,
305 str = NS.framesetHtml(nameTab),
306 iframeId = NS.iframeNumber + '_' + nameTab,
307 // tmp.html from wsc/dialogs
308 iframeInnerHtml =
309 '<!DOCTYPE html>' +
310 '<html>' +
311 '<head>' +
312 '<meta charset="UTF-8">' +
313 '<title>iframe</title>' +
314
315 '<style>' +
316 'html,body{' +
317 'margin: 0;' +
318 'height: 100%;' +
319 'font: 13px/1.555 "Trebuchet MS", sans-serif;' +
320 '}' +
321 'a{' +
322 'color: #888;' +
323 'font-weight: bold;' +
324 'text-decoration: none;' +
325 'border-bottom: 1px solid #888;' +
326 '}' +
327 '.main-box {' +
328 'color:#252525;' +
329 'padding: 3px 5px;' +
330 'text-align: justify;' +
331 '}' +
332 '.main-box p{margin: 0 0 14px;}' +
333 '.main-box .cerr{' +
334 'color: #f00000;' +
335 'border-bottom-color: #f00000;' +
336 '}' +
337 '</style>' +
338 '</head>' +
339 '<body>' +
340 '<div id="content" class="main-box"></div>' +
341 '<iframe src="" frameborder="0" id="spelltext" name="spelltext" style="display:none; width: 100%" ></iframe>' +
342 '<iframe src="" frameborder="0" id="loadsuggestfirst" name="loadsuggestfirst" style="display:none; width: 100%" ></iframe>' +
343 '<iframe src="" frameborder="0" id="loadspellsuggestall" name="loadspellsuggestall" style="display:none; width: 100%" ></iframe>' +
344 '<iframe src="" frameborder="0" id="loadOptionsForm" name="loadOptionsForm" style="display:none; width: 100%" ></iframe>' +
345 '<script>' +
346 '(function(window) {' +
347 // Constructor Manager PostMessage
348
349 'var ManagerPostMessage = function() {' +
350 'var _init = function(handler) {' +
351 'if (document.addEventListener) {' +
352 'window.addEventListener("message", handler, false);' +
353 '} else {' +
354 'window.attachEvent("onmessage", handler);' +
355 '};' +
356 '};' +
357 'var _sendCmd = function(o) {' +
358 'var str,' +
359 'type = Object.prototype.toString,' +
360 'fn = o.fn || null,' +
361 'id = o.id || "",' +
362 'target = o.target || window,' +
363 'message = o.message || { "id": id };' +
364
365 'if (o.message && type.call(o.message) == "[object Object]") {' +
366 '(o.message["id"]) ? o.message["id"] : o.message["id"] = id;' +
367 'message = o.message;' +
368 '};' +
369
370 'str = JSON.stringify(message, fn);' +
371 'target.postMessage(str, "*");' +
372 '};' +
373
374 'return {' +
375 'init: _init,' +
376 'send: _sendCmd' +
377 '};' +
378 '};' +
379
380 'var manageMessageTmp = new ManagerPostMessage;' +
381
382
383 'var appString = (function(){' +
384 'var spell = parent.CKEDITOR.config.wsc.DefaultParams.scriptPath;' +
385 'var serverUrl = parent.CKEDITOR.config.wsc.DefaultParams.serviceHost;' +
386 'return serverUrl + spell;' +
387 '})();' +
388
389 'function loadScript(src, callback) {' +
390 'var scriptTag = document.createElement("script");' +
391 'scriptTag.type = "text/javascript";' +
392 'callback ? callback : callback = function() {};' +
393 'if(scriptTag.readyState) {' +
394 //IE
395 'scriptTag.onreadystatechange = function() {' +
396 'if (scriptTag.readyState == "loaded" ||' +
397 'scriptTag.readyState == "complete") {' +
398 'scriptTag.onreadystatechange = null;' +
399 'setTimeout(function(){scriptTag.parentNode.removeChild(scriptTag)},1);' +
400 'callback();' +
401 '}' +
402 '};' +
403 '}else{' +
404 //Others
405 'scriptTag.onload = function() {' +
406 'setTimeout(function(){scriptTag.parentNode.removeChild(scriptTag)},1);' +
407 'callback();' +
408 '};' +
409 '};' +
410 'scriptTag.src = src;' +
411 'document.getElementsByTagName("head")[0].appendChild(scriptTag);' +
412 '};' +
413
414
415 'window.onload = function(){' +
416 'loadScript(appString, function(){' +
417 'manageMessageTmp.send({' +
418 '"id": "iframeOnload",' +
419 '"target": window.parent' +
420 '});' +
421 '});' +
422 '}' +
423 '})(this);' +
424 '</script>' +
425 '</body>' +
426 '</html>';
427
428 that.getElement().setHtml(str);
429 iframe = document.getElementById(iframeId);
430 iframe = (iframe.contentWindow) ? iframe.contentWindow : (iframe.contentDocument.document) ? iframe.contentDocument.document : iframe.contentDocument;
431 iframe.document.open();
432 iframe.document.write(iframeInnerHtml);
433 iframe.document.close();
434 };
435
436 NS.setCurrentIframe = function(currentTab) {
437 var that = NS.dialog._.contents[currentTab].Content,
438 tabID, iframe;
439
440 NS.setIframe(that, currentTab);
441
442 };
443
444 NS.setHeightBannerFrame = function() {
445 var height = "90px",
446 bannerPlaceSpellTab = NS.dialog.getContentElement('SpellTab', 'banner').getElement(),
447 bannerPlaceGrammTab = NS.dialog.getContentElement('GrammTab', 'banner').getElement(),
448 bannerPlaceThesaurus = NS.dialog.getContentElement('Thesaurus', 'banner').getElement();
449
450 bannerPlaceSpellTab.setStyle('height', height);
451 bannerPlaceGrammTab.setStyle('height', height);
452 bannerPlaceThesaurus.setStyle('height', height);
453 };
454
455 NS.setHeightFrame = function() {
456 var currentTab = NS.dialog._.currentTabId,
457 tabID = NS.iframeNumber + '_' + currentTab,
458 iframe = document.getElementById(tabID);
459
460 iframe.style.height = '240px';
461 };
462
463 NS.sendData = function(scope) {
464 var currentTab = scope._.currentTabId,
465 that = scope._.contents[currentTab].Content,
466 tabID, iframe;
467
468 NS.previousTab = currentTab;
469 NS.setIframe(that, currentTab);
470
471 var loadNewTab = function(event) {
472 currentTab = scope._.currentTabId;
473 event = event || window.event;
474
475 if (!event.data.getTarget().is('a')) {
476 return;
477 }
478
479 if(currentTab === NS.previousTab) return;
480 NS.previousTab = currentTab;
481
482 that = scope._.contents[currentTab].Content;
483 tabID = NS.iframeNumber + '_' + currentTab;
484 NS.div_overlay.setEnable();
485
486 if (!that.getElement().getChildCount()) {
487 NS.setIframe(that, currentTab);
488 iframe = document.getElementById(tabID);
489 NS.targetFromFrame[tabID] = iframe.contentWindow;
490 } else {
491 sendData(NS.targetFromFrame[tabID], NS.cmd[currentTab]);
492 }
493 };
494
495 scope.parts.tabs.removeListener('click', loadNewTab);
496 scope.parts.tabs.on('click', loadNewTab);
497 };
498
499 NS.buildSelectLang = function(aId) {
500 var divContainer = new CKEDITOR.dom.element('div'),
501 selectContainer = new CKEDITOR.dom.element('select'),
502 id = "wscLang" + aId;
503
504 divContainer.addClass("cke_dialog_ui_input_select");
505 divContainer.setAttribute("role", "presentation");
506 divContainer.setStyles({
507 'height': 'auto',
508 'position': 'absolute',
509 'right': '0',
510 'top': '-1px',
511 'width': '160px',
512 'white-space': 'normal'
513 });
514
515 selectContainer.setAttribute('id', id);
516 selectContainer.addClass("cke_dialog_ui_input_select");
517 selectContainer.setStyles({
518 'width': '160px'
519 });
520 var currentTabId = NS.dialog._.currentTabId,
521 frameId = NS.iframeNumber + '_' + currentTabId;
522
523 divContainer.append(selectContainer);
524
525 return divContainer;
526
527 };
528
529 NS.buildOptionLang = function(key, aId) {
530 var id = "wscLang" + aId;
531 var select = document.getElementById(id),
532 fragment = document.createDocumentFragment(),
533 create_option, txt_option,
534 sort = [];
535
536 if(select.options.length === 0) {
537 for (var lang in key) {
538 sort.push([lang, key[lang]]);
539 }
540 sort.sort();
541
542 for (var i = 0; i < sort.length; i++) {
543 create_option=document.createElement("option");
544 create_option.setAttribute("value", sort[i][1]);
545 txt_option = document.createTextNode(sort[i][0]);
546 create_option.appendChild(txt_option);
547
548 fragment.appendChild(create_option);
549 }
550 select.appendChild(fragment);
551 }
552
553 // make appropriate option selected according to current selected language
554 for (var j = 0; j < select.options.length; j++) {
555 if (select.options[j].value == NS.selectingLang) {
556 select.options[j].selected = "selected";
557 }
558 }
559 };
560
561 NS.buildOptionSynonyms = function(key) {
562 var syn = NS.selectNodeResponce[key];
563
564 var select = getSelect( NS.selectNode['Synonyms'] );
565
566 NS.selectNode['Synonyms'].clear();
567
568 for (var i = 0; i < syn.length; i++) {
569 var option = document.createElement('option');
570 option.text = syn[i];
571 option.value = syn[i];
572
573 select.$.add(option, i);
574 }
575
576 NS.selectNode['Synonyms'].getInputElement().$.firstChild.selected = true;
577 NS.textNode['Thesaurus'].setValue(NS.selectNode['Synonyms'].getInputElement().getValue());
578 };
579
580 var setBannerInPlace = function(htmlBanner) {
581 var findBannerPlace = NS.dialog.getContentElement(NS.dialog._.currentTabId, 'banner').getElement();
582 findBannerPlace.setHtml(htmlBanner);
583
584 };
585
586 var overlayBlock = function overlayBlock(opt) {
587 var progress = opt.progress || "",
588 doc = document,
589 target = opt.target || doc.body,
590 overlayId = opt.id || "overlayBlock",
591 opacity = opt.opacity || "0.9",
592 background = opt.background || "#f1f1f1",
593 getOverlay = doc.getElementById(overlayId),
594 thisOverlay = getOverlay || doc.createElement("div");
595
596 thisOverlay.style.cssText = "position: absolute;" +
597 "top:30px;" +
598 "bottom:41px;" +
599 "left:1px;" +
600 "right:1px;" +
601 "z-index: 10020;" +
602 "padding:0;" +
603 "margin:0;" +
604 "background:" + background + ";" +
605 "opacity: " + opacity + ";" +
606 "filter: alpha(opacity=" + opacity * 100 + ");" +
607 "display: none;";
608 thisOverlay.id = overlayId;
609
610 if (!getOverlay) {
611 target.appendChild(thisOverlay);
612 }
613
614 return {
615 setDisable: function() {
616 thisOverlay.style.display = "none";
617 },
618 setEnable: function() {
619 thisOverlay.style.display = "block";
620 }
621 };
622 };
623
624 var buildRadioInputs = function(key, value, check) {
625 var divContainer = new CKEDITOR.dom.element('div'),
626 radioButton = new CKEDITOR.dom.element('input'),
627 radioLabel = new CKEDITOR.dom.element('label'),
628 id = "wscGrammerSuggest" + key + "_" + value;
629
630 divContainer.addClass("cke_dialog_ui_input_radio");
631 divContainer.setAttribute("role", "presentation");
632 divContainer.setStyles({
633 width: "97%",
634 padding: "5px",
635 'white-space': 'normal'
636 });
637
638 radioButton.setAttributes({
639 type: "radio",
640 value: value,
641 name: 'wscGrammerSuggest',
642 id: id
643 });
644 radioButton.setStyles({
645 "float":"left"
646 });
647
648 radioButton.on("click", function(data) {
649 NS.textNode['GrammTab'].setValue(data.sender.getValue());
650 });
651
652 (check) ? radioButton.setAttribute("checked", true) : false;
653
654 radioButton.addClass("cke_dialog_ui_radio_input");
655
656 radioLabel.appendText(key);
657 radioLabel.setAttribute("for", id);
658 radioLabel.setStyles({
659 'display': "block",
660 'line-height': '16px',
661 'margin-left': '18px',
662 'white-space': 'normal'
663 });
664
665 divContainer.append(radioButton);
666 divContainer.append(radioLabel);
667
668 return divContainer;
669 };
670
671 var statusGrammarTab = function(aState) { //#19221
672 aState = aState || 'true';
673 if(aState !== null && aState == 'false'){
674 hideGrammTab();
675 }
676 };
677
678 var langConstructor = function(lang) {
679 var langSelectBox = new __constructLangSelectbox(lang),
680 selectId = "wscLang" + NS.dialog.getParentEditor().name,
681 selectContainer = document.getElementById(selectId),
682 currentTabId = NS.dialog._.currentTabId,
683 frameId = NS.iframeNumber + '_' + currentTabId;
684
685 NS.buildOptionLang(langSelectBox.setLangList, NS.dialog.getParentEditor().name);
686 tabView[langSelectBox.getCurrentLangGroup(NS.selectingLang)].onShow();
687 statusGrammarTab(NS.show_grammar);
688
689 selectContainer.onchange = function(e) {
690 var langGroup = langSelectBox.getCurrentLangGroup(this.value),
691 currentTabId = NS.dialog._.currentTabId,
692 cmd;
693
694 e = e || window.event;
695
696 tabView[langGroup].onShow();
697 statusGrammarTab(NS.show_grammar);
698 NS.div_overlay.setEnable();
699 NS.selectingLang = this.value;
700
701 // get command for current opened tan
702 cmd = NS.cmd[currentTabId];
703 // check whether current tab can be opened after language switching
704 if(!langGroup || !tabView[langGroup] || !tabView[langGroup].allowedTabCommands[cmd]) {
705 // if not so - set default tab to open after reload
706 cmd = tabView[langGroup].defaultTabCommand;
707 }
708
709 for(var key in NS.cmd) {
710 if(NS.cmd[key] == cmd) {
711 NS.previousTab = key;
712 break;
713 }
714 }
715
716 appTools.postMessage.send({
717 'message': {
718 'changeLang': NS.selectingLang,
719 'text': NS.dataTemp,
720 'cmd': cmd
721 },
722 'target': NS.targetFromFrame[frameId],
723 'id': 'selectionLang_outer__page'
724 });
725 };
726
727 };
728
729 var disableButtonSuggest = function(word) {
730 var changeToButton, changeAllButton,
731 styleDisable = function(instanceButton) {
732 var button = NS.dialog.getContentElement(NS.dialog._.currentTabId, instanceButton) || NS.LocalizationButton[instanceButton].instance;
733 button.getElement().hasClass('cke_disabled') ? button.getElement().setStyle('color', '#a0a0a0') : button.disable();
734 },
735 styleEnable = function(instanceButton) {
736 var button = NS.dialog.getContentElement(NS.dialog._.currentTabId, instanceButton) || NS.LocalizationButton[instanceButton].instance;
737 button.enable();
738 button.getElement().setStyle('color', '#333');
739 };
740
741 if (word == 'no_any_suggestions') {
742 word = 'No suggestions';
743
744 changeToButton = NS.dialog.getContentElement(NS.dialog._.currentTabId, 'ChangeTo_button') || NS.LocalizationButton['ChangeTo_button'].instance;
745 changeToButton.disable();
746 changeAllButton = NS.dialog.getContentElement(NS.dialog._.currentTabId, 'ChangeAll') || NS.LocalizationButton['ChangeAll'].instance;
747 changeAllButton.disable();
748
749 styleDisable('ChangeTo_button');
750 styleDisable('ChangeAll');
751
752 return word;
753 } else {
754 styleEnable('ChangeTo_button');
755 styleEnable('ChangeAll');
756
757 return word;
758 }
759 };
760
761 function getSelect( obj ) {
762 if ( obj && obj.domId && obj.getInputElement().$ )
763 return obj.getInputElement();
764 else if ( obj && obj.$ )
765 return obj;
766 return false;
767 }
768
769 var handlerId = {
770 iframeOnload: function(response) {
771 NS.div_overlay.setEnable();
772 iframeOnload = true;
773 var currentTab = NS.dialog._.currentTabId,
774 tabId = NS.iframeNumber + '_' + currentTab;
775 sendData(NS.targetFromFrame[tabId], NS.cmd[currentTab]);
776 },
777
778 suggestlist: function(response) {
779 delete response.id;
780 NS.div_overlay_no_check.setDisable();
781 hideCurrentFinishChecking();
782 langConstructor(NS.langList);
783
784 var word = disableButtonSuggest(response.word),
785 suggestionsList = '';
786
787 if (word instanceof Array) {
788 word = response.word[0];
789 }
790
791 word = word.split(',');
792 suggestionsList = word;
793
794 NS.textNode['SpellTab'].setValue(suggestionsList[0]);
795
796 var select = getSelect( selectNode );
797
798 selectNode.clear();
799
800 for (var i = 0; i < suggestionsList.length; i++) {
801 var option = document.createElement('option');
802 option.text = suggestionsList[i];
803 option.value = suggestionsList[i];
804
805 select.$.add(option, i);
806 }
807
808 showCurrentTabs();
809 NS.div_overlay.setDisable();
810
811 },
812
813 grammerSuggest: function(response) {
814 delete response.id;
815 delete response.mocklangs;
816
817 hideCurrentFinishChecking();
818 langConstructor(NS.langList); // Show select language for this command CKEDITOR.config.wsc_cmd
819 var firstSuggestValue = response.grammSuggest[0];// ? firstSuggestValue = response.grammSuggest[0] : firstSuggestValue = 'No suggestion for this words';
820 NS.grammerSuggest.getElement().setHtml('');
821
822 NS.textNode['GrammTab'].reset();
823 NS.textNode['GrammTab'].setValue(firstSuggestValue);
824
825 NS.textNodeInfo['GrammTab'].getElement().setHtml('');
826 NS.textNodeInfo['GrammTab'].getElement().setText(response.info);
827
828 var arr = response.grammSuggest,
829 len = arr.length,
830 check = true;
831
832 for (var i = 0; i < len; i++) {
833 NS.grammerSuggest.getElement().append(buildRadioInputs(arr[i], arr[i], check));
834 check = false;
835 }
836
837 showCurrentTabs();
838 NS.div_overlay.setDisable();
839 },
840
841 thesaurusSuggest: function(response) {
842 delete response.id;
843 delete response.mocklangs;
844
845 hideCurrentFinishChecking();
846 langConstructor(NS.langList); // Show select language for this command CKEDITOR.config.wsc_cmd
847 NS.selectNodeResponce = response;
848
849 NS.textNode['Thesaurus'].reset();
850
851 var select = getSelect( NS.selectNode['Categories'] ),
852 count = 0;
853
854 NS.selectNode['Categories'].clear();
855
856 for (var i in response) {
857
858 var option = document.createElement('option');
859 option.text = i;
860 option.value = i;
861
862 select.$.add(option, count);
863 count++
864 }
865
866 var synKey = NS.selectNode['Categories'].getInputElement().getChildren().$[0].value;
867 NS.selectNode['Categories'].getInputElement().getChildren().$[0].selected = true;
868 NS.buildOptionSynonyms(synKey);
869
870 showCurrentTabs();
871 NS.div_overlay.setDisable();
872 count = 0;
873 },
874 finish: function(response) {
875 delete response.id;
876
877 hideCurrentTabs();
878 showCurrentFinishChecking();
879 NS.div_overlay.setDisable();
880 },
881 settext: function(response) {
882 delete response.id;
883
884 var command = NS.dialog.getParentEditor().getCommand( 'checkspell' ),
885 editor = NS.dialog.getParentEditor();
886
887 //set local storage for synchronization before scayt reinit
888 if (editor.scayt && editor.wsc.isSsrvSame) {
889 var wscUDN = editor.wsc.udn;
890
891 if (!wscUDN) {
892 editor.wsc.DataStorage.setData('scayt_user_dictionary_name', '');
893 } else {
894 editor.wsc.DataStorage.setData('scayt_user_dictionary_name', wscUDN);
895 }
896 }
897
898
899 try {
900 editor.focus();
901 } catch(e) {}
902
903 editor.setData(response.text, function(){
904 NS.dataTemp = '';
905 editor.unlockSelection();
906 editor.fire('saveSnapshot');
907 NS.dialog.hide();
908 });
909
910 },
911 ReplaceText: function(response) {
912
913 delete response.id;
914 NS.div_overlay.setEnable();
915
916 NS.dataTemp = response.text;
917 NS.selectingLang = response.currentLang;
918
919 if (response.cmd = 'spell' && response.len !== '0' && response.len) {
920 NS.div_overlay.setDisable();
921 } else {
922 window.setTimeout(function() {
923 try {
924 NS.div_overlay.setDisable();
925 } catch(e) {}
926 }, 500);
927 }
928
929 SetLocalizationButton(NS.LocalizationButton);
930 SetLocalizationLabel(NS.LocalizationLabel);
931
932 },
933 options_checkbox_send: function(response) {
934 delete response.id;
935
936 var obj = {
937 'osp': appTools.cookie.get('osp'),
938 'udn': appTools.cookie.get('udn'),
939 'cust_dic_ids': NS.cust_dic_ids
940 };
941
942 var currentTabId = NS.dialog._.currentTabId,
943 frameId = NS.iframeNumber + '_' + currentTabId;
944
945 appTools.postMessage.send({
946 'message': obj,
947 'target': NS.targetFromFrame[frameId],
948 'id': 'options_outer__page'
949 });
950 },
951
952 getOptions: function(response) {
953 var udn = response.DefOptions.udn;
954 NS.LocalizationComing = response.DefOptions.localizationButtonsAndText;
955 NS.show_grammar = response.show_grammar;
956 NS.langList = response.lang;
957 NS.bnr = response.bannerId;
958 NS.sessionid = response.sessionid;
959 if (response.bannerId) {
960 NS.setHeightBannerFrame();
961 setBannerInPlace(response.banner);
962 } else {
963 NS.setHeightFrame();
964 }
965
966 if (udn == 'undefined') {
967 if (NS.userDictionaryName) {
968 udn = NS.userDictionaryName;
969
970 var obj = {
971 'osp': appTools.cookie.get('osp'),
972 'udn': NS.userDictionaryName,
973 'cust_dic_ids': NS.cust_dic_ids,
974 'id': 'options_dic_send',
975 'udnCmd': 'create'
976 };
977
978 appTools.postMessage.send({
979 'message': obj,
980 'target': NS.targetFromFrame[frameId]
981 });
982
983 } else{
984 udn = '';
985 }
986 }
987
988 appTools.cookie.set('osp', response.DefOptions.osp);
989 appTools.cookie.set('udn', udn);
990 appTools.cookie.set('cust_dic_ids', response.DefOptions.cust_dic_ids);
991
992 appTools.postMessage.send({
993 'id': 'giveOptions'
994 });
995 },
996
997 options_dic_send: function(response) {
998
999 var obj = {
1000 'osp': appTools.cookie.get('osp'),
1001 'udn': appTools.cookie.get('udn'),
1002 'cust_dic_ids': NS.cust_dic_ids,
1003 'id': 'options_dic_send',
1004 'udnCmd': appTools.cookie.get('udnCmd')
1005 };
1006
1007 var currentTabId = NS.dialog._.currentTabId,
1008 frameId = NS.iframeNumber + '_' + currentTabId;
1009
1010 appTools.postMessage.send({
1011 'message': obj,
1012 'target': NS.targetFromFrame[frameId]
1013 });
1014 },
1015 data: function(response) {
1016 delete response.id;
1017 },
1018
1019 giveOptions: function() {
1020
1021 },
1022
1023 setOptionsConfirmF:function() {
1024 OptionsConfirm(false);
1025 },
1026
1027 setOptionsConfirmT:function() {
1028 OptionsConfirm(true);
1029 },
1030
1031 clickBusy: function() {
1032 NS.div_overlay.setEnable();
1033 },
1034
1035 suggestAllCame: function() {
1036 NS.div_overlay.setDisable();
1037 NS.div_overlay_no_check.setDisable();
1038 },
1039
1040 TextCorrect: function() {
1041 langConstructor(NS.langList);
1042 }
1043
1044 };
1045
1046 var handlerIncomingData = function(event) {
1047 event = event || window.event;
1048 var response = window.JSON.parse(event.data);
1049
1050 if(response && response.id) {
1051 handlerId[response.id](response);
1052 }
1053 };
1054
1055 var handlerButtonOptions = function(event) {
1056 event = event || window.event;
1057
1058 var currentTabId = NS.dialog._.currentTabId,
1059 frameId = NS.iframeNumber + '_' + currentTabId;
1060
1061 appTools.postMessage.send({
1062 'message': {
1063 'cmd': 'Options'
1064 },
1065 'target': NS.targetFromFrame[frameId],
1066 'id': 'cmd'
1067 });
1068
1069 };
1070
1071 var sendData = function(frameTarget, cmd, sendText, reset_suggest) {
1072 cmd = cmd || CKEDITOR.config.wsc_cmd;
1073 reset_suggest = reset_suggest || false;
1074 sendText = sendText || NS.dataTemp;
1075
1076 appTools.postMessage.send({
1077 'message': {
1078 'customerId': NS.wsc_customerId,
1079 'text': sendText,
1080 'txt_ctrl': NS.TextAreaNumber,
1081 'cmd': cmd,
1082 'cust_dic_ids': NS.cust_dic_ids,
1083 'udn': NS.userDictionaryName,
1084 'slang': NS.selectingLang,
1085 'reset_suggest': reset_suggest,
1086 'sessionid': NS.sessionid
1087 },
1088 'target': frameTarget,
1089 'id': 'data_outer__page'
1090 });
1091
1092 NS.div_overlay.setEnable();
1093 };
1094
1095 var tabView = {
1096 "superset": {
1097 onShow: function() {
1098 showThesaurusTab();
1099 showGrammTab();
1100 showSpellTab();
1101 },
1102 allowedTabCommands: {
1103 "spell": true,
1104 "grammar": true,
1105 "thes": true
1106 },
1107 defaultTabCommand: "spell"
1108 },
1109 "usual": {
1110 onShow: function() {
1111 hideThesaurusTab();
1112 hideGrammTab();
1113 showSpellTab();
1114 },
1115 allowedTabCommands: {
1116 "spell": true
1117 },
1118 defaultTabCommand: "spell"
1119 },
1120 "rtl": {
1121 onShow: function() {
1122 hideThesaurusTab();
1123 hideGrammTab();
1124 showSpellTab();
1125 },
1126 allowedTabCommands: {
1127 "spell": true
1128 },
1129 defaultTabCommand: "spell"
1130 },
1131 "spellgrammar": {
1132 onShow: function() {
1133 hideThesaurusTab();
1134 showGrammTab();
1135 showSpellTab();
1136 },
1137 allowedTabCommands: {
1138 "spell": true,
1139 "grammar": true
1140 },
1141 defaultTabCommand: "spell"
1142 },
1143 "spellthes": {
1144 onShow: function() {
1145 showThesaurusTab();
1146 hideGrammTab();
1147 showSpellTab();
1148 },
1149 allowedTabCommands: {
1150 "spell": true,
1151 "thes": true
1152 },
1153 defaultTabCommand: "spell"
1154 }
1155 };
1156
1157 var showFirstTab = function(scope) {
1158 var cmdManger = function(cmdView) {
1159 var obj = {};
1160 var _getCmd = function(cmd) {
1161 for (var tabId in cmdView) {
1162 obj[cmdView[tabId]] = tabId;
1163 }
1164 return obj[cmd];
1165 };
1166 return {
1167 getCmdByTab: _getCmd
1168 };
1169 };
1170
1171 var cmdM = new cmdManger(NS.cmd),
1172 tabToOpen = cmdM.getCmdByTab(CKEDITOR.config.wsc_cmd);
1173
1174 scope.selectPage(tabToOpen);
1175 NS.sendData(scope);
1176 };
1177
1178 var showThesaurusTab = function() {
1179 NS.dialog.showPage('Thesaurus');
1180 };
1181
1182 var hideThesaurusTab = function() {
1183 NS.dialog.hidePage('Thesaurus');
1184 };
1185
1186 var showGrammTab = function() {
1187 NS.dialog.showPage('GrammTab');
1188 };
1189
1190 var hideGrammTab = function() {
1191 NS.dialog.hidePage('GrammTab');
1192 };
1193
1194 var showSpellTab = function() {
1195 NS.dialog.showPage('SpellTab');
1196 };
1197
1198 var hideSpellTab = function() {
1199 NS.dialog.hidePage('SpellTab');
1200 };
1201
1202 var showCurrentTabs = function() {
1203 var target = NS.dialog.getContentElement(NS.dialog._.currentTabId, 'bottomGroup').getElement();
1204
1205 target.removeStyle('display');
1206 target.removeStyle('position');
1207 target.removeStyle('left');
1208
1209 target.show();
1210 };
1211
1212 var hideCurrentTabs = function() {
1213 var target = NS.dialog.getContentElement(NS.dialog._.currentTabId, 'bottomGroup').getElement(),
1214 activeElement = document.activeElement,
1215 focusableElements;
1216
1217 target.setStyles({
1218 display: 'block',
1219 position: 'absolute',
1220 left: '-9999px'
1221 });
1222
1223 setTimeout(function() {
1224 target.removeStyle('display');
1225 target.removeStyle('position');
1226 target.removeStyle('left');
1227
1228 target.hide();
1229
1230 NS.dialog._.editor.focusManager.currentActive.focusNext();
1231
1232 focusableElements = appTools.misc.findFocusable(NS.dialog.parts.contents);
1233 if(!appTools.misc.hasClass(activeElement, 'cke_dialog_tab') && !appTools.misc.hasClass(activeElement, 'cke_dialog_contents_body') && appTools.misc.isVisible(activeElement)) {
1234 try {
1235 activeElement.focus();
1236 } catch(e) {}
1237 } else {
1238 for(var i = 0, tmpCkEl; i < focusableElements.count(); i++) {
1239 tmpCkEl = focusableElements.getItem(i);
1240 if(appTools.misc.isVisible(tmpCkEl.$)) {
1241 try {
1242 tmpCkEl.$.focus();
1243 } catch(e) {}
1244
1245 break;
1246 }
1247 }
1248 }
1249 }, 0);
1250 };
1251
1252 var showCurrentFinishChecking = function() {
1253 var target = NS.dialog.getContentElement(NS.dialog._.currentTabId, 'BlockFinishChecking').getElement();
1254
1255 target.removeStyle('display');
1256 target.removeStyle('position');
1257 target.removeStyle('left');
1258
1259 target.show();
1260 };
1261
1262 var hideCurrentFinishChecking = function() {
1263 var target = NS.dialog.getContentElement(NS.dialog._.currentTabId, 'BlockFinishChecking').getElement(),
1264 activeElement = document.activeElement,
1265 focusableElements;
1266
1267 target.setStyles({
1268 display: 'block',
1269 position: 'absolute',
1270 left: '-9999px'
1271 });
1272
1273 setTimeout(function() {
1274 target.removeStyle('display');
1275 target.removeStyle('position');
1276 target.removeStyle('left');
1277
1278 target.hide();
1279
1280 NS.dialog._.editor.focusManager.currentActive.focusNext();
1281
1282 focusableElements = appTools.misc.findFocusable(NS.dialog.parts.contents);
1283 if(!appTools.misc.hasClass(activeElement, 'cke_dialog_tab') && !appTools.misc.hasClass(activeElement, 'cke_dialog_contents_body') && appTools.misc.isVisible(activeElement)) {
1284 try {
1285 activeElement.focus();
1286 } catch(e) {}
1287 } else {
1288 for(var i = 0, tmpCkEl; i < focusableElements.count(); i++) {
1289 tmpCkEl = focusableElements.getItem(i);
1290 if(appTools.misc.isVisible(tmpCkEl.$)) {
1291 try {
1292 tmpCkEl.$.focus();
1293 } catch(e) {}
1294
1295 break;
1296 }
1297 }
1298 }
1299 }, 0);
1300 };
1301
1302
1303
1304 function __constructLangSelectbox(languageGroup) {
1305 if( !languageGroup ) { throw "Languages-by-groups list are required for construct selectbox"; }
1306
1307 var that = this,
1308 o_arr = [],
1309 priorLang ="en_US",
1310 priorLangTitle = "",
1311 currLang = NS.selectingLang;
1312
1313 for ( var group in languageGroup){
1314 for ( var langCode in languageGroup[group]){
1315 var langName = languageGroup[group][langCode];
1316 if ( langName == priorLang ) {
1317 priorLangTitle = langName;
1318 } else {
1319 o_arr.push( langName );
1320 }
1321 }
1322 }
1323
1324 o_arr.sort();
1325 if(priorLangTitle) {
1326 o_arr.unshift( priorLangTitle );
1327 }
1328
1329 var searchGroup = function ( code ){
1330 for ( var group in languageGroup){
1331 for ( var langCode in languageGroup[group]){
1332 if ( langCode.toUpperCase() === code.toUpperCase() ) {
1333 return group;
1334 }
1335 }
1336 }
1337 return "";
1338 };
1339
1340 var _setLangList = function() {
1341 var langList = {},
1342 langArray = [];
1343 for (var group in languageGroup) {
1344 for ( var langCode in languageGroup[group]){
1345 langList[languageGroup[group][langCode]] = langCode;
1346 }
1347 }
1348 return langList;
1349 };
1350
1351 var _return = {
1352 getCurrentLangGroup: function(code) {
1353 return searchGroup(code);
1354 },
1355 setLangList: _setLangList()
1356 };
1357
1358 return _return;
1359 }
1360
1361 CKEDITOR.dialog.add('checkspell', function(editor) {
1362 var handlerButtons = function(event) {
1363 event = event || window.event;
1364
1365 // because in chrome and safary document.activeElement returns <body> tag. We need to signal that clicked element is active
1366 this.getElement().focus();
1367
1368 NS.div_overlay.setEnable();
1369 var currentTabId = NS.dialog._.currentTabId,
1370 frameId = NS.iframeNumber + '_' + currentTabId,
1371 new_word = NS.textNode[currentTabId].getValue(),
1372 cmd = this.getElement().getAttribute("title-cmd");
1373
1374 appTools.postMessage.send({
1375 'message': {
1376 'cmd': cmd,
1377 'tabId': currentTabId,
1378 'new_word': new_word
1379 },
1380 'target': NS.targetFromFrame[frameId],
1381 'id': 'cmd_outer__page'
1382 });
1383
1384 if (cmd == 'ChangeTo' || cmd == 'ChangeAll') {
1385 editor.fire('saveSnapshot');
1386 }
1387
1388 if (cmd == 'FinishChecking') {
1389 editor.config.wsc_onFinish.call(CKEDITOR.document.getWindow().getFrame());
1390 }
1391
1392 },
1393 constraints = {
1394 minWidth: 560,
1395 minHeight: 444
1396 };
1397
1398 function initView(dialog) {
1399 var newViewSettings = {
1400 left: parseInt(editor.config.wsc_left, 10),
1401 top: parseInt(editor.config.wsc_top, 10),
1402 width: parseInt(editor.config.wsc_width, 10),
1403 height: parseInt(editor.config.wsc_height, 10)
1404 },
1405 viewSize = CKEDITOR.document.getWindow().getViewPaneSize(),
1406 currentPosition = dialog.getPosition(),
1407 currentSize = dialog.getSize(),
1408 savePosition = 0;
1409
1410 if(!dialog._.resized) {
1411 var wrapperHeight = currentSize.height - dialog.parts.contents.getSize('height', !(CKEDITOR.env.gecko || CKEDITOR.env.opera || CKEDITOR.env.ie && CKEDITOR.env.quirks)),
1412 wrapperWidth = currentSize.width - dialog.parts.contents.getSize('width', 1);
1413
1414 if(newViewSettings.width < constraints.minWidth || isNaN(newViewSettings.width)) {
1415 newViewSettings.width = constraints.minWidth;
1416 }
1417 if(newViewSettings.width > viewSize.width - wrapperWidth) {
1418 newViewSettings.width = viewSize.width - wrapperWidth;
1419 }
1420
1421 if(newViewSettings.height < constraints.minHeight || isNaN(newViewSettings.height)) {
1422 newViewSettings.height = constraints.minHeight;
1423 }
1424 if(newViewSettings.height > viewSize.height - wrapperHeight) {
1425 newViewSettings.height = viewSize.height - wrapperHeight;
1426 }
1427
1428 currentSize.width = newViewSettings.width + wrapperWidth;
1429 currentSize.height = newViewSettings.height + wrapperHeight;
1430
1431 dialog._.fromResizeEvent = false;
1432 dialog.resize(newViewSettings.width, newViewSettings.height);
1433 setTimeout(function() {
1434 dialog._.fromResizeEvent = false;
1435 CKEDITOR.dialog.fire('resize', {
1436 dialog: dialog,
1437 width: newViewSettings.width,
1438 height: newViewSettings.height
1439 }, editor);
1440 }, 300);
1441 }
1442
1443 if(!dialog._.moved) {
1444 savePosition = isNaN(newViewSettings.left) && isNaN(newViewSettings.top) ? 0 : 1;
1445
1446 if(isNaN(newViewSettings.left)) {
1447 newViewSettings.left = (viewSize.width - currentSize.width) / 2;
1448 }
1449 if(newViewSettings.left < 0) {
1450 newViewSettings.left = 0;
1451 }
1452 if(newViewSettings.left > viewSize.width - currentSize.width) {
1453 newViewSettings.left = viewSize.width - currentSize.width;
1454 }
1455
1456 if(isNaN(newViewSettings.top)) {
1457 newViewSettings.top = (viewSize.height - currentSize.height) / 2;
1458 }
1459 if(newViewSettings.top < 0) {
1460 newViewSettings.top = 0;
1461 }
1462 if(newViewSettings.top > viewSize.height - currentSize.height) {
1463 newViewSettings.top = viewSize.height - currentSize.height;
1464 }
1465
1466 dialog.move(newViewSettings.left, newViewSettings.top, savePosition);
1467 }
1468 }
1469
1470 function createWscObjectForUdAndUdnSyncrhonization() {
1471 editor.wsc = {};
1472
1473 //DataStorage object for cookies and localStorage manipulation
1474 (function( object ) {
1475 'use strict';
1476
1477 var DataTypeManager = {
1478 separator: '<$>',
1479 getDataType: function(value) {
1480 var type;
1481
1482 if(typeof value === 'undefined') {
1483 type = 'undefined';
1484 } else if(value === null) {
1485 type = 'null';
1486 } else {
1487 type = Object.prototype.toString.call(value).slice(8, -1);
1488 }
1489 return type;
1490 },
1491 convertDataToString: function(value) {
1492 var str,
1493 type = this.getDataType(value).toLowerCase();
1494
1495 str = type + this.separator + value;
1496 return str;
1497 },
1498 // get value type and convert value due to type, since all stored values are String
1499 restoreDataFromString: function(str) {
1500 var value = str,
1501 type,
1502 separatorStartIndex;
1503
1504 // @TODO: remove this line much later. Support of old format for options
1505 str = this.backCompatibility(str);
1506
1507 if(typeof str === 'string') {
1508 separatorStartIndex = str.indexOf(this.separator);
1509 type = str.substring(0, separatorStartIndex);
1510 value = str.substring(separatorStartIndex + this.separator.length);
1511
1512 switch(type) {
1513 case 'boolean':
1514 value = value === 'true';
1515 break;
1516 case 'number':
1517 value = parseFloat(value);
1518 break;
1519 // we assume that we will store string values only, due to performance
1520 case 'array':
1521 value = value === '' ? [] : value.split(',');
1522 break;
1523 case 'null':
1524 value = null;
1525 break;
1526 case 'undefined':
1527 value = undefined;
1528 break;
1529 }
1530 }
1531 return value;
1532 },
1533 // old data type support
1534 // here we trying to convert data from old format into new
1535 // @TODO: remove this function much later
1536 backCompatibility: function(str) {
1537 var convertedStr = str,
1538 value,
1539 separatorStartIndex;
1540
1541 if(typeof str === 'string') {
1542 separatorStartIndex = str.indexOf(this.separator);
1543 // is it old format?
1544 if(separatorStartIndex < 0) {
1545 // try to get number from string
1546 value = parseFloat(str);
1547 // is it not a number?
1548 if(isNaN(value)) {
1549 // yes, this is not a number. Lets check is this is an array "[comma,separated,values]"
1550 if((str[0] === '[') && (str[str.length - 1] === ']')) {
1551 // this is an array. Lets remove brackets symbols and extract the words
1552 str = str.replace('[', '');
1553 str = str.replace(']', '');
1554 if(str === '') {
1555 value = [];
1556 } else {
1557 value = str.split(',');
1558 }
1559 // value = str === '[]' ? [] : str.split(',');
1560 } else if(str === 'true' || str === 'false') {
1561 // this is boolean value
1562 value = str === 'true';
1563 } else {
1564 // this is string
1565 value = str;
1566 }
1567 }
1568
1569 convertedStr = this.convertDataToString(value);
1570 }
1571 }
1572
1573 return convertedStr;
1574 }
1575 };
1576
1577 var LocalStorage = {
1578
1579 get: function( key ) {
1580 var value = DataTypeManager.restoreDataFromString( window.localStorage.getItem(key) );
1581 return value;
1582 },
1583
1584 set: function( key, value ) {
1585 var _value = DataTypeManager.convertDataToString( value );
1586 window.localStorage.setItem( key, _value );
1587 },
1588
1589 del: function( key ) {
1590 window.localStorage.removeItem( key );
1591 },
1592
1593 clear: function() {
1594 window.localStorage.clear();
1595 }
1596 };
1597
1598 var CookiesStorage = {
1599
1600 expiration: (function() {
1601 return 60 * 60 * 24 * 366;
1602 }()),
1603
1604 get: function(key) {
1605 var value = DataTypeManager.restoreDataFromString(this.getCookie(key));
1606 return value;
1607 },
1608
1609 set: function(key, value) {
1610 var _value = DataTypeManager.convertDataToString(value);
1611 this.setCookie(key, _value, {expires: this.expiration});
1612 },
1613
1614 del: function(key) {
1615 this.deleteCookie(key);
1616 },
1617
1618 getCookie: function(name) {
1619 var matches = document.cookie.match(new RegExp("(?:^|; )" + name.replace(/([\.$?*|{}\(\)\[\]\\\/\+^])/g, '\\$1') + "=([^;]*)"));
1620 return matches ? decodeURIComponent(matches[1]) : undefined;
1621 },
1622
1623 setCookie: function(name, value, props) {
1624 props = props || {};
1625 var exp = props.expires;
1626
1627 if (typeof exp === "number" && exp) {
1628 var d = new Date();
1629
1630 d.setTime(d.getTime() + exp * 1000);
1631 exp = props.expires = d;
1632 }
1633
1634 if(exp && exp.toUTCString) {
1635 props.expires = exp.toUTCString();
1636 }
1637
1638 value = encodeURIComponent(value);
1639 var updatedCookie = name + "=" + value;
1640
1641 for(var propName in props) {
1642 var propValue = props[propName];
1643
1644 updatedCookie += "; " + propName;
1645
1646 if(propValue !== true) {
1647 updatedCookie += "=" + propValue;
1648 }
1649 }
1650
1651 document.cookie = updatedCookie;
1652 },
1653
1654 deleteCookie: function(name) {
1655 this.setCookie(name, null, {expires: -1});
1656 },
1657
1658 // delete all cookies
1659 clear: function() {
1660 var cookies = document.cookie.split(";");
1661
1662 for (var i = 0; i < cookies.length; i++) {
1663 var cookie = cookies[i];
1664 var eqPos = cookie.indexOf("=");
1665 var name = eqPos > -1 ? cookie.substr(0, eqPos) : cookie;
1666
1667 this.deleteCookie(name);
1668 }
1669 }
1670 };
1671
1672 var strategy = window.localStorage ? LocalStorage : CookiesStorage;
1673
1674 var DataStorage = {
1675 // Get data within storage for key
1676 getData: function( key ) {
1677 return strategy.get( key );
1678 },
1679
1680 // Set data within storage
1681 setData: function( key, value ) {
1682 strategy.set( key, value );
1683 },
1684
1685 // Delete data within storage for key
1686 deleteData: function( key ) {
1687 strategy.del( key );
1688 },
1689
1690 // Clear storage
1691 clear: function() {
1692 strategy.clear();
1693 }
1694 };
1695
1696 // Static Module of Storage Data in the localStorage.
1697 object.DataStorage = DataStorage;
1698 }( editor.wsc ));
1699
1700 editor.wsc.operationWithUDN = function(command, UDName) {
1701 var obj = {
1702 'udn': UDName,
1703 'id': 'operationWithUDN',
1704 'udnCmd': command
1705 };
1706 var currentTabId = NS.dialog._.currentTabId,
1707 frameId = NS.iframeNumber + '_' + currentTabId;
1708
1709 appTools.postMessage.send({
1710 'message': obj,
1711 'target': NS.targetFromFrame[frameId]
1712 });
1713 };
1714 editor.wsc.getLocalStorageUDN = function() {
1715 var udn = editor.wsc.DataStorage.getData('scayt_user_dictionary_name');
1716
1717 if (!udn) {
1718 return;
1719 }
1720
1721 return udn;
1722 };
1723 editor.wsc.getLocalStorageUD = function() {
1724 var ud = editor.wsc.DataStorage.getData('scayt_user_dictionary');
1725
1726 if (!ud) {
1727 return;
1728 }
1729
1730 return ud;
1731 };
1732 editor.wsc.addWords = function(words, callback) {
1733 var url = editor.config.wsc.DefaultParams.serviceHost + editor.config.wsc.DefaultParams.ssrvHost +
1734 '?cmd=dictionary&format=json&' +
1735 'customerid=1%3AncttD3-fIoSf2-huzwE4-Y5muI2-mD0Tt-kG9Wz-UEDFC-tYu243-1Uq474-d9Z2l3&' +
1736 'action=addword&word='+ words + '&callback=toString&synchronization=true',
1737 script = document.createElement('script');
1738
1739 script['type'] = 'text/javascript';
1740 script['src'] = url;
1741 document.getElementsByTagName("head")[0].appendChild(script);
1742
1743 //chrome, firefox, safari
1744 script.onload = callback;
1745
1746 //IE
1747 script.onreadystatechange = function() {
1748 if (this.readyState === 'loaded') {
1749 callback();
1750 }
1751 };
1752 };
1753 editor.wsc.cgiOrigin = function() {
1754 var wscServiceHostString = editor.config.wsc.DefaultParams.serviceHost,
1755 wscServiceHostArray = wscServiceHostString.split('/'),
1756 cgiOrigin = wscServiceHostArray[0] + '//' + wscServiceHostArray[2];
1757
1758 return cgiOrigin;
1759 };
1760 editor.wsc.isSsrvSame = false;
1761 }
1762
1763 return {
1764 title: editor.config.wsc_dialogTitle || editor.lang.wsc.title,
1765 minWidth: constraints.minWidth,
1766 minHeight: constraints.minHeight,
1767 buttons: [CKEDITOR.dialog.cancelButton],
1768 onLoad: function() {
1769 NS.dialog = this;
1770 hideThesaurusTab();
1771 hideGrammTab();
1772 showSpellTab();
1773
1774 //creating wsc object for UD synchronization between wsc and scayt
1775 if (editor.plugins.scayt) {
1776 createWscObjectForUdAndUdnSyncrhonization();
1777 }
1778 },
1779 onShow: function() {
1780 NS.dialog = this;
1781
1782 editor.lockSelection(editor.getSelection());
1783
1784 NS.TextAreaNumber = 'cke_textarea_' + editor.name;
1785 appTools.postMessage.init(handlerIncomingData);
1786 NS.dataTemp = editor.getData();
1787 //NS.div_overlay.setDisable();
1788 NS.OverlayPlace = NS.dialog.parts.tabs.getParent().$;
1789 if(CKEDITOR && CKEDITOR.config){
1790 NS.wsc_customerId = editor.config.wsc_customerId;
1791 NS.cust_dic_ids = editor.config.wsc_customDictionaryIds;
1792 NS.userDictionaryName = editor.config.wsc_userDictionaryName;
1793 NS.defaultLanguage = CKEDITOR.config.defaultLanguage;
1794 var protocol = document.location.protocol == "file:" ? "http:" : document.location.protocol;
1795 var wscCoreUrl = editor.config.wsc_customLoaderScript || ( protocol + '//loader.webspellchecker.net/sproxy_fck/sproxy.php?plugin=fck2&customerid=' + NS.wsc_customerId + '&cmd=script&doc=wsc&schema=22');
1796 } else {
1797 NS.dialog.hide();
1798 return;
1799 }
1800
1801 initView(this);
1802
1803 CKEDITOR.scriptLoader.load(wscCoreUrl, function(success) {
1804 if(CKEDITOR.config && CKEDITOR.config.wsc && CKEDITOR.config.wsc.DefaultParams){
1805 NS.serverLocationHash = CKEDITOR.config.wsc.DefaultParams.serviceHost;
1806 NS.logotype = CKEDITOR.config.wsc.DefaultParams.logoPath;
1807 NS.loadIcon = CKEDITOR.config.wsc.DefaultParams.iconPath;
1808 NS.loadIconEmptyEditor = CKEDITOR.config.wsc.DefaultParams.iconPathEmptyEditor;
1809 NS.LangComparer = new CKEDITOR.config.wsc.DefaultParams._SP_FCK_LangCompare();
1810 }else{
1811 NS.serverLocationHash = DefaultParams.serviceHost;
1812 NS.logotype = DefaultParams.logoPath;
1813 NS.loadIcon = DefaultParams.iconPath;
1814 NS.loadIconEmptyEditor = DefaultParams.iconPathEmptyEditor;
1815 NS.LangComparer = new _SP_FCK_LangCompare();
1816 }
1817
1818 NS.pluginPath = CKEDITOR.getUrl(editor.plugins.wsc.path);
1819 NS.iframeNumber = NS.TextAreaNumber;
1820 NS.templatePath = NS.pluginPath + 'dialogs/tmp.html';
1821 NS.LangComparer.setDefaulLangCode( NS.defaultLanguage );
1822 NS.currentLang = editor.config.wsc_lang || NS.LangComparer.getSPLangCode( editor.langCode ) || 'en_US';
1823 NS.selectingLang = NS.currentLang;
1824 NS.div_overlay = new overlayBlock({
1825 opacity: "1",
1826 background: "#fff url(" + NS.loadIcon + ") no-repeat 50% 50%",
1827 target: NS.OverlayPlace
1828
1829 });
1830
1831 var number_ck = NS.dialog.parts.tabs.getId(),
1832 dialogPartsTab = CKEDITOR.document.getById(number_ck);
1833
1834 dialogPartsTab.setStyle('width', '97%');
1835 if (!dialogPartsTab.getElementsByTag('DIV').count()){
1836 dialogPartsTab.append(NS.buildSelectLang(NS.dialog.getParentEditor().name));
1837 }
1838
1839 NS.div_overlay_no_check = new overlayBlock({
1840 opacity: "1",
1841 id: 'no_check_over',
1842 background: "#fff url(" + NS.loadIconEmptyEditor + ") no-repeat 50% 50%",
1843 target: NS.OverlayPlace
1844 });
1845
1846 if (success) {
1847 showFirstTab(NS.dialog);
1848 NS.dialog.setupContent(NS.dialog);
1849 }
1850
1851 if (editor.plugins.scayt) {
1852 //is ssrv.cgi path for WSC and scayt same
1853 editor.wsc.isSsrvSame = (function() {
1854 var wscSsrvWholePath,
1855 wscServiceHost = CKEDITOR.config.wsc.DefaultParams.serviceHost.replace('lf/22/js/../../../', '').split('//')[1],
1856 wscSsrvHost = CKEDITOR.config.wsc.DefaultParams.ssrvHost,
1857 scaytSsrvWholePath,
1858 scaytSsrvProtocol,
1859 scaytSsrvHost,
1860 scaytSsrvPath,
1861
1862 scaytSrcUrl = editor.config.scayt_srcUrl,
1863 scaytSsrvSrcUrlSsrvProtocol,
1864 scaytSsrvSrcUrlSsrvHost,
1865 scaytSsrvSrcUrlSsrvPath,
1866
1867 scaytBasePath,
1868 scaytBasePathSsrvProtocol,
1869 scaytBasePathSsrvHost,
1870 scaytBasePathSsrvPath;
1871
1872 if (window.SCAYT && window.SCAYT.CKSCAYT) {
1873 scaytBasePath = SCAYT.CKSCAYT.prototype.basePath;
1874 scaytBasePathSsrvProtocol = scaytBasePath.split('//')[0];
1875 scaytBasePathSsrvHost = scaytBasePath.split('//')[1].split('/')[0];
1876 scaytBasePathSsrvPath = scaytBasePath.split(scaytBasePathSsrvHost + '/')[1].replace('/lf/scayt3/ckscayt/', '') + '/script/ssrv.cgi';
1877 }
1878
1879 if (scaytSrcUrl && !scaytBasePath && !editor.config.scayt_servicePath) {
1880 scaytSsrvSrcUrlSsrvProtocol = scaytSrcUrl.split('//')[0];
1881 scaytSsrvSrcUrlSsrvHost = scaytSrcUrl.split('//')[1].split('/')[0];
1882 scaytSsrvSrcUrlSsrvPath = scaytSrcUrl.split(scaytSsrvSrcUrlSsrvHost + '/')[1].replace('/lf/scayt3/ckscayt/ckscayt.js', '') + '/script/ssrv.cgi';
1883 }
1884
1885 scaytSsrvProtocol = editor.config.scayt_serviceProtocol || scaytBasePathSsrvProtocol || scaytSsrvSrcUrlSsrvProtocol;
1886 scaytSsrvHost = editor.config.scayt_serviceHost || scaytBasePathSsrvHost || scaytSsrvSrcUrlSsrvHost;
1887 scaytSsrvPath = editor.config.scayt_servicePath || scaytBasePathSsrvPath || scaytSsrvSrcUrlSsrvPath;
1888
1889 wscSsrvWholePath = '//' + wscServiceHost + wscSsrvHost;
1890 scaytSsrvWholePath = '//' + scaytSsrvHost + '/' + scaytSsrvPath;
1891
1892 return wscSsrvWholePath === scaytSsrvWholePath;
1893 })();
1894 }
1895
1896 //wsc on scayt UserDictionary and UserDictionaryName synchronization
1897 if (window.SCAYT && editor.wsc && editor.wsc.isSsrvSame) {
1898 var cgiOrigin = editor.wsc.cgiOrigin();
1899 editor.wsc.syncIsDone = false;
1900
1901 var getUdOrUdn = function (e) {
1902 if (e.origin === cgiOrigin) {
1903 var data = JSON.parse(e.data);
1904
1905 if (data.ud && data.ud !== 'undefined') {
1906 editor.wsc.ud = data.ud;
1907 } else if (data.ud === 'undefined') {
1908 editor.wsc.ud = undefined;
1909 }
1910
1911 if (data.udn && data.udn !== 'undefined') {
1912 editor.wsc.udn = data.udn;
1913 } else if (data.udn === 'undefined') {
1914 editor.wsc.udn = undefined;
1915 }
1916
1917 if (!editor.wsc.syncIsDone) {
1918 udSynchronization(editor.wsc.ud);
1919 editor.wsc.syncIsDone = true;
1920 }
1921 }
1922 };
1923
1924 var udSynchronization = function(cookieUd) {
1925 var localStorageUdArray = editor.wsc.getLocalStorageUD(),
1926 newUd;
1927
1928 if (localStorageUdArray instanceof Array) {
1929 newUd = localStorageUdArray.toString();
1930 }
1931
1932 if (newUd !== undefined && newUd !== '') {
1933 setTimeout(function() {
1934 editor.wsc.addWords(newUd, function() {
1935 showFirstTab(NS.dialog);
1936 NS.dialog.setupContent(NS.dialog);
1937 });
1938 }, 400);
1939 }
1940 };
1941
1942 if (window.addEventListener){
1943 addEventListener("message", getUdOrUdn, false);
1944 } else {
1945 window.attachEvent("onmessage", getUdOrUdn);
1946 }
1947
1948 //wsc on scayt UserDictionaryName synchronization
1949 setTimeout(
1950 function() {
1951 var udn = editor.wsc.getLocalStorageUDN();
1952
1953 if (udn !== undefined) {
1954 editor.wsc.operationWithUDN('restore', udn);
1955 }
1956
1957 },
1958 500); //need to wait spell.js file to load
1959
1960 }
1961 });
1962
1963 },
1964 onHide: function() {
1965 var scaytPlugin = CKEDITOR.plugins.scayt,
1966 scaytInstance = editor.scayt;
1967
1968 editor.unlockSelection();
1969
1970 if(scaytPlugin && scaytInstance && scaytPlugin.state[editor.name]) {
1971 scaytInstance.setMarkupPaused(false);
1972 }
1973
1974 NS.dataTemp = '';
1975 NS.sessionid = '';
1976 appTools.postMessage.unbindHandler(handlerIncomingData);
1977
1978 //scayt on wsc UserDictionary and UserDictionaryName synchronization
1979 if (editor.plugins.scayt && editor.wsc && editor.wsc.isSsrvSame) {
1980 var wscUDN = editor.wsc.udn,
1981 wscUD = editor.wsc.ud,
1982 wscUDarray,
1983 i;
1984
1985 if (editor.scayt) { // if SCAYT active
1986 if (!wscUDN) {
1987 editor.wsc.DataStorage.setData('scayt_user_dictionary_name', '');
1988 editor.scayt.removeUserDictionary();
1989 } else {
1990 editor.wsc.DataStorage.setData('scayt_user_dictionary_name', wscUDN);
1991 editor.scayt.restoreUserDictionary(wscUDN);
1992 }
1993
1994 if (wscUD) {
1995 setTimeout(function() {
1996 wscUDarray = wscUD.split(',');
1997 for (i = 0; i < wscUDarray.length; i += 1) {
1998 editor.scayt.addWordToUserDictionary(wscUDarray[i]);
1999 }
2000 }, 200); //wait for 'removeUserDictionary' command response
2001 }
2002
2003 if (!wscUD) {
2004 editor.wsc.DataStorage.setData('scayt_user_dictionary', []);
2005 }
2006
2007 } else { //if SCAYT not active
2008
2009 if (!wscUDN) {
2010 editor.wsc.DataStorage.setData('scayt_user_dictionary_name', '');
2011 } else {
2012 editor.wsc.DataStorage.setData('scayt_user_dictionary_name', wscUDN);
2013 }
2014
2015 if (wscUD) {
2016 wscUDarray = wscUD.split(',');
2017 editor.wsc.DataStorage.setData('scayt_user_dictionary', wscUDarray);
2018 }
2019 }
2020 }
2021 },
2022 contents: [
2023 {
2024 id: 'SpellTab',
2025 label: 'SpellChecker',
2026 accessKey: 'S',
2027 elements: [
2028 {
2029 type: 'html',
2030 id: 'banner',
2031 label: 'banner',
2032 style: '', //TODO
2033 html: '<div></div>'
2034 },
2035 {
2036 type: 'html',
2037 id: 'Content',
2038 label: 'spellContent',
2039 html: '',
2040 setup: function(dialog) {
2041 var tabId = NS.iframeNumber + '_' + dialog._.currentTabId;
2042 var iframe = document.getElementById(tabId);
2043 NS.targetFromFrame[tabId] = iframe.contentWindow;
2044 }
2045 },
2046 {
2047 type: 'hbox',
2048 id: 'bottomGroup',
2049 style: 'width:560px; margin: 0 auto;',
2050 widths: ['50%', '50%'],
2051 children: [
2052 {
2053 type: 'hbox',
2054 id: 'leftCol',
2055 align: 'left',
2056 width: '50%',
2057 children: [
2058 {
2059 type: 'vbox',
2060 id: 'rightCol1',
2061 widths: ['50%', '50%'],
2062 children: [
2063 {
2064 type: 'text',
2065 id: 'ChangeTo_label',
2066 label: NS.LocalizationLabel['ChangeTo_label'].text + ':',
2067 labelLayout: 'horizontal',
2068 labelStyle: 'font: 12px/25px arial, sans-serif;',
2069 width: '140px',
2070 'default': '',
2071 onShow: function() {
2072 NS.textNode['SpellTab'] = this;
2073 NS.LocalizationLabel['ChangeTo_label'].instance = this;
2074 },
2075 onHide: function() {
2076 this.reset();
2077 }
2078 },
2079 {
2080 type: 'hbox',
2081 id: 'rightCol',
2082 align: 'right',
2083 width: '30%',
2084 children: [
2085 {
2086 type: 'vbox',
2087 id: 'rightCol_col__left',
2088 children: [
2089 {
2090 type: 'text',
2091 id: 'labelSuggestions',
2092 label: NS.LocalizationLabel['Suggestions'].text + ':',
2093 onShow: function() {
2094 NS.LocalizationLabel['Suggestions'].instance = this;
2095 this.getInputElement().setStyles({
2096 display: 'none'
2097 });
2098 }
2099 },
2100 {
2101 type: 'html',
2102 id: 'logo',
2103 html: '<img width="99" height="68" border="0" src="" title="WebSpellChecker.net" alt="WebSpellChecker.net" style="display: inline-block;">',
2104 setup: function(dialog) {
2105 this.getElement().$.src = NS.logotype;
2106 this.getElement().getParent().setStyles({
2107 "text-align": "left"
2108 });
2109 }
2110 }
2111 ]
2112 },
2113 {
2114 type: 'select',
2115 id: 'list_of_suggestions',
2116 labelStyle: 'font: 12px/25px arial, sans-serif;',
2117 size: '6',
2118 inputStyle: 'width: 140px; height: auto;',
2119 items: [['loading...']],
2120 onShow: function() {
2121 selectNode = this;
2122 },
2123 onChange: function() {
2124 NS.textNode['SpellTab'].setValue(this.getValue());
2125 }
2126 }
2127 ]
2128 }
2129 ]
2130 }
2131 ]
2132 },
2133 {
2134 type: 'hbox',
2135 id: 'rightCol',
2136 align: 'right',
2137 width: '50%',
2138 children: [
2139 {
2140 type: 'vbox',
2141 id: 'rightCol_col__left',
2142 widths: ['50%', '50%', '50%', '50%'],
2143 children: [
2144 {
2145 type: 'button',
2146 id: 'ChangeTo_button',
2147 label: NS.LocalizationButton['ChangeTo_button'].text,
2148 title: 'Change to',
2149 style: 'width: 100%;',
2150 onLoad: function() {
2151 this.getElement().setAttribute("title-cmd", 'ChangeTo');
2152 NS.LocalizationButton['ChangeTo_button'].instance = this;
2153 },
2154 onClick: handlerButtons
2155 },
2156 {
2157 type: 'button',
2158 id: 'ChangeAll',
2159 label: NS.LocalizationButton['ChangeAll'].text,
2160 title: 'Change All',
2161 style: 'width: 100%;',
2162 onLoad: function() {
2163 this.getElement().setAttribute("title-cmd", this.id);
2164 NS.LocalizationButton['ChangeAll'].instance = this;
2165 },
2166 onClick: handlerButtons
2167 },
2168 {
2169 type: 'button',
2170 id: 'AddWord',
2171 label: NS.LocalizationButton['AddWord'].text,
2172 title: 'Add word',
2173 style: 'width: 100%;',
2174 onLoad: function() {
2175 this.getElement().setAttribute("title-cmd", this.id);
2176 NS.LocalizationButton['AddWord'].instance = this;
2177 },
2178 onClick: handlerButtons
2179 },
2180 {
2181 type: 'button',
2182 id: 'FinishChecking_button',
2183 label: NS.LocalizationButton['FinishChecking_button'].text,
2184 title: 'Finish Checking',
2185 style: 'width: 100%;margin-top: 9px;',
2186 onLoad: function() {
2187 this.getElement().setAttribute("title-cmd", 'FinishChecking');
2188 NS.LocalizationButton['FinishChecking_button'].instance = this;
2189 },
2190 onClick: handlerButtons
2191 }
2192 ]
2193 },
2194 {
2195 type: 'vbox',
2196 id: 'rightCol_col__right',
2197 widths: ['50%', '50%', '50%'],
2198 children: [
2199 {
2200 type: 'button',
2201 id: 'IgnoreWord',
2202 label: NS.LocalizationButton['IgnoreWord'].text,
2203 title: 'Ignore word',
2204 style: 'width: 100%;',
2205 onLoad: function() {
2206 this.getElement().setAttribute("title-cmd", this.id);
2207 NS.LocalizationButton['IgnoreWord'].instance = this;
2208 },
2209 onClick: handlerButtons
2210 },
2211 {
2212 type: 'button',
2213 id: 'IgnoreAllWords',
2214 label: NS.LocalizationButton['IgnoreAllWords'].text,
2215 title: 'Ignore all words',
2216 style: 'width: 100%;',
2217 onLoad: function() {
2218 this.getElement().setAttribute("title-cmd", this.id);
2219 NS.LocalizationButton['IgnoreAllWords'].instance = this;
2220 },
2221 onClick: handlerButtons
2222 },
2223 {
2224 type: 'button',
2225 id: 'Options',
2226 label: NS.LocalizationButton['Options'].text,
2227 title: 'Option',
2228 style: 'width: 100%;',
2229 onLoad: function() {
2230 NS.LocalizationButton['Options'].instance = this;
2231 if (document.location.protocol == "file:") {
2232 this.disable();
2233 }
2234 },
2235 onClick: function() {
2236 // because in chrome and safary document.activeElement returns <body> tag. We need to signal that clicked element is active
2237 this.getElement().focus();
2238
2239 if (document.location.protocol == "file:") {
2240 alert('WSC: Options functionality is disabled when runing from file system');
2241 } else {
2242 activeElement = document.activeElement;
2243 editor.openDialog('options');
2244 }
2245 }
2246 }
2247 ]
2248 }
2249 ]
2250 }
2251 ]
2252 },
2253 {
2254 type: 'hbox',
2255 id: 'BlockFinishChecking',
2256 style: 'width:560px; margin: 0 auto;',
2257 widths: ['70%', '30%'],
2258 onShow: function() {
2259 this.getElement().setStyles({
2260 display: 'block',
2261 position: 'absolute',
2262 left: '-9999px'
2263 });
2264 },
2265 onHide: showCurrentTabs,
2266 children: [
2267 {
2268 type: 'hbox',
2269 id: 'leftCol',
2270 align: 'left',
2271 width: '70%',
2272 children: [
2273 {
2274 type: 'vbox',
2275 id: 'rightCol1',
2276 setup: function() {
2277 this.getChild()[0].getElement().$.src = NS.logotype;
2278 this.getChild()[0].getElement().getParent().setStyles({
2279 "text-align": "center"
2280 });
2281 },
2282 children: [
2283 {
2284 type: 'html',
2285 id: 'logo',
2286 html: '<img width="99" height="68" border="0" src="" title="WebSpellChecker.net" alt="WebSpellChecker.net" style="display: inline-block;">'
2287 }
2288 ]
2289 }
2290 ]
2291 },
2292 {
2293 type: 'hbox',
2294 id: 'rightCol',
2295 align: 'right',
2296 width: '30%',
2297 children: [
2298 {
2299 type: 'vbox',
2300 id: 'rightCol_col__left',
2301 children: [
2302 {
2303 type: 'button',
2304 id: 'Option_button',
2305 label: NS.LocalizationButton['Options'].text,
2306 title: 'Option',
2307 style: 'width: 100%;',
2308 onLoad: function() {
2309 this.getElement().setAttribute("title-cmd", this.id);
2310 if (document.location.protocol == "file:") {
2311 this.disable();
2312 }
2313 },
2314 onClick: function() {
2315 // because in chrome and safary document.activeElement returns <body> tag. We need to signal that clicked element is active
2316 this.getElement().focus();
2317
2318 if (document.location.protocol == "file:") {
2319 alert('WSC: Options functionality is disabled when runing from file system');
2320 } else {
2321 activeElement = document.activeElement;
2322 editor.openDialog('options');
2323 }
2324 }
2325 },
2326 {
2327 type: 'button',
2328 id: 'FinishChecking_button_block',
2329 label: NS.LocalizationButton['FinishChecking_button_block'].text,
2330 title: 'Finish Checking',
2331 style: 'width: 100%;',
2332 onLoad: function() {
2333 this.getElement().setAttribute("title-cmd", 'FinishChecking');
2334 },
2335 onClick: handlerButtons
2336 }
2337 ]
2338 }
2339 ]
2340 }
2341 ]
2342 }
2343 ]
2344 },
2345 {
2346 id: 'GrammTab',
2347 label: 'Grammar',
2348 accessKey: 'G',
2349 elements: [
2350 {
2351 type: 'html',
2352 id: 'banner',
2353 label: 'banner',
2354 style: '', //TODO
2355 html: '<div></div>'
2356 },
2357 {
2358 type: 'html',
2359 id: 'Content',
2360 label: 'GrammarContent',
2361 html: '',
2362 setup: function() {
2363 var tabId = NS.iframeNumber + '_' + NS.dialog._.currentTabId;
2364 var iframe = document.getElementById(tabId);
2365 NS.targetFromFrame[tabId] = iframe.contentWindow;
2366 }
2367 },
2368 {
2369 type: 'vbox',
2370 id: 'bottomGroup',
2371 style: 'width:560px; margin: 0 auto;',
2372 children: [
2373 {
2374 type: 'hbox',
2375 id: 'leftCol',
2376 widths: ['66%', '34%'],
2377 children: [
2378 {
2379 type: 'vbox',
2380 children: [
2381 {
2382 type: 'text',
2383 id: 'text',
2384 label: "Change to:",
2385 labelLayout: 'horizontal',
2386 labelStyle: 'font: 12px/25px arial, sans-serif;',
2387 inputStyle: 'float: right; width: 200px;',
2388 'default': '',
2389 onShow: function() {
2390 NS.textNode['GrammTab'] = this;
2391 },
2392 onHide: function() {
2393 this.reset();
2394 }
2395 },
2396 {
2397 type: 'html',
2398 id: 'html_text',
2399 html: "<div style='min-height: 17px; line-height: 17px; padding: 5px; text-align: left;background: #F1F1F1;color: #595959; white-space: normal!important;'></div>",
2400 onShow: function(e) {
2401 NS.textNodeInfo['GrammTab'] = this;
2402 }
2403 },
2404 {
2405 type: 'html',
2406 id: 'radio',
2407 html: "",
2408 onShow: function() {
2409 NS.grammerSuggest = this;
2410 }
2411 }
2412 ]
2413 },
2414 {
2415 type: 'vbox',
2416 children: [
2417 {
2418 type: 'button',
2419 id: 'ChangeTo_button',
2420 label: 'Change to',
2421 title: 'Change to',
2422 style: 'width: 133px; float: right;',
2423 onLoad: function() {
2424 this.getElement().setAttribute("title-cmd", 'ChangeTo');
2425 },
2426 onClick: handlerButtons
2427 },
2428 {
2429 type: 'button',
2430 id: 'IgnoreWord',
2431 label: 'Ignore word',
2432 title: 'Ignore word',
2433 style: 'width: 133px; float: right;',
2434 onLoad: function() {
2435 this.getElement().setAttribute("title-cmd", this.id);
2436 },
2437 onClick: handlerButtons
2438 },
2439 {
2440 type: 'button',
2441 id: 'IgnoreAllWords',
2442 label: 'Ignore Problem',
2443 title: 'Ignore Problem',
2444 style: 'width: 133px; float: right;',
2445 onLoad: function() {
2446 this.getElement().setAttribute("title-cmd", this.id);
2447 },
2448 onClick: handlerButtons
2449 },
2450 {
2451 type: 'button',
2452 id: 'FinishChecking_button',
2453 label: NS.LocalizationButton['FinishChecking_button'].text,
2454 title: 'Finish Checking',
2455 style: 'width: 133px; float: right; margin-top: 9px;',
2456 onLoad: function() {
2457 this.getElement().setAttribute("title-cmd", 'FinishChecking');
2458 },
2459 onClick: handlerButtons
2460 }
2461 ]
2462 }
2463 ]
2464 }
2465 ]
2466 },
2467 {
2468 type: 'hbox',
2469 id: 'BlockFinishChecking',
2470 style: 'width:560px; margin: 0 auto;',
2471 widths: ['70%', '30%'],
2472 onShow: function() {
2473 this.getElement().setStyles({
2474 display: 'block',
2475 position: 'absolute',
2476 left: '-9999px'
2477 });
2478 },
2479 onHide: showCurrentTabs,
2480 children: [
2481 {
2482 type: 'hbox',
2483 id: 'leftCol',
2484 align: 'left',
2485 width: '70%',
2486 children: [
2487 {
2488 type: 'vbox',
2489 id: 'rightCol1',
2490 children: [
2491 {
2492 type: 'html',
2493 id: 'logo',
2494 html: '<img width="99" height="68" border="0" src="" title="WebSpellChecker.net" alt="WebSpellChecker.net" style="display: inline-block;">',
2495 setup: function() {
2496 this.getElement().$.src = NS.logotype;
2497 this.getElement().getParent().setStyles({
2498 "text-align": "center"
2499 });
2500 }
2501 }
2502 ]
2503 }
2504 ]
2505 },
2506 {
2507 type: 'hbox',
2508 id: 'rightCol',
2509 align: 'right',
2510 width: '30%',
2511 children: [
2512 {
2513 type: 'vbox',
2514 id: 'rightCol_col__left',
2515 children: [
2516 {
2517 type: 'button',
2518 id: 'FinishChecking_button_block',
2519 label: NS.LocalizationButton['FinishChecking_button_block'].text,
2520 title: 'Finish Checking',
2521 style: 'width: 100%;',
2522 onLoad: function() {
2523 this.getElement().setAttribute("title-cmd", 'FinishChecking');
2524 },
2525 onClick: handlerButtons
2526 }
2527 ]
2528 }
2529 ]
2530 }
2531 ]
2532 }
2533 ]
2534 },
2535 {
2536 id: 'Thesaurus',
2537 label: 'Thesaurus',
2538 accessKey: 'T',
2539 elements: [
2540 {
2541 type: 'html',
2542 id: 'banner',
2543 label: 'banner',
2544 style: '', //TODO
2545 html: '<div></div>'
2546 },
2547 {
2548 type: 'html',
2549 id: 'Content',
2550 label: 'spellContent',
2551 html: '',
2552 setup: function() {
2553 var tabId = NS.iframeNumber + '_' + NS.dialog._.currentTabId;
2554 var iframe = document.getElementById(tabId);
2555 NS.targetFromFrame[tabId] = iframe.contentWindow;
2556 }
2557 },
2558 {
2559 type: 'vbox',
2560 id: 'bottomGroup',
2561 style: 'width:560px; margin: -10px auto; overflow: hidden;',
2562 children: [
2563 {
2564 type: 'hbox',
2565 widths: ['75%', '25%'],
2566 children: [
2567 {
2568 type: 'vbox',
2569 children: [
2570 {
2571 type: 'hbox',
2572 widths: ['65%', '35%'],
2573 children: [
2574 {
2575 type: 'text',
2576 id: 'ChangeTo_label',
2577 label: NS.LocalizationLabel['ChangeTo_label'].text + ':',
2578 labelLayout: 'horizontal',
2579 inputStyle: 'width: 160px;',
2580 labelStyle: 'font: 12px/25px arial, sans-serif;',
2581 'default': '',
2582 onShow: function(e) {
2583 NS.textNode['Thesaurus'] = this;
2584 NS.LocalizationLabel['ChangeTo_label'].instance = this;
2585 },
2586 onHide: function() {
2587 this.reset();
2588 }
2589 },
2590 {
2591 type: 'button',
2592 id: 'ChangeTo_button',
2593 label: NS.LocalizationButton['ChangeTo_button'].text,
2594 title: 'Change to',
2595 style: 'width: 121px; margin-top: 1px;',
2596 onLoad: function() {
2597 this.getElement().setAttribute("title-cmd", 'ChangeTo');
2598 NS.LocalizationButton['ChangeTo_button'].instance = this;
2599 },
2600 onClick: handlerButtons
2601 }
2602 ]
2603 },
2604 {
2605 type: 'hbox',
2606 children: [
2607 {
2608 type: 'select',
2609 id: 'Categories',
2610 label: NS.LocalizationLabel['Categories'].text + ':',
2611 labelStyle: 'font: 12px/25px arial, sans-serif;',
2612 size: '5',
2613 inputStyle: 'width: 180px; height: auto;',
2614 items: [],
2615 onShow: function() {
2616 NS.selectNode['Categories'] = this;
2617 NS.LocalizationLabel['Categories'].instance = this;
2618 },
2619 onChange: function() {
2620 NS.buildOptionSynonyms(this.getValue());
2621 }
2622 },
2623 {
2624 type: 'select',
2625 id: 'Synonyms',
2626 label: NS.LocalizationLabel['Synonyms'].text + ':',
2627 labelStyle: 'font: 12px/25px arial, sans-serif;',
2628 size: '5',
2629 inputStyle: 'width: 180px; height: auto;',
2630 items: [],
2631 onShow: function() {
2632 NS.selectNode['Synonyms'] = this;
2633 NS.textNode['Thesaurus'].setValue(this.getValue());
2634 NS.LocalizationLabel['Synonyms'].instance = this;
2635 },
2636 onChange: function(e) {
2637 NS.textNode['Thesaurus'].setValue(this.getValue());
2638 }
2639 }
2640 ]
2641 }
2642 ]
2643 },
2644 {
2645 type: 'vbox',
2646 width: '120px',
2647 style: "margin-top:46px;",
2648 children: [
2649 {
2650 type: 'html',
2651 id: 'logotype',
2652 label: 'WebSpellChecker.net',
2653 html: '<img width="99" height="68" border="0" src="" title="WebSpellChecker.net" alt="WebSpellChecker.net" style="display: inline-block;">',
2654 setup: function() {
2655 this.getElement().$.src = NS.logotype;
2656 this.getElement().getParent().setStyles({
2657 "text-align": "center"
2658 });
2659 }
2660 },
2661 {
2662 type: 'button',
2663 id: 'FinishChecking_button',
2664 label: NS.LocalizationButton['FinishChecking_button'].text,
2665 title: 'Finish Checking',
2666 style: 'width: 100%; float: right; margin-top: 9px;',
2667 onLoad: function() {
2668 this.getElement().setAttribute("title-cmd", 'FinishChecking');
2669 },
2670 onClick: handlerButtons
2671 }
2672 ]
2673 }
2674 ]
2675 }
2676 ]
2677 },
2678 {
2679 type: 'hbox',
2680 id: 'BlockFinishChecking',
2681 style: 'width:560px; margin: 0 auto;',
2682 widths: ['70%', '30%'],
2683 onShow: function() {
2684 this.getElement().setStyles({
2685 display: 'block',
2686 position: 'absolute',
2687 left: '-9999px'
2688 });
2689 },
2690 children: [
2691 {
2692 type: 'hbox',
2693 id: 'leftCol',
2694 align: 'left',
2695 width: '70%',
2696 children: [
2697 {
2698 type: 'vbox',
2699 id: 'rightCol1',
2700 children: [
2701 {
2702 type: 'html',
2703 id: 'logo',
2704 html: '<img width="99" height="68" border="0" src="" title="WebSpellChecker.net" alt="WebSpellChecker.net" style="display: inline-block;">',
2705 setup: function() {
2706 this.getElement().$.src = NS.logotype;
2707 this.getElement().getParent().setStyles({
2708 "text-align": "center"
2709 });
2710 }
2711 }
2712 ]
2713 }
2714 ]
2715 },
2716 {
2717 type: 'hbox',
2718 id: 'rightCol',
2719 align: 'right',
2720 width: '30%',
2721 children: [
2722 {
2723 type: 'vbox',
2724 id: 'rightCol_col__left',
2725 children: [
2726 {
2727 type: 'button',
2728 id: 'FinishChecking_button_block',
2729 label: NS.LocalizationButton['FinishChecking_button_block'].text,
2730 title: 'Finish Checking',
2731 style: 'width: 100%;',
2732 onLoad: function() {
2733 this.getElement().setAttribute("title-cmd", 'FinishChecking');
2734 },
2735 onClick: handlerButtons
2736 }
2737 ]
2738 }
2739 ]
2740 }
2741 ]
2742 }
2743 ]
2744 }
2745 ]
2746 };
2747 });
2748
2749 var activeElement = null;
2750
2751 // Options dialog
2752 CKEDITOR.dialog.add('options', function(editor) {
2753 var dialog = null;
2754 var linkOnCheckbox = {};
2755 var checkboxState = {};
2756 var ospString = null;
2757 var OptionsTextError = null;
2758 var cmd = null;
2759
2760 var set_osp = [];
2761 var dictionaryState = {
2762 'udn': appTools.cookie.get('udn'),
2763 'osp': appTools.cookie.get('osp')
2764 };
2765
2766 var setHandlerOptions = function() {
2767 var osp = appTools.cookie.get('osp'),
2768 strToArr = osp.split("");
2769
2770 checkboxState['IgnoreAllCapsWords'] = strToArr[0];
2771 checkboxState['IgnoreWordsNumbers'] = strToArr[1];
2772 checkboxState['IgnoreMixedCaseWords'] = strToArr[2];
2773 checkboxState['IgnoreDomainNames'] = strToArr[3];
2774 };
2775
2776 var sendDicOptions = function(event) {
2777 event = event || window.event;
2778 cmd = this.getElement().getAttribute("title-cmd");
2779 var osp = [];
2780
2781 osp[0] = checkboxState['IgnoreAllCapsWords'];
2782 osp[1] = checkboxState['IgnoreWordsNumbers'];
2783 osp[2] = checkboxState['IgnoreMixedCaseWords'];
2784 osp[3] = checkboxState['IgnoreDomainNames'];
2785
2786 osp = osp.toString().replace(/,/g, "");
2787
2788
2789 appTools.cookie.set('osp', osp);
2790 appTools.cookie.set('udnCmd', cmd ? cmd : 'ignore');
2791 if (cmd == "delete") {
2792
2793 appTools.postMessage.send({
2794 'id': 'options_dic_send'
2795 });
2796 } else {
2797 var udn = '';
2798 if(nameNode.getValue() !== ''){
2799 udn = nameNode.getValue();
2800 }
2801 appTools.cookie.set('udn', udn);
2802 appTools.postMessage.send({
2803 'id': 'options_dic_send'
2804 });
2805 }
2806
2807 };
2808
2809
2810 var sendAllOptions = function() {
2811 var osp = [];
2812
2813 osp[0] = checkboxState['IgnoreAllCapsWords'];
2814 osp[1] = checkboxState['IgnoreWordsNumbers'];
2815 osp[2] = checkboxState['IgnoreMixedCaseWords'];
2816 osp[3] = checkboxState['IgnoreDomainNames'];
2817
2818 osp = osp.toString().replace(/,/g, "");
2819
2820 appTools.cookie.set('osp', osp);
2821
2822 appTools.postMessage.send({
2823 'id': 'options_checkbox_send'
2824 });
2825
2826
2827 };
2828
2829 var cameOptions = function() {
2830 OptionsTextError.getElement().setHtml(NS.LocalizationComing['error']);
2831 OptionsTextError.getElement().show();
2832 };
2833
2834 return {
2835 title: NS.LocalizationComing['Options'],
2836 minWidth: 430,
2837 minHeight: 130,
2838 resizable: CKEDITOR.DIALOG_RESIZE_NONE,
2839 contents: [
2840 {
2841 id: 'OptionsTab',
2842 label: 'Options',
2843 accessKey: 'O',
2844 elements: [
2845 {
2846 type: 'hbox',
2847 id: 'options_error',
2848 children: [
2849 {
2850 type: 'html',
2851 style: "display: block;text-align: center;white-space: normal!important; font-size: 12px;color:red",
2852 html: '<div></div>',
2853 onShow: function() {
2854 OptionsTextError = this;
2855 }
2856 }
2857 ]
2858 },
2859 {
2860 type: 'vbox',
2861 id: 'Options_content',
2862 children: [
2863 {
2864 type: 'hbox',
2865 id: 'Options_manager',
2866 widths: ['52%', '48%'],
2867 children: [
2868 {
2869 type: 'fieldset',
2870 label: 'Spell Checking Options',
2871 style: 'border: none;margin-top: 13px;padding: 10px 0 10px 10px',
2872 onShow: function() {
2873 this.getInputElement().$.children[0].innerHTML = NS.LocalizationComing['SpellCheckingOptions'];
2874 },
2875 children: [
2876 {
2877 type: 'vbox',
2878 id: 'Options_checkbox',
2879 children: [
2880 {
2881 type: 'checkbox',
2882 id: 'IgnoreAllCapsWords',
2883 label: 'Ignore All-Caps Words',
2884 labelStyle: 'margin-left: 5px; font: 12px/16px arial, sans-serif;display: inline-block;white-space: normal;',
2885 style: "float:left; min-height: 16px;",
2886 'default': '',
2887 onClick: function() {
2888 checkboxState[this.id] = (!this.getValue()) ? 0 : 1;
2889 }
2890 },
2891 {
2892 type: 'checkbox',
2893 id: 'IgnoreWordsNumbers',
2894 label: 'Ignore Words with Numbers',
2895 labelStyle: 'margin-left: 5px; font: 12px/16px arial, sans-serif;display: inline-block;white-space: normal;',
2896 style: "float:left; min-height: 16px;",
2897 'default': '',
2898 onClick: function() {
2899 checkboxState[this.id] = (!this.getValue()) ? 0 : 1;
2900 }
2901 },
2902 {
2903 type: 'checkbox',
2904 id: 'IgnoreMixedCaseWords',
2905 label: 'Ignore Mixed-Case Words',
2906 labelStyle: 'margin-left: 5px; font: 12px/16px arial, sans-serif;display: inline-block;white-space: normal;',
2907 style: "float:left; min-height: 16px;",
2908 'default': '',
2909 onClick: function() {
2910 checkboxState[this.id] = (!this.getValue()) ? 0 : 1;
2911 }
2912 },
2913 {
2914 type: 'checkbox',
2915 id: 'IgnoreDomainNames',
2916 label: 'Ignore Domain Names',
2917 labelStyle: 'margin-left: 5px; font: 12px/16px arial, sans-serif;display: inline-block;white-space: normal;',
2918 style: "float:left; min-height: 16px;",
2919 'default': '',
2920 onClick: function() {
2921 checkboxState[this.id] = (!this.getValue()) ? 0 : 1;
2922 }
2923 }
2924 ]
2925 }
2926 ]
2927 },
2928 {
2929 type: 'vbox',
2930 id: 'Options_DictionaryName',
2931 children: [
2932 {
2933 type: 'text',
2934 id: 'DictionaryName',
2935 style: 'margin-bottom: 10px',
2936 label: 'Dictionary Name:',
2937 labelLayout: 'vertical',
2938 labelStyle: 'font: 12px/25px arial, sans-serif;',
2939 'default': '',
2940 onLoad: function() {
2941 nameNode = this;
2942 var udn = NS.userDictionaryName ? NS.userDictionaryName : appTools.cookie.get('udn') && undefined ? ' ' : this.getValue();
2943 this.setValue(udn);
2944 },
2945 onShow: function() {
2946 nameNode = this;
2947 var udn = !appTools.cookie.get('udn') ? this.getValue() : appTools.cookie.get('udn');
2948 this.setValue(udn);
2949 this.setLabel(NS.LocalizationComing['DictionaryName']);
2950 },
2951 onHide: function() {
2952 this.reset();
2953 }
2954 },
2955 {
2956 type: 'hbox',
2957 id: 'Options_buttons',
2958 children: [
2959 {
2960 type: 'vbox',
2961 id: 'Options_leftCol_col',
2962 widths: ['50%', '50%'],
2963 children: [
2964 {
2965 type: 'button',
2966 id: 'create',
2967 label: 'Create',
2968 title: 'Create',
2969 style: 'width: 100%;',
2970 onLoad: function() {
2971 this.getElement().setAttribute("title-cmd", this.id);
2972 },
2973 onShow: function() {
2974 var el = this.getElement().getFirst() || this.getElement();
2975
2976 el.setText(NS.LocalizationComing['Create']);
2977 },
2978 onClick: sendDicOptions
2979 },
2980 {
2981 type: 'button',
2982 id: 'restore',
2983 label: 'Restore',
2984 title: 'Restore',
2985 style: 'width: 100%;',
2986 onLoad: function() {
2987 this.getElement().setAttribute("title-cmd", this.id);
2988 },
2989 onShow: function() {
2990 var el = this.getElement().getFirst() || this.getElement();
2991
2992 el.setText(NS.LocalizationComing['Restore']);
2993 },
2994 onClick: sendDicOptions
2995 }
2996 ]
2997 },
2998 {
2999 type: 'vbox',
3000 id: 'Options_rightCol_col',
3001 widths: ['50%', '50%'],
3002 children: [
3003 {
3004 type: 'button',
3005 id: 'rename',
3006 label: 'Rename',
3007 title: 'Rename',
3008 style: 'width: 100%;',
3009 onLoad: function() {
3010 this.getElement().setAttribute("title-cmd", this.id);
3011 },
3012 onShow: function() {
3013 var el = this.getElement().getFirst() || this.getElement();
3014
3015 el.setText(NS.LocalizationComing['Rename']);
3016 },
3017 onClick: sendDicOptions
3018 },
3019 {
3020 type: 'button',
3021 id: 'delete',
3022 label: 'Remove',
3023 title: 'Remove',
3024 style: 'width: 100%;',
3025 onLoad: function() {
3026 this.getElement().setAttribute("title-cmd", this.id);
3027 },
3028 onShow: function() {
3029 var el = this.getElement().getFirst() || this.getElement();
3030
3031 el.setText(NS.LocalizationComing['Remove']);
3032 },
3033 onClick: sendDicOptions
3034 }
3035 ]
3036 }
3037 ]
3038 }
3039 ]
3040 }
3041 ]
3042 },
3043 {
3044 type: 'hbox',
3045 id: 'Options_text',
3046 children: [
3047 {
3048 type: 'html',
3049 style: "text-align: justify;margin-top: 15px;white-space: normal!important; font-size: 12px;color:#777;",
3050 html: "<div>" + NS.LocalizationComing['OptionsTextIntro'] + "</div>",
3051 onShow: function() {
3052 this.getElement().setText(NS.LocalizationComing['OptionsTextIntro']);
3053 }
3054 }
3055 ]
3056 }
3057 ]
3058 }
3059 ]
3060 }
3061 ],
3062 buttons: [CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton],
3063 onOk: function() {
3064 sendAllOptions();
3065 OptionsTextError.getElement().hide();
3066 OptionsTextError.getElement().setHtml(' ');
3067 },
3068 onLoad: function() {
3069 dialog = this;
3070 // appTools.postMessage.init(cameOptions);
3071
3072 linkOnCheckbox['IgnoreAllCapsWords'] = dialog.getContentElement('OptionsTab', 'IgnoreAllCapsWords');
3073 linkOnCheckbox['IgnoreWordsNumbers'] = dialog.getContentElement('OptionsTab', 'IgnoreWordsNumbers');
3074 linkOnCheckbox['IgnoreMixedCaseWords'] = dialog.getContentElement('OptionsTab', 'IgnoreMixedCaseWords');
3075 linkOnCheckbox['IgnoreDomainNames'] = dialog.getContentElement('OptionsTab', 'IgnoreDomainNames');
3076
3077 },
3078 onShow: function() {
3079 appTools.postMessage.init(cameOptions);
3080 setHandlerOptions();
3081
3082 (!parseInt(checkboxState['IgnoreAllCapsWords'], 10)) ? linkOnCheckbox['IgnoreAllCapsWords'].setValue('', false) : linkOnCheckbox['IgnoreAllCapsWords'].setValue('checked', false);
3083 (!parseInt(checkboxState['IgnoreWordsNumbers'], 10)) ? linkOnCheckbox['IgnoreWordsNumbers'].setValue('', false) : linkOnCheckbox['IgnoreWordsNumbers'].setValue('checked', false);
3084 (!parseInt(checkboxState['IgnoreMixedCaseWords'], 10)) ? linkOnCheckbox['IgnoreMixedCaseWords'].setValue('', false) : linkOnCheckbox['IgnoreMixedCaseWords'].setValue('checked', false);
3085 (!parseInt(checkboxState['IgnoreDomainNames'], 10)) ? linkOnCheckbox['IgnoreDomainNames'].setValue('', false) : linkOnCheckbox['IgnoreDomainNames'].setValue('checked', false);
3086
3087 checkboxState['IgnoreAllCapsWords'] = (!linkOnCheckbox['IgnoreAllCapsWords'].getValue()) ? 0 : 1;
3088 checkboxState['IgnoreWordsNumbers'] = (!linkOnCheckbox['IgnoreWordsNumbers'].getValue()) ? 0 : 1;
3089 checkboxState['IgnoreMixedCaseWords'] = (!linkOnCheckbox['IgnoreMixedCaseWords'].getValue()) ? 0 : 1;
3090 checkboxState['IgnoreDomainNames'] = (!linkOnCheckbox['IgnoreDomainNames'].getValue()) ? 0 : 1;
3091
3092 linkOnCheckbox['IgnoreAllCapsWords'].getElement().$.lastChild.innerHTML = NS.LocalizationComing['IgnoreAllCapsWords'];
3093 linkOnCheckbox['IgnoreWordsNumbers'].getElement().$.lastChild.innerHTML = NS.LocalizationComing['IgnoreWordsWithNumbers'];
3094 linkOnCheckbox['IgnoreMixedCaseWords'].getElement().$.lastChild.innerHTML = NS.LocalizationComing['IgnoreMixedCaseWords'];
3095 linkOnCheckbox['IgnoreDomainNames'].getElement().$.lastChild.innerHTML = NS.LocalizationComing['IgnoreDomainNames'];
3096 },
3097 onHide: function() {
3098 appTools.postMessage.unbindHandler(cameOptions);
3099 if(activeElement) {
3100 try {
3101 activeElement.focus();
3102 } catch(e) {}
3103 }
3104 }
3105 };
3106 });
3107
3108 // Expand the spell-check frame when dialog resized. (#6829)
3109 CKEDITOR.dialog.on( 'resize', function( evt ) {
3110 var data = evt.data,
3111 dialog = data.dialog,
3112 currentTabId = dialog._.currentTabId,
3113 tabID = NS.iframeNumber + '_' + currentTabId,
3114 iframe = CKEDITOR.document.getById(tabID);
3115
3116 if ( dialog._.name == 'checkspell' ) {
3117 if (NS.bnr) {
3118 iframe && iframe.setSize( 'height', data.height - '310' );
3119 } else {
3120 iframe && iframe.setSize( 'height', data.height - '220' );
3121 }
3122
3123 // add flag that indicate whether dialog has been resized by user
3124 if(dialog._.fromResizeEvent && !dialog._.resized) {
3125 dialog._.resized = true;
3126 }
3127 dialog._.fromResizeEvent = true;
3128 }
3129 });
3130
3131 CKEDITOR.on('dialogDefinition', function(dialogDefinitionEvent) {
3132
3133 if(dialogDefinitionEvent.data.name === 'checkspell') {
3134 var dialogDefinition = dialogDefinitionEvent.data.definition;
3135
3136 NS.onLoadOverlay = new overlayBlock({
3137 opacity: "1",
3138 background: "#fff",
3139 target: dialogDefinition.dialog.parts.tabs.getParent().$
3140 });
3141
3142 NS.onLoadOverlay.setEnable();
3143
3144 dialogDefinition.dialog.on('cancel', function(cancelEvent) {
3145 dialogDefinition.dialog.getParentEditor().config.wsc_onClose.call(this.document.getWindow().getFrame());
3146 NS.div_overlay.setDisable();
3147 NS.onLoadOverlay.setDisable();
3148 return false;
3149 }, this, null, -1);
3150 }
3151 });
3152 })();