2 Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.
\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license
\r
8 var flashFilenameRegex = /\.swf(?:$|\?)/i,
\r
9 numberRegex = /^\d+(?:\.\d+)?$/;
\r
11 function cssifyLength( length )
\r
13 if ( numberRegex.test( length ) )
\r
14 return length + 'px';
\r
18 function isFlashEmbed( element )
\r
20 var attributes = element.attributes;
\r
22 return ( attributes.type == 'application/x-shockwave-flash' || flashFilenameRegex.test( attributes.src || '' ) );
\r
25 function createFakeElement( editor, realElement )
\r
27 var fakeElement = editor.createFakeParserElement( realElement, 'cke_flash', 'flash', true ),
\r
28 fakeStyle = fakeElement.attributes.style || '';
\r
30 var width = realElement.attributes.width,
\r
31 height = realElement.attributes.height;
\r
33 if ( typeof width != 'undefined' )
\r
34 fakeStyle = fakeElement.attributes.style = fakeStyle + 'width:' + cssifyLength( width ) + ';';
\r
36 if ( typeof height != 'undefined' )
\r
37 fakeStyle = fakeElement.attributes.style = fakeStyle + 'height:' + cssifyLength( height ) + ';';
\r
42 CKEDITOR.plugins.add( 'flash',
\r
44 init : function( editor )
\r
46 editor.addCommand( 'flash', new CKEDITOR.dialogCommand( 'flash' ) );
\r
47 editor.ui.addButton( 'Flash',
\r
49 label : editor.lang.common.flash,
\r
52 CKEDITOR.dialog.add( 'flash', this.path + 'dialogs/flash.js' );
\r
57 'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/placeholder.png' ) + ');' +
\r
58 'background-position: center center;' +
\r
59 'background-repeat: no-repeat;' +
\r
60 'border: 1px solid #a9a9a9;' +
\r
66 // If the "menu" plugin is loaded, register the menu items.
\r
67 if ( editor.addMenuItems )
\r
69 editor.addMenuItems(
\r
73 label : editor.lang.flash.properties,
\r
80 // If the "contextmenu" plugin is loaded, register the listeners.
\r
81 if ( editor.contextMenu )
\r
83 editor.contextMenu.addListener( function( element, selection )
\r
85 if ( element && element.is( 'img' ) && element.getAttribute( '_cke_real_element_type' ) == 'flash' )
\r
86 return { flash : CKEDITOR.TRISTATE_OFF };
\r
91 afterInit : function( editor )
\r
93 var dataProcessor = editor.dataProcessor,
\r
94 dataFilter = dataProcessor && dataProcessor.dataFilter;
\r
98 dataFilter.addRules(
\r
102 'cke:object' : function( element )
\r
104 var attributes = element.attributes,
\r
105 classId = attributes.classid && String( attributes.classid ).toLowerCase();
\r
109 // Look for the inner <embed>
\r
110 for ( var i = 0 ; i < element.children.length ; i++ )
\r
112 if ( element.children[ i ].name == 'embed' )
\r
114 if ( !isFlashEmbed( element.children[ i ] ) )
\r
117 return createFakeElement( editor, element );
\r
123 return createFakeElement( editor, element );
\r
126 'cke:embed' : function( element )
\r
128 if ( !isFlashEmbed( element ) )
\r
131 return createFakeElement( editor, element );
\r
139 requires : [ 'fakeobjects' ]
\r
143 CKEDITOR.tools.extend( CKEDITOR.config,
\r
146 * Save as EMBED tag only. This tag is unrecommended.
\r
150 flashEmbedTagOnly : false,
\r
153 * Add EMBED tag as alternative: <object><embed></embed></object>
\r
157 flashAddEmbedTag : true,
\r
160 * Use embedTagOnly and addEmbedTag values on edit.
\r
164 flashConvertOnEdit : false
\r