]> git.immae.eu Git - perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git/blame - sources/plugins/save/plugin.js
Initial commit
[perso/Immae/Projets/packagist/connexionswing-ckeditor-component.git] / sources / plugins / save / plugin.js
CommitLineData
7adcb81e
IB
1/**\r
2 * @license Copyright (c) 2003-2015, CKSource - Frederico Knabben. All rights reserved.\r
3 * For licensing, see LICENSE.md or http://ckeditor.com/license\r
4 */\r
5\r
6/**\r
7 * @fileOverview The Save plugin.\r
8 */\r
9\r
10( function() {\r
11 var saveCmd = {\r
12 readOnly: 1,\r
13\r
14 exec: function( editor ) {\r
15 if ( editor.fire( 'save' ) ) {\r
16 var $form = editor.element.$.form;\r
17\r
18 if ( $form ) {\r
19 try {\r
20 $form.submit();\r
21 } catch ( e ) {\r
22 // If there's a button named "submit" then the form.submit\r
23 // function is masked and can't be called in IE/FF, so we\r
24 // call the click() method of that button.\r
25 if ( $form.submit.click )\r
26 $form.submit.click();\r
27 }\r
28 }\r
29 }\r
30 }\r
31 };\r
32\r
33 var pluginName = 'save';\r
34\r
35 // Register a plugin named "save".\r
36 CKEDITOR.plugins.add( pluginName, {\r
37 // jscs:disable maximumLineLength\r
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%\r
39 // jscs:enable maximumLineLength\r
40 icons: 'save', // %REMOVE_LINE_CORE%\r
41 hidpi: true, // %REMOVE_LINE_CORE%\r
42 init: function( editor ) {\r
43 // Save plugin is for replace mode only.\r
44 if ( editor.elementMode != CKEDITOR.ELEMENT_MODE_REPLACE )\r
45 return;\r
46\r
47 var command = editor.addCommand( pluginName, saveCmd );\r
48 command.modes = { wysiwyg: !!( editor.element.$.form ) };\r
49\r
50 editor.ui.addButton && editor.ui.addButton( 'Save', {\r
51 label: editor.lang.save.toolbar,\r
52 command: pluginName,\r
53 toolbar: 'document,10'\r
54 } );\r
55 }\r
56 } );\r
57} )();\r
58\r
59/**\r
60 * Fired when the user clicks the Save button on the editor toolbar.\r
61 * This event allows to overwrite the default Save button behavior.\r
62 *\r
63 * @since 4.2\r
64 * @event save\r
65 * @member CKEDITOR.editor\r
66 * @param {CKEDITOR.editor} editor This editor instance.\r
67 */\r