]> git.immae.eu Git - perso/Immae/Projets/packagist/ludivine-ckeditor-component.git/blob - sources/plugins/iframe/plugin.js
Validation initiale
[perso/Immae/Projets/packagist/ludivine-ckeditor-component.git] / sources / plugins / iframe / plugin.js
1 /**
2 * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
4 */
5
6 ( function() {
7 CKEDITOR.plugins.add( 'iframe', {
8 requires: 'dialog,fakeobjects',
9 // jscs:disable maximumLineLength
10 lang: 'af,ar,az,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,oc,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%
11 // jscs:enable maximumLineLength
12 icons: 'iframe', // %REMOVE_LINE_CORE%
13 hidpi: true, // %REMOVE_LINE_CORE%
14 onLoad: function() {
15 CKEDITOR.addCss( 'img.cke_iframe' +
16 '{' +
17 'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/placeholder.png' ) + ');' +
18 'background-position: center center;' +
19 'background-repeat: no-repeat;' +
20 'border: 1px solid #a9a9a9;' +
21 'width: 80px;' +
22 'height: 80px;' +
23 '}'
24 );
25 },
26 init: function( editor ) {
27 var pluginName = 'iframe',
28 lang = editor.lang.iframe,
29 allowed = 'iframe[align,longdesc,frameborder,height,name,scrolling,src,title,width]';
30
31 if ( editor.plugins.dialogadvtab )
32 allowed += ';iframe' + editor.plugins.dialogadvtab.allowedContent( { id: 1, classes: 1, styles: 1 } );
33
34 CKEDITOR.dialog.add( pluginName, this.path + 'dialogs/iframe.js' );
35 editor.addCommand( pluginName, new CKEDITOR.dialogCommand( pluginName, {
36 allowedContent: allowed,
37 requiredContent: 'iframe'
38 } ) );
39
40 editor.ui.addButton && editor.ui.addButton( 'Iframe', {
41 label: lang.toolbar,
42 command: pluginName,
43 toolbar: 'insert,80'
44 } );
45
46 editor.on( 'doubleclick', function( evt ) {
47 var element = evt.data.element;
48 if ( element.is( 'img' ) && element.data( 'cke-real-element-type' ) == 'iframe' )
49 evt.data.dialog = 'iframe';
50 } );
51
52 if ( editor.addMenuItems ) {
53 editor.addMenuItems( {
54 iframe: {
55 label: lang.title,
56 command: 'iframe',
57 group: 'image'
58 }
59 } );
60 }
61
62 // If the "contextmenu" plugin is loaded, register the listeners.
63 if ( editor.contextMenu ) {
64 editor.contextMenu.addListener( function( element ) {
65 if ( element && element.is( 'img' ) && element.data( 'cke-real-element-type' ) == 'iframe' )
66 return { iframe: CKEDITOR.TRISTATE_OFF };
67 } );
68 }
69 },
70 afterInit: function( editor ) {
71 var dataProcessor = editor.dataProcessor,
72 dataFilter = dataProcessor && dataProcessor.dataFilter;
73
74 if ( dataFilter ) {
75 dataFilter.addRules( {
76 elements: {
77 iframe: function( element ) {
78 return editor.createFakeParserElement( element, 'cke_iframe', 'iframe', true );
79 }
80 }
81 } );
82 }
83 }
84 } );
85 } )();