2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
8 var flashFilenameRegex = /\.swf(?:$|\?)/i;
10 var cssifyLength = CKEDITOR.tools.cssLength;
12 function isFlashEmbed( element )
14 var attributes = element.attributes;
16 return ( attributes.type == 'application/x-shockwave-flash' || flashFilenameRegex.test( attributes.src || '' ) );
19 function createFakeElement( editor, realElement )
21 var fakeElement = editor.createFakeParserElement( realElement, 'cke_flash', 'flash', true ),
22 fakeStyle = fakeElement.attributes.style || '';
24 var width = realElement.attributes.width,
25 height = realElement.attributes.height;
27 if ( typeof width != 'undefined' )
28 fakeStyle = fakeElement.attributes.style = fakeStyle + 'width:' + cssifyLength( width ) + ';';
30 if ( typeof height != 'undefined' )
31 fakeStyle = fakeElement.attributes.style = fakeStyle + 'height:' + cssifyLength( height ) + ';';
36 CKEDITOR.plugins.add( 'flash',
38 init : function( editor )
40 editor.addCommand( 'flash', new CKEDITOR.dialogCommand( 'flash' ) );
41 editor.ui.addButton( 'Flash',
43 label : editor.lang.common.flash,
46 CKEDITOR.dialog.add( 'flash', this.path + 'dialogs/flash.js' );
51 'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/placeholder.png' ) + ');' +
52 'background-position: center center;' +
53 'background-repeat: no-repeat;' +
54 'border: 1px solid #a9a9a9;' +
60 // If the "menu" plugin is loaded, register the menu items.
61 if ( editor.addMenuItems )
67 label : editor.lang.flash.properties,
74 editor.on( 'doubleclick', function( evt )
76 var element = evt.data.element;
78 if ( element.is( 'img' ) && element.data( 'cke-real-element-type' ) == 'flash' )
79 evt.data.dialog = 'flash';
82 // If the "contextmenu" plugin is loaded, register the listeners.
83 if ( editor.contextMenu )
85 editor.contextMenu.addListener( function( element, selection )
87 if ( element && element.is( 'img' ) && !element.isReadOnly()
88 && element.data( 'cke-real-element-type' ) == 'flash' )
89 return { flash : CKEDITOR.TRISTATE_OFF };
94 afterInit : function( editor )
96 var dataProcessor = editor.dataProcessor,
97 dataFilter = dataProcessor && dataProcessor.dataFilter;
105 'cke:object' : function( element )
107 var attributes = element.attributes,
108 classId = attributes.classid && String( attributes.classid ).toLowerCase();
112 // Look for the inner <embed>
113 for ( var i = 0 ; i < element.children.length ; i++ )
115 if ( element.children[ i ].name == 'cke:embed' )
117 if ( !isFlashEmbed( element.children[ i ] ) )
120 return createFakeElement( editor, element );
126 return createFakeElement( editor, element );
129 'cke:embed' : function( element )
131 if ( !isFlashEmbed( element ) )
134 return createFakeElement( editor, element );
142 requires : [ 'fakeobjects' ]
146 CKEDITOR.tools.extend( CKEDITOR.config,
149 * Save as EMBED tag only. This tag is unrecommended.
153 flashEmbedTagOnly : false,
156 * Add EMBED tag as alternative: <object><embed></embed></object>
160 flashAddEmbedTag : true,
163 * Use embedTagOnly and addEmbedTag values on edit.
167 flashConvertOnEdit : false