includes/clientside/tinymce/plugins/autosave/editor_plugin_src.js
changeset 1 fe660c52c48f
child 335 67bd3121a12e
equal deleted inserted replaced
0:902822492a68 1:fe660c52c48f
       
     1 /**
       
     2  * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $
       
     3  *
       
     4  * @author Moxiecode
       
     5  * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved.
       
     6  */
       
     7 
       
     8 /* Import plugin specific language pack */
       
     9 tinyMCE.importPluginLanguagePack('autosave');
       
    10 
       
    11 var TinyMCE_AutoSavePlugin = {
       
    12 	getInfo : function() {
       
    13 		return {
       
    14 			longname : 'Auto save',
       
    15 			author : 'Moxiecode Systems AB',
       
    16 			authorurl : 'http://tinymce.moxiecode.com',
       
    17 			infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autosave',
       
    18 			version : tinyMCE.majorVersion + "." + tinyMCE.minorVersion
       
    19 		};
       
    20 	},
       
    21 
       
    22 	// Private plugin internal methods
       
    23 
       
    24 	_beforeUnloadHandler : function() {
       
    25 		var n, inst, anyDirty = false, msg = tinyMCE.getLang("lang_autosave_unload_msg");
       
    26 
       
    27 		if (tinyMCE.getParam("fullscreen_is_enabled"))
       
    28 			return;
       
    29 
       
    30 		for (n in tinyMCE.instances) {
       
    31 			inst = tinyMCE.instances[n];
       
    32 
       
    33 			if (!tinyMCE.isInstance(inst))
       
    34 				continue;
       
    35 
       
    36 			if (inst.isDirty())
       
    37 				return msg;
       
    38 		}
       
    39 
       
    40 		return;
       
    41 	}
       
    42 };
       
    43 
       
    44 window.onbeforeunload = TinyMCE_AutoSavePlugin._beforeUnloadHandler;
       
    45 
       
    46 tinyMCE.addPlugin("autosave", TinyMCE_AutoSavePlugin);