]> CRI, Mines Paris - PSL - ckeditor.git/blobdiff - skins/ckeditor/_source/plugins/flash/plugin.js
Mimimum syndical pour en faire un produit zope / cmf.
[ckeditor.git] / skins / ckeditor / _source / plugins / flash / plugin.js
diff --git a/skins/ckeditor/_source/plugins/flash/plugin.js b/skins/ckeditor/_source/plugins/flash/plugin.js
new file mode 100644 (file)
index 0000000..97f8a12
--- /dev/null
@@ -0,0 +1,154 @@
+/*\r
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
+For licensing, see LICENSE.html or http://ckeditor.com/license\r
+*/\r
+\r
+(function()\r
+{\r
+       var flashFilenameRegex = /\.swf(?:$|\?)/i;\r
+\r
+       function isFlashEmbed( element )\r
+       {\r
+               var attributes = element.attributes;\r
+\r
+               return ( attributes.type == 'application/x-shockwave-flash' || flashFilenameRegex.test( attributes.src || '' ) );\r
+       }\r
+\r
+       function createFakeElement( editor, realElement )\r
+       {\r
+               return editor.createFakeParserElement( realElement, 'cke_flash', 'flash', true );\r
+       }\r
+\r
+       CKEDITOR.plugins.add( 'flash',\r
+       {\r
+               init : function( editor )\r
+               {\r
+                       editor.addCommand( 'flash', new CKEDITOR.dialogCommand( 'flash' ) );\r
+                       editor.ui.addButton( 'Flash',\r
+                               {\r
+                                       label : editor.lang.common.flash,\r
+                                       command : 'flash'\r
+                               });\r
+                       CKEDITOR.dialog.add( 'flash', this.path + 'dialogs/flash.js' );\r
+\r
+                       editor.addCss(\r
+                               'img.cke_flash' +\r
+                               '{' +\r
+                                       'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/placeholder.png' ) + ');' +\r
+                                       'background-position: center center;' +\r
+                                       'background-repeat: no-repeat;' +\r
+                                       'border: 1px solid #a9a9a9;' +\r
+                                       'width: 80px;' +\r
+                                       'height: 80px;' +\r
+                               '}'\r
+                               );\r
+\r
+                       // If the "menu" plugin is loaded, register the menu items.\r
+                       if ( editor.addMenuItems )\r
+                       {\r
+                               editor.addMenuItems(\r
+                                       {\r
+                                               flash :\r
+                                               {\r
+                                                       label : editor.lang.flash.properties,\r
+                                                       command : 'flash',\r
+                                                       group : 'flash'\r
+                                               }\r
+                                       });\r
+                       }\r
+\r
+                       editor.on( 'doubleclick', function( evt )\r
+                               {\r
+                                       var element = evt.data.element;\r
+\r
+                                       if ( element.is( 'img' ) && element.data( 'cke-real-element-type' ) == 'flash' )\r
+                                               evt.data.dialog = 'flash';\r
+                               });\r
+\r
+                       // If the "contextmenu" plugin is loaded, register the listeners.\r
+                       if ( editor.contextMenu )\r
+                       {\r
+                               editor.contextMenu.addListener( function( element, selection )\r
+                                       {\r
+                                               if ( element && element.is( 'img' ) && !element.isReadOnly()\r
+                                                               && element.data( 'cke-real-element-type' ) == 'flash' )\r
+                                                       return { flash : CKEDITOR.TRISTATE_OFF };\r
+                                       });\r
+                       }\r
+               },\r
+\r
+               afterInit : function( editor )\r
+               {\r
+                       var dataProcessor = editor.dataProcessor,\r
+                               dataFilter = dataProcessor && dataProcessor.dataFilter;\r
+\r
+                       if ( dataFilter )\r
+                       {\r
+                               dataFilter.addRules(\r
+                                       {\r
+                                               elements :\r
+                                               {\r
+                                                       'cke:object' : function( element )\r
+                                                       {\r
+                                                               var attributes = element.attributes,\r
+                                                                       classId = attributes.classid && String( attributes.classid ).toLowerCase();\r
+\r
+                                                               if ( !classId && !isFlashEmbed( element ) )\r
+                                                               {\r
+                                                                       // Look for the inner <embed>\r
+                                                                       for ( var i = 0 ; i < element.children.length ; i++ )\r
+                                                                       {\r
+                                                                               if ( element.children[ i ].name == 'cke:embed' )\r
+                                                                               {\r
+                                                                                       if ( !isFlashEmbed( element.children[ i ] ) )\r
+                                                                                               return null;\r
+\r
+                                                                                       return createFakeElement( editor, element );\r
+                                                                               }\r
+                                                                       }\r
+                                                                       return null;\r
+                                                               }\r
+\r
+                                                               return createFakeElement( editor, element );\r
+                                                       },\r
+\r
+                                                       'cke:embed' : function( element )\r
+                                                       {\r
+                                                               if ( !isFlashEmbed( element ) )\r
+                                                                       return null;\r
+\r
+                                                               return createFakeElement( editor, element );\r
+                                                       }\r
+                                               }\r
+                                       },\r
+                                       5);\r
+                       }\r
+               },\r
+\r
+               requires : [ 'fakeobjects' ]\r
+       });\r
+})();\r
+\r
+CKEDITOR.tools.extend( CKEDITOR.config,\r
+{\r
+       /**\r
+        * Save as EMBED tag only. This tag is unrecommended.\r
+        * @type Boolean\r
+        * @default false\r
+        */\r
+       flashEmbedTagOnly : false,\r
+\r
+       /**\r
+        * Add EMBED tag as alternative: &lt;object&gt&lt;embed&gt&lt;/embed&gt&lt;/object&gt\r
+        * @type Boolean\r
+        * @default false\r
+        */\r
+       flashAddEmbedTag : true,\r
+\r
+       /**\r
+        * Use embedTagOnly and addEmbedTag values on edit.\r
+        * @type Boolean\r
+        * @default false\r
+        */\r
+       flashConvertOnEdit : false\r
+} );\r