Ticket #5084: 5084_4.patch
File 5084_4.patch, 12.5 KB (added by , 13 years ago) |
---|
-
3.5.x/_source/plugins/dialog/plugin.js
666 666 * @function 667 667 * @param {Number} x The target x-coordinate. 668 668 * @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. 669 670 * @example 670 671 * dialogObj.move( 10, 40 ); 671 672 */ 672 673 move : (function() 673 674 { 674 675 var isFixed; 675 return function( x, y )676 return function( x, y, internal ) 676 677 { 677 678 // The dialog may be fixed positioned or absolute positioned. Ask the 678 679 // browser what is the current situation first. … … 699 700 'left' : ( x > 0 ? x : 0 ) + 'px', 700 701 'top' : ( y > 0 ? y : 0 ) + 'px' 701 702 }); 703 704 !internal && ( this._.moved = 1 ); 702 705 }; 703 706 })(), 704 707 … … 745 748 746 749 747 750 // 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 ); 749 753 750 754 // Reset all inputs back to their default value. 751 755 this.reset(); … … 790 794 // Reset the hasFocus state. 791 795 this._.hasFocus = false; 792 796 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. 794 798 CKEDITOR.tools.setTimeout( function() 795 799 { 796 800 var viewSize = CKEDITOR.document.getWindow().getViewPaneSize(); … … 798 802 799 803 // We're using definition size for initial position because of 800 804 // 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 ); 802 807 803 808 this.parts.dialog.setStyle( 'visibility', '' ); 804 809 … … 1699 1704 1700 1705 function initResizeHandles( dialog ) 1701 1706 { 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; 1707 1711 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; 1712 1717 1713 function rightSizer( coords, dx)1718 function positionDialog( right ) 1714 1719 { 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 } 1716 1732 } 1717 1733 1718 function bottomSizer( coords, dy)1734 var mouseDownFn = CKEDITOR.tools.addFunction( function( $event ) 1719 1735 { 1720 coords.y2 += dy; 1721 } 1736 origin = { x : $event.screenX, y : $event.screenY }; 1722 1737 1723 function leftSizer( coords, dx ) 1724 { 1725 coords.x += dx; 1726 } 1738 dialog._.updateSize = true; 1739 startSize = dialog.getSize(); 1727 1740 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(); 1732 1742 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 ); 1743 1745 1744 CKEDITOR.document.on( 'mousemove', mouseMoveHandler, dialog, { part : partName } );1745 CKEDITOR.document.on( 'mouseup', mouseUpHandler, dialog, { part : partName } );1746 1747 1746 if ( CKEDITOR.env.ie6Compat ) 1748 1747 { 1749 1748 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 ); 1752 1751 } 1753 1752 1754 evt.data.preventDefault();1755 } 1753 $event.preventDefault && $event.preventDefault(); 1754 }); 1756 1755 1757 function mouseMoveHandler( evt ) 1756 // Prepend the grip to the dialog. 1757 dialog.on( 'load', function() 1758 1758 { 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 ); 1765 1768 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 ); } ); 1774 1774 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(); 1776 1786 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; 1778 1791 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 ); 1785 1796 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 ); 1792 1799 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 ); 1799 1802 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 ); 1806 1805 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 ); 1809 1809 1810 1810 evt.data.preventDefault(); 1811 1811 } 1812 1812 1813 function mouseUpHandler( evt)1813 function mouseUpHandler() 1814 1814 { 1815 1815 CKEDITOR.document.removeListener( 'mouseup', mouseUpHandler ); 1816 1816 CKEDITOR.document.removeListener( 'mousemove', mouseMoveHandler ); … … 1821 1821 coverDoc.removeListener( 'mouseup', mouseUpHandler ); 1822 1822 coverDoc.removeListener( 'mousemove', mouseMoveHandler ); 1823 1823 } 1824 }1825 1824 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 } 1841 1834 } 1842 1835 1843 1836 var resizeCover; -
3.5.x/_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 -
3.5.x/_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 -
3.5.x/_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