]> git.immae.eu Git - perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git/blob - sources/plugins/colordialog/plugin.js
Upgrade to 4.5.7 and add some plugin
[perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git] / sources / plugins / colordialog / plugin.js
1 /**
2 * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved.
3 * For licensing, see LICENSE.md or http://ckeditor.com/license
4 */
5
6 CKEDITOR.plugins.colordialog = {
7 requires: 'dialog',
8 // jscs:disable maximumLineLength
9 lang: 'af,ar,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,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%
10 // jscs:enable maximumLineLength
11 init: function( editor ) {
12 var cmd = new CKEDITOR.dialogCommand( 'colordialog' );
13 cmd.editorFocus = false;
14
15 editor.addCommand( 'colordialog', cmd );
16
17 CKEDITOR.dialog.add( 'colordialog', this.path + 'dialogs/colordialog.js' );
18
19 /**
20 * Open up color dialog and to receive the selected color.
21 *
22 * @param {Function} callback The callback when color dialog is closed
23 * @param {String} callback.color The color value received if selected on the dialog.
24 * @param [scope] The scope in which the callback will be bound.
25 * @member CKEDITOR.editor
26 */
27 editor.getColorFromDialog = function( callback, scope ) {
28 var onClose = function( evt ) {
29 releaseHandlers( this );
30 var color = evt.name == 'ok' ? this.getValueOf( 'picker', 'selectedColor' ) : null;
31 callback.call( scope, color );
32 };
33 var releaseHandlers = function( dialog ) {
34 dialog.removeListener( 'ok', onClose );
35 dialog.removeListener( 'cancel', onClose );
36 };
37 var bindToDialog = function( dialog ) {
38 dialog.on( 'ok', onClose );
39 dialog.on( 'cancel', onClose );
40 };
41
42 editor.execCommand( 'colordialog' );
43
44 if ( editor._.storedDialogs && editor._.storedDialogs.colordialog )
45 bindToDialog( editor._.storedDialogs.colordialog );
46 else {
47 CKEDITOR.on( 'dialogDefinition', function( e ) {
48 if ( e.data.name != 'colordialog' )
49 return;
50
51 var definition = e.data.definition;
52
53 e.removeListener();
54 definition.onLoad = CKEDITOR.tools.override( definition.onLoad,
55 function( orginal ) {
56 return function() {
57 bindToDialog( this );
58 definition.onLoad = orginal;
59 if ( typeof orginal == 'function' )
60 orginal.call( this );
61 };
62 } );
63 } );
64 }
65 };
66
67
68 }
69 };
70
71 CKEDITOR.plugins.add( 'colordialog', CKEDITOR.plugins.colordialog );