Index: _source/plugins/iframedialog/plugin.js
===================================================================
--- _source/plugins/iframedialog/plugin.js (revision 0)
+++ _source/plugins/iframedialog/plugin.js (revision 0)
@@ -0,0 +1,135 @@
+/*
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+/**
+ * @fileOverview Plugin for making iframe based dialogs.
+ */
+
+CKEDITOR.plugins.add( 'iframedialog',
+{
+ requires : [ 'dialog' ],
+ onLoad : function()
+ {
+ CKEDITOR.dialog.addIframe = function( name, title, src, width, height, onContentLoad )
+ {
+ var element =
+ {
+ type : 'iframe',
+ src : src,
+ width : '100%',
+ height : '100%'
+ }
+ if ( typeof( onContentLoad ) == 'function' )
+ element.onContentLoad = onContentLoad;
+
+ var definition =
+ {
+ title : title,
+ minWidth : width,
+ minHeight : height,
+ contents :
+ [
+ {
+ id : 'iframe',
+ label : title,
+ expand : true,
+ elements : [ element ]
+ }
+ ]
+ };
+
+ return this.add( name, function(){ return definition; } );
+ };
+
+ (function()
+ {
+ /**
+ * An iframe element.
+ * @extends CKEDITOR.ui.dialog.uiElement
+ * @example
+ * @constructor
+ * @param {CKEDITOR.dialog} dialog
+ * Parent dialog object.
+ * @param {CKEDITOR.dialog.uiElementDefinition} elementDefinition
+ * The element definition. Accepted fields:
+ *
+ * - src (Required) The src field of the iframe.
+ * - width (Required) The iframe's width.
+ * - height (Required) The iframe's height.
+ * - onContentLoad (Optional) A function to be executed
+ * after the iframe's contents has finished loading.
+ *
+ * @param {Array} htmlList
+ * List of HTML code to output to.
+ */
+ var iframeElement = function( dialog, elementDefinition, htmlList )
+ {
+ if ( arguments.length < 3 )
+ return;
+
+ var _ = ( this._ || ( this._ = {} ) ),
+ contentLoad = elementDefinition.onContentLoad && CKEDITOR.tools.bind( elementDefinition.onContentLoad, this ),
+ cssWidth = CKEDITOR.tools.cssLength( elementDefinition.width ),
+ cssHeight = CKEDITOR.tools.cssLength( elementDefinition.height );
+ _.frameId = CKEDITOR.tools.getNextNumber() + '_iframe';
+
+ // IE BUG: Parent container does not resize to contain the iframe automatically.
+ dialog.on( 'load', function()
+ {
+ var iframe = CKEDITOR.document.getById( _.frameId ),
+ parentContainer = iframe.getParent();
+
+ parentContainer.setStyles(
+ {
+ width : cssWidth,
+ height : cssHeight
+ } );
+ } );
+
+ var attributes =
+ {
+ src : '%2',
+ id : _.frameId,
+ frameborder : 0,
+ allowtransparency : true
+ };
+ var myHtml = [];
+
+ if ( typeof( elementDefinition.onContentLoad ) == 'function' )
+ attributes.onload = 'CKEDITOR.tools.callFunction(%1);';
+
+ CKEDITOR.ui.dialog.uiElement.call( this, dialog, elementDefinition, myHtml, 'iframe',
+ {
+ width : cssWidth,
+ height : cssHeight
+ }, attributes, '' );
+
+ // Put a placeholder for the first time.
+ htmlList.push( '' );
+
+ // Iframe elements should be refreshed whenever it is shown.
+ myHtml = myHtml.join( '' );
+ dialog.on( 'show', function()
+ {
+ var iframe = CKEDITOR.document.getById( _.frameId ),
+ parentContainer = iframe.getParent(),
+ callIndex = CKEDITOR.tools.addFunction( contentLoad ),
+ html = myHtml.replace( '%1', callIndex ).replace( '%2', CKEDITOR.tools.htmlEncode( elementDefinition.src ) );
+ parentContainer.setHtml( html );
+ } );
+ };
+
+ iframeElement.prototype = new CKEDITOR.ui.dialog.uiElement;
+
+ CKEDITOR.dialog.addUIElement( 'iframe',
+ {
+ build : function( dialog, elementDefinition, output )
+ {
+ return new iframeElement( dialog, elementDefinition, output );
+ }
+ } );
+ })();
+ }
+} );
Index: _source/plugins/dialog/plugin.js
===================================================================
--- _source/plugins/dialog/plugin.js (revision 3123)
+++ _source/plugins/dialog/plugin.js (working copy)
@@ -1620,12 +1620,6 @@
(function()
{
- var decimalRegex = /^\d+(?:\.\d+)?$/,
- fixLength = function( length )
- {
- return length + ( decimalRegex.test( length ) ? 'px' : '' );
- };
-
CKEDITOR.ui.dialog =
{
/**
@@ -1807,14 +1801,14 @@
if ( widths )
{
if ( widths[i] )
- styles.push( 'width:' + fixLength( widths[i] ) );
+ styles.push( 'width:' + CKEDITOR.tools.cssLength( widths[i] ) );
}
else
styles.push( 'width:' + Math.floor( 100 / childHtmlList.length ) + '%' );
if ( height )
- styles.push( 'height:' + fixLength( height ) );
+ styles.push( 'height:' + CKEDITOR.tools.cssLength( height ) );
if ( elementDefinition && elementDefinition.padding != undefined )
- styles.push( 'padding:' + fixLength( elementDefinition.padding ) );
+ styles.push( 'padding:' + CKEDITOR.tools.cssLength( elementDefinition.padding ) );
if ( styles.length > 0 )
html.push( 'style="' + styles.join('; ') + '" ' );
html.push( '>', childHtmlList[i], '' );
@@ -1873,7 +1867,7 @@
html.push( 'style="' );
if ( elementDefinition && elementDefinition.expand )
html.push( 'height:100%;' );
- html.push( 'width:' + fixLength( width || '100%' ), ';' );
+ html.push( 'width:' + CKEDITOR.tools.cssLength( width || '100%' ), ';' );
html.push( '"' );
html.push( 'align="', CKEDITOR.tools.htmlEncode(
( elementDefinition && elementDefinition.align ) || ( dialog.getParentEditor().lang.dir == 'ltr' ? 'left' : 'right' ) ), '" ' );
@@ -1884,13 +1878,13 @@
var styles = [];
html.push( ' 0 )
html.push( 'style="', styles.join( '; ' ), '" ' );
html.push( ' class="cke_dialog_ui_vbox_child">', childHtmlList[i], ' |
' );
Index: _source/core/tools.js
===================================================================
--- _source/core/tools.js (revision 3123)
+++ _source/core/tools.js (working copy)
@@ -451,7 +451,16 @@
{
var fn = functions[ index ];
return fn.apply( window, Array.prototype.slice.call( arguments, 1 ) );
- }
+ },
+
+ cssLength : (function()
+ {
+ var decimalRegex = /^\d+(?:\.\d+)?$/;
+ return function( length )
+ {
+ return length + ( decimalRegex.test( length ) ? 'px' : '' );
+ };
+ })()
};
})();