2007-01-16 18:52:13 +01:00
|
|
|
|
/**
|
2008-01-17 16:44:05 +01:00
|
|
|
|
* $Id$
|
2007-01-16 18:52:13 +01:00
|
|
|
|
*
|
|
|
|
|
* @author Moxiecode
|
2008-01-17 16:44:05 +01:00
|
|
|
|
* @copyright Copyright <EFBFBD> 2004-2008, Moxiecode Systems AB, All rights reserved.
|
2007-01-16 18:52:13 +01:00
|
|
|
|
*/
|
|
|
|
|
|
2008-01-17 16:44:05 +01:00
|
|
|
|
(function() {
|
|
|
|
|
tinymce.create('tinymce.plugins.AutoSavePlugin', {
|
|
|
|
|
init : function(ed, url) {
|
|
|
|
|
var t = this;
|
2007-01-16 18:52:13 +01:00
|
|
|
|
|
2008-01-17 16:44:05 +01:00
|
|
|
|
t.editor = ed;
|
2007-01-16 18:52:13 +01:00
|
|
|
|
|
2008-01-17 16:44:05 +01:00
|
|
|
|
window.onbeforeunload = tinymce.plugins.AutoSavePlugin._beforeUnloadHandler;
|
|
|
|
|
},
|
2007-01-16 18:52:13 +01:00
|
|
|
|
|
2008-01-17 16:44:05 +01:00
|
|
|
|
getInfo : function() {
|
|
|
|
|
return {
|
|
|
|
|
longname : 'Auto save',
|
|
|
|
|
author : 'Moxiecode Systems AB',
|
|
|
|
|
authorurl : 'http://tinymce.moxiecode.com',
|
|
|
|
|
infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autosave',
|
|
|
|
|
version : tinymce.majorVersion + "." + tinymce.minorVersion
|
|
|
|
|
};
|
|
|
|
|
},
|
2007-01-16 18:52:13 +01:00
|
|
|
|
|
2008-01-17 16:44:05 +01:00
|
|
|
|
// Private plugin internal methods
|
2007-01-16 18:52:13 +01:00
|
|
|
|
|
2008-01-17 16:44:05 +01:00
|
|
|
|
'static' : {
|
|
|
|
|
_beforeUnloadHandler : function() {
|
|
|
|
|
var msg;
|
2007-01-16 18:52:13 +01:00
|
|
|
|
|
2008-01-17 16:44:05 +01:00
|
|
|
|
tinymce.each(tinyMCE.editors, function(ed) {
|
|
|
|
|
if (ed.getParam("fullscreen_is_enabled"))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
if (ed.isDirty()) {
|
|
|
|
|
msg = ed.getLang("autosave.unload_msg");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
});
|
2007-01-16 18:52:13 +01:00
|
|
|
|
|
|
|
|
|
return msg;
|
2008-01-17 16:44:05 +01:00
|
|
|
|
}
|
2007-01-16 18:52:13 +01:00
|
|
|
|
}
|
2008-01-17 16:44:05 +01:00
|
|
|
|
});
|
2007-01-16 18:52:13 +01:00
|
|
|
|
|
2008-01-17 16:44:05 +01:00
|
|
|
|
// Register plugin
|
|
|
|
|
tinymce.PluginManager.add('autosave', tinymce.plugins.AutoSavePlugin);
|
|
|
|
|
})();
|