Ticket #5618: 5618_2.patch
File 5618_2.patch, 5.8 KB (added by , 14 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 ); … … 802 803 */ 803 804 hide : function() 804 805 { 806 if ( !this.parts.dialog.isVisible() ) 807 return; 808 805 809 this.fire( 'hide', {} ); 806 810 this._.editor.fire( 'dialogHide', this ); 807 811 var element = this._.element; … … 810 814 // Unregister all access keys associated with this dialog. 811 815 unregisterAccessKey( this ); 812 816 817 // Close any child(top) dialogs first. 818 while( CKEDITOR.dialog._.currentTop != this ) 819 CKEDITOR.dialog._.currentTop.hide(); 820 813 821 // Maintain dialog ordering and remove cover if needed. 814 822 if ( !this._.parentDialog ) 815 removeCover();823 hideCover(); 816 824 else 817 825 { 818 826 var parentElement = this._.parentDialog.getElement().getFirst(); … … 845 853 else 846 854 CKEDITOR.dialog._.currentZIndex -= 10; 847 855 848 856 delete this._.parentDialog; 849 857 // Reset the initial values of the dialog. 850 858 this.foreach( function( contentObj ) { contentObj.resetInitValue && contentObj.resetInitValue(); } ); 851 859 }, … … 1749 1757 } 1750 1758 1751 1759 var resizeCover; 1752 var coverElement; 1760 // Caching resuable covers and allowing only one cover 1761 // on screen. 1762 var covers = {}, 1763 currentCover; 1753 1764 1754 var addCover = function( editor )1765 function showCover( editor ) 1755 1766 { 1756 1767 var win = CKEDITOR.document.getWindow(); 1768 var backgroundColorStyle = editor.config.dialog_backgroundCoverColor || 'white', 1769 backgroundCoverOpacity = editor.config.dialog_backgroundCoverOpacity, 1770 baseFloatZIndex = editor.config.baseFloatZIndex, 1771 coverKey = CKEDITOR.tools.genKey( 1772 backgroundColorStyle, 1773 backgroundCoverOpacity, 1774 baseFloatZIndex ), 1775 coverElement = covers[ coverKey ]; 1757 1776 1758 1777 if ( !coverElement ) 1759 1778 { 1760 var backgroundColorStyle = editor.config.dialog_backgroundCoverColor || 'white';1761 1762 1779 var html = [ 1763 1780 '<div style="position: ', ( CKEDITOR.env.ie6Compat ? 'absolute' : 'fixed' ), 1764 '; z-index: ', editor.config.baseFloatZIndex,1781 '; z-index: ', baseFloatZIndex, 1765 1782 '; top: 0px; left: 0px; ', 1766 1783 ( !CKEDITOR.env.ie6Compat ? 'background-color: ' + backgroundColorStyle : '' ), 1767 '" id="cke_dialog_background_cover">'1784 '" class="cke_dialog_background_cover">' 1768 1785 ]; 1769 1786 1770 1771 1787 if ( CKEDITOR.env.ie6Compat ) 1772 1788 { 1773 1789 // Support for custom document.domain in IE. … … 1803 1819 html.push( '</div>' ); 1804 1820 1805 1821 coverElement = CKEDITOR.dom.element.createFromHtml( html.join( '' ) ); 1822 coverElement.setOpacity( backgroundCoverOpacity != undefined ? backgroundCoverOpacity : 0.5 ); 1823 1824 coverElement.appendTo( CKEDITOR.document.getBody() ); 1825 covers[ coverKey ] = coverElement; 1806 1826 } 1827 else 1828 coverElement. show(); 1807 1829 1808 var element = coverElement; 1809 1830 currentCover = coverElement; 1810 1831 var resizeFunc = function() 1811 1832 { 1812 1833 var size = win.getViewPaneSize(); 1813 element.setStyles(1834 coverElement.setStyles( 1814 1835 { 1815 1836 width : size.width + 'px', 1816 1837 height : size.height + 'px' … … 1821 1842 { 1822 1843 var pos = win.getScrollPosition(), 1823 1844 cursor = CKEDITOR.dialog._.currentTop; 1824 element.setStyles(1845 coverElement.setStyles( 1825 1846 { 1826 1847 left : pos.x + 'px', 1827 1848 top : pos.y + 'px' … … 1853 1874 }, 0 ); 1854 1875 scrollFunc(); 1855 1876 } 1856 1857 var opacity = editor.config.dialog_backgroundCoverOpacity;1858 element.setOpacity( typeof opacity != 'undefined' ? opacity : 0.5 );1859 1860 element.appendTo( CKEDITOR.document.getBody() );1861 1877 }; 1862 1878 1863 var removeCover = function()1879 function hideCover() 1864 1880 { 1865 if ( !c overElement)1881 if ( !currentCover ) 1866 1882 return; 1867 1883 1868 1884 var win = CKEDITOR.document.getWindow(); 1869 c overElement.remove();1885 currentCover.hide(); 1870 1886 win.removeListener( 'resize', resizeCover ); 1871 1887 1872 1888 if ( CKEDITOR.env.ie6Compat ) … … 1879 1895 } 1880 1896 resizeCover = null; 1881 1897 }; 1882 1898 1899 function removeCovers() 1900 { 1901 for ( var coverId in covers ) 1902 covers[ coverId ].remove(); 1903 covers = {}; 1904 } 1905 1883 1906 var accessKeyProcessors = {}; 1884 1907 1885 1908 var accessKeyDownHandler = function( evt ) … … 2781 2804 2782 2805 CKEDITOR.on( 'instanceDestroyed', function( evt ) 2783 2806 { 2807 // Remove dialog cover on last instance destroy. 2808 if ( CKEDITOR.tools.isEmpty( CKEDITOR.instances ) ) 2809 { 2810 var currentTopDialog; 2811 while ( currentTopDialog = CKEDITOR.dialog._.currentTop ) 2812 currentTopDialog.hide(); 2813 removeCovers(); 2814 } 2815 2784 2816 var dialogs = evt.editor._.storedDialogs; 2785 2817 for ( var name in dialogs ) 2786 2818 dialogs[ name ].destroy(); 2787 2819 2788 // Remove dialog cover on last instance destroy.2789 if ( CKEDITOR.tools.isEmpty( CKEDITOR.instances ) && coverElement )2790 coverElement.remove();2791 2820 }); 2792 2821 2793 2822 })();