Ticket #5084: 5084_3.patch
File 5084_3.patch, 10.7 KB (added by , 13 years ago) |
---|
-
_source/plugins/dialog/plugin.js
638 638 * @function 639 639 * @param {Number} x The target x-coordinate. 640 640 * @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. 641 642 * @example 642 643 * dialogObj.move( 10, 40 ); 643 644 */ 644 645 move : (function() 645 646 { 646 647 var isFixed; 647 return function( x, y )648 return function( x, y, internal ) 648 649 { 649 650 // The dialog may be fixed positioned or absolute positioned. Ask the 650 651 // browser what is the current situation first. … … 671 672 'left' : ( x > 0 ? x : 0 ) + 'px', 672 673 'top' : ( y > 0 ? y : 0 ) + 'px' 673 674 }); 675 676 !internal && ( this._.moved = 1 ); 674 677 }; 675 678 })(), 676 679 … … 717 720 718 721 719 722 // 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 ); 721 724 722 725 // Reset all inputs back to their default value. 723 726 this.reset(); … … 770 773 771 774 // We're using definition size for initial position because of 772 775 // 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 ); 774 778 775 779 this.parts.dialog.setStyle( 'visibility', '' ); 776 780 … … 1671 1675 1672 1676 function initResizeHandles( dialog ) 1673 1677 { 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; 1679 1682 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; 1684 1688 1685 function rightSizer( coords, dx)1689 function positionDialog() 1686 1690 { 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 ); 1688 1695 } 1689 1696 1690 function bottomSizer( coords, dy)1697 var mouseDownFn = CKEDITOR.tools.addFunction( function( $event ) 1691 1698 { 1692 coords.y2 += dy; 1693 } 1699 origin = { x : $event.screenX, y : $event.screenY }; 1694 1700 1695 function leftSizer( coords, dx ) 1696 { 1697 coords.x += dx; 1698 } 1701 dialog._.updateSize = true; 1702 startSize = dialog.getSize(); 1699 1703 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(); 1704 1705 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 ); 1715 1708 1716 CKEDITOR.document.on( 'mousemove', mouseMoveHandler, dialog, { part : partName } );1717 CKEDITOR.document.on( 'mouseup', mouseUpHandler, dialog, { part : partName } );1718 1719 1709 if ( CKEDITOR.env.ie6Compat ) 1720 1710 { 1721 1711 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 ); 1724 1714 } 1725 1715 1726 evt.data.preventDefault();1727 } 1716 $event.preventDefault(); 1717 }); 1728 1718 1729 function mouseMoveHandler( evt ) 1719 // Prepend the grip to the dialog. 1720 dialog.on( 'load', function() 1730 1721 { 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 ); 1737 1731 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 ); } ); 1746 1737 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; 1748 1746 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]; 1750 1751 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 ); 1757 1754 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 ); 1764 1757 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 ); 1771 1760 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(); 1782 1763 evt.data.preventDefault(); 1783 1764 } 1784 1765 1785 function mouseUpHandler( evt)1766 function mouseUpHandler() 1786 1767 { 1787 1768 CKEDITOR.document.removeListener( 'mouseup', mouseUpHandler ); 1788 1769 CKEDITOR.document.removeListener( 'mousemove', mouseMoveHandler ); … … 1794 1775 coverDoc.removeListener( 'mousemove', mouseMoveHandler ); 1795 1776 } 1796 1777 } 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 // }1813 1778 } 1814 1779 1815 1780 var resizeCover; -
_source/skins/kama/dialog.css
102 102 text-align: left; 103 103 } 104 104 105 .cke_skin_kama .cke_dialog_footer .cke_resizer { 106 margin-top: 20px; 107 } 108 105 109 /* tabs */ 106 110 107 111 .cke_skin_kama .cke_dialog_tabs -
_source/skins/office2003/dialog.css
200 200 text-align: left; 201 201 } 202 202 203 .cke_skin_office2003 .cke_dialog_footer .cke_resizer { 204 margin-top: 21px; 205 } 206 203 207 /* tabs */ 204 208 205 209 .cke_skin_office2003 .cke_dialog_tabs -
_source/skins/v2/dialog.css
197 197 text-align: left; 198 198 } 199 199 200 .cke_skin_v2 .cke_dialog_footer .cke_resizer { 201 margin-top: 21px; 202 } 203 200 204 /* tabs */ 201 205 202 206 .cke_skin_v2 .cke_dialog_tabs