From ee1ca7853f5bd4d54b9e3580ebf72a6028288425 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Mon, 3 Nov 2014 08:46:22 -0500 Subject: [PATCH] removed embed. fixed switch metacode set lightbox overflow. disabled topic creation and topic deletion from public maps by non-owner --- app/assets/javascripts/src/Metamaps.JIT.js | 84 +++++++++----- app/assets/javascripts/src/Metamaps.js | 123 +++++++++++++++++---- app/assets/stylesheets/application.css | 18 ++- app/assets/stylesheets/base.css | 1 + app/controllers/maps_controller.rb | 29 +---- app/controllers/topics_controller.rb | 8 +- app/views/maps/embed.html.erb | 83 -------------- app/views/shared/_switchmetacodes.html.erb | 16 +-- config/routes.rb | 1 - 9 files changed, 191 insertions(+), 172 deletions(-) delete mode 100644 app/views/maps/embed.html.erb 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 = '