1 tinymce
.PluginManager
.add("autosave",function(t
){function e(t
,e
){var n
={s
:1e3
,m
:6e4
};return t
=/^(\d+)([ms]?)$/.exec(""+(t
||e
)),(t
[2]?n
[t
[2]]:1)*parseInt(t
,10)}function n(){var t
=parseInt(m
.getItem(f
+"autosave.time"),10)||0;return(new Date
).getTime()-t
>d
.autosave_retention
?(i(),!1):!0}function i(){m
.removeItem(f
+"autosave.draft"),m
.removeItem(f
+"autosave.time")}function a(){c
&&t
.isDirty()&&(m
.setItem(f
+"autosave.draft",t
.getContent({format
:"raw",no_events
:!0})),m
.setItem(f
+"autosave.time",(new Date
).getTime()),t
.fire("StoreDraft"))}function r(){n()&&(t
.setContent(m
.getItem(f
+"autosave.draft"),{format
:"raw"}),i(),t
.fire("RestoreDraft"))}function o(){c
||(setInterval(function(){t
.removed
||a()},d
.autosave_interval
),c
=!0)}function s(){var e
=this;e
.disabled(!n()),t
.on("StoreDraft RestoreDraft",function(){e
.disabled(!n())}),o()}function l(){t
.undoManager
.beforeChange(),r(),t
.undoManager
.add()}function u(){var t
;return tinymce
.each(tinymce
.editors
,function(e
){e
.plugins
.autosave
&&e
.plugins
.autosave
.storeDraft(),!t
&&e
.isDirty()&&e
.getParam("autosave_ask_before_unload",!0)&&(t
=e
.translate("You have unsaved changes are you sure you want to navigate away?"))}),t
}var c
,d
=t
.settings
,m
=tinymce
.util
.LocalStorage
,f
=t
.id
;d
.autosave_interval
=e(d
.autosave_interval
,"30s"),d
.autosave_retention
=e(d
.autosave_retention
,"20m"),t
.addButton("restoredraft",{title
:"Restore last draft",onclick
:l
,onPostRender
:s
}),t
.addMenuItem("restoredraft",{text
:"Restore last draft",onclick
:l
,onPostRender
:s
,context
:"file"}),this.storeDraft
=a
,window
.onbeforeunload
=u
});