]>
git.immae.eu Git - perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git/blob - sources/plugins/flash/plugin.js
2 * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
7 var flashFilenameRegex
= /\.swf(?:$|\?)/i;
9 function isFlashEmbed( element
) {
10 var attributes
= element
.attributes
;
12 return ( attributes
.type
== 'application/x-shockwave-flash' || flashFilenameRegex
.test( attributes
.src
|| '' ) );
15 function createFakeElement( editor
, realElement
) {
16 return editor
.createFakeParserElement( realElement
, 'cke_flash', 'flash', true );
19 CKEDITOR
.plugins
.add( 'flash', {
20 requires: 'dialog,fakeobjects',
21 // jscs:disable maximumLineLength
22 lang: 'af,ar,bg,bn,bs,ca,cs,cy,da,de,de-ch,el,en,en-au,en-ca,en-gb,eo,es,et,eu,fa,fi,fo,fr,fr-ca,gl,gu,he,hi,hr,hu,id,is,it,ja,ka,km,ko,ku,lt,lv,mk,mn,ms,nb,nl,no,pl,pt,pt-br,ro,ru,si,sk,sl,sq,sr,sr-latn,sv,th,tr,tt,ug,uk,vi,zh,zh-cn', // %REMOVE_LINE_CORE%
23 // jscs:enable maximumLineLength
24 icons: 'flash', // %REMOVE_LINE_CORE%
25 hidpi: true, // %REMOVE_LINE_CORE%
27 CKEDITOR
.addCss( 'img.cke_flash' +
29 'background-image: url(' + CKEDITOR
.getUrl( this.path
+ 'images/placeholder.png' ) + ');' +
30 'background-position: center center;' +
31 'background-repeat: no-repeat;' +
32 'border: 1px solid #a9a9a9;' +
39 init: function( editor
) {
40 var allowed
= 'object[classid,codebase,height,hspace,vspace,width];' +
41 'param[name,value];' +
42 'embed[height,hspace,pluginspage,src,type,vspace,width]';
44 if ( CKEDITOR
.dialog
.isTabEnabled( editor
, 'flash', 'properties' ) )
45 allowed
+= ';object[align]; embed[allowscriptaccess,quality,scale,wmode]';
46 if ( CKEDITOR
.dialog
.isTabEnabled( editor
, 'flash', 'advanced' ) )
47 allowed
+= ';object[id]{*}; embed[bgcolor]{*}(*)';
49 editor
.addCommand( 'flash', new CKEDITOR
.dialogCommand( 'flash', {
50 allowedContent: allowed
,
51 requiredContent: 'embed'
53 editor
.ui
.addButton
&& editor
.ui
.addButton( 'Flash', {
54 label: editor
.lang
.common
.flash
,
58 CKEDITOR
.dialog
.add( 'flash', this.path
+ 'dialogs/flash.js' );
60 // If the "menu" plugin is loaded, register the menu items.
61 if ( editor
.addMenuItems
) {
62 editor
.addMenuItems( {
64 label: editor
.lang
.flash
.properties
,
71 editor
.on( 'doubleclick', function( evt
) {
72 var element
= evt
.data
.element
;
74 if ( element
.is( 'img' ) && element
.data( 'cke-real-element-type' ) == 'flash' )
75 evt
.data
.dialog
= 'flash';
78 // If the "contextmenu" plugin is loaded, register the listeners.
79 if ( editor
.contextMenu
) {
80 editor
.contextMenu
.addListener( function( element
) {
81 if ( element
&& element
.is( 'img' ) && !element
.isReadOnly() && element
.data( 'cke-real-element-type' ) == 'flash' )
82 return { flash: CKEDITOR
.TRISTATE_OFF
};
87 afterInit: function( editor
) {
88 var dataProcessor
= editor
.dataProcessor
,
89 dataFilter
= dataProcessor
&& dataProcessor
.dataFilter
;
92 dataFilter
.addRules( {
94 'cke:object': function( element
) {
95 var attributes
= element
.attributes
,
96 classId
= attributes
.classid
&& String( attributes
.classid
).toLowerCase();
98 if ( !classId
&& !isFlashEmbed( element
) ) {
99 // Look for the inner <embed>
100 for ( var i
= 0; i
< element
.children
.length
; i
++ ) {
101 if ( element
.children
[ i
].name
== 'cke:embed' ) {
102 if ( !isFlashEmbed( element
.children
[ i
] ) )
105 return createFakeElement( editor
, element
);
111 return createFakeElement( editor
, element
);
114 'cke:embed': function( element
) {
115 if ( !isFlashEmbed( element
) )
118 return createFakeElement( editor
, element
);
127 CKEDITOR
.tools
.extend( CKEDITOR
.config
, {
129 * Save as `<embed>` tag only. This tag is unrecommended.
131 * @cfg {Boolean} [flashEmbedTagOnly=false]
132 * @member CKEDITOR.config
134 flashEmbedTagOnly: false,
137 * Add `<embed>` tag as alternative: `<object><embed></embed></object>`.
139 * @cfg {Boolean} [flashAddEmbedTag=false]
140 * @member CKEDITOR.config
142 flashAddEmbedTag: true,
145 * Use {@link #flashEmbedTagOnly} and {@link #flashAddEmbedTag} values on edit.
147 * @cfg {Boolean} [flashConvertOnEdit=false]
148 * @member CKEDITOR.config
150 flashConvertOnEdit: false