2013-01-11 23:49:59 +00:00
|
|
|
<%#
|
|
|
|
# @file
|
|
|
|
# Code to display a map
|
2013-01-23 18:55:50 +00:00
|
|
|
# /maps/:id
|
2013-01-11 23:49:59 +00:00
|
|
|
#%>
|
2013-07-09 16:32:13 +00:00
|
|
|
|
|
|
|
<% content_for :title, @map.name + " | Metamaps" %>
|
2013-01-06 23:40:48 +00:00
|
|
|
|
2014-01-31 00:32:15 +00:00
|
|
|
<% if authenticated? %>
|
2014-02-09 15:05:32 +00:00
|
|
|
<% if @map.permission == "commons" || @map.user == user %>
|
|
|
|
<div class="sidebarSave">
|
|
|
|
<div class="sidebarSaveIcon"></div>
|
|
|
|
<div class="sidebarSaveBox"></div>
|
|
|
|
</div>
|
|
|
|
<% end %>
|
|
|
|
<div class="sidebarFork">
|
|
|
|
<div class="sidebarForkIcon"></div>
|
|
|
|
<div class="sidebarForkBox"></div>
|
2014-01-31 00:32:15 +00:00
|
|
|
</div>
|
2014-02-01 08:57:19 +00:00
|
|
|
<div class="sidebarCollaborate">
|
|
|
|
<div class="sidebarCollaborateIcon"></div>
|
|
|
|
<div class="sidebarCollaborateBox">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
2014-01-31 00:32:15 +00:00
|
|
|
<% end %>
|
2014-02-03 05:35:21 +00:00
|
|
|
<div class="sidebarFilter <%= authenticated? ? 'loggedin' : 'loggedout' %>">
|
2014-02-01 08:57:19 +00:00
|
|
|
<div class="sidebarFilterIcon"></div>
|
|
|
|
<div class="sidebarFilterBox">
|
|
|
|
<h3 class="filterByMetacode">Filter By Metacode</h3><span class="showAll">all</span><span class="hideAll">none</span>
|
|
|
|
<div class="clearfloat"></div>
|
|
|
|
<%= render :partial => 'main/filterbymetacode' %>
|
|
|
|
</div>
|
|
|
|
</div>
|
2013-01-06 23:40:48 +00:00
|
|
|
|
2014-01-29 03:46:58 +00:00
|
|
|
<div class="index">
|
2014-02-05 05:03:44 +00:00
|
|
|
<div class="openCheatsheet openLightbox" data-open="cheatsheet"></div>
|
2014-01-29 03:46:58 +00:00
|
|
|
<span><img width="35" height="35" src="/assets/map.png"></span>
|
|
|
|
<span class="mapName"><%= @map.name %></span>
|
|
|
|
<span class="mapInfo"></span>
|
|
|
|
<div class="clearfloat"></div>
|
2014-02-04 01:43:31 +00:00
|
|
|
<%= render :partial => 'maps/mapinfobox' %>
|
2014-01-29 03:46:58 +00:00
|
|
|
</div>
|
2012-10-26 10:04:52 +00:00
|
|
|
|
2013-01-05 02:39:16 +00:00
|
|
|
<div class="maps onMap" id="container">
|
2012-10-26 10:04:52 +00:00
|
|
|
<div id="center-container">
|
|
|
|
<div id="infovis"></div>
|
|
|
|
</div>
|
2013-03-17 09:18:30 +00:00
|
|
|
<div class="showcard" id="showcard"></div>
|
2012-10-26 10:04:52 +00:00
|
|
|
</div>
|
|
|
|
<div class="clearfloat"></div>
|
|
|
|
|
2013-01-05 02:39:16 +00:00
|
|
|
<% if authenticated? %>
|
|
|
|
<%= render :partial => 'newtopic' %>
|
|
|
|
<%= render :partial => 'newsynapse' %>
|
2014-02-09 23:54:45 +00:00
|
|
|
<%= render :partial => 'main/metacodeoptions' %>
|
2014-01-31 00:32:15 +00:00
|
|
|
|
|
|
|
<% # for saving layouts %>
|
|
|
|
<% if @map.permission == "commons" || @map.user == user %>
|
|
|
|
<%= form_for @map, :url => savelayout_path(@map), :html => { :class => "saveMapLayout", :id => "saveMapLayout"}, remote: true do |form| %>
|
|
|
|
<%= form.hidden_field "coordinates", :value => "" %>
|
|
|
|
<% end %>
|
|
|
|
<% end %>
|
2013-01-05 02:39:16 +00:00
|
|
|
<% end %>
|
2013-01-08 04:40:58 +00:00
|
|
|
|
2013-01-05 02:39:16 +00:00
|
|
|
<script>
|
2014-01-31 00:32:15 +00:00
|
|
|
$(document).ready(function() {
|
|
|
|
function bindWandHover() {
|
|
|
|
|
|
|
|
var wandIsOpen = false
|
|
|
|
|
|
|
|
// controls the sliding hover of the bottom left menu
|
|
|
|
var sliding1 = false;
|
|
|
|
var lT;
|
|
|
|
|
|
|
|
var closeWand = function() {
|
|
|
|
lT = setTimeout(function() {
|
|
|
|
if (! sliding1) {
|
|
|
|
sliding1 = true;
|
2014-02-06 20:16:51 +00:00
|
|
|
$('.sidebarWandIcon').css('background-color','#0F1519');
|
2014-01-31 00:32:15 +00:00
|
|
|
$('.sidebarWandBox').fadeOut(200, function() {
|
|
|
|
sliding1 = false;
|
|
|
|
wandIsOpen = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},300);
|
|
|
|
}
|
|
|
|
|
|
|
|
var openWand = function() {
|
|
|
|
clearTimeout(lT);
|
|
|
|
if (! sliding1) {
|
|
|
|
sliding1 = true;
|
2014-02-01 08:57:19 +00:00
|
|
|
|
|
|
|
// hide the other two
|
|
|
|
$('.sidebarAccountBox').hide();
|
|
|
|
$('.sidebarFilterBox').hide();
|
2014-02-06 20:16:51 +00:00
|
|
|
$('.sidebarFilterIcon').css('background-color','#0F1519');
|
|
|
|
$('.sidebarAccountIcon').css('background-color','#0F1519');
|
2014-02-01 08:57:19 +00:00
|
|
|
|
2014-02-06 20:16:51 +00:00
|
|
|
$('.sidebarWandIcon').css('background-color','#000');
|
2014-01-31 00:32:15 +00:00
|
|
|
$('.sidebarWandBox').fadeIn(200, function() {
|
|
|
|
sliding1 = false;
|
|
|
|
wandIsOpen = true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// bind the hover events
|
|
|
|
$(".sidebarWand").hover(openWand, closeWand);
|
|
|
|
|
|
|
|
// attach events for clicking on wand actions
|
|
|
|
$('li.wandSaveLayout').click(function() {
|
|
|
|
saveLayoutAll();
|
|
|
|
});
|
|
|
|
$('li.wandForkMap').click(function() {
|
|
|
|
saveToMap();
|
|
|
|
closeWand();
|
|
|
|
});
|
|
|
|
$('li.wandFilter').click(function() {
|
|
|
|
return;
|
|
|
|
});
|
|
|
|
|
2014-02-01 08:57:19 +00:00
|
|
|
} // end bindWandHover
|
|
|
|
|
|
|
|
function bindFilterHover() {
|
|
|
|
|
|
|
|
var filterIsOpen = false
|
|
|
|
|
|
|
|
// controls the sliding hover of the bottom left menu
|
|
|
|
var sliding1 = false;
|
|
|
|
var lT;
|
|
|
|
|
|
|
|
var closeFilter = function() {
|
|
|
|
lT = setTimeout(function() {
|
|
|
|
if (! sliding1) {
|
|
|
|
sliding1 = true;
|
2014-02-06 20:16:51 +00:00
|
|
|
$('.sidebarFilterIcon').css('background-color','#0F1519');
|
2014-02-01 08:57:19 +00:00
|
|
|
$('.sidebarFilterBox').fadeOut(200, function() {
|
|
|
|
sliding1 = false;
|
|
|
|
filterIsOpen = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},300);
|
|
|
|
}
|
|
|
|
|
|
|
|
var openFilter = function() {
|
|
|
|
clearTimeout(lT);
|
|
|
|
if (! sliding1) {
|
|
|
|
sliding1 = true;
|
|
|
|
|
|
|
|
// hide the other two
|
|
|
|
$('.sidebarAccountBox').hide();
|
|
|
|
$('.sidebarWandBox').hide();
|
2014-02-06 20:16:51 +00:00
|
|
|
$('.sidebarAccountIcon').css('background-color','#0F1519');
|
|
|
|
$('.sidebarWandIcon').css('background-color','#0F1519');
|
2014-02-01 08:57:19 +00:00
|
|
|
|
2014-02-06 20:16:51 +00:00
|
|
|
$('.sidebarFilterIcon').css('background-color','#000');
|
2014-02-01 08:57:19 +00:00
|
|
|
$('.sidebarFilterBox').fadeIn(200, function() {
|
|
|
|
sliding1 = false;
|
|
|
|
filterIsOpen = true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// bind the hover events
|
|
|
|
$(".sidebarFilter").hover(openFilter, closeFilter);
|
|
|
|
|
|
|
|
} // end bindFilterHover
|
2014-02-04 01:43:31 +00:00
|
|
|
|
|
|
|
function bindInfoHover() {
|
|
|
|
|
|
|
|
var infoIsOpen = false
|
|
|
|
|
|
|
|
// controls the sliding hover of the bottom left menu
|
|
|
|
var sliding1 = false;
|
|
|
|
var lT;
|
|
|
|
|
|
|
|
var closeInfo = function() {
|
|
|
|
lT = setTimeout(function() {
|
|
|
|
if (! sliding1) {
|
|
|
|
sliding1 = true;
|
|
|
|
$('.mapInfoBox').fadeOut(200, function() {
|
|
|
|
sliding1 = false;
|
|
|
|
infoIsOpen = false;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
},300);
|
|
|
|
}
|
|
|
|
|
|
|
|
var openInfo = function(event) {
|
|
|
|
clearTimeout(lT);
|
2014-02-06 20:16:51 +00:00
|
|
|
if (! sliding1 && event.target.className != "openCheatsheet openLightbox") {
|
2014-02-04 01:43:31 +00:00
|
|
|
sliding1 = true;
|
|
|
|
|
|
|
|
$('.mapInfoBox').fadeIn(200, function() {
|
|
|
|
sliding1 = false;
|
|
|
|
infoIsOpen = true;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// bind the hover events
|
|
|
|
$("div.index").hover(openInfo, closeInfo);
|
|
|
|
|
|
|
|
|
|
|
|
} // end bindWandHover
|
2014-01-31 00:32:15 +00:00
|
|
|
bindWandHover();
|
2014-02-01 08:57:19 +00:00
|
|
|
bindFilterHover();
|
2014-02-04 01:43:31 +00:00
|
|
|
bindInfoHover();
|
2014-02-01 08:57:19 +00:00
|
|
|
|
2014-02-05 01:28:06 +00:00
|
|
|
$(".sidebarCollaborateIcon").click(function(event) {
|
|
|
|
goRealtime = !goRealtime;
|
|
|
|
$(".sidebarCollaborateIcon").toggleClass("blue");
|
|
|
|
});
|
|
|
|
|
2014-02-04 19:55:26 +00:00
|
|
|
// initialize best_in_place editing
|
|
|
|
$('.authenticated div.permission.canEdit .best_in_place').best_in_place();
|
|
|
|
|
2014-02-03 05:35:21 +00:00
|
|
|
$('.showcard').draggable({ handle: ".metacodeImage" });
|
2014-02-01 08:57:19 +00:00
|
|
|
$('#showcard').resizable({
|
|
|
|
maxHeight: 500,
|
|
|
|
maxWidth: 500,
|
|
|
|
minHeight: 320,
|
|
|
|
minWidth: 226
|
|
|
|
}).css({
|
|
|
|
display: 'none',
|
|
|
|
top: '300px',
|
|
|
|
left: '100px'
|
|
|
|
});
|
|
|
|
|
2014-01-31 00:32:15 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
|
2013-01-05 02:39:16 +00:00
|
|
|
var dragged = 0;
|
|
|
|
mapid = <%= @map.id %>;
|
2013-01-25 05:47:32 +00:00
|
|
|
<% if (@map.permission == "commons" && authenticated?) || @map.user == user %>
|
|
|
|
mapperm = true;
|
|
|
|
<% end %>
|
2013-04-26 04:07:29 +00:00
|
|
|
|
2012-12-15 07:39:14 +00:00
|
|
|
viewMode = "graph";
|
2012-10-26 10:04:52 +00:00
|
|
|
json = <%= @mapjson %>;
|
|
|
|
if (json.length > 0) {
|
2014-01-29 03:46:58 +00:00
|
|
|
$(window).load(function() {
|
2012-12-03 23:40:14 +00:00
|
|
|
<% if (@map.arranged) %>
|
2012-12-14 18:31:39 +00:00
|
|
|
initialize("arranged");
|
2012-12-03 23:40:14 +00:00
|
|
|
<% else %>
|
2012-12-14 18:31:39 +00:00
|
|
|
initialize("chaotic");
|
2012-12-03 23:40:14 +00:00
|
|
|
<% end %>
|
2012-10-26 10:04:52 +00:00
|
|
|
});
|
|
|
|
}
|
2012-12-25 23:29:20 +00:00
|
|
|
else {
|
2014-01-29 03:46:58 +00:00
|
|
|
$(window).load(function() {
|
2012-12-25 23:29:20 +00:00
|
|
|
initialize("chaotic", true);
|
|
|
|
});
|
|
|
|
}
|
2014-02-09 15:05:32 +00:00
|
|
|
/*window.realtime.socket = io.connect('http://gentle-savannah-1303.herokuapp.com');
|
2014-02-04 19:55:26 +00:00
|
|
|
window.realtime.socket.on('connect', function() {
|
|
|
|
subscribeToRooms();
|
|
|
|
console.log('socket connected');
|
2014-02-09 15:05:32 +00:00
|
|
|
});*/
|
2013-04-26 04:07:29 +00:00
|
|
|
function subscribeToRooms() {
|
2014-02-04 19:55:26 +00:00
|
|
|
window.realtime.socket.on('maps-' + mapid, function(data) {
|
2013-04-26 04:07:29 +00:00
|
|
|
//as long as you weren't the origin of the changes, update your map
|
|
|
|
if (data.origin != userid && goRealtime) {
|
|
|
|
if (data.resource == 'Topic') {
|
|
|
|
topic = $.parseJSON(data.obj);
|
|
|
|
|
|
|
|
if (data.action == 'create') {
|
2014-02-04 19:55:26 +00:00
|
|
|
window.realtime.addTopicToMap(topic);
|
2013-04-26 04:07:29 +00:00
|
|
|
}
|
|
|
|
else if (data.action == 'update' && Mconsole.graph.getNode(topic.id) != 'undefined') {
|
2014-02-04 19:55:26 +00:00
|
|
|
window.realtime.updateTopicOnMap(topic);
|
2013-04-26 04:07:29 +00:00
|
|
|
}
|
|
|
|
else if (data.action == 'destroy' && Mconsole.graph.getNode(topic.id) != 'undefined') {
|
|
|
|
hideNode(topic.id)
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else if (data.resource == 'Synapse') {
|
|
|
|
synapse = $.parseJSON(data.obj);
|
|
|
|
|
|
|
|
if (data.action == 'create') {
|
2014-02-04 19:55:26 +00:00
|
|
|
window.realtime.addSynapseToMap(synapse);
|
2013-04-26 04:07:29 +00:00
|
|
|
}
|
|
|
|
else if (data.action == 'update' &&
|
|
|
|
Mconsole.graph.getAdjacence(synapse.data.$direction['0'], synapse.data.$direction['1']) != 'undefined') {
|
2014-02-04 19:55:26 +00:00
|
|
|
window.realtime.updateSynapseOnMap(synapse);
|
2013-04-26 04:07:29 +00:00
|
|
|
}
|
|
|
|
else if (data.action == 'destroy' &&
|
|
|
|
Mconsole.graph.getAdjacence(synapse.data.$direction['0'], synapse.data.$direction['1']) != 'undefined') {
|
|
|
|
var edge = Mconsole.graph.getAdjacence(synapse.data.$direction['0'], synapse.data.$direction['1']);
|
|
|
|
hideEdge(edge);
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2014-01-29 03:46:58 +00:00
|
|
|
</script>
|