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