diff --git a/public/js/keybinds.js b/public/js/keybinds.js index f2b9c61..344d2d0 100644 --- a/public/js/keybinds.js +++ b/public/js/keybinds.js @@ -15,7 +15,9 @@ var keybinds = { 'defmod-l' : 'setTool_line', 'defmod-r' : 'setTool_rect', 'defmod-c' : 'setTool_circle', - 'defmod-d' : 'switchLineRecCircle', + 'shift-f' : 'toggleLineRecCircle', + 'shift-p' : 'togglePenEraser', + 'shift-r' : 'toggleMainColors', 'defmod-a' : 'setTool_text', 'defmod-e' : 'setTool_eraser', 'defmod-up' : 'thickness_bigger', @@ -28,7 +30,7 @@ var keybinds = { 'shift-4' : 'setDrawColorRed', 'defmod-s' : 'saveWhiteboardAsImage', 'defmod-j' : 'saveWhiteboardAsJson', - 'defmod-w' : 'uploadWhiteboardToWebDav', + 'shift-w' : 'uploadWhiteboardToWebDav', 'shift-j' : 'uploadJsonToWhiteboard', 'shift-s' : 'shareWhiteboard', 'tab' : 'hideShowControls', @@ -37,6 +39,7 @@ var keybinds = { 'left' : 'moveDraggableLeft', 'right' : 'moveDraggableRight', 'enter' : 'dropDraggable', + 'shift-enter' : 'addToBackground', 'escape' : 'cancelAllActions', 'del' : 'deleteSelection' } \ No newline at end of file diff --git a/public/js/main.js b/public/js/main.js index 45252c7..fa427bf 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -114,7 +114,7 @@ $(document).ready(function () { }, openColorPicker: function () { $("#whiteboardColorpicker").click(); }, saveWhiteboardAsImage: function () { $("#saveAsImageBtn").click(); }, - saveWhiteboardAsJson: function () { $("#saveAsImageBtn").click(); }, + saveWhiteboardAsJson: function () { $("#saveAsJSONBtn").click(); }, uploadWhiteboardToWebDav: function () { $("#uploadWebDavBtn").click(); }, uploadJsonToWhiteboard: function () { $("#uploadJsonBtn").click(); }, shareWhiteboard: function () { $("#shareWhiteboardBtn").click(); }, @@ -146,7 +146,7 @@ $(document).ready(function () { $("#whiteboardColorpicker").css({ "background": "yellow" }); }, - switchLineRecCircle: function () { + toggleLineRecCircle: function () { var activeTool = $(".whiteboardTool.active").attr("tool"); if (activeTool == "line") { $(".whiteboardTool[tool=rect]").click(); @@ -156,25 +156,54 @@ $(document).ready(function () { $(".whiteboardTool[tool=line]").click(); } }, + togglePenEraser: function () { + var activeTool = $(".whiteboardTool.active").attr("tool"); + if (activeTool == "pen") { + $(".whiteboardTool[tool=eraser]").click(); + } else { + $(".whiteboardTool[tool=pen]").click(); + } + }, + toggleMainColors: function () { + var bgColor = $("#whiteboardColorpicker")[0].style.backgroundColor; + if (bgColor == "blue") { + shortcutFunctions.setDrawColorGreen(); + } else if (bgColor == "green") { + shortcutFunctions.setDrawColorYellow(); + } else if (bgColor == "yellow") { + shortcutFunctions.setDrawColorRed(); + } else if (bgColor == "red") { + shortcutFunctions.setDrawColorBlack(); + } else { + shortcutFunctions.setDrawColorBlue(); + } + }, moveDraggableUp: function () { - var p = $($(".ui-draggable")[0]).position(); - $($(".ui-draggable")[0]).css({ top: p.top - 5, left: p.left }) + var elm = whiteboard.tool == "text" ? $("#"+whiteboard.latestActiveTextBoxId) : $(".dragMe")[0]; + var p = $(elm).position(); + $(elm).css({ top: p.top - 5, left: p.left }) }, moveDraggableDown: function () { - var p = $($(".ui-draggable")[0]).position(); - $($(".ui-draggable")[0]).css({ top: p.top + 5, left: p.left }) + var elm = whiteboard.tool == "text" ? $("#"+whiteboard.latestActiveTextBoxId) : $(".dragMe")[0]; + var p = $(elm).position(); + $(elm).css({ top: p.top + 5, left: p.left }) }, moveDraggableLeft: function () { - var p = $($(".ui-draggable")[0]).position(); - $($(".ui-draggable")[0]).css({ top: p.top, left: p.left - 5 }) + var elm = whiteboard.tool == "text" ? $("#"+whiteboard.latestActiveTextBoxId) : $(".dragMe")[0]; + var p = $(elm).position(); + $(elm).css({ top: p.top, left: p.left - 5 }) }, moveDraggableRight: function () { - var p = $($(".ui-draggable")[0]).position(); - $($(".ui-draggable")[0]).css({ top: p.top, left: p.left + 5 }) + var elm = whiteboard.tool == "text" ? $("#"+whiteboard.latestActiveTextBoxId) : $(".dragMe")[0]; + var p = $(elm).position(); + $(elm).css({ top: p.top, left: p.left + 5 }) }, dropDraggable: function () { - var p = $($(".ui-draggable")[0]).find('.addToCanvasBtn').click(); + $($(".dragMe")[0]).find('.addToCanvasBtn').click(); + }, + addToBackground: function () { + $($(".dragMe")[0]).find('.addToBackgroundBtn').click(); }, cancelAllActions: function () { whiteboard.escKeyAction(); }, deleteSelection: function () { whiteboard.delKeyAction(); }, diff --git a/public/js/whiteboard.js b/public/js/whiteboard.js index 3b48ec2..03ea734 100644 --- a/public/js/whiteboard.js +++ b/public/js/whiteboard.js @@ -212,7 +212,7 @@ var whiteboard = { var left = _this.startCoords[0] < currX ? _this.startCoords[0] : currX; var top = _this.startCoords[1] < currY ? _this.startCoords[1] : currY; _this.mouseOverlay.css({ "cursor": "default" }); - var imgDiv = $('