Index: /CKEditor/branches/prototype/_source/dialogs/testOnly/dialog.js
===================================================================
--- /CKEditor/branches/prototype/_source/dialogs/testOnly/dialog.js	(revision 2556)
+++ /CKEditor/branches/prototype/_source/dialogs/testOnly/dialog.js	(revision 2556)
@@ -0,0 +1,144 @@
+CKEDITOR.dialog.add( 'testOnly', function( editor )
+		{
+			return {
+				title : 'Test Dialog',
+				resizable : CKEDITOR.DIALOG_RESIZE_BOTH,
+				minWidth : 500,
+				minHeight : 400,
+				contents : [
+					{
+						id : 'tab1',
+						label : 'First Tab',
+						title : 'First Tab Title',
+						accessKey : 'Q',
+						elements : [
+							{
+								type : 'text',
+								label : 'Test Text 1',
+								id : 'testText1',
+								'default' : 'hello world!'
+							},
+
+							{
+								type : 'text',
+								label : 'Test Text 2',
+								id : 'testText2',
+								'default' : 'Wheee'
+							},
+
+							{
+								type : 'text',
+								label : 'Test Text 3',
+								id : 'testText3',
+								'default' : 'Blah blah'
+							}
+						]
+					},
+
+					{
+						id : 'tab2',
+						label : 'Second Tab',
+						title : 'Second Tab Title',
+						accessKey : 'W',
+						elements : [
+							{
+								type : 'hbox',
+								children : [
+									{
+										type : 'text',
+										label : 'Test Text 4',
+										title : 'Your love is like bad medicine!',
+										id : 'testText4',
+										'default' : 'hello world!',
+										validate : function( dialog )
+										{
+											var valid = /^[A-Z a-z!]+$/.test( this.getValue() );
+											if ( !valid )
+											{
+												this.select();
+												alert( 'Test Text 4 must only contain alphanumeric characters, space, or ! and must not be empty.' );
+											}
+											return valid;
+										}
+									},
+
+									{
+										type : 'text',
+										label : 'Test Text 5',
+										id : 'testText5',
+										'default' : 'Wheee'
+									},
+
+									{
+										type : 'text',
+										label : 'Test Text 6',
+										id : 'testText6',
+										'default' : 'Blah blah'
+									}
+								]
+							}
+						]
+					},
+
+					{
+						id : 'tab3',
+						label : 'Third Tab',
+						title : 'Third Tab Title',
+						accessKey : 'E',
+						elements : [
+							{
+								type : 'vbox',
+								children : [
+									{
+										type : 'checkbox',
+										label : 'Enable this',
+										title : 'Shake it up, just like bad medicine!',
+										checked : false
+									},
+
+									{
+										type : 'checkbox',
+										label : 'Enable that',
+										checked : true 
+									},
+
+									{
+										type : 'checkbox',
+										label : 'Enable those',
+										checked : false
+									},
+
+									{
+										type : 'radio',
+										label : 'Include library:',
+										title : 'Trying to include a library in LOLCODE.',
+										'default' : 'stdio',
+										items : [
+											[ 'Standard I/O', 'stdio', 'You need this to write Hello World.' ],
+											[ 'Standard C Library', 'stdlib', 'You need this to exit.' ],
+											[ 'POSIX Library', 'unistd', 'You need this to sleep.' ],
+											[ 'Signal Library', 'signal' ]
+										]
+									},
+
+									{
+										type : 'button',
+										label : 'Click Me',
+										title : 'Click me plz!',
+										onClick : function( evt )
+										{
+											console.log( 'Clicked!!' );
+										}
+									},
+
+									{
+										type : 'html',
+										html : '<strong>CKEditor rocks.</strong>'
+									}
+								]
+							}
+						]
+					}
+				]
+			};
+		});
Index: /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js
===================================================================
--- /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js	(revision 2555)
+++ /CKEditor/branches/prototype/_source/plugins/dialog/plugin.js	(revision 2556)
@@ -26,7 +26,7 @@
 
 CKEDITOR.DIALOG_RESIZE_NONE = 0;
-CKEDITOR.DIALOG_RESIZE_RESIZE_WIDTH = 1;
-CKEDITOR.DIALOG_RESIZE_RESIZE_HEIGHT = 2;
-CKEDITOR.DIALOG_RESIZE_RESIZE_BOTH = 3;
+CKEDITOR.DIALOG_RESIZE_WIDTH = 1;
+CKEDITOR.DIALOG_RESIZE_HEIGHT = 2;
+CKEDITOR.DIALOG_RESIZE_BOTH = 3;
 
 CKEDITOR.dialog = function( editor, dialogName )
@@ -42,5 +42,5 @@
 		return;
 	}
-	definition = CKEDITOR.tools.extend( {}, CKEDITOR.dialog._.defaultDialogDefinition, definition(), true );
+	definition = CKEDITOR.tools.extend( {}, CKEDITOR.dialog._.defaultDialogDefinition( editor ), definition( editor ), true );
 	if ( !( definition.title && definition.contents ) )
 	{
@@ -400,16 +400,25 @@
 		// Place the bridge just under the selected tab. Count 1px left and right
 		// of the tab as border space.
-		setTimeout( function()
-			{
-				var selectedElement = selected[0].getFirst().$;
-				bridge.setStyles(
-						{
-							left : me._.editor.lang.dir == 'ltr' ? ( selectedElement.offsetLeft + 17 || 0 ) + 'px' : 'auto',
-							right : me._.editor.lang.dir == 'rtl' ?
-								( selectedElement.offsetParent.offsetWidth - selectedElement.offsetLeft - selectedElement.offsetWidth + 17 || 0 ) + 'px' :
-								'auto',
-							width : ( selected[0].getFirst().$.offsetWidth - 2 || 0 ) + 'px'
-						});
-			}, 0 );
+		var placeBridge = function()
+		{
+			var selectedElement = selected[0].getFirst().$;
+
+			// Gecko and Opera have a strange bug that cause the bridge to be
+			// added to the wrong layout element initially.
+			if ( !selectedElement.offsetParent || selectedElement.offsetParent.nodeName.toLowerCase() == 'body' )
+			{
+				setTimeout( placeBridge, 50 );
+				return;
+			}
+			bridge.setStyles(
+					{
+						left : me._.editor.lang.dir == 'ltr' ? ( selectedElement.offsetLeft + 17 || 0 ) + 'px' : 'auto',
+						right : me._.editor.lang.dir == 'rtl' ?
+							( selectedElement.offsetParent.offsetWidth - selectedElement.offsetLeft - selectedElement.offsetWidth + 17 || 0 ) + 'px' :
+							'auto',
+						width : ( selected[0].getFirst().$.offsetWidth - 2 || 0 ) + 'px'
+					});
+		};
+		placeBridge();
 	},
 
@@ -427,4 +436,9 @@
 	{
 		return this._.contents[id] && this._.contents[id].getValue();
+	},
+
+	setValueOf : function( id, value )
+	{
+		return this._.contents[id] && this._.contents[id].setValue( value );
 	}
 };
@@ -432,7 +446,7 @@
 CKEDITOR.tools.extend( CKEDITOR.dialog,
 	{
-		add : function( name, callback )
-		{
-			this._.dialogDefinitions[name] = callback;
+		add : function( name, dialogDefinition )
+		{
+			this._.dialogDefinitions[name] = dialogDefinition;
 		},
 
@@ -478,159 +492,19 @@
 CKEDITOR.dialog._ = 
 {
-	defaultDialogDefinition :
-	{
-		resizable : CKEDITOR.DIALOG_RESIZE_NONE,
-		minWidth : 600,
-		minHeight : 400,
-		buttons : [ CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton ]
+	defaultDialogDefinition : function( editor )
+	{
+		return {
+			resizable : CKEDITOR.DIALOG_RESIZE_NONE,
+			minWidth : 600,
+			minHeight : 400,
+			buttons : [ CKEDITOR.dialog.okButton, CKEDITOR.dialog.cancelButton ]
+		}
 	},
 
 	uiElementBuilders : {},
 
-	dialogDefinitions : {
-		testOnly : function()
-		{
-			return {
-				title : 'Test Dialog',
-				resizable : CKEDITOR.DIALOG_RESIZE_NONE,
-				minWidth : 500,
-				minHeight : 400,
-				contents : [
-					{
-						id : 'tab1',
-						label : 'First Tab',
-						title : 'First Tab Title',
-						accessKey : 'Q',
-						elements : [
-							{
-								type : 'text',
-								label : 'Test Text 1',
-								id : 'testText1',
-								'default' : 'hello world!'
-							},
-
-							{
-								type : 'text',
-								label : 'Test Text 2',
-								id : 'testText2',
-								'default' : 'Wheee'
-							},
-
-							{
-								type : 'text',
-								label : 'Test Text 3',
-								id : 'testText3',
-								'default' : 'Blah blah'
-							}
-						]
-					},
-
-					{
-						id : 'tab2',
-						label : 'Second Tab',
-						title : 'Second Tab Title',
-						accessKey : 'W',
-						elements : [
-							{
-								type : 'hbox',
-								children : [
-									{
-										type : 'text',
-										label : 'Test Text 4',
-										title : 'Your love is like bad medicine!',
-										id : 'testText4',
-										'default' : 'hello world!',
-										validate : function( dialog )
-										{
-											var valid = /^[A-Z a-z!]+$/.test( this.getValue() );
-											if ( !valid )
-											{
-												this.select();
-												alert( 'Test Text 4 must only contain alphanumeric characters, space, or ! and must not be empty.' );
-											}
-											return valid;
-										}
-									},
-
-									{
-										type : 'text',
-										label : 'Test Text 5',
-										id : 'testText5',
-										'default' : 'Wheee'
-									},
-
-									{
-										type : 'text',
-										label : 'Test Text 6',
-										id : 'testText6',
-										'default' : 'Blah blah'
-									}
-								]
-							}
-						]
-					},
-
-					{
-						id : 'tab3',
-						label : 'Third Tab',
-						title : 'Third Tab Title',
-						accessKey : 'E',
-						elements : [
-							{
-								type : 'vbox',
-								children : [
-									{
-										type : 'checkbox',
-										label : 'Enable this',
-										title : 'Shake it up, just like bad medicine!',
-										checked : false
-									},
-
-									{
-										type : 'checkbox',
-										label : 'Enable that',
-										checked : true 
-									},
-
-									{
-										type : 'checkbox',
-										label : 'Enable those',
-										checked : false
-									},
-
-									{
-										type : 'radio',
-										label : 'Include library:',
-										title : 'Trying to include a library in LOLCODE.',
-										'default' : 'stdio',
-										items : [
-											[ 'Standard I/O', 'stdio', 'You need this to write Hello World.' ],
-											[ 'Standard C Library', 'stdlib', 'You need this to exit.' ],
-											[ 'POSIX Library', 'unistd', 'You need this to sleep.' ],
-											[ 'Signal Library', 'signal' ]
-										]
-									},
-
-									{
-										type : 'button',
-										label : 'Click Me',
-										title : 'Click me plz!',
-										onClick : function( evt )
-										{
-											console.log( 'Clicked!!' );
-										}
-									},
-
-									{
-										type : 'html',
-										html : '<strong>CKEditor rocks.</strong>'
-									}
-								]
-							}
-						]
-					}
-				]
-			};
-		}
+	dialogDefinitions : 
+	{
+		testOnly : '_source/dialogs/testOnly/dialog.js'
 	},
 
@@ -794,6 +668,8 @@
 	initResizeHandles : function( dialog )
 	{
-		var minWidth = dialog._.definition.minWidth || 0,
-			minHeight = dialog._.definition.minHeight || 0,
+		var definition = dialog._.definition,
+			minWidth = definition.minWidth || 0,
+			minHeight = definition.minHeight || 0,
+			resizable = definition.resizable,
 			topSizer = function( coords, dy )
 			{
@@ -907,7 +783,16 @@
 			};
 
+		var widthTest = /[lr]/,
+			heightTest = /[tb]/;
 		for ( var i = 0 ; i < 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] } );
 		}
@@ -1122,8 +1007,24 @@
 		openDialog : function( dialogName )
 		{
-			var dialog = CKEDITOR.dialog.storedDialogs[dialogName] || new CKEDITOR.dialog( this, dialogName );
-			CKEDITOR.dialog.storedDialogs[dialogName] = dialog;
-			dialog.show();
-			return dialog;
+			var me = this;
+
+			// If the dialogDefinition is already loaded, open it immediately.
+			if ( typeof( CKEDITOR.dialog._.dialogDefinitions[dialogName] ) == 'function' )
+			{
+				var dialog = CKEDITOR.dialog.storedDialogs[dialogName] || new CKEDITOR.dialog( this, dialogName );
+				CKEDITOR.dialog.storedDialogs[dialogName] = dialog;
+				dialog.show();
+				return dialog;
+			}
+
+			// Not loaded? Load the .js file first.
+			var body = CKEDITOR.document.getBody(),
+				cursor = body.$.style.cursor;
+			body.setStyle( 'cursor', 'wait' );
+			CKEDITOR.scriptLoader.load( CKEDITOR.getUrl( CKEDITOR.dialog._.dialogDefinitions[dialogName] ), function()
+				{
+					me.openDialog( dialogName );
+					body.setStyle( 'cursor', cursor );
+				} );
 		}
 	});
