2 Copyright (c) 2003-2010, 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 editor.on( 'doubleclick', function( evt )
\r
82 var element = evt.data.element;
\r
84 if ( element.is( 'img' ) && element.getAttribute( '_cke_real_element_type' ) == 'flash' )
\r
85 evt.data.dialog = 'flash';
\r
88 // If the "contextmenu" plugin is loaded, register the listeners.
\r
89 if ( editor.contextMenu )
\r
91 editor.contextMenu.addListener( function( element, selection )
\r
93 if ( element && element.is( 'img' ) && !element.isReadOnly()
\r
94 && element.getAttribute( '_cke_real_element_type' ) == 'flash' )
\r
95 return { flash : CKEDITOR.TRISTATE_OFF };
\r
100 afterInit : function( editor )
\r
102 var dataProcessor = editor.dataProcessor,
\r
103 dataFilter = dataProcessor && dataProcessor.dataFilter;
\r
107 dataFilter.addRules(
\r
111 'cke:object' : function( element )
\r
113 var attributes = element.attributes,
\r
114 classId = attributes.classid && String( attributes.classid ).toLowerCase();
\r
118 // Look for the inner <embed>
\r
119 for ( var i = 0 ; i < element.children.length ; i++ )
\r
121 if ( element.children[ i ].name == 'cke:embed' )
\r
123 if ( !isFlashEmbed( element.children[ i ] ) )
\r
126 return createFakeElement( editor, element );
\r
132 return createFakeElement( editor, element );
\r
135 'cke:embed' : function( element )
\r
137 if ( !isFlashEmbed( element ) )
\r
140 return createFakeElement( editor, element );
\r
148 requires : [ 'fakeobjects' ]
\r
152 CKEDITOR.tools.extend( CKEDITOR.config,
\r
155 * Save as EMBED tag only. This tag is unrecommended.
\r
159 flashEmbedTagOnly : false,
\r
162 * Add EMBED tag as alternative: <object><embed></embed></object>
\r
166 flashAddEmbedTag : true,
\r
169 * Use embedTagOnly and addEmbedTag values on edit.
\r
173 flashConvertOnEdit : false
\r