Auto-Save Widget

The Auto-Save Widget is bundled with XWiki and it is used to enable the periodical automatic saving of a document. 

AutoSaveWidget.png

To enable the automatic save, just select the "Autosave" checkbox next to the action buttons. Additionally, you can change the interval (in minutes) by specifying an integer value in the dedicated input.

Usage

To use the Auto-Save widget, start by creating a wiki page and include the following JavaScript resource files:

  • js/xwiki/editors/autosave.js
  • js/xwiki/actionbuttons/actionButtons.js - this script file is necessary because the autosave.js depends on it. Even though actionbuttons.js is already pulled when generating the action buttons, the call is made after the wiki page content has been executed, so you have to explicitly include it.

You can additionally include the js/xwiki/editors/autosave.css file, for the case you need to display the widget UI.

{{velocity}}
$xwiki.jsfx.use('js/xwiki/actionbuttons/actionButtons.js', true)##
$xwiki.jsfx.use('js/xwiki/editors/autosave.js')##
$xwiki.ssfx.use('js/xwiki/editors/autosave.css')##
{{/velocity}}
  

Next, add an "XWiki.JavaScriptExtension" object with the following code

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

which indicates that the auto-save UI will be displayed in "Inline" mode and the page will be automatically saved every minute.

Finally, edit the page in "Inline" mode and you should see the screen below:

AutoSaveExample.png

Parameters of the XWiki.editors.AutoSave Constructor

ParameterDescriptionDefault value
formThe ID or DOM node to save.xwikieditcontent which is the main form in wiki edit mode.
enabledA flag describing the initial state of the auto-save. If false, the user has to click the "Autosave" check-box in order to activate it.false
frequencyThe interval in minutes between consecutive saves.5
showConfigurationUIA flag stating whether the auto-save UI is displayed or not.true
disabledOpacityA number between 0 and 1 which sets the opacity of the frequency input when the auto-save is disabled.0.2

Related Pages

Search this space

 

Most popular tags

Failed to execute the [groovy] macro
  1. access rights
  2. activity stream
  3. annotation
  4. attachment
  5. comment
  6. Document Tree Macro
  7. export
  8. Extension Manager
  9. Flamingo skin
  10. global user
  11. Groovy event listener
  12. group
  13. nested page
  14. search
  15. skin
  16. syntax
  17. user
  18. user profile
  19. velocity macros
  20. wiki
  21. wysiwyg
  22. XWiki Applications
  23. xwikiattachment_archive table
  24. xwikiattachment table
  25. xwikiattrecyclebin table
  26. xwikiproperties table

[Display all tags from this space]