diff --git a/app/assets/javascripts/src/Metamaps.JIT.js b/app/assets/javascripts/src/Metamaps.JIT.js index 4cb4ea26..a83db26e 100644 --- a/app/assets/javascripts/src/Metamaps.JIT.js +++ b/app/assets/javascripts/src/Metamaps.JIT.js @@ -757,6 +757,8 @@ Metamaps.JIT = { var positionsToSend = {}; var topic; + var authorized = Metamaps.Active.Map && Metamaps.Active.Map.authorizeToEdit(Metamaps.Active.Mapper); + if (node && !node.nodeFrom) { var pos = eventInfo.getPos(); // if it's a left click, or a touch, move the node @@ -821,7 +823,7 @@ Metamaps.JIT = { Metamaps.Visualize.mGraph.plot(); } // if it's a right click or holding down alt, start synapse creation ->third option is for firefox - else if ((e.button == 2 || (e.button == 0 && e.altKey) || e.buttons == 2) && Metamaps.Active.Mapper) { + else if ((e.button == 2 || (e.button == 0 && e.altKey) || e.buttons == 2) && authorized) { if (tempInit == false) { tempNode = node; tempInit = true; @@ -886,6 +888,9 @@ Metamaps.JIT = { $(document).trigger(Metamaps.JIT.events.mouseMove, [pos]); } } + else if ((e.button == 2 || (e.button == 0 && e.altKey) || e.buttons == 2) && !authorized) { + Metamaps.GlobalUI.notifyUser("Cannot edit Public map."); + } } }, // onDragMoveTopicHandler onDragCancelHandler: function (node, eventInfo, e) { @@ -927,6 +932,9 @@ Metamaps.JIT = { // check whether to save mappings var checkWhetherToSave = function() { var map = Metamaps.Active.Map; + + if (!map) return false; + var mapper = Metamaps.Active.Mapper; // this case // covers when it is a public map owned by you @@ -967,7 +975,13 @@ Metamaps.JIT = { var now = Date.now(); //not compatible with IE8 FYI Metamaps.Mouse.lastCanvasClick = now; + var authorized = Metamaps.Active.Map && Metamaps.Active.Map.authorizeToEdit(Metamaps.Active.Mapper); + if (now - storedTime < Metamaps.Mouse.DOUBLE_CLICK_TOLERANCE && !Metamaps.Mouse.didPan) { + if (Metamaps.Active.Map && !authorized) { + Metamaps.GlobalUI.notifyUser("Cannot edit Public map."); + return; + } // DOUBLE CLICK //pop up node creation :) Metamaps.Create.newTopic.addSynapse = false; @@ -1269,12 +1283,16 @@ Metamaps.JIT = { // add the proper options to the menu var menustring = '