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