source: sandbox/3.0/phpgwapi/js/ckeditor/_source/plugins/wsc/dialogs/wsc.js @ 2862

Revision 2862, 5.3 KB checked in by rodsouza, 14 years ago (diff)

Ticket #663 - Atualizando e centralizando o CKEditor (v. 3.2.1)

Line 
1/*
2Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
3For licensing, see LICENSE.html or http://ckeditor.com/license
4*/
5
6CKEDITOR.dialog.add( 'checkspell', function( editor )
7{
8        var number = CKEDITOR.tools.getNextNumber(),
9                iframeId = 'cke_frame_' + number,
10                textareaId = 'cke_data_' + number,
11                errorBoxId = 'cke_error_' + number,
12                interval,
13                protocol = document.location.protocol || 'http:',
14                errorMsg = editor.lang.spellCheck.notAvailable;
15
16        var pasteArea = '<textarea'+
17                        ' style="display: none"' +
18                        ' id="' + textareaId + '"' +
19                        ' rows="10"' +
20                        ' cols="40">' +
21                ' </textarea><div' +
22                        ' id="' + errorBoxId + '"' +
23                        ' style="display:none;color:red;font-size:16px;font-weight:bold;padding-top:160px;text-align:center;z-index:11;">' +
24                '</div><iframe' +
25                        ' src=""' +
26                        ' style="width:485px;background-color:#f1f1e3;height:380px"' +
27                        ' frameborder="0"' +
28                        ' name="' + iframeId + '"' +
29                        ' id="' + iframeId + '"' +
30                        ' allowtransparency="1">' +
31                '</iframe>';
32
33        var wscCoreUrl = editor.config.wsc_customLoaderScript || ( protocol +
34                        '//loader.spellchecker.net/sproxy_fck/sproxy.php'
35                        + '?plugin=fck2'
36                        + '&customerid=' + editor.config.wsc_customerId
37                        + '&cmd=script&doc=wsc&schema=22'
38                );
39
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>';
43
44        function burnSpelling( dialog, errorMsg )
45        {
46                var i = 0;
47                return function ()
48                {
49                        if ( typeof( window.doSpell ) == 'function' )
50                        {
51                                //Call from window.setInteval expected at once.
52                                if ( typeof( interval ) != 'undefined' )
53                                        window.clearInterval( interval );
54
55                                initAndSpell( dialog );
56                        }
57                        else if ( i++ == 180 )                                                          // Timeout: 180 * 250ms = 45s.
58                                window._cancelOnError( errorMsg );
59                };
60        }
61
62        window._cancelOnError = function( m )
63        {
64                if ( typeof( window.WSC_Error ) == 'undefined' )
65                {
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 );
70                }
71        };
72
73        function initAndSpell( dialog )
74        {
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';
78
79                // global var is used in FCK specific core
80                // change on equal var used in fckplugin.js
81                window.gFCKPluginName = 'wsc';
82
83                LangComparer.setDefaulLangCode( editor.config.defaultLanguage );
84
85                window.doSpell({
86                        ctrl : textareaId,
87
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.
91
92                        // Callback binding section.
93                        onCancel : function()
94                        {
95                                dialog.hide();
96                        },
97                        onFinish : function( dT )
98                        {
99                                editor.focus();
100                                dialog.getParentEditor().setData( dT.value );
101                                dialog.hide();
102                        },
103
104                        // Some manipulations with client static pages.
105                        staticFrame : framesetPath,
106                        framesetPath : framesetPath,
107                        iframePath : pluginPath + 'ciframe.html',
108
109                        // Styles defining.
110                        schemaURI : pluginPath + 'wsc.css',
111
112                        userDictionaryName: editor.config.wsc_userDictionaryName,
113                        customDictionaryName: editor.config.wsc_customDictionaryIds && editor.config.wsc_customDictionaryIds.split(","),
114                        domainName: editor.config.wsc_domainName
115
116                });
117
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' );
121        }
122
123        return {
124                title : editor.config.wsc_dialogTitle || editor.lang.spellCheck.title,
125                minWidth : 485,
126                minHeight : 380,
127                buttons : [ CKEDITOR.dialog.cancelButton ],
128                onShow : function()
129                {
130                        var contentArea = this.getContentElement( 'general', 'content' ).getElement();
131                        contentArea.setHtml( pasteArea );
132
133                        if ( typeof( window.doSpell ) != 'function' )
134                        {
135                                // Load script.
136                                CKEDITOR.document.getHead().append(
137                                        CKEDITOR.document.createElement( 'script',
138                                                {
139                                                        attributes :
140                                                                {
141                                                                        type : 'text/javascript',
142                                                                        src : wscCoreUrl
143                                                                }
144                                                })
145                                );
146                        }
147
148                        var sData = editor.getData();                                                                                   // Get the data to be checked.
149                        CKEDITOR.document.getById( textareaId ).setValue( sData );
150
151                        interval = window.setInterval( burnSpelling( this, errorMsg ), 250 );
152                },
153                onHide : function()
154                {
155                        window.ooo = undefined;
156                        window.int_framsetLoaded = undefined;
157                        window.framesetLoaded = undefined;
158                        window.is_window_opened = false;
159                },
160                contents : [
161                        {
162                                id : 'general',
163                                label : editor.config.wsc_dialogTitle || editor.lang.spellCheck.title,
164                                padding : 0,
165                                elements : [
166                                        {
167                                                type : 'html',
168                                                id : 'content',
169                                                style : 'width:485;height:380px',
170                                                html : '<div></div>'
171                                        }
172                                ]
173                        }
174                ]
175        };
176});
Note: See TracBrowser for help on using the repository browser.