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