diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-01-25 17:45:33 +0100 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2016-01-25 18:00:33 +0100 |
commit | 7adcb81e4f83f98c468889aaa5a85558ba88c770 (patch) | |
tree | 0d6ede733777b29060b48df4afaa2c64bfbae276 /sources/plugins/colordialog/plugin.js | |
download | connexionswing-ckeditor-component-4.5.6.tar.gz connexionswing-ckeditor-component-4.5.6.tar.zst connexionswing-ckeditor-component-4.5.6.zip |
Initial commit4.5.6
Diffstat (limited to 'sources/plugins/colordialog/plugin.js')
-rw-r--r-- | sources/plugins/colordialog/plugin.js | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/sources/plugins/colordialog/plugin.js b/sources/plugins/colordialog/plugin.js new file mode 100644 index 00000000..57f59199 --- /dev/null +++ b/sources/plugins/colordialog/plugin.js | |||
@@ -0,0 +1,71 @@ | |||
1 | /** | ||
2 | * @license Copyright (c) 2003-2015, 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,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 ); | ||