Ticket #5084: 5084_3.patch

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

     
    638638                 * @function
    639639                 * @param {Number} x The target x-coordinate.
    640640                 * @param {Number} y The target y-coordinate.
     641                 * @param {Boolean} internal Whether this is an internal moving, which should not indicate the dialog has been actually moved.
    641642                 * @example
    642643                 * dialogObj.move( 10, 40 );
    643644                 */
    644645                move : (function()
    645646                {
    646647                        var isFixed;
    647                         return function( x, y )
     648                        return function( x, y, internal )
    648649                        {
    649650                                // The dialog may be fixed positioned or absolute positioned. Ask the
    650651                                // browser what is the current situation first.
     
    671672                                                        'left'  : ( x > 0 ? x : 0 ) + 'px',
    672673                                                        'top'   : ( y > 0 ? y : 0 ) + 'px'
    673674                                                });
     675
     676                                !internal && ( this._.moved = 1 );
    674677                        };
    675678                })(),
    676679
     
    717720
    718721
    719722                        // First, set the dialog to an appropriate size.
    720                         this.resize( definition.minWidth, definition.minHeight );
     723                        this.resize( this._.contentSize.width || definition.minWidth, this._.contentSize.height || definition.minHeight );
    721724
    722725                        // Reset all inputs back to their default value.
    723726                        this.reset();
     
    770773
    771774                                        // We're using definition size for initial position because of
    772775                                        // offten corrupted data in offsetWidth at this point. (#4084)
    773                                         this.move( ( viewSize.width - definition.minWidth ) / 2, ( viewSize.height - dialogSize.height ) / 2 );
     776                                        this.move( ( viewSize.width - ( this._.contentSize.width || definition.minWidth ) ) / 2,
     777                                                        ( viewSize.height - dialogSize.height ) / 2, 1 );
    774778
    775779                                        this.parts.dialog.setStyle( 'visibility', '' );
    776780
     
    16711675
    16721676        function initResizeHandles( dialog )
    16731677        {
    1674                 var definition = dialog.definition,
    1675                         minWidth = definition.minWidth || 0,
    1676                         minHeight = definition.minHeight || 0,
    1677                         resizable = definition.resizable,
    1678                         margins = dialog.getParentEditor().skin.margins || [ 0, 0, 0, 0 ];
     1678                var def = dialog.definition,
     1679                        resizable = def.resizable;
     1680                if ( resizable == CKEDITOR.DIALOG_RESIZE_NONE )
     1681                        return;
    16791682
    1680                 function topSizer( coords, dy )
    1681                 {
    1682                         coords.y += dy;
    1683                 }
     1683                var editor = dialog.getParentEditor(),
     1684                        minHeight = def.minHeight || 0,
     1685                        minWidth = def.minWidth || 0,
     1686                        margin = editor.skin.margins || [ 0, 0, 0, 0 ],
     1687                        wrapperWidth, wrapperHeight, viewSize, origin;
    16841688
    1685                 function rightSizer( coords, dx )
     1689                function positionDialog()
    16861690                {
    1687                         coords.x2 += dx;
     1691                        if ( dialog._.moved )
     1692                                return;
     1693                        var dialogSize = dialog.getSize();
     1694                        dialog.move( ( viewSize.width - dialogSize.width ) / 2 + margin[ 0 ], ( viewSize.height - dialogSize.height ) / 2 + margin[ 1 ] , 1 );
    16881695                }
    16891696
    1690                 function bottomSizer( coords, dy )
     1697                var mouseDownFn = CKEDITOR.tools.addFunction( function( $event )
    16911698                {
    1692                         coords.y2 += dy;
    1693                 }
     1699                        origin = { x : $event.screenX, y : $event.screenY };
    16941700
    1695                 function leftSizer( coords, dx )
    1696                 {
    1697                         coords.x += dx;
    1698                 }
     1701                        dialog._.updateSize = true;
     1702                        startSize = dialog.getSize();
    16991703
    1700                 var lastCoords = null,
    1701                         abstractDialogCoords = null,
    1702                         magnetDistance = dialog._.editor.config.magnetDistance,
    1703                         parts = [ 'tl', 't', 'tr', 'l', 'r', 'bl', 'b', 'br' ];
     1704                        viewSize = CKEDITOR.document.getWindow().getViewPaneSize();
    17041705
    1705                 function mouseDownHandler( evt )
    1706                 {
    1707                         var partName = evt.listenerData.part, size = dialog.getSize();
    1708                         abstractDialogCoords = dialog.getPosition();
    1709                         CKEDITOR.tools.extend( abstractDialogCoords,
    1710                                 {
    1711                                         x2 : abstractDialogCoords.x + size.width,
    1712                                         y2 : abstractDialogCoords.y + size.height
    1713                                 } );
    1714                         lastCoords = { x : evt.data.$.screenX, y : evt.data.$.screenY };
     1706                        CKEDITOR.document.on( 'mousemove', mouseMoveHandler );
     1707                        CKEDITOR.document.on( 'mouseup', mouseUpHandler );
    17151708
    1716                         CKEDITOR.document.on( 'mousemove', mouseMoveHandler, dialog, { part : partName } );
    1717                         CKEDITOR.document.on( 'mouseup', mouseUpHandler, dialog, { part : partName } );
    1718 
    17191709                        if ( CKEDITOR.env.ie6Compat )
    17201710                        {
    17211711                                var coverDoc = currentCover.getChild( 0 ).getFrameDocument();
    1722                                 coverDoc.on( 'mousemove', mouseMoveHandler, dialog, { part : partName } );
    1723                                 coverDoc.on( 'mouseup', mouseUpHandler, dialog, { part : partName } );
     1712                                coverDoc.on( 'mousemove', mouseMoveHandler );
     1713                                coverDoc.on( 'mouseup', mouseUpHandler );
    17241714                        }
    17251715
    1726                         evt.data.preventDefault();
    1727                 }
     1716                        $event.preventDefault();
     1717                });
    17281718
    1729                 function mouseMoveHandler( evt )
     1719                // Prepend the grip to the dialog.
     1720                dialog.on( 'load', function()
    17301721                {
    1731                         var x = evt.data.$.screenX,
    1732                                 y = evt.data.$.screenY,
    1733                                 dx = x - lastCoords.x,
    1734                                 dy = y - lastCoords.y,
    1735                                 viewPaneSize = CKEDITOR.document.getWindow().getViewPaneSize(),
    1736                                 partName = evt.listenerData.part;
     1722                        var direction = '';
     1723                        if ( resizable == CKEDITOR.DIALOG_RESIZE_WIDTH )
     1724                                direction = ' cke_resizer_horizontal';
     1725                        else if ( resizable == CKEDITOR.DIALOG_RESIZE_HEIGHT )
     1726                                direction = ' cke_resizer_vertical';
     1727                        var resizer = CKEDITOR.dom.element.createFromHtml( '<div class="cke_resizer' + direction + '"' +
     1728                                        ' title="' + CKEDITOR.tools.htmlEncode( editor.lang.resize ) + '"' +
     1729                                        ' onmousedown="CKEDITOR.tools.callFunction(' + mouseDownFn + ', event )"></div>' );
     1730                        dialog.parts.footer.append( resizer, 1 );
    17371731
    1738                         if ( partName.search( 't' ) != -1 )
    1739                                 topSizer( abstractDialogCoords, dy );
    1740                         if ( partName.search( 'l' ) != -1 )
    1741                                 leftSizer( abstractDialogCoords, dx );
    1742                         if ( partName.search( 'b' ) != -1 )
    1743                                 bottomSizer( abstractDialogCoords, dy );
    1744                         if ( partName.search( 'r' ) != -1 )
    1745                                 rightSizer( abstractDialogCoords, dx );
     1732                        var dialogSize = dialog.getSize();
     1733                        wrapperHeight = dialogSize.height - dialog.parts.contents.$.offsetHeight;
     1734                        wrapperWidth = dialogSize.width - dialog.parts.contents.$.offsetWidth;
     1735                });
     1736                editor.on( 'destroy', function() { CKEDITOR.tools.removeFunction( mouseDownFn ); } );
    17461737
    1747                         lastCoords = { x : x, y : y };
     1738                function mouseMoveHandler( evt )
     1739                {
     1740                        var dx = ( evt.data.$.screenX - origin.x ) * ( editor.lang.dir == 'rtl' ? -1 : 1 ),
     1741                                dy = evt.data.$.screenY - origin.y,
     1742                                width = startSize.width,
     1743                                height = startSize.height,
     1744                                internalWidth = width + 2 * dx,
     1745                                internalHeight = height + 2 * dy;
    17481746
    1749                         var realX, realY, realX2, realY2;
     1747                        if ( internalHeight > viewSize.height - margin[1] - margin[3] )
     1748                                internalHeight = viewSize.height - margin[1] - margin[3];
     1749                        if ( internalWidth > viewSize.width - margin[0] - margin[2] )
     1750                                internalWidth = viewSize.width - margin[0] - margin[2];
    17501751
    1751                         if ( abstractDialogCoords.x + margins[3] < magnetDistance )
    1752                                 realX = - margins[3];
    1753                         else if ( partName.search( 'l' ) != -1 && abstractDialogCoords.x2 - abstractDialogCoords.x < minWidth + magnetDistance )
    1754                                 realX = abstractDialogCoords.x2 - minWidth;
    1755                         else
    1756                                 realX = abstractDialogCoords.x;
     1752                        if ( resizable == CKEDITOR.DIALOG_RESIZE_WIDTH || resizable == CKEDITOR.DIALOG_RESIZE_BOTH )
     1753                                width = Math.max( minWidth, internalWidth );
    17571754
    1758                         if ( abstractDialogCoords.y + margins[0] < magnetDistance )
    1759                                 realY = - margins[0];
    1760                         else if ( partName.search( 't' ) != -1 && abstractDialogCoords.y2 - abstractDialogCoords.y < minHeight + magnetDistance )
    1761                                 realY = abstractDialogCoords.y2 - minHeight;
    1762                         else
    1763                                 realY = abstractDialogCoords.y;
     1755                        if ( resizable == CKEDITOR.DIALOG_RESIZE_HEIGHT || resizable == CKEDITOR.DIALOG_RESIZE_BOTH )
     1756                                height = Math.max( minHeight, internalHeight );
    17641757
    1765                         if ( abstractDialogCoords.x2 - margins[1] > viewPaneSize.width - magnetDistance )
    1766                                 realX2 = viewPaneSize.width + margins[1] ;
    1767                         else if ( partName.search( 'r' ) != -1 && abstractDialogCoords.x2 - abstractDialogCoords.x < minWidth + magnetDistance )
    1768                                 realX2 = abstractDialogCoords.x + minWidth;
    1769                         else
    1770                                 realX2 = abstractDialogCoords.x2;
     1758                        width = Math.max( width - wrapperWidth, 0 );
     1759                        height = Math.max( height - wrapperHeight, 0 );
    17711760
    1772                         if ( abstractDialogCoords.y2 - margins[2] > viewPaneSize.height - magnetDistance )
    1773                                 realY2= viewPaneSize.height + margins[2] ;
    1774                         else if ( partName.search( 'b' ) != -1 && abstractDialogCoords.y2 - abstractDialogCoords.y < minHeight + magnetDistance )
    1775                                 realY2 = abstractDialogCoords.y + minHeight;
    1776                         else
    1777                                 realY2 = abstractDialogCoords.y2 ;
    1778 
    1779                         dialog.move( realX, realY );
    1780                         dialog.resize( realX2 - realX, realY2 - realY );
    1781 
     1761                        dialog.resize( width, height );
     1762                        positionDialog();
    17821763                        evt.data.preventDefault();
    17831764                }
    17841765
    1785                 function mouseUpHandler( evt )
     1766                function mouseUpHandler()
    17861767                {
    17871768                        CKEDITOR.document.removeListener( 'mouseup', mouseUpHandler );
    17881769                        CKEDITOR.document.removeListener( 'mousemove', mouseMoveHandler );
     
    17941775                                coverDoc.removeListener( 'mousemove', mouseMoveHandler );
    17951776                        }
    17961777                }
    1797 
    1798 // TODO : Simplify the resize logic, having just a single resize grip <div>.
    1799 //              var widthTest = /[lr]/,
    1800 //                      heightTest = /[tb]/;
    1801 //              for ( var i = 0 ; i < parts.length ; i++ )
    1802 //              {
    1803 //                      var element = dialog.parts[ parts[i] + '_resize' ];
    1804 //                      if ( resizable == CKEDITOR.DIALOG_RESIZE_NONE ||
    1805 //                                      resizable == CKEDITOR.DIALOG_RESIZE_HEIGHT && widthTest.test( parts[i] ) ||
    1806 //                                      resizable == CKEDITOR.DIALOG_RESIZE_WIDTH && heightTest.test( parts[i] ) )
    1807 //                      {
    1808 //                              element.hide();
    1809 //                              continue;
    1810 //                      }
    1811 //                      element.on( 'mousedown', mouseDownHandler, dialog, { part : parts[i] } );
    1812 //              }
    18131778        }
    18141779
    18151780        var resizeCover;
  • _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
  • _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
  • _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