]>
git.immae.eu Git - perso/Immae/Projets/packagist/piedsjaloux-ckeditor-component.git/blob - sources/plugins/Audio/plugin.js
ee618f6dd74805360549a7628dd44baa4e052726
2 * @file audio plugin for CKEditor
3 * Copyright (C) 2011 Alfonso Martínez de Lizarrondo
7 * Licensed under the terms of any of the following licenses at your
10 * - GNU General Public License Version 2 or later (the "GPL")
11 * http://www.gnu.org/licenses/gpl.html
13 * - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
14 * http://www.gnu.org/licenses/lgpl.html
16 * - Mozilla Public License Version 1.1 or later (the "MPL")
17 * http://www.mozilla.org/MPL/MPL-1.1.html
25 CKEDITOR
.plugins
.add( 'Audio',
27 // Translations, available at the end of this file, without extra requests
28 lang : [ 'en', 'es' ],
30 getPlaceholderCss : function()
32 return 'img.cke_audio' +
34 'background-image: url(' + CKEDITOR
.getUrl( this.path
+ 'images/placeholder.png' ) + ');' +
35 'background-position: center center;' +
36 'background-repeat: no-repeat;' +
37 'background-color:gray;'+
38 'border: 1px solid #a9a9a9;' +
48 CKEDITOR
.addCss( this.getPlaceholderCss() );
52 init : function( editor
)
54 var lang
= editor
.lang
.audio
;
56 // Check for CKEditor 3.5
57 if (typeof editor
.element
.data
== 'undefined')
59 alert('The "audio" plugin requires CKEditor 3.5 or newer');
63 CKEDITOR
.dialog
.add( 'audio', this.path
+ 'dialogs/audio.js' );
65 editor
.addCommand( 'Audio', new CKEDITOR
.dialogCommand( 'audio' ) );
66 editor
.ui
.addButton( 'Audio',
70 icon : this.path
+ 'images/icon.png'
75 editor
.addCss( this.getPlaceholderCss() );
78 // If the "menu" plugin is loaded, register the menu items.
79 if ( editor
.addMenuItems
)
85 label : lang
.properties
,
92 editor
.on( 'doubleclick', function( evt
)
94 var element
= evt
.data
.element
;
96 if ( element
.is( 'img' ) && element
.data( 'cke-real-element-type' ) == 'audio' )
97 evt
.data
.dialog
= 'audio';
100 // If the "contextmenu" plugin is loaded, register the listeners.
101 if ( editor
.contextMenu
)
103 editor
.contextMenu
.addListener( function( element
, selection
)
105 if ( element
&& element
.is( 'img' ) && !element
.isReadOnly()
106 && element
.data( 'cke-real-element-type' ) == 'audio' )
107 return { audio : CKEDITOR
.TRISTATE_OFF
};
111 // Add special handling for these items
112 CKEDITOR
.dtd
.$empty
['cke:source']=1;
113 CKEDITOR
.dtd
.$empty
['source']=1;
115 editor
.lang
.fakeobjects
.audio
= lang
.fakeObject
;
120 afterInit: function( editor
)
122 var dataProcessor
= editor
.dataProcessor
,
123 htmlFilter
= dataProcessor
&& dataProcessor
.htmlFilter
,
124 dataFilter
= dataProcessor
&& dataProcessor
.dataFilter
;
126 // dataFilter : conversion from html input to internal data
131 $ : function( realElement
)
133 if ( realElement
.name
== 'audio' )
135 realElement
.name
= 'cke:audio';
136 for( var i
=0; i
< realElement
.children
.length
; i
++)
138 if ( realElement
.children
[ i
].name
== 'source' )
139 realElement
.children
[ i
].name
= 'cke:source'
142 var fakeElement
= editor
.createFakeParserElement( realElement
, 'cke_audio', 'audio', false ),
143 fakeStyle
= fakeElement
.attributes
.style
|| '';
145 var width
= realElement
.attributes
.width
,
146 height
= realElement
.attributes
.height
,
147 poster
= realElement
.attributes
.poster
;
149 if ( typeof width
!= 'undefined' )
150 fakeStyle
= fakeElement
.attributes
.style
= fakeStyle
+ 'width:' + CKEDITOR
.tools
.cssLength( width
) + ';';
152 if ( typeof height
!= 'undefined' )
153 fakeStyle
= fakeElement
.attributes
.style
= fakeStyle
+ 'height:' + CKEDITOR
.tools
.cssLength( height
) + ';';
156 fakeStyle
= fakeElement
.attributes
.style
= fakeStyle
+ 'background-image:url(' + poster
+ ');';
173 dialogTitle : 'Audio properties',
174 fakeObject : 'Audio',
175 properties : 'Edit audio',
176 widthRequired : 'Width field cannot be empty',
177 heightRequired : 'Height field cannot be empty',
178 poster: 'Poster image',
179 sourceaudio: 'Source audio',
180 sourceType : 'Audio type',
181 linkTemplate : '<a href="%src%">%type%</a> ',
182 fallbackTemplate : 'Your browser doesn\'t support audio.<br>Please download the file: %links%'
187 dialogTitle : 'Propiedades de audio',
188 fakeObject : 'Audio',
189 properties : 'Editar el audio',
190 widthRequired : 'La anchura no se puede dejar en blanco',
191 heightRequired : 'La altura no se puede dejar en blanco',
192 poster: 'Imagen de presentación',
193 sourceaudio: 'Archivo de audio',
195 linkTemplate : '<a href="%src%">%type%</a> ',
196 fallbackTemplate : 'Su navegador no soporta audio.<br>Por favor, descargue el fichero: %links%'
207 CKEDITOR
.plugins
.setLang( 'audio', 'en', en
);
209 CKEDITOR
.plugins
.setLang( 'audio', 'es', es
);