bgneal@45: /**
bgneal@45:  * $Id: editor_plugin_src.js 520 2008-01-07 16:30:32Z spocke $
bgneal@45:  *
bgneal@45:  * @author Moxiecode
bgneal@45:  * @copyright Copyright © 2004-2008, Moxiecode Systems AB, All rights reserved.
bgneal@45:  */
bgneal@45: 
bgneal@45: (function() {
bgneal@45: 	tinymce.create('tinymce.plugins.AutoSavePlugin', {
bgneal@45: 		init : function(ed, url) {
bgneal@45: 			var t = this;
bgneal@45: 
bgneal@45: 			t.editor = ed;
bgneal@45: 
bgneal@45: 			window.onbeforeunload = tinymce.plugins.AutoSavePlugin._beforeUnloadHandler;
bgneal@45: 		},
bgneal@45: 
bgneal@45: 		getInfo : function() {
bgneal@45: 			return {
bgneal@45: 				longname : 'Auto save',
bgneal@45: 				author : 'Moxiecode Systems AB',
bgneal@45: 				authorurl : 'http://tinymce.moxiecode.com',
bgneal@45: 				infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autosave',
bgneal@45: 				version : tinymce.majorVersion + "." + tinymce.minorVersion
bgneal@45: 			};
bgneal@45: 		},
bgneal@45: 
bgneal@45: 		// Private plugin internal methods
bgneal@45: 
bgneal@45: 		'static' : {
bgneal@45: 			_beforeUnloadHandler : function() {
bgneal@45: 				var msg;
bgneal@45: 
bgneal@45: 				tinymce.each(tinyMCE.editors, function(ed) {
bgneal@45: 					if (ed.getParam("fullscreen_is_enabled"))
bgneal@45: 						return;
bgneal@45: 
bgneal@45: 					if (ed.isDirty()) {
bgneal@45: 						msg = ed.getLang("autosave.unload_msg");
bgneal@45: 						return false;
bgneal@45: 					}
bgneal@45: 				});
bgneal@45: 
bgneal@45: 				return msg;
bgneal@45: 			}
bgneal@45: 		}
bgneal@45: 	});
bgneal@45: 
bgneal@45: 	// Register plugin
bgneal@45: 	tinymce.PluginManager.add('autosave', tinymce.plugins.AutoSavePlugin);
bgneal@45: })();