Nation Notes module contributed by Z&H Healthcare.
[openemr.git] / library / custom_template / ckeditor / _source / plugins / flash / plugin.js
bloba3eb0b7072dbc449ef2c0876d8452ebcc7433c82
1 /*
2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
3 For licensing, see LICENSE.html or http://ckeditor.com/license
4 */
6 (function()
8         var flashFilenameRegex = /\.swf(?:$|\?)/i;
10         var cssifyLength = CKEDITOR.tools.cssLength;
12         function isFlashEmbed( element )
13         {
14                 var attributes = element.attributes;
16                 return ( attributes.type == 'application/x-shockwave-flash' || flashFilenameRegex.test( attributes.src || '' ) );
17         }
19         function createFakeElement( editor, realElement )
20         {
21                 var fakeElement = editor.createFakeParserElement( realElement, 'cke_flash', 'flash', true ),
22                         fakeStyle = fakeElement.attributes.style || '';
24                 var width = realElement.attributes.width,
25                         height = realElement.attributes.height;
27                 if ( typeof width != 'undefined' )
28                         fakeStyle = fakeElement.attributes.style = fakeStyle + 'width:' + cssifyLength( width ) + ';';
30                 if ( typeof height != 'undefined' )
31                         fakeStyle = fakeElement.attributes.style = fakeStyle + 'height:' + cssifyLength( height ) + ';';
33                 return fakeElement;
34         }
36         CKEDITOR.plugins.add( 'flash',
37         {
38                 init : function( editor )
39                 {
40                         editor.addCommand( 'flash', new CKEDITOR.dialogCommand( 'flash' ) );
41                         editor.ui.addButton( 'Flash',
42                                 {
43                                         label : editor.lang.common.flash,
44                                         command : 'flash'
45                                 });
46                         CKEDITOR.dialog.add( 'flash', this.path + 'dialogs/flash.js' );
48                         editor.addCss(
49                                 'img.cke_flash' +
50                                 '{' +
51                                         'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/placeholder.png' ) + ');' +
52                                         'background-position: center center;' +
53                                         'background-repeat: no-repeat;' +
54                                         'border: 1px solid #a9a9a9;' +
55                                         'width: 80px;' +
56                                         'height: 80px;' +
57                                 '}'
58                                 );
60                         // If the "menu" plugin is loaded, register the menu items.
61                         if ( editor.addMenuItems )
62                         {
63                                 editor.addMenuItems(
64                                         {
65                                                 flash :
66                                                 {
67                                                         label : editor.lang.flash.properties,
68                                                         command : 'flash',
69                                                         group : 'flash'
70                                                 }
71                                         });
72                         }
74                         editor.on( 'doubleclick', function( evt )
75                                 {
76                                         var element = evt.data.element;
78                                         if ( element.is( 'img' ) && element.data( 'cke-real-element-type' ) == 'flash' )
79                                                 evt.data.dialog = 'flash';
80                                 });
82                         // If the "contextmenu" plugin is loaded, register the listeners.
83                         if ( editor.contextMenu )
84                         {
85                                 editor.contextMenu.addListener( function( element, selection )
86                                         {
87                                                 if ( element && element.is( 'img' ) && !element.isReadOnly()
88                                                                 && element.data( 'cke-real-element-type' ) == 'flash' )
89                                                         return { flash : CKEDITOR.TRISTATE_OFF };
90                                         });
91                         }
92                 },
94                 afterInit : function( editor )
95                 {
96                         var dataProcessor = editor.dataProcessor,
97                                 dataFilter = dataProcessor && dataProcessor.dataFilter;
99                         if ( dataFilter )
100                         {
101                                 dataFilter.addRules(
102                                         {
103                                                 elements :
104                                                 {
105                                                         'cke:object' : function( element )
106                                                         {
107                                                                 var attributes = element.attributes,
108                                                                         classId = attributes.classid && String( attributes.classid ).toLowerCase();
110                                                                 if ( !classId )
111                                                                 {
112                                                                         // Look for the inner <embed>
113                                                                         for ( var i = 0 ; i < element.children.length ; i++ )
114                                                                         {
115                                                                                 if ( element.children[ i ].name == 'cke:embed' )
116                                                                                 {
117                                                                                         if ( !isFlashEmbed( element.children[ i ] ) )
118                                                                                                 return null;
120                                                                                         return createFakeElement( editor, element );
121                                                                                 }
122                                                                         }
123                                                                         return null;
124                                                                 }
126                                                                 return createFakeElement( editor, element );
127                                                         },
129                                                         'cke:embed' : function( element )
130                                                         {
131                                                                 if ( !isFlashEmbed( element ) )
132                                                                         return null;
134                                                                 return createFakeElement( editor, element );
135                                                         }
136                                                 }
137                                         },
138                                         5);
139                         }
140                 },
142                 requires : [ 'fakeobjects' ]
143         });
144 })();
146 CKEDITOR.tools.extend( CKEDITOR.config,
148         /**
149          * Save as EMBED tag only. This tag is unrecommended.
150          * @type Boolean
151          * @default false
152          */
153         flashEmbedTagOnly : false,
155         /**
156          * Add EMBED tag as alternative: &lt;object&gt&lt;embed&gt&lt;/embed&gt&lt;/object&gt
157          * @type Boolean
158          * @default false
159          */
160         flashAddEmbedTag : true,
162         /**
163          * Use embedTagOnly and addEmbedTag values on edit.
164          * @type Boolean
165          * @default false
166          */
167         flashConvertOnEdit : false
168 } );