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

PHP Demo Application - Source Code

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



/*
Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
For licensing, see LICENSE.html or http://ckeditor.com/license
*/
/**
 * @fileOverview The floating dialog plugin.
 */
/**
 * No resize for this dialog.
 * @constant
 */
CKEDITOR.DIALOG_RESIZE_NONE 0;
/**
 * Only allow horizontal resizing for this dialog, disable vertical resizing.
 * @constant
 */
CKEDITOR.DIALOG_RESIZE_WIDTH 1;
/**
 * Only allow vertical resizing for this dialog, disable horizontal resizing.
 * @constant
 */
CKEDITOR.DIALOG_RESIZE_HEIGHT 2;
/*
 * Allow the dialog to be resized in both directions.
 * @constant
 */
CKEDITOR.DIALOG_RESIZE_BOTH 3;
(function()
{
	    function isTabVisibletabId )
	    {
		        return !!this._.tabstabId ][ ].$.offsetHeight;
		    }
	    function getPreviousVisibleTab()
	    {
		        var tabId this._.currentTabId,
		            length this._.tabIdList.length,
		            tabIndex CKEDITOR.tools.indexOfthis._.tabIdListtabId ) + length;
		        for ( var tabIndex ;
		 tabIndex length ;
		 i-- )
		        {
			            if ( isTabVisible.callthisthis._.tabIdListlength ] ) )
			                return this._.tabIdListlength ];
			        }
		        return null;
		    }
	    function getNextVisibleTab()
	    {
		        var tabId this._.currentTabId,
		            length this._.tabIdList.length,
		            tabIndex CKEDITOR.tools.indexOfthis._.tabIdListtabId );
		        for ( var tabIndex ;
		 tabIndex length ;
		 i++ )
		        {
			            if ( isTabVisible.callthisthis._.tabIdListlength ] ) )
			                return this._.tabIdListlength ];
			        }
		        return null;
		    }
	    function clearOrRecoverTextInputValuecontainerisRecover )
	    {
		        var inputs container.$.getElementsByTagName'input' );
		        for ( var 0length inputs.length;
		 length ;
		 i++ )
		        {
			            var item = new CKEDITOR.dom.elementinputs] );
			            if ( item.getAttribute'type' ).toLowerCase() == 'text' )
			            {
				                if ( isRecover )
				                {
					                    item.setAttribute'value'item.getCustomData'fake_value' ) || '' );
					                    item.removeCustomData'fake_value' );
					                }
				                else
				                {
					                    item.setCustomData'fake_value'item.getAttribute'value' ) );
					                    item.setAttribute'value''' );
					                }
				            }
			        }
		    }
	    /**
	     * This is the base class for runtime dialog objects. An instance of this
	     * class represents a single named dialog for a single editor instance.
	     * @param {Object} editor The editor which created the dialog.
	     * @param {String} dialogName The dialog's registered name.
	     * @constructor
	     * @example
	     * var dialogObj = new CKEDITOR.dialog( editor, 'smiley' );
	     */
	    CKEDITOR.dialog = function( editordialogName )
	    {
		        // Load the dialog definition.
		        var definition CKEDITOR.dialog._.dialogDefinitionsdialogName ];
		        // Completes the definition with the default values.
		        definition CKEDITOR.tools.extenddefinitioneditor ), defaultDialogDefinition );
		        // Clone a functionally independent copy for this dialog.
		        definition CKEDITOR.tools.clone( definition );
		        // Create a complex definition object, extending it with the API
		        // functions.
		        definition = new definitionObjectthisdefinition );
		        var doc CKEDITOR.document;
		        var themeBuilt editor.theme.buildDialogeditor );
		        // Initialize some basic parameters.
		        this.=
		        {
			            editor editor,
			            element themeBuilt.element,
			            name dialogName,
			            contentSize : { width 0height 0
				},
			            size : { width 0height 0
				},
			            updateSize false,
			            contents {},
			            buttons {},
			            accessKeyMap {},
			            // Initialize the tab and page map.
			            tabs {},
			            tabIdList [],
			            currentTabId null,
			            currentTabIndex null,
			            pageCount 0,
			            lastTab null,
			            tabBarMode false,
			            // Initialize the tab order array for input widgets.
			            focusList [],
			            currentFocusIndex 0,
			            hasFocus false
			        };
		        this.parts themeBuilt.parts;
		        CKEDITOR.tools.setTimeout( function()
		            {
			                editor.fire'ariaWidget'this.parts.contents );
			            },
		            0this );
		        // Set the startup styles for the dialog, avoiding it enlarging the
		        // page size on the dialog creation.
		        this.parts.dialog.setStyles(
		            {
			                position CKEDITOR.env.ie6Compat 'absolute' 'fixed',
			                top 0,
			                left0,
			                visibility 'hidden'
			            });
		        // Call the CKEDITOR.event constructor to initialize this instance.
		        CKEDITOR.event.callthis );
		        // Fire the "dialogDefinition" event, making it possible to customize
		        // the dialog definition.
		        this.definition definition CKEDITOR.fire'dialogDefinition',
		            {
			                name dialogName,
			                definition definition
			            }
		            , editor ).definition;
		        // Initialize load, show, hide, ok and cancel events.
		        if ( definition.onLoad )
		            this.on'load'definition.onLoad );
		        if ( definition.onShow )
		            this.on'show'definition.onShow );
		        if ( definition.onHide )
		            this.on'hide'definition.onHide );
		        if ( definition.onOk )
		        {
			            this.on'ok', function( evt )
			                {
				                    // Dialog confirm might probably introduce content changes (#5415).
				                    editor.fire'saveSnapshot' );
				                    setTimeout( function () {
					editor.fire'saveSnapshot' );
					}, );
				                    if ( definition.onOk.callthisevt ) === false )
				                        evt.data.hide false;
				                });
			        }
		        if ( definition.onCancel )
		        {
			            this.on'cancel', function( evt )
			                {
				                    if ( definition.onCancel.callthisevt ) === false )
				                        evt.data.hide false;
				                });
			        }
		        var me this;
		        // Iterates over all items inside all content in the dialog, calling a
		        // function for each of them.
		        var iterContents = function( func )
		        {
			            var contents me._.contents,
			                stop false;
			            for ( var i in contents )
			            {
				                for ( var j in contents[i] )
				                {
					                    stop func.callthiscontents[i][j] );
					                    if ( stop )
					                        return;
					                }
				            }
			        };
		        this.on'ok', function( evt )
		            {
			                iterContents( function( item )
			                    {
				                        if ( item.validate )
				                        {
					                            var isValid item.validatethis );
					                            if ( typeof isValid == 'string' )
					                            {
						                                alertisValid );
						                                isValid false;
						                            }
					                            if ( isValid === false )
					                            {
						                                if ( item.select )
						                                    item.select();
						                                else
						                                    item.focus();
						                                evt.data.hide false;
						                                evt.stop();
						                                return true;
						                            }
					                        }
				                    });
			            }, thisnull);
		        this.on'cancel', function( evt )
		            {
			                iterContents( function( item )
			                    {
				                        if ( item.isChanged() )
				                        {
					                            if ( !confirmeditor.lang.common.confirmCancel ) )
					                                evt.data.hide false;
					                            return true;
					                        }
				                    });
			            }, thisnull);
		        this.parts.close.on'click', function( evt )
		                {
			                    if ( this.fire'cancel', { hide true
				} ).hide !== false )
			                        this.hide();
			                    evt.data.preventDefault();
			                }, this );
		        // Sort focus list according to tab order definitions.
		        function setupFocus()
		        {
			            var focusList me._.focusList;
			            focusList.sort( function( a)
			                {
				                    // Mimics browser tab order logics;
				                    if ( a.tabIndex != b.tabIndex )
				                        return b.tabIndex a.tabIndex;
				                    //  Sort is not stable in some browsers,
				                    // fall-back the comparator to 'focusIndex';
				                    else
				                        return a.focusIndex b.focusIndex;
				                });
			            var size focusList.length;
			            for ( var 0;
			 size;
			 i++ )
			                focusList].focusIndex i;
			        }
		        function changeFocusforward )
		        {
			            var focusList me._.focusList,
			                offset forward : -1;
			            if ( focusList.length )
			                return;
			            var current me._.currentFocusIndex;
			            // Trigger the 'blur' event of  any input element before anything,
			            // since certain UI updates may depend on it.
			            try
			            {
				                focusListcurrent ].getInputElement().$.blur();
				            }
			            catch( ){}
			            var startIndex = ( current offset focusList.length ) % focusList.length,
			                currentIndex startIndex;
			            while ( !focusListcurrentIndex ].isFocusable() )
			            {
				                currentIndex = ( currentIndex offset focusList.length ) % focusList.length;
				                if ( currentIndex == startIndex )
				                    break;
				            }
			            focusListcurrentIndex ].focus();
			            // Select whole field content.
			            if ( focusListcurrentIndex ].type == 'text' )
			                focusListcurrentIndex ].select();
			        }
		        this.changeFocus changeFocus;
		        var processed;
		        function focusKeydownHandlerevt )
		        {
			            // If I'm not the top dialog, ignore.
			            if ( me != CKEDITOR.dialog._.currentTop )
			                return;
			            var keystroke evt.data.getKeystroke(),
			                rtl editor.lang.dir == 'rtl';
			            processed 0;
			            if ( keystroke == || keystroke == CKEDITOR.SHIFT )
			            {
				                var shiftPressed = ( keystroke == CKEDITOR.SHIFT );
				                // Handling Tab and Shift-Tab.
				                if ( me._.tabBarMode )
				                {
					                    // Change tabs.
					                    var nextId shiftPressed getPreviousVisibleTab.callme ) : getNextVisibleTab.callme );
					                    me.selectPagenextId );
					                    me._.tabsnextId ][ ].focus();
					                }
				                else
				                {
					                    // Change the focus of inputs.
					                    changeFocus( !shiftPressed );
					                }
				                processed 1;
				            }
			            else if ( keystroke == CKEDITOR.ALT 121 && !me._.tabBarMode && me.getPageCount() > )
			            {
				                // Alt-F10 puts focus into the current tab item in the tab bar.
				                me._.tabBarMode true;
				                me._.tabsme._.currentTabId ][ ].focus();
				                processed 1;
				            }
			            else if ( ( keystroke == 37 || keystroke == 39 ) && me._.tabBarMode )
			            {
				                // Arrow keys - used for changing tabs.
				                nextId = ( keystroke == ( rtl 39 37 ) ? getPreviousVisibleTab.callme ) : getNextVisibleTab.callme ) );
				                me.selectPagenextId );
				                me._.tabsnextId ][ ].focus();
				                processed 1;
				            }
			            else if ( ( keystroke == 13 || keystroke == 32 ) && me._.tabBarMode )
			            {
				                this.selectPagethis._.currentTabId );
				                this._.tabBarMode false;
				                this._.currentFocusIndex = -1;
				                changeFocustrue );
				                processed 1;
				            }
			            if ( processed )
			            {
				                evt.stop();
				                evt.data.preventDefault();
				            }
			        }
		        function focusKeyPressHandlerevt )
		        {
			            processed && evt.data.preventDefault();
			        }
		        var dialogElement this._.element;
		        // Add the dialog keyboard handlers.
		        this.on'show', function()
		            {
			                dialogElement.on'keydown'focusKeydownHandlerthisnull);
			                // Some browsers instead, don't cancel key events in the keydown, but in the
			                // keypress. So we must do a longer trip in those cases. (#4531)
			                if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ) )
			                    dialogElement.on'keypress'focusKeyPressHandlerthis );
			            } );
		        this.on'hide', function()
		            {
			                dialogElement.removeListener'keydown'focusKeydownHandler );
			                if ( CKEDITOR.env.opera || ( CKEDITOR.env.gecko && CKEDITOR.env.mac ) )
			                    dialogElement.removeListener'keypress'focusKeyPressHandler );
			            } );
		        this.on'iframeAdded', function( evt )
		            {
			                var doc = new CKEDITOR.dom.documentevt.data.iframe.$.contentWindow.document );
			                doc.on'keydown'focusKeydownHandlerthisnull);
			            } );
		        // Auto-focus logic in dialog.
		        this.on'show', function()
		            {
			                // Setup tabIndex on showing the dialog instead of on loading
			                // to allow dynamic tab order happen in dialog definition.
			                setupFocus();
			                if ( editor.config.dialog_startupFocusTab
			                    && me._.pageCount )
			                {
				                    me._.tabBarMode true;
				                    me._.tabsme._.currentTabId ][ ].focus();
				                }
			                else if ( !this._.hasFocus )
			                {
				                    this._.currentFocusIndex = -1;
				                    // Decide where to put the initial focus.
				                    if ( definition.onFocus )
				                    {
					                        var initialFocus definition.onFocus.callthis );
					                        // Focus the field that the user specified.
					                        initialFocus && initialFocus.focus();
					                    }
				                    // Focus the first field in layout order.
				                    else
				                        changeFocustrue );
				                    /*
				                     * IE BUG: If the initial focus went into a non-text element (e.g. button),
				                     * then IE would still leave the caret inside the editing area.
				                     */
				                    if ( this._.editor.mode == 'wysiwyg' && CKEDITOR.env.ie )
				                    {
					                        var $selection editor.document.$.selection,
					                            $range $selection.createRange();
					                        if ( $range )
					                        {
						                            if ( $range.parentElement && $range.parentElement().ownerDocument == editor.document.$
						                              || $range.item && $range.item).ownerDocument == editor.document.$ )
						                            {
							                                var $myRange document.body.createTextRange();
							                                $myRange.moveToElementTextthis.getElement().getFirst().$ );
							                                $myRange.collapsetrue );
							                                $myRange.select();
							                            }
						                        }
					                    }
				                }
			            }, thisnull0xffffffff );
		        // IE6 BUG: Text fields and text areas are only half-rendered the first time the dialog appears in IE6 (#2661).
		        // This is still needed after [2708] and [2709] because text fields in hidden TR tags are still broken.
		        if ( CKEDITOR.env.ie6Compat )
		        {
			            this.on'load', function( evt )
			                    {
				                        var outer this.getElement(),
				                            inner outer.getFirst();
				                        inner.remove();
				                        inner.appendToouter );
				                    }, this );
			        }
		        initDragAndDropthis );
		        initResizeHandlesthis );
		        // Insert the title.
		        ( new CKEDITOR.dom.textdefinition.titleCKEDITOR.document ) ).appendTothis.parts.title );
		        // Insert the tabs and contents.
		        for ( var ;
		 definition.contents.length ;
		 i++ )
		        {
			            var page definition.contents[i];
			            page && this.addPagepage );
			        }
		        this.parts['tabs'].on'click', function( evt )
		                {
			                    var target evt.data.getTarget();
			                    // If we aren't inside a tab, bail out.
			                    if ( target.hasClass'cke_dialog_tab' ) )
			                    {
				                        // Get the ID of the tab, without the 'cke_' prefix and the unique number suffix.
				                        var id target.$.id;
				                        this.selectPageid.substring4id.lastIndexOf'_' ) ) );
				                        if ( this._.tabBarMode )
				                        {
					                            this._.tabBarMode false;
					                            this._.currentFocusIndex = -1;
					                            changeFocustrue );
					                        }
				                        evt.data.preventDefault();
				                    }
			                }, this );
		        // Insert buttons.
		        var buttonsHtml [],
		            buttons CKEDITOR.dialog._.uiElementBuilders.hbox.buildthis,
		                {
			                    type 'hbox',
			                    className 'cke_dialog_footer_buttons',
			                    widths [],
			                    children definition.buttons
			                }, buttonsHtml ).getChild();
		        this.parts.footer.setHtmlbuttonsHtml.join'' ) );
		        for ( ;
		 buttons.length ;
		 i++ )
		            this._.buttonsbuttons[i].id ] = buttons[i];
		    };
	    // Focusable interface. Use it via dialog.addFocusable.
	    function Focusabledialogelementindex )
	    {
		        this.element element;
		        this.focusIndex index;
		        // TODO: support tabIndex for focusables.
		        this.tabIndex 0;
		        this.isFocusable = function()
		        {
			            return !element.getAttribute'disabled' ) && element.isVisible();
			        };
		        this.focus = function()
		        {
			            dialog._.currentFocusIndex this.focusIndex;
			            this.element.focus();
			        };
		        // Bind events
		        element.on'keydown', function( )
		            {
			                if ( e.data.getKeystroke() in 32:113:1
				}  )
			                    this.fire'click' );
			            } );
		        element.on'focus', function()
		            {
			                this.fire'mouseover' );
			            } );
		        element.on'blur', function()
		            {
			                this.fire'mouseout' );
			            } );
		    }
	    CKEDITOR.dialog.prototype =
	    {
		        destroy : function()
		        {
			            this.hide();
			            this._.element.remove();
			        },
		        /**
		         * Resizes the dialog.
		         * @param {Number} width The width of the dialog in pixels.
		         * @param {Number} height The height of the dialog in pixels.
		         * @function
		         * @example
		         * dialogObj.resize( 800, 640 );
		         */
		        resize : (function()
		        {
			            return function( widthheight )
			            {
				                if ( this._.contentSize && this._.contentSize.width == width && this._.contentSize.height == height )
				                    return;
				                CKEDITOR.dialog.fire'resize',
				                    {
					                        dialog this,
					                        skin this._.editor.skinName,
					                        width width,
					                        height height
					                    }, this._.editor );
				                this._.contentSize = { width widthheight height
					};
				                this._.updateSize true;
				            };
			        })(),
		        /**
		         * Gets the current size of the dialog in pixels.
		         * @returns {Object} An object with "width" and "height" properties.
		         * @example
		         * var width = dialogObj.getSize().width;
		         */
		        getSize : function()
		        {
			            if ( !this._.updateSize )
			                return this._.size;
			            var element this._.element.getFirst();
			            var size this._.size = { width element.$.offsetWidth || 0height element.$.offsetHeight || 0};
			            // If either the offsetWidth or offsetHeight is 0, the element isn't visible.
			            this._.updateSize = !size.width || !size.height;
			            return size;
			        },
		        /**
		         * Moves the dialog to an (x, y) coordinate relative to the window.
		         * @function
		         * @param {Number} x The target x-coordinate.
		         * @param {Number} y The target y-coordinate.
		         * @example
		         * dialogObj.move( 10, 40 );
		         */
		        move : (function()
		        {
			            var isFixed;
			            return function( x)
			            {
				                // The dialog may be fixed positioned or absolute positioned. Ask the
				                // browser what is the current situation first.
				                var element this._.element.getFirst();
				                if ( isFixed === undefined )
				                    isFixed element.getComputedStyle'position' ) == 'fixed';
				                if ( isFixed && this._.position && this._.position.== && this._.position.== )
				                    return;
				                // Save the current position.
				                this._.position = { xy
					};
				                // If not fixed positioned, add scroll position to the coordinates.
				                if ( !isFixed )
				                {
					                    var scrollPosition CKEDITOR.document.getWindow().getScrollPosition();
					                    += scrollPosition.x;
					                    += scrollPosition.y;
					                }
				                element.setStyles(
				                        {
					                            'left'    : ( ) + 'px',
					                            'top'    : ( ) + 'px'
					                        });
				            };
			        })(),
		        /**
		         * Gets the dialog's position in the window.
		         * @returns {Object} An object with "x" and "y" properties.
		         * @example
		         * var dialogX = dialogObj.getPosition().x;
		         */
		        getPosition : function(){ return CKEDITOR.tools.extend{}this._.position );
			},
		        /**
		         * Shows the dialog box.
		         * @example
		         * dialogObj.show();
		         */
		        show : function()
		        {
			            var editor this._.editor;
			            if ( editor.mode == 'wysiwyg' && CKEDITOR.env.ie )
			            {
				                var selection editor.getSelection();
				                selection && selection.lock();
				            }
			            // Insert the dialog's element to the root document.
			            var element this._.element;
			            var definition this.definition;
			            if ( !( element.getParent() && element.getParent().equalsCKEDITOR.document.getBody() ) ) )
			                element.appendToCKEDITOR.document.getBody() );
			            else
			                element.setStyle'display''block' );
			            // FIREFOX BUG: Fix vanishing caret for Firefox 2 or Gecko 1.8.
			            if ( CKEDITOR.env.gecko && CKEDITOR.env.version 10900 )
			            {
				                var dialogElement this.parts.dialog;
				                dialogElement.setStyle'position''absolute' );
				                setTimeout( function()
				                    {
					                        dialogElement.setStyle'position''fixed' );
					                    }, );
				            }
			            // First, set the dialog to an appropriate size.
			            this.resizedefinition.minWidthdefinition.minHeight );
			            // Reset all inputs back to their default value.
			            this.reset();
			            // Select the first tab by default.
			            this.selectPagethis.definition.contents[0].id );
			            // Set z-index.
			            if ( CKEDITOR.dialog._.currentZIndex === null )
			                CKEDITOR.dialog._.currentZIndex this._.editor.config.baseFloatZIndex;
			            this._.element.getFirst().setStyle'z-index'CKEDITOR.dialog._.currentZIndex += 10 );
			            // Maintain the dialog ordering and dialog cover.
			            // Also register key handlers if first dialog.
			            if ( CKEDITOR.dialog._.currentTop === null )
			            {
				                CKEDITOR.dialog._.currentTop this;
				                this._.parentDialog null;
				                showCoverthis._.editor );
				                element.on'keydown'accessKeyDownHandler );
				                element.onCKEDITOR.env.opera 'keypress' 'keyup'accessKeyUpHandler );
				                // Prevent some keys from bubbling up. (#4269)
				                for ( var event in keyup :1keydown :1keypress :1
					} )
				                    element.oneventpreventKeyBubbling );
				            }
			            else
			            {
				                this._.parentDialog CKEDITOR.dialog._.currentTop;
				                var parentElement this._.parentDialog.getElement().getFirst();
				                parentElement.$.style.zIndex  -= Math.floorthis._.editor.config.baseFloatZIndex );
				                CKEDITOR.dialog._.currentTop this;
				            }
			            // Register the Esc hotkeys.
			            registerAccessKeythisthis'\x1b'null, function()
			                    {
				                        this.getButton'cancel' ) && this.getButton'cancel' ).click();
				                    } );
			            // Reset the hasFocus state.
			            this._.hasFocus false;
			            // Rearrange the dialog to the middle of the window.
			            CKEDITOR.tools.setTimeout( function()
			                {
				                    var viewSize CKEDITOR.document.getWindow().getViewPaneSize();
				                    var dialogSize this.getSize();
				                    // We're using definition size for initial position because of
				                    // offten corrupted data in offsetWidth at this point. (#4084)
				                    this.move( ( viewSize.width definition.minWidth ) / 2, ( viewSize.height dialogSize.height ) / );
				                    this.parts.dialog.setStyle'visibility''' );
				                    // Execute onLoad for the first show.
				                    this.fireOnce'load'{} );
				                    this.fire'show'{} );
				                    this._.editor.fire'dialogShow'this );
				                    // Save the initial values of the dialog.
				                    this.foreach( function( contentObj ) {
					contentObj.setInitValue && contentObj.setInitValue();
					} );
				                },
			                100this );
			        },
		        /**
		         * Executes a function for each UI element.
		         * @param {Function} fn Function to execute for each UI element.
		         * @returns {CKEDITOR.dialog} The current dialog object.
		         */
		        foreach : function( fn )
		        {
			            for ( var i in this._.contents )
			            {
				                for ( var j in this._.contents[i] )
				                    fnthis._.contents[i][j] );
				            }
			            return this;
			        },
		        /**
		         * Resets all input values in the dialog.
		         * @example
		         * dialogObj.reset();
		         * @returns {CKEDITOR.dialog} The current dialog object.
		         */
		        reset : (function()
		        {
			            var fn = function( widget ){ if ( widget.reset widget.reset);
				};
			            return function(){ this.foreach( fn );
				 return this;
				};
			        })(),
		        setupContent : function()
		        {
			            var args arguments;
			            this.foreach( function( widget )
			                {
				                    if ( widget.setup )
				                        widget.setup.applywidgetargs );
				                });
			        },
		        commitContent : function()
		        {
			            var args arguments;
			            this.foreach( function( widget )
			                {
				                    if ( widget.commit )
				                        widget.commit.applywidgetargs );
				                });
			        },
		        /**
		         * Hides the dialog box.
		         * @example
		         * dialogObj.hide();
		         */
		        hide : function()
		        {
			            if ( !this.parts.dialog.isVisible() )
			                return;
			            this.fire'hide'{} );
			            this._.editor.fire'dialogHide'this );
			            var element this._.element;
			            element.setStyle'display''none' );
			            this.parts.dialog.setStyle'visibility''hidden' );
			            // Unregister all access keys associated with this dialog.
			            unregisterAccessKeythis );
			            // Close any child(top) dialogs first.
			            while( CKEDITOR.dialog._.currentTop != this )
			                CKEDITOR.dialog._.currentTop.hide();
			            // Maintain dialog ordering and remove cover if needed.
			            if ( !this._.parentDialog )
			                hideCover();
			            else
			            {
				                var parentElement this._.parentDialog.getElement().getFirst();
				                parentElement.setStyle'z-index'parseIntparentElement.$.style.zIndex10 ) + Math.floorthis._.editor.config.baseFloatZIndex ) );
				            }
			            CKEDITOR.dialog._.currentTop this._.parentDialog;
			            // Deduct or clear the z-index.
			            if ( !this._.parentDialog )
			            {
				                CKEDITOR.dialog._.currentZIndex null;
				                // Remove access key handlers.
				                element.removeListener'keydown'accessKeyDownHandler );
				                element.removeListenerCKEDITOR.env.opera 'keypress' 'keyup'accessKeyUpHandler );
				                // Remove bubbling-prevention handler. (#4269)
				                for ( var event in keyup :1keydown :1keypress :1
					} )
				                    element.removeListenereventpreventKeyBubbling );
				                var editor this._.editor;
				                editor.focus();
				                if ( editor.mode == 'wysiwyg' && CKEDITOR.env.ie )
				                {
					                    var selection editor.getSelection();
					                    selection && selection.unlocktrue );
					                }
				            }
			            else
			                CKEDITOR.dialog._.currentZIndex -= 10;
			            delete this._.parentDialog;
			            // Reset the initial values of the dialog.
			            this.foreach( function( contentObj ) {
				contentObj.resetInitValue && contentObj.resetInitValue();
				} );
			        },
		        /**
		         * Adds a tabbed page into the dialog.
		         * @param {Object} contents Content definition.
		         * @example
		         */
		        addPage : function( contents )
		        {
			            var pageHtml [],
			                titleHtml contents.label ' title="' CKEDITOR.tools.htmlEncodecontents.label ) + '"' '',
			                elements contents.elements,
			                vbox CKEDITOR.dialog._.uiElementBuilders.vbox.buildthis,
			                        {
				                            type 'vbox',
				                            className 'cke_dialog_page_contents',
				                            children contents.elements,
				                            expand : !!contents.expand,
				                            padding contents.padding,
				                            style contents.style || 'width: 100%;
				 height: 100%;
				'
				                        }, pageHtml );
			            // Create the HTML for the tab and the content block.
			            var page CKEDITOR.dom.element.createFromHtmlpageHtml.join'' ) );
			            page.setAttribute'role''tabpanel' );
			            var env CKEDITOR.env;
			            var tabId 'cke_' contents.id '_' CKEDITOR.tools.getNextNumber(),
			                 tab CKEDITOR.dom.element.createFromHtml( [
			                    '<a class="cke_dialog_tab"',
			                        ( this._.pageCount ' cke_last' 'cke_first' ),
			                        titleHtml,
			                        ( !!contents.hidden ' style="display:none"' '' ),
			                        ' id="'tabId'"',
			                        env.gecko && env.version >= 10900 && !env.hc '' ' href="javascript:void(0)"',
			                        ' tabIndex="-1"',
			                        ' hidefocus="true"',
			                        ' role="tab">',
			                            contents.label,
			                    '</a>'
			                ].join'' ) );
			            page.setAttribute'aria-labelledby'tabId );
			            // Take records for the tabs and elements created.
			            this._.tabscontents.id ] = [ tabpage ];
			            this._.tabIdList.pushcontents.id );
			            !contents.hidden && this._.pageCount++;
			            this._.lastTab tab;
			            this.updateStyle();
			            var contentMap this._.contentscontents.id ] = {},
			                cursor,
			                children vbox.getChild();
			            while ( ( cursor children.shift() ) )
			            {
				                contentMapcursor.id ] = cursor;
				                if ( typeofcursor.getChild ) == 'function' )
				                    children.push.applychildrencursor.getChild() );
				            }
			            // Attach the DOM nodes.
			            page.setAttribute'name'contents.id );
			            page.appendTothis.parts.contents );
			            tab.unselectable();
			            this.parts.tabs.appendtab );
			            // Add access key handlers if access key is defined.
			            if ( contents.accessKey )
			            {
				                registerAccessKeythisthis'CTRL+' contents.accessKey,
				                    tabAccessKeyDowntabAccessKeyUp );
				                this._.accessKeyMap'CTRL+' contents.accessKey ] = contents.id;
				            }
			        },
		        /**
		         * Activates a tab page in the dialog by its id.
		         * @param {String} id The id of the dialog tab to be activated.
		         * @example
		         * dialogObj.selectPage( 'tab_1' );
		         */
		        selectPage : function( id )
		        {
			            if ( this._.currentTabId == id )
			                return;
			            // Returning true means that the event has been canceled
			            if ( this.fire'selectPage', { page idcurrentPage this._.currentTabId
				} ) === true )
			                return;
			            // Hide the non-selected tabs and pages.
			            for ( var i in this._.tabs )
			            {
				                var tab this._.tabs[i][0],
				                    page this._.tabs[i][1];
				                if ( != id )
				                {
					                    tab.removeClass'cke_dialog_tab_selected' );
					                    page.hide();
					                }
				                page.setAttribute'aria-hidden'!= id );
				            }
			            var selected this._.tabs[id];
			            selected[0].addClass'cke_dialog_tab_selected' );
			            // [IE] a unvisible input[type='text'] will enlarge it's width
			            // if it's value is long when it show( #5649 )
			            // so we clear it's value before it shows and then recover it
			            if ( CKEDITOR.env.ie6Compat || CKEDITOR.env.ie7Compat )
			            {
				                clearOrRecoverTextInputValueselected[1] );
				                selected[1].show();
				                setTimeout( function()
				                {
					                    clearOrRecoverTextInputValueselected[1], true );
					                }, );
				            }
			            else
			            {
				                selected[1].show();
				            }
			            this._.currentTabId id;
			            this._.currentTabIndex CKEDITOR.tools.indexOfthis._.tabIdListid );
			        },
		        // Dialog state-specific style updates.
		        updateStyle : function()
		        {
			            // If only a single page shown, a different style is used in the central pane.
			            this.parts.dialog[ ( this._.pageCount === 'add' 'remove' ) + 'Class' ]( 'cke_single_page' );
			        },
		        /**
		         * Hides a page's tab away from the dialog.
		         * @param {String} id The page's Id.
		         * @example
		         * dialog.hidePage( 'tab_3' );
		         */
		        hidePage : function( id )
		        {
			            var tab this._.tabs[id] && this._.tabs[id][0];
			            if ( !tab || this._.pageCount == )
			                return;
			            // Switch to other tab first when we're hiding the active tab.
			            else if ( id == this._.currentTabId )
			                this.selectPagegetPreviousVisibleTab.callthis ) );
			            tab.hide();
			            this._.pageCount--;
			            this.updateStyle();
			        },
		        /**
		         * Unhides a page's tab.
		         * @param {String} id The page's Id.
		         * @example
		         * dialog.showPage( 'tab_2' );
		         */
		        showPage : function( id )
		        {
			            var tab this._.tabs[id] && this._.tabs[id][0];
			            if ( !tab )
			                return;
			            tab.show();
			            this._.pageCount++;
			            this.updateStyle();
			        },
		        /**
		         * Gets the root DOM element of the dialog.
		         * @returns {CKEDITOR.dom.element} The &lt;
		span&gt;
		 element containing this dialog.
		         * @example
		         * var dialogElement = dialogObj.getElement().getFirst();
		         * dialogElement.setStyle( 'padding', '5px' );
		         */
		        getElement : function()
		        {
			            return this._.element;
			        },
		        /**
		         * Gets the name of the dialog.
		         * @returns {String} The name of this dialog.
		         * @example
		         * var dialogName = dialogObj.getName();
		         */
		        getName : function()
		        {
			            return this._.name;
			        },
		        /**
		         * Gets a dialog UI element object from a dialog page.
		         * @param {String} pageId id of dialog page.
		         * @param {String} elementId id of UI element.
		         * @example
		         * @returns {CKEDITOR.ui.dialog.uiElement} The dialog UI element.
		         */
		        getContentElement : function( pageIdelementId )
		        {
			            var page this._.contentspageId ];
			            return page && pageelementId ];
			        },
		        /**
		         * Gets the value of a dialog UI element.
		         * @param {String} pageId id of dialog page.
		         * @param {String} elementId id of UI element.
		         * @example
		         * @returns {Object} The value of the UI element.
		         */
		        getValueOf : function( pageIdelementId )
		        {
			            return this.getContentElementpageIdelementId ).getValue();
			        },
		        /**
		         * Sets the value of a dialog UI element.
		         * @param {String} pageId id of the dialog page.
		         * @param {String} elementId id of the UI element.
		         * @param {Object} value The new value of the UI element.
		         * @example
		         */
		        setValueOf : function( pageIdelementIdvalue )
		        {
			            return this.getContentElementpageIdelementId ).setValuevalue );
			        },
		        /**
		         * Gets the UI element of a button in the dialog's button row.
		         * @param {String} id The id of the button.
		         * @example
		         * @returns {CKEDITOR.ui.dialog.button} The button object.
		         */
		        getButton : function( id )
		        {
			            return this._.buttonsid ];
			        },
		        /**
		         * Simulates a click to a dialog button in the dialog's button row.
		         * @param {String} id The id of the button.
		         * @example
		         * @returns The return value of the dialog's "click" event.
		         */
		        click : function( id )
		        {
			            return this._.buttonsid ].click();
			        },
		        /**
		         * Disables a dialog button.
		         * @param {String} id The id of the button.
		         * @example
		         */
		        disableButton : function( id )
		        {
			            return this._.buttonsid ].disable();
			        },
		        /**
		         * Enables a dialog button.
		         * @param {String} id The id of the button.
		         * @example
		         */
		        enableButton : function( id )
		        {
			            return this._.buttonsid ].enable();
			        },
		        /**
		         * Gets the number of pages in the dialog.
		         * @returns {Number} Page count.
		         */
		        getPageCount : function()
		        {
			            return this._.pageCount;
			        },
		        /**
		         * Gets the editor instance which opened this dialog.
		         * @returns {CKEDITOR.editor} Parent editor instances.
		         */
		        getParentEditor : function()
		        {
			            return this._.editor;
			        },
		        /**
		         * Gets the element that was selected when opening the dialog, if any.
		         * @returns {CKEDITOR.dom.element} The element that was selected, or null.
		         */
		        getSelectedElement : function()
		        {
			            return this.getParentEditor().getSelection().getSelectedElement();
			        },
		        /**
		         * Adds element to dialog's focusable list.
		         *
		         * @param {CKEDITOR.dom.element} element
		         * @param {Number} [index]
		         */
		        addFocusable: function( elementindex ) {
			            if ( typeof index == 'undefined' )
			            {
				                index this._.focusList.length;
				                this._.focusList.push( new Focusablethiselementindex ) );
				            }
			            else
			            {
				                this._.focusList.spliceindex0, new Focusablethiselementindex ) );
				                for ( var index ;
				 this._.focusList.length ;
				 i++ )
				                    this._.focusList].focusIndex++;
				            }
			        }
		    };
	    CKEDITOR.tools.extendCKEDITOR.dialog,
	        /**
	         * @lends CKEDITOR.dialog
	         */
	        {
		            /**
		             * Registers a dialog.
		             * @param {String} name The dialog's name.
		             * @param {Function|String} dialogDefinition
		             * A function returning the dialog's definition, or the URL to the .js file holding the function.
		             * The function should accept an argument "editor" which is the current editor instance, and
		             * return an object conforming to {@link CKEDITOR.dialog.dialogDefinition}.
		             * @example
		             * @see CKEDITOR.dialog.dialogDefinition
		             */
		            add : function( namedialogDefinition )
		            {
			                // Avoid path registration from multiple instances override definition.
			                if ( !this._.dialogDefinitions[name]
			                    || typeof  dialogDefinition == 'function' )
			                    this._.dialogDefinitions[name] = dialogDefinition;
			            },
		            exists : function( name )
		            {
			                return !!this._.dialogDefinitionsname ];
			            },
		            getCurrent : function()
		            {
			                return CKEDITOR.dialog._.currentTop;
			            },
		            /**
		             * The default OK button for dialogs. Fires the "ok" event and closes the dialog if the event succeeds.
		             * @static
		             * @field
		             * @example
		             * @type Function
		             */
		            okButton : (function()
		            {
			                var retval = function( editoroverride )
			                {
				                    override override || {};
				                    return CKEDITOR.tools.extend( {
					                        id 'ok',
					                        type 'button',
					                        label editor.lang.common.ok,
					                        'class' 'cke_dialog_ui_button_ok',
					                        onClick : function( evt )
					                        {
						                            var dialog evt.data.dialog;
						                            if ( dialog.fire'ok', { hide true
							} ).hide !== false )
						                                dialog.hide();
						                        }
					                    }, overridetrue );
				                };
			                retval.type 'button';
			                retval.override = function( override )
			                {
				                    return CKEDITOR.tools.extend( function( editor ){ return retvaleditoroverride );
					},
				                            { type 'button'
					}, true );
				                };
			                return retval;
			            })(),
		            /**
		             * The default cancel button for dialogs. Fires the "cancel" event and closes the dialog if no UI element value changed.
		             * @static
		             * @field
		             * @example
		             * @type Function
		             */
		            cancelButton : (function()
		            {
			                var retval = function( editoroverride )
			                {
				                    override override || {};
				                    return CKEDITOR.tools.extend( {
					                        id 'cancel',
					                        type 'button',
					                        label editor.lang.common.cancel,
					                        'class' 'cke_dialog_ui_button_cancel',
					                        onClick : function( evt )
					                        {
						                            var dialog evt.data.dialog;
						                            if ( dialog.fire'cancel', { hide true
							} ).hide !== false )
						                                dialog.hide();
						                        }
					                    }, overridetrue );
				                };
			                retval.type 'button';
			                retval.override = function( override )
			                {
				                    return CKEDITOR.tools.extend( function( editor ){ return retvaleditoroverride );
					},
				                            { type 'button'
					}, true );
				                };
			                return retval;
			            })(),
		            /**
		             * Registers a dialog UI element.
		             * @param {String} typeName The name of the UI element.
		             * @param {Function} builder The function to build the UI element.
		             * @example
		             */
		            addUIElement : function( typeNamebuilder )
		            {
			                this._.uiElementBuilderstypeName ] = builder;
			            }
		        });
	    CKEDITOR.dialog.=
	    {
		        uiElementBuilders {},
		        dialogDefinitions {},
		        currentTop null,
		        currentZIndex null
		    };
	    // "Inherit" (copy actually) from CKEDITOR.event.
	    CKEDITOR.event.implementOnCKEDITOR.dialog );
	    CKEDITOR.event.implementOnCKEDITOR.dialog.prototypetrue );
	    var defaultDialogDefinition =
	    {
		        resizable CKEDITOR.DIALOG_RESIZE_BOTH,
		        minWidth 600,
		        minHeight 400,
		        buttons : [ CKEDITOR.dialog.okButtonCKEDITOR.dialog.cancelButton ]
		    };
	    // The buttons in MacOS Apps are in reverse order #4750
	    CKEDITOR.env.mac && defaultDialogDefinition.buttons.reverse();
	    // Tool function used to return an item from an array based on its id
	    // property.
	    var getById = function( array, idrecurse )
	    {
		        for ( var 0item ;
		 ( item = array[ ] ) ;
		 i++ )
		        {
			            if ( item.id == id )
			                return item;
			            if ( recurse && itemrecurse ] )
			            {
				                var retval getByIditemrecurse ], idrecurse ) ;
				                if ( retval )
				                    return retval;
				            }
			        }
		        return null;
		    };
	    // Tool function used to add an item into an array.
	    var addById = function( array, newItemnextSiblingIdrecursenullIfNotFound )
	    {
		        if ( nextSiblingId )
		        {
			            for ( var 0item ;
			 ( item = array[ ] ) ;
			 i++ )
			            {
				                if ( item.id == nextSiblingId )
				                {
					                    array.splicei0newItem );
					                    return newItem;
					                }
				                if ( recurse && itemrecurse ] )
				                {
					                    var retval addByIditemrecurse ], newItemnextSiblingIdrecursetrue );
					                    if ( retval )
					                        return retval;
					                }
				            }
			            if ( nullIfNotFound )
			                return null;
			        }
		        array.pushnewItem );
		        return newItem;
		    };
	    // Tool function used to remove an item from an array based on its id.
	    var removeById = function( array, idrecurse )
	    {
		        for ( var 0item ;
		 ( item = array[ ] ) ;
		 i++ )
		        {
			            if ( item.id == id )
			                return array.splicei);
			            if ( recurse && itemrecurse ] )
			            {
				                var retval removeByIditemrecurse ], idrecurse );
				                if ( retval )
				                    return retval;
				            }
			        }
		        return null;
		    };
	    /**
	     * This class is not really part of the API. It is the "definition" property value
	     * passed to "dialogDefinition" event handlers.
	     * @constructor
	     * @name CKEDITOR.dialog.dialogDefinitionObject
	     * @extends CKEDITOR.dialog.dialogDefinition
	     * @example
	     * CKEDITOR.on( 'dialogDefinition', function( evt )
	     *     {
		     *         var definition = evt.data.definition;
		     *         var content = definition.getContents( 'page1' );
		     *         ...
		     *     } );
	     */
	    var definitionObject = function( dialogdialogDefinition )
	    {
		        // TODO : Check if needed.
		        this.dialog dialog;
		        // Transform the contents entries in contentObjects.
		        var contents dialogDefinition.contents;
		        for ( var 0content ;
		 ( content contents[i] ) ;
		 i++ )
		            contents] = content && new contentObjectdialogcontent );
		        CKEDITOR.tools.extendthisdialogDefinition );
		    };
	    definitionObject.prototype =
	    /** @lends CKEDITOR.dialog.dialogDefinitionObject.prototype */
	    {
		        /**
		         * Gets a content definition.
		         * @param {String} id The id of the content definition.
		         * @returns {CKEDITOR.dialog.contentDefinition} The content definition
		         *        matching id.
		         */
		        getContents : function( id )
		        {
			            return getByIdthis.contentsid );
			        },
		        /**
		         * Gets a button definition.
		         * @param {String} id The id of the button definition.
		         * @returns {CKEDITOR.dialog.buttonDefinition} The button definition
		         *        matching id.
		         */
		        getButton : function( id )
		        {
			            return getByIdthis.buttonsid );
			        },
		        /**
		         * Adds a content definition object under this dialog definition.
		         * @param {CKEDITOR.dialog.contentDefinition} contentDefinition The
		         *        content definition.
		         * @param {String} [nextSiblingId] The id of an existing content
		         *        definition which the new content definition will be inserted
		         *        before. Omit if the new content definition is to be inserted as
		         *        the last item.
		         * @returns {CKEDITOR.dialog.contentDefinition} The inserted content
		         *        definition.
		         */
		        addContents : function( contentDefinitionnextSiblingId )
		        {
			            return addByIdthis.contentscontentDefinitionnextSiblingId );
			        },
		        /**
		         * Adds a button definition object under this dialog definition.
		         * @param {CKEDITOR.dialog.buttonDefinition} buttonDefinition The
		         *        button definition.
		         * @param {String} [nextSiblingId] The id of an existing button
		         *        definition which the new button definition will be inserted
		         *        before. Omit if the new button definition is to be inserted as
		         *        the last item.
		         * @returns {CKEDITOR.dialog.buttonDefinition} The inserted button
		         *        definition.
		         */
		        addButton : function( buttonDefinitionnextSiblingId )
		        {
			            return addByIdthis.buttonsbuttonDefinitionnextSiblingId );
			        },
		        /**
		         * Removes a content definition from this dialog definition.
		         * @param {String} id The id of the content definition to be removed.
		         * @returns {CKEDITOR.dialog.contentDefinition} The removed content
		         *        definition.
		         */
		        removeContents : function( id )
		        {
			            removeByIdthis.contentsid );
			        },
		        /**
		         * Removes a button definition from the dialog definition.
		         * @param {String} id The id of the button definition to be removed.
		         * @returns {CKEDITOR.dialog.buttonDefinition} The removed button
		         *        definition.
		         */
		        removeButton : function( id )
		        {
			            removeByIdthis.buttonsid );
			        }
		    };
	    /**
	     * This class is not really part of the API. It is the template of the
	     * objects representing content pages inside the
	     * CKEDITOR.dialog.dialogDefinitionObject.
	     * @constructor
	     * @name CKEDITOR.dialog.contentDefinitionObject
	     * @example
	     * CKEDITOR.on( 'dialogDefinition', function( evt )
	     *     {
		     *         var definition = evt.data.definition;
		     *         var content = definition.getContents( 'page1' );
		     *        content.remove( 'textInput1' );
		     *         ...
		     *     } );
	     */
	    function contentObjectdialogcontentDefinition )
	    {
		        this.=
		        {
			            dialog dialog
			        };
		        CKEDITOR.tools.extendthiscontentDefinition );
		    }
	    contentObject.prototype =
	    /** @lends CKEDITOR.dialog.contentDefinitionObject.prototype */
	    {
		        /**
		         * Gets a UI element definition under the content definition.
		         * @param {String} id The id of the UI element definition.
		         * @returns {CKEDITOR.dialog.uiElementDefinition}
		         */
		        get : function( id )
		        {
			            return getByIdthis.elementsid'children' );
			        },
		        /**
		         * Adds a UI element definition to the content definition.
		         * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition The
		         *        UI elemnet definition to be added.
		         * @param {String} nextSiblingId The id of an existing UI element
		         *        definition which the new UI element definition will be inserted
		         *        before. Omit if the new button definition is to be inserted as
		         *        the last item.
		         * @returns {CKEDITOR.dialog.uiElementDefinition} The element
		         *        definition inserted.
		         */
		        add : function( elementDefinitionnextSiblingId )
		        {
			            return addByIdthis.elementselementDefinitionnextSiblingId'children' );
			        },
		        /**
		         * Removes a UI element definition from the content definition.
		         * @param {String} id The id of the UI element definition to be
		         *        removed.
		         * @returns {CKEDITOR.dialog.uiElementDefinition} The element
		         *        definition removed.
		         * @example
		         */
		        remove : function( id )
		        {
			            removeByIdthis.elementsid'children' );
			        }
		    };
	    function initDragAndDropdialog )
	    {
		        var lastCoords null,
		            abstractDialogCoords null,
		            element dialog.getElement().getFirst(),
		            editor dialog.getParentEditor(),
		            magnetDistance editor.config.dialog_magnetDistance,
		            margins editor.skin.margins || [ 000];
		        if ( typeof magnetDistance == 'undefined' )
		            magnetDistance 20;
		        function mouseMoveHandlerevt )
		        {
			            var dialogSize dialog.getSize(),
			                viewPaneSize CKEDITOR.document.getWindow().getViewPaneSize(),
			                evt.data.$.screenX,
			                evt.data.$.screenY,
			                dx lastCoords.x,
			                dy lastCoords.y,
			                realXrealY;
			            lastCoords = { xy
				};
			            abstractDialogCoords.+= dx;
			            abstractDialogCoords.+= dy;
			            if ( abstractDialogCoords.margins[3] < magnetDistance )
			                realX = - margins[3];
			            else if ( abstractDialogCoords.margins[1] > viewPaneSize.width dialogSize.width magnetDistance )
			                realX viewPaneSize.width dialogSize.width margins[1];
			            else
			                realX abstractDialogCoords.x;
			            if ( abstractDialogCoords.margins[0] < magnetDistance )
			                realY = - margins[0];
			            else if ( abstractDialogCoords.margins[2] > viewPaneSize.height dialogSize.height magnetDistance )
			                realY viewPaneSize.height dialogSize.height margins[2];
			            else
			                realY abstractDialogCoords.y;
			            dialog.moverealXrealY );
			            evt.data.preventDefault();
			        }
		        function mouseUpHandlerevt )
		        {
			            CKEDITOR.document.removeListener'mousemove'mouseMoveHandler );
			            CKEDITOR.document.removeListener'mouseup'mouseUpHandler );
			            if ( CKEDITOR.env.ie6Compat )
			            {
				                var coverDoc currentCover.getChild).getFrameDocument();
				                coverDoc.removeListener'mousemove'mouseMoveHandler );
				                coverDoc.removeListener'mouseup'mouseUpHandler );
				            }
			        }
		        dialog.parts.title.on'mousedown', function( evt )
		            {
			                dialog._.updateSize true;
			                lastCoords = { evt.data.$.screenXevt.data.$.screenY
				};
			                CKEDITOR.document.on'mousemove'mouseMoveHandler );
			                CKEDITOR.document.on'mouseup'mouseUpHandler );
			                abstractDialogCoords dialog.getPosition();
			                if ( CKEDITOR.env.ie6Compat )
			                {
				                    var coverDoc currentCover.getChild).getFrameDocument();
				                    coverDoc.on'mousemove'mouseMoveHandler );
				                    coverDoc.on'mouseup'mouseUpHandler );
				                }
			                evt.data.preventDefault();
			            }, dialog );
		    }
	    function initResizeHandlesdialog )
	    {
		        var definition dialog.definition,
		            minWidth definition.minWidth || 0,
		            minHeight definition.minHeight || 0,
		            resizable definition.resizable,
		            margins dialog.getParentEditor().skin.margins || [ 000];
		        function topSizercoordsdy )
		        {
			            coords.+= dy;
			        }
		        function rightSizercoordsdx )
		        {
			            coords.x2 += dx;
			        }
		        function bottomSizercoordsdy )
		        {
			            coords.y2 += dy;
			        }
		        function leftSizercoordsdx )
		        {
			            coords.+= dx;
			        }
		        var lastCoords null,
		            abstractDialogCoords null,
		            magnetDistance dialog._.editor.config.magnetDistance,
		            parts = [ 'tl''t''tr''l''r''bl''b''br' ];
		        function mouseDownHandlerevt )
		        {
			            var partName evt.listenerData.partsize dialog.getSize();
			            abstractDialogCoords dialog.getPosition();
			            CKEDITOR.tools.extendabstractDialogCoords,
			                {
				                    x2 abstractDialogCoords.size.width,
				                    y2 abstractDialogCoords.size.height
				                } );
			            lastCoords = { evt.data.$.screenXevt.data.$.screenY
				};
			            CKEDITOR.document.on'mousemove'mouseMoveHandlerdialog, { part partName
				} );
			            CKEDITOR.document.on'mouseup'mouseUpHandlerdialog, { part partName
				} );
			            if ( CKEDITOR.env.ie6Compat )
			            {
				                var coverDoc currentCover.getChild).getFrameDocument();
				                coverDoc.on'mousemove'mouseMoveHandlerdialog, { part partName
					} );
				                coverDoc.on'mouseup'mouseUpHandlerdialog, { part partName
					} );
				            }
			            evt.data.preventDefault();
			        }
		        function mouseMoveHandlerevt )
		        {
			            var evt.data.$.screenX,
			                evt.data.$.screenY,
			                dx lastCoords.x,
			                dy lastCoords.y,
			                viewPaneSize CKEDITOR.document.getWindow().getViewPaneSize(),
			                partName evt.listenerData.part;
			            if ( partName.search't' ) != -)
			                topSizerabstractDialogCoordsdy );
			            if ( partName.search'l' ) != -)
			                leftSizerabstractDialogCoordsdx );
			            if ( partName.search'b' ) != -)
			                bottomSizerabstractDialogCoordsdy );
			            if ( partName.search'r' ) != -)
			                rightSizerabstractDialogCoordsdx );
			            lastCoords = { xy
				};
			            var realXrealYrealX2realY2;
			            if ( abstractDialogCoords.margins[3] < magnetDistance )
			                realX = - margins[3];
			            else if ( partName.search'l' ) != -&& abstractDialogCoords.x2 abstractDialogCoords.minWidth magnetDistance )
			                realX abstractDialogCoords.x2 minWidth;
			            else
			                realX abstractDialogCoords.x;
			            if ( abstractDialogCoords.margins[0] < magnetDistance )
			                realY = - margins[0];
			            else if ( partName.search't' ) != -&& abstractDialogCoords.y2 abstractDialogCoords.minHeight magnetDistance )
			                realY abstractDialogCoords.y2 minHeight;
			            else
			                realY abstractDialogCoords.y;
			            if ( abstractDialogCoords.x2 margins[1] > viewPaneSize.width magnetDistance )
			                realX2 viewPaneSize.width margins[1] ;
			            else if ( partName.search'r' ) != -&& abstractDialogCoords.x2 abstractDialogCoords.minWidth magnetDistance )
			                realX2 abstractDialogCoords.minWidth;
			            else
			                realX2 abstractDialogCoords.x2;
			            if ( abstractDialogCoords.y2 margins[2] > viewPaneSize.height magnetDistance )
			                realY2viewPaneSize.height margins[2] ;
			            else if ( partName.search'b' ) != -&& abstractDialogCoords.y2 abstractDialogCoords.minHeight magnetDistance )
			                realY2 abstractDialogCoords.minHeight;
			            else
			                realY2 abstractDialogCoords.y2 ;
			            dialog.moverealXrealY );
			            dialog.resizerealX2 realXrealY2 realY );
			            evt.data.preventDefault();
			        }
		        function mouseUpHandlerevt )
		        {
			            CKEDITOR.document.removeListener'mouseup'mouseUpHandler );
			            CKEDITOR.document.removeListener'mousemove'mouseMoveHandler );
			            if ( CKEDITOR.env.ie6Compat )
			            {
				                var coverDoc currentCover.getChild).getFrameDocument();
				                coverDoc.removeListener'mouseup'mouseUpHandler );
				                coverDoc.removeListener'mousemove'mouseMoveHandler );
				            }
			        }
		// TODO : Simplify the resize logic, having just a single resize grip <div>.
		//        var widthTest = /[lr]/,
		//            heightTest = /[tb]/;
		//        for ( var i = 0 ;
		 parts.length ;
		 i++ )
		//        {
			//            var element = dialog.parts[ parts[i] + '_resize' ];
			//            if ( resizable == CKEDITOR.DIALOG_RESIZE_NONE ||
			//                    resizable == CKEDITOR.DIALOG_RESIZE_HEIGHT && widthTest.test( parts[i] ) ||
			//                      resizable == CKEDITOR.DIALOG_RESIZE_WIDTH && heightTest.test( parts[i] ) )
			//            {
				//                element.hide();
				//                continue;
				//            }
			//            element.on( 'mousedown', mouseDownHandler, dialog, { part : parts[i]
				} );
			//        }
		    }
	    var resizeCover;
	    // Caching resuable covers and allowing only one cover
	    // on screen.
	    var covers {},
	        currentCover;
	    function showCovereditor )
	    {
		        var win CKEDITOR.document.getWindow();
		        var backgroundColorStyle editor.config.dialog_backgroundCoverColor || 'white',
		            backgroundCoverOpacity editor.config.dialog_backgroundCoverOpacity,
		            baseFloatZIndex editor.config.baseFloatZIndex,
		            coverKey CKEDITOR.tools.genKey(
		                    backgroundColorStyle,
		                    backgroundCoverOpacity,
		                    baseFloatZIndex ),
		            coverElement coverscoverKey ];
		        if ( !coverElement )
		        {
			            var html = [
			                    '<div style="position: ', ( CKEDITOR.env.ie6Compat 'absolute' 'fixed' ),
			                    ';
			 z-index: 'baseFloatZIndex,
			                    ';
			 top: 0px;
			 left: 0px;
			 ',
			                    ( !CKEDITOR.env.ie6Compat 'background-color: ' backgroundColorStyle '' ),
			                    '" class="cke_dialog_background_cover">'
			                ];
			            if ( CKEDITOR.env.ie6Compat )
			            {
				                // Support for custom document.domain in IE.
				                var isCustomDomain CKEDITOR.env.isCustomDomain(),
				                    iframeHtml '<html><body style=\\\'background-color:' backgroundColorStyle ';
				\\\'></body></html>';
				                html.push(
				                    '<iframe' +
				                        ' hidefocus="true"' +
				                        ' frameborder="0"' +
				                        ' id="cke_dialog_background_iframe"' +
				                        ' src="javascript:' );
				                html.push'void((function(){' +
					                                'document.open();
					' +
					                                ( isCustomDomain 'document.domain=\'' document.domain '\';
					' '' ) +
					                                'document.write( \'' iframeHtml '\' );
					' +
					                                'document.close();
					' +
					                            '})())' );
				                html.push(
				                        '"' +
				                        ' style="' +
				                            'position:absolute;
				' +
				                            'left:0;
				' +
				                            'top:0;
				' +
				                            'width:100%;
				' +
				                            'height: 100%;
				' +
				                            'progid:DXImageTransform.Microsoft.Alpha(opacity=0)">' +
				                    '</iframe>' );
				            }
			            html.push'</div>' );
			            coverElement CKEDITOR.dom.element.createFromHtmlhtml.join'' ) );
			            coverElement.setOpacitybackgroundCoverOpacity != undefined backgroundCoverOpacity 0.5 );
			            coverElement.appendToCKEDITOR.document.getBody() );
			            coverscoverKey ] = coverElement;
			        }
		        else
		            coverElement.    show();
		        currentCover coverElement;
		        var resizeFunc = function()
		        {
			            var size win.getViewPaneSize();
			            coverElement.setStyles(
			                {
				                    width size.width 'px',
				                    height size.height 'px'
				                } );
			        };
		        var scrollFunc = function()
		        {
			            var pos win.getScrollPosition(),
			                cursor CKEDITOR.dialog._.currentTop;
			            coverElement.setStyles(
			                    {
				                        left pos.'px',
				                        top pos.'px'
				                    });
			            do
			            {
				                var dialogPos cursor.getPosition();
				                cursor.movedialogPos.xdialogPos.);
				            } while ( ( cursor cursor._.parentDialog ) );
			        };
		        resizeCover resizeFunc;
		        win.on'resize'resizeFunc );
		        resizeFunc();
		        if ( CKEDITOR.env.ie6Compat )
		        {
			            // IE BUG: win.$.onscroll assignment doesn't work.. it must be window.onscroll.
			            // So we need to invent a really funny way to make it work.
			            var myScrollHandler = function()
			                {
				                    scrollFunc();
				                    arguments.callee.prevScrollHandler.applythisarguments );
				                };
			            win.$.setTimeout( function()
			                {
				                    myScrollHandler.prevScrollHandler window.onscroll || function(){};
				                    window.onscroll myScrollHandler;
				                }, );
			            scrollFunc();
			        }
		    }
	    function hideCover()
	    {
		        if ( !currentCover )
		            return;
		        var win CKEDITOR.document.getWindow();
		        currentCover.hide();
		        win.removeListener'resize'resizeCover );
		        if ( CKEDITOR.env.ie6Compat )
		        {
			            win.$.setTimeout( function()
			                {
				                    var prevScrollHandler window.onscroll && window.onscroll.prevScrollHandler;
				                    window.onscroll prevScrollHandler || null;
				                }, );
			        }
		        resizeCover null;
		    }
	    function removeCovers()
	    {
		        for ( var coverId in covers )
		            coverscoverId ].remove();
		        covers {};
		    }
	    var accessKeyProcessors {};
	    var accessKeyDownHandler = function( evt )
	    {
		        var ctrl evt.data.$.ctrlKey || evt.data.$.metaKey,
		            alt evt.data.$.altKey,
		            shift evt.data.$.shiftKey,
		            key String.fromCharCodeevt.data.$.keyCode ),
		            keyProcessor accessKeyProcessors[( ctrl 'CTRL+' '' ) + ( alt 'ALT+' '') + ( shift 'SHIFT+' '' ) + key];
		        if ( !keyProcessor || !keyProcessor.length )
		            return;
		        keyProcessor keyProcessor[keyProcessor.length 1];
		        keyProcessor.keydown && keyProcessor.keydown.callkeyProcessor.uiElementkeyProcessor.dialogkeyProcessor.key );
		        evt.data.preventDefault();
		    };
	    var accessKeyUpHandler = function( evt )
	    {
		        var ctrl evt.data.$.ctrlKey || evt.data.$.metaKey,
		            alt evt.data.$.altKey,
		            shift evt.data.$.shiftKey,
		            key String.fromCharCodeevt.data.$.keyCode ),
		            keyProcessor accessKeyProcessors[( ctrl 'CTRL+' '' ) + ( alt 'ALT+' '') + ( shift 'SHIFT+' '' ) + key];
		        if ( !keyProcessor || !keyProcessor.length )
		            return;
		        keyProcessor keyProcessor[keyProcessor.length 1];
		        if ( keyProcessor.keyup )
		        {
			            keyProcessor.keyup.callkeyProcessor.uiElementkeyProcessor.dialogkeyProcessor.key );
			            evt.data.preventDefault();
			        }
		    };
	    var registerAccessKey = function( uiElementdialogkeydownFuncupFunc )
	    {
		        var procList accessKeyProcessors[key] || ( accessKeyProcessors[key] = [] );
		        procList.push( {
			                uiElement uiElement,
			                dialog dialog,
			                key key,
			                keyup upFunc || uiElement.accessKeyUp,
			                keydown downFunc || uiElement.accessKeyDown
			            } );
		    };
	    var unregisterAccessKey = function( obj )
	    {
		        for ( var i in accessKeyProcessors )
		        {
			            var list = accessKeyProcessors[i];
			            for ( var = list.length ;
			 >= ;
			 j-- )
			            {
				                if ( list[j].dialog == obj || list[j].uiElement == obj )
				                    list.splicej);
				            }
			            if ( list.length === )
			                delete accessKeyProcessors[i];
			        }
		    };
	    var tabAccessKeyUp = function( dialogkey )
	    {
		        if ( dialog._.accessKeyMap[key] )
		            dialog.selectPagedialog._.accessKeyMap[key] );
		    };
	    var tabAccessKeyDown = function( dialogkey )
	    {
		    };
	    // ESC, ENTER
	    var preventKeyBubblingKeys = { 27 :113 :1
		};
	    var preventKeyBubbling = function( )
	    {
		        if ( e.data.getKeystroke() in preventKeyBubblingKeys )
		            e.data.stopPropagation();
		    };
	    (function()
	    {
		        CKEDITOR.ui.dialog =
		        {
			            /**
			             * The base class of all dialog UI elements.
			             * @constructor
			             * @param {CKEDITOR.dialog} dialog Parent dialog object.
			             * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition Element
			             * definition. Accepted fields:
			             * <ul>
			             *     <li><strong>id</strong> (Required) The id of the UI element. See {@link
				             *     CKEDITOR.dialog#getContentElement}</li>
			             *     <li><strong>type</strong> (Required) The type of the UI element. The
			             *     value to this field specifies which UI element class will be used to
			             *     generate the final widget.</li>
			             *     <li><strong>title</strong> (Optional) The popup tooltip for the UI
			             *     element.</li>
			             *     <li><strong>hidden</strong> (Optional) A flag that tells if the element
			             *     should be initially visible.</li>
			             *     <li><strong>className</strong> (Optional) Additional CSS class names
			             *     to add to the UI element. Separated by space.</li>
			             *     <li><strong>style</strong> (Optional) Additional CSS inline styles
			             *     to add to the UI element. A semicolon (;
			) is required after the last
			             *     style declaration.</li>
			             *     <li><strong>accessKey</strong> (Optional) The alphanumeric access key
			             *     for this element. Access keys are automatically prefixed by CTRL.</li>
			             *     <li><strong>on*</strong> (Optional) Any UI element definition field that
			             *     starts with <em>on</em> followed immediately by a capital letter and
			             *     probably more letters is an event handler. Event handlers may be further
			             *     divided into registered event handlers and DOM event handlers. Please
			             *     refer to {@link CKEDITOR.ui.dialog.uiElement#registerEvents} and
			             *     {@link CKEDITOR.ui.dialog.uiElement#eventProcessors} for more
			             *     information.</li>
			             * </ul>
			             * @param {Array} htmlList
			             * List of HTML code to be added to the dialog's content area.
			             * @param {Function|String} nodeNameArg
			             * A function returning a string, or a simple string for the node name for
			             * the root DOM node. Default is 'div'.
			             * @param {Function|Object} stylesArg
			             * A function returning an object, or a simple object for CSS styles applied
			             * to the DOM node. Default is empty object.
			             * @param {Function|Object} attributesArg
			             * A fucntion returning an object, or a simple object for attributes applied
			             * to the DOM node. Default is empty object.
			             * @param {Function|String} contentsArg
			             * A function returning a string, or a simple string for the HTML code inside
			             * the root DOM node. Default is empty string.
			             * @example
			             */
			            uiElement : function( dialogelementDefinitionhtmlListnodeNameArgstylesArgattributesArgcontentsArg )
			            {
				                if ( arguments.length )
				                    return;
				                var nodeName = ( nodeNameArg.call nodeNameArgelementDefinition ) : nodeNameArg ) || 'div',
				                    html = [ '<'nodeName' ' ],
				                    styles = ( stylesArg && stylesArg.call stylesArgelementDefinition ) : stylesArg ) || {},
				                    attributes = ( attributesArg && attributesArg.call attributesArgelementDefinition ) : attributesArg ) || {},
				                    innerHTML = ( contentsArg && contentsArg.call contentsArg.callthisdialogelementDefinition ) : contentsArg ) || '',
				                    domId this.domId attributes.id || CKEDITOR.tools.getNextId() + '_uiElement',
				                    id this.id elementDefinition.id,
				                    i;
				                // Set the id, a unique id is required for getElement() to work.
				                attributes.id domId;
				                // Set the type and definition CSS class names.
				                var classes {};
				                if ( elementDefinition.type )
				                    classes'cke_dialog_ui_' elementDefinition.type ] = 1;
				                if ( elementDefinition.className )
				                    classeselementDefinition.className ] = 1;
				                var attributeClasses = ( attributes['class'] && attributes['class'].split ) ? attributes['class'].split' ' ) : [];
				                for ( ;
				 attributeClasses.length ;
				 i++ )
				                {
					                    if ( attributeClasses[i] )
					                        classesattributeClasses[i] ] = 1;
					                }
				                var finalClasses [];
				                for ( i in classes )
				                    finalClasses.push);
				                attributes['class'] = finalClasses.join' ' );
				                // Set the popup tooltop.
				                if ( elementDefinition.title )
				                    attributes.title elementDefinition.title;
				                // Write the inline CSS styles.
				                var styleStr = ( elementDefinition.style || '' ).split';
				' );
				                for ( i in styles )
				                    styleStr.push':' styles[i] );
				                if ( elementDefinition.hidden )
				                    styleStr.push'display:none' );
				                for ( styleStr.length ;
				 >= ;
				 i-- )
				                {
					                    if ( styleStr[i] === '' )
					                        styleStr.splicei);
					                }
				                if ( styleStr.length )
				                    attributes.style = ( attributes.style ? ( attributes.style ';
				 ' ) : '' ) + styleStr.join';
				 ' );
				                // Write the attributes.
				                for ( i in attributes )
				                    html.push'="' CKEDITOR.tools.htmlEncodeattributes[i] ) + '" ');
				                // Write the content HTML.
				                html.push'>'innerHTML'</'nodeName'>' );
				                // Add contents to the parent HTML array.
				                htmlList.pushhtml.join'' ) );
				                ( this.|| ( this.{} ) ).dialog dialog;
				                // Override isChanged if it is defined in element definition.
				                if ( typeofelementDefinition.isChanged ) == 'boolean' )
				                    this.isChanged = function(){ return elementDefinition.isChanged;
					};
				                if ( typeofelementDefinition.isChanged ) == 'function' )
				                    this.isChanged elementDefinition.isChanged;
				                // Add events.
				                CKEDITOR.event.implementOnthis );
				                this.registerEventselementDefinition );
				                if ( this.accessKeyUp && this.accessKeyDown && elementDefinition.accessKey )
				                    registerAccessKeythisdialog'CTRL+' elementDefinition.accessKey );
				                var me this;
				                dialog.on'load', function()
				                    {
					                        if ( me.getInputElement() )
					                        {
						                            me.getInputElement().on'focus', function()
						                                {
							                                    dialog._.tabBarMode false;
							                                    dialog._.hasFocus true;
							                                    me.fire'focus' );
							                                }, me );
						                        }
					                    } );
				                // Register the object as a tab focus if it can be included.
				                if ( this.keyboardFocusable )
				                {
					                    this.tabIndex elementDefinition.tabIndex || 0;
					                    this.focusIndex dialog._.focusList.pushthis ) - 1;
					                    this.on'focus', function()
					                        {
						                            dialog._.currentFocusIndex me.focusIndex;
						                        } );
					                }
				                // Completes this object with everything we have in the
				                // definition.
				                CKEDITOR.tools.extendthiselementDefinition );
				            },
			            /**
			             * Horizontal layout box for dialog UI elements, auto-expends to available width of container.
			             * @constructor
			             * @extends CKEDITOR.ui.dialog.uiElement
			             * @param {CKEDITOR.dialog} dialog
			             * Parent dialog object.
			             * @param {Array} childObjList
			             * Array of {@link CKEDITOR.ui.dialog.uiElement} objects inside this
			             * container.
			             * @param {Array} childHtmlList
			             * Array of HTML code that correspond to the HTML output of all the
			             * objects in childObjList.
			             * @param {Array} htmlList
			             * Array of HTML code that this element will output to.
			             * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition
			             * The element definition. Accepted fields:
			             * <ul>
			             *     <li><strong>widths</strong> (Optional) The widths of child cells.</li>
			             *     <li><strong>height</strong> (Optional) The height of the layout.</li>
			             *     <li><strong>padding</strong> (Optional) The padding width inside child
			             *      cells.</li>
			             *     <li><strong>align</strong> (Optional) The alignment of the whole layout
			             *     </li>
			             * </ul>
			             * @example
			             */
			            hbox : function( dialogchildObjListchildHtmlListhtmlListelementDefinition )
			            {
				                if ( arguments.length )
				                    return;
				                this.|| ( this.{} );
				                var children this._.children childObjList,
				                    widths elementDefinition && elementDefinition.widths || null,
				                    height elementDefinition && elementDefinition.height || null,
				                    styles {},
				                    i;
				                /** @ignore */
				                var innerHTML = function()
				                {
					                    var html = [ '<tbody><tr class="cke_dialog_ui_hbox">' ];
					                    for ( ;
					 childHtmlList.length ;
					 i++ )
					                    {
						                        var className 'cke_dialog_ui_hbox_child',
						                            styles [];
						                        if ( === )
						                            className 'cke_dialog_ui_hbox_first';
						                        if ( == childHtmlList.length )
						                            className 'cke_dialog_ui_hbox_last';
						                        html.push'<td class="'className'" role="presentation" ' );
						                        if ( widths )
						                        {
							                            if ( widths[i] )
							                                styles.push'width:' CKEDITOR.tools.cssLengthwidths[i] ) );
							                        }
						                        else
						                            styles.push'width:' Math.floor100 childHtmlList.length ) + '%' );
						                        if ( height )
						                            styles.push'height:' CKEDITOR.tools.cssLengthheight ) );
						                        if ( elementDefinition && elementDefinition.padding != undefined )
						                            styles.push'padding:' CKEDITOR.tools.cssLengthelementDefinition.padding ) );
						                        if ( styles.length )
						                            html.push'style="' styles.join(';
						 ') + '" ' );
						                        html.push'>'childHtmlList[i], '</td>' );
						                    }
					                    html.push'</tr></tbody>' );
					                    return html.join'' );
					                };
				                var attribs = { role 'presentation'
					};
				                elementDefinition && elementDefinition.align && ( attribs.align elementDefinition.align );
				                CKEDITOR.ui.dialog.uiElement.call(
				                    this,
				                    dialog,
				                    elementDefinition || { type 'hbox'
					},
				                    htmlList,
				                    'table',
				                    styles,
				                    attribs,
				                    innerHTML );
				            },
			            /**
			             * Vertical layout box for dialog UI elements.
			             * @constructor
			             * @extends CKEDITOR.ui.dialog.hbox
			             * @param {CKEDITOR.dialog} dialog
			             * Parent dialog object.
			             * @param {Array} childObjList
			             * Array of {@link CKEDITOR.ui.dialog.uiElement} objects inside this
			             * container.
			             * @param {Array} childHtmlList
			             * Array of HTML code that correspond to the HTML output of all the
			             * objects in childObjList.
			             * @param {Array} htmlList
			             * Array of HTML code that this element will output to.
			             * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition
			             * The element definition. Accepted fields:
			             * <ul>
			             *     <li><strong>width</strong> (Optional) The width of the layout.</li>
			             *     <li><strong>heights</strong> (Optional) The heights of individual cells.
			             *     </li>
			             *     <li><strong>align</strong> (Optional) The alignment of the layout.</li>
			             *     <li><strong>padding</strong> (Optional) The padding width inside child
			             *     cells.</li>
			             *     <li><strong>expand</strong> (Optional) Whether the layout should expand
			             *     vertically to fill its container.</li>
			             * </ul>
			             * @example
			             */
			            vbox : function( dialogchildObjListchildHtmlListhtmlListelementDefinition )
			            {
				                if (arguments.length )
				                    return;
				                this.|| ( this.{} );
				                var children this._.children childObjList,
				                    width elementDefinition && elementDefinition.width || null,
				                    heights elementDefinition && elementDefinition.heights || null;
				                /** @ignore */
				                var innerHTML = function()
				                {
					                    var html = [ '<table role="presentation" cellspacing="0" border="0" ' ];
					                    html.push'style="' );
					                    if ( elementDefinition && elementDefinition.expand )
					                        html.push'height:100%;
					' );
					                    html.push'width:' CKEDITOR.tools.cssLengthwidth || '100%' ), ';
					' );
					                    html.push'"' );
					                    html.push'align="'CKEDITOR.tools.htmlEncode(
					                        ( elementDefinition && elementDefinition.align ) || ( dialog.getParentEditor().lang.dir == 'ltr' 'left' 'right' ) ), '" ' );
					                    html.push'><tbody>' );
					                    for ( var ;
					 childHtmlList.length ;
					 i++ )
					                    {
						                        var styles [];
						                        html.push'<tr><td role="presentation" ' );
						                        if ( width )
						                            styles.push'width:' CKEDITOR.tools.cssLengthwidth || '100%' ) );
						                        if ( heights )
						                            styles.push'height:' CKEDITOR.tools.cssLengthheights[i] ) );
						                        else if ( elementDefinition && elementDefinition.expand )
						                            styles.push'height:' Math.floor100 childHtmlList.length ) + '%' );
						                        if ( elementDefinition && elementDefinition.padding != undefined )
						                            styles.push'padding:' CKEDITOR.tools.cssLengthelementDefinition.padding ) );
						                        if ( styles.length )
						                            html.push'style="'styles.join';
						 ' ), '" ' );
						                        html.push' class="cke_dialog_ui_vbox_child">'childHtmlList[i], '</td></tr>' );
						                    }
					                    html.push'</tbody></table>' );
					                    return html.join'' );
					                };
				                CKEDITOR.ui.dialog.uiElement.callthisdialogelementDefinition || { type 'vbox'
					}, htmlList'div'null, { role 'presentation'
					}, innerHTML );
				            }
			        };
		    })();
	    CKEDITOR.ui.dialog.uiElement.prototype =
	    {
		        /**
		         * Gets the root DOM element of this dialog UI object.
		         * @returns {CKEDITOR.dom.element} Root DOM element of UI object.
		         * @example
		         * uiElement.getElement().hide();
		         */
		        getElement : function()
		        {
			            return CKEDITOR.document.getByIdthis.domId );
			        },
		        /**
		         * Gets the DOM element that the user inputs values.
		         * This function is used by setValue(), getValue() and focus(). It should
		         * be overrided in child classes where the input element isn't the root
		         * element.
		         * @returns {CKEDITOR.dom.element} The element where the user input values.
		         * @example
		         * var rawValue = textInput.getInputElement().$.value;
		         */
		        getInputElement : function()
		        {
			            return this.getElement();
			        },
		        /**
		         * Gets the parent dialog object containing this UI element.
		         * @returns {CKEDITOR.dialog} Parent dialog object.
		         * @example
		         * var dialog = uiElement.getDialog();
		         */
		        getDialog : function()
		        {
			            return this._.dialog;
			        },
		        /**
		         * Sets the value of this dialog UI object.
		         * @param {Object} value The new value.
		         * @param {Boolean} noChangeEvent Internal commit, to supress 'change' event on this element.
		         * @returns {CKEDITOR.dialog.uiElement} The current UI element.
		         * @example
		         * uiElement.setValue( 'Dingo' );
		         */
		        setValue : function( valuenoChangeEvent )
		        {
			            this.getInputElement().setValuevalue );
			            !noChangeEvent && this.fire'change', { value value
				} );
			            return this;
			        },
		        /**
		         * Gets the current value of this dialog UI object.
		         * @returns {Object} The current value.
		         * @example
		         * var myValue = uiElement.getValue();
		         */
		        getValue : function()
		        {
			            return this.getInputElement().getValue();
			        },
		        /**
		         * Tells whether the UI object's value has changed.
		         * @returns {Boolean} true if changed, false if not changed.
		         * @example
		         * if ( uiElement.isChanged() )
		         * &nbsp;
		&nbsp;
		confirm( 'Value changed! Continue?' );
		         */
		        isChanged : function()
		        {
			            // Override in input classes.
			            return false;
			        },
		        /**
		         * Selects the parent tab of this element. Usually called by focus() or overridden focus() methods.
		         * @returns {CKEDITOR.dialog.uiElement} The current UI element.
		         * @example
		         * focus : function()
		         * {
			         *         this.selectParentTab();
			         *         // do something else.
			         *
			}
		         */
		        selectParentTab : function()
		        {
			            var element this.getInputElement(),
			                cursor element,
			                tabId;
			            while ( ( cursor cursor.getParent() ) && cursor.$.className.search'cke_dialog_page_contents' ) == -)
			            { /*jsl:pass*/
				}
			            // Some widgets don't have parent tabs (e.g. OK and Cancel buttons).
			            if ( !cursor )
			                return this;
			            tabId cursor.getAttribute'name' );
			            // Avoid duplicate select.
			            if ( this._.dialog._.currentTabId != tabId )
			                this._.dialog.selectPagetabId );
			            return this;
			        },
		        /**
		         * Puts the focus to the UI object. Switches tabs if the UI object isn't in the active tab page.
		         * @returns {CKEDITOR.dialog.uiElement} The current UI element.
		         * @example
		         * uiElement.focus();
		         */
		        focus : function()
		        {
			            this.selectParentTab().getInputElement().focus();
			            return this;
			        },
		        /**
		         * Registers the on* event handlers defined in the element definition.
		         * The default behavior of this function is:
		         * <ol>
		         *  <li>
		         *      If the on* event is defined in the class's eventProcesors list,
		         *      then the registration is delegated to the corresponding function
		         *      in the eventProcessors list.
		         *  </li>
		         *  <li>
		         *      If the on* event is not defined in the eventProcessors list, then
		         *      register the event handler under the corresponding DOM event of
		         *      the UI element's input DOM element (as defined by the return value
		         *      of {@link CKEDITOR.ui.dialog.uiElement#getInputElement}).
		         *  </li>
		         * </ol>
		         * This function is only called at UI element instantiation, but can
		         * be overridded in child classes if they require more flexibility.
		         * @param {CKEDITOR.dialog.uiElementDefinition} definition The UI element
		         * definition.
		         * @returns {CKEDITOR.dialog.uiElement} The current UI element.
		         * @example
		         */
		        registerEvents : function( definition )
		        {
			            var regex = /^on([A-Z]\w+)/,
			                match;
			            var registerDomEvent = function( uiElementdialogeventNamefunc )
			            {
				                dialog.on'load', function()
				                {
					                    uiElement.getInputElement().oneventNamefuncuiElement );
					                });
				            };
			            for ( var i in definition )
			            {
				                if ( !( match i.matchregex ) ) )
				                    continue;
				                if ( this.eventProcessors[i] )
				                    this.eventProcessors[i].callthisthis._.dialogdefinition[i] );
				                else
				                    registerDomEventthisthis._.dialogmatch[1].toLowerCase(), definition[i] );
				            }
			            return this;
			        },
		        /**
		         * The event processor list used by
		         * {@link CKEDITOR.ui.dialog.uiElement#getInputElement} at UI element
		         * instantiation. The default list defines three on* events:
		         * <ol>
		         *  <li>onLoad - Called when the element's parent dialog opens for the
		         *  first time</li>
		         *  <li>onShow - Called whenever the element's parent dialog opens.</li>
		         *  <li>onHide - Called whenever the element's parent dialog closes.</li>
		         * </ol>
		         * @field
		         * @type Object
		         * @example
		         * // This connects the 'click' event in CKEDITOR.ui.dialog.button to onClick
		         * // handlers in the UI element's definitions.
		         * CKEDITOR.ui.dialog.button.eventProcessors = CKEDITOR.tools.extend( {},
		         * &nbsp;
		&nbsp;
		CKEDITOR.ui.dialog.uiElement.prototype.eventProcessors,
		         * &nbsp;
		&nbsp;
		{ onClick : function( dialog, func ) {
				this.on( 'click', func );
				}
			},
		         * &nbsp;
		&nbsp;
		true );
		         */
		        eventProcessors :
		        {
			            onLoad : function( dialogfunc )
			            {
				                dialog.on'load'functhis );
				            },
			            onShow : function( dialogfunc )
			            {
				                dialog.on'show'functhis );
				            },
			            onHide : function( dialogfunc )
			            {
				                dialog.on'hide'functhis );
				            }
			        },
		        /**
		         * The default handler for a UI element's access key down event, which
		         * tries to put focus to the UI element.<br />
		         * Can be overridded in child classes for more sophisticaed behavior.
		         * @param {CKEDITOR.dialog} dialog The parent dialog object.
		         * @param {String} key The key combination pressed. Since access keys
		         * are defined to always include the CTRL key, its value should always
		         * include a 'CTRL+' prefix.
		         * @example
		         */
		        accessKeyDown : function( dialogkey )
		        {
			            this.focus();
			        },
		        /**
		         * The default handler for a UI element's access key up event, which
		         * does nothing.<br />
		         * Can be overridded in child classes for more sophisticated behavior.
		         * @param {CKEDITOR.dialog} dialog The parent dialog object.
		         * @param {String} key The key combination pressed. Since access keys
		         * are defined to always include the CTRL key, its value should always
		         * include a 'CTRL+' prefix.
		         * @example
		         */
		        accessKeyUp : function( dialogkey )
		        {
			        },
		        /**
		         * Disables a UI element.
		         * @example
		         */
		        disable : function()
		        {
			            var element this.getInputElement();
			            element.setAttribute'disabled''true' );
			            element.addClass'cke_disabled' );
			        },
		        /**
		         * Enables a UI element.
		         * @example
		         */
		        enable : function()
		        {
			            var element this.getInputElement();
			            element.removeAttribute'disabled' );
			            element.removeClass'cke_disabled' );
			        },
		        /**
		         * Determines whether an UI element is enabled or not.
		         * @returns {Boolean} Whether the UI element is enabled.
		         * @example
		         */
		        isEnabled : function()
		        {
			            return !this.getInputElement().getAttribute'disabled' );
			        },
		        /**
		         * Determines whether an UI element is visible or not.
		         * @returns {Boolean} Whether the UI element is visible.
		         * @example
		         */
		        isVisible : function()
		        {
			            return this.getInputElement().isVisible();
			        },
		        /**
		         * Determines whether an UI element is focus-able or not.
		         * Focus-able is defined as being both visible and enabled.
		         * @returns {Boolean} Whether the UI element can be focused.
		         * @example
		         */
		        isFocusable : function()
		        {
			            if ( !this.isEnabled() || !this.isVisible() )
			                return false;
			            return true;
			        }
		    };
	    CKEDITOR.ui.dialog.hbox.prototype CKEDITOR.tools.extend( new CKEDITOR.ui.dialog.uiElement,
	        /**
	         * @lends CKEDITOR.ui.dialog.hbox.prototype
	         */
	        {
		            /**
		             * Gets a child UI element inside this container.
		             * @param {Array|Number} indices An array or a single number to indicate the child's
		             * position in the container's descendant tree. Omit to get all the children in an array.
		             * @returns {Array|CKEDITOR.ui.dialog.uiElement} Array of all UI elements in the container
		             * if no argument given, or the specified UI element if indices is given.
		             * @example
		             * var checkbox = hbox.getChild( [0,1] );
		             * checkbox.setValue( true );
		             */
		            getChild : function( indices )
		            {
			                // If no arguments, return a clone of the children array.
			                if ( arguments.length )
			                    return this._.children.concat();
			                // If indices isn't array, make it one.
			                if ( !indices.splice )
			                    indices = [ indices ];
			                // Retrieve the child element according to tree position.
			                if ( indices.length )
			                    return this._.childrenindices[0] ];
			                else
			                    return ( this._.childrenindices[0] ] && this._.childrenindices[0] ].getChild ) ?
			                        this._.childrenindices[0] ].getChildindices.slice1indices.length ) ) :
			                        null;
			            }
		        }, true );
	    CKEDITOR.ui.dialog.vbox.prototype = new CKEDITOR.ui.dialog.hbox();
	    (function()
	    {
		        var commonBuilder = {
			            build : function( dialogelementDefinitionoutput )
			            {
				                var children elementDefinition.children,
				                    child,
				                    childHtmlList [],
				                    childObjList [];
				                for ( var ;
				 ( children.length && ( child children[i] ) ) ;
				 i++ )
				                {
					                    var childHtml [];
					                    childHtmlList.pushchildHtml );
					                    childObjList.pushCKEDITOR.dialog._.uiElementBuilderschild.type ].builddialogchildchildHtml ) );
					                }
				                return new CKEDITOR.ui.dialog[elementDefinition.type]( dialogchildObjListchildHtmlListoutputelementDefinition );
				            }
			        };
		        CKEDITOR.dialog.addUIElement'hbox'commonBuilder );
		        CKEDITOR.dialog.addUIElement'vbox'commonBuilder );
		    })();
	    /**
	     * Generic dialog command. It opens a specific dialog when executed.
	     * @constructor
	     * @augments CKEDITOR.commandDefinition
	     * @param {string} dialogName The name of the dialog to open when executing
	     *        this command.
	     * @example
	     * // Register the "link" command, which opens the "link" dialog.
	     * editor.addCommand( 'link', <b>new CKEDITOR.dialogCommand( 'link' )</b> );
	     */
	    CKEDITOR.dialogCommand = function( dialogName )
	    {
		        this.dialogName dialogName;
		    };
	    CKEDITOR.dialogCommand.prototype =
	    {
		        /** @ignore */
		        exec : function( editor )
		        {
			            editor.openDialogthis.dialogName );
			        },
		        // Dialog commands just open a dialog ui, thus require no undo logic,
		        // undo support should dedicate to specific dialog implementation.
		        canUndofalse,
		        editorFocus CKEDITOR.env.ie || CKEDITOR.env.webkit
		    };
	    (function()
	    {
		        var notEmptyRegex = /^([a]|[^a])+$/,
		            integerRegex = /^\d*$/,
		            numberRegex = /^\d*(?:\.\d+)?$/;
		        CKEDITOR.VALIDATE_OR 1;
		        CKEDITOR.VALIDATE_AND 2;
		        CKEDITOR.dialog.validate =
		        {
			            functions : function()
			            {
				                return function()
				                {
					                    /**
					                     * It's important for validate functions to be able to accept the value
					                     * as argument in addition to this.getValue(), so that it is possible to
					                     * combine validate functions together to make more sophisticated
					                     * validators.
					                     */
					                    var value this && this.getValue this.getValue() : arguments[0];
					                    var msg undefined,
					                        relation CKEDITOR.VALIDATE_AND,
					                        functions []i;
					                    for ( ;
					 arguments.length ;
					 i++ )
					                    {
						                        if ( typeofarguments[i] ) == 'function' )
						                            functions.pusharguments[i] );
						                        else
						                            break;
						                    }
					                    if ( arguments.length && typeofarguments[i] ) == 'string' )
					                    {
						                        msg arguments[i];
						                        i++;
						                    }
					                    if ( arguments.length && typeofarguments[i]) == 'number' )
					                        relation arguments[i];
					                    var passed = ( relation == CKEDITOR.VALIDATE_AND true false );
					                    for ( ;
					 functions.length ;
					 i++ )
					                    {
						                        if ( relation == CKEDITOR.VALIDATE_AND )
						                            passed passed && functions[i]( value );
						                        else
						                            passed passed || functions[i]( value );
						                    }
					                    if ( !passed )
					                    {
						                        if ( msg !== undefined )
						                            alertmsg );
						                        if ( this && ( this.select || this.focus ) )
						                            ( this.select || this.focus )();
						                        return false;
						                    }
					                    return true;
					                };
				            },
			            regex : function( regexmsg )
			            {
				                /*
				                 * Can be greatly shortened by deriving from functions validator if code size
				                 * turns out to be more important than performance.
				                 */
				                return function()
				                {
					                    var value this && this.getValue this.getValue() : arguments[0];
					                    if ( !regex.testvalue ) )
					                    {
						                        if ( msg !== undefined )
						                            alertmsg );
						                        if ( this && ( this.select || this.focus ) )
						                        {
							                            if ( this.select )
							                                this.select();
							                            else
							                                this.focus();
							                        }
						                        return false;
						                    }
					                    return true;
					                };
				            },
			            notEmpty : function( msg )
			            {
				                return this.regexnotEmptyRegexmsg );
				            },
			            integer : function( msg )
			            {
				                return this.regexintegerRegexmsg );
				            },
			            'number' : function( msg )
			            {
				                return this.regexnumberRegexmsg );
				            },
			            equals : function( valuemsg )
			            {
				                return this.functions( function( val ){ return val == value;
					}, msg );
				            },
			            notEqual : function( valuemsg )
			            {
				                return this.functions( function( val ){ return val != value;
					}, msg );
				            }
			        };
		    CKEDITOR.on'instanceDestroyed', function( evt )
		    {
			        // Remove dialog cover on last instance destroy.
			        if ( CKEDITOR.tools.isEmptyCKEDITOR.instances ) )
			        {
				            var currentTopDialog;
				            while ( ( currentTopDialog CKEDITOR.dialog._.currentTop ) )
				                currentTopDialog.hide();
				            removeCovers();
				        }
			        var dialogs evt.editor._.storedDialogs;
			        for ( var name in dialogs )
			            dialogsname ].destroy();
			    });
		    })();
	})();
// Extend the CKEDITOR.editor class with dialog specific functions.
CKEDITOR.tools.extendCKEDITOR.editor.prototype,
    /** @lends CKEDITOR.editor.prototype */
    {
	        /**
	         * Loads and opens a registered dialog.
	         * @param {String} dialogName The registered name of the dialog.
	         * @param {Function} callback The function to be invoked after dialog instance created.
	         * @see CKEDITOR.dialog.add
	         * @example
	         * CKEDITOR.instances.editor1.openDialog( 'smiley' );
	         * @returns {CKEDITOR.dialog} The dialog object corresponding to the dialog displayed. null if the dialog name is not registered.
	         */
	        openDialog : function( dialogNamecallback )
	        {
		            var dialogDefinitions CKEDITOR.dialog._.dialogDefinitionsdialogName ],
		                    dialogSkin this.skin.dialog;
		            // If the dialogDefinition is already loaded, open it immediately.
		            if ( typeof dialogDefinitions == 'function' && dialogSkin._isLoaded )
		            {
			                var storedDialogs this._.storedDialogs ||
			                    ( this._.storedDialogs {} );
			                var dialog storedDialogsdialogName ] ||
			                    ( storedDialogsdialogName ] = new CKEDITOR.dialogthisdialogName ) );
			                callback && callback.calldialogdialog );
			                dialog.show();
			                return dialog;
			            }
		            else if ( dialogDefinitions == 'failed' )
		                throw new Error'[CKEDITOR.dialog.openDialog] Dialog "' dialogName '" failed when loading definition.' );
		            // Not loaded? Load the .js file first.
		            var body CKEDITOR.document.getBody(),
		                cursor body.$.style.cursor,
		                me this;
		            body.setStyle'cursor''wait' );
		            function onDialogFileLoadedsuccess )
		            {
			                var dialogDefinition CKEDITOR.dialog._.dialogDefinitionsdialogName ],
			                        skin me.skin.dialog;
			                // Check if both skin part and definition is loaded.
			                if ( !skin._isLoaded || loadDefinition && typeof success == 'undefined' )
			                    return;
			                // In case of plugin error, mark it as loading failed.
			                if ( typeof dialogDefinition != 'function' )
			                    CKEDITOR.dialog._.dialogDefinitionsdialogName ] = 'failed';
			                me.openDialogdialogNamecallback );
			                body.setStyle'cursor'cursor );
			            }
		            if ( typeof dialogDefinitions == 'string' )
		            {
			                var loadDefinition 1;
			                CKEDITOR.scriptLoader.loadCKEDITOR.getUrldialogDefinitions ), onDialogFileLoaded );
			            }
		            CKEDITOR.skins.loadthis'dialog'onDialogFileLoaded );
		            return null;
		        }
	    });
CKEDITOR.plugins.add'dialog',
    {
	        requires : [ 'dialogui' ]
	    });
// Dialog related configurations.
/**
 * The color of the dialog background cover. It should be a valid CSS color
 * string.
 * @name CKEDITOR.config.dialog_backgroundCoverColor
 * @type String
 * @default 'white'
 * @example
 * config.dialog_backgroundCoverColor = 'rgb(255, 254, 253)';
 */
/**
 * The opacity of the dialog background cover. It should be a number within the
 * range [0.0, 1.0].
 * @name CKEDITOR.config.dialog_backgroundCoverOpacity
 * @type Number
 * @default 0.5
 * @example
 * config.dialog_backgroundCoverOpacity = 0.7;
 */
/**
 * If the dialog has more than one tab, put focus into the first tab as soon as dialog is opened.
 * @name CKEDITOR.config.dialog_startupFocusTab
 * @type Boolean
 * @default false
 * @example
 * config.dialog_startupFocusTab = true;
 */
/**
 * The distance of magnetic borders used in moving and resizing dialogs,
 * measured in pixels.
 * @name CKEDITOR.config.dialog_magnetDistance
 * @type Number
 * @default 20
 * @example
 * config.dialog_magnetDistance = 30;
 */
/**
 * Fired when a dialog definition is about to be used to create a dialog into
 * an editor instance. This event makes it possible to customize the definition
 * before creating it.
 * <p>Note that this event is called only the first time a specific dialog is
 * opened. Successive openings will use the cached dialog, and this event will
 * not get fired.</p>
 * @name CKEDITOR#dialogDefinition
 * @event
 * @param {CKEDITOR.dialog.dialogDefinition} data The dialog defination that
 *        is being loaded.
 * @param {CKEDITOR.editor} editor The editor instance that will use the
 *        dialog.
 */
/**
 * Fired when a tab is going to be selected in a dialog
 * @name dialog#selectPage
 * @event
 * @param String page The id of the page that it's gonna be selected.
 * @param String currentPage The id of the current page.
 */





PHP Demo Source Code Index