disabled topic and synapse creation on public map that's not yours

This commit is contained in:
Connor Turland 2014-03-03 03:05:59 -08:00
parent d89dddb45c
commit 1c5a57d67c
3 changed files with 54 additions and 41 deletions

View file

@ -338,36 +338,41 @@ function selectNodeOnClickHandler(node, e) {
} //selectNodeOnRightClickHandler } //selectNodeOnRightClickHandler
function canvasDoubleClickHandler(canvasLoc,e) { function canvasDoubleClickHandler(canvasLoc,e) {
//grab the location and timestamp of the click //grab the location and timestamp of the click
var storedTime = MetamapsModel.lastCanvasClick; var storedTime = MetamapsModel.lastCanvasClick;
var now = Date.now(); //not compatible with IE8 FYI var now = Date.now(); //not compatible with IE8 FYI
MetamapsModel.lastCanvasClick = now; MetamapsModel.lastCanvasClick = now;
if (now - storedTime < MetamapsModel.DOUBLE_CLICK_TOLERANCE) { // if on a public map, disable topic creation
//pop up node creation :) if (userid && (mapperm || !mapid) ) {
$('#topic_grabTopic').val("null"); if (now - storedTime < MetamapsModel.DOUBLE_CLICK_TOLERANCE) {
$('#topic_addSynapse').val("false"); //pop up node creation :)
$('#new_topic').css('left', e.clientX + "px"); $('#topic_grabTopic').val("null");
$('#new_topic').css('top', e.clientY + "px"); $('#topic_addSynapse').val("false");
$('#topic_x').val(canvasLoc.x); $('#new_topic').css('left', e.clientX + "px");
$('#topic_y').val(canvasLoc.y); $('#new_topic').css('top', e.clientY + "px");
$('#new_topic').fadeIn('fast'); $('#topic_x').val(canvasLoc.x);
$('#topic_name').focus(); $('#topic_y').val(canvasLoc.y);
} else { $('#new_topic').fadeIn('fast');
$('#new_topic').fadeOut('fast'); $('#topic_name').typeahead('setQuery','').focus();
$('#new_synapse').fadeOut('fast'); return;
// reset the draw synapse positions to false }
MetamapsModel.synapseStartCoord = false; }
MetamapsModel.synapseEndCoord = false;
// set all node dimensions back to normal $('#new_topic').fadeOut('fast');
Mconsole.graph.eachNode(function (n) { $('#new_synapse').fadeOut('fast');
n.setData('dim', 25, 'current'); // reset the draw synapse positions to false
}); MetamapsModel.synapseStartCoord = false;
tempInit = false; MetamapsModel.synapseEndCoord = false;
tempNode = null; // set all node dimensions back to normal
tempNode2 = null; Mconsole.graph.eachNode(function (n) {
Mconsole.plot(); n.setData('dim', 25, 'current');
} });
tempInit = false;
tempNode = null;
tempNode2 = null;
Mconsole.plot();
}//canvasDoubleClickHandler }//canvasDoubleClickHandler
function handleSelectionBeforeDragging(node, e) { function handleSelectionBeforeDragging(node, e) {
@ -459,6 +464,10 @@ function onDragMoveTopicHandler(node, eventInfo, e) {
} }
// if it's a right click or holding down alt, start synapse creation ->third option is for firefox // 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) && userid != null) { else if ((e.button == 2 || (e.button == 0 && e.altKey) || e.buttons == 2) && userid != null) {
// if on a public map, disable synapse creation
if (mapid && !mapperm) return;
if (tempInit == false) { if (tempInit == false) {
tempNode = node; tempNode = node;
tempInit = true; tempInit = true;

View file

@ -8328,7 +8328,7 @@ Layouts.ForceDirected = new Class({
return; return;
} }
} }
incremental.onStep(Math.round(i /(times -1) * 100)); incremental.onStep(Math.round((i)/(times -1) * 100));
setTimeout(iter, 1); setTimeout(iter, 1);
})(); })();
} else { } else {

View file

@ -15,20 +15,22 @@
<div class="sidebarSaveBox"></div> <div class="sidebarSaveBox"></div>
</div> </div>
<% end %> <% end %>
<div class="sidebarFork"> <div class="sidebarFork">
<div class="sidebarForkIcon hoverForTip"> <div class="sidebarForkIcon hoverForTip">
<div class="tip">Save To New Map</div> <div class="tip">Save To New Map</div>
</div>
<div class="sidebarForkBox"></div>
</div> </div>
<div class="sidebarForkBox"></div> <% if @map.permission == "commons" || @map.user == user %>
</div> <div class="sidebarCollaborate">
<div class="sidebarCollaborate"> <div class="sidebarCollaborateIcon hoverForTip">
<div class="sidebarCollaborateIcon hoverForTip"> <div class="tip">Start Realtime Collaboration</div>
<div class="tip">Start Realtime Collaboration</div> </div>
</div> <div class="sidebarCollaborateBox">
<div class="sidebarCollaborateBox">
</div>
</div> </div>
</div> <% end %>
<% end %> <% end %>
<div class="sidebarFilter <%= authenticated? ? 'loggedin' : 'loggedout' %>"> <div class="sidebarFilter <%= authenticated? ? 'loggedin' : 'loggedout' %>">
<div class="sidebarFilterIcon"></div> <div class="sidebarFilterIcon"></div>
@ -57,8 +59,10 @@
<div class="clearfloat"></div> <div class="clearfloat"></div>
<% if authenticated? %> <% if authenticated? %>
<%= render :partial => 'newtopic' %> <% if @map.permission == "commons" || @map.user == user %>
<%= render :partial => 'newsynapse' %> <%= render :partial => 'newtopic' %>
<%= render :partial => 'newsynapse' %>
<% end %>
<%= render :partial => 'main/metacodeoptions' %> <%= render :partial => 'main/metacodeoptions' %>
<% # for saving layouts %> <% # for saving layouts %>