CLICK HERE TO BUY IT TODAY! OR GET IT FREE VIA TRIALPAY  

PHP Demo Application - Source Code

/Framework/Model/Vendor/CkEditor/_source/plugins/maximize/plugin.js



/*
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
(function()
{
	    function protectFormStylesformElement )
	    {
		        if ( !formElement || formElement.type != CKEDITOR.NODE_ELEMENT || formElement.getName() != 'form' )
		            return [];
		        var hijackRecord [];
		        var hijackNames = [ 'style''className' ];
		        for ( var ;
		 hijackNames.length ;
		 i++ )
		        {
			            var name hijackNames[i];
			            var $node formElement.$.elements.namedItemname );
			            if ( $node )
			            {
				                var hijackNode = new CKEDITOR.dom.element$node );
				                hijackRecord.push( [ hijackNodehijackNode.nextSibling ] );
				                hijackNode.remove();
				            }
			        }
		        return hijackRecord;
		    }
	    function restoreFormStylesformElementhijackRecord )
	    {
		        if ( !formElement || formElement.type != CKEDITOR.NODE_ELEMENT || formElement.getName() != 'form' )
		            return;
		        if ( hijackRecord.length )
		        {
			            for ( var hijackRecord.length ;
			 >= ;
			 i-- )
			            {
				                var node hijackRecord[i][0];
				                var sibling hijackRecord[i][1];
				                if ( sibling )
				                    node.insertBeforesibling );
				                else
				                    node.appendToformElement );
				            }
			        }
		    }
	    function saveStyleselementisInsideEditor )
	    {
		        var data protectFormStyleselement );
		        var retval {};
		        var $element element.$;
		        if ( !isInsideEditor )
		        {
			            retval'class' ] = $element.className || '';
			            $element.className '';
			        }
		        retval.inline $element.style.cssText || '';
		        if ( !isInsideEditor )        // Reset any external styles that might interfere. (#2474)
		            $element.style.cssText 'position: static;
		 overflow: visible';
		        restoreFormStylesdata );
		        return retval;
		    }
	    function restoreStyleselementsavedStyles )
	    {
		        var data protectFormStyleselement );
		        var $element element.$;
		        if ( 'class' in savedStyles )
		            $element.className savedStyles'class' ];
		        if ( 'inline' in savedStyles )
		            $element.style.cssText savedStyles.inline;
		        restoreFormStylesdata );
		    }
	    function refreshCursoreditor )
	    {
		        // Refresh all editor instances on the page (#5724).
		        var all CKEDITOR.instances;
		        for ( var i in all )
		        {
			            var one all];
			            if ( one.mode == 'wysiwyg' )
			            {
				                var body one.document.getBody();
				                // Refresh 'contentEditable' otherwise
				                // DOM lifting breaks design mode. (#5560)
				                body.setAttribute'contentEditable'false );
				                body.setAttribute'contentEditable'true );
				            }
			        }
		        if ( editor.focusManager.hasFocus )
		        {
			            editor.toolbox.focus();
			            editor.focus();
			        }
		    }
	    /**
	     * Adding an iframe shim to this element, OR removing the existing one if already applied.
	     * Note: This will only affect IE version below 7.
	     */
	     function createIframeShimelement )
	    {
		        if ( !CKEDITOR.env.ie || CKEDITOR.env.version )
		            return null;
		        var shim CKEDITOR.dom.element.createFromHtml'<iframe frameborder="0" tabindex="-1"' +
		                    ' src="javascript:' +
		                       'void((function(){' +
			                           'document.open();
			' +
			                           ( CKEDITOR.env.isCustomDomain() ? 'document.domain=\'' this.getDocument().$.domain '\';
			' '' ) +
			                           'document.close();
			' +
			                       '})())"' +
		                    ' style="display:block;
		position:absolute;
		z-index:-1;
		' +
		                    'progid:DXImageTransform.Microsoft.Alpha(opacity=0);
		' +
		                    '"></iframe>' );
		        return element.appendshimtrue );
		    }
	    CKEDITOR.plugins.add'maximize',
	    {
		        init : function( editor )
		        {
			            var lang editor.lang;
			            var mainDocument CKEDITOR.document;
			            var mainWindow mainDocument.getWindow();
			            // Saved selection and scroll position for the editing area.
			            var savedSelection;
			            var savedScroll;
			            // Saved scroll position for the outer window.
			            var outerScroll;
			            var shim;
			            // Saved resize handler function.
			            function resizeHandler()
			            {
				                var viewPaneSize mainWindow.getViewPaneSize();
				                shim && shim.setStyles( { width viewPaneSize.width 'px'height viewPaneSize.height 'px'
					} );
				                editor.resizeviewPaneSize.widthviewPaneSize.heightnulltrue );
				            }
			            // Retain state after mode switches.
			            var savedState CKEDITOR.TRISTATE_OFF;
			            editor.addCommand'maximize',
			                {
				                    modes : { wysiwyg 1source 1
					},
				                    editorFocus false,
				                    exec : function()
				                    {
					                        var container editor.container.getChild);
					                        var contents editor.getThemeSpace'contents' );
					                        // Save current selection and scroll position in editing area.
					                        if ( editor.mode == 'wysiwyg' )
					                        {
						                            var selection editor.getSelection();
						                            savedSelection selection && selection.getRanges();
						                            savedScroll mainWindow.getScrollPosition();
						                        }
					                        else
					                        {
						                            var $textarea editor.textarea.$;
						                            savedSelection = !CKEDITOR.env.ie && [ $textarea.selectionStart$textarea.selectionEnd ];
						                            savedScroll = [ $textarea.scrollLeft$textarea.scrollTop ];
						                        }
					                        if ( this.state == CKEDITOR.TRISTATE_OFF )        // Go fullscreen if the state is off.
					                        {
						                            // Add event handler for resizing.
						                            mainWindow.on'resize'resizeHandler );
						                            // Save the scroll bar position.
						                            outerScroll mainWindow.getScrollPosition();
						                            // Save and reset the styles for the entire node tree.
						                            var currentNode editor.container;
						                            while ( ( currentNode currentNode.getParent() ) )
						                            {
							                                currentNode.setCustomData'maximize_saved_styles'saveStylescurrentNode ) );
							                                currentNode.setStyle'z-index'editor.config.baseFloatZIndex );
							                            }
						                            contents.setCustomData'maximize_saved_styles'saveStylescontentstrue ) );
						                            container.setCustomData'maximize_saved_styles'saveStylescontainertrue ) );
						                            // Hide scroll bars.
						                            if ( CKEDITOR.env.ie )
						                            {
							                                mainDocument.$.documentElement.style.overflow =
							                                    mainDocument.getBody().$.style.overflow 'hidden';
							                            }
						                            else
						                            {
							                                mainDocument.getBody().setStyles(
							                                    {
								                                        overflow 'hidden',
								                                        width '0px',
								                                        height '0px'
								                                    } );
							                            }
						                            // Scroll to the top left (IE needs some time for it - #4923).
						                            CKEDITOR.env.ie ?
						                                setTimeout( function() {
							mainWindow.$.scrollTo0);
							}, ) :
						                                mainWindow.$.scrollTo0);
						                            // Resize and move to top left.
						                            var viewPaneSize mainWindow.getViewPaneSize();
						                            container.setStyle'position''absolute' );
						                            container.$.offsetLeft;
						            // SAFARI BUG: See #2066.
						                            container.setStyles(
						                                {
							                                    'z-index' editor.config.baseFloatZIndex 1,
							                                    left '0px',
							                                    top '0px'
							                                } );
						                            shim =  createIframeShimcontainer );
						        // IE6 select element penetration when maximized. (#4459)
						                            // Add cke_maximized class before resize handle since that will change things sizes (#5580)
						                            container.addClass'cke_maximized' );
						                            resizeHandler();
						                            // Still not top left? Fix it. (Bug #174)
						                            var offset container.getDocumentPosition();
						                            container.setStyles(
						                                {
							                                    left : ( -offset.) + 'px',
							                                    top : ( -offset.) + 'px'
							                                } );
						                            // Fixing positioning editor chrome in Firefox break design mode. (#5149)
						                            CKEDITOR.env.gecko && refreshCursoreditor );
						                        }
					                        else if ( this.state == CKEDITOR.TRISTATE_ON )    // Restore from fullscreen if the state is on.
					                        {
						                            // Remove event handler for resizing.
						                            mainWindow.removeListener'resize'resizeHandler );
						                            // Restore CSS styles for the entire node tree.
						                            var editorElements = [ contentscontainer ];
						                            for ( var ;
						 editorElements.length ;
						 i++ )
						                            {
							                                restoreStyleseditorElements[i], editorElements[i].getCustomData'maximize_saved_styles' ) );
							                                editorElements[i].removeCustomData'maximize_saved_styles' );
							                            }
						                            currentNode editor.container;
						                            while ( ( currentNode currentNode.getParent() ) )
						                            {
							                                restoreStylescurrentNodecurrentNode.getCustomData'maximize_saved_styles' ) );
							                                currentNode.removeCustomData'maximize_saved_styles' );
							                            }
						                            // Restore the window scroll position.
						                            CKEDITOR.env.ie ?
						                                setTimeout( function() {
							mainWindow.$.scrollToouterScroll.xouterScroll.);
							}, ) :
						                                mainWindow.$.scrollToouterScroll.xouterScroll.);
						                            // Remove cke_maximized class.
						                            container.removeClass'cke_maximized' );
						                            if ( shim )
						                            {
							                                shim.remove();
							                                shim null;
							                            }
						                            // Emit a resize event, because this time the size is modified in
						                            // restoreStyles.
						                            editor.fire'resize' );
						                        }
					                        this.toggleState();
					                        // Toggle button label.
					                        var button this.uiItems];
					                        var label = ( this.state == CKEDITOR.TRISTATE_OFF )
					                            ? lang.maximize lang.minimize;
					                        var buttonNode editor.element.getDocument().getByIdbutton._.id );
					                        buttonNode.getChild).setHtmllabel );
					                        buttonNode.setAttribute'title'label );
					                        buttonNode.setAttribute'href''javascript:void("' label '");
					' );
					                        // Restore selection and scroll position in editing area.
					                        if ( editor.mode == 'wysiwyg' )
					                        {
						                            if ( savedSelection )
						                            {
							                                // Fixing positioning editor chrome in Firefox break design mode. (#5149)
							                                CKEDITOR.env.gecko && refreshCursoreditor );
							                                editor.getSelection().selectRanges(savedSelection);
							                                var element editor.getSelection().getStartElement();
							                                element && element.scrollIntoViewtrue );
							                            }
						                            else
						                                mainWindow.$.scrollTosavedScroll.xsavedScroll.);
						                        }
					                        else
					                        {
						                            if ( savedSelection )
						                            {
							                                $textarea.selectionStart savedSelection[0];
							                                $textarea.selectionEnd savedSelection[1];
							                            }
						                            $textarea.scrollLeft savedScroll[0];
						                            $textarea.scrollTop savedScroll[1];
						                        }
					                        savedSelection savedScroll null;
					                        savedState this.state;
					                    },
				                    canUndo false
				                } );
			            editor.ui.addButton'Maximize',
			                {
				                    label lang.maximize,
				                    command 'maximize'
				                } );
			            // Restore the command state after mode change.
			            editor.on'mode', function()
			                {
				                    editor.getCommand'maximize' ).setStatesavedState );
				                }, nullnull100 );
			        }
		    } );
	})();





PHP Demo Source Code Index