aboutsummaryrefslogtreecommitdiff
path: root/sources/plugins/html5audio
diff options
context:
space:
mode:
Diffstat (limited to 'sources/plugins/html5audio')
-rw-r--r--sources/plugins/html5audio/dialogs/html5audio.js135
-rw-r--r--sources/plugins/html5audio/icons/html5audio.pngbin0 -> 560 bytes
-rw-r--r--sources/plugins/html5audio/lang/de.js14
-rw-r--r--sources/plugins/html5audio/lang/el.js14
-rw-r--r--sources/plugins/html5audio/lang/en.js14
-rw-r--r--sources/plugins/html5audio/lang/es.js14
-rw-r--r--sources/plugins/html5audio/lang/eu.js14
-rw-r--r--sources/plugins/html5audio/lang/fr.js14
-rw-r--r--sources/plugins/html5audio/lang/ru.js14
-rw-r--r--sources/plugins/html5audio/lang/uk.js14
-rw-r--r--sources/plugins/html5audio/lang/uz.js14
-rw-r--r--sources/plugins/html5audio/lang/zh-cn.js14
-rw-r--r--sources/plugins/html5audio/plugin.js122
13 files changed, 397 insertions, 0 deletions
diff --git a/sources/plugins/html5audio/dialogs/html5audio.js b/sources/plugins/html5audio/dialogs/html5audio.js
new file mode 100644
index 0000000..47de947
--- /dev/null
+++ b/sources/plugins/html5audio/dialogs/html5audio.js
@@ -0,0 +1,135 @@
1CKEDITOR.dialog.add( 'html5audio', function( editor ) {
2 return {
3 title: editor.lang.html5audio.title,
4 minWidth: 500,
5 minHeight: 100,
6 contents: [ {
7 id: 'info',
8 label: editor.lang.html5audio.infoLabel,
9 elements: [ {
10 type: 'vbox',
11 padding: 0,
12 children: [ {
13 type: 'hbox',
14 widths: [ '365px', '110px' ],
15 align: 'right',
16 children: [ {
17 type: 'text',
18 id: 'url',
19 label: editor.lang.common.url,
20 required: true,
21 validate: CKEDITOR.dialog.validate.notEmpty( editor.lang.html5audio.urlMissing ),
22 setup: function( widget ) {
23 this.setValue( widget.data.src );
24 },
25 commit: function( widget ) {
26 widget.setData( 'src', this.getValue() );
27 }
28 },
29 {
30 type: 'button',
31 id: 'browse',
32 // v-align with the 'txtUrl' field.
33 // TODO: We need something better than a fixed size here.
34 style: 'display:inline-block;margin-top:14px;',
35 align: 'center',
36 label: editor.lang.common.browseServer,
37 hidden: true,
38 filebrowser: 'info:url'
39 } ]
40 } ]
41 },
42 {
43 type: 'hbox',
44 id: 'alignment',
45 children: [ {
46 type: 'radio',
47 id: 'align',
48 label: editor.lang.common.align,
49 items: [
50 [editor.lang.common.alignCenter, 'center'],
51 [editor.lang.common.alignLeft, 'left'],
52 [editor.lang.common.alignRight, 'right'],
53 [editor.lang.common.alignNone, 'none']
54 ],
55 'default': 'center',
56 setup: function( widget ) {
57 if ( widget.data.align ) {
58 this.setValue( widget.data.align );
59 }
60 },
61 commit: function( widget ) {
62 widget.setData( 'align', this.getValue() );
63 }
64 } ]
65 } ]
66 },
67 {
68 id: 'Upload',
69 hidden: true,
70 filebrowser: 'uploadButton',
71 label: editor.lang.html5audio.upload,
72 elements: [ {
73 type: 'file',
74 id: 'upload',
75 label: editor.lang.html5audio.btnUpload,
76 style: 'height:40px',
77 size: 38
78 },
79 {
80 type: 'fileButton',
81 id: 'uploadButton',
82 filebrowser: 'info:url',
83 label: editor.lang.html5audio.btnUpload,
84 'for': [ 'Upload', 'upload' ]
85 } ]
86 },
87 {
88 id: 'advanced',
89 label: editor.lang.html5audio.advanced,
90 elements: [ {
91 type: 'vbox',
92 padding: 0,
93 children: [ {
94 type: 'hbox',
95 children: [ {
96 type: 'radio',
97 id: 'autoplay',
98 label: editor.lang.html5audio.autoplay,
99 items: [
100 [editor.lang.html5audio.yes, 'yes'],
101 [editor.lang.html5audio.no, 'no']
102 ],
103 'default': 'no',
104 setup: function( widget ) {
105 if ( widget.data.autoplay ) {
106 this.setValue( widget.data.autoplay );
107 }
108 },
109 commit: function( widget ) {
110 widget.setData( 'autoplay', this.getValue() );
111 }
112 },
113 {
114 type: 'radio',
115 id: 'allowdownload',
116 label: editor.lang.html5audio.allowdownload,
117 items: [
118 [editor.lang.html5audio.yes, 'yes'],
119 [editor.lang.html5audio.no, 'no']
120 ],
121 'default': 'no',
122 setup: function( widget ) {
123 if ( widget.data.allowdownload ) {
124 this.setValue(widget.data.allowdownload);
125 }
126 },
127 commit: function( widget ) {
128 widget.setData( 'allowdownload', this.getValue() );
129 }
130 } ]
131 } ]
132 } ]
133 } ]
134 };
135} );
diff --git a/sources/plugins/html5audio/icons/html5audio.png b/sources/plugins/html5audio/icons/html5audio.png
new file mode 100644
index 0000000..4367015
--- /dev/null
+++ b/sources/plugins/html5audio/icons/html5audio.png
Binary files differ
diff --git a/sources/plugins/html5audio/lang/de.js b/sources/plugins/html5audio/lang/de.js
new file mode 100644
index 0000000..e779745
--- /dev/null
+++ b/sources/plugins/html5audio/lang/de.js
@@ -0,0 +1,14 @@
1CKEDITOR.plugins.setLang( 'html5audio', 'de', {
2 button: 'HTML5 Audio einfügen',
3 title: 'HTML5 Audio',
4 infoLabel: 'Audio Infos',
5 urlMissing: 'Sie haben keine URL zur Audio-Datei angegeben.',
6 audioProperties: 'Audio-Einstellungen',
7 upload: 'Hochladen',
8 btnUpload: 'Zum Server senden',
9 advanced: 'Erweitert',
10 autoplay: 'Autoplay?',
11 allowdownload: 'Download zulassen?',
12 yes: 'Ja',
13 no: 'Nein'
14} );
diff --git a/sources/plugins/html5audio/lang/el.js b/sources/plugins/html5audio/lang/el.js
new file mode 100644
index 0000000..a7d2f84
--- /dev/null
+++ b/sources/plugins/html5audio/lang/el.js
@@ -0,0 +1,14 @@
1CKEDITOR.plugins.setLang( 'html5audio', 'el', {
2 button: 'Προσθέστε HTML5 ήχο',
3 title: 'HTML5 ήχος',
4 infoLabel: 'Πληροφορίες ήχου',
5 urlMissing: 'Η πηγή URL ήχου απουσιάζει.',
6 audioProperties: 'Ιδιότητες ήχου',
7 upload: 'Upload',
8 btnUpload: 'Αποστολή στον διακομιστή',
9 advanced: 'Προχωρημένα',
10 autoplay: 'Αυτόματη αναπαραγωγή;',
11 allowdownload: 'Επιτρέψτε τη λήψη;',
12 yes: 'Ναι',
13 no: 'Όχι'
14} );
diff --git a/sources/plugins/html5audio/lang/en.js b/sources/plugins/html5audio/lang/en.js
new file mode 100644
index 0000000..63e8c40
--- /dev/null
+++ b/sources/plugins/html5audio/lang/en.js
@@ -0,0 +1,14 @@
1CKEDITOR.plugins.setLang( 'html5audio', 'en', {
2 button: 'Insert HTML5 audio',
3 title: 'HTML5 audio',
4 infoLabel: 'Audio info',
5 urlMissing: 'Audio source URL is missing.',
6 audioProperties: 'Audio properties',
7 upload: 'Upload',
8 btnUpload: 'Send it to the server',
9 advanced: 'Advanced',
10 autoplay: 'Autoplay?',
11 allowdownload: 'Allow download?',
12 yes: 'Yes',
13 no: 'No'
14} );
diff --git a/sources/plugins/html5audio/lang/es.js b/sources/plugins/html5audio/lang/es.js
new file mode 100644
index 0000000..a9dd960
--- /dev/null
+++ b/sources/plugins/html5audio/lang/es.js
@@ -0,0 +1,14 @@
1CKEDITOR.plugins.setLang( 'html5audio', 'es', {
2 button: 'Insertar audio HTML5',
3 title: 'Audio HTML5',
4 infoLabel: 'Información del audio',
5 urlMissing: 'La URL del audio no puede estar vacia.',
6 audioProperties: 'Propiedades del audio',
7 upload: 'Cargar',
8 btnUpload: 'Enviar al servidor',
9 advanced: 'Avanzado',
10 autoplay: '¿Reproducir automáticamente?',
11 allowdownload: '¿Permitir la descarga?',
12 yes: 'Si',
13 no: 'No'
14} );
diff --git a/sources/plugins/html5audio/lang/eu.js b/sources/plugins/html5audio/lang/eu.js
new file mode 100644
index 0000000..5a7d103
--- /dev/null
+++ b/sources/plugins/html5audio/lang/eu.js
@@ -0,0 +1,14 @@
1CKEDITOR.plugins.setLang( 'html5audio', 'eu', {
2 button: 'Txertatu HTML5 audioa',
3 title: 'HTML5 audioa',
4 infoLabel: 'Audioaren informazioa',
5 urlMissing: 'Audioaren URLak ezin du hutsik egon.',
6 audioProperties: 'Audioaren propietateak',
7 upload: 'Kargatu',
8 btnUpload: 'Bidali zerbitzarira',
9 advanced: 'Aurreratua',
10 autoplay: 'Automatikoki erreproduzitu?',
11 allowdownload: 'Baimendu deskargatzea?',
12 yes: 'Bai',
13 no: 'Ez'
14} );
diff --git a/sources/plugins/html5audio/lang/fr.js b/sources/plugins/html5audio/lang/fr.js
new file mode 100644
index 0000000..51103f2
--- /dev/null
+++ b/sources/plugins/html5audio/lang/fr.js
@@ -0,0 +1,14 @@
1CKEDITOR.plugins.setLang( 'html5audio', 'fr', {
2 button: 'Insérer un lecteur audio HTML5',
3 title: 'HTML5 audio',
4 infoLabel: 'Informations audio',
5 urlMissing: 'URL de la source audio manquante. Veuillez la renseigner.',
6 audioProperties: 'Propriétés Audio',
7 upload: 'Télécharger',
8 btnUpload: 'Envoyer vers le serveur',
9 advanced: 'Avancé',
10 autoplay: 'Jouer automatiquement ?',
11 allowdownload: 'Autoriser le téléchargement?',
12 yes: 'Oui',
13 no: 'Non'
14} );
diff --git a/sources/plugins/html5audio/lang/ru.js b/sources/plugins/html5audio/lang/ru.js
new file mode 100644
index 0000000..7060753
--- /dev/null
+++ b/sources/plugins/html5audio/lang/ru.js
@@ -0,0 +1,14 @@
1CKEDITOR.plugins.setLang( 'html5audio', 'ru', {
2 button: 'Вставить HTML5 аудио',
3 title: 'HTML5 аудио',
4 infoLabel: 'Аудио',
5 urlMissing: 'Не выбран источник аудио',
6 audioProperties: 'Свойства аудио',
7 upload: 'Загрузить',
8 btnUpload: 'Загрузить на сервер',
9 advanced: 'Дополнительно',
10 autoplay: 'Автовоспроизведение',
11 allowdownload: 'Разрешить загрузку',
12 yes: 'Да',
13 no: 'Нет'
14} );
diff --git a/sources/plugins/html5audio/lang/uk.js b/sources/plugins/html5audio/lang/uk.js
new file mode 100644
index 0000000..3d10fd0
--- /dev/null
+++ b/sources/plugins/html5audio/lang/uk.js
@@ -0,0 +1,14 @@
1CKEDITOR.plugins.setLang( 'html5audio', 'uk', {
2 button: 'Вставити HTML5 аудіо',
3 title: 'HTML5 аудіо',
4 infoLabel: 'Інформація',
5 urlMissing: 'Не обрано джерела аудіо',
6 audioProperties: 'Властивості аудіо',
7 upload: 'Відвантажити',
8 btnUpload: 'Відвантажити на сервер',
9 advanced: 'Додатково',
10 autoplay: 'Автовідтворення?',
11 allowdownload: 'Дозволити завантажити?',
12 yes: 'Так',
13 no: 'Ні'
14} );
diff --git a/sources/plugins/html5audio/lang/uz.js b/sources/plugins/html5audio/lang/uz.js
new file mode 100644
index 0000000..c21b2c6
--- /dev/null
+++ b/sources/plugins/html5audio/lang/uz.js
@@ -0,0 +1,14 @@
1CKEDITOR.plugins.setLang( 'html5audio', 'uz', {
2 button: 'HTML5 audio qo‘shing',
3 title: 'HTML5 audio',
4 infoLabel: 'Audio ma\'lumot',
5 urlMissing: 'Audio\'ning URL manbasi topilmadi.',
6 audioProperties: 'Audio xususiyatlari',
7 upload: 'Yuklash',
8 btnUpload: 'Serverga jo‘natish',
9 advanced: 'Kengaytrilgan',
10 autoplay: 'Avtoijro?',
11 allowdownload: 'Yuklab olish uchun ruxsat berilsinmi?',
12 yes: 'Ha',
13 no: 'Yo‘q'
14} );
diff --git a/sources/plugins/html5audio/lang/zh-cn.js b/sources/plugins/html5audio/lang/zh-cn.js
new file mode 100644
index 0000000..018ffb0
--- /dev/null
+++ b/sources/plugins/html5audio/lang/zh-cn.js
@@ -0,0 +1,14 @@
1CKEDITOR.plugins.setLang( 'html5audio', 'zh-cn', {
2 button: '插入HTML5音频',
3 title: 'HTML5 音频',
4 infoLabel: '音频信息',
5 urlMissing: '音频URL',
6 audioProperties: '音频属性',
7 upload: '上传',
8 btnUpload: '上传到服务器',
9 advanced: '高级',
10 autoplay: '自动播放?',
11 allowdownload: '允许下载?',
12 yes: '是',
13 no: '否'
14} );
diff --git a/sources/plugins/html5audio/plugin.js b/sources/plugins/html5audio/plugin.js
new file mode 100644
index 0000000..7d0d886
--- /dev/null
+++ b/sources/plugins/html5audio/plugin.js
@@ -0,0 +1,122 @@
1CKEDITOR.plugins.add( 'html5audio', {
2 requires: 'widget',
3 lang: 'de,el,en,eu,es,fr,ru,uk,uz,zh-cn',
4 icons: 'html5audio',
5 init: function( editor ) {
6 editor.widgets.add( 'html5audio', {
7 button: editor.lang.html5audio.button,
8 template: '<div class="ckeditor-html5-audio"></div>', // We add the audio element when needed in the data function, to avoid having an undefined src attribute.
9 // See issue #9 on github: https://github.com/iametza/ckeditor-html5-audio/issues/9
10 editables: {},
11 /*
12 * Allowed content rules (http://docs.ckeditor.com/#!/guide/dev_allowed_content_rules):
13 * - div-s with text-align,float,margin-left,margin-right inline style rules and required ckeditor-html5-audio class.
14 * - audio tags with src and controls attributes.
15 */
16 allowedContent: 'div(!ckeditor-html5-audio){text-align,float,margin-left,margin-right}; audio[src,controls,controlslist,autoplay];',
17 requiredContent: 'div(ckeditor-html5-audio); audio[src,controls];',
18 upcast: function( element ) {
19 return element.name === 'div' && element.hasClass( 'ckeditor-html5-audio' );
20 },
21 dialog: 'html5audio',
22 init: function() {
23 var src = '';
24 var autoplay = '';
25 var align = this.element.getStyle( 'text-align' );
26
27 // If there's a child (the audio element)
28 if ( this.element.getChild( 0 ) ) {
29 // get it's attributes.
30 src = this.element.getChild( 0 ).getAttribute( 'src' );
31 autoplay = this.element.getChild( 0 ).getAttribute( 'autoplay' );
32 allowdownload = !this.element.getChild( 0 ).getAttribute( 'controlslist' );
33 }
34
35 if ( src ) {
36 this.setData( 'src', src );
37
38 if ( align ) {
39 this.setData( 'align', align );
40 } else {
41 this.setData( 'align', 'none' );
42 }
43
44 if ( autoplay ) {
45 this.setData( 'autoplay', 'yes' );
46 }
47
48 if ( allowdownload ) {
49 this.setData( 'allowdownload', 'yes' );
50 }
51 }
52 },
53 data: function() {
54 // If there is an audio source
55 if ( this.data.src ) {
56 // and there isn't a child (the audio element)
57 if ( !this.element.getChild( 0 ) ) {
58 // Create a new <audio> element.
59 var audioElement = new CKEDITOR.dom.element( 'audio' );
60 // Set the controls attribute.
61 audioElement.setAttribute( 'controls', 'controls' );
62 // Append it to the container of the plugin.
63 this.element.append( audioElement );
64 }
65 this.element.getChild( 0 ).setAttribute( 'src', this.data.src );
66 }
67
68 this.element.removeStyle( 'float' );
69 this.element.removeStyle( 'margin-left' );
70 this.element.removeStyle( 'margin-right' );
71
72 if ( this.data.align === 'none' ) {
73 this.element.removeStyle( 'text-align' );
74 } else {
75 this.element.setStyle( 'text-align', this.data.align );
76 }
77
78 if ( this.data.align === 'left' ) {
79 this.element.setStyle( 'float', this.data.align );
80 this.element.setStyle( 'margin-right', '10px' );
81 } else if ( this.data.align === 'right' ) {
82 this.element.setStyle( 'float', this.data.align );
83 this.element.setStyle( 'margin-left', '10px' );
84 }
85
86 if ( this.element.getChild( 0 ) ) {
87 if ( this.data.autoplay === 'yes' ) {
88 this.element.getChild( 0 ).setAttribute( 'autoplay', 'autoplay' );
89 } else {
90 this.element.getChild( 0 ).removeAttribute( 'autoplay' );
91 }
92 if ( this.data.allowdownload === 'yes' ) {
93 this.element.getChild( 0 ).removeAttribute( 'controlslist' );
94 } else {
95 this.element.getChild( 0 ).setAttribute( 'controlslist', 'nodownload' );
96 }
97 }
98 }
99 } );
100
101 if ( editor.contextMenu ) {
102 editor.addMenuGroup( 'html5audioGroup' );
103 editor.addMenuItem( 'html5audioPropertiesItem', {
104 label: editor.lang.html5audio.audioProperties,
105 icon: 'html5audio',
106 command: 'html5audio',
107 group: 'html5audioGroup'
108 });
109
110 editor.contextMenu.addListener( function( element ) {
111 if ( element &&
112 element.getChild( 0 ) &&
113 element.getChild( 0 ).hasClass &&
114 element.getChild( 0 ).hasClass( 'ckeditor-html5-audio' ) ) {
115 return { html5audioPropertiesItem: CKEDITOR.TRISTATE_OFF };
116 }
117 });
118 }
119
120 CKEDITOR.dialog.add( 'html5audio', this.path + 'dialogs/html5audio.js' );
121 }
122} );