Ticket #635: 635_3.patch

File 635_3.patch, 10.2 KB (added by Minh Nguyen, 14 years ago)
  • _source/plugins/dialog/plugin.js

     
    12491249                        addUIElement : function( typeName, builder )
    12501250                        {
    12511251                                this._.uiElementBuilders[ typeName ] = builder;
     1252                        },
     1253                       
     1254                        /**
     1255                         * Registers function for detect dialog via selection.
     1256                         * @param {Function} func The function listener.
     1257                         * @example
     1258                         */
     1259                        addDetection : function( func )
     1260                        {
     1261                                this._.dialogDetections.push( func );
     1262                        },
     1263                       
     1264                        autoDetect : function( element, selection )
     1265                        {
     1266                                if ( !element || !selection ) return null;
     1267                                var detections = this._.dialogDetections,
     1268                                        dialogDefinitions = this._.dialogDefinitions;
     1269                                for ( var i = 0; i < detections.length; ++ i )
     1270                                {
     1271                                        var detectItems = detections[ i ]( element, selection );
     1272                                        if ( detectItems )
     1273                                                for ( var itemName in detectItems )
     1274                                                        if (itemName in dialogDefinitions )
     1275                                                                return itemName;
     1276                                }
     1277                                return null;
    12521278                        }
    12531279                });
    12541280
     
    12571283                uiElementBuilders : {},
    12581284
    12591285                dialogDefinitions : {},
    1260 
     1286               
     1287                dialogDetections : [],
     1288               
    12611289                currentTop : null,
    12621290
    12631291                currentZIndex : null
  • _source/plugins/flash/plugin.js

     
    7676                                                }
    7777                                        });
    7878                        }
    79 
     79                       
     80                        var listener = function( element, selection )
     81                                {
     82                                        if ( element && element.is( 'img' ) && element.getAttribute( '_cke_real_element_type' ) == 'flash' )
     83                                                return { flash : CKEDITOR.TRISTATE_OFF };
     84                                };
     85                               
     86                        // Register for auto detect dialog.
     87                        CKEDITOR.dialog.addDetection( listener );
     88               
    8089                        // If the "contextmenu" plugin is loaded, register the listeners.
    8190                        if ( editor.contextMenu )
    8291                        {
    83                                 editor.contextMenu.addListener( function( element, selection )
    84                                         {
    85                                                 if ( element && element.is( 'img' ) && element.getAttribute( '_cke_real_element_type' ) == 'flash' )
    86                                                         return { flash : CKEDITOR.TRISTATE_OFF };
    87                                         });
     92                                editor.contextMenu.addListener( listener );
    8893                        }
    8994                },
    9095
  • _source/plugins/forms/plugin.js

     
    114114                                        }
    115115                                });
    116116                }
    117 
    118                 // If the "contextmenu" plugin is loaded, register the listeners.
    119                 if ( editor.contextMenu )
    120                 {
    121                         editor.contextMenu.addListener( function( element )
     117               
     118                var formListener = function( element )
     119                        {
     120                                if ( element && element.hasAscendant( 'form', true ) )
     121                                        return { form : CKEDITOR.TRISTATE_OFF };
     122                        };
     123               
     124                var inputListener = function( element )
     125                        {
     126                                if ( element )
    122127                                {
    123                                         if ( element && element.hasAscendant( 'form', true ) )
    124                                                 return { form : CKEDITOR.TRISTATE_OFF };
    125                                 });
     128                                        var name = element.getName();
    126129
    127                         editor.contextMenu.addListener( function( element )
    128                                 {
    129                                         if ( element )
    130                                         {
    131                                                 var name = element.getName();
     130                                        if ( name == 'select' )
     131                                                return { select : CKEDITOR.TRISTATE_OFF };
    132132
    133                                                 if ( name == 'select' )
    134                                                         return { select : CKEDITOR.TRISTATE_OFF };
     133                                        if ( name == 'textarea' )
     134                                                return { textarea : CKEDITOR.TRISTATE_OFF };
    135135
    136                                                 if ( name == 'textarea' )
    137                                                         return { textarea : CKEDITOR.TRISTATE_OFF };
     136                                        if ( name == 'input' )
     137                                        {
     138                                                var type = element.getAttribute( 'type' );
    138139
    139                                                 if ( name == 'input' )
    140                                                 {
    141                                                         var type = element.getAttribute( 'type' );
     140                                                if ( type == 'text' || type == 'password' )
     141                                                        return { textfield : CKEDITOR.TRISTATE_OFF };
    142142
    143                                                         if ( type == 'text' || type == 'password' )
    144                                                                 return { textfield : CKEDITOR.TRISTATE_OFF };
     143                                                if ( type == 'button' || type == 'submit' || type == 'reset' )
     144                                                        return { button : CKEDITOR.TRISTATE_OFF };
    145145
    146                                                         if ( type == 'button' || type == 'submit' || type == 'reset' )
    147                                                                 return { button : CKEDITOR.TRISTATE_OFF };
     146                                                if ( type == 'checkbox' )
     147                                                        return { checkbox : CKEDITOR.TRISTATE_OFF };
    148148
    149                                                         if ( type == 'checkbox' )
    150                                                                 return { checkbox : CKEDITOR.TRISTATE_OFF };
     149                                                if ( type == 'radio' )
     150                                                        return { radio : CKEDITOR.TRISTATE_OFF };
    151151
    152                                                         if ( type == 'radio' )
    153                                                                 return { radio : CKEDITOR.TRISTATE_OFF };
     152                                                if ( type == 'image' )
     153                                                        return { imagebutton : CKEDITOR.TRISTATE_OFF };
     154                                        }
    154155
    155                                                         if ( type == 'image' )
    156                                                                 return { imagebutton : CKEDITOR.TRISTATE_OFF };
    157                                                 }
    158 
    159                                                 if ( name == 'img' && element.getAttribute( '_cke_real_element_type' ) == 'hiddenfield' )
    160                                                         return { hiddenfield : CKEDITOR.TRISTATE_OFF };
    161                                         }
    162                                 });
     156                                        if ( name == 'img' && element.getAttribute( '_cke_real_element_type' ) == 'hiddenfield' )
     157                                                return { hiddenfield : CKEDITOR.TRISTATE_OFF };
     158                                }
     159                        };
     160                       
     161                // Register for auto detect dialog.
     162                CKEDITOR.dialog.addDetection( formListener );
     163                CKEDITOR.dialog.addDetection( inputListener );
     164               
     165                // If the "contextmenu" plugin is loaded, register the listeners.
     166                if ( editor.contextMenu )
     167                {
     168                        editor.contextMenu.addListener( formListener );
     169                        editor.contextMenu.addListener( inputListener );
    163170                }
    164171        },
    165172
  • _source/plugins/image/plugin.js

     
    3939                                        }
    4040                                });
    4141                }
    42 
     42               
     43                var listener = function( element, selection )
     44                        {
     45                                if ( !element || !element.is( 'img' ) || element.getAttribute( '_cke_realelement' ) )
     46                                        return null;
     47               
     48                                return { image : CKEDITOR.TRISTATE_OFF };
     49                        };
     50                       
     51                // Register for auto detect dialog.
     52                CKEDITOR.dialog.addDetection( listener );
     53               
    4354                // If the "contextmenu" plugin is loaded, register the listeners.
    4455                if ( editor.contextMenu )
    4556                {
    46                         editor.contextMenu.addListener( function( element, selection )
    47                                 {
    48                                         if ( !element || !element.is( 'img' ) || element.getAttribute( '_cke_realelement' ) )
    49                                                 return null;
    50 
    51                                         return { image : CKEDITOR.TRISTATE_OFF };
    52                                 });
     57                        editor.contextMenu.addListener( listener );
    5358                }
    5459        }
    5560} );
  • _source/plugins/link/plugin.js

     
    9595                                });
    9696                }
    9797
    98                 // If the "contextmenu" plugin is loaded, register the listeners.
    99                 if ( editor.contextMenu )
    100                 {
    101                         editor.contextMenu.addListener( function( element, selection )
     98                var listener = function( element, selection )
     99                        {
     100                                if ( !element )
     101                                        return null;
     102
     103                                var isAnchor = ( element.is( 'img' ) && element.getAttribute( '_cke_real_element_type' ) == 'anchor' );
     104
     105                                if ( !isAnchor )
    102106                                {
    103                                         if ( !element )
     107                                        if ( !( element = element.getAscendant( 'a', true ) ) )
    104108                                                return null;
    105109
    106                                         var isAnchor = ( element.is( 'img' ) && element.getAttribute( '_cke_real_element_type' ) == 'anchor' );
     110                                        isAnchor = ( element.getAttribute( 'name' ) && !element.getAttribute( 'href' ) );
     111                                }
    107112
    108                                         if ( !isAnchor )
    109                                         {
    110                                                 if ( !( element = element.getAscendant( 'a', true ) ) )
    111                                                         return null;
    112 
    113                                                 isAnchor = ( element.getAttribute( 'name' ) && !element.getAttribute( 'href' ) );
    114                                         }
    115 
    116                                         return isAnchor ?
    117                                                         { anchor : CKEDITOR.TRISTATE_OFF } :
    118                                                         { link : CKEDITOR.TRISTATE_OFF, unlink : CKEDITOR.TRISTATE_OFF };
    119                                 });
     113                                return isAnchor ?
     114                                                { anchor : CKEDITOR.TRISTATE_OFF } :
     115                                                { link : CKEDITOR.TRISTATE_OFF, unlink : CKEDITOR.TRISTATE_OFF };
     116                        };
     117                       
     118                // Register for auto detect dialog.
     119                CKEDITOR.dialog.addDetection( listener );
     120                       
     121                // If the "contextmenu" plugin is loaded, register the listeners.
     122                if ( editor.contextMenu )
     123                {
     124                        editor.contextMenu.addListener( listener );
    120125                }
    121126        },
    122127
  • _source/plugins/table/plugin.js

     
    4444                                        }
    4545                                } );
    4646                }
     47                       
     48                var listener = function( element, selection )
     49                        {
     50                                if ( !element )
     51                                        return null;
    4752
     53                                var isTable     = element.is( 'table' ) || element.hasAscendant( 'table' );
     54
     55                                if ( isTable )
     56                                {
     57                                        return {
     58                                                tabledelete : CKEDITOR.TRISTATE_OFF,
     59                                                table : CKEDITOR.TRISTATE_OFF
     60                                        };
     61                                }
     62
     63                                return null;
     64                        };
     65               
     66                // Register for auto detect dialog.
     67                CKEDITOR.dialog.addDetection( listener );
     68               
    4869                // If the "contextmenu" plugin is loaded, register the listeners.
    4970                if ( editor.contextMenu )
    5071                {
    51                         editor.contextMenu.addListener( function( element, selection )
    52                                 {
    53                                         if ( !element )
    54                                                 return null;
    55 
    56                                         var isTable     = element.is( 'table' ) || element.hasAscendant( 'table' );
    57 
    58                                         if ( isTable )
    59                                         {
    60                                                 return {
    61                                                         tabledelete : CKEDITOR.TRISTATE_OFF,
    62                                                         table : CKEDITOR.TRISTATE_OFF
    63                                                 };
    64                                         }
    65 
    66                                         return null;
    67                                 } );
     72                        editor.contextMenu.addListener( listener );
    6873                }
    6974        }
    7075} );
  • _source/plugins/wysiwygarea/plugin.js

     
    369369                                                        } );
    370370                                                }
    371371
     372                                                domDocument.on( 'dblclick', function(ev)
     373                                                {
     374                                                        var element = ev.data.getTarget(),
     375                                                                selection = editor.getSelection();
     376                                                                dialogName = CKEDITOR.dialog.autoDetect( element, selection );
     377                                                               
     378                                                        if ( dialogName ) editor.openDialog( dialogName );
     379                                                });
     380                                               
     381                                               
    372382                                                // Webkit: avoid from editing form control elements content.
    373383                                                if ( CKEDITOR.env.webkit )
    374384                                                {
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy