Show last authors
1 {{box cssClass="floatinginfobox" title="**Contents**"}}
2 {{toc/}}
3 {{/box}}
4
5 {{info}}
6 This is a Javascript widget bundled by default with the XWiki platform.
7 {{/info}}
8
9 The //Autosave widget// enables periodical automatic saving of a document. This widget is not mature enough yet, so by default it is enabled only in wiki mode, but it is possible to manually enable it in an application using its JS API.
10
11 = Usage =
12
13 {{info}}
14 To learn how to use the AutoSave feature check the [[Page Editing guide>>platform:Features.PageEditing||anchor="HAutosave"]].
15 {{/info}}
16
17 {{warning}}
18 This API is available since XWiki 4.4 Milestone 1
19 {{/warning}}
20
21 To enable the autosave widget in an application, you can include the ##js/xwiki/editors/autosave.js## script in the sheet, along with a custom [[JSX>>platform:DevGuide.SkinExtensionsTutorial]] that initializes the widget.
22
23 In the sheet:
24
25 {{code language="none"}}
26 {{velocity}}
27 $xwiki.jsfx.use('js/xwiki/actionbuttons/actionButtons.js', true)##
28 $xwiki.jsfx.use('js/xwiki/editors/autosave.js')##
29 ## If you don't want to show the UI, then don't include the CSS file
30 $xwiki.ssfx.use('js/xwiki/editors/autosave.css')##
31 ## Use to the correct name of the sheet, or the document where the JSX is located, if not in the sheet
32 $xwiki.jsx.use('MyApplication.MyApplicationSheet')##
33 {{/velocity}}
34 {{/code}}
35
36 {{warning}}
37 The widget depends on the ##actionbuttons.js## script, so make sure you pull that script as well **before** pulling ##autosave.js##. Even though ##actionbuttons.js## is already pulled when generating the action buttons, the call is made after the sheet content has been executed.
38 {{/warning}}
39
40 In the JSX object:
41
42 {{code language="javascript"}}
43 document.observe('xwiki:dom:loaded', function() {
44 new XWiki.editors.AutoSave({
45 form : 'inline',
46 enabled: true,
47 frequency: 1,
48 showConfigurationUI: false
49 });
50 });
51 {{/code}}
52
53 == Parameters ==
54
55 The constructor accepts a map of parameters as its only argument, with the following property keys known (all are optional):
56
57 |=Parameter|=Description|=Default value
58 |##form##|the ID (or DOM node) to save|by default the form containing the element with the "xwikieditcontent" ID is used, which is the main form in wiki edit mode
59 |##enabled##|the initial state of the autosave|##false## - the user must click the checkbox to activate autosaving
60 |##frequency##|the interval between consecutive saves, in minutes|5
61 |##showConfigurationUI##|is the UI for configuring the autosave enabled or not|true
62 |##disabledOpacity##|the opacity of the configuration UI (the frequency input) when the autosave is disabled, a number between 0 and 1|0.2

Get Connected