Index: /CKEditor/branches/prototype/_source/plugins/dialogui/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/dialogui/plugin.js	(revision 2660)
+++ /CKEditor/branches/prototype/_source/plugins/dialogui/plugin.js	(revision 2661)
@@ -404,5 +404,5 @@
 					return;
 				
-				var _ = initPrivateObject.call( this, elementDefinition );
+				var _ = CKEDITOR.tools.extend( initPrivateObject.call( this, elementDefinition ), { definition : elementDefinition } );
 
 				if ( elementDefinition.validate )
@@ -411,9 +411,281 @@
 				var myDefinition = CKEDITOR.tools.extend( {}, elementDefinition );
 
-				// onLoad doesn't work. The file input needs to be drawn each time the dialog is shown.
-				myDefinition.onShow = function()
-				{
-					var frameElement = CKEDITOR.document.getById( _.frameId ),
-						frameDocument = frameElement.$.contentWindow.document;
+				/** @ignore */
+				var innerHTML = function()
+				{
+					_.frameId = CKEDITOR.tools.getNextNumber() + '_fileInput';
+					var html = [ '<iframe frameborder="0" allowtransparency="0" class="cke_dialog_ui_input_file" id="',
+						_.frameId, '" src="javascript: void(0)" ></iframe>' ];
+					return html.join( '' );
+				};
+
+				CKEDITOR.ui.dialog.labeledElement.call( this, dialog, myDefinition, htmlList, innerHTML );
+			},
+
+			/**
+			 * A button for submitting the file in a file upload input.
+			 * @extends CKEDITOR.ui.dialog.button
+			 * @example
+			 * @constructor
+			 */
+			fileButton : function( dialog, elementDefinition, htmlList )
+			{
+				if ( arguments.length < 3 )
+					return;
+				
+				var _ = initPrivateObject.call( this, elementDefinition );
+
+				if ( elementDefinition.validate )
+					this.validate = elementDefinition.validate;
+
+				var myDefinition = CKEDITOR.tools.extend( {}, elementDefinition );
+				myDefinition.className = ( myDefinition.className ? myDefinition.className + ' ' : '' ) + 'cke_dialog_ui_button';
+				myDefinition.onClick = function( evt ) 
+				{
+					var target = elementDefinition[ 'for' ];		// [ pageId, elementId ]
+					dialog.getContentElement( target[0], target[1] ).submit();
+				};
+
+				CKEDITOR.ui.dialog.button.call( this, dialog, myDefinition, htmlList );
+			},
+
+			/**
+			 * A dialog element made from raw HTML code.
+			 * @extends CKEDITOR.ui.dialog.uiElement
+			 * @example
+			 * @constructor
+			 */
+			html : (function()
+			{
+				var myHtmlRe = /^\s*<[\w:]+\s+([^>]*)?>/,
+					theirHtmlRe = /^(\s*<[\w:]+(?:\s+[^>]*)?)((?:.|\r|\n)+)$/,
+					emptyTagRe = /\/$/;
+				return function( dialog, elementDefinition, htmlList )
+				{
+					if ( arguments.length < 3 )
+						return;
+
+					var myHtmlList = [],
+						myHtml,
+						theirHtml = elementDefinition.html,
+						myMatch, theirMatch;
+					CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition, myHtmlList, 'span', null, null, '' );
+
+					// Append the attributes created by the uiElement call to the real HTML.
+					myHtml = myHtmlList.join( '' );
+					myMatch = myHtml.match( myHtmlRe );
+					theirMatch = theirHtml.match( theirHtmlRe ) || [ '', '', '' ];
+
+					if ( emptyTagRe.test( theirMatch[1] ) )
+					{
+						theirMatch[1] = theirMatch[1].slice( 0, -1 );
+						theirMatch[2] = '/' + theirMatch[2];
+					}
+
+					htmlList.push( [ theirMatch[1], ' ', myMatch[1] || '', theirMatch[2] ].join( '' ) );
+				}
+			})()
+		}, true );
+
+	CKEDITOR.ui.dialog.labeledElement.prototype
+		= CKEDITOR.ui.dialog.html.prototype
+		= new CKEDITOR.ui.dialog.uiElement;
+
+	CKEDITOR.ui.dialog.button.prototype = CKEDITOR.tools.extend( new CKEDITOR.ui.dialog.uiElement,
+			/** @lends CKEDITOR.ui.dialog.button.prototype */
+			{
+				/**
+				 * Simulates a click to the button.
+				 * @example
+				 * @returns {Object} Return value of the 'click' event.
+				 */
+				click : function()
+				{
+					if ( !this._.disabled )
+						return this.fire( 'click', { dialog : this._.dialog } );
+				},
+
+				/**
+				 * Enables the button.
+				 * @example
+				 */
+				enable : function()
+				{
+					this._.disabled = false;
+					this.getElement().removeClass( 'disabled' );
+				},
+
+				/**
+				 * Disables the button.
+				 * @example
+				 */
+				disable : function()
+				{
+					this._.disabled = true;
+					this.getElement().addClass( 'disabled' );
+				},
+
+				eventProcessors : CKEDITOR.tools.extend( {}, CKEDITOR.ui.dialog.uiElement.prototype.eventProcessors,
+					{
+						onClick : function( dialog, func )
+						{
+							this.on( 'click', func );
+						}
+					}, true ),
+
+				accessKeyUp : function()
+				{
+					this.getElement().removeClass( 'active' );
+					this.click();
+				},
+
+				accessKeyDown : function()
+				{
+					this.getElement().addClass( 'active' );
+				},
+			}, true );
+
+	CKEDITOR.ui.dialog.textInput.prototype = CKEDITOR.tools.extend( new CKEDITOR.ui.dialog.labeledElement,
+			/** @lends CKEDITOR.ui.dialog.textInput.prototype */
+			{
+				/**
+				 * Gets the text input DOM element under this UI object.
+				 * @example
+				 * @returns {CKEDITOR.dom.element} The DOM element of the text input.
+				 */
+				getElement : function()
+				{
+					return CKEDITOR.document.getById( this._.inputId );
+				},
+
+				/**
+				 * Selects all the text in the text input.
+				 * @example
+				 */
+				select : function()
+				{
+					this.focus();
+					this.getElement().$.select();
+				},
+
+				accessKeyUp : function()
+				{
+					this.select();
+				}
+			}, commonPrototype, true );
+
+	CKEDITOR.ui.dialog.select.prototype = CKEDITOR.tools.extend( new CKEDITOR.ui.dialog.labeledElement,
+			/** @lends CKEDITOR.ui.dialog.select.prototype */
+			{
+				getElement : function()
+				{
+					return this._.select.getElement();
+				}
+			} );
+
+	CKEDITOR.ui.dialog.checkbox.prototype = CKEDITOR.tools.extend( new CKEDITOR.ui.dialog.uiElement,
+			/** @lends CKEDITOR.ui.dialog.checkbox.prototype */
+			{
+				/**
+				 * Gets the checkbox DOM element.
+				 * @example
+				 * @returns {CKEDITOR.dom.element} The DOM element of the checkbox.
+				 */
+				getElement : function()
+				{
+					return this._.checkbox.getElement();
+				},
+
+				/**
+				 * Sets the state of the checkbox.
+				 * @example
+				 * @param {Boolean} true to tick the checkbox, false to untick it.
+				 */
+				setValue : function( checked )
+				{
+					this.getElement().$.checked = checked;
+				},
+
+				/**
+				 * Gets the state of the checkbox.
+				 * @example
+				 * @returns {Boolean} true means the checkbox is ticked, false means it's not ticked.
+				 */
+				getValue : function()
+				{
+					return this.getElement().$.checked;
+				},
+
+				accessKeyUp : function()
+				{
+					this.setValue( !this.getValue() );
+				}
+			}, commonPrototype, true );
+
+	CKEDITOR.ui.dialog.radio.prototype = CKEDITOR.tools.extend( new CKEDITOR.ui.dialog.uiElement,
+			/** @lends CKEDITOR.ui.dialog.radio.prototype */
+			{
+				/**
+				 * Checks one of the radio buttons in this button group.
+				 * @example
+				 * @param {String} value The value of the button to be chcked.
+				 */
+				setValue : function( value )
+				{
+					var children = this._.children,
+						item;
+					for ( var i = 0 ; ( i < children.length ) && ( item = children[i] ) ; i++ )
+						item.getElement().$.checked = ( item.getValue() == value );
+				},
+
+				/**
+				 * Gets the value of the currently checked radio button.
+				 * @example
+				 * @returns {String} The currently checked button's value.
+				 */
+				getValue : function()
+				{
+					var children = this._.children;
+					for ( var i = 0 ; i < children.length ; i++ )
+					{
+						if ( children[i].getElement().$.checked )
+							return children[i].getValue();
+					}
+					return null;
+				},
+
+				accessKeyUp : function()
+				{
+					var children = this._.children, i;
+					for ( i = 0 ; i < children.length ; i++ )
+					{
+						if ( children[i].getElement().$.checked )
+						{
+							children[i].getElement().focus();
+							return;
+						}
+					}
+					children[0].getElement().focus();
+				}
+			}, commonPrototype, true );
+
+	CKEDITOR.ui.dialog.file.prototype = CKEDITOR.tools.extend( new CKEDITOR.ui.dialog.labeledElement,
+			{
+				getElement : function()
+				{
+					return new CKEDITOR.dom.element( CKEDITOR.document.getById( this._.frameId )
+						.$.contentWindow.document.forms[0].elements[0] );
+				},
+
+				submit : function()
+				{
+					return this.getElement().getParent().$.submit();
+				},
+
+				reset : function()
+				{
+					var frameElement = CKEDITOR.document.getById( this._.frameId ),
+						frameDocument = frameElement.$.contentWindow.document,
+						elementDefinition = this._.definition;
 					frameDocument.open();
 					frameDocument.write( [ '<html><head><title></title></head><body style="margin: 0; overflow: hidden;">',
@@ -429,277 +701,4 @@
 							'</body></html>' ].join( '' ) );
 					frameDocument.close();
-					return elementDefinition.onShow && elementDefinition.onShow.apply( this, arguments );
-				}
-
-				/** @ignore */
-				var innerHTML = function()
-				{
-					_.frameId = CKEDITOR.tools.getNextNumber() + '_fileInput';
-					var html = [ '<iframe frameborder="0" allowtransparency="0" class="cke_dialog_ui_input_file" id="',
-						_.frameId, '" src="javascript: void(0)" ></iframe>' ];
-					return html.join( '' );
-				};
-
-				CKEDITOR.ui.dialog.labeledElement.call( this, dialog, myDefinition, htmlList, innerHTML );
-			},
-
-			/**
-			 * A button for submitting the file in a file upload input.
-			 * @extends CKEDITOR.ui.dialog.button
-			 * @example
-			 * @constructor
-			 */
-			fileButton : function( dialog, elementDefinition, htmlList )
-			{
-				if ( arguments.length < 3 )
-					return;
-				
-				var _ = initPrivateObject.call( this, elementDefinition );
-
-				if ( elementDefinition.validate )
-					this.validate = elementDefinition.validate;
-
-				var myDefinition = CKEDITOR.tools.extend( {}, elementDefinition );
-				myDefinition.className = ( myDefinition.className ? myDefinition.className + ' ' : '' ) + 'cke_dialog_ui_button';
-				myDefinition.onClick = function( evt ) 
-				{
-					var target = elementDefinition[ 'for' ];		// [ pageId, elementId ]
-					dialog.getContentElement( target[0], target[1] ).submit();
-				};
-
-				CKEDITOR.ui.dialog.button.call( this, dialog, myDefinition, htmlList );
-			},
-
-			/**
-			 * A dialog element made from raw HTML code.
-			 * @extends CKEDITOR.ui.dialog.uiElement
-			 * @example
-			 * @constructor
-			 */
-			html : (function()
-			{
-				var myHtmlRe = /^\s*<[\w:]+\s+([^>]*)?>/,
-					theirHtmlRe = /^(\s*<[\w:]+(?:\s+[^>]*)?)((?:.|\r|\n)+)$/,
-					emptyTagRe = /\/$/;
-				return function( dialog, elementDefinition, htmlList )
-				{
-					if ( arguments.length < 3 )
-						return;
-
-					var myHtmlList = [],
-						myHtml,
-						theirHtml = elementDefinition.html,
-						myMatch, theirMatch;
-					CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition, myHtmlList, 'span', null, null, '' );
-
-					// Append the attributes created by the uiElement call to the real HTML.
-					myHtml = myHtmlList.join( '' );
-					myMatch = myHtml.match( myHtmlRe );
-					theirMatch = theirHtml.match( theirHtmlRe ) || [ '', '', '' ];
-
-					if ( emptyTagRe.test( theirMatch[1] ) )
-					{
-						theirMatch[1] = theirMatch[1].slice( 0, -1 );
-						theirMatch[2] = '/' + theirMatch[2];
-					}
-
-					htmlList.push( [ theirMatch[1], ' ', myMatch[1] || '', theirMatch[2] ].join( '' ) );
-				}
-			})()
-		}, true );
-
-	CKEDITOR.ui.dialog.labeledElement.prototype
-		= CKEDITOR.ui.dialog.html.prototype
-		= new CKEDITOR.ui.dialog.uiElement;
-
-	CKEDITOR.ui.dialog.button.prototype = CKEDITOR.tools.extend( new CKEDITOR.ui.dialog.uiElement,
-			/** @lends CKEDITOR.ui.dialog.button.prototype */
-			{
-				/**
-				 * Simulates a click to the button.
-				 * @example
-				 * @returns {Object} Return value of the 'click' event.
-				 */
-				click : function()
-				{
-					if ( !this._.disabled )
-						return this.fire( 'click', { dialog : this._.dialog } );
-				},
-
-				/**
-				 * Enables the button.
-				 * @example
-				 */
-				enable : function()
-				{
-					this._.disabled = false;
-					this.getElement().removeClass( 'disabled' );
-				},
-
-				/**
-				 * Disables the button.
-				 * @example
-				 */
-				disable : function()
-				{
-					this._.disabled = true;
-					this.getElement().addClass( 'disabled' );
-				},
-
-				eventProcessors : CKEDITOR.tools.extend( {}, CKEDITOR.ui.dialog.uiElement.prototype.eventProcessors,
-					{
-						onClick : function( dialog, func )
-						{
-							this.on( 'click', func );
-						}
-					}, true ),
-
-				accessKeyUp : function()
-				{
-					this.getElement().removeClass( 'active' );
-					this.click();
-				},
-
-				accessKeyDown : function()
-				{
-					this.getElement().addClass( 'active' );
-				},
-			}, true );
-
-	CKEDITOR.ui.dialog.textInput.prototype = CKEDITOR.tools.extend( new CKEDITOR.ui.dialog.labeledElement,
-			/** @lends CKEDITOR.ui.dialog.textInput.prototype */
-			{
-				/**
-				 * Gets the text input DOM element under this UI object.
-				 * @example
-				 * @returns {CKEDITOR.dom.element} The DOM element of the text input.
-				 */
-				getElement : function()
-				{
-					return CKEDITOR.document.getById( this._.inputId );
-				},
-
-				/**
-				 * Selects all the text in the text input.
-				 * @example
-				 */
-				select : function()
-				{
-					this.focus();
-					this.getElement().$.select();
-				},
-
-				accessKeyUp : function()
-				{
-					this.select();
-				}
-			}, commonPrototype, true );
-
-	CKEDITOR.ui.dialog.select.prototype = CKEDITOR.tools.extend( new CKEDITOR.ui.dialog.labeledElement,
-			/** @lends CKEDITOR.ui.dialog.select.prototype */
-			{
-				getElement : function()
-				{
-					return this._.select.getElement();
-				}
-			} );
-
-	CKEDITOR.ui.dialog.checkbox.prototype = CKEDITOR.tools.extend( new CKEDITOR.ui.dialog.uiElement,
-			/** @lends CKEDITOR.ui.dialog.checkbox.prototype */
-			{
-				/**
-				 * Gets the checkbox DOM element.
-				 * @example
-				 * @returns {CKEDITOR.dom.element} The DOM element of the checkbox.
-				 */
-				getElement : function()
-				{
-					return this._.checkbox.getElement();
-				},
-
-				/**
-				 * Sets the state of the checkbox.
-				 * @example
-				 * @param {Boolean} true to tick the checkbox, false to untick it.
-				 */
-				setValue : function( checked )
-				{
-					this.getElement().$.checked = checked;
-				},
-
-				/**
-				 * Gets the state of the checkbox.
-				 * @example
-				 * @returns {Boolean} true means the checkbox is ticked, false means it's not ticked.
-				 */
-				getValue : function()
-				{
-					return this.getElement().$.checked;
-				},
-
-				accessKeyUp : function()
-				{
-					this.setValue( !this.getValue() );
-				}
-			}, commonPrototype, true );
-
-	CKEDITOR.ui.dialog.radio.prototype = CKEDITOR.tools.extend( new CKEDITOR.ui.dialog.uiElement,
-			/** @lends CKEDITOR.ui.dialog.radio.prototype */
-			{
-				/**
-				 * Checks one of the radio buttons in this button group.
-				 * @example
-				 * @param {String} value The value of the button to be chcked.
-				 */
-				setValue : function( value )
-				{
-					var children = this._.children,
-						item;
-					for ( var i = 0 ; ( i < children.length ) && ( item = children[i] ) ; i++ )
-						item.getElement().$.checked = ( item.getValue() == value );
-				},
-
-				/**
-				 * Gets the value of the currently checked radio button.
-				 * @example
-				 * @returns {String} The currently checked button's value.
-				 */
-				getValue : function()
-				{
-					var children = this._.children;
-					for ( var i = 0 ; i < children.length ; i++ )
-					{
-						if ( children[i].getElement().$.checked )
-							return children[i].getValue();
-					}
-					return null;
-				},
-
-				accessKeyUp : function()
-				{
-					var children = this._.children, i;
-					for ( i = 0 ; i < children.length ; i++ )
-					{
-						if ( children[i].getElement().$.checked )
-						{
-							children[i].getElement().focus();
-							return;
-						}
-					}
-					children[0].getElement().focus();
-				}
-			}, commonPrototype, true );
-
-	CKEDITOR.ui.dialog.file.prototype = CKEDITOR.tools.extend( new CKEDITOR.ui.dialog.labeledElement,
-			{
-				getElement : function()
-				{
-					return new CKEDITOR.dom.element( CKEDITOR.document.getById( this._.frameId )
-						.$.contentWindow.document.forms[0].elements[0] );
-				},
-
-				submit : function()
-				{
-					return this.getElement().getParent().$.submit();
 				}
 			}, true );
