]> git.immae.eu Git - perso/Immae/Projets/packagist/ludivine-ckeditor-component.git/blobdiff - sources/plugins/colordialog/plugin.js
Add audio, color and fonts
[perso/Immae/Projets/packagist/ludivine-ckeditor-component.git] / sources / plugins / colordialog / plugin.js
diff --git a/sources/plugins/colordialog/plugin.js b/sources/plugins/colordialog/plugin.js
new file mode 100644 (file)
index 0000000..1ad7e2d
--- /dev/null
@@ -0,0 +1,71 @@
+/**\r
+ * @license Copyright (c) 2003-2017, CKSource - Frederico Knabben. All rights reserved.\r
+ * For licensing, see LICENSE.md or http://ckeditor.com/license\r
+ */\r
+\r
+CKEDITOR.plugins.colordialog = {\r
+       requires: 'dialog',\r
+       // jscs:disable maximumLineLength\r
+       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%\r
+       // jscs:enable maximumLineLength\r
+       init: function( editor ) {\r
+               var cmd = new CKEDITOR.dialogCommand( 'colordialog' );\r
+               cmd.editorFocus = false;\r
+\r
+               editor.addCommand( 'colordialog', cmd );\r
+\r
+               CKEDITOR.dialog.add( 'colordialog', this.path + 'dialogs/colordialog.js' );\r
+\r
+               /**\r
+                * Open up color dialog and to receive the selected color.\r
+                *\r
+                * @param {Function} callback The callback when color dialog is closed\r
+                * @param {String} callback.color The color value received if selected on the dialog.\r
+                * @param [scope] The scope in which the callback will be bound.\r
+                * @member CKEDITOR.editor\r
+                */\r
+               editor.getColorFromDialog = function( callback, scope ) {\r
+                       var onClose = function( evt ) {\r
+                               releaseHandlers( this );\r
+                               var color = evt.name == 'ok' ? this.getValueOf( 'picker', 'selectedColor' ) : null;\r
+                               callback.call( scope, color );\r
+                       };\r
+                       var releaseHandlers = function( dialog ) {\r
+                               dialog.removeListener( 'ok', onClose );\r
+                               dialog.removeListener( 'cancel', onClose );\r
+                       };\r
+                       var bindToDialog = function( dialog ) {\r
+                               dialog.on( 'ok', onClose );\r
+                               dialog.on( 'cancel', onClose );\r
+                       };\r
+\r
+                       editor.execCommand( 'colordialog' );\r
+\r
+                       if ( editor._.storedDialogs && editor._.storedDialogs.colordialog )\r
+                               bindToDialog( editor._.storedDialogs.colordialog );\r
+                       else {\r
+                               CKEDITOR.on( 'dialogDefinition', function( e ) {\r
+                                       if ( e.data.name != 'colordialog' )\r
+                                               return;\r
+\r
+                                       var definition = e.data.definition;\r
+\r
+                                       e.removeListener();\r
+                                       definition.onLoad = CKEDITOR.tools.override( definition.onLoad,\r
+                                               function( orginal ) {\r
+                                                       return function() {\r
+                                                               bindToDialog( this );\r
+                                                               definition.onLoad = orginal;\r
+                                                               if ( typeof orginal == 'function' )\r
+                                                                       orginal.call( this );\r
+                                                       };\r
+                                               } );\r
+                               } );\r
+                       }\r
+               };\r
+\r
+\r
+       }\r
+};\r
+\r
+CKEDITOR.plugins.add( 'colordialog', CKEDITOR.plugins.colordialog );\r