2 Copyright (c) 2003-2013, 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 );
\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.htmlLength( commonLang.invalidHtmlLength.replace( '%1', commonLang.width ) ),
\r
128 commit : commitValue
\r
133 style : 'width:100%',
\r
134 labelLayout : 'vertical',
\r
135 label : commonLang.height,
\r
136 validate : CKEDITOR.dialog.validate.htmlLength( commonLang.invalidHtmlLength.replace( '%1', commonLang.height ) ),
\r
138 commit : commitValue
\r
146 [ commonLang.notSet , '' ],
\r
147 [ commonLang.alignLeft , 'left' ],
\r
148 [ commonLang.alignRight , 'right' ],
\r
149 [ commonLang.alignTop , 'top' ],
\r
150 [ commonLang.alignMiddle , 'middle' ],
\r
151 [ commonLang.alignBottom , 'bottom' ]
\r
153 style : 'width:100%',
\r
154 labelLayout : 'vertical',
\r
155 label : commonLang.align,
\r
156 setup : function( iframeNode, fakeImage )
\r
158 loadValue.apply( this, arguments );
\r
161 var fakeImageAlign = fakeImage.getAttribute( 'align' );
\r
162 this.setValue( fakeImageAlign && fakeImageAlign.toLowerCase() || '' );
\r
165 commit : function( iframeNode, extraStyles, extraAttributes )
\r
167 commitValue.apply( this, arguments );
\r
168 if ( this.getValue() )
\r
169 extraAttributes.align = this.getValue();
\r
176 widths : [ '50%', '50%' ],
\r
182 label : iframeLang.scrolling,
\r
184 commit : commitValue
\r
187 id : 'frameborder',
\r
189 label : iframeLang.border,
\r
191 commit : commitValue
\r
197 widths : [ '50%', '50%' ],
\r
203 label : commonLang.name,
\r
205 commit : commitValue
\r
210 label : commonLang.advisoryTitle,
\r
212 commit : commitValue
\r
219 label : commonLang.longDescr,
\r
221 commit : commitValue
\r
225 dialogadvtab && dialogadvtab.createAdvancedTab( editor, { id:1, classes:1, styles:1 })
\r