JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
5cf2b91b47d0f5e3bdf3a95cfc782d4d7ec0cfb9
[ckeditor.git] / _source / plugins / save / plugin.js
1 /*\r
2 Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.\r
3 For licensing, see LICENSE.html or http://ckeditor.com/license\r
4 */\r
5 \r
6 /**\r
7  * @fileSave plugin.\r
8  */\r
9 \r
10 (function()\r
11 {\r
12         var saveCmd =\r
13         {\r
14                 modes : { wysiwyg:1, source:1 },\r
15 \r
16                 exec : function( editor )\r
17                 {\r
18                         var $form = editor.element.$.form;\r
19 \r
20                         if ( $form )\r
21                         {\r
22                                 try\r
23                                 {\r
24                                         $form.submit();\r
25                                 }\r
26                                 catch( e )\r
27                                 {\r
28                                         // If there's a button named "submit" then the form.submit\r
29                                         // function is masked and can't be called in IE/FF, so we\r
30                                         // call the click() method of that button.\r
31                                         if ( $form.submit.click )\r
32                                                 $form.submit.click();\r
33                                 }\r
34                         }\r
35                 }\r
36         };\r
37 \r
38         var pluginName = 'save';\r
39 \r
40         // Register a plugin named "save".\r
41         CKEDITOR.plugins.add( pluginName,\r
42         {\r
43                 init : function( editor )\r
44                 {\r
45                         var command = editor.addCommand( pluginName, saveCmd );\r
46                         command.modes = { wysiwyg : !!( editor.element.$.form ) };\r
47 \r
48                         editor.ui.addButton( 'Save',\r
49                                 {\r
50                                         label : editor.lang.save,\r
51                                         command : pluginName\r
52                                 });\r
53                 }\r
54         });\r
55 })();\r