Ticket #3496: 3496_3.patch

File 3496_3.patch, 46.8 KB (added by Frederico Caldeira Knabben, 16 years ago)
  • _source/core/command.js

     
    2929
    3030CKEDITOR.command.prototype =
    3131{
     32        enable : function()
     33        {
     34                if ( this.state == CKEDITOR.TRISTATE_DISABLED )
     35                        this.setState( ( !this.preserveState || ( typeof this.previousState == 'undefined' ) ) ? CKEDITOR.TRISTATE_OFF : this.previousState );
     36        },
     37
     38        disable : function()
     39        {
     40                this.setState( CKEDITOR.TRISTATE_DISABLED );
     41        },
     42
    3243        setState : function( newState )
    3344        {
    3445                // Do nothing if there is no state change.
    3546                if ( this.state == newState )
    3647                        return false;
    3748
     49                this.previousState = this.state;
     50
    3851                // Set the new state.
    3952                this.state = newState;
    4053
  • _source/core/config.js

     
    150150         * config.plugins = 'basicstyles,button,htmldataprocessor,toolbar,wysiwygarea';
    151151         */
    152152
    153         plugins : 'about,basicstyles,blockquote,button,clipboard,colorbutton,contextmenu,elementspath,enterkey,entities,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,maximize,newpage,pagebreak,pastefromword,pastetext,preview,print,removeformat,save,smiley,showblocks,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
     153        plugins : 'about,basicstyles,blockquote,button,clipboard,colorbutton,contextmenu,elementspath,enterkey,entities,find,flash,font,format,forms,horizontalrule,htmldataprocessor,image,indent,justify,keystrokes,link,list,maximize,newpage,pagebreak,pastefromword,pastetext,preview,print,removeformat,save,scayt,smiley,showblocks,sourcearea,stylescombo,table,tabletools,specialchar,tab,templates,toolbar,undo,wysiwygarea,wsc',
    154154
    155155        /**
    156156         * List of additional plugins to be loaded. This is a tool setting which
  • _source/core/editor.js

     
    320320                for ( var name in commands )
    321321                {
    322322                        command = commands[ name ];
    323 
    324                         command.setState( command.modes[ mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED );
     323                        command[ command.modes[ mode ] ? 'enable' : 'disable' ]();
    325324                }
    326325        }
    327326
     
    399398
    400399                        CKEDITOR.fire( 'instanceCreated', null, this );
    401400
    402                         this.on( 'mode', updateCommandsMode );
     401                        this.on( 'mode', updateCommandsMode, null, null, 1 );
    403402
    404403                        initConfig( this, instanceConfig );
    405404                };
  • _source/lang/en.js

     
    620620                'FFF' : 'White'
    621621        },
    622622
     623        scayt :
     624        {
     625                title : 'Spell Check As You Type',
     626                enable : 'Enable SCAYT',
     627                disable : 'Disable SCAYT',
     628                about : 'About SCAYT',
     629                toggle : 'Toggle SCAYT',
     630                options : 'Options',
     631                langs : 'Languages',
     632                moreSuggestions : 'More suggestions',
     633                ignore : 'Ignore',
     634                ignoreAll : 'Ignore All',
     635                addWord : 'Add Word',
     636                emptyDic : 'Dictionary name should not be empty.',
     637                optionsTab : 'Options',
     638                languagesTab : 'Languages',
     639                dictionariesTab : 'Dictionaries',
     640                aboutTab : 'About'
     641        },
     642
    623643        about :
    624644        {
    625645                title : 'About CKEditor',
  • _source/plugins/button/plugin.js

     
    2727 */
    2828CKEDITOR.ui.button = function( definition )
    2929{
    30         /**
    31          * The button label.
    32          * @name CKEDITOR.ui.button.prototype.label
    33          * @type String
    34          * @example
    35          */
    36         this.label = definition.label;
    37 
    38         /**
    39          * The button advisory title. It is usually displayed as the button tooltip.
    40          * If not defined, the label is used.
    41          * @name CKEDITOR.ui.button.prototype.title
    42          * @type String
    43          * @example
    44          */
    45         this.title = definition.title || definition.label;
    46 
    47         /**
    48          * The command name associated to the button. If no command is defined, the
    49          * "click" event is used.
    50          * @name CKEDITOR.ui.button.prototype.command
    51          * @type String
    52          * @example
    53          */
    54         this.command = definition.command;
    55 
    56         this.className = definition.className || ( definition.command && 'cke_button_' + definition.command ) || '';
    57 
    58         this.icon = definition.icon;
    59         this.iconOffset = definition.iconOffset;
    60 
    61         /**
    62          * The function to be called when the user clicks the button. If not
    63          * defined, the "command" property is required, and the command gets
    64          * executed on click.
    65          * @function
    66          * @name CKEDITOR.ui.button.prototype.click
    67          * @example
    68          */
    69         this.click = definition.click || function( editor )
     30        // Copy all definition properties to this object.
     31        CKEDITOR.tools.extend( this, definition,
     32                // Set defaults.
    7033                {
    71                         editor.execCommand( definition.command );
    72                 };
     34                        title           : definition.label,
     35                        className       : definition.className || ( definition.command && 'cke_button_' + definition.command ) || '',
     36                        click           : definition.click || function( editor )
     37                                {
     38                                        editor.execCommand( definition.command );
     39                                }
     40                });
    7341
    7442        this._ = {};
    7543};
     
    11886                                this.button.click( editor );
    11987                        }
    12088                };
     89               
     90                var clickFn = CKEDITOR.tools.addFunction( instance.execute, instance );
    12191
    12292                var index = CKEDITOR.ui.button._.instances.push( instance ) - 1;
    12393
     
    138108                                                this.setState( command.state );
    139109                                        }, this);
    140110
    141                                 classes += ' cke_' + (
     111                                classes += 'cke_' + (
    142112                                        command.state == CKEDITOR.TRISTATE_ON ? 'on' :
    143113                                        command.state == CKEDITOR.TRISTATE_DISABLED ? 'disabled' :
    144114                                        'off' );
    145115                        }
    146116                }
     117               
     118                if ( !command )
     119                        classes += 'cke_off';
    147120
    148121                if ( this.className )
    149122                        classes += ' ' + this.className;
     
    176149                output.push(
    177150                                ' onkeydown="return CKEDITOR.ui.button._.keydown(', index, ', event);"' +
    178151                                ' onfocus="return CKEDITOR.ui.button._.focus(', index, ', event);"' +
    179                                 ' onclick="return CKEDITOR.ui.button._.click(', index, ', event);">' +
     152                                ' onclick="CKEDITOR.tools.callFunction(', clickFn, ', this); return false;">' +
    180153                                        '<span class="cke_icon"' );
    181154
    182155                if ( this.icon )
     
    187160
    188161                output.push(
    189162                                        '></span>' +
    190                                         '<span class="cke_label">', this.label, '</span>' +
     163                                        '<span class="cke_label">', this.label, '</span>' );
     164
     165                if ( this.hasArrow )
     166                {
     167                        output.push(
     168                                        '<span class="cke_buttonarrow"></span>' );
     169                }
     170
     171                output.push(
    191172                        '</a>',
    192173                        '</span>' );
    193174
     175                if ( this.onRender )
     176                        this.onRender();
     177
    194178                return instance;
    195179        },
    196180
     
    213197{
    214198        instances : [],
    215199
    216         click : function( index )
    217         {
    218                 CKEDITOR.ui.button._.instances[ index ].execute();
    219                 return false;
    220         },
    221 
    222200        keydown : function( index, ev )
    223201        {
    224202                var instance = CKEDITOR.ui.button._.instances[ index ];
  • _source/plugins/contextmenu/plugin.js

     
    3939
    4040        _ :
    4141        {
    42                 onMenu : function( offsetParent, offsetX, offsetY )
     42                onMenu : function( offsetParent, corner, offsetX, offsetY )
    4343                {
    4444                        var menu = this._.menu,
    4545                                editor = this.editor;
     
    5454                                menu = this._.menu = new CKEDITOR.menu( editor );
    5555                                menu.onClick = CKEDITOR.tools.bind( function( item )
    5656                                {
    57                                         menu.onHide = null;
    58 
    5957                                        var noUnlock = true;
    6058                                        menu.hide();
    6159
     
    8886                        // Lock the selection in IE, so it can be restored when closing the
    8987                        // menu.
    9088                        if ( CKEDITOR.env.ie )
    91                         {
    9289                                selection.lock();
    93                                 menu.onHide = function()
     90
     91                        menu.onHide = CKEDITOR.tools.bind( function()
    9492                                {
    95                                         editor.getSelection().unlock();
    96                                 };
    97                         }
     93                                        menu.onHide = null;
    9894
     95                                        if ( CKEDITOR.env.ie )
     96                                                editor.getSelection().unlock();
     97                                       
     98                                        this.onHide && this.onHide();
     99                                },
     100                                this );
     101
    99102                        // Call all listeners, filling the list of items to be displayed.
    100103                        for ( var i = 0 ; i < listeners.length ; i++ )
    101104                        {
     
    116119                                }
    117120                        }
    118121
    119                         menu.show( offsetParent, editor.lang.dir == 'rtl' ? 2 : 1, offsetX, offsetY );
     122                        menu.show( offsetParent, corner || ( editor.lang.dir == 'rtl' ? 2 : 1 ), offsetX, offsetY );
    120123                }
    121124        },
    122125
     
    137140
    138141                                        CKEDITOR.tools.setTimeout( function()
    139142                                                {
    140                                                         this._.onMenu( offsetParent, offsetX, offsetY );
     143                                                        this._.onMenu( offsetParent, null, offsetX, offsetY );
    141144                                                },
    142145                                                0, this );
    143146                                },
     
    149152                        this._.listeners.push( listenerFn );
    150153                },
    151154
    152                 show : function()
     155                show : function( offsetParent, corner, offsetX, offsetY )
    153156                {
    154157                        this.editor.focus();
    155                         this._.onMenu( CKEDITOR.document.getDocumentElement(), 0, 0 );
     158                        this._.onMenu( offsetParent || CKEDITOR.document.getDocumentElement(), corner, offsetX || 0, offsetY || 0 );
    156159                }
    157160        }
    158161});
  • _source/plugins/menu/plugin.js

     
    2020
    2121CKEDITOR.tools.extend( CKEDITOR.editor.prototype,
    2222{
     23        addMenuGroup : function( name, order )
     24        {
     25                this._.menuGroups[ name ] = order || 100;
     26        },
     27
    2328        addMenuItem : function( name, definition )
    2429        {
    2530                if ( this._.menuGroups[ definition.group ] )
     
    171176                                                {
    172177                                                        var item = this.items[ index ];
    173178
     179                                                        if ( item.state == CKEDITOR.TRISTATE_DISABLED )
     180                                                        {
     181                                                                this.hide();
     182                                                                return;
     183                                                        }
     184
    174185                                                        if ( item.getItems )
    175186                                                                this._.showSubMenu( index );
    176187                                                        else
     
    258269                render : function( menu, index, output )
    259270                {
    260271                        var id = menu.id + String( index ),
    261                                 state = this.state || CKEDITOR.TRISTATE_OFF;
     272                                state = ( typeof this.state == 'undefined' ) ? CKEDITOR.TRISTATE_OFF : this.state;
    262273
    263274                        var classes = ' cke_' + (
    264275                                state == CKEDITOR.TRISTATE_ON ? 'on' :
  • _source/plugins/menubutton/plugin.js

    Property changes on: _source\plugins\menubutton
    ___________________________________________________________________
    Added: bugtraq:label
       + Ticket
    Added: bugtraq:url
       + http://dev.fckeditor.net/ticket/%BUGID%
    Added: webviewer:pathrevision
       + http://dev.fckeditor.net/browser/%PATH%?rev=%REVISION% 
    Added: webviewer:revision
       + http://dev.fckeditor.net/changeset/%REVISION%
    Added: bugtraq:logregex
       + (?:ticket: *|#)(\d+) *(?:, *(\d+))*
    
    
     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6CKEDITOR.plugins.add( 'menubutton',
     7{
     8        requires : [ 'button' ],
     9        beforeInit : function( editor )
     10        {
     11                editor.ui.addHandler( CKEDITOR.UI_MENUBUTTON, CKEDITOR.ui.menuButton.handler );
     12        }
     13});
     14
     15/**
     16 * Button UI element.
     17 * @constant
     18 * @example
     19 */
     20CKEDITOR.UI_MENUBUTTON = 5;
     21
     22(function()
     23{
     24        var clickFn = function( editor )
     25        {
     26                var _ = this._;
     27
     28                // Do nothing if this button is disabled.
     29                if ( _.state === CKEDITOR.TRISTATE_DISABLED )
     30                        return;
     31               
     32                _.previousState = _.state;
     33
     34                // Check if we already have a menu for it, otherwise just create it.
     35                var menu = _.menu;
     36                if ( !menu )
     37                {
     38                        menu = _.menu = new CKEDITOR.plugins.contextMenu( editor );
     39
     40                        menu.onHide = CKEDITOR.tools.bind( function()
     41                                {
     42                                        this.setState( _.previousState );
     43                                },
     44                                this );
     45
     46                        // Initialize the menu items at this point.
     47                        if ( this.onMenu )
     48                        {
     49                                menu.addListener( this.onMenu );
     50                        }
     51                }
     52
     53                if ( _.on )
     54                {
     55                        menu.hide();
     56                        return;
     57                }
     58
     59                this.setState( CKEDITOR.TRISTATE_ON );
     60
     61                menu.show( CKEDITOR.document.getById( this._.id ), 4 );
     62        };
     63
     64
     65        CKEDITOR.ui.menuButton = CKEDITOR.tools.createClass(
     66        {
     67                base : CKEDITOR.ui.button,
     68
     69                $ : function( definition )
     70                {
     71                        // We don't want the panel definition in this object.
     72                        var panelDefinition = definition.panel;
     73                        delete definition.panel;
     74
     75                        this.base( definition );
     76                       
     77                        this.hasArrow = true;
     78
     79                        this.click = clickFn;
     80                },
     81
     82                statics :
     83                {
     84                        handler :
     85                        {
     86                                create : function( definition )
     87                                {
     88                                        return new CKEDITOR.ui.menuButton( definition );
     89                                }
     90                        }
     91                }
     92        });
     93})();
     94 No newline at end of file
  • _source/plugins/panelbutton/plugin.js

     
    1919 */
    2020CKEDITOR.UI_PANELBUTTON = 4;
    2121
    22 CKEDITOR.ui.panelButton = CKEDITOR.tools.createClass(
     22(function()
    2323{
    24         $ : function( definition )
     24        var clickFn = function( editor )
    2525        {
    26                 // Copy all definition properties to this object.
    27                 CKEDITOR.tools.extend( this, definition,
    28                         // Set defaults.
    29                         {
    30                                 title : definition.label,
    31                                 modes : { wysiwyg : 1 }
    32                         });
     26                var _ = this._;
    3327
    34                 // We don't want the panel definition in this object.
    35                 var panelDefinition = this.panel;
    36                 delete this.panel;
     28                if ( _.state == CKEDITOR.TRISTATE_DISABLED )
     29                        return;
    3730
    38                 this.document = ( panelDefinition
    39                                                         && panelDefinition.parent
    40                                                         && panelDefinition.parent.getDocument() )
    41                                                 || CKEDITOR.document;
    42                 this._ =
    43                 {
    44                         panelDefinition : panelDefinition
    45                 };
    46         },
     31                this.createPanel( editor );
    4732
    48         statics :
    49         {
    50                 handler :
     33                if ( _.on )
    5134                {
    52                         create : function( definition )
    53                         {
    54                                 return new CKEDITOR.ui.panelButton( definition );
    55                         }
     35                        _.panel.hide();
     36                        return;
    5637                }
    57         },
    5838
    59         proto :
    60         {
    61                 render : function( editor, output )
    62                 {
    63                         var id = this._.id = 'cke_' + CKEDITOR.tools.getNextNumber();
     39                _.panel.showBlock( this._.id, this.document.getById( this._.id ), 4 );
     40        };
    6441
    65                         var instance =
    66                         {
    67                                 id : id,
    68                                 focus : function()
    69                                 {
    70                                         var element = CKEDITOR.document.getById( id );
    71                                         element.focus();
    72                                 },
    73                                 execute : function()
    74                                 {
    75                                         this.button.click( editor );
    76                                 }
    77                         };
    7842
    79                         var clickFn = CKEDITOR.tools.addFunction( function( $element )
    80                                 {
    81                                         var _ = this._;
     43        CKEDITOR.ui.panelButton = CKEDITOR.tools.createClass(
     44        {
     45                base : CKEDITOR.ui.button,
    8246
    83                                         if ( _.state == CKEDITOR.TRISTATE_DISABLED )
    84                                                 return;
     47                $ : function( definition )
     48                {
     49                        // We don't want the panel definition in this object.
     50                        var panelDefinition = definition.panel;
     51                        delete definition.panel;
    8552
    86                                         this.createPanel( editor );
     53                        this.base( definition );
    8754
    88                                         if ( _.on )
    89                                         {
    90                                                 _.panel.hide();
    91                                                 return;
    92                                         }
     55                        this.document = ( panelDefinition
     56                                                                && panelDefinition.parent
     57                                                                && panelDefinition.parent.getDocument() )
     58                                                        || CKEDITOR.document;
     59                       
     60                        this.hasArrow = true;
    9361
    94                                         _.panel.showBlock( this._.id, new CKEDITOR.dom.element( $element ), 4 );
    95                                 },
    96                                 this );
    97                         var keyDownFn = CKEDITOR.tools.addFunction( function( ev, element ){
     62                        this.click = clickFn;
    9863
    99                                 ev = new CKEDITOR.dom.event( ev );
     64                        this._ =
     65                        {
     66                                panelDefinition : panelDefinition
     67                        };
     68                },
    10069
    101                                 var keystroke = ev.getKeystroke();
    102                                 switch ( keystroke )
     70                statics :
     71                {
     72                        handler :
     73                        {
     74                                create : function( definition )
    10375                                {
    104                                         case 13 :       // ENTER
    105                                         case 32 :       // SPACE
    106                                         case 40 :       // ARROW-DOWN
    107                                                 // Show panel
    108                                                 CKEDITOR.tools.callFunction( clickFn, element );
    109                                                 break;
    110                                         default :
    111                                                 // Delegate the default behavior to toolbar button key handling.
    112                                                 instance.onkey( instance,  keystroke );
     76                                        return new CKEDITOR.ui.panelButton( definition );
    11377                                }
    114 
    115                                 // Avoid subsequent focus grab on editor document.
    116                                 ev.preventDefault();
    117                         });
    118 
    119                         var label = this.label || '';
    120 
    121                         var classes = 'cke_off';
    122 
    123                         if ( this.className )
    124                                 classes += ' ' + this.className;
    125 
    126                         editor.on( 'mode', function()
    127                                 {
    128                                         this.setState( this.modes[ editor.mode ] ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED );
    129                                 },
    130                                 this );
    131 
    132                         output.push(
    133                                 '<span class="cke_button">',
    134                                 '<a id="', id, '"' +
    135                                         ' class="', classes, '" href="javascript:void(\'', ( this.title || '' ).replace( "'", '' ), '\')"' +
    136                                         ' title="', this.title, '"' +
    137                                         ' tabindex="-1"' +
    138                                         ' hidefocus="true"' );
    139 
    140                         // Some browsers don't cancel key events in the keydown but in the
    141                         // keypress.
    142                         // TODO: Check if really needed for Gecko+Mac.
    143                         if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ) )
    144                         {
    145                                 output.push(
    146                                         ' onkeypress="return false;"' );
    14778                        }
    148 
    149                         // With Firefox, we need to force the button to redraw, otherwise it
    150                         // will remain in the focus state.
    151                         if ( CKEDITOR.env.gecko )
    152                         {
    153                                 output.push(
    154                                         ' onblur="this.style.cssText = this.style.cssText;"' );
    155                         }
    156 
    157                         output.push(
    158                                         ' onkeydown="CKEDITOR.tools.callFunction( ', keyDownFn, ', event, this );"' +
    159                                         ' onclick="CKEDITOR.tools.callFunction(', clickFn, ', this); return false;">' +
    160                                                 '<span class="cke_icon"></span>' +
    161                                                 '<span class="cke_label">', this.label, '</span>' +
    162                                                 '<span class="cke_buttonarrow"></span>' +
    163                                 '</a>' +
    164                                 '</span>' );
    165 
    166                         return instance;
    16779                },
    16880
    169                 createPanel : function( editor )
     81                proto :
    17082                {
    171                         var _ = this._;
     83                        createPanel : function( editor )
     84                        {
     85                                var _ = this._;
    17286
    173                         if ( _.panel )
    174                                 return;
     87                                if ( _.panel )
     88                                        return;
    17589
    176                         var panelDefinition = this._.panelDefinition || {},
    177                                 panelParentElement = panelDefinition.parent || CKEDITOR.document.getBody(),
    178                                 panel = this._.panel = new CKEDITOR.ui.floatPanel( editor, panelParentElement, panelDefinition ),
    179                                 me = this;
     90                                var panelDefinition = this._.panelDefinition || {},
     91                                        panelParentElement = panelDefinition.parent || CKEDITOR.document.getBody(),
     92                                        panel = this._.panel = new CKEDITOR.ui.floatPanel( editor, panelParentElement, panelDefinition ),
     93                                        me = this;
    18094
    181                         panel.onShow = function()
    182                                 {
    183                                         if ( me.className )
    184                                                 this.element.getFirst().addClass( me.className + '_panel' );
     95                                panel.onShow = function()
     96                                        {
     97                                                if ( me.className )
     98                                                        this.element.getFirst().addClass( me.className + '_panel' );
    18599
    186                                         me.setState( CKEDITOR.TRISTATE_ON );
     100                                                _.oldState = me._.state;
     101                                                me.setState( CKEDITOR.TRISTATE_ON );
    187102
    188                                         _.on = 1;
     103                                                _.on = 1;
    189104
    190                                         if ( me.onOpen )
    191                                                 me.onOpen();
    192                                 };
     105                                                if ( me.onOpen )
     106                                                        me.onOpen();
     107                                        };
    193108
    194                         panel.onHide = function()
    195                                 {
    196                                         if ( me.className )
    197                                                 this.element.getFirst().removeClass( me.className + '_panel' );
     109                                panel.onHide = function()
     110                                        {
     111                                                if ( me.className )
     112                                                        this.element.getFirst().removeClass( me.className + '_panel' );
    198113
    199                                         me.setState( CKEDITOR.TRISTATE_OFF );
     114                                                me.setState( _.oldState );
    200115
    201                                         _.on = 0;
     116                                                _.on = 0;
    202117
    203                                         if ( me.onClose )
    204                                                 me.onClose();
    205                                 };
     118                                                if ( me.onClose )
     119                                                        me.onClose();
     120                                        };
    206121
    207                         panel.onEscape = function()
    208                                 {
    209                                         panel.hide();
    210                                         me.document.getById( _.id ).focus();
    211                                 };
     122                                panel.onEscape = function()
     123                                        {
     124                                                panel.hide();
     125                                                me.document.getById( _.id ).focus();
     126                                        };
    212127
    213128
    214                         if ( this.onBlock )
    215                                 this.onBlock( panel, _.id );
    216                 },
     129                                if ( this.onBlock )
     130                                        this.onBlock( panel, _.id );
     131                        }
     132                }
     133        });
    217134
    218                 setState : CKEDITOR.ui.button.prototype.setState
    219         }
    220 });
     135})();
     136 No newline at end of file
  • _source/plugins/scayt/dialogs/options.js

     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6CKEDITOR.dialog.add( 'scaytcheck', function( editor )
     7{
     8        var firstLoad = true,
     9                captions,
     10                doc = CKEDITOR.document,
     11                fckLang = "en";
     12
     13        var init_with_captions = function()
     14        {
     15                var dialog = this,
     16                        lang_list = dialog.data.scayt.getLangList(),
     17                        buttons = [ 'dic_create','dic_delete','dic_rename','dic_restore' ],
     18                        labels = [ 'mixedCase','mixedWithDigits','allCaps','ignoreDomainNames' ];
     19
     20/*
     21                // Add buttons titles
     22                for ( var i in buttons )
     23                {
     24                        var button = buttons[ i ];
     25                        doc.getById( button ).setHtml( captions[ "button_" + button] );
     26                }
     27                doc.getById( "dic_info" ).setHtml( captions[ "dic_info" ] );
     28*/
     29
     30                // Fill options and dictionary labels.
     31                for ( var i in labels )
     32                {
     33                        var label = "label_" + labels[ i ];
     34                        var labelElement = doc.getById( label );
     35                        if ( labelElement )
     36                                labelElement.setHtml( captions[ label ] );
     37                }
     38               
     39                var about = '<p>' + captions[ "about_throwt_image" ] + '</p>'+
     40                                        '<p>' + captions[ "version" ]  + dialog.data.scayt.version.toString() + '</p>' +
     41                                        '<p>' + captions[ "about_throwt_copy" ] + '</p>';
     42
     43                doc.getById( "scayt_about" ).setHtml( about );
     44
     45                // Create languages tab.
     46                var createOption = function( option, list )
     47                {
     48                        var label = doc.createElement( 'label' );
     49                        label.setAttribute( 'for', 'cke_option' + option );
     50                        label.setHtml( list[ option ] );
     51
     52                        if ( dialog.sLang == option )   // Current.
     53                                dialog.chosed_lang = option;
     54
     55                        var div = doc.createElement( 'div' );
     56                                radio = CKEDITOR.dom.element.createFromHtml( '<input id="cke_option' +
     57                                        option + '" type="radio" ' +
     58                                        ( dialog.sLang == option ? 'checked="checked"' : '' ) +
     59                                        ' value="' + option + '" name="scayt_lang" />' );
     60
     61                        radio.on( 'click', function()
     62                                {
     63                                        this.$.checked = true;
     64                                        dialog.chosed_lang = option;
     65                                });
     66
     67                        div.append( radio );
     68                        div.append( label );
     69
     70                        return {
     71                                lang : list[ option ],
     72                                code : option,
     73                                radio : div
     74                        }
     75                };
     76
     77                var langList = [];
     78                for ( var i in lang_list.rtl )
     79                        langList[ langList.length ] = createOption( i, lang_list.ltr )
     80
     81                for ( var i in lang_list.ltr )
     82                        langList[ langList.length  ] = createOption( i, lang_list.ltr )
     83
     84                langList.sort(  function( lang1, lang2 )
     85                        {
     86                                return ( lang2.lang > lang1.lang ) ? -1 : 1 ;
     87                        });
     88
     89                var fieldL = doc.getById( 'scayt_lcol' ),
     90                        fieldR = doc.getById( 'scayt_rcol' );
     91                for ( var i=0; i < langList.length; i++ )
     92                {
     93                        var field = ( i < langList.length / 2 ) ? fieldL : fieldR;
     94                        field.append( langList[ i ].radio );
     95                }
     96        };
     97        var reload = function()
     98        {
     99                var dialog = this;
     100
     101                // Animate options.
     102                for ( var i in dialog.options )
     103                {
     104                        var checkbox = doc.getById( i );
     105                        if ( checkbox )
     106                        {
     107                                checkbox.removeAttribute( 'checked' );
     108                                if ( dialog.options[ i ] == 1 )
     109                                        checkbox.setAttribute( 'checked', "checked" );
     110
     111                                // Bind events. Do it only once.
     112                                if ( firstLoad )
     113                                {
     114                                        checkbox.on( 'click', function()
     115                                                {
     116                                                        dialog.options[ this.getId() ] = this.$.checked ? 1 : 0 ;
     117                                                } )
     118                                }
     119                        }
     120                }
     121
     122                // * user dictionary   
     123                var dic_buttons = [
     124                        // [0] contains buttons for creating
     125                        "dic_create,dic_restore",
     126                        // [1] contains buton for manipulation
     127                        "dic_rename,dic_delete,dic_restore"
     128                ];
     129                scayt.getNameUserDictionary(
     130                        function( o )
     131                        {
     132                                var dic_name = o.dname;
     133                                if ( dic_name )
     134                                {
     135                                        dojo.byId( 'dic_name' ).value = dic_name;
     136                                        display_dic_buttons( dic_buttons[1] );
     137                                }
     138                                else
     139                                        display_dic_buttons( dic_buttons[0] );
     140                               
     141                        },
     142                        function () {
     143                        });
     144
     145                var dic_flag = 0;
     146                 // ** bind event listeners
     147                dojo.query("div.dic_buttons a.button").onclick(function( ev )
     148                        {
     149                                if (typeof window[this.id] == 'function'  ){
     150                                        // get dic name
     151                                        var dic_name = dojo.trim ( dojo.byId('dic_name').value );
     152                                        // check common dictionary rules
     153                                        if (!dic_name)
     154                                        {
     155                                                dic_error_message( editor.lang.scayt.emptyDic );
     156                                                return false;
     157                                        }
     158                                        //apply handler
     159                                        window[this.id].apply( window, [this,ev , dic_name, dic_buttons ] );
     160                                }
     161                                //console.info( typeof window[this.id], window[this.id].calle )
     162                                return false;
     163                        });
     164        };
     165
     166    return {
     167           title : editor.lang.scayt.title,
     168           minWidth : 340,
     169           minHeight : 200,
     170           onShow : function()
     171                   {
     172                                var dialog = this;
     173                                dialog.data = editor.fire( "scaytDialog", {} );
     174                                dialog.options = dialog.data.scayt_control.option();
     175                                dialog.sLang = dialog.data.scayt_control.sLang;
     176
     177                                if ( !dialog.data || !dialog.data.scayt || !dialog.data.scayt_control )
     178                                {
     179                                        alert( "Error loading application service" );
     180                                        dialog.hide();
     181                                        return;
     182                                }
     183
     184                                var stop = 0;
     185                                if ( firstLoad )
     186                                {
     187                                        dialog.data.scayt.getCaption( 'en', function( caps )
     188                                                {
     189                                                        if ( stop++ > 0 )       // Once only
     190                                                                return;
     191                                                        captions = caps;
     192                                                        init_with_captions.apply( dialog );
     193                                                        reload.apply( dialog );
     194                                                        firstLoad = false;
     195                                                });
     196                                }
     197                                else
     198                                        reload.apply( dialog );
     199
     200                                dialog.selectPage( dialog.data.tab );
     201                        },
     202                        onOk : function()
     203                        {
     204                                var scayt_control =  this.data.scayt_control;
     205                                        o = scayt_control.option();
     206                                        c = 0;
     207
     208                                // Set upp options if any was set.
     209                                for ( var oN in this.options )
     210                                {
     211                                        if (o[oN] != this.options[ oN ] && c == 0 )
     212                                        {
     213                                                scayt_control.option( this.options );
     214                                                c++;
     215                                        }
     216                                }
     217
     218                                // Setup languge if it was changed.
     219                                var csLang = this.chosed_lang;
     220                                if ( csLang && this.data.sLang != csLang )
     221                                {
     222                                        scayt_control.setLang( csLang );
     223                                        c++;
     224                                }
     225                                if ( c > 0 )
     226                                        scayt_control.refresh();
     227                        },
     228                        contents : [
     229                                {
     230                                        id : 'options',
     231                                        label : editor.lang.scayt.optionsTab,
     232                                        elements : [
     233                                                {
     234                                                        type : 'html',
     235                                                        id : 'options',
     236                                                        html :  '<div class="inner_options">' +
     237                                                                        '       <div class="messagebox"></div>' +
     238                                                                        '       <div>' +
     239                                                                        '               <input type="checkbox" value="0" id="allCaps" />' +
     240                                                                        '               <label for="allCaps" id="label_allCaps"></label>' +
     241                                                                        '       </div>' +
     242                                                                        '       <div>' +
     243                                                                        '               <input type="checkbox" value="0" id="ignoreDomainNames" />' +
     244                                                                        '               <label for="ignoreDomainNames" id="label_ignoreDomainNames"></label>' +
     245                                                                        '       </div>' +
     246                                                                        '       <div>' +
     247                                                                        '       <input type="checkbox" value="0" id="mixedCase" />' +
     248                                                                        '               <label for="mixedCase" id="label_mixedCase"></label>' +
     249                                                                        '       </div>' +
     250                                                                        '       <div>' +
     251                                                                        '               <input type="checkbox" value="0" id="mixedWithDigits" />' +
     252                                                                        '               <label for="mixedWithDigits" id="label_mixedWithDigits"></label>' +
     253                                                                        '       </div>' +
     254                                                                        '</div>'
     255                                                }
     256                                        ]
     257                                },
     258                                {
     259                                        id : 'langs',
     260                                        label : editor.lang.scayt.languagesTab,
     261                                        elements : [
     262                                                {
     263                                                        type : 'html',
     264                                                        id : 'langs',
     265                                                        html :  '<div class="inner_langs">' +
     266                                                                        '       <div class="messagebox"></div>  ' +
     267                                                                        '   <div style="float:left;width:47%;margin-left:5px;" id="scayt_lcol" ></div>' +
     268                                                                        '   <div style="float:left;width:47%;margin-left:15px;" id="scayt_rcol"></div>' +
     269                                                                        '</div>'
     270                                                }
     271                                        ]
     272                                },
     273                                /*
     274                                {
     275                                        id : 'dictionaries',
     276                                        label : editor.lang.scayt.dictionariesTab,
     277                                        elements : [
     278                                                {
     279                                                        type : 'html',
     280                                                        style: '',
     281                                                        id : 'dic',
     282                                                        html :  '<div class="inner_dictionary">' +
     283                                                                        '       <div class="messagebox" id="dic_message"></div>' +
     284                                                                        '       <div class="dictionary" > ' +
     285                                                                        '               <label for="dname" id="dname"></label>' +
     286                                                                        '               <input type="text" size="14" maxlength="15" value="" id="dic_name" name="dic_name"/>' +
     287                                                                        '               <div class="dic_buttons">' +
     288                                                                        '                       <a href="javascript:void(0)" id="dic_create" class="button"></a>' +
     289                                                                        '                       <a href="javascript:void(0)" id="dic_delete" class="button"></a>' +
     290                                                                        '                       <a href="javascript:void(0)" id="dic_rename" class="button"></a>' +
     291                                                                        '                       <a href="javascript:void(0)" id="dic_restore" class="button"></a>' +
     292                                                                        '               </div>' +
     293                                                                        '       </div><p id="dic_info"></p>' +
     294                                                                        '</div>'
     295                                                }
     296                                        ]
     297                                },
     298                                */
     299                                {
     300                                        id : 'about',
     301                                        label : editor.lang.scayt.aboutTab,
     302                                        elements : [
     303                                                {
     304                                                        type : 'html',
     305                                                        id : 'about',
     306                                                        style : "margin: 10px 40px;",
     307                                                        html : '<div id="scayt_about"></div>'
     308                                                }
     309                                        ]
     310                                }
     311                        ]
     312        };
     313});
  • _source/plugins/scayt/dialogs/toolbar.css

     
     1a
     2{
     3        text-decoration:none;
     4        padding: 2px 4px 4px 6px;
     5        display : block;
     6        border-width: 1px;
     7        border-style: solid;
     8        margin : 0px;
     9}
     10
     11a.cke_scayt_toogle:hover,
     12a.cke_scayt_toogle:focus,
     13a.cke_scayt_toogle:active
     14{
     15        border-color: #316ac5;
     16        background-color: #dff1ff;
     17        color : #000;
     18        cursor: pointer;
     19        margin : 0px;
     20}
     21a.cke_scayt_toogle {
     22        color : #316ac5;
     23        border-color: #fff;
     24}
     25.scayt_enabled a.cke_scayt_item {
     26        color : #316ac5;
     27        border-color: #fff;
     28        margin : 0px;
     29}
     30.scayt_disabled a.cke_scayt_item {
     31        color : gray;
     32        border-color : #fff;
     33}
     34.scayt_enabled a.cke_scayt_item:hover,
     35.scayt_enabled a.cke_scayt_item:focus,
     36.scayt_enabled a.cke_scayt_item:active
     37{
     38        border-color: #316ac5;
     39        background-color: #dff1ff;
     40        color : #000;
     41        cursor: pointer;
     42}
     43.scayt_disabled a.cke_scayt_item:hover,
     44.scayt_disabled a.cke_scayt_item:focus,
     45.scayt_disabled a.cke_scayt_item:active
     46{
     47        border-color: gray;
     48        background-color: #dff1ff;
     49        color : gray;
     50        cursor: no-drop;
     51}
     52.cke_scayt_set_on, .cke_scayt_set_off
     53{
     54        display: none;
     55}
     56.scayt_enabled .cke_scayt_set_on
     57{
     58        display: none;
     59}
     60.scayt_disabled .cke_scayt_set_on
     61{
     62        display: inline;
     63}
     64.scayt_disabled .cke_scayt_set_off
     65{
     66        display: none;
     67}
     68.scayt_enabled  .cke_scayt_set_off
     69{
     70        display: inline;
     71}
     72 No newline at end of file
  • _source/plugins/scayt/plugin.js

     
     1/*
     2Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
     3For licensing, see LICENSE.html or http://ckeditor.com/license
     4*/
     5
     6/**
     7 * @fileOverview Spell Check As You Type (SCAYT).
     8 * Button name : Scayt.
     9 */
     10
     11(function()
     12{
     13        var commandName         = "scaytcheck",
     14                sc_on_cssclass  = "scayt_enabled",
     15                sc_off_cssclass = 'scayt_disabled',
     16                openPage                = '';
     17
     18        var onEngineLoad = function()
     19        {
     20                var editor = this;
     21                dojo.requireLocalization( 'scayt', 'caption', '', "ROOT" );
     22
     23                var createInstnce = function()  // Create new instance every time Document is created.
     24                {
     25                        // Initialise Scayt instance.
     26                        var scayt_control = new scayt(
     27                                {
     28                                        srcNodeRef: editor.document.getWindow().$.frameElement
     29                                });
     30
     31                        // Copy config.
     32                        var     lastInstance = plugin.instances[ editor.name ]
     33                        if ( lastInstance )
     34                        {
     35                                scayt_control.sLang = lastInstance.sLang;
     36                                scayt_control.option( lastInstance.option() );
     37                                scayt_control.paused = lastInstance.paused;
     38                        }
     39
     40                        plugin.instances[ editor.name ] = scayt_control;
     41
     42                        try {
     43                                scayt_control.setDisabled( scayt_control.paused === false );                            // I really don't know why it couse JS error in IE
     44                        } catch (e) {}
     45                };
     46
     47                editor.on( 'contentDom', createInstnce )                // Get the iframe somehow.
     48                editor.on( 'contentDomUnload', function()
     49                        {
     50                                // Remove scripts.
     51                                var scripts = CKEDITOR.document.getElementsByTag( 'script' );
     52                                scaytIdRegex =  /^dojoIoScript(\d+)$/i;
     53                                scaytSrcRegex =  /^http:\/\/demo\.spellchecker\.net\/spellcheck3\/script\/ssrv\.cgi/i;
     54
     55                                for ( var i=0; i < scripts.count(); i++ )
     56                                {
     57                                        var script = scripts.getItem( i ),
     58                                                id = script.getId(),
     59                                                src = script.getAttribute( 'src' );
     60
     61                                        if ( id && src && id.match( scaytIdRegex ) && src.match( scaytSrcRegex ))
     62                                                script.remove();
     63                                }
     64                        })
     65
     66                editor.on( 'beforeCommandExec', function( ev )          // Disable SCAYT before Source command execution.
     67                        {
     68                                if ( ev.data.name == 'source' && editor.mode == 'wysiwyg' )
     69                                {
     70                                        var scayt = plugin.getScayt( editor )
     71                                        if ( scayt )
     72                                        {
     73                                                scayt.paused = !scayt.disabled;
     74                                                scayt.setDisabled( true );
     75                                        }
     76                                }
     77                        });
     78
     79                // Listen to data manipulation to reflect scayt markup.
     80                editor.on( 'beforeGetData', function()
     81                        {
     82                                if ( plugin.isScaytEnabled( editor ) )
     83                                        plugin.getScayt( editor ).refresh();
     84                        });
     85
     86                editor.on( 'afterSetData', function()
     87                        {
     88                                if ( plugin.isScaytEnabled( editor ) )
     89                                        plugin.getScayt( editor ).refresh();
     90                        });
     91
     92                editor.on( 'scaytDialog', function( ev )        // Communication with dialog.
     93                        {
     94                                ev.data.djConfig = djConfig;
     95                                ev.data.scayt_control = plugin.getScayt( editor );
     96                                ev.data.tab = openPage;
     97                                ev.data.scayt = scayt;
     98                        });
     99
     100                if ( editor.document )
     101                {
     102                        createInstnce();
     103                        editor.fire( 'showScaytState' );
     104                }
     105        };
     106
     107        CKEDITOR.plugins.scayt =
     108        {
     109                engineLoaded : false,
     110                instances : {},
     111                getScayt : function( editor )
     112                {
     113                        var instance = this.instances[ editor.name ];
     114                        return instance;
     115                },
     116                isScaytReady : function( editor )
     117                {
     118                        return this.engineLoaded === true &&
     119                                'undefined' !== typeof scayt && this.getScayt( editor );
     120                },
     121                isScaytEnabled : function( editor )
     122                {
     123                        var scayt = this.getScayt( editor );
     124                        return ( scayt ) ? scayt.disabled === false : false;
     125                },
     126                loadEngine : function( editor )
     127                {
     128                        if ( this.engineLoaded === true )
     129                                return onEngineLoad.apply( editor );    // Add new instance.
     130                        else if ( this.engineLoaded == -1 )                     // We are waiting.
     131                                return CKEDITOR.on( "scaytReady", function(){ onEngineLoad.apply( editor )} );  // Use function(){} to avoid rejection as duplicate.
     132
     133                        CKEDITOR.on( "scaytReady", onEngineLoad, editor );
     134                        CKEDITOR.on( "scaytReady", function()
     135                                {
     136                                        this.engineLoaded = true;
     137                                },
     138                                this,
     139                                null,
     140                                0 );    // First to run.
     141
     142                        this.engineLoaded = -1; // Loading in progress.
     143                        djConfig =
     144                        {
     145                                baseUrl: "./",
     146                                blankGif: "http://demo.spellchecker.net/spellcheck3/lf/scayt/blank.gif",
     147                                parseOnLoad: true,
     148                                afterOnLoad: true,
     149                                useXDomain: true,
     150                                locale: 'en',
     151                                xdWaitSeconds: 10,
     152                                preventCache: false,
     153                                scaytNodes: document.getElementById('foo'),
     154                                require: [
     155                                        "dojo.i18n",
     156                                        "scayt._base"
     157                                ],
     158                                modulePaths:
     159                                {
     160                                        "scayt": "http://demo.spellchecker.net/spellcheck3/lf/scayt"
     161                                },
     162                                addOnLoad:
     163                                [
     164                                        function()
     165                                        {
     166                                                CKEDITOR.fireOnce( "scaytReady" );
     167                                        }
     168                                ],
     169                                isDebug: false
     170                        };
     171
     172                        // Append javascrip code.
     173                        CKEDITOR.document.getHead().append(
     174                                CKEDITOR.document.createElement( 'script',
     175                                        {
     176                                                attributes :
     177                                                        {
     178                                                                type : 'text/javascript',
     179                                                                src : "http://demo.spellchecker.net/spellcheck3/lf/dojo/dojo/dojo.xd.js"
     180                                                        }
     181                                        })
     182                        );
     183                }
     184        };
     185
     186        var plugin = CKEDITOR.plugins.scayt;
     187
     188        // Context menu constructing.
     189        var addButtonCommand = function( editor, buttonName, buttonLabel, commandName, command, menugroup, menuOrder )
     190        {
     191                editor.addCommand( commandName, command );
     192
     193                // If the "menu" plugin is loaded, register the menu item.
     194                editor.addMenuItem( commandName,
     195                        {
     196                                label : buttonLabel,
     197                                command : commandName,
     198                                group : menugroup,
     199                                order : menuOrder
     200                        });
     201        };
     202
     203        var commandDefinition =
     204        {
     205                preserveState : true,
     206
     207                exec: function( editor )
     208                {
     209                        if ( plugin.isScaytReady( editor ) )
     210                        {
     211                                var isEnabled = plugin.isScaytEnabled( editor );
     212                               
     213                                this.setState( isEnabled ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_ON );
     214
     215                                var scayt_control = plugin.getScayt( editor );
     216                                scayt_control.setDisabled( isEnabled );
     217                        }
     218                        else if ( !editor.config.scayt_autoStartup && plugin.engineLoaded >= 0 )        // Load first time
     219                        {
     220                                this.setState( CKEDITOR.TRISTATE_DISABLED );
     221                               
     222                                editor.on( 'showScaytState', function()
     223                                        {
     224                                                this.removeListener();
     225                                                this.setState( plugin.isScaytEnabled( editor ) ? CKEDITOR.TRISTATE_ON : CKEDITOR.TRISTATE_OFF );
     226                                        },
     227                                        this);
     228                               
     229                                plugin.loadEngine( editor );
     230                        }
     231                }
     232        };
     233       
     234        // Add scayt plugin.
     235        CKEDITOR.plugins.add( 'scayt',
     236        {
     237                requires : [ 'menubutton' ],
     238
     239                beforeInit : function( editor )
     240                {
     241                        // Register own rbc menu group.
     242                        editor.config.menu_groups = 'scayt_suggest,scayt_moresuggest,scayt_control,' + editor.config.menu_groups;
     243                },
     244
     245                init : function( editor )
     246                {
     247                        var moreSuggestions = {};
     248                        var mainSuggestions = {};
     249
     250                        // Scayt command.
     251                        var command = editor.addCommand( commandName, commandDefinition );
     252
     253                        // Add Options dialog.
     254                        CKEDITOR.dialog.add( commandName, CKEDITOR.getUrl( this.path + 'dialogs/options.js' ) );
     255
     256                        var menuGroup = 'scaytButton';
     257                        editor.addMenuGroup( menuGroup );
     258                        editor.addMenuItems(
     259                                {
     260                                        scaytToggle :
     261                                        {
     262                                                label : editor.lang.scayt.enable,
     263                                                command : commandName,
     264                                                group : menuGroup
     265                                        },
     266                                       
     267                                        scaytOptions :
     268                                        {
     269                                                label : editor.lang.scayt.options,
     270                                                group : menuGroup,
     271                                                onClick : function()
     272                                                {
     273                                                        openPage = 'options';
     274                                                        editor.openDialog( commandName );
     275                                                }
     276                                        },
     277                                       
     278                                        scaytLangs :
     279                                        {
     280                                                label : editor.lang.scayt.langs,
     281                                                group : menuGroup,
     282                                                onClick : function()
     283                                                {
     284                                                        openPage = 'langs';
     285                                                        editor.openDialog( commandName );
     286                                                }
     287                                        },
     288                                       
     289                                        scaytAbout :
     290                                        {
     291                                                label : editor.lang.scayt.about,
     292                                                group : menuGroup,
     293                                                onClick : function()
     294                                                {
     295                                                        openPage = 'about';
     296                                                        editor.openDialog( commandName );
     297                                                }
     298                                        }
     299                                });
     300
     301                        editor.ui.add( "Scayt", CKEDITOR.UI_MENUBUTTON,
     302                                {
     303                                        label : editor.lang.scayt.title,
     304                                        title : editor.lang.scayt.title,
     305                                        className : 'cke_button_scayt',
     306                                        onRender: function()
     307                                        {
     308                                                command.on( 'state', function()
     309                                                        {
     310                                                                this.setState( command.state );
     311                                                        },
     312                                                        this);
     313                                        },
     314                                        onMenu : function()
     315                                        {
     316                                                var isEnabled = plugin.isScaytEnabled( editor );
     317
     318                                                editor.getMenuItem( 'scaytToggle' ).label = editor.lang.scayt[ isEnabled ? 'disable' : 'enable' ];
     319
     320                                                return {
     321                                                        scaytToggle : CKEDITOR.TRISTATE_OFF,
     322                                                        scaytOptions : isEnabled ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
     323                                                        scaytLangs : isEnabled ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED,
     324                                                        scaytAbout : isEnabled ? CKEDITOR.TRISTATE_OFF : CKEDITOR.TRISTATE_DISABLED
     325                                                };
     326                                        }
     327                                });
     328
     329                        // If the "contextmenu" plugin is loaded, register the listeners.
     330                        if ( editor.contextMenu && editor.addMenuItems )
     331                        {
     332                                editor.contextMenu.addListener( function( element, selection )
     333                                        {
     334                                                var scayt_control = plugin.getScayt( editor );
     335                                                if ( !plugin.isScaytEnabled( editor ) || !element || !element.$ )
     336                                                        return null;
     337
     338                                                var word = scayt_control.getWord( element.$ );
     339
     340                                                if ( !word )
     341                                                        return null;
     342
     343                                                var sLang = scayt_control.getLang(),
     344                                                        _r = {},
     345                                                        items_suggestion = scayt.getSuggestion( word, sLang );
     346
     347                                                // Remove unused commands and menuitems
     348                                                for ( i in moreSuggestions )
     349                                                {
     350                                                        delete editor._.menuItems[ i ];
     351                                                        delete editor._.commands[ i ];
     352                                                }
     353                                                for ( i in mainSuggestions )
     354                                                {
     355                                                        delete editor._.menuItems[ i ];
     356                                                        delete editor._.commands[ i ];
     357                                                }
     358                                                moreSuggestions = {};           // Reset items.
     359                                                mainSuggestions = {};
     360
     361                                                // Rgister the More suggestions group;
     362                                                editor.addMenuItem( 'scayt_moresuggest',
     363                                                        {
     364                                                                label : editor.lang.scayt.moreSuggestions,
     365                                                                group : 'scayt_moresuggest',
     366                                                                order : 10,
     367                                                                getItems : function()
     368                                                                {
     369                                                                        return moreSuggestions;
     370                                                                }
     371                                                        });
     372
     373                                                for ( var i = 0, l = items_suggestion.length; i < l; i += 1 )
     374                                                {
     375                                                        var commandName = 'scayt_suggestion_' + items_suggestion[i].replace( " ", "_" );
     376                                                        var exec = ( function( el, s )
     377                                                                {
     378                                                                        return {
     379                                                                                exec: function( editor )
     380                                                                                {
     381                                                                                        scayt_control.replace(el, s);
     382                                                                                }
     383                                                                        };
     384                                                                })( element.$, items_suggestion[i] );
     385
     386                                                        if ( i < editor.config.scayt_maxSuggestions )
     387                                                        {
     388                                                                addButtonCommand( editor, "button_" + commandName, items_suggestion[i],
     389                                                                        commandName, exec, 'scayt_suggest', i + 1 );
     390                                                                _r[ commandName ] = CKEDITOR.TRISTATE_OFF;
     391                                                                mainSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF;
     392                                                        }
     393                                                        else
     394                                                        {
     395                                                                addButtonCommand( editor, "button_" + commandName, items_suggestion[i],
     396                                                                        commandName, exec, 'scayt_moresuggest', i + 1 );
     397                                                                moreSuggestions[ commandName ] = CKEDITOR.TRISTATE_OFF;
     398                                                        }
     399                                                }
     400
     401                                                var ignore_command =
     402                                                {
     403                                                        exec: function()
     404                                                        {
     405                                                                scayt_control.ignore( element.$ );
     406                                                        }
     407                                                };
     408                                                var ignore_all_command =
     409                                                {
     410                                                        exec: function()
     411                                                        {
     412                                                                scayt_control.ignoreAll( element.$ );
     413                                                        }
     414                                                };
     415                                                var addword_command =
     416                                                {
     417                                                        exec: function()
     418                                                        {
     419                                                                scayt.addWordToUserDictionary( element.$ );
     420                                                        }
     421                                                };
     422
     423                                                addButtonCommand( editor, "ignore", editor.lang.scayt.ignore,
     424                                                        'scayt_ignore', ignore_command, 'scayt_control', 1);
     425                                                addButtonCommand( editor, "ignore_all", editor.lang.scayt.ignoreAll,
     426                                                        'scayt_ignore_all', ignore_all_command, 'scayt_control', 2);
     427                                                addButtonCommand( editor, "add_word", editor.lang.scayt.addWord,
     428                                                        'scayt_add_word', addword_command, 'scayt_control', 3);
     429
     430                                                mainSuggestions[ 'scayt_moresuggest' ] = CKEDITOR.TRISTATE_OFF;
     431                                                mainSuggestions[ 'scayt_ignore' ] = CKEDITOR.TRISTATE_OFF;
     432                                                mainSuggestions[ 'scayt_ignore_all' ] = CKEDITOR.TRISTATE_OFF;
     433                                                mainSuggestions[ 'scayt_add_word' ] = CKEDITOR.TRISTATE_OFF;
     434
     435                                                return mainSuggestions;
     436                                        });
     437                        }
     438
     439                        // Start plugin
     440                        if ( editor.config.scayt_autoStartup )
     441                                plugin.loadEngine( editor );
     442                }
     443        });
     444})();
     445
     446CKEDITOR.config.scayt_maxSuggestions = 5;
     447CKEDITOR.config.scayt_autoStartup = false;
  • _source/plugins/showblocks/plugin.js

     
    8888
    8989        var commandDefinition =
    9090        {
     91                preserveState : true,
     92
    9193                exec : function ( editor )
    9294                {
    93                         var isOn = ( this.state == CKEDITOR.TRISTATE_ON );
    94                         var funcName = isOn ? 'removeClass' : 'addClass';
     95                        this.toggleState();
     96                        this.refresh( editor );
     97                },
     98               
     99                refresh : function( editor )
     100                {
     101                        var funcName = ( this.state == CKEDITOR.TRISTATE_ON ) ? 'addClass' : 'removeClass';
    95102                        editor.document.getBody()[funcName]( 'cke_show_blocks' );
    96 
    97                         this.toggleState();
    98                         editor._.showBlocks = !isOn;
    99103                }
    100104        };
    101105
     
    107111                {
    108112                        var command = editor.addCommand( 'showblocks', commandDefinition );
    109113
     114                        if ( editor.config.startupOutlineBlocks )
     115                                command.setState( CKEDITOR.TRISTATE_ON );
     116
    110117                        editor.addCss( cssTemplate
    111118                                .replace( cssTemplateRegex, 'background-image: url(' + CKEDITOR.getUrl( this.path ) + 'images/block_' )
    112                                    .replace( cssClassRegex, 'cke_show_blocks ' ) );
     119                                .replace( cssClassRegex, 'cke_show_blocks ' ) );
    113120
    114                         // Set a flag in the editor object for remembering the show block state on
    115                         // mode switches.
    116                         editor._.showBlocks = editor.config.startupOutlineBlocks;
    117 
    118121                        editor.ui.addButton( 'ShowBlocks',
    119122                                {
    120123                                        label : editor.lang.showBlocks,
    121124                                        command : 'showblocks'
    122                                 } );
     125                                });
    123126
    124                         // Restore the command state after mode change.
     127                        // Refresh the command on mode changes.
    125128                        editor.on( 'mode', function()
    126                         {
    127                                 if ( editor.mode == 'wysiwyg' && this._.showBlocks )
    128                                         command.exec();
    129                         }, null, null, 100 );
     129                                {
     130                                        if ( command.state != CKEDITOR.TRISTATE_DISABLED )
     131                                                command.refresh( editor );
     132                                });
    130133                }
    131134        });
    132135} )();
  • _source/plugins/toolbar/plugin.js

     
    277277CKEDITOR.config.toolbar_Full =
    278278[
    279279        ['Source','-','Save','NewPage','Preview','-','Templates'],
    280         ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker'],
     280        ['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
    281281        ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
    282282        ['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
    283283        '/',
  • _source/skins/office2003/icons.css

     
    143143        background-position: 0 -176px;
    144144}
    145145
    146 .cke_skin_office2003 .cke_button_checkspell .cke_icon
     146.cke_skin_office2003 .cke_button_checkspell .cke_icon,
     147.cke_skin_office2003 .cke_button_scayt .cke_icon
    147148{
    148149        background-position: 0 -192px;
    149150}
  • _source/skins/v2/icons.css

     
    143143        background-position: 0 -176px;
    144144}
    145145
    146 .cke_skin_v2 .cke_button_checkspell .cke_icon
     146.cke_skin_v2 .cke_button_checkspell .cke_icon,
     147.cke_skin_v2 .cke_button_scayt .cke_icon
    147148{
    148149        background-position: 0 -192px;
    149150}
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy