Ticket #8629: 8629.patch

File 8629.patch, 2.3 KB (added by Garry Yao, 12 years ago)
  • _source/plugins/floatpanel/plugin.js

    IDEA additional info:
    Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
    <+>UTF-8
     
    247247                                                        else
    248248                                                                target.removeStyle( 'height' );
    249249
     250                                                        // Place for measurement.
     251                                                        element.setStyle( 'left', CKEDITOR.tools.cssLength( left ) );
     252
    250253                                                        var panelElement = panel.element,
    251254                                                                panelWindow = panelElement.getWindow(),
    252                                                                 windowScroll = panelWindow.getScrollPosition(),
    253                                                                 viewportSize = panelWindow.getViewPaneSize(),
    254                                                                 panelSize =
    255                                                                 {
    256                                                                         'height' : panelElement.$.offsetHeight,
    257                                                                         'width' : panelElement.$.offsetWidth
    258                                                                 };
     255                                                                rect = element.$.getBoundingClientRect(),
     256                                                                viewportSize = panelWindow.getViewPaneSize();
    259257
    260                                                         // If the menu is horizontal off, shift it toward
    261                                                         // the opposite language direction.
    262                                                         if ( rtl ? left < 0 : left + panelSize.width > viewportSize.width + windowScroll.x )
    263                                                                 left += ( panelSize.width * ( rtl ? 1 : -1 ) );
     258                                                        // Compensation for browsers that dont support "width" and "height".
     259                                                        var rectWidth = rect.width || rect.right - rect.left,
     260                                                        rectHeight = rect.height || rect.bottom - rect.top;
    264261
    265                                                         // Vertical off screen is simpler.
    266                                                         if ( top + panelSize.height > viewportSize.height + windowScroll.y )
    267                                                                 top -= panelSize.height;
     262                                                        // Check to flip the panel display direction to opposite side
     263                                                        // when there's not enough space available.
     264                                                        var spaceAfter = rtl ? rect.right : viewportSize.width - rect.left,
     265                                                                spaceBefore = rtl ? viewportSize.width - rect.right : rect.left;
     266
     267                                                        // Flip horizontally.
     268                                                        if ( spaceAfter - rectWidth < 0 && spaceBefore > spaceAfter )
     269                                                                left += ( rectWidth * ( rtl ? 1 : -1 ) );
     270
     271                                                        // Flip vertically.
     272                                                        var spaceBelow = viewportSize.height - rect.top,
     273                                                                spaceAbove = rect.top;
     274
     275                                                        if ( spaceBelow - rectHeight < 0 && spaceAbove > spaceBelow )
     276                                                                top -= rectHeight;
    268277
    269278                                                        // If IE is in R™TL, we have troubles with absolute
    270279                                                        // position and horizontal scrolls. Here we have a
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy