Ticket #8385: sample.js

File sample.js, 2.3 KB (added by z.kwiecinski, 12 years ago)

Additional javascript

Line 
1/*
2Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3For licensing, see LICENSE.html or http://ckeditor.com/license
4*/
5
6// This file is not required by CKEditor and may be safely ignored.
7// It is just a helper file that displays a red message about browser compatibility
8// at the top of the samples (if incompatible browser is detected).
9
10if ( window.CKEDITOR )
11{
12        (function()
13        {
14                var showCompatibilityMsg = function()
15                {
16                        var env = CKEDITOR.env;
17
18                        var html = '<p><strong>Your browser is not compatible with CKEditor.</strong>';
19
20                        var browsers =
21                        {
22                                gecko : 'Firefox 2.0',
23                                ie : 'Internet Explorer 6.0',
24                                opera : 'Opera 9.5',
25                                webkit : 'Safari 3.0'
26                        };
27
28                        var alsoBrowsers = '';
29
30                        for ( var key in env )
31                        {
32                                if ( browsers[ key ] )
33                                {
34                                        if ( env[key] )
35                                                html += ' CKEditor is compatible with ' + browsers[ key ] + ' or higher.';
36                                        else
37                                                alsoBrowsers += browsers[ key ] + '+, ';
38                                }
39                        }
40
41                        alsoBrowsers = alsoBrowsers.replace( /\+,([^,]+), $/, '+ and $1' );
42
43                        html += ' It is also compatible with ' + alsoBrowsers + '.';
44
45                        html += '</p><p>With non compatible browsers, you should still be able to see and edit the contents (HTML) in a plain text field.</p>';
46
47                        var alertsEl = document.getElementById( 'alerts' );
48                        alertsEl && ( alertsEl.innerHTML = html );
49                };
50
51                var onload = function()
52                {
53                        // Show a friendly compatibility message as soon as the page is loaded,
54                        // for those browsers that are not compatible with CKEditor.
55                        if ( !CKEDITOR.env.isCompatible )
56                                showCompatibilityMsg();
57                };
58
59                // Register the onload listener.
60                if ( window.addEventListener )
61                        window.addEventListener( 'load', onload, false );
62                else if ( window.attachEvent )
63                        window.attachEvent( 'onload', onload );
64        })();
65}
66
67function konfiguruj(textArea, config) {
68        var sep = '/';
69        if (location.pathname.split('\\').length > location.pathname.split('/').length) {
70                sep = '\\';
71        }
72        var tab = location.pathname.split(sep);
73        tab[tab.length-1] = '8385-config.js';
74        sep = sep == '/' ? sep + tab.join(sep) : tab.join(sep);
75       
76        if (textArea.className == 'ck-cust') {
77                CKEDITOR.replace( textArea, {customConfig : sep} );
78                return false;
79        } else {
80                return textArea.className.indexOf('ckeditor') == 0;
81        }   
82}
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy