JasonWoof Got questions, comments, patches, etc.? Contact Jason Woofenden
vanilla ckeditor-3.0
[ckeditor.git] / _source / plugins / save / plugin.js
diff --git a/_source/plugins/save/plugin.js b/_source/plugins/save/plugin.js
new file mode 100644 (file)
index 0000000..e2d84bc
--- /dev/null
@@ -0,0 +1,55 @@
+/*\r
+Copyright (c) 2003-2009, CKSource - Frederico Knabben. All rights reserved.\r
+For licensing, see LICENSE.html or http://ckeditor.com/license\r
+*/\r
+\r
+/**\r
+ * @fileSave plugin.\r
+ */\r
+\r
+(function()\r
+{\r
+       var saveCmd =\r
+       {\r
+               modes : { wysiwyg:1, source:1 },\r
+\r
+               exec : function( editor )\r
+               {\r
+                       var $form = editor.element.$.form;\r
+\r
+                       if ( $form )\r
+                       {\r
+                               try\r
+                               {\r
+                                       $form.submit();\r
+                               }\r
+                               catch( e )\r
+                               {\r
+                                       // If there's a button named "submit" then the form.submit\r
+                                       // function is masked and can't be called in IE/FF, so we\r
+                                       // call the click() method of that button.\r
+                                       if ( $form.submit.click )\r
+                                               $form.submit.click();\r
+                               }\r
+                       }\r
+               }\r
+       };\r
+\r
+       var pluginName = 'save';\r
+\r
+       // Register a plugin named "save".\r
+       CKEDITOR.plugins.add( pluginName,\r
+       {\r
+               init : function( editor )\r
+               {\r
+                       var command = editor.addCommand( pluginName, saveCmd );\r
+                       command.modes = { wysiwyg : !!( editor.element.$.form ) };\r
+\r
+                       editor.ui.addButton( 'Save',\r
+                               {\r
+                                       label : editor.lang.save,\r
+                                       command : pluginName\r
+                               });\r
+               }\r
+       });\r
+})();\r