Ticket #5395: 5395.patch

File 5395.patch, 3.2 KB (added by Garry Yao, 14 years ago)
  • _source/core/dom/domobject.js

     
    245245                return this.$._cke_expando || ( this.$._cke_expando = CKEDITOR.tools.getNextNumber() );
    246246        };
    247247
     248        /**
     249         * Feature detecting the availability of the specified event on this document/element.
     250         * @param {String} eventName
     251         * @return {Boolean} true if event is supported
     252         */
     253        domObjectProto.supports = (function()
     254        {
     255                var cache = {};
     256                function isEventSupported( eventName )
     257                {
     258                        var type = this.$.nodeType;
     259                        if ( !( type == CKEDITOR.NODE_DOCUMENT ||
     260                                        type == CKEDITOR.NODE_DOCUMENT ) )
     261                                return false;
     262
     263                        eventName = 'on' + eventName;
     264
     265                        var element = this.$,
     266                                nodeName = element.nodeName;
     267
     268                        // return cached result.
     269                        if ( nodeName in cache )
     270                                return cache[ nodeName ];
     271
     272                        // When using `setAttribute`, IE skips "unload",
     273                        // WebKit skips "unload" and "resize", whereas `in` "catches" those
     274                        var isSupported = ( eventName in element );
     275
     276                        if ( !isSupported )
     277                        {
     278                                // if it has no `setAttribute` (i.e. doesn't implement Node interface), try generic element
     279                                if ( !element.setAttribute )
     280                                        element = document.createElement( 'div' );
     281                                if ( element.setAttribute && element.removeAttribute )
     282                                {
     283                                        element.setAttribute( eventName, '' );
     284                                        isSupported = typeof element[ eventName ] == 'function';
     285
     286                                        // if property was created, "remove it" (by setting value to `undefined`)
     287                                        if ( typeof element[ eventName ] != 'undefined' )
     288                                                element[ eventName ] = undefined;
     289                                        element.removeAttribute( eventName );
     290                                }
     291                        }
     292
     293                        element = null;
     294                        return ( cache[ nodeName ] = isSupported );
     295                }
     296
     297                return isEventSupported;
     298        })()
     299
    248300        // Implement CKEDITOR.event.
    249301        CKEDITOR.event.implementOn( domObjectProto );
    250302
  • _source/plugins/contextmenu/plugin.js

     
    147147        {
    148148                addTarget : function( element, nativeContextMenuOnCtrl )
    149149                {
    150                         // Opera doesn't support 'contextmenu' event, we have duo approaches employed here:
    151                         // 1. Inherit the 'button override' hack we introduced in v2 (#4530), while this require the Opera browser
    152                         //  option 'Allow script to detect context menu/right click events' to be always turned on.
     150                        // For browsers (Opera <=10a) that doesn't support 'contextmenu' event, we have duo approaches employed here:
     151                        // 1. Inherit the 'button override' hack we introduced in v2 (#4530) (In Opera browser, this require the
     152                        //  option 'Allow script to detect context menu/right click events' to be always turned on).
    153153                        // 2. Considering the fact that ctrl/meta key is not been occupied
    154154                        //  for multiple range selecting (like Gecko), we use this key
    155155                        //  combination as a fallback for triggering context-menu. (#4530)
    156                         if ( CKEDITOR.env.opera )
     156                        if ( !element.supports( 'contextmenu' ) )
    157157                        {
    158158                                var contextMenuOverrideButton;
    159159                                element.on( 'mousedown', function( evt )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy