Ticket #5084: 5084_4.patch

File 5084_4.patch, 12.5 KB (added by Sa'ar Zac Elias, 13 years ago)
  • 3.5.x/_source/plugins/dialog/plugin.js

     
    666666                 * @function
    667667                 * @param {Number} x The target x-coordinate.
    668668                 * @param {Number} y The target y-coordinate.
     669                 * @param {Boolean} internal Whether this is an internal moving, which should not indicate that the dialog has been actually moved.
    669670                 * @example
    670671                 * dialogObj.move( 10, 40 );
    671672                 */
    672673                move : (function()
    673674                {
    674675                        var isFixed;
    675                         return function( x, y )
     676                        return function( x, y, internal )
    676677                        {
    677678                                // The dialog may be fixed positioned or absolute positioned. Ask the
    678679                                // browser what is the current situation first.
     
    699700                                                        'left'  : ( x > 0 ? x : 0 ) + 'px',
    700701                                                        'top'   : ( y > 0 ? y : 0 ) + 'px'
    701702                                                });
     703
     704                                !internal && ( this._.moved = 1 );
    702705                        };
    703706                })(),
    704707
     
    745748
    746749
    747750                        // First, set the dialog to an appropriate size.
    748                         this.resize( definition.minWidth, definition.minHeight );
     751                        this.resize( this._.contentSize && this._.contentSize.width || definition.minWidth,
     752                                        this._.contentSize && this._.contentSize.height || definition.minHeight );
    749753
    750754                        // Reset all inputs back to their default value.
    751755                        this.reset();
     
    790794                        // Reset the hasFocus state.
    791795                        this._.hasFocus = false;
    792796
    793                         // Rearrange the dialog to the middle of the window.
     797                        // Rearrange the dialog to its previous position or the middle of the window on first opening.
    794798                        CKEDITOR.tools.setTimeout( function()
    795799                                {
    796800                                        var viewSize = CKEDITOR.document.getWindow().getViewPaneSize();
     
    798802
    799803                                        // We're using definition size for initial position because of
    800804                                        // offten corrupted data in offsetWidth at this point. (#4084)
    801                                         this.move( ( viewSize.width - definition.minWidth ) / 2, ( viewSize.height - dialogSize.height ) / 2 );
     805                                        this.move( this._.position ? this._.position.x : ( viewSize.width - definition.minWidth ) / 2 ,
     806                                                        this._.position ? this._.position.y : ( viewSize.height - dialogSize.height ) / 2, 1 );
    802807
    803808                                        this.parts.dialog.setStyle( 'visibility', '' );
    804809
     
    16991704
    17001705        function initResizeHandles( dialog )
    17011706        {
    1702                 var definition = dialog.definition,
    1703                         minWidth = definition.minWidth || 0,
    1704                         minHeight = definition.minHeight || 0,
    1705                         resizable = definition.resizable,
    1706                         margins = dialog.getParentEditor().skin.margins || [ 0, 0, 0, 0 ];
     1707                var def = dialog.definition,
     1708                        resizable = def.resizable;
     1709                if ( resizable == CKEDITOR.DIALOG_RESIZE_NONE )
     1710                        return;
    17071711
    1708                 function topSizer( coords, dy )
    1709                 {
    1710                         coords.y += dy;
    1711                 }
     1712                var editor = dialog.getParentEditor(),
     1713                        minHeight = def.minHeight || 0,
     1714                        minWidth = def.minWidth || 0,
     1715                        margin = editor.skin.margins || [ 0, 0, 0, 0 ],
     1716                        wrapperWidth, wrapperHeight, viewSize, origin;
    17121717
    1713                 function rightSizer( coords, dx )
     1718                function positionDialog( right )
    17141719                {
    1715                         coords.x2 += dx;
     1720                        // Maintain righthand sizing in RTL.
     1721                        if ( dialog._.moved && editor.lang.dir == 'rtl' )
     1722                        {
     1723                                var element = dialog._.element.getFirst();
     1724                                element.setStyle( 'right', right );
     1725                                element.removeStyle( 'left' );
     1726                        }
     1727                        else if ( !dialog._.moved )
     1728                        {
     1729                                var dialogSize = dialog.getSize();
     1730                                dialog.move( ( viewSize.width - dialogSize.width ) / 2 + margin[ 0 ], ( viewSize.height - dialogSize.height ) / 2 + margin[ 1 ] , 1 );
     1731                        }
    17161732                }
    17171733
    1718                 function bottomSizer( coords, dy )
     1734                var mouseDownFn = CKEDITOR.tools.addFunction( function( $event )
    17191735                {
    1720                         coords.y2 += dy;
    1721                 }
     1736                        origin = { x : $event.screenX, y : $event.screenY };
    17221737
    1723                 function leftSizer( coords, dx )
    1724                 {
    1725                         coords.x += dx;
    1726                 }
     1738                        dialog._.updateSize = true;
     1739                        startSize = dialog.getSize();
    17271740
    1728                 var lastCoords = null,
    1729                         abstractDialogCoords = null,
    1730                         magnetDistance = dialog._.editor.config.magnetDistance,
    1731                         parts = [ 'tl', 't', 'tr', 'l', 'r', 'bl', 'b', 'br' ];
     1741                        viewSize = CKEDITOR.document.getWindow().getViewPaneSize();
    17321742
    1733                 function mouseDownHandler( evt )
    1734                 {
    1735                         var partName = evt.listenerData.part, size = dialog.getSize();
    1736                         abstractDialogCoords = dialog.getPosition();
    1737                         CKEDITOR.tools.extend( abstractDialogCoords,
    1738                                 {
    1739                                         x2 : abstractDialogCoords.x + size.width,
    1740                                         y2 : abstractDialogCoords.y + size.height
    1741                                 } );
    1742                         lastCoords = { x : evt.data.$.screenX, y : evt.data.$.screenY };
     1743                        CKEDITOR.document.on( 'mousemove', mouseMoveHandler );
     1744                        CKEDITOR.document.on( 'mouseup', mouseUpHandler );
    17431745
    1744                         CKEDITOR.document.on( 'mousemove', mouseMoveHandler, dialog, { part : partName } );
    1745                         CKEDITOR.document.on( 'mouseup', mouseUpHandler, dialog, { part : partName } );
    1746 
    17471746                        if ( CKEDITOR.env.ie6Compat )
    17481747                        {
    17491748                                var coverDoc = currentCover.getChild( 0 ).getFrameDocument();
    1750                                 coverDoc.on( 'mousemove', mouseMoveHandler, dialog, { part : partName } );
    1751                                 coverDoc.on( 'mouseup', mouseUpHandler, dialog, { part : partName } );
     1749                                coverDoc.on( 'mousemove', mouseMoveHandler );
     1750                                coverDoc.on( 'mouseup', mouseUpHandler );
    17521751                        }
    17531752
    1754                         evt.data.preventDefault();
    1755                 }
     1753                        $event.preventDefault && $event.preventDefault();
     1754                });
    17561755
    1757                 function mouseMoveHandler( evt )
     1756                // Prepend the grip to the dialog.
     1757                dialog.on( 'load', function()
    17581758                {
    1759                         var x = evt.data.$.screenX,
    1760                                 y = evt.data.$.screenY,
    1761                                 dx = x - lastCoords.x,
    1762                                 dy = y - lastCoords.y,
    1763                                 viewPaneSize = CKEDITOR.document.getWindow().getViewPaneSize(),
    1764                                 partName = evt.listenerData.part;
     1759                        var direction = '';
     1760                        if ( resizable == CKEDITOR.DIALOG_RESIZE_WIDTH )
     1761                                direction = ' cke_resizer_horizontal';
     1762                        else if ( resizable == CKEDITOR.DIALOG_RESIZE_HEIGHT )
     1763                                direction = ' cke_resizer_vertical';
     1764                        var resizer = CKEDITOR.dom.element.createFromHtml( '<div class="cke_resizer' + direction + '"' +
     1765                                        ' title="' + CKEDITOR.tools.htmlEncode( editor.lang.resize ) + '"' +
     1766                                        ' onmousedown="CKEDITOR.tools.callFunction(' + mouseDownFn + ', event )"></div>' );
     1767                        dialog.parts.footer.append( resizer, 1 );
    17651768
    1766                         if ( partName.search( 't' ) != -1 )
    1767                                 topSizer( abstractDialogCoords, dy );
    1768                         if ( partName.search( 'l' ) != -1 )
    1769                                 leftSizer( abstractDialogCoords, dx );
    1770                         if ( partName.search( 'b' ) != -1 )
    1771                                 bottomSizer( abstractDialogCoords, dy );
    1772                         if ( partName.search( 'r' ) != -1 )
    1773                                 rightSizer( abstractDialogCoords, dx );
     1769                        var dialogSize = dialog.getSize();
     1770                        wrapperHeight = dialogSize.height - dialog.parts.contents.$.offsetHeight;
     1771                        wrapperWidth = dialogSize.width - dialog.parts.contents.$.offsetWidth;
     1772                });
     1773                editor.on( 'destroy', function() { CKEDITOR.tools.removeFunction( mouseDownFn ); } );
    17741774
    1775                         lastCoords = { x : x, y : y };
     1775                function mouseMoveHandler( evt )
     1776                {
     1777                        var rtl = editor.lang.dir == 'rtl',
     1778                                dx = ( evt.data.$.screenX - origin.x ) * ( rtl ? -1 : 1 ),
     1779                                dy = evt.data.$.screenY - origin.y,
     1780                                width = startSize.width,
     1781                                height = startSize.height,
     1782                                internalWidth = width + dx * ( dialog._.moved ? 1 : 2 ),
     1783                                internalHeight = height + dy * ( dialog._.moved ? 1 : 2 ),
     1784                                right = rtl && dialog._.element.getFirst().getComputedStyle( 'right' );
     1785                                position = dialog.getPosition();
    17761786
    1777                         var realX, realY, realX2, realY2;
     1787                        if ( internalHeight > viewSize.height - margin[1] - margin[3] )
     1788                                internalHeight = viewSize.height - margin[1] - margin[3];
     1789                        else if ( position.y + internalHeight > viewSize.height - margin[1] - margin[3] )
     1790                                internalHeight = viewSize.height - margin[3] - position.y;
    17781791
    1779                         if ( abstractDialogCoords.x + margins[3] < magnetDistance )
    1780                                 realX = - margins[3];
    1781                         else if ( partName.search( 'l' ) != -1 && abstractDialogCoords.x2 - abstractDialogCoords.x < minWidth + magnetDistance )
    1782                                 realX = abstractDialogCoords.x2 - minWidth;
    1783                         else
    1784                                 realX = abstractDialogCoords.x;
     1792                        if ( internalWidth > viewSize.width - margin[0] - margin[2] )
     1793                                internalWidth = viewSize.width - margin[0] - margin[2];
     1794                        else if ( ( rtl ? right : position.x ) + internalWidth > viewSize.width - margin[0] - margin[2] )
     1795                                internalWidth = viewSize.width - margin[2] - ( rtl ? right : position.x );
    17851796
    1786                         if ( abstractDialogCoords.y + margins[0] < magnetDistance )
    1787                                 realY = - margins[0];
    1788                         else if ( partName.search( 't' ) != -1 && abstractDialogCoords.y2 - abstractDialogCoords.y < minHeight + magnetDistance )
    1789                                 realY = abstractDialogCoords.y2 - minHeight;
    1790                         else
    1791                                 realY = abstractDialogCoords.y;
     1797                        if ( resizable == CKEDITOR.DIALOG_RESIZE_WIDTH || resizable == CKEDITOR.DIALOG_RESIZE_BOTH )
     1798                                width = Math.max( minWidth, internalWidth );
    17921799
    1793                         if ( abstractDialogCoords.x2 - margins[1] > viewPaneSize.width - magnetDistance )
    1794                                 realX2 = viewPaneSize.width + margins[1] ;
    1795                         else if ( partName.search( 'r' ) != -1 && abstractDialogCoords.x2 - abstractDialogCoords.x < minWidth + magnetDistance )
    1796                                 realX2 = abstractDialogCoords.x + minWidth;
    1797                         else
    1798                                 realX2 = abstractDialogCoords.x2;
     1800                        if ( resizable == CKEDITOR.DIALOG_RESIZE_HEIGHT || resizable == CKEDITOR.DIALOG_RESIZE_BOTH )
     1801                                height = Math.max( minHeight, internalHeight );
    17991802
    1800                         if ( abstractDialogCoords.y2 - margins[2] > viewPaneSize.height - magnetDistance )
    1801                                 realY2= viewPaneSize.height + margins[2] ;
    1802                         else if ( partName.search( 'b' ) != -1 && abstractDialogCoords.y2 - abstractDialogCoords.y < minHeight + magnetDistance )
    1803                                 realY2 = abstractDialogCoords.y + minHeight;
    1804                         else
    1805                                 realY2 = abstractDialogCoords.y2 ;
     1803                        width = Math.max( width - wrapperWidth, 0 );
     1804                        height = Math.max( height - wrapperHeight, 0 );
    18061805
    1807                         dialog.move( realX, realY );
    1808                         dialog.resize( realX2 - realX, realY2 - realY );
     1806                        dialog.resize( width, height );
     1807                        // The right property might get broken during resizing, so computing it before the resizing.
     1808                        positionDialog( right );
    18091809
    18101810                        evt.data.preventDefault();
    18111811                }
    18121812
    1813                 function mouseUpHandler( evt )
     1813                function mouseUpHandler()
    18141814                {
    18151815                        CKEDITOR.document.removeListener( 'mouseup', mouseUpHandler );
    18161816                        CKEDITOR.document.removeListener( 'mousemove', mouseMoveHandler );
     
    18211821                                coverDoc.removeListener( 'mouseup', mouseUpHandler );
    18221822                                coverDoc.removeListener( 'mousemove', mouseMoveHandler );
    18231823                        }
    1824                 }
    18251824
    1826 // TODO : Simplify the resize logic, having just a single resize grip <div>.
    1827 //              var widthTest = /[lr]/,
    1828 //                      heightTest = /[tb]/;
    1829 //              for ( var i = 0 ; i < parts.length ; i++ )
    1830 //              {
    1831 //                      var element = dialog.parts[ parts[i] + '_resize' ];
    1832 //                      if ( resizable == CKEDITOR.DIALOG_RESIZE_NONE ||
    1833 //                                      resizable == CKEDITOR.DIALOG_RESIZE_HEIGHT && widthTest.test( parts[i] ) ||
    1834 //                                      resizable == CKEDITOR.DIALOG_RESIZE_WIDTH && heightTest.test( parts[i] ) )
    1835 //                      {
    1836 //                              element.hide();
    1837 //                              continue;
    1838 //                      }
    1839 //                      element.on( 'mousedown', mouseDownHandler, dialog, { part : parts[i] } );
    1840 //              }
     1825                        // Switch back to use the left property, if RTL is used.
     1826                        if ( editor.lang.dir == 'rtl' )
     1827                        {
     1828                                var element = dialog._.element.getFirst(),
     1829                                        left = element.getComputedStyle( 'left' );
     1830                                element.removeStyle( 'right' );
     1831                                dialog.move( parseInt( left, 10 ), parseInt( element.getComputedStyle( 'top' ), 10 ), 1 );
     1832                        }
     1833                }
    18411834        }
    18421835
    18431836        var resizeCover;
  • 3.5.x/_source/skins/kama/dialog.css

     
    102102        text-align: left;
    103103}
    104104
     105.cke_skin_kama .cke_dialog_footer .cke_resizer {
     106        margin-top: 20px;
     107}
     108
    105109/* tabs */
    106110
    107111.cke_skin_kama .cke_dialog_tabs
  • 3.5.x/_source/skins/office2003/dialog.css

     
    200200        text-align: left;
    201201}
    202202
     203.cke_skin_office2003 .cke_dialog_footer .cke_resizer {
     204        margin-top: 21px;
     205}
     206
    203207/* tabs */
    204208
    205209.cke_skin_office2003 .cke_dialog_tabs
  • 3.5.x/_source/skins/v2/dialog.css

     
    197197        text-align: left;
    198198}
    199199
     200.cke_skin_v2 .cke_dialog_footer .cke_resizer {
     201        margin-top: 21px;
     202}
     203
    200204/* tabs */
    201205
    202206.cke_skin_v2 .cke_dialog_tabs
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy