Ticket #4594: 4594_2.patch

File 4594_2.patch, 4.7 KB (added by Garry Yao, 14 years ago)
  • _source/plugins/menu/plugin.js

     
    9797                                // Get the element representing the current item.
    9898                                var element = this._.panel.getBlock( this.id ).element.getDocument().getById( this.id + String( index ) );
    9999
    100                                 // Show the submenu.
    101                                 menu.show( element, 2 );
     100                                // Show the submenu, reverse the 'corner' when necessary.
     101                                menu.show( element, this._.reverse ? 1 : 2 );
     102                                // Inheirit the reverse from parent menu.
     103                                menu._.reverse = this._.reverse;
    102104                        }
    103105                },
    104106
     
    147149
    148150                                        panel.onHide = CKEDITOR.tools.bind( function()
    149151                                        {
     152                                                delete this._.reverse;
    150153                                                this.onHide && this.onHide();
    151154                                        },
    152155                                        this );
     
    227230                                // Inject the HTML inside the panel.
    228231                                element.setHtml( output.join( '' ) );
    229232
     233                                // Off-screen menu support. (#4594)
     234                                panel.on( 'position', function ( evt )
     235                                {
     236                                        evt.removeListener();
     237
     238                                        var left = evt.data.left,
     239                                                top = evt.data.top,
     240                                                panelElement = panel.element,
     241                                                rtl = panel._.dir == 'rtl',
     242                                                viewportSize = panelElement.getWindow().getViewPaneSize();
     243
     244                                        var panelSize =
     245                                        {
     246                                                'height' : panelElement.$.offsetHeight,
     247                                                'width' : panelElement.$.offsetWidth
     248                                        };
     249
     250                                        // Reverse the 'rtl' offsets.
     251                                        if ( this._.reverse )
     252                                        {
     253                                                left += ( panelSize.width * ( rtl ? 1 : -1 ) );
     254                                        }
     255                                        // If the menu is horizontal off, shift it toward the opposite direction,
     256                                        // meanwhile ask subsequent sub-menus to be opened in the reverse way.
     257                                        else if ( rtl ? left < 0 : left + panelSize.width > viewportSize.width )
     258                                        {
     259                                                left += ( panelSize.width * ( rtl ? 1 : -1 ) );
     260                                                this._.reverse = true;
     261                                        }
     262
     263                                        // Vertical off screen is simpler.
     264                                        if( top + panelSize.height > viewportSize.height )
     265                                                top -= panelSize.height;
     266                                       
     267                                        evt.data = { left : left, top : top };
     268
     269                                }, this );
     270
     271
    230272                                // Show the panel.
    231273                                if ( this.parent )
    232274                                        this.parent._.panel.showAsChild( panel, this.id, offsetParent, corner, offsetX, offsetY );
    233275                                else
    234276                                        panel.showBlock( this.id, offsetParent, corner, offsetX, offsetY );
    235 
     277                               
    236278                                editor.fire( 'menuShow', [ panel ] );
    237279                        },
    238280
  • _source/plugins/floatpanel/plugin.js

     
    195195                                                if ( rtl )
    196196                                                        left -= element.$.offsetWidth;
    197197
    198                                                 element.setStyles(
    199                                                         {
    200                                                                 left : left + 'px',
    201                                                                 visibility      : '',
    202                                                                 opacity : '1'   // FF3 is ignoring "visibility"
    203                                                         });
     198                                                var panelLoad = CKEDITOR.tools.bind( function ()
     199                                                {
     200                                                        if ( this.onShow )
     201                                                                this.onShow.call( this );
    204202
    205                                                 if ( block.autoSize )
    206                                                 {
    207                                                         function setHeight()
    208                                                         {
     203                                                        if ( block.autoSize )
     204                                                        {
    209205                                                                var target = element.getFirst();
    210206                                                                var height = block.element.$.scrollHeight;
    211207
     
    220216                                                                // Fix IE < 8 visibility.
    221217                                                                panel._.currentBlock.element.setStyle( 'display', 'none' ).removeStyle( 'display' );
    222218                                                        }
    223 
    224                                                         if ( panel.isLoaded )
    225                                                                 setHeight();
    226219                                                        else
    227                                                                 panel.onLoad = setHeight;
    228                                                 }
    229                                                 else
    230                                                         element.getFirst().removeStyle( 'height' );
     220                                                                element.getFirst().removeStyle( 'height' );
    231221
     222                                                        // The panel size has been known for now,
     223                                                        // allow futher manipulating the position,
     224                                                        // e.g. off-screen adjustment for context menu.
     225                                                        var position = this.fire( 'position', { top : top, left : left } );
     226
     227                                                        element.setStyles(
     228                                                                {
     229                                                                        top : ( position ? position.top : top ) + 'px',
     230                                                                        left : ( position ? position.left : left ) + 'px',
     231                                                                        visibility      : '',
     232                                                                        opacity : '1'   // FF3 is ignoring "visibility"
     233                                                                } );
     234
     235                                                        isShowing = false;
     236                                                } , this );
     237
     238                                                panel.isLoaded ? panelLoad() : panel.onLoad = panelLoad;
    232239                                                // Set the IFrame focus, so the blur event gets fired.
    233240                                                CKEDITOR.tools.setTimeout( function()
    234241                                                        {
     
    255262                                        }, 0, this);
    256263                                this.visible = 1;
    257264
    258                                 if ( this.onShow )
    259                                         this.onShow.call( this );
    260 
    261                                 isShowing = false;
    262265                        },
    263266
    264267                        hide : function()
     
    329332                        }
    330333                }
    331334        });
     335        CKEDITOR.event.implementOn( CKEDITOR.ui.floatPanel.prototype, true );
    332336})();
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy