Autosave Widget

Last modified by Jean-S├ębastien Dennebouy on 2018/04/27

This is a Javascript widget bundled by default with the XWiki platform.

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.

Usage

To learn how to use the AutoSave feature check the Page Editing guide.
This API is available since XWiki 4.4 Milestone 1

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 that initializes the widget.

In the sheet:

{{velocity}}
$xwiki.jsfx.use('js/xwiki/actionbuttons/actionButtons.js', true)##
$xwiki.jsfx.use('js/xwiki/editors/autosave.js')##
## If you don't want to show the UI, then don't include the CSS file
$xwiki.ssfx.use('js/xwiki/editors/autosave.css')##
## Use to the correct name of the sheet, or the document where the JSX is located, if not in the sheet
$xwiki.jsx.use('MyApplication.MyApplicationSheet')##
{{/velocity}}
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.

In the JSX object:

document.observe('xwiki:dom:loaded', function() {
 new XWiki.editors.AutoSave({
    form : 'inline',
    enabled: true,
    frequency: 1,
    showConfigurationUI: false
  });
});

Parameters

The constructor accepts a map of parameters as its only argument, with the following property keys known (all are optional):

ParameterDescriptionDefault value
formthe ID (or DOM node) to saveby default the form containing the element with the "xwikieditcontent" ID is used, which is the main form in wiki edit mode
enabledthe initial state of the autosavefalse - the user must click the checkbox to activate autosaving
frequencythe interval between consecutive saves, in minutes5
showConfigurationUIis the UI for configuring the autosave enabled or nottrue
disabledOpacitythe opacity of the configuration UI (the frequency input) when the autosave is disabled, a number between 0 and 10.2
Tags:
Created by Vincent Massol on 2017/09/04
   

Get Connected