2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
8 // Map 'true' and 'false' values to match W3C's specifications
9 // http://www.w3.org/TR/REC-html40/present/frames.html#h-16.5
12 scrolling : { 'true' : 'yes', 'false' : 'no' },
13 frameborder : { 'true' : '1', 'false' : '0' }
16 function loadValue( iframeNode )
18 var isCheckbox = this instanceof CKEDITOR.ui.dialog.checkbox;
19 if ( iframeNode.hasAttribute( this.id ) )
21 var value = iframeNode.getAttribute( this.id );
23 this.setValue( checkboxValues[ this.id ][ 'true' ] == value.toLowerCase() );
25 this.setValue( value );
29 function commitValue( iframeNode )
31 var isRemove = this.getValue() === '',
32 isCheckbox = this instanceof CKEDITOR.ui.dialog.checkbox,
33 value = this.getValue();
35 iframeNode.removeAttribute( this.att || this.id );
36 else if ( isCheckbox )
37 iframeNode.setAttribute( this.id, checkboxValues[ this.id ][ value ] );
39 iframeNode.setAttribute( this.att || this.id, value );
42 CKEDITOR.dialog.add( 'iframe', function( editor )
44 var iframeLang = editor.lang.iframe,
45 commonLang = editor.lang.common,
46 dialogadvtab = editor.plugins.dialogadvtab;
48 title : iframeLang.title,
53 // Clear previously saved elements.
54 this.fakeImage = this.iframeNode = null;
56 var fakeImage = this.getSelectedElement();
57 if ( fakeImage && fakeImage.data( 'cke-real-element-type' ) && fakeImage.data( 'cke-real-element-type' ) == 'iframe' )
59 this.fakeImage = fakeImage;
61 var iframeNode = editor.restoreRealElement( fakeImage );
62 this.iframeNode = iframeNode;
64 this.setupContent( iframeNode, fakeImage );
70 if ( !this.fakeImage )
71 iframeNode = new CKEDITOR.dom.element( 'iframe' );
73 iframeNode = this.iframeNode;
75 // A subset of the specified attributes/styles
76 // should also be applied on the fake element to
77 // have better visual effect. (#5240)
78 var extraStyles = {}, extraAttributes = {};
79 this.commitContent( iframeNode, extraStyles, extraAttributes );
81 // Refresh the fake image.
82 var newFakeImage = editor.createFakeElement( iframeNode, 'cke_iframe', 'iframe', true );
83 newFakeImage.setAttributes( extraAttributes );
84 newFakeImage.setStyles( extraStyles );
87 newFakeImage.replace( this.fakeImage );
88 editor.getSelection().selectElement( newFakeImage );
91 editor.insertElement( newFakeImage );
96 label : commonLang.generalTab,
108 label : commonLang.url,
110 validate : CKEDITOR.dialog.validate.notEmpty( iframeLang.noUrl ),
123 style : 'width:100%',
124 labelLayout : 'vertical',
125 label : commonLang.width,
126 validate : CKEDITOR.dialog.validate.integer( commonLang.invalidWidth ),
127 setup : function( iframeNode, fakeImage )
129 loadValue.apply( this, arguments );
132 var fakeImageWidth = parseInt( fakeImage.$.style.width, 10 );
133 if ( !isNaN( fakeImageWidth ) )
134 this.setValue( fakeImageWidth );
137 commit : function( iframeNode, extraStyles )
139 commitValue.apply( this, arguments );
140 if ( this.getValue() )
141 extraStyles.width = this.getValue() + 'px';
147 style : 'width:100%',
148 labelLayout : 'vertical',
149 label : commonLang.height,
150 validate : CKEDITOR.dialog.validate.integer( commonLang.invalidHeight ),
151 setup : function( iframeNode, fakeImage )
153 loadValue.apply( this, arguments );
156 var fakeImageHeight = parseInt( fakeImage.$.style.height, 10 );
157 if ( !isNaN( fakeImageHeight ) )
158 this.setValue( fakeImageHeight );
161 commit : function( iframeNode, extraStyles )
163 commitValue.apply( this, arguments );
164 if ( this.getValue() )
165 extraStyles.height = this.getValue() + 'px';
174 [ commonLang.notSet , '' ],
175 [ commonLang.alignLeft , 'left' ],
176 [ commonLang.alignRight , 'right' ],
177 [ commonLang.alignTop , 'top' ],
178 [ commonLang.alignMiddle , 'middle' ],
179 [ commonLang.alignBottom , 'bottom' ]
181 style : 'width:100%',
182 labelLayout : 'vertical',
183 label : commonLang.align,
184 setup : function( iframeNode, fakeImage )
186 loadValue.apply( this, arguments );
189 var fakeImageAlign = fakeImage.getAttribute( 'align' );
190 this.setValue( fakeImageAlign && fakeImageAlign.toLowerCase() || '' );
193 commit : function( iframeNode, extraStyles, extraAttributes )
195 commitValue.apply( this, arguments );
196 if ( this.getValue() )
197 extraAttributes.align = this.getValue();
204 widths : [ '50%', '50%' ],
210 label : iframeLang.scrolling,
217 label : iframeLang.border,
225 widths : [ '50%', '50%' ],
231 label : commonLang.name,
238 label : commonLang.advisoryTitle,
247 label : commonLang.longDescr,
253 dialogadvtab && dialogadvtab.createAdvancedTab( editor, { id:1, classes:1, styles:1 })