2020-05-02 21:35:08 +02:00
|
|
|
/**
|
|
|
|
* Class the handle the read-only logic
|
|
|
|
*/
|
|
|
|
class ReadOnlyService {
|
|
|
|
/**
|
|
|
|
* @type {boolean}
|
|
|
|
*/
|
2020-05-11 15:12:37 +02:00
|
|
|
#readOnlyActive = true;
|
|
|
|
get readOnlyActive() {
|
|
|
|
return this.#readOnlyActive;
|
|
|
|
}
|
2020-05-02 21:35:08 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @type {object}
|
|
|
|
*/
|
2020-05-11 15:12:37 +02:00
|
|
|
#previousToolHtmlElem = null;
|
|
|
|
get previousToolHtmlElem() {
|
|
|
|
return this.#previousToolHtmlElem;
|
|
|
|
}
|
2020-05-02 21:35:08 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Activate read-only mode
|
|
|
|
*/
|
|
|
|
activateReadOnlyMode() {
|
2020-05-11 15:12:37 +02:00
|
|
|
this.#readOnlyActive = true;
|
2020-05-02 21:35:08 +02:00
|
|
|
|
2020-05-11 15:12:37 +02:00
|
|
|
this.#previousToolHtmlElem = $(".whiteboard-tool.active");
|
2020-05-02 21:35:08 +02:00
|
|
|
|
|
|
|
// switch to mouse tool to prevent the use of the
|
|
|
|
// other tools
|
|
|
|
$(".whiteboard-tool[tool=mouse]").click();
|
|
|
|
$(".whiteboard-tool").prop("disabled", true);
|
|
|
|
$(".whiteboard-edit-group > button").prop("disabled", true);
|
|
|
|
$(".whiteboard-edit-group").addClass("group-disabled");
|
|
|
|
$("#whiteboardUnlockBtn").hide();
|
|
|
|
$("#whiteboardLockBtn").show();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Deactivate read-only mode
|
|
|
|
*/
|
|
|
|
deactivateReadOnlyMode() {
|
2020-05-11 15:12:37 +02:00
|
|
|
this.#readOnlyActive = false;
|
2020-05-02 21:35:08 +02:00
|
|
|
|
|
|
|
$(".whiteboard-tool").prop("disabled", false);
|
|
|
|
$(".whiteboard-edit-group > button").prop("disabled", false);
|
|
|
|
$(".whiteboard-edit-group").removeClass("group-disabled");
|
|
|
|
$("#whiteboardUnlockBtn").show();
|
|
|
|
$("#whiteboardLockBtn").hide();
|
|
|
|
|
|
|
|
// restore previously selected tool
|
2020-05-11 15:12:37 +02:00
|
|
|
const { previousToolHtmlElem } = this;
|
|
|
|
if (previousToolHtmlElem) previousToolHtmlElem.click();
|
2020-05-02 21:35:08 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-05-09 15:40:26 +02:00
|
|
|
export default new ReadOnlyService();
|