From 9946db9daaa76448d0e43247472cdedd2a5ea22a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Isma=C3=ABl=20Bouya?= Date: Mon, 4 Dec 2017 18:46:08 +0100 Subject: Change audio plugin --- sources/build-config.js | 91 ------ sources/config.js | 2 +- sources/plugins/Audio/dialogs/audio.js | 350 ----------------------- sources/plugins/Audio/docs/install.html | 69 ----- sources/plugins/Audio/docs/styles.css | 67 ----- sources/plugins/Audio/images/audio.png | Bin 15258 -> 0 bytes sources/plugins/Audio/images/icon.png | Bin 1356 -> 0 bytes sources/plugins/Audio/images/placeholder.png | Bin 862 -> 0 bytes sources/plugins/Audio/plugin.js | 211 -------------- sources/plugins/html5audio/dialogs/html5audio.js | 135 +++++++++ sources/plugins/html5audio/icons/html5audio.png | Bin 0 -> 560 bytes sources/plugins/html5audio/lang/de.js | 14 + sources/plugins/html5audio/lang/el.js | 14 + sources/plugins/html5audio/lang/en.js | 14 + sources/plugins/html5audio/lang/es.js | 14 + sources/plugins/html5audio/lang/eu.js | 14 + sources/plugins/html5audio/lang/fr.js | 14 + sources/plugins/html5audio/lang/ru.js | 14 + sources/plugins/html5audio/lang/uk.js | 14 + sources/plugins/html5audio/lang/uz.js | 14 + sources/plugins/html5audio/lang/zh-cn.js | 14 + sources/plugins/html5audio/plugin.js | 122 ++++++++ 22 files changed, 398 insertions(+), 789 deletions(-) delete mode 100644 sources/build-config.js delete mode 100644 sources/plugins/Audio/dialogs/audio.js delete mode 100644 sources/plugins/Audio/docs/install.html delete mode 100644 sources/plugins/Audio/docs/styles.css delete mode 100644 sources/plugins/Audio/images/audio.png delete mode 100644 sources/plugins/Audio/images/icon.png delete mode 100644 sources/plugins/Audio/images/placeholder.png delete mode 100644 sources/plugins/Audio/plugin.js create mode 100644 sources/plugins/html5audio/dialogs/html5audio.js create mode 100644 sources/plugins/html5audio/icons/html5audio.png create mode 100644 sources/plugins/html5audio/lang/de.js create mode 100644 sources/plugins/html5audio/lang/el.js create mode 100644 sources/plugins/html5audio/lang/en.js create mode 100644 sources/plugins/html5audio/lang/es.js create mode 100644 sources/plugins/html5audio/lang/eu.js create mode 100644 sources/plugins/html5audio/lang/fr.js create mode 100644 sources/plugins/html5audio/lang/ru.js create mode 100644 sources/plugins/html5audio/lang/uk.js create mode 100644 sources/plugins/html5audio/lang/uz.js create mode 100644 sources/plugins/html5audio/lang/zh-cn.js create mode 100644 sources/plugins/html5audio/plugin.js (limited to 'sources') diff --git a/sources/build-config.js b/sources/build-config.js deleted file mode 100644 index 207d280..0000000 --- a/sources/build-config.js +++ /dev/null @@ -1,91 +0,0 @@ -/** - * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved. - * For licensing, see LICENSE.md or http://ckeditor.com/license - */ - -/** - * This file was added automatically by CKEditor builder. - * You may re-use it at any time to build CKEditor again. - * - * If you would like to build CKEditor online again - * (for example to upgrade), visit one the following links: - * - * (1) http://ckeditor.com/builder - * Visit online builder to build CKEditor from scratch. - * - * (2) http://ckeditor.com/builder/9323150a85589a6899021c19376669e6 - * Visit online builder to build CKEditor, starting with the same setup as before. - * - * (3) http://ckeditor.com/builder/download/9323150a85589a6899021c19376669e6 - * Straight download link to the latest version of CKEditor (Optimized) with the same setup as before. - * - * NOTE: - * This file is not used by CKEditor, you may remove it. - * Changing this file will not change your CKEditor configuration. - */ - -var CKBUILDER_CONFIG = { - skin: 'moono', - preset: 'full', - ignore: [ - '.DS_Store', - '.bender', - '.editorconfig', - '.gitattributes', - '.gitignore', - '.idea', - '.jscsrc', - '.jshintignore', - '.jshintrc', - '.mailmap', - '.travis.yml', - 'bender-err.log', - 'bender-out.log', - 'bender.ci.js', - 'bender.js', - 'dev', - 'gruntfile.js', - 'less', - 'node_modules', - 'package.json', - 'tests' - ], - plugins : { - 'Audio' : 1, - 'a11yhelp' : 1, - 'basicstyles' : 1, - 'contextmenu' : 1, - 'dialogadvtab' : 1, - 'elementspath' : 1, - 'enterkey' : 1, - 'entities' : 1, - 'filebrowser' : 1, - 'floatingspace' : 1, - 'format' : 1, - 'horizontalrule' : 1, - 'html5video' : 1, - 'htmlwriter' : 1, - 'iframe' : 1, - 'image' : 1, - 'indentblock' : 1, - 'indentlist' : 1, - 'justify' : 1, - 'link' : 1, - 'list' : 1, - 'liststyle' : 1, - 'magicline' : 1, - 'maximize' : 1, - 'oembed' : 1, - 'removeformat' : 1, - 'resize' : 1, - 'showborders' : 1, - 'sourcearea' : 1, - 'tab' : 1, - 'toolbar' : 1, - 'wysiwygarea' : 1 - }, - languages : { - 'en' : 1, - 'fr' : 1 - } -}; \ No newline at end of file diff --git a/sources/config.js b/sources/config.js index 049b0d9..69de42a 100644 --- a/sources/config.js +++ b/sources/config.js @@ -7,7 +7,7 @@ CKEDITOR.editorConfig = function( config ) { // %REMOVE_START% // The configuration options below are needed when running CKEditor from source files. - config.plugins = 'dialogui,dialog,a11yhelp,dialogadvtab,basicstyles,panel,floatpanel,menu,contextmenu,resize,button,toolbar,elementspath,enterkey,entities,popup,filebrowser,floatingspace,listblock,richcombo,format,horizontalrule,htmlwriter,fakeobjects,iframe,wysiwygarea,image,indent,indentblock,indentlist,justify,link,list,liststyle,magicline,maximize,removeformat,showborders,sourcearea,tab,lineutils,notification,clipboard,widgetselection,widget,oembed,Audio,html5video'; + config.plugins = 'dialogui,dialog,a11yhelp,dialogadvtab,basicstyles,panel,floatpanel,menu,contextmenu,resize,button,toolbar,elementspath,enterkey,entities,popup,filebrowser,floatingspace,listblock,richcombo,format,horizontalrule,htmlwriter,fakeobjects,iframe,wysiwygarea,image,indent,indentblock,indentlist,justify,link,list,liststyle,magicline,maximize,removeformat,showborders,sourcearea,tab,lineutils,notification,clipboard,widgetselection,widget,oembed,html5video,html5audio'; config.skin = 'moono'; // %REMOVE_END% 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 @@ -CKEDITOR.dialog.add( 'audio', function ( editor ) -{ - var lang = editor.lang.audio; - - function commitValue( audioNode, extraStyles ) - { - var value=this.getValue(); - - if ( !value && this.id=='id' ) - value = generateId(); - - audioNode.setAttribute( this.id, value); - - if ( !value ) - return; - switch( this.id ) - { - case 'poster': - extraStyles.backgroundImage = 'url(' + value + ')'; - break; - case 'width': - extraStyles.width = value + 'px'; - break; - case 'height': - extraStyles.height = value + 'px'; - break; - } - } - - function commitSrc( audioNode, extraStyles, audios ) - { - var match = this.id.match(/(\w+)(\d)/), - id = match[1], - number = parseInt(match[2], 10); - - var audio = audios[number] || (audios[number]={}); - audio[id] = this.getValue(); - } - - function loadValue( audioNode ) - { - if ( audioNode ) - this.setValue( audioNode.getAttribute( this.id ) ); - else - { - if ( this.id == 'id') - this.setValue( generateId() ); - } - } - - function loadSrc( audioNode, audios ) - { - var match = this.id.match(/(\w+)(\d)/), - id = match[1], - number = parseInt(match[2], 10); - - var audio = audios[number]; - if (!audio) - return; - this.setValue( audio[ id ] ); - } - - function generateId() - { - var now = new Date(); - return 'audio' + now.getFullYear() + now.getMonth() + now.getDate() + now.getHours() + now.getMinutes() + now.getSeconds(); - } - - // To automatically get the dimensions of the poster image - var onImgLoadEvent = function() - { - // Image is ready. - var preview = this.previewImage; - preview.removeListener( 'load', onImgLoadEvent ); - preview.removeListener( 'error', onImgLoadErrorEvent ); - preview.removeListener( 'abort', onImgLoadErrorEvent ); - - this.setValueOf( 'info', 'width', preview.$.width ); - this.setValueOf( 'info', 'height', preview.$.height ); - }; - - var onImgLoadErrorEvent = function() - { - // Error. Image is not loaded. - var preview = this.previewImage; - preview.removeListener( 'load', onImgLoadEvent ); - preview.removeListener( 'error', onImgLoadErrorEvent ); - preview.removeListener( 'abort', onImgLoadErrorEvent ); - }; - - return { - title : lang.dialogTitle, - minWidth : 400, - minHeight : 200, - - onShow : function() - { - // Clear previously saved elements. - this.fakeImage = this.audioNode = null; - // To get dimensions of poster image - this.previewImage = editor.document.createElement( 'img' ); - - var fakeImage = this.getSelectedElement(); - if ( fakeImage && fakeImage.data( 'cke-real-element-type' ) && fakeImage.data( 'cke-real-element-type' ) == 'audio' ) - { - this.fakeImage = fakeImage; - - var audioNode = editor.restoreRealElement( fakeImage ), - audios = [], - sourceList = audioNode.getElementsByTag( 'source', '' ); - if (sourceList.count()==0) - sourceList = audioNode.getElementsByTag( 'source', 'cke' ); - - for ( var i = 0, length = sourceList.count() ; i < length ; i++ ) - { - var item = sourceList.getItem( i ); - audios.push( {src : item.getAttribute( 'src' ), type: item.getAttribute( 'type' )} ); - } - - this.audioNode = audioNode; - - this.setupContent( audioNode, audios ); - } - else - this.setupContent( null, [] ); - }, - - onOk : function() - { - // If there's no selected element create one. Otherwise, reuse it - var audioNode = null; - if ( !this.fakeImage ) - { - audioNode = CKEDITOR.dom.element.createFromHtml( '', editor.document ); - audioNode.setAttributes( - { - controls : 'controls' - } ); - } - else - { - audioNode = this.audioNode; - } - - var extraStyles = {}, audios = []; - this.commitContent( audioNode, extraStyles, audios ); - - var innerHtml = '', links = '', - link = lang.linkTemplate || '', - fallbackTemplate = lang.fallbackTemplate || ''; - for(var i=0; i'; - links += link.replace('%src%', audio.src).replace('%type%', audio.type); - } - audioNode.setHtml( innerHtml + fallbackTemplate.replace( '%links%', links ) ); - - // Refresh the fake image. - var newFakeImage = editor.createFakeElement( audioNode, 'cke_audio', 'audio', false ); - newFakeImage.setStyles( extraStyles ); - if ( this.fakeImage ) - { - newFakeImage.replace( this.fakeImage ); - editor.getSelection().selectElement( newFakeImage ); - } - else - { - // Insert it in a div - var div = new CKEDITOR.dom.element( 'DIV', editor.document ); - editor.insertElement( div ); - div.append( newFakeImage ); - } - }, - onHide : function() - { - if ( this.previewImage ) - { - this.previewImage.removeListener( 'load', onImgLoadEvent ); - this.previewImage.removeListener( 'error', onImgLoadErrorEvent ); - this.previewImage.removeListener( 'abort', onImgLoadErrorEvent ); - this.previewImage.remove(); - this.previewImage = null; // Dialog is closed. - } - }, - - contents : - [ - { - id : 'info', - elements : - [ - { - type : 'hbox', - widths: [ '', '100px'], - children : [ - { - type : 'text', - id : 'poster', - label : lang.poster, - commit : commitValue, - setup : loadValue, - onChange : function() - { - var dialog = this.getDialog(), - newUrl = this.getValue(); - - //Update preview image - if ( newUrl.length > 0 ) //Prevent from load before onShow - { - dialog = this.getDialog(); - var preview = dialog.previewImage; - - preview.on( 'load', onImgLoadEvent, dialog ); - preview.on( 'error', onImgLoadErrorEvent, dialog ); - preview.on( 'abort', onImgLoadErrorEvent, dialog ); - preview.setAttribute( 'src', newUrl ); - } - } - }, - { - type : 'button', - id : 'browse', - hidden : 'true', - style : 'display:inline-block;margin-top:10px;', - filebrowser : - { - action : 'Browse', - target: 'info:poster', - url: editor.config.filebrowserImageBrowseUrl || editor.config.filebrowserBrowseUrl - }, - label : editor.lang.common.browseServer - }] - }, - { - type : 'hbox', - widths: [ '33%', '33%', '33%'], - children : [ - { - type : 'text', - id : 'width', - label : editor.lang.common.width, - 'default' : 400, - validate : CKEDITOR.dialog.validate.notEmpty( lang.widthRequired ), - commit : commitValue, - setup : loadValue - }, - { - type : 'text', - id : 'height', - label : editor.lang.common.height, - 'default' : 300, - validate : CKEDITOR.dialog.validate.notEmpty(lang.heightRequired ), - commit : commitValue, - setup : loadValue - }, - { - type : 'text', - id : 'id', - label : 'Id', - commit : commitValue, - setup : loadValue - } - ] - }, - { - type : 'hbox', - widths: [ '', '100px', '75px'], - children : [ - { - type : 'text', - id : 'src0', - label : lang.sourceaudio, - commit : commitSrc, - setup : loadSrc - }, - { - type : 'button', - id : 'browse', - hidden : 'true', - style : 'display:inline-block;margin-top:10px;', - filebrowser : - { - action : 'Browse', - target: 'info:src0', - url: editor.config.filebrowserAudioBrowseUrl || editor.config.filebrowserBrowseUrl - }, - label : editor.lang.common.browseServer - }, - { - id : 'type0', - label : lang.sourceType, - type : 'select', - 'default' : 'audio/mp3', - items : - [ - [ 'MP3', 'audio/mp3' ], - [ 'WAV', 'audio/wav' ] - ], - commit : commitSrc, - setup : loadSrc - }] - }, - - { - type : 'hbox', - widths: [ '', '100px', '75px'], - children : [ - { - type : 'text', - id : 'src1', - label : lang.sourceaudio, - commit : commitSrc, - setup : loadSrc - }, - { - type : 'button', - id : 'browse', - hidden : 'true', - style : 'display:inline-block;margin-top:10px;', - filebrowser : - { - action : 'Browse', - target: 'info:src1', - url: editor.config.filebrowserAudioBrowseUrl || editor.config.filebrowserBrowseUrl - }, - label : editor.lang.common.browseServer - }, - { - id : 'type1', - label : lang.sourceType, - type : 'select', - 'default':'audio/wav', - items : - [ - [ 'MP3', 'audio/mp3' ], - [ 'WAV', 'audio/wav' ] - ], - commit : commitSrc, - setup : loadSrc - }] - } - ] - } - - ] - }; -} ); 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 @@ - - - - -Audio plugin - - - - -

Audio Plugin for CKEditor

- -

Introduction

-

This is a plugin to create HTML5 <audio> elements in CKEditor.

-

Version history:

-
    -
  1. 1.0: 10-July-2015. First version.
  2. -
- -

Installation

-

1. Copying the files

-

Extract the contents of the zip in you plugins directory, so it ends up like - this
- -

-
-ckeditor\
-	...
-	images\
-	lang\
-	plugins\
-		...
-		audio\
-			plugin.js
-			dialogs\
-				audio.js
-			docs\
-				install.html
-			images\
-				icon.png
-				placeholder.png
-		...
-	skins\
-	themes\
-
-

2. Adding it to CKEditor

-

Now add the plugin in your config.js or custom js configuration -file: -config.extraPlugins='audio'; -

- -

3. Add it to your toolbar

-

In your toolbar configuration, add a new 'Audio' item in the place where you want the button to show up.

- -

4. Configure server browser for audio

-

You can use the config.filebrowserAudioBrowseUrl entry to specify a url so the file browser shows just audio elements (as long as your configure properly your file browser).

- -

5. Use it

-

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.

- -

Final notes

-

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 -use some javascript or css to customize the final behavior of these elements.

- - -

Disclaimers

-

CKEditor is © CKSource.com

- - 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 @@ -body { - font-family: Arial, Helvetica, sans-serif; - font-size: 90%; -} -h1 { - text-align:center; - font-size:180%; -} -h2 { - border-bottom:2px solid #CCC; - margin:1em 0 0.4em 0; -} -h3 { - margin-bottom:0.4em; -} -p { - margin:0 0 1em 1em; - text-align:justify; -} -ol { - margin:0 0 1.2em 1em; - padding:0; - list-style-type:none; -} -ol li { - margin:0.2em 0; -} -pre { - font-size:100%; - font-family:"Courier New", Courier, mono; - background-color: #CCCCCC; - border:1px solid #999; - padding:0.2em 1em; - margin: 0.4em 0; - display:block; - white-space: pre; - overflow: auto; -} -code { - font-size:100%; - font-family:"Courier New", Courier, mono; - background-color: #CCCCCC; - border:1px solid #999; - padding:0.2em; - white-space: pre; -} -form { - margin:0 0 0 1em; -} -span.key { - color: #006600; -} -#install { - display:none -} -#languages ul { - display:inline; - list-style-type:none; - margin:0; - padding:0; -} -#languages li { - display:inline; - margin:0; - padding:0; - vertical-align:bottom; -} diff --git a/sources/plugins/Audio/images/audio.png b/sources/plugins/Audio/images/audio.png deleted file mode 100644 index b4a4ef7..0000000 Binary files a/sources/plugins/Audio/images/audio.png and /dev/null differ diff --git a/sources/plugins/Audio/images/icon.png b/sources/plugins/Audio/images/icon.png deleted file mode 100644 index 1ec7ecc..0000000 Binary files a/sources/plugins/Audio/images/icon.png and /dev/null differ diff --git a/sources/plugins/Audio/images/placeholder.png b/sources/plugins/Audio/images/placeholder.png deleted file mode 100644 index 1456cac..0000000 Binary files a/sources/plugins/Audio/images/placeholder.png and /dev/null 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 @@ -/* - * @file audio plugin for CKEditor - * Copyright (C) 2011 Alfonso Martínez de Lizarrondo - * - * == BEGIN LICENSE == - * - * Licensed under the terms of any of the following licenses at your - * choice: - * - * - GNU General Public License Version 2 or later (the "GPL") - * http://www.gnu.org/licenses/gpl.html - * - * - GNU Lesser General Public License Version 2.1 or later (the "LGPL") - * http://www.gnu.org/licenses/lgpl.html - * - * - Mozilla Public License Version 1.1 or later (the "MPL") - * http://www.mozilla.org/MPL/MPL-1.1.html - * - * == END LICENSE == - * - */ - -( function() { - -CKEDITOR.plugins.add( 'Audio', -{ - // Translations, available at the end of this file, without extra requests - lang : [ 'en', 'es' ], - - getPlaceholderCss : function() - { - return 'img.cke_audio' + - '{' + - 'background-image: url(' + CKEDITOR.getUrl( this.path + 'images/placeholder.png' ) + ');' + - 'background-position: center center;' + - 'background-repeat: no-repeat;' + - 'background-color:gray;'+ - 'border: 1px solid #a9a9a9;' + - 'width: 80px;' + - 'height: 80px;' + - '}'; - }, - - onLoad : function() - { - // v4 - if (CKEDITOR.addCss) - CKEDITOR.addCss( this.getPlaceholderCss() ); - - }, - - init : function( editor ) - { - var lang = editor.lang.audio; - - // Check for CKEditor 3.5 - if (typeof editor.element.data == 'undefined') - { - alert('The "audio" plugin requires CKEditor 3.5 or newer'); - return; - } - - CKEDITOR.dialog.add( 'audio', this.path + 'dialogs/audio.js' ); - - editor.addCommand( 'Audio', new CKEDITOR.dialogCommand( 'audio' ) ); - editor.ui.addButton( 'Audio', - { - label : lang.toolbar, - command : 'Audio', - icon : this.path + 'images/icon.png' - } ); - - // v3 - if (editor.addCss) - editor.addCss( this.getPlaceholderCss() ); - - - // If the "menu" plugin is loaded, register the menu items. - if ( editor.addMenuItems ) - { - editor.addMenuItems( - { - audio : - { - label : lang.properties, - command : 'Audio', - group : 'flash' - } - }); - } - - editor.on( 'doubleclick', function( evt ) - { - var element = evt.data.element; - - if ( element.is( 'img' ) && element.data( 'cke-real-element-type' ) == 'audio' ) - evt.data.dialog = 'audio'; - }); - - // If the "contextmenu" plugin is loaded, register the listeners. - if ( editor.contextMenu ) - { - editor.contextMenu.addListener( function( element, selection ) - { - if ( element && element.is( 'img' ) && !element.isReadOnly() - && element.data( 'cke-real-element-type' ) == 'audio' ) - return { audio : CKEDITOR.TRISTATE_OFF }; - }); - } - - // Add special handling for these items - CKEDITOR.dtd.$empty['cke:source']=1; - CKEDITOR.dtd.$empty['source']=1; - - editor.lang.fakeobjects.audio = lang.fakeObject; - - - }, //Init - - afterInit: function( editor ) - { - var dataProcessor = editor.dataProcessor, - htmlFilter = dataProcessor && dataProcessor.htmlFilter, - dataFilter = dataProcessor && dataProcessor.dataFilter; - - // dataFilter : conversion from html input to internal data - dataFilter.addRules( - { - - elements : { - $ : function( realElement ) - { - if ( realElement.name == 'audio' ) - { - realElement.name = 'cke:audio'; - for( var i=0; i < realElement.children.length; i++) - { - if ( realElement.children[ i ].name == 'source' ) - realElement.children[ i ].name = 'cke:source' - } - - var fakeElement = editor.createFakeParserElement( realElement, 'cke_audio', 'audio', false ), - fakeStyle = fakeElement.attributes.style || ''; - - var width = realElement.attributes.width, - height = realElement.attributes.height, - poster = realElement.attributes.poster; - - if ( typeof width != 'undefined' ) - fakeStyle = fakeElement.attributes.style = fakeStyle + 'width:' + CKEDITOR.tools.cssLength( width ) + ';'; - - if ( typeof height != 'undefined' ) - fakeStyle = fakeElement.attributes.style = fakeStyle + 'height:' + CKEDITOR.tools.cssLength( height ) + ';'; - - if ( poster ) - fakeStyle = fakeElement.attributes.style = fakeStyle + 'background-image:url(' + poster + ');'; - - return fakeElement; - } - } - } - - } - ); - - } // afterInit - -} ); // plugins.add - - -var en = { - toolbar : 'Audio', - dialogTitle : 'Audio properties', - fakeObject : 'Audio', - properties : 'Edit audio', - widthRequired : 'Width field cannot be empty', - heightRequired : 'Height field cannot be empty', - poster: 'Poster image', - sourceaudio: 'Source audio', - sourceType : 'Audio type', - linkTemplate : '%type% ', - fallbackTemplate : 'Your browser doesn\'t support audio.
Please download the file: %links%' - }; - -var es = { - toolbar : 'Audio', - dialogTitle : 'Propiedades de audio', - fakeObject : 'Audio', - properties : 'Editar el audio', - widthRequired : 'La anchura no se puede dejar en blanco', - heightRequired : 'La altura no se puede dejar en blanco', - poster: 'Imagen de presentación', - sourceaudio: 'Archivo de audio', - sourceType : 'Tipo', - linkTemplate : '%type% ', - fallbackTemplate : 'Su navegador no soporta audio.
Por favor, descargue el fichero: %links%' - }; - - // v3 - if (CKEDITOR.skins) - { - en = { audio : en} ; - es = { audio : es} ; - } - -// Translations -CKEDITOR.plugins.setLang( 'audio', 'en', en ); - -CKEDITOR.plugins.setLang( 'audio', 'es', es ); - -})(); 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 @@ +CKEDITOR.dialog.add( 'html5audio', function( editor ) { + return { + title: editor.lang.html5audio.title, + minWidth: 500, + minHeight: 100, + contents: [ { + id: 'info', + label: editor.lang.html5audio.infoLabel, + elements: [ { + type: 'vbox', + padding: 0, + children: [ { + type: 'hbox', + widths: [ '365px', '110px' ], + align: 'right', + children: [ { + type: 'text', + id: 'url', + label: editor.lang.common.url, + required: true, + validate: CKEDITOR.dialog.validate.notEmpty( editor.lang.html5audio.urlMissing ), + setup: function( widget ) { + this.setValue( widget.data.src ); + }, + commit: function( widget ) { + widget.setData( 'src', this.getValue() ); + } + }, + { + type: 'button', + id: 'browse', + // v-align with the 'txtUrl' field. + // TODO: We need something better than a fixed size here. + style: 'display:inline-block;margin-top:14px;', + align: 'center', + label: editor.lang.common.browseServer, + hidden: true, + filebrowser: 'info:url' + } ] + } ] + }, + { + type: 'hbox', + id: 'alignment', + children: [ { + type: 'radio', + id: 'align', + label: editor.lang.common.align, + items: [ + [editor.lang.common.alignCenter, 'center'], + [editor.lang.common.alignLeft, 'left'], + [editor.lang.common.alignRight, 'right'], + [editor.lang.common.alignNone, 'none'] + ], + 'default': 'center', + setup: function( widget ) { + if ( widget.data.align ) { + this.setValue( widget.data.align ); + } + }, + commit: function( widget ) { + widget.setData( 'align', this.getValue() ); + } + } ] + } ] + }, + { + id: 'Upload', + hidden: true, + filebrowser: 'uploadButton', + label: editor.lang.html5audio.upload, + elements: [ { + type: 'file', + id: 'upload', + label: editor.lang.html5audio.btnUpload, + style: 'height:40px', + size: 38 + }, + { + type: 'fileButton', + id: 'uploadButton', + filebrowser: 'info:url', + label: editor.lang.html5audio.btnUpload, + 'for': [ 'Upload', 'upload' ] + } ] + }, + { + id: 'advanced', + label: editor.lang.html5audio.advanced, + elements: [ { + type: 'vbox', + padding: 0, + children: [ { + type: 'hbox', + children: [ { + type: 'radio', + id: 'autoplay', + label: editor.lang.html5audio.autoplay, + items: [ + [editor.lang.html5audio.yes, 'yes'], + [editor.lang.html5audio.no, 'no'] + ], + 'default': 'no', + setup: function( widget ) { + if ( widget.data.autoplay ) { + this.setValue( widget.data.autoplay ); + } + }, + commit: function( widget ) { + widget.setData( 'autoplay', this.getValue() ); + } + }, + { + type: 'radio', + id: 'allowdownload', + label: editor.lang.html5audio.allowdownload, + items: [ + [editor.lang.html5audio.yes, 'yes'], + [editor.lang.html5audio.no, 'no'] + ], + 'default': 'no', + setup: function( widget ) { + if ( widget.data.allowdownload ) { + this.setValue(widget.data.allowdownload); + } + }, + commit: function( widget ) { + widget.setData( 'allowdownload', this.getValue() ); + } + } ] + } ] + } ] + } ] + }; +} ); diff --git a/sources/plugins/html5audio/icons/html5audio.png b/sources/plugins/html5audio/icons/html5audio.png new file mode 100644 index 0000000..4367015 Binary files /dev/null and b/sources/plugins/html5audio/icons/html5audio.png 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 @@ +CKEDITOR.plugins.setLang( 'html5audio', 'de', { + button: 'HTML5 Audio einfügen', + title: 'HTML5 Audio', + infoLabel: 'Audio Infos', + urlMissing: 'Sie haben keine URL zur Audio-Datei angegeben.', + audioProperties: 'Audio-Einstellungen', + upload: 'Hochladen', + btnUpload: 'Zum Server senden', + advanced: 'Erweitert', + autoplay: 'Autoplay?', + allowdownload: 'Download zulassen?', + yes: 'Ja', + no: 'Nein' +} ); 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 @@ +CKEDITOR.plugins.setLang( 'html5audio', 'el', { + button: 'Προσθέστε HTML5 ήχο', + title: 'HTML5 ήχος', + infoLabel: 'Πληροφορίες ήχου', + urlMissing: 'Η πηγή URL ήχου απουσιάζει.', + audioProperties: 'Ιδιότητες ήχου', + upload: 'Upload', + btnUpload: 'Αποστολή στον διακομιστή', + advanced: 'Προχωρημένα', + autoplay: 'Αυτόματη αναπαραγωγή;', + allowdownload: 'Επιτρέψτε τη λήψη;', + yes: 'Ναι', + no: 'Όχι' +} ); 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 @@ +CKEDITOR.plugins.setLang( 'html5audio', 'en', { + button: 'Insert HTML5 audio', + title: 'HTML5 audio', + infoLabel: 'Audio info', + urlMissing: 'Audio source URL is missing.', + audioProperties: 'Audio properties', + upload: 'Upload', + btnUpload: 'Send it to the server', + advanced: 'Advanced', + autoplay: 'Autoplay?', + allowdownload: 'Allow download?', + yes: 'Yes', + no: 'No' +} ); 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 @@ +CKEDITOR.plugins.setLang( 'html5audio', 'es', { + button: 'Insertar audio HTML5', + title: 'Audio HTML5', + infoLabel: 'Información del audio', + urlMissing: 'La URL del audio no puede estar vacia.', + audioProperties: 'Propiedades del audio', + upload: 'Cargar', + btnUpload: 'Enviar al servidor', + advanced: 'Avanzado', + autoplay: '¿Reproducir automáticamente?', + allowdownload: '¿Permitir la descarga?', + yes: 'Si', + no: 'No' +} ); 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 @@ +CKEDITOR.plugins.setLang( 'html5audio', 'eu', { + button: 'Txertatu HTML5 audioa', + title: 'HTML5 audioa', + infoLabel: 'Audioaren informazioa', + urlMissing: 'Audioaren URLak ezin du hutsik egon.', + audioProperties: 'Audioaren propietateak', + upload: 'Kargatu', + btnUpload: 'Bidali zerbitzarira', + advanced: 'Aurreratua', + autoplay: 'Automatikoki erreproduzitu?', + allowdownload: 'Baimendu deskargatzea?', + yes: 'Bai', + no: 'Ez' +} ); 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 @@ +CKEDITOR.plugins.setLang( 'html5audio', 'fr', { + button: 'Insérer un lecteur audio HTML5', + title: 'HTML5 audio', + infoLabel: 'Informations audio', + urlMissing: 'URL de la source audio manquante. Veuillez la renseigner.', + audioProperties: 'Propriétés Audio', + upload: 'Télécharger', + btnUpload: 'Envoyer vers le serveur', + advanced: 'Avancé', + autoplay: 'Jouer automatiquement ?', + allowdownload: 'Autoriser le téléchargement?', + yes: 'Oui', + no: 'Non' +} ); 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 @@ +CKEDITOR.plugins.setLang( 'html5audio', 'ru', { + button: 'Вставить HTML5 аудио', + title: 'HTML5 аудио', + infoLabel: 'Аудио', + urlMissing: 'Не выбран источник аудио', + audioProperties: 'Свойства аудио', + upload: 'Загрузить', + btnUpload: 'Загрузить на сервер', + advanced: 'Дополнительно', + autoplay: 'Автовоспроизведение', + allowdownload: 'Разрешить загрузку', + yes: 'Да', + no: 'Нет' +} ); 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 @@ +CKEDITOR.plugins.setLang( 'html5audio', 'uk', { + button: 'Вставити HTML5 аудіо', + title: 'HTML5 аудіо', + infoLabel: 'Інформація', + urlMissing: 'Не обрано джерела аудіо', + audioProperties: 'Властивості аудіо', + upload: 'Відвантажити', + btnUpload: 'Відвантажити на сервер', + advanced: 'Додатково', + autoplay: 'Автовідтворення?', + allowdownload: 'Дозволити завантажити?', + yes: 'Так', + no: 'Ні' +} ); 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 @@ +CKEDITOR.plugins.setLang( 'html5audio', 'uz', { + button: 'HTML5 audio qo‘shing', + title: 'HTML5 audio', + infoLabel: 'Audio ma\'lumot', + urlMissing: 'Audio\'ning URL manbasi topilmadi.', + audioProperties: 'Audio xususiyatlari', + upload: 'Yuklash', + btnUpload: 'Serverga jo‘natish', + advanced: 'Kengaytrilgan', + autoplay: 'Avtoijro?', + allowdownload: 'Yuklab olish uchun ruxsat berilsinmi?', + yes: 'Ha', + no: 'Yo‘q' +} ); 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 @@ +CKEDITOR.plugins.setLang( 'html5audio', 'zh-cn', { + button: '插入HTML5音频', + title: 'HTML5 音频', + infoLabel: '音频信息', + urlMissing: '音频URL', + audioProperties: '音频属性', + upload: '上传', + btnUpload: '上传到服务器', + advanced: '高级', + autoplay: '自动播放?', + allowdownload: '允许下载?', + yes: '是', + no: '否' +} ); 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 @@ +CKEDITOR.plugins.add( 'html5audio', { + requires: 'widget', + lang: 'de,el,en,eu,es,fr,ru,uk,uz,zh-cn', + icons: 'html5audio', + init: function( editor ) { + editor.widgets.add( 'html5audio', { + button: editor.lang.html5audio.button, + template: '
', // We add the audio element when needed in the data function, to avoid having an undefined src attribute. + // See issue #9 on github: https://github.com/iametza/ckeditor-html5-audio/issues/9 + editables: {}, + /* + * Allowed content rules (http://docs.ckeditor.com/#!/guide/dev_allowed_content_rules): + * - div-s with text-align,float,margin-left,margin-right inline style rules and required ckeditor-html5-audio class. + * - audio tags with src and controls attributes. + */ + allowedContent: 'div(!ckeditor-html5-audio){text-align,float,margin-left,margin-right}; audio[src,controls,controlslist,autoplay];', + requiredContent: 'div(ckeditor-html5-audio); audio[src,controls];', + upcast: function( element ) { + return element.name === 'div' && element.hasClass( 'ckeditor-html5-audio' ); + }, + dialog: 'html5audio', + init: function() { + var src = ''; + var autoplay = ''; + var align = this.element.getStyle( 'text-align' ); + + // If there's a child (the audio element) + if ( this.element.getChild( 0 ) ) { + // get it's attributes. + src = this.element.getChild( 0 ).getAttribute( 'src' ); + autoplay = this.element.getChild( 0 ).getAttribute( 'autoplay' ); + allowdownload = !this.element.getChild( 0 ).getAttribute( 'controlslist' ); + } + + if ( src ) { + this.setData( 'src', src ); + + if ( align ) { + this.setData( 'align', align ); + } else { + this.setData( 'align', 'none' ); + } + + if ( autoplay ) { + this.setData( 'autoplay', 'yes' ); + } + + if ( allowdownload ) { + this.setData( 'allowdownload', 'yes' ); + } + } + }, + data: function() { + // If there is an audio source + if ( this.data.src ) { + // and there isn't a child (the audio element) + if ( !this.element.getChild( 0 ) ) { + // Create a new