2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
6 CKEDITOR.dialog.add( 'checkspell', function( editor )
\r
8 var number = CKEDITOR.tools.getNextNumber(),
\r
9 iframeId = 'cke_frame_' + number,
\r
10 textareaId = 'cke_data_' + number,
\r
11 errorBoxId = 'cke_error_' + number,
\r
13 protocol = document.location.protocol || 'http:',
\r
14 errorMsg = editor.lang.spellCheck.notAvailable;
\r
16 var pasteArea = '<textarea'+
\r
17 ' style="display: none"' +
\r
18 ' id="' + textareaId + '"' +
\r
21 ' </textarea><div' +
\r
22 ' id="' + errorBoxId + '"' +
\r
23 ' style="display:none;color:red;font-size:16px;font-weight:bold;padding-top:160px;text-align:center;z-index:11;">' +
\r
26 ' style="width:100%;background-color:#f1f1e3;"' +
\r
27 ' frameborder="0"' +
\r
28 ' name="' + iframeId + '"' +
\r
29 ' id="' + iframeId + '"' +
\r
30 ' allowtransparency="1">' +
\r
33 var wscCoreUrl = editor.config.wsc_customLoaderScript || ( protocol +
\r
34 '//loader.spellchecker.net/sproxy_fck/sproxy.php'
\r
36 + '&customerid=' + editor.config.wsc_customerId
\r
37 + '&cmd=script&doc=wsc&schema=22'
\r
40 if ( editor.config.wsc_customLoaderScript )
\r
41 errorMsg += '<p style="color:#000;font-size:11px;font-weight: normal;text-align:center;padding-top:10px">' +
\r
42 editor.lang.spellCheck.errorLoading.replace( /%s/g, editor.config.wsc_customLoaderScript ) + '</p>';
\r
44 function burnSpelling( dialog, errorMsg )
\r
49 if ( typeof( window.doSpell ) == 'function' )
\r
51 //Call from window.setInteval expected at once.
\r
52 if ( typeof( interval ) != 'undefined' )
\r
53 window.clearInterval( interval );
\r
55 initAndSpell( dialog );
\r
57 else if ( i++ == 180 ) // Timeout: 180 * 250ms = 45s.
\r
58 window._cancelOnError( errorMsg );
\r
62 window._cancelOnError = function( m )
\r
64 if ( typeof( window.WSC_Error ) == 'undefined' )
\r
66 CKEDITOR.document.getById( iframeId ).setStyle( 'display', 'none' );
\r
67 var errorBox = CKEDITOR.document.getById( errorBoxId );
\r
68 errorBox.setStyle( 'display', 'block' );
\r
69 errorBox.setHtml( m || editor.lang.spellCheck.notAvailable );
\r
73 function initAndSpell( dialog )
\r
75 var LangComparer = new window._SP_FCK_LangCompare(), // Language abbr standarts comparer.
\r
76 pluginPath = CKEDITOR.getUrl( editor.plugins.wsc.path + 'dialogs/' ), // Service paths corecting/preparing.
\r
77 framesetPath = pluginPath + 'tmpFrameset.html';
\r
79 // global var is used in FCK specific core
\r
80 // change on equal var used in fckplugin.js
\r
81 window.gFCKPluginName = 'wsc';
\r
83 LangComparer.setDefaulLangCode( editor.config.defaultLanguage );
\r
88 lang : editor.config.wsc_lang || LangComparer.getSPLangCode(editor.langCode ),
\r
89 intLang: editor.config.wsc_uiLang || LangComparer.getSPLangCode(editor.langCode ),
\r
90 winType : iframeId, // If not defined app will run on winpopup.
\r
92 // Callback binding section.
\r
93 onCancel : function()
\r
97 onFinish : function( dT )
\r
100 dialog.getParentEditor().setData( dT.value );
\r
104 // Some manipulations with client static pages.
\r
105 staticFrame : framesetPath,
\r
106 framesetPath : framesetPath,
\r
107 iframePath : pluginPath + 'ciframe.html',
\r
109 // Styles defining.
\r
110 schemaURI : pluginPath + 'wsc.css',
\r
112 userDictionaryName: editor.config.wsc_userDictionaryName,
\r
113 customDictionaryName: editor.config.wsc_customDictionaryIds && editor.config.wsc_customDictionaryIds.split(","),
\r
114 domainName: editor.config.wsc_domainName
\r
118 // Hide user message console (if application was loaded more then after timeout).
\r
119 CKEDITOR.document.getById( errorBoxId ).setStyle( 'display', 'none' );
\r
120 CKEDITOR.document.getById( iframeId ).setStyle( 'display', 'block' );
\r
124 title : editor.config.wsc_dialogTitle || editor.lang.spellCheck.title,
\r
127 buttons : [ CKEDITOR.dialog.cancelButton ],
\r
128 onShow : function()
\r
130 var contentArea = this.getContentElement( 'general', 'content' ).getElement();
\r
131 contentArea.setHtml( pasteArea );
\r
132 contentArea.getChild( 2 ).setStyle( 'height', this._.contentSize.height + 'px' );
\r
134 if ( typeof( window.doSpell ) != 'function' )
\r
137 CKEDITOR.document.getHead().append(
\r
138 CKEDITOR.document.createElement( 'script',
\r
142 type : 'text/javascript',
\r
149 var sData = editor.getData(); // Get the data to be checked.
\r
150 CKEDITOR.document.getById( textareaId ).setValue( sData );
\r
152 interval = window.setInterval( burnSpelling( this, errorMsg ), 250 );
\r
154 onHide : function()
\r
156 window.ooo = undefined;
\r
157 window.int_framsetLoaded = undefined;
\r
158 window.framesetLoaded = undefined;
\r
159 window.is_window_opened = false;
\r
164 label : editor.config.wsc_dialogTitle || editor.lang.spellCheck.title,
\r
178 // Expand the spell-check frame when dialog resized. (#6829)
\r
179 CKEDITOR.dialog.on( 'resize', function( evt )
\r
181 var data = evt.data,
\r
182 dialog = data.dialog;
\r
184 if ( dialog._.name == 'checkspell' )
\r
186 var content = dialog.getContentElement( 'general', 'content' ).getElement(),
\r
187 iframe = content && content.getChild( 2 );
\r
189 iframe && iframe.setSize( 'height', data.height );
\r
190 iframe && iframe.setSize( 'width', data.width );
\r