+/*\r
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
+For licensing, see LICENSE.html or http://ckeditor.com/license\r
+*/\r
+\r
+CKEDITOR.dialog.add( 'checkspell', function( editor )\r
+{\r
+ var number = CKEDITOR.tools.getNextNumber(),\r
+ iframeId = 'cke_frame_' + number,\r
+ textareaId = 'cke_data_' + number,\r
+ errorBoxId = 'cke_error_' + number,\r
+ interval,\r
+ protocol = document.location.protocol || 'http:',\r
+ errorMsg = editor.lang.spellCheck.notAvailable;\r
+\r
+ var pasteArea = '<textarea'+\r
+ ' style="display: none"' +\r
+ ' id="' + textareaId + '"' +\r
+ ' rows="10"' +\r
+ ' cols="40">' +\r
+ ' </textarea><div' +\r
+ ' id="' + errorBoxId + '"' +\r
+ ' style="display:none;color:red;font-size:16px;font-weight:bold;padding-top:160px;text-align:center;z-index:11;">' +\r
+ '</div><iframe' +\r
+ ' src=""' +\r
+ ' style="width:485px;background-color:#f1f1e3;height:380px"' +\r
+ ' frameborder="0"' +\r
+ ' name="' + iframeId + '"' +\r
+ ' id="' + iframeId + '"' +\r
+ ' allowtransparency="1">' +\r
+ '</iframe>';\r
+\r
+ var wscCoreUrl = editor.config.wsc_customLoaderScript || ( protocol +\r
+ '//loader.spellchecker.net/sproxy_fck/sproxy.php'\r
+ + '?plugin=fck2'\r
+ + '&customerid=' + editor.config.wsc_customerId\r
+ + '&cmd=script&doc=wsc&schema=22'\r
+ );\r
+\r
+ if ( editor.config.wsc_customLoaderScript )\r
+ errorMsg += '<p style="color:#000;font-size:11px;font-weight: normal;text-align:center;padding-top:10px">' +\r
+ editor.lang.spellCheck.errorLoading.replace( /%s/g, editor.config.wsc_customLoaderScript ) + '</p>';\r
+\r
+ function burnSpelling( dialog, errorMsg )\r
+ {\r
+ var i = 0;\r
+ return function ()\r
+ {\r
+ if ( typeof( window.doSpell ) == 'function' )\r
+ {\r
+ //Call from window.setInteval expected at once.\r
+ if ( typeof( interval ) != 'undefined' )\r
+ window.clearInterval( interval );\r
+\r
+ initAndSpell( dialog );\r
+ }\r
+ else if ( i++ == 180 ) // Timeout: 180 * 250ms = 45s.\r
+ window._cancelOnError( errorMsg );\r
+ };\r
+ }\r
+\r
+ window._cancelOnError = function( m )\r
+ {\r
+ if ( typeof( window.WSC_Error ) == 'undefined' )\r
+ {\r
+ CKEDITOR.document.getById( iframeId ).setStyle( 'display', 'none' );\r
+ var errorBox = CKEDITOR.document.getById( errorBoxId );\r
+ errorBox.setStyle( 'display', 'block' );\r
+ errorBox.setHtml( m || editor.lang.spellCheck.notAvailable );\r
+ }\r
+ };\r
+\r
+ function initAndSpell( dialog )\r
+ {\r
+ var LangComparer = new window._SP_FCK_LangCompare(), // Language abbr standarts comparer.\r
+ pluginPath = CKEDITOR.getUrl( editor.plugins.wsc.path + 'dialogs/' ), // Service paths corecting/preparing.\r
+ framesetPath = pluginPath + 'tmpFrameset.html';\r
+\r
+ // global var is used in FCK specific core\r
+ // change on equal var used in fckplugin.js\r
+ window.gFCKPluginName = 'wsc';\r
+\r
+ LangComparer.setDefaulLangCode( editor.config.defaultLanguage );\r
+\r
+ window.doSpell({\r
+ ctrl : textareaId,\r
+ lang : LangComparer.getSPLangCode( editor.langCode ),\r
+ winType : iframeId, // If not defined app will run on winpopup.\r
+\r
+ // Callback binding section.\r
+ onCancel : function()\r
+ {\r
+ dialog.hide();\r
+ },\r
+ onFinish : function( dT )\r
+ {\r
+ editor.focus();\r
+ dialog.getParentEditor().setData( dT.value );\r
+ dialog.hide();\r
+ },\r
+\r
+ // Some manipulations with client static pages.\r
+ staticFrame : framesetPath,\r
+ framesetPath : framesetPath,\r
+ iframePath : pluginPath + 'ciframe.html',\r
+\r
+ // Styles defining.\r
+ schemaURI : pluginPath + 'wsc.css'\r
+ });\r
+\r
+ // Hide user message console (if application was loaded more then after timeout).\r
+ CKEDITOR.document.getById( errorBoxId ).setStyle( 'display', 'none' );\r
+ CKEDITOR.document.getById( iframeId ).setStyle( 'display', 'block' );\r
+ }\r
+\r
+ return {\r
+ title : editor.lang.spellCheck.title,\r
+ minWidth : 485,\r
+ minHeight : 380,\r
+ buttons : [ CKEDITOR.dialog.cancelButton ],\r
+ onShow : function()\r
+ {\r
+ var contentArea = this.getContentElement( 'general', 'content' ).getElement();\r
+ contentArea.setHtml( pasteArea );\r
+\r
+ if ( typeof( window.doSpell ) != 'function' )\r
+ {\r
+ // Load script.\r
+ CKEDITOR.document.getHead().append(\r
+ CKEDITOR.document.createElement( 'script',\r
+ {\r
+ attributes :\r
+ {\r
+ type : 'text/javascript',\r
+ src : wscCoreUrl\r
+ }\r
+ })\r
+ );\r
+ }\r
+\r
+ var sData = editor.getData(); // Get the data to be checked.\r
+ CKEDITOR.document.getById( textareaId ).setValue( sData );\r
+\r
+ interval = window.setInterval( burnSpelling( this, errorMsg ), 250 );\r
+ },\r
+ onHide : function()\r
+ {\r
+ window.ooo = undefined;\r
+ window.int_framsetLoaded = undefined;\r
+ window.framesetLoaded = undefined;\r
+ window.is_window_opened = false;\r
+ },\r
+ contents : [\r
+ {\r
+ id : 'general',\r
+ label : editor.lang.spellCheck.title,\r
+ padding : 0,\r
+ elements : [\r
+ {\r
+ type : 'html',\r
+ id : 'content',\r
+ style : 'width:485;height:380px',\r
+ html : '<div></div>'\r
+ }\r
+ ]\r
+ }\r
+ ]\r
+ };\r
+});\r