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