Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -605,12 +605,6 @@ body > .selectize-dropdown {
padding: .5em;
}

/* The 'skin-flamingo' class name is removed from the body element in full-screen mode so we need to fix the auto-save
styles. */
.cke_maximized #autosaveControl input.autosave-frequency {
width: 3em;
}

/* Make sure the notifications (e.g. for Save & Continue action) and the modals (e.g. for expired session) are visible
when editing in full-screen mode. */
body[data-maximized] .xnotification-container,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,11 +180,6 @@ div.suggestItems .hide-button {
}
}

// FIX: Auto-save
.skin-flamingo #autosaveControl input.autosave-frequency {
width: 3em;
}

// FIX: user profile
.skin-flamingo {
.user-menu-profile:before, .user-menu-preferences:before, .user-menu-watchlist:before, .user-menu-network:before, .user-menu-wikis:before, .user-menu-dashboard:before {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ core.edit.wikiToolbar.htmltext=<!-- Your HTML code here -->
core.edit.wikiToolbar.velocity=Velocity code
core.edit.wikiToolbar.velocitytext=#* Your velocity code here *#
core.edit.autosave=Autosave
core.edit.autosave.every=every
core.edit.autosave.interval.label=Autosave interval (in mins)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The term "mins" is colloquial English, I think we should use a proper formal term like "minutes".


notice=Notice
changephoto=Changing photo for {0}
Expand Down Expand Up @@ -5695,6 +5695,11 @@ platform.index.spaceIndexDocumentListCreate=Create a new page
csrf.confirmation=<p>This request contains an invalid authentication information.</p><p>This might happen in the following situations:</p><ul><li>You left the editor open in another window/tab and logged off and on again</li><li>Your authentication token expired after a long period of inactivity</li><li>Somebody tried to perform a CSRF attack</li></ul><p>If you are sure that none of these situations apply in your case, you might have found a bug. We are sorry about that, please report it on <a href="http://jira.xwiki.org/">XWiki JIRA</a></p><p>Do you want to resend the request? If unsure, say <strong>No</strong>.</p>
core.register.successful={0} ({1}): Registration successful.

#######################################
## until 17.9.0RC1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## until 17.9.0RC1
## until 17.10.0RC1

#######################################
core.edit.autosave.every=every

## Used to indicate where deprecated keys end
#@deprecatedend

Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,18 @@
#template('colorThemeInit.vm')
#autosaveControl {
display: inline;
white-space: nowrap;
}
#autosaveControl input.autosave-frequency {
text-align: center;
width: 2em;
}

/** Override Toucan styles */
#body #autosaveControl label {
display: inline;
margin: 0;
#autosaveControl .interval {
display: none;
margin-left: 2em;

& .autosave-interval {
width: 3em;
margin-left: 1em;
}
}
#body #autosaveControl label.frequency, #body #autosaveControl label.frequency span {
text-transform: none;
font-weight: 400;
}
#autosaveControl label.autosave {
font-weight: 400;

#autosaveControl .autosave:has(input:checked) + .interval {
display: inline-block;
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ editors.AutoSave = Class.create({
/** Is the autosave enabled ? */
enabled: false,
/** If enabled, how frequent are the savings */
frequency: 5, // minutes
interval: 5, // minutes
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a breaking API change as this is a public API, e.g., documented at https://www.xwiki.org/xwiki/bin/view/Documentation/DevGuide/FrontendResources/Autosave/. I would suggest not modifying the API and just modifying the displayed text.

/** Is the UI for configuring the autosave enabled or not? */
showConfigurationUI: true,
/**
Expand All @@ -45,7 +45,7 @@ editors.AutoSave = Class.create({
/** Initialization */
initialize : function(options) {
this.options = Object.extend(Object.clone(this.options), options || { });
this.form = $(this.options.form) || ($("xwikieditcontent") && $("xwikieditcontent").up('form'));
this.form = $(this.options.form) || $("xwikieditcontent")?.up('form');
if (!this.form || this.form.down('#autosaveControl')) {
return;
}
Expand Down Expand Up @@ -83,44 +83,40 @@ editors.AutoSave = Class.create({
},

/**
* The UI of the autosave feature is created and introduced at the beginning of the edit form. It comprises a checkbox
* for enabling / disabling the autosave and an input that allows to set the autosave frequency.
* The UI of the autosave feature is created and introduced towards the end of the edit form.
* It contains a checkbox for toggling the autosave and an input that allows to set the autosave interval in minutes.
*/
createUIElements : function() {
// Checkbox to enable/disable the autosave
// Toggle for the autosave feature.
this.autosaveCheckbox = new Element('input', {
type: "checkbox",
checked: this.options.enabled,
name: "doAutosave",
id: "doAutosave"
});
// Input for setting the autosave frequency
this.autosaveInput = new Element('input', {
// Input for setting the autosave interval
this.autosaveIntervalInput = new Element('input', {
type: "text",
value: this.options.frequency,
value: this.options.interval,
size: "2",
"class": "autosave-frequency"
"class": "autosave-interval"
});
// Labels
var autosaveLabel = new Element('label', {'class': 'autosave', 'for' : "doAutosave"});
let autosaveLabel = new Element('label', {'class': 'autosave'});
autosaveLabel.appendChild(this.autosaveCheckbox);
autosaveLabel.appendChild(document.createTextNode(" $services.localization.render('core.edit.autosave')"));
var frequencyLabel = new Element('label', {'class': 'frequency'});
frequencyLabel.appendChild(document.createTextNode("$services.localization.render('core.edit.autosave.every') "));
frequencyLabel.appendChild(this.autosaveInput);
this.timeUnit = new Element('span');
this.setTimeUnit();
frequencyLabel.appendChild(document.createTextNode(" "));
frequencyLabel.appendChild(this.timeUnit);
autosaveLabel.appendChild(document.createTextNode("$escapetool.javascript($services.localization.render('core.edit.autosave'))"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be much simpler to use the append method here (if this is a proper Element and not just something from Prototype, if not it might be a good reason to migrate away from Prototype).

let intervalLabel = new Element('label', {'class': 'interval'});
intervalLabel.appendChild(document.createTextNode("$escapetool.javascript($services.localization.render('core.edit.autosave.interval.label'))"));
intervalLabel.appendChild(this.autosaveIntervalInput);
// A paragraph containing the whole thing
var container = new Element('div', {"id": "autosaveControl"});
let container = new Element('div', {"id": "autosaveControl"});
this.classNameAutosaveDisabled = 'autosaveDisabled';
if (!this.options.enabled) {
container.addClassName(this.classNameAutosaveDisabled);
}
container.appendChild(autosaveLabel);
container.appendChild(document.createTextNode(" "));
container.appendChild(frequencyLabel);
container.appendChild(intervalLabel);
container.appendChild(document.createTextNode(" "));
// Insert in the editing UI
this.form.down('.buttons').insert(container);
Expand All @@ -138,7 +134,7 @@ editors.AutoSave = Class.create({
}
};
["keydown", "keyup", "keypress"].each(function(eventName) {
this.autosaveInput.observe(eventName, preventSubmit);
this.autosaveIntervalInput.observe(eventName, preventSubmit);
this.autosaveCheckbox.observe(eventName, preventSubmit);
}.bind(this));

Expand All @@ -147,38 +143,24 @@ editors.AutoSave = Class.create({
this.toggleTimer(this.autosaveCheckbox.checked);
}.bindAsEventListener(this));

// Set autosave frequency
Event.observe(this.autosaveInput, "blur", function() {
// Set autosave interval
Event.observe(this.autosaveIntervalInput, "blur", function() {
// is the given value valid?
var newFrequency = new Number(this.autosaveInput.value);
if (newFrequency > 0) {
let newInterval = Number(this.autosaveIntervalInput.value);
if (newInterval > 0) {
// yes: memorize it
this.options.frequency = newFrequency;
this.setTimeUnit();
this.options.interval = newInterval;
// reset autosave loop
this.startTimer();
} else {
// no: restore the previous value in the input
this.autosaveInput.value = this.options.frequency;
this.autosaveIntervalInput.value = this.options.interval;
}
}.bindAsEventListener(this));

this._toggleTimerWhenSaveButtonIsEnabledOrDisabled();
},

/**
* Changes the label text displaying the time measure unit for autosave freaquency,
* according to the value introduced by the user in the input (singular or plural).
* TODO This is bad, very difficult to internationalize.
*/
setTimeUnit : function() {
if (this.options.frequency == 1) {
this.timeUnit.update("minute");
} else {
this.timeUnit.update("minutes");
}
},

/**
* Stop the timer when the save button is disabled (e.g. because there is another save in progress or because the save
* button was hidden) and restart the timer, if needed, when the save button is enabled.
Expand Down Expand Up @@ -207,30 +189,30 @@ editors.AutoSave = Class.create({
}
if (this.options.enabled) {
this.startTimer();
if (this.autosaveInput) {
this.autosaveInput.up(1).removeClassName(this.classNameAutosaveDisabled);
if (this.autosaveIntervalInput) {
this.autosaveIntervalInput.up(1).removeClassName(this.classNameAutosaveDisabled);
}
} else {
this.stopTimer();
if (this.autosaveInput) {
this.autosaveInput.up(1).addClassName(this.classNameAutosaveDisabled);
if (this.autosaveIntervalInput) {
this.autosaveIntervalInput.up(1).addClassName(this.classNameAutosaveDisabled);
}
}
},

/**
* Start autosave timer when the autosave is enabled.
* Every (this.options.frequency * 60) seconds, the callback function doAutosave is called.
* Every (this.options.interval * 60) seconds, the callback function doAutosave is called.
*/
startTimer : function() {
// Make sure we stop the existing timer.
this.stopTimer();
this.timer = new PeriodicalExecuter(this.doAutosave.bind(this),
this.options.frequency * 60 /* seconds in a minute */);
this.options.interval * 60 /* seconds in a minute */);
},

/**
* Stop the autosave loop when the autosave is disabled or when the autosave frequency is changed
* Stop the autosave loop when the autosave is disabled or when the autosave interval is changed
* and the loop needs to be restarted.
*/
stopTimer : function() {
Expand Down