diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2017-12-04 18:46:08 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2017-12-04 18:46:08 +0100 |
commit | 9946db9daaa76448d0e43247472cdedd2a5ea22a (patch) | |
tree | c9de3eba90b0fa47a4c567681deb7f0a6ab5b383 /sources/plugins/Audio | |
parent | 317f8f8f0651488f226b5280a8f036c7c135c639 (diff) | |
download | piedsjaloux-ckeditor-component-master.tar.gz piedsjaloux-ckeditor-component-master.tar.zst piedsjaloux-ckeditor-component-master.zip |
Diffstat (limited to 'sources/plugins/Audio')
-rw-r--r-- | sources/plugins/Audio/dialogs/audio.js | 350 | ||||
-rw-r--r-- | sources/plugins/Audio/docs/install.html | 69 | ||||
-rw-r--r-- | sources/plugins/Audio/docs/styles.css | 67 | ||||
-rw-r--r-- | sources/plugins/Audio/images/audio.png | bin | 15258 -> 0 bytes | |||
-rw-r--r-- | sources/plugins/Audio/images/icon.png | bin | 1356 -> 0 bytes | |||
-rw-r--r-- | sources/plugins/Audio/images/placeholder.png | bin | 862 -> 0 bytes | |||
-rw-r--r-- | sources/plugins/Audio/plugin.js | 211 |
7 files changed, 0 insertions, 697 deletions
diff --git a/sources/plugins/Audio/dialogs/audio.js b/sources/plugins/Audio/dialogs/audio.js deleted file mode 100644 index 5b72af9..0000000 --- a/sources/plugins/Audio/dialogs/audio.js +++ /dev/null | |||
@@ -1,350 +0,0 @@ | |||
1 | CKEDITOR.dialog.add( 'audio', function ( editor ) | ||
2 | { | ||
3 | var lang = editor.lang.audio; | ||
4 | |||
5 | function commitValue( audioNode, extraStyles ) | ||
6 | { | ||
7 | var value=this.getValue(); | ||
8 | |||
9 | if ( !value && this.id=='id' ) | ||
10 | value = generateId(); | ||
11 | |||
12 | audioNode.setAttribute( this.id, value); | ||
13 | |||
14 | if ( !value ) | ||
15 | return; | ||
16 | switch( this.id ) | ||
17 | { | ||
18 | case 'poster': | ||
19 | extraStyles.backgroundImage = 'url(' + value + ')'; | ||
20 | break; | ||
21 | case 'width': | ||
22 | extraStyles.width = value + 'px'; | ||
23 | break; | ||
24 | case 'height': | ||
25 | extraStyles.height = value + 'px'; | ||
26 | break; | ||
27 | } | ||
28 | } | ||
29 | |||
30 | function commitSrc( audioNode, extraStyles, audios ) | ||
31 | { | ||
32 | var match = this.id.match(/(\w+)(\d)/), | ||
33 | id = match[1], | ||
34 | number = parseInt(match[2], 10); | ||
35 | |||
36 | var audio = audios[number] || (audios[number]={}); | ||
37 | audio[id] = this.getValue(); | ||
38 | } | ||
39 | |||
40 | function loadValue( audioNode ) | ||
41 | { | ||
42 | if ( audioNode ) | ||
43 | this.setValue( audioNode.getAttribute( this.id ) ); | ||
44 | else | ||
45 | { | ||
46 | if ( this.id == 'id') | ||
47 | this.setValue( generateId() ); | ||
48 | } | ||
49 | } | ||
50 | |||
51 | function loadSrc( audioNode, audios ) | ||
52 | { | ||
53 | var match = this.id.match(/(\w+)(\d)/), | ||
54 | id = match[1], | ||
55 | number = parseInt(match[2], 10); | ||
56 | |||
57 | var audio = audios[number]; | ||
58 | if (!audio) | ||
59 | return; | ||
60 | this.setValue( audio[ id ] ); | ||
61 | } | ||
62 | |||
63 | function generateId() | ||
64 | { | ||
65 | var now = new Date(); | ||
66 | return 'audio' + now.getFullYear() + now.getMonth() + now.getDate() + now.getHours() + now.getMinutes() + now.getSeconds(); | ||
67 | } | ||
68 | |||
69 | // To automatically get the dimensions of the poster image | ||
70 | var onImgLoadEvent = function() | ||
71 | { | ||
72 | // Image is ready. | ||
73 | var preview = this.previewImage; | ||
74 | preview.removeListener( 'load', onImgLoadEvent ); | ||
75 | preview.removeListener( 'error', onImgLoadErrorEvent ); | ||
76 | preview.removeListener( 'abort', onImgLoadErrorEvent ); | ||
77 | |||
78 | this.setValueOf( 'info', 'width', preview.$.width ); | ||
79 | this.setValueOf( 'info', 'height', preview.$.height ); | ||
80 | }; | ||
81 | |||
82 | var onImgLoadErrorEvent = function() | ||
83 | { | ||
84 | // Error. Image is not loaded. | ||
85 | var preview = this.previewImage; | ||
86 | preview.removeListener( 'load', onImgLoadEvent ); | ||
87 | preview.removeListener( 'error', onImgLoadErrorEvent ); | ||
88 | preview.removeListener( 'abort', onImgLoadErrorEvent ); | ||
89 | }; | ||
90 | |||
91 | return { | ||
92 | title : lang.dialogTitle, | ||
93 | minWidth : 400, | ||
94 | minHeight : 200, | ||
95 | |||
96 | onShow : function() | ||
97 | { | ||
98 | // Clear previously saved elements. | ||
99 | this.fakeImage = this.audioNode = null; | ||
100 | // To get dimensions of poster image | ||
101 | this.previewImage = editor.document.createElement( 'img' ); | ||
102 | |||
103 | var fakeImage = this.getSelectedElement(); | ||
104 | if ( fakeImage && fakeImage.data( 'cke-real-element-type' ) && fakeImage.data( 'cke-real-element-type' ) == 'audio' ) | ||
105 | { | ||
106 | this.fakeImage = fakeImage; | ||
107 | |||
108 | var audioNode = editor.restoreRealElement( fakeImage ), | ||
109 | audios = [], | ||
110 | sourceList = audioNode.getElementsByTag( 'source', '' ); | ||
111 | if (sourceList.count()==0) | ||
112 | sourceList = audioNode.getElementsByTag( 'source', 'cke' ); | ||
113 | |||
114 | for ( var i = 0, length = sourceList.count() ; i < length ; i++ ) | ||
115 | { | ||
116 | var item = sourceList.getItem( i ); | ||
117 | audios.push( {src : item.getAttribute( 'src' ), type: item.getAttribute( 'type' )} ); | ||
118 | } | ||
119 | |||
120 | this.audioNode = audioNode; | ||
121 | |||
122 | this.setupContent( audioNode, audios ); | ||
123 | } | ||
124 | else | ||
125 | this.setupContent( null, [] ); | ||
126 | }, | ||
127 | |||
128 | onOk : function() | ||
129 | { | ||
130 | // If there's no selected element create one. Otherwise, reuse it | ||
131 | var audioNode = null; | ||
132 | if ( !this.fakeImage ) | ||
133 | { | ||
134 | audioNode = CKEDITOR.dom.element.createFromHtml( '<cke:audio></cke:audio>', editor.document ); | ||
135 | audioNode.setAttributes( | ||
136 | { | ||
137 | controls : 'controls' | ||
138 | } ); | ||
139 | } | ||
140 | else | ||
141 | { | ||
142 | audioNode = this.audioNode; | ||
143 | } | ||
144 | |||
145 | var extraStyles = {}, audios = []; | ||
146 | this.commitContent( audioNode, extraStyles, audios ); | ||
147 | |||
148 | var innerHtml = '', links = '', | ||
149 | link = lang.linkTemplate || '', | ||
150 | fallbackTemplate = lang.fallbackTemplate || ''; | ||
151 | for(var i=0; i<audios.length; i++) | ||
152 | { | ||
153 | var audio = audios[i]; | ||
154 | if ( !audio || !audio.src ) | ||
155 | continue; | ||
156 | innerHtml += '<cke:source src="' + audio.src + '" type="' + audio.type + '" />'; | ||
157 | links += link.replace('%src%', audio.src).replace('%type%', audio.type); | ||
158 | } | ||
159 | audioNode.setHtml( innerHtml + fallbackTemplate.replace( '%links%', links ) ); | ||
160 | |||
161 | // Refresh the fake image. | ||
162 | var newFakeImage = editor.createFakeElement( audioNode, 'cke_audio', 'audio', false ); | ||
163 | newFakeImage.setStyles( extraStyles ); | ||
164 | if ( this.fakeImage ) | ||
165 | { | ||
166 | newFakeImage.replace( this.fakeImage ); | ||
167 | editor.getSelection().selectElement( newFakeImage ); | ||
168 | } | ||
169 | else | ||
170 | { | ||
171 | // Insert it in a div | ||
172 | var div = new CKEDITOR.dom.element( 'DIV', editor.document ); | ||
173 | editor.insertElement( div ); | ||
174 | div.append( newFakeImage ); | ||
175 | } | ||
176 | }, | ||
177 | onHide : function() | ||
178 | { | ||
179 | if ( this.previewImage ) | ||
180 | { | ||
181 | this.previewImage.removeListener( 'load', onImgLoadEvent ); | ||
182 | this.previewImage.removeListener( 'error', onImgLoadErrorEvent ); | ||
183 | this.previewImage.removeListener( 'abort', onImgLoadErrorEvent ); | ||
184 | this.previewImage.remove(); | ||
185 | this.previewImage = null; // Dialog is closed. | ||
186 | } | ||
187 | }, | ||
188 | |||
189 | contents : | ||
190 | [ | ||
191 | { | ||
192 | id : 'info', | ||
193 | elements : | ||
194 | [ | ||
195 | { | ||
196 | type : 'hbox', | ||
197 | widths: [ '', '100px'], | ||
198 | children : [ | ||
199 | { | ||
200 | type : 'text', | ||
201 | id : 'poster', | ||
202 | label : lang.poster, | ||
203 | commit : commitValue, | ||
204 | setup : loadValue, | ||
205 | onChange : function() | ||
206 | { | ||
207 | var dialog = this.getDialog(), | ||
208 | newUrl = this.getValue(); | ||
209 | |||
210 | //Update preview image | ||
211 | if ( newUrl.length > 0 ) //Prevent from load before onShow | ||
212 | { | ||
213 | dialog = this.getDialog(); | ||
214 | var preview = dialog.previewImage; | ||
215 | |||
216 | preview.on( 'load', onImgLoadEvent, dialog ); | ||
217 | preview.on( 'error', onImgLoadErrorEvent, dialog ); | ||
218 | preview.on( 'abort', onImgLoadErrorEvent, dialog ); | ||
219 | preview.setAttribute( 'src', newUrl ); | ||
220 | } | ||
221 | } | ||
222 | }, | ||
223 | { | ||
224 | type : 'button', | ||
225 | id : 'browse', | ||
226 | hidden : 'true', | ||
227 | style : 'display:inline-block;margin-top:10px;', | ||
228 | filebrowser : | ||
229 | { | ||
230 | action : 'Browse', | ||
231 | target: 'info:poster', | ||
232 | url: editor.config.filebrowserImageBrowseUrl || editor.config.filebrowserBrowseUrl | ||
233 | }, | ||
234 | label : editor.lang.common.browseServer | ||
235 | }] | ||
236 | }, | ||
237 | { | ||
238 | type : 'hbox', | ||
239 | widths: [ '33%', '33%', '33%'], | ||
240 | children : [ | ||
241 | { | ||
242 | type : 'text', | ||
243 | id : 'width', | ||
244 | label : editor.lang.common.width, | ||
245 | 'default' : 400, | ||
246 | validate : CKEDITOR.dialog.validate.notEmpty( lang.widthRequired ), | ||
247 | commit : commitValue, | ||
248 | setup : loadValue | ||
249 | }, | ||
250 | { | ||
251 | type : 'text', | ||
252 | id : 'height', | ||
253 | label : editor.lang.common.height, | ||
254 | 'default' : 300, | ||
255 | validate : CKEDITOR.dialog.validate.notEmpty(lang.heightRequired ), | ||
256 | commit : commitValue, | ||
257 | setup : loadValue | ||
258 | }, | ||
259 | { | ||
260 | type : 'text', | ||
261 | id : 'id', | ||
262 | label : 'Id', | ||
263 | commit : commitValue, | ||
264 | setup : loadValue | ||
265 | } | ||
266 | ] | ||
267 | }, | ||
268 | { | ||
269 | type : 'hbox', | ||
270 | widths: [ '', '100px', '75px'], | ||
271 | children : [ | ||
272 | { | ||
273 | type : 'text', | ||
274 | id : 'src0', | ||
275 | label : lang.sourceaudio, | ||
276 | commit : commitSrc, | ||
277 | setup : loadSrc | ||
278 | }, | ||
279 | { | ||
280 | type : 'button', | ||
281 | id : 'browse', | ||
282 | hidden : 'true', | ||
283 | style : 'display:inline-block;margin-top:10px;', | ||
284 | filebrowser : | ||
285 | { | ||
286 | action : 'Browse', | ||
287 | target: 'info:src0', | ||
288 | url: editor.config.filebrowserAudioBrowseUrl || editor.config.filebrowserBrowseUrl | ||
289 | }, | ||
290 | label : editor.lang.common.browseServer | ||
291 | }, | ||
292 | { | ||
293 | id : 'type0', | ||
294 | label : lang.sourceType, | ||
295 | type : 'select', | ||
296 | 'default' : 'audio/mp3', | ||
297 | items : | ||
298 | [ | ||
299 | [ 'MP3', 'audio/mp3' ], | ||
300 | [ 'WAV', 'audio/wav' ] | ||
301 | ], | ||
302 | commit : commitSrc, | ||
303 | setup : loadSrc | ||
304 | }] | ||
305 | }, | ||
306 | |||
307 | { | ||
308 | type : 'hbox', | ||
309 | widths: [ '', '100px', '75px'], | ||
310 | children : [ | ||
311 | { | ||
312 | type : 'text', | ||
313 | id : 'src1', | ||
314 | label : lang.sourceaudio, | ||
315 | commit : commitSrc, | ||
316 | setup : loadSrc | ||
317 | }, | ||
318 | { | ||
319 | type : 'button', | ||
320 | id : 'browse', | ||
321 | hidden : 'true', | ||
322 | style : 'display:inline-block;margin-top:10px;', | ||
323 | filebrowser : | ||
324 | { | ||
325 | action : 'Browse', | ||
326 | target: 'info:src1', | ||
327 | url: editor.config.filebrowserAudioBrowseUrl || editor.config.filebrowserBrowseUrl | ||
328 | }, | ||
329 | label : editor.lang.common.browseServer | ||
330 | }, | ||
331 | { | ||
332 | id : 'type1', | ||
333 | label : lang.sourceType, | ||
334 | type : 'select', | ||
335 | 'default':'audio/wav', | ||
336 | items : | ||
337 | [ | ||
338 | [ 'MP3', 'audio/mp3' ], | ||
339 | [ 'WAV', 'audio/wav' ] | ||
340 | ], | ||
341 | commit : commitSrc, | ||
342 | setup : loadSrc | ||
343 | }] | ||
344 | } | ||
345 | ] | ||
346 | } | ||
347 | |||
348 | ] | ||
349 | }; | ||
350 | } ); | ||
diff --git a/sources/plugins/Audio/docs/install.html b/sources/plugins/Audio/docs/install.html deleted file mode 100644 index 3fbf30e..0000000 --- a/sources/plugins/Audio/docs/install.html +++ /dev/null | |||
@@ -1,69 +0,0 @@ | |||
1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" | ||
2 | "http://www.w3.org/TR/html4/loose.dtd"> | ||
3 | <html lang="en"> | ||
4 | <head> | ||
5 | <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> | ||
6 | <title>Audio plugin</title> | ||
7 | <link href="styles.css" rel="stylesheet" type="text/css"> | ||
8 | </head> | ||
9 | |||
10 | <body> | ||
11 | <h1>Audio Plugin for CKEditor</h1> | ||
12 | |||
13 | <h2>Introduction</h2> | ||
14 | <p>This is a plugin to create HTML5 <audio> elements in <a href="http://www.ckeditor.com">CKEditor</a>.</p> | ||
15 | <h3>Version history: </h3> | ||
16 | <ol> | ||
17 | <li>1.0: 10-July-2015. First version.</li> | ||
18 | </ol> | ||
19 | |||
20 | <h2>Installation</h2> | ||
21 | <h3>1. Copying the files</h3> | ||
22 | <p>Extract the contents of the zip in you plugins directory, so it ends up like | ||
23 | this<br> | ||
24 | <!--<img src="installation.png" alt="Screenshot of installation" width="311" height="346" longdesc="#install">--> | ||
25 | </p> | ||
26 | <pre id="--install"> | ||
27 | ckeditor\ | ||
28 | ... | ||
29 | images\ | ||
30 | lang\ | ||
31 | plugins\ | ||
32 | ... | ||
33 | audio\ | ||
34 | plugin.js | ||
35 | dialogs\ | ||
36 | audio.js | ||
37 | docs\ | ||
38 | install.html | ||
39 | images\ | ||
40 | icon.png | ||
41 | placeholder.png | ||
42 | ... | ||
43 | skins\ | ||
44 | themes\ | ||
45 | </pre> | ||
46 | <h3>2. Adding it to CKEditor</h3> | ||
47 | <p>Now add the plugin in your <em>config.js</em> or custom js configuration | ||
48 | file: | ||
49 | <code>config.extraPlugins='audio'; </code> | ||
50 | </p> | ||
51 | |||
52 | <h3>3. Add it to your toolbar</h3> | ||
53 | <p>In your toolbar configuration, add a new 'Audio' item in the place where you want the button to show up.</p> | ||
54 | |||
55 | <h3>4. Configure server browser for audio</h3> | ||
56 | <p>You can use the <code>config.filebrowserAudioBrowseUrl</code> entry to specify a url so the file browser shows just audio elements (as long as your configure properly your file browser).</p> | ||
57 | |||
58 | <h3>5. Use it</h3> | ||
59 | <p>Now empty the cache of your browser and reload the editor, the new button should show up and you can add <audio> elements into the content.</p> | ||
60 | |||
61 | <h2>Final notes</h2> | ||
62 | <p>Please, note that only newer browsers support the Audio element, in older ones a simple text linking to the source audios is provided, you might want to | ||
63 | use some javascript or css to customize the final behavior of these elements.</p> | ||
64 | |||
65 | |||
66 | <h2>Disclaimers</h2> | ||
67 | <p>CKEditor is © CKSource.com</p> | ||
68 | </body> | ||
69 | </html> | ||
diff --git a/sources/plugins/Audio/docs/styles.css b/sources/plugins/Audio/docs/styles.css deleted file mode 100644 index 5eba91e..0000000 --- a/sources/plugins/Audio/docs/styles.css +++ /dev/null | |||
@@ -1,67 +0,0 @@ | |||
1 | body { | ||
2 | font-family: Arial, Helvetica, sans-serif; | ||
3 | font-size: 90%; | ||
4 | } | ||
5 | h1 { | ||
6 | text-align:center; | ||
7 | font-size:180%; | ||
8 | } | ||
9 | h2 { | ||
10 | border-bottom:2px solid #CCC; | ||
11 | margin:1em 0 0.4em 0; | ||
12 | } | ||
13 | h3 { | ||
14 | margin-bottom:0.4em; | ||
15 | } | ||
16 | p { | ||
17 | margin:0 0 1em 1em; | ||
18 | text-align:justify; | ||
19 | } | ||
20 | ol { | ||
21 | margin:0 0 1.2em 1em; | ||
22 | padding:0; | ||
23 | list-style-type:none; | ||
24 | } | ||
25 | ol li { | ||
26 | margin:0.2em 0; | ||
27 | } | ||
28 | pre { | ||
29 | font-size:100%; | ||
30 | font-family:"Courier New", Courier, mono; | ||
31 | background-color: #CCCCCC; | ||
32 | border:1px solid #999; | ||
33 | padding:0.2em 1em; | ||
34 | margin: 0.4em 0; | ||
35 | display:block; | ||
36 | white-space: pre; | ||
37 | overflow: auto; | ||
38 | } | ||
39 | code { | ||
40 | font-size:100%; | ||
41 | font-family:"Courier New", Courier, mono; | ||
42 | background-color: #CCCCCC; | ||
43 | border:1px solid #999; | ||
44 | padding:0.2em; | ||
45 | white-space: pre; | ||
46 | } | ||
47 | form { | ||
48 | margin:0 0 0 1em; | ||
49 | } | ||
50 | span.key { | ||
51 | color: #006600; | ||
52 | } | ||
53 | #install { | ||
54 | display:none | ||
55 | } | ||
56 | #languages ul { | ||
57 | display:inline; | ||
58 | list-style-type:none; | ||
59 | margin:0; | ||
60 | padding:0; | ||
61 | } | ||
62 | #languages li { | ||
63 | display:inline; | ||
64 | margin:0; | ||
65 | padding:0; | ||
66 | vertical-align:bottom; | ||
67 | } | ||
diff --git a/sources/plugins/Audio/images/audio.png b/sources/plugins/Audio/images/audio.png deleted file mode 100644 index b4a4ef7..0000000 --- a/sources/plugins/Audio/images/audio.png +++ /dev/null | |||
Binary files differ | |||
diff --git a/sources/plugins/Audio/images/icon.png b/sources/plugins/Audio/images/icon.png deleted file mode 100644 index 1ec7ecc..0000000 --- a/sources/plugins/Audio/images/icon.png +++ /dev/null | |||
Binary files differ | |||
diff --git a/sources/plugins/Audio/images/placeholder.png b/sources/plugins/Audio/images/placeholder.png deleted file mode 100644 index 1456cac..0000000 --- a/sources/plugins/Audio/images/placeholder.png +++ /dev/null | |||
Binary files differ | |||
diff --git a/sources/plugins/Audio/plugin.js b/sources/plugins/Audio/plugin.js deleted file mode 100644 index ee618f6..0000000 --- a/sources/plugins/Audio/plugin.js +++ /dev/null | |||
@@ -1,211 +0,0 @@ | |||
1 | /* | ||
2 | * @file audio plugin for CKEditor | ||
3 | * Copyright (C) 2011 Alfonso Martínez de Lizarrondo | ||
4 | * | ||
5 | * == BEGIN LICENSE == | ||
6 | * | ||
7 | * Licensed under the terms of any of the following licenses at your | ||
8 | * choice: | ||
9 | * | ||
10 | * - GNU General Public License Version 2 or later (the "GPL") | ||
11 | * http://www.gnu.org/licenses/gpl.html | ||
12 | * | ||
13 | * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") | ||
14 | * http://www.gnu.org/licenses/lgpl.html | ||
15 | * | ||
16 | * - Mozilla Public License Version 1.1 or later (the "MPL") | ||
17 | * http://www.mozilla.org/MPL/MPL-1.1.html | ||
18 | * | ||
19 | * == END LICENSE == | ||
20 | * | ||
21 | */ | ||
22 | |||
23 | ( function() { | ||
24 | |||
25 | CKEDITOR.plugins.add( 'Audio', | ||
26 | { | ||
27 | // Translations, available at the end of this file, without extra requests | ||
28 | lang : [ 'en', 'es' ], | ||
29 | |||
30 | getPlaceholderCss : function() | ||
31 | { | ||
32 | return 'img.cke_audio' + | ||
33 | '{' + | ||
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;' + | ||
39 | 'width: 80px;' + | ||
40 | 'height: 80px;' + | ||
41 | '}'; | ||
42 | }, | ||
43 | |||
44 | onLoad : function() | ||
45 | { | ||
46 | // v4 | ||
47 | if (CKEDITOR.addCss) | ||
48 | CKEDITOR.addCss( this.getPlaceholderCss() ); | ||
49 | |||
50 | }, | ||
51 | |||
52 | init : function( editor ) | ||
53 | { | ||
54 | var lang = editor.lang.audio; | ||
55 | |||
56 | // Check for CKEditor 3.5 | ||
57 | if (typeof editor.element.data == 'undefined') | ||
58 | { | ||
59 | alert('The "audio" plugin requires CKEditor 3.5 or newer'); | ||
60 | return; | ||
61 | } | ||
62 | |||
63 | CKEDITOR.dialog.add( 'audio', this.path + 'dialogs/audio.js' ); | ||
64 | |||
65 | editor.addCommand( 'Audio', new CKEDITOR.dialogCommand( 'audio' ) ); | ||
66 | editor.ui.addButton( 'Audio', | ||
67 | { | ||
68 | label : lang.toolbar, | ||
69 | command : 'Audio', | ||
70 | icon : this.path + 'images/icon.png' | ||
71 | } ); | ||
72 | |||
73 | // v3 | ||
74 | if (editor.addCss) | ||
75 | editor.addCss( this.getPlaceholderCss() ); | ||
76 | |||
77 | |||
78 | // If the "menu" plugin is loaded, register the menu items. | ||
79 | if ( editor.addMenuItems ) | ||
80 | { | ||
81 | editor.addMenuItems( | ||
82 | { | ||
83 | audio : | ||
84 | { | ||
85 | label : lang.properties, | ||
86 | command : 'Audio', | ||
87 | group : 'flash' | ||
88 | } | ||
89 | }); | ||
90 | } | ||
91 | |||
92 | editor.on( 'doubleclick', function( evt ) | ||
93 | { | ||
94 | var element = evt.data.element; | ||
95 | |||
96 | if ( element.is( 'img' ) && element.data( 'cke-real-element-type' ) == 'audio' ) | ||
97 | evt.data.dialog = 'audio'; | ||
98 | }); | ||
99 | |||
100 | // If the "contextmenu" plugin is loaded, register the listeners. | ||
101 | if ( editor.contextMenu ) | ||
102 | { | ||
103 | editor.contextMenu.addListener( function( element, selection ) | ||
104 | { | ||
105 | if ( element && element.is( 'img' ) && !element.isReadOnly() | ||
106 | && element.data( 'cke-real-element-type' ) == 'audio' ) | ||
107 | return { audio : CKEDITOR.TRISTATE_OFF }; | ||
108 | }); | ||
109 | } | ||
110 | |||
111 | // Add special handling for these items | ||
112 | CKEDITOR.dtd.$empty['cke:source']=1; | ||
113 | CKEDITOR.dtd.$empty['source']=1; | ||
114 | |||
115 | editor.lang.fakeobjects.audio = lang.fakeObject; | ||
116 | |||
117 | |||
118 | }, //Init | ||
119 | |||
120 | afterInit: function( editor ) | ||
121 | { | ||
122 | var dataProcessor = editor.dataProcessor, | ||
123 | htmlFilter = dataProcessor && dataProcessor.htmlFilter, | ||
124 | dataFilter = dataProcessor && dataProcessor.dataFilter; | ||
125 | |||
126 | // dataFilter : conversion from html input to internal data | ||
127 | dataFilter.addRules( | ||
128 | { | ||
129 | |||
130 | elements : { | ||
131 | $ : function( realElement ) | ||
132 | { | ||
133 | if ( realElement.name == 'audio' ) | ||
134 | { | ||
135 | realElement.name = 'cke:audio'; | ||
136 | for( var i=0; i < realElement.children.length; i++) | ||
137 | { | ||
138 | if ( realElement.children[ i ].name == 'source' ) | ||
139 | realElement.children[ i ].name = 'cke:source' | ||
140 | } | ||
141 | |||
142 | var fakeElement = editor.createFakeParserElement( realElement, 'cke_audio', 'audio', false ), | ||
143 | fakeStyle = fakeElement.attributes.style || ''; | ||
144 | |||
145 | var width = realElement.attributes.width, | ||
146 | height = realElement.attributes.height, | ||
147 | poster = realElement.attributes.poster; | ||
148 | |||
149 | if ( typeof width != 'undefined' ) | ||
150 | fakeStyle = fakeElement.attributes.style = fakeStyle + 'width:' + CKEDITOR.tools.cssLength( width ) + ';'; | ||
151 | |||
152 | if ( typeof height != 'undefined' ) | ||
153 | fakeStyle = fakeElement.attributes.style = fakeStyle + 'height:' + CKEDITOR.tools.cssLength( height ) + ';'; | ||
154 | |||
155 | if ( poster ) | ||
156 | fakeStyle = fakeElement.attributes.style = fakeStyle + 'background-image:url(' + poster + ');'; | ||
157 | |||
158 | return fakeElement; | ||
159 | } | ||
160 | } | ||
161 | } | ||
162 | |||
163 | } | ||
164 | ); | ||
165 | |||
166 | } // afterInit | ||
167 | |||
168 | } ); // plugins.add | ||
169 | |||
170 | |||
171 | var en = { | ||
172 | toolbar : 'Audio', | ||
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%' | ||
183 | }; | ||
184 | |||
185 | var es = { | ||
186 | toolbar : 'Audio', | ||
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', | ||
194 | sourceType : 'Tipo', | ||
195 | linkTemplate : '<a href="%src%">%type%</a> ', | ||
196 | fallbackTemplate : 'Su navegador no soporta audio.<br>Por favor, descargue el fichero: %links%' | ||
197 | }; | ||
198 | |||
199 | // v3 | ||
200 | if (CKEDITOR.skins) | ||
201 | { | ||
202 | en = { audio : en} ; | ||
203 | es = { audio : es} ; | ||
204 | } | ||
205 | |||
206 | // Translations | ||
207 | CKEDITOR.plugins.setLang( 'audio', 'en', en ); | ||
208 | |||
209 | CKEDITOR.plugins.setLang( 'audio', 'es', es ); | ||
210 | |||
211 | })(); | ||