diff options
Diffstat (limited to 'sources/plugins/save/plugin.js')
-rw-r--r-- | sources/plugins/save/plugin.js | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/sources/plugins/save/plugin.js b/sources/plugins/save/plugin.js new file mode 100644 index 00000000..54ac3acd --- /dev/null +++ b/sources/plugins/save/plugin.js | |||
@@ -0,0 +1,67 @@ | |||
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 | /** | ||
7 | * @fileOverview The Save plugin. | ||
8 | */ | ||
9 | |||
10 | ( function() { | ||
11 | var saveCmd = { | ||
12 | readOnly: 1, | ||
13 | |||
14 | exec: function( editor ) { | ||
15 | if ( editor.fire( 'save' ) ) { | ||
16 | var $form = editor.element.$.form; | ||
17 | |||
18 | if ( $form ) { | ||
19 | try { | ||
20 | $form.submit(); | ||
21 | } catch ( e ) { | ||
22 | // If there's a button named "submit" then the form.submit | ||
23 | // function is masked and can't be called in IE/FF, so we | ||
24 | // call the click() method of that button. | ||
25 | if ( $form.submit.click ) | ||
26 | $form.submit.click(); | ||
27 | } | ||
28 | } | ||
29 | } | ||
30 | } | ||
31 | }; | ||
32 | |||
33 | var pluginName = 'save'; | ||
34 | |||
35 | // Register a plugin named "save". | ||
36 | CKEDITOR.plugins.add( pluginName, { | ||
37 | // jscs:disable maximumLineLength | ||
38 | 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% | ||
39 | // jscs:enable maximumLineLength | ||
40 | icons: 'save', // %REMOVE_LINE_CORE% | ||
41 | hidpi: true, // %REMOVE_LINE_CORE% | ||
42 | init: function( editor ) { | ||
43 | // Save plugin is for replace mode only. | ||
44 | if ( editor.elementMode != CKEDITOR.ELEMENT_MODE_REPLACE ) | ||
45 | return; | ||
46 | |||
47 | var command = editor.addCommand( pluginName, saveCmd ); | ||
48 | command.modes = { wysiwyg: !!( editor.element.$.form ) }; | ||
49 | |||
50 | editor.ui.addButton && editor.ui.addButton( 'Save', { | ||
51 | label: editor.lang.save.toolbar, | ||
52 | command: pluginName, | ||
53 | toolbar: 'document,10' | ||
54 | } ); | ||
55 | } | ||
56 | } ); | ||
57 | } )(); | ||
58 | |||
59 | /** | ||
60 | * Fired when the user clicks the Save button on the editor toolbar. | ||
61 | * This event allows to overwrite the default Save button behavior. | ||
62 | * | ||
63 | * @since 4.2 | ||
64 | * @event save | ||
65 | * @member CKEDITOR.editor | ||
66 | * @param {CKEDITOR.editor} editor This editor instance. | ||
67 | */ | ||