chore(front): remove click events before adding them
* Helps with hot reloading in dev env * Prevents the same event handlers from being registered twice * Shouldn't break things
This commit is contained in:
parent
e7725e30d5
commit
a78bb8a0d7
@ -117,13 +117,19 @@ function showBasicAlert(html, newOptions) {
|
|||||||
);
|
);
|
||||||
alertHtml.find(".htmlcontent").append(html);
|
alertHtml.find(".htmlcontent").append(html);
|
||||||
$("body").append(alertHtml);
|
$("body").append(alertHtml);
|
||||||
alertHtml.find(".okbtn").click(function () {
|
alertHtml
|
||||||
|
.find(".okbtn")
|
||||||
|
.off("click")
|
||||||
|
.click(function () {
|
||||||
if (options.onOkClick) {
|
if (options.onOkClick) {
|
||||||
options.onOkClick();
|
options.onOkClick();
|
||||||
}
|
}
|
||||||
alertHtml.remove();
|
alertHtml.remove();
|
||||||
});
|
});
|
||||||
alertHtml.find(".closeAlert").click(function () {
|
alertHtml
|
||||||
|
.find(".closeAlert")
|
||||||
|
.off("click")
|
||||||
|
.click(function () {
|
||||||
alertHtml.remove();
|
alertHtml.remove();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -236,7 +242,9 @@ function initWhiteboard() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// whiteboard clear button
|
// whiteboard clear button
|
||||||
$("#whiteboardTrashBtn").click(function () {
|
$("#whiteboardTrashBtn")
|
||||||
|
.off("click")
|
||||||
|
.click(function () {
|
||||||
$("#whiteboardTrashBtnConfirm").show().focus();
|
$("#whiteboardTrashBtnConfirm").show().focus();
|
||||||
$(this).css({ visibility: "hidden" });
|
$(this).css({ visibility: "hidden" });
|
||||||
});
|
});
|
||||||
@ -246,34 +254,46 @@ function initWhiteboard() {
|
|||||||
$("#whiteboardTrashBtn").css({ visibility: "inherit" });
|
$("#whiteboardTrashBtn").css({ visibility: "inherit" });
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#whiteboardTrashBtnConfirm").click(function () {
|
$("#whiteboardTrashBtnConfirm")
|
||||||
|
.off("click")
|
||||||
|
.click(function () {
|
||||||
$(this).hide();
|
$(this).hide();
|
||||||
$("#whiteboardTrashBtn").css({ visibility: "inherit" });
|
$("#whiteboardTrashBtn").css({ visibility: "inherit" });
|
||||||
whiteboard.clearWhiteboard();
|
whiteboard.clearWhiteboard();
|
||||||
});
|
});
|
||||||
|
|
||||||
// undo button
|
// undo button
|
||||||
$("#whiteboardUndoBtn").click(function () {
|
$("#whiteboardUndoBtn")
|
||||||
|
.off("click")
|
||||||
|
.click(function () {
|
||||||
whiteboard.undoWhiteboardClick();
|
whiteboard.undoWhiteboardClick();
|
||||||
});
|
});
|
||||||
|
|
||||||
// redo button
|
// redo button
|
||||||
$("#whiteboardRedoBtn").click(function () {
|
$("#whiteboardRedoBtn")
|
||||||
|
.off("click")
|
||||||
|
.click(function () {
|
||||||
whiteboard.redoWhiteboardClick();
|
whiteboard.redoWhiteboardClick();
|
||||||
});
|
});
|
||||||
|
|
||||||
// view only
|
// view only
|
||||||
$("#whiteboardLockBtn").click(() => {
|
$("#whiteboardLockBtn")
|
||||||
|
.off("click")
|
||||||
|
.click(() => {
|
||||||
ReadOnlyService.deactivateReadOnlyMode();
|
ReadOnlyService.deactivateReadOnlyMode();
|
||||||
});
|
});
|
||||||
$("#whiteboardUnlockBtn").click(() => {
|
$("#whiteboardUnlockBtn")
|
||||||
|
.off("click")
|
||||||
|
.click(() => {
|
||||||
ReadOnlyService.activateReadOnlyMode();
|
ReadOnlyService.activateReadOnlyMode();
|
||||||
});
|
});
|
||||||
$("#whiteboardUnlockBtn").hide();
|
$("#whiteboardUnlockBtn").hide();
|
||||||
$("#whiteboardLockBtn").show();
|
$("#whiteboardLockBtn").show();
|
||||||
|
|
||||||
// switch tool
|
// switch tool
|
||||||
$(".whiteboard-tool").click(function () {
|
$(".whiteboard-tool")
|
||||||
|
.off("click")
|
||||||
|
.click(function () {
|
||||||
$(".whiteboard-tool").removeClass("active");
|
$(".whiteboard-tool").removeClass("active");
|
||||||
$(this).addClass("active");
|
$(this).addClass("active");
|
||||||
var activeTool = $(this).attr("tool");
|
var activeTool = $(this).attr("tool");
|
||||||
@ -286,13 +306,17 @@ function initWhiteboard() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// upload image button
|
// upload image button
|
||||||
$("#addImgToCanvasBtn").click(function () {
|
$("#addImgToCanvasBtn")
|
||||||
|
.off("click")
|
||||||
|
.click(function () {
|
||||||
if (ReadOnlyService.readOnlyActive) return;
|
if (ReadOnlyService.readOnlyActive) return;
|
||||||
showBasicAlert("Please drag the image into the browser.");
|
showBasicAlert("Please drag the image into the browser.");
|
||||||
});
|
});
|
||||||
|
|
||||||
// save image as imgae
|
// save image as imgae
|
||||||
$("#saveAsImageBtn").click(function () {
|
$("#saveAsImageBtn")
|
||||||
|
.off("click")
|
||||||
|
.click(function () {
|
||||||
whiteboard.getImageDataBase64(
|
whiteboard.getImageDataBase64(
|
||||||
{
|
{
|
||||||
imageFormat: ConfigService.imageDownloadFormat,
|
imageFormat: ConfigService.imageDownloadFormat,
|
||||||
@ -317,7 +341,9 @@ function initWhiteboard() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// save image to json containing steps
|
// save image to json containing steps
|
||||||
$("#saveAsJSONBtn").click(function () {
|
$("#saveAsJSONBtn")
|
||||||
|
.off("click")
|
||||||
|
.click(function () {
|
||||||
var imgData = whiteboard.getImageDataJson();
|
var imgData = whiteboard.getImageDataJson();
|
||||||
|
|
||||||
var w = window.open("about:blank"); //Firefox will not allow downloads without extra window
|
var w = window.open("about:blank"); //Firefox will not allow downloads without extra window
|
||||||
@ -335,7 +361,9 @@ function initWhiteboard() {
|
|||||||
}, 0);
|
}, 0);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#uploadWebDavBtn").click(function () {
|
$("#uploadWebDavBtn")
|
||||||
|
.off("click")
|
||||||
|
.click(function () {
|
||||||
if ($(".webdavUploadBtn").length > 0) {
|
if ($(".webdavUploadBtn").length > 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -385,7 +413,10 @@ function initWhiteboard() {
|
|||||||
"</table>" +
|
"</table>" +
|
||||||
"</div>"
|
"</div>"
|
||||||
);
|
);
|
||||||
webDavHtml.find(".webdavUploadBtn").click(function () {
|
webDavHtml
|
||||||
|
.find(".webdavUploadBtn")
|
||||||
|
.off("click")
|
||||||
|
.click(function () {
|
||||||
var webdavserver = webDavHtml.find(".webdavserver").val();
|
var webdavserver = webDavHtml.find(".webdavserver").val();
|
||||||
localStorage.setItem("webdavserver", webdavserver);
|
localStorage.setItem("webdavserver", webdavserver);
|
||||||
var webdavpath = webDavHtml.find(".webdavpath").val();
|
var webdavpath = webDavHtml.find(".webdavpath").val();
|
||||||
@ -429,11 +460,15 @@ function initWhiteboard() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// upload json containing steps
|
// upload json containing steps
|
||||||
$("#uploadJsonBtn").click(function () {
|
$("#uploadJsonBtn")
|
||||||
|
.off("click")
|
||||||
|
.click(function () {
|
||||||
$("#myFile").click();
|
$("#myFile").click();
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#shareWhiteboardBtn").click(() => {
|
$("#shareWhiteboardBtn")
|
||||||
|
.off("click")
|
||||||
|
.click(() => {
|
||||||
function urlToClipboard(whiteboardId = null) {
|
function urlToClipboard(whiteboardId = null) {
|
||||||
const { protocol, host, pathname, search } = window.location;
|
const { protocol, host, pathname, search } = window.location;
|
||||||
const basePath = `${protocol}//${host}${pathname}`;
|
const basePath = `${protocol}//${host}${pathname}`;
|
||||||
@ -463,11 +498,15 @@ function initWhiteboard() {
|
|||||||
$("#shareWhiteboardDialogMessage").toggleClass("displayNone", true);
|
$("#shareWhiteboardDialogMessage").toggleClass("displayNone", true);
|
||||||
|
|
||||||
$("#shareWhiteboardDialog").toggleClass("displayNone", false);
|
$("#shareWhiteboardDialog").toggleClass("displayNone", false);
|
||||||
$("#shareWhiteboardDialogGoBack").click(() => {
|
$("#shareWhiteboardDialogGoBack")
|
||||||
|
.off("click")
|
||||||
|
.click(() => {
|
||||||
$("#shareWhiteboardDialog").toggleClass("displayNone", true);
|
$("#shareWhiteboardDialog").toggleClass("displayNone", true);
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#shareWhiteboardDialogCopyReadOnlyLink").click(() => {
|
$("#shareWhiteboardDialogCopyReadOnlyLink")
|
||||||
|
.off("click")
|
||||||
|
.click(() => {
|
||||||
urlToClipboard(ConfigService.correspondingReadOnlyWid);
|
urlToClipboard(ConfigService.correspondingReadOnlyWid);
|
||||||
|
|
||||||
$("#shareWhiteboardDialogMessage")
|
$("#shareWhiteboardDialogMessage")
|
||||||
@ -485,12 +524,16 @@ function initWhiteboard() {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#displayWhiteboardInfoBtn").click(() => {
|
$("#displayWhiteboardInfoBtn")
|
||||||
|
.off("click")
|
||||||
|
.click(() => {
|
||||||
InfoService.toggleDisplayInfo();
|
InfoService.toggleDisplayInfo();
|
||||||
});
|
});
|
||||||
|
|
||||||
var btnsMini = false;
|
var btnsMini = false;
|
||||||
$("#minMaxBtn").click(function () {
|
$("#minMaxBtn")
|
||||||
|
.off("click")
|
||||||
|
.click(function () {
|
||||||
if (!btnsMini) {
|
if (!btnsMini) {
|
||||||
$("#toolbar").find(".btn-group:not(.minGroup)").hide();
|
$("#toolbar").find(".btn-group:not(.minGroup)").hide();
|
||||||
$(this).find("#minBtn").hide();
|
$(this).find("#minBtn").hide();
|
||||||
@ -590,7 +633,10 @@ function initWhiteboard() {
|
|||||||
showPDFPageAsImage(parseInt($(this).val()));
|
showPDFPageAsImage(parseInt($(this).val()));
|
||||||
});
|
});
|
||||||
|
|
||||||
modalDiv.find("button").click(function () {
|
modalDiv
|
||||||
|
.find("button")
|
||||||
|
.off("click")
|
||||||
|
.click(function () {
|
||||||
if (currentDataUrl) {
|
if (currentDataUrl) {
|
||||||
$(".basicalert").remove();
|
$(".basicalert").remove();
|
||||||
uploadImgAndAddToWhiteboard(currentDataUrl);
|
uploadImgAndAddToWhiteboard(currentDataUrl);
|
||||||
|
@ -375,13 +375,19 @@ const whiteboard = {
|
|||||||
width,
|
width,
|
||||||
height
|
height
|
||||||
);
|
);
|
||||||
imgDiv.find(".xCanvasBtn").click(function () {
|
imgDiv
|
||||||
|
.find(".xCanvasBtn")
|
||||||
|
.off("click")
|
||||||
|
.click(function () {
|
||||||
_this.imgDragActive = false;
|
_this.imgDragActive = false;
|
||||||
_this.refreshCursorAppearance();
|
_this.refreshCursorAppearance();
|
||||||
imgDiv.remove();
|
imgDiv.remove();
|
||||||
dragOutOverlay.remove();
|
dragOutOverlay.remove();
|
||||||
});
|
});
|
||||||
imgDiv.find(".addToCanvasBtn").click(function () {
|
imgDiv
|
||||||
|
.find(".addToCanvasBtn")
|
||||||
|
.off("click")
|
||||||
|
.click(function () {
|
||||||
_this.imgDragActive = false;
|
_this.imgDragActive = false;
|
||||||
_this.refreshCursorAppearance();
|
_this.refreshCursorAppearance();
|
||||||
const p = imgDiv.position();
|
const p = imgDiv.position();
|
||||||
@ -766,7 +772,10 @@ const whiteboard = {
|
|||||||
'<div class="rotationHandle" style="position:absolute; bottom: -30px; left: 0px; width:100%; text-align:center; cursor:ew-resize;"><i class="fa fa-undo"></i></div>' +
|
'<div class="rotationHandle" style="position:absolute; bottom: -30px; left: 0px; width:100%; text-align:center; cursor:ew-resize;"><i class="fa fa-undo"></i></div>' +
|
||||||
"</div>"
|
"</div>"
|
||||||
);
|
);
|
||||||
imgDiv.find(".xCanvasBtn").click(function () {
|
imgDiv
|
||||||
|
.find(".xCanvasBtn")
|
||||||
|
.off("click")
|
||||||
|
.click(function () {
|
||||||
_this.imgDragActive = false;
|
_this.imgDragActive = false;
|
||||||
_this.refreshCursorAppearance();
|
_this.refreshCursorAppearance();
|
||||||
imgDiv.remove();
|
imgDiv.remove();
|
||||||
@ -778,7 +787,10 @@ const whiteboard = {
|
|||||||
var p = imgDiv.position();
|
var p = imgDiv.position();
|
||||||
var left = 200;
|
var left = 200;
|
||||||
var top = 200;
|
var top = 200;
|
||||||
imgDiv.find(".addToCanvasBtn,.addToBackgroundBtn").click(function () {
|
imgDiv
|
||||||
|
.find(".addToCanvasBtn,.addToBackgroundBtn")
|
||||||
|
.off("click")
|
||||||
|
.click(function () {
|
||||||
var draw = $(this).attr("draw");
|
var draw = $(this).attr("draw");
|
||||||
_this.imgDragActive = false;
|
_this.imgDragActive = false;
|
||||||
|
|
||||||
@ -930,7 +942,10 @@ const whiteboard = {
|
|||||||
var text = btoa(unescape(encodeURIComponent($(this).html()))); //Get html and make encode base64 also take care of the charset
|
var text = btoa(unescape(encodeURIComponent($(this).html()))); //Get html and make encode base64 also take care of the charset
|
||||||
_this.sendFunction({ t: "setTextboxText", d: [txId, text] });
|
_this.sendFunction({ t: "setTextboxText", d: [txId, text] });
|
||||||
});
|
});
|
||||||
textBox.find(".removeIcon").click(function (e) {
|
textBox
|
||||||
|
.find(".removeIcon")
|
||||||
|
.off("click")
|
||||||
|
.click(function (e) {
|
||||||
$("#" + txId).remove();
|
$("#" + txId).remove();
|
||||||
_this.sendFunction({ t: "removeTextbox", d: [txId] });
|
_this.sendFunction({ t: "removeTextbox", d: [txId] });
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
Loading…
Reference in New Issue
Block a user