1 /** |
1 /** |
2 * $Id: editor_plugin_src.js 201 2007-02-12 15:56:56Z spocke $ |
2 * $Id: editor_plugin_src.js 372 2007-11-11 18:38:50Z spocke $ |
3 * |
3 * |
4 * @author Moxiecode |
4 * @author Moxiecode |
5 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. |
5 * @copyright Copyright © 2004-2007, Moxiecode Systems AB, All rights reserved. |
6 */ |
6 */ |
7 |
7 |
8 /* Import plugin specific language pack */ |
8 (function() { |
9 tinyMCE.importPluginLanguagePack('autosave'); |
9 tinymce.create('tinymce.plugins.AutoSavePlugin', { |
|
10 init : function(ed, url) { |
|
11 var t = this; |
10 |
12 |
11 var TinyMCE_AutoSavePlugin = { |
13 t.editor = ed; |
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 |
14 |
22 // Private plugin internal methods |
15 window.onbeforeunload = tinymce.plugins.AutoSavePlugin._beforeUnloadHandler; |
|
16 }, |
23 |
17 |
24 _beforeUnloadHandler : function() { |
18 getInfo : function() { |
25 var n, inst, anyDirty = false, msg = tinyMCE.getLang("lang_autosave_unload_msg"); |
19 return { |
|
20 longname : 'Auto save', |
|
21 author : 'Moxiecode Systems AB', |
|
22 authorurl : 'http://tinymce.moxiecode.com', |
|
23 infourl : 'http://wiki.moxiecode.com/index.php/TinyMCE:Plugins/autosave', |
|
24 version : tinymce.majorVersion + "." + tinymce.minorVersion |
|
25 }; |
|
26 }, |
26 |
27 |
27 if (tinyMCE.getParam("fullscreen_is_enabled")) |
28 // Private plugin internal methods |
28 return; |
|
29 |
29 |
30 for (n in tinyMCE.instances) { |
30 'static' : { |
31 inst = tinyMCE.instances[n]; |
31 _beforeUnloadHandler : function() { |
|
32 var msg; |
32 |
33 |
33 if (!tinyMCE.isInstance(inst)) |
34 tinymce.each(tinyMCE.editors, function(ed) { |
34 continue; |
35 if (ed.getParam("fullscreen_is_enabled")) |
|
36 return; |
35 |
37 |
36 if (inst.isDirty()) |
38 if (ed.isDirty()) { |
|
39 msg = ed.getLang("autosave.unload_msg"); |
|
40 return false; |
|
41 } |
|
42 }); |
|
43 |
37 return msg; |
44 return msg; |
|
45 } |
38 } |
46 } |
|
47 }); |
39 |
48 |
40 return; |
49 // Register plugin |
41 } |
50 tinymce.PluginManager.add('autosave', tinymce.plugins.AutoSavePlugin); |
42 }; |
51 })(); |
43 |
|
44 window.onbeforeunload = TinyMCE_AutoSavePlugin._beforeUnloadHandler; |
|
45 |
|
46 tinyMCE.addPlugin("autosave", TinyMCE_AutoSavePlugin); |
|