Nation Notes module contributed by Z&H Healthcare.
[openemr.git] / library / custom_template / ckeditor / _source / plugins / iframe / plugin.js
blobe0d2d3831c2bde6e90167a5ff499e7fe1183400f
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         function createFakeElement( editor, realElement )
9         {
10                 var fakeElement = editor.createFakeParserElement( realElement, 'cke_iframe', 'iframe', true ),
11                         fakeStyle = fakeElement.attributes.style || '';
13                 var width = realElement.attributes.width,
14                         height = realElement.attributes.height;
16                 if ( typeof width != 'undefined' )
17                         fakeStyle += 'width:' + CKEDITOR.tools.cssLength( width ) + ';';
19                 if ( typeof height != 'undefined' )
20                         fakeStyle += 'height:' + CKEDITOR.tools.cssLength( height ) + ';';
22                 fakeElement.attributes.style = fakeStyle;
24                 return fakeElement;
25         }
27         CKEDITOR.plugins.add( 'iframe',
28         {
29                 requires : [ 'dialog', 'fakeobjects' ],
30                 init : function( editor )
31                 {
32                         var pluginName = 'iframe',
33                                 lang = editor.lang.iframe;
35                         CKEDITOR.dialog.add( pluginName, this.path + 'dialogs/iframe.js' );
36                         editor.addCommand( pluginName, new CKEDITOR.dialogCommand( pluginName ) );
38                         editor.addCss(
39                                 'img.cke_iframe' +
40                                 '{' +
41                                         'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/placeholder.png' ) + ');' +
42                                         'background-position: center center;' +
43                                         'background-repeat: no-repeat;' +
44                                         'border: 1px solid #a9a9a9;' +
45                                         'width: 80px;' +
46                                         'height: 80px;' +
47                                 '}'
48                         );
50                         editor.ui.addButton( 'Iframe',
51                                 {
52                                         label : lang.toolbar,
53                                         command : pluginName
54                                 });
56                         editor.on( 'doubleclick', function( evt )
57                                 {
58                                         var element = evt.data.element;
59                                         if ( element.is( 'img' ) && element.data( 'cke-real-element-type' ) == 'iframe' )
60                                                 evt.data.dialog = 'iframe';
61                                 });
63                         if ( editor.addMenuItems )
64                         {
65                                 editor.addMenuItems(
66                                 {
67                                         iframe :
68                                         {
69                                                 label : lang.title,
70                                                 command : 'iframe',
71                                                 group : 'image'
72                                         }
73                                 });
74                         }
76                         // If the "contextmenu" plugin is loaded, register the listeners.
77                         if ( editor.contextMenu )
78                         {
79                                 editor.contextMenu.addListener( function( element, selection )
80                                         {
81                                                 if ( element && element.is( 'img' ) && element.data( 'cke-real-element-type' ) == 'iframe' )
82                                                         return { iframe : CKEDITOR.TRISTATE_OFF };
83                                         });
84                         }
85                 },
86                 afterInit : function( editor )
87                 {
88                         var dataProcessor = editor.dataProcessor,
89                                 dataFilter = dataProcessor && dataProcessor.dataFilter;
91                         if ( dataFilter )
92                         {
93                                 dataFilter.addRules(
94                                 {
95                                         elements :
96                                         {
97                                                 iframe : function( element )
98                                                 {
99                                                         return createFakeElement( editor, element );
100                                                 }
101                                         }
102                                 });
103                         }
104                 }
105         });
106 })();