Ticket #4797: 4797_4.patch
File 4797_4.patch, 6.1 KB (added by , 13 years ago) |
---|
-
_source/core/tools.js
691 691 catch (e) {} 692 692 } 693 693 return returnValue; 694 }, 695 696 /** 697 * Generate a combined key from a series of params. 698 * @param {String} subKey One or more string used as sub keys. 699 * @example 700 * var key = CKEDITOR.tools.genKey( 'key1', 'key2', 'key3' ); 701 * alert( key ); // "key1-key2-key3". 702 */ 703 genKey : function() 704 { 705 return Array.prototype.slice.call( arguments ).join( '-' ); 694 706 } 695 707 }; 696 708 })(); -
_source/plugins/dialog/plugin.js
545 545 { 546 546 destroy : function() 547 547 { 548 this.hide(); 548 549 this._.element.remove(); 549 550 }, 550 551 … … 698 699 { 699 700 CKEDITOR.dialog._.currentTop = this; 700 701 this._.parentDialog = null; 701 addCover( this._.editor );702 showCover( this._.editor ); 702 703 703 704 element.on( 'keydown', accessKeyDownHandler ); 704 705 element.on( CKEDITOR.env.opera ? 'keypress' : 'keyup', accessKeyUpHandler ); … … 711 712 { 712 713 this._.parentDialog = CKEDITOR.dialog._.currentTop; 713 714 var parentElement = this._.parentDialog.getElement().getFirst(); 714 parentElement.$.style.zIndex -= Math.floor( this._.editor.config.baseFloatZIndex / 2 );715 715 CKEDITOR.dialog._.currentTop = this; 716 716 } 717 717 … … 802 802 */ 803 803 hide : function() 804 804 { 805 if ( !this.parts.dialog.isVisible() ) 806 return; 807 805 808 this.fire( 'hide', {} ); 806 809 this._.editor.fire( 'dialogHide', this ); 807 810 var element = this._.element; … … 810 813 // Unregister all access keys associated with this dialog. 811 814 unregisterAccessKey( this ); 812 815 816 // Close any child(top) dialogs first. 817 while( CKEDITOR.dialog._.currentTop != this ) 818 CKEDITOR.dialog._.currentTop.hide(); 819 813 820 // Maintain dialog ordering and remove cover if needed. 814 821 if ( !this._.parentDialog ) 815 removeCover(); 816 else 817 { 818 var parentElement = this._.parentDialog.getElement().getFirst(); 819 parentElement.setStyle( 'z-index', parseInt( parentElement.$.style.zIndex, 10 ) + Math.floor( this._.editor.config.baseFloatZIndex / 2 ) ); 820 } 822 hideCover(); 823 821 824 CKEDITOR.dialog._.currentTop = this._.parentDialog; 822 825 823 826 // Deduct or clear the z-index. … … 845 848 else 846 849 CKEDITOR.dialog._.currentZIndex -= 10; 847 850 848 851 delete this._.parentDialog; 849 852 // Reset the initial values of the dialog. 850 853 this.foreach( function( contentObj ) { contentObj.resetInitValue && contentObj.resetInitValue(); } ); 851 854 }, … … 1749 1752 } 1750 1753 1751 1754 var resizeCover; 1752 var coverElement; 1755 // Caching resuable covers and allowing only one cover 1756 // on screen. 1757 var covers = {}, 1758 currentCover; 1753 1759 1754 var addCover = function( editor )1760 function showCover( editor ) 1755 1761 { 1756 1762 var win = CKEDITOR.document.getWindow(); 1763 var backgroundColorStyle = editor.config.dialog_backgroundCoverColor || 'white', 1764 baseFloatZIndex = editor.config.baseFloatZIndex, 1765 coverKey = CKEDITOR.tools.genKey( backgroundColorStyle, baseFloatZIndex ), 1766 coverElement = covers[ coverKey ]; 1757 1767 1758 1768 if ( !coverElement ) 1759 1769 { 1760 var backgroundColorStyle = editor.config.dialog_backgroundCoverColor || 'white';1761 1762 1770 var html = [ 1763 1771 '<div style="position: ', ( CKEDITOR.env.ie6Compat ? 'absolute' : 'fixed' ), 1764 '; z-index: ', editor.config.baseFloatZIndex,1772 '; z-index: ', baseFloatZIndex, 1765 1773 '; top: 0px; left: 0px; ', 1766 1774 ( !CKEDITOR.env.ie6Compat ? 'background-color: ' + backgroundColorStyle : '' ), 1767 '" id="cke_dialog_background_cover">'1775 '" class="cke_dialog_background_cover">' 1768 1776 ]; 1769 1777 1770 1778 … … 1803 1811 html.push( '</div>' ); 1804 1812 1805 1813 coverElement = CKEDITOR.dom.element.createFromHtml( html.join( '' ) ); 1814 covers[ coverKey ] = coverElement; 1806 1815 } 1816 else 1817 coverElement. show(); 1807 1818 1808 var element = coverElement; 1809 1819 currentCover = coverElement; 1810 1820 var resizeFunc = function() 1811 1821 { 1812 1822 var size = win.getViewPaneSize(); 1813 element.setStyles(1823 coverElement.setStyles( 1814 1824 { 1815 1825 width : size.width + 'px', 1816 1826 height : size.height + 'px' … … 1821 1831 { 1822 1832 var pos = win.getScrollPosition(), 1823 1833 cursor = CKEDITOR.dialog._.currentTop; 1824 element.setStyles(1834 coverElement.setStyles( 1825 1835 { 1826 1836 left : pos.x + 'px', 1827 1837 top : pos.y + 'px' … … 1855 1865 } 1856 1866 1857 1867 var opacity = editor.config.dialog_backgroundCoverOpacity; 1858 element.setOpacity( typeof opacity != 'undefined' ? opacity : 0.5 );1868 coverElement.setOpacity( typeof opacity != 'undefined' ? opacity : 0.5 ); 1859 1869 1860 element.appendTo( CKEDITOR.document.getBody() );1870 coverElement.appendTo( CKEDITOR.document.getBody() ); 1861 1871 }; 1862 1872 1863 var removeCover = function()1873 function hideCover() 1864 1874 { 1865 if ( !c overElement)1875 if ( !currentCover ) 1866 1876 return; 1867 1877 1868 1878 var win = CKEDITOR.document.getWindow(); 1869 c overElement.remove();1879 currentCover.hide(); 1870 1880 win.removeListener( 'resize', resizeCover ); 1871 1881 1872 1882 if ( CKEDITOR.env.ie6Compat ) … … 1879 1889 } 1880 1890 resizeCover = null; 1881 1891 }; 1882 1892 1893 function removeCovers() 1894 { 1895 for ( var coverId in covers ) 1896 covers[ coverId ].remove(); 1897 covers = {}; 1898 } 1899 1883 1900 var accessKeyProcessors = {}; 1884 1901 1885 1902 var accessKeyDownHandler = function( evt ) … … 2781 2798 2782 2799 CKEDITOR.on( 'instanceDestroyed', function( evt ) 2783 2800 { 2801 // Remove dialog cover on last instance destroy. 2802 if ( CKEDITOR.tools.isEmpty( CKEDITOR.instances ) ) 2803 { 2804 var currentTopDialog; 2805 while ( currentTopDialog = CKEDITOR.dialog._.currentTop ) 2806 currentTopDialog.hide(); 2807 removeCovers(); 2808 } 2809 2784 2810 var dialogs = evt.editor._.storedDialogs; 2785 2811 for ( var name in dialogs ) 2786 2812 dialogs[ name ].destroy(); 2787 2813 2788 // Remove dialog cover on last instance destroy.2789 if ( CKEDITOR.tools.isEmpty( CKEDITOR.instances ) );2790 coverElement.remove();2791 2814 }); 2792 2815 2793 2816 })();