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 var command = editor.addCommand( pluginName, saveCmd ); 46 command.modes = { wysiwyg : !!( editor.element.$.form ) }; 47 48 editor.ui.addButton( 'Save', 49 { 50 label : editor.lang.save, 51 command : pluginName 52 }); 53 } 54 }); 55 })(); 56