This commit is contained in:
Bashar Jabbour 2014-10-07 14:47:18 -04:00
commit e3c677fa5b
25 changed files with 639 additions and 526 deletions

View file

@ -37,7 +37,7 @@ Driessen][git-branching-model]. Here's an overview:
Metamaps developers should be basing their work on. The `master` branch is not guaranteed to be stable.
* All commits intended for `master` should take place on your own personal
fork, and be submitted via pull request when ready.
* Only maintainers can accept pull requests from forks into the core Famo.us
* Only maintainers can accept pull requests from forks into the core Metamaps.cc
repository.
* Please squash your commits into a single commit before making a pull request.
@ -68,10 +68,11 @@ TODO
### Branch grouping tokens
All pull requests submitted to Famo.us should occur on a new branch. For these
All pull requests submitted to Metamaps.cc should occur on a new branch. For these
branches, we at metamaps use a short token indicating the nature of the branch in
question followed by a solidus (`/`) and a kebab-cased string describing the
branch. We are using the following tokens:
**NOTE: Not sure the above is right, but also not sure what to change it to **
bug // bug fixes
wip // work in progress

View file

@ -19,7 +19,7 @@ gem 'json'
gem 'rails3-jquery-autocomplete'
gem 'best_in_place'
gem 'kaminari' # pagination
gem 'uservoice-ruby'
gem 'paperclip'
gem 'aws-sdk'

View file

@ -58,6 +58,7 @@ GEM
warden (~> 1.2.3)
erubis (2.7.0)
execjs (2.0.2)
ezcrypto (0.7.2)
formtastic (2.2.1)
actionpack (>= 3.0)
formula (1.0.1)
@ -84,6 +85,7 @@ GEM
mini_portile (= 0.6.0)
nokogiri (1.6.2.1-x86-mingw32)
mini_portile (= 0.6.0)
oauth (0.4.7)
orm_adapter (0.5.0)
paperclip (4.1.1)
activemodel (>= 3.0.0)
@ -141,6 +143,10 @@ GEM
uglifier (2.5.0)
execjs (>= 0.3.0)
json (>= 1.8.0)
uservoice-ruby (0.0.11)
ezcrypto (>= 0.7.2)
json (>= 1.7.5)
oauth (>= 0.4.7)
warden (1.2.3)
rack (>= 1.0)
@ -167,3 +173,4 @@ DEPENDENCIES
redis (= 2.2.2)
sass-rails
uglifier (>= 1.0.3)
uservoice-ruby

View file

@ -3,7 +3,7 @@ if(BAROMETER == undefined) {
BAROMETER = {};
}
BAROMETER.load = function(barometer_id) {
//BAROMETER.load = function(barometer_id) {
this.barometer_id = barometer_id;
this.empty_url = "http://getbarometer.s3.amazonaws.com/assets/barometer/images/transparent.gif";
this.feedback_url = 'http://getbarometer.com/system/feedback_form/' + this.barometer_id;

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -0,0 +1,49 @@
var USERVOICE;
if(USERVOICE == undefined) {
USERVOICE = {};
}
USERVOICE.load = function (barometer_id) {
// Include the UserVoice JavaScript SDK (only needed once on a page)
UserVoice=window.UserVoice||[];(function(){var uv=document.createElement('script');uv.type='text/javascript';uv.async=true;uv.src='//widget.uservoice.com/wybK0nSMNuhlWkIKzTyWg.js';var s=document.getElementsByTagName('script')[0];s.parentNode.insertBefore(uv,s)})();
//
// UserVoice Javascript SDK developer documentation:
// https://www.uservoice.com/o/javascript-sdk
//
// Set colors
UserVoice.push(['set', {
accent_color: '#448dd6',
trigger_color: 'white',
trigger_background_color: 'rgba(46, 49, 51, 0.6)'
}]);
// Identify the user and pass traits
// To enable, replace sample data with actual user traits and uncomment the line
//TODO NEED HELP HERE MAKING SURE CORRECT USER DATA GETS PUSHED
UserVoice.push(['identify', {
//email: 'getElementsByTagName(userid)', // Users email address
name: "userid", // Users real name
//created_at: 1364406966, // Unix timestamp for the date the user signed up
id: "Metamaps.Active.Mapper.id", // Optional: Unique id of the user (if set, this should not change)
//type: 'Owner', // Optional: segment your users by type
//account: {
// id: 123, // Optional: associate multiple users with a single account
// name: 'Acme, Co.', // Account name
// created_at: 1364406966, // Unix timestamp for the date the account was created
// monthly_rate: 9.99, // Decimal; monthly rate of the account
// ltv: 1495.00, // Decimal; lifetime value of the account
// plan: 'Enhanced' // Plan name for the account
//}
}]);
// Add default trigger to the bottom-right corner of the window:
UserVoice.push(['addTrigger', { mode: 'contact', trigger_position: 'bottom-left' }]);
// Or, use your own custom trigger:
//UserVoice.push(['addTrigger', '#barometer_tab', { mode: 'contact' }]);
// Autoprompt for Satisfaction and SmartVote (only displayed under certain conditions)
UserVoice.push(['autoprompt', {}]);
};

View file

@ -8405,7 +8405,11 @@ $jit.RGraph = new Class( {
*/
refresh: function(){
this.compute();
// START METAMAPS CODE
// this.compute();
// END METAMAPS CODE
// ORIGINAL CODE: this.compute();
this.plot();
},
@ -9119,7 +9123,10 @@ $jit.ForceDirected = new Class( {
Computes positions and plots the tree.
*/
refresh: function() {
this.compute();
// START METAMAPS CODE
// this.compute();
// END METAMAPS CODE
// ORIGINAL CODE: this.compute();
this.plot();
},

View file

@ -373,29 +373,7 @@ Metamaps.GlobalUI.Search = {
self.close(0, true);
}
break;
case 65:
case 97:
if (e.ctrlKey){
Metamaps.Control.deselectAllNodes();
Metamaps.Control.deselectAllEdges();
e.preventDefault();
Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
Metamaps.Control.selectNode(n,e);
});
Metamaps.Visualize.mGraph.plot();
}
break;
case 69:
case 101:
if (e.ctrlKey){
e.preventDefault();
Metamaps.JIT.zoomExtents();
}
break;
default:
break; //console.log(e.which);
}
@ -424,7 +402,6 @@ Metamaps.GlobalUI.Search = {
padding: '7px 10px 3px 10px',
width: '380px'
});
$('.sidebarSearchField').focus();
self.changing = false;
self.isOpen = true;
});
@ -451,11 +428,6 @@ Metamaps.GlobalUI.Search = {
});
}
}, closeAfter);
/*if (self.locked) {
$('.sidebarSearchField').typeahead('setQuery', '');
$('.sidebarSearchField').blur();
}*/
},
startTypeahead: function () {
var self = Metamaps.GlobalUI.Search;

View file

@ -97,7 +97,20 @@ Metamaps.JIT = {
var pos = adj.nodeFrom.pos.getc(true);
var posChild = adj.nodeTo.pos.getc(true);
var synapse = adj.getData("synapses")[0]; // for now, just grab the first synapse
var synapse;
if(adj.getData("displayIndex")) {
synapse = adj.getData("synapses")[adj.getData("displayIndex")];
if (!synapse) {
delete adj.data.$displayIndex;
synapse = adj.getData("synapses")[0];
}
}
else {
synapse = adj.getData("synapses")[0];
}
if (!synapse) return; // this means there are no corresponding synapses for
// this edge, don't render it
var directionCat = synapse.get("category");
@ -568,7 +581,12 @@ Metamaps.JIT = {
levelDistance: 200
},
onMouseEnter: function (edge) {
if (edge.getData('alpha') === 0) return; // don't do anything if the edge is filtered
var filtered = edge.getData('alpha') === 0;
// don't do anything if the edge is filtered
// or if the canvas is animating
if (filtered || Metamaps.Visualize.mGraph.busy) return;
$('canvas').css('cursor', 'pointer');
var edgeIsSelected = Metamaps.Selected.Edges.indexOf(edge);
//following if statement only executes if the edge being hovered over is not selected
@ -1089,17 +1107,22 @@ Metamaps.JIT = {
}
//The test synapse was selected!
// make sure the edge hasn't been hidden from the page
var node1id = synapse.get('edge').nodeFrom.id;
var node2id = synapse.get('edge').nodeTo.id;
var edge = Metamaps.Visualize.mGraph.graph.getAdjacence(node1id, node2id);
if(selectTest){
if(e.ctrlKey){
if(Metamaps.Selected.Edges.indexOf(synapse.get('edge')) != -1 ){
Metamaps.Control.deselectEdge(synapse.get('edge'));
}
else{
Metamaps.Control.selectEdge(synapse.get('edge'));
if (edge) Metamaps.Control.selectEdge(synapse.get('edge'));
}
}
else{
Metamaps.Control.selectEdge(synapse.get('edge'));
if (edge) Metamaps.Control.selectEdge(synapse.get('edge'));
}
}
});
@ -1227,24 +1250,14 @@ Metamaps.JIT = {
top: e.clientY
});
//add the menu to the page
$('#infovis-canvaswidget').append(rightclickmenu);
$('#wrapper').append(rightclickmenu);
// attach events to clicks on the list items
// delete the selected things from the database
$('.rc-delete').click(function () {
$('.rightclickmenu').remove();
var n = Metamaps.Selected.Nodes.length;
var e = Metamaps.Selected.Edges.length;
var ntext = n == 1 ? "1 topic" : n + " topics";
var etext = e == 1 ? "1 synapse" : e + " synapses";
var text = "You have " + ntext + " and " + etext + " selected. ";
var r = confirm(text + "Are you sure you want to permanently delete them all? This will remove them from all maps they appear on.");
if (r == true) {
Metamaps.Control.deleteSelectedEdges();
Metamaps.Control.deleteSelectedNodes();
}
Metamaps.Control.deleteSelected();
});
// remove the selected things from the map
@ -1264,7 +1277,7 @@ Metamaps.JIT = {
// when in radial, center on the topic you picked
$('.rc-center').click(function () {
$('.rightclickmenu').remove();
centerOn(node.id);
Metamaps.Topic.centerOn(node.id);
});
// open the entity in a new tab
@ -1282,7 +1295,7 @@ Metamaps.JIT = {
});
// change the metacode of all the selected nodes that you have edit permission for
$('.rc-metacode li').click(function () {
$('.rc-metacode li li').click(function () {
$('.rightclickmenu').remove();
//
Metamaps.Control.updateSelectedMetacodes($(this).attr('data-id'));
@ -1378,17 +1391,7 @@ Metamaps.JIT = {
// delete the selected things from the database
$('.rc-delete').click(function () {
$('.rightclickmenu').remove();
var n = Metamaps.Selected.Nodes.length;
var e = Metamaps.Selected.Edges.length;
var ntext = n == 1 ? "1 topic" : n + " topics";
var etext = e == 1 ? "1 synapse" : e + " synapses";
var text = "You have " + ntext + " and " + etext + " selected. ";
var r = confirm(text + "Are you sure you want to permanently delete them all? This will remove them from all maps they appear on.");
if (r == true) {
Metamaps.Control.deleteSelectedEdges();
Metamaps.Control.deleteSelectedNodes();
}
Metamaps.Control.deleteSelected();
});
// remove the selected things from the map
@ -1644,6 +1647,11 @@ Metamaps.JIT = {
var ratioX = spanX / width;
var ratioY = spanY / height;
var cogX = (maxX + minX)/2;
var cogY = (maxY + minY)/2;
canvas.translate(-1* cogX, -1* cogY);
var newRatio = Math.max(ratioX,ratioY);
var scaleMultiplier = 1/newRatio*0.9;
@ -1659,43 +1667,6 @@ Metamaps.JIT = {
canvas.scale(scaleMultiplier,scaleMultiplier);
}
counter = 0;
nodes.forEach(function (n) {
var x = n.pos.x,
y = n.pos.y;
if (counter == 0){
maxX = x;
minX = x;
maxY = y;
minY = y;
}
var arrayOfLabelLines = Metamaps.Util.splitLine(n.name, 30).split('\n'),
dim = n.getData('dim'),
ctx = canvas.getCtx();
var height = 25 * arrayOfLabelLines.length;
var index, lineWidths = [];
for (index = 0; index < arrayOfLabelLines.length; ++index) {
lineWidths.push(ctx.measureText(arrayOfLabelLines[index]).width)
}
var width = Math.max.apply(null, lineWidths) + 8;
maxX = Math.max(x + width /2,maxX);
maxY = Math.max(y + n.getData("height") + 5 + height,maxY);
minX = Math.min(x - width /2,minX);
minY = Math.min(y - dim,minY);
counter++;
});
var cogX = (maxX + minX)/2;
var cogY = (maxY + minY)/2;
canvas.translate(-1* cogX, -1* cogY);
$(document).trigger(Metamaps.JIT.events.zoom, [event]);
}
else if(nodes.length == 1){

View file

@ -27,7 +27,7 @@ Metamaps.Settings = {
background: '#344A58',
synapses: {
normal: '#888888',
hover: '#222222',
hover: '#888888',
selected: '#FFFFFF'
},
topics: {
@ -40,6 +40,7 @@ Metamaps.Settings = {
}
};
Metamaps.Touch = {
touchPos: null, // this stores the x and y values of a current touch event
touchDragNode: null // this stores a reference to a JIT node that is being dragged
@ -61,6 +62,12 @@ Metamaps.Mouse = {
};
Metamaps.Selected = {
reset: function () {
var self = Metamaps.Selected;
self.Nodes = [];
self.edges = [];
},
Nodes: [],
Edges: []
};
@ -697,7 +704,7 @@ Metamaps.TopicCard = {
var setMapperImage = function (mapper) {
$('.contributorIcon').attr('src', mapper.get('image'));
};
Metamaps.Mapper.get(topic.get('user_id'), setMapperImage)
Metamaps.Mapper.get(topic.get('user_id'), setMapperImage);
// starting embed.ly
var resetFunc = function () {
@ -975,11 +982,13 @@ Metamaps.SynapseCard = {
//so label is missing while editing
Metamaps.Control.deselectEdge(edge);
var synapse = edge.getData('synapses')[0]; // for now, just get the first synapse
var index = edge.getData("displayIndex") ? edge.getData("displayIndex") : 0;
var synapse = edge.getData('synapses')[index]; // for now, just get the first synapse
//create the wrapper around the form elements, including permissions
//classes to make best_in_place happy
var edit_div = document.createElement('div');
edit_div.innerHTML = '<div id="editSynUpperBar"></div><div id="editSynLowerBar"></div>';
edit_div.setAttribute('id', 'edit_synapse');
if (synapse.authorizeToEdit(Metamaps.Active.Mapper)) {
edit_div.className = 'permission canEdit';
@ -987,9 +996,9 @@ Metamaps.SynapseCard = {
} else {
edit_div.className = 'permission cannotEdit';
}
$('.main .wrapper').append(edit_div);
$('#wrapper').append(edit_div);
self.populateShowCard(synapse);
self.populateShowCard(edge, synapse);
//drop it in the right spot, activate it
$('#edit_synapse').css('position', 'absolute');
@ -1004,7 +1013,7 @@ Metamaps.SynapseCard = {
//$('#edit_synapse_name input').focus();
$('#edit_synapse').show();
self.openSynapseCard = synapse.isNew() ? synapse.cid : synapse.id;
self.openSynapseCard = edge;
},
hideCard: function () {
@ -1012,39 +1021,43 @@ Metamaps.SynapseCard = {
Metamaps.SynapseCard.openSynapseCard = null;
},
populateShowCard: function (synapse) {
populateShowCard: function (edge, synapse) {
var self = Metamaps.SynapseCard;
self.add_name_form(synapse);
self.add_synapse_count(edge);
self.add_desc_form(synapse);
self.add_drop_down(edge, synapse);
self.add_user_info(synapse);
self.add_perms_form(synapse);
if (synapse.authorizeToEdit(Metamaps.Active.Mapper)) {
self.add_direction_form(synapse);
}
},
add_synapse_count: function (edge) {
var count = edge.getData("synapses").length;
add_name_form: function (synapse) {
$('#editSynUpperBar').append('<div id="synapseCardCount">' + count + '</div>')
},
add_desc_form: function (synapse) {
var data_nil = 'Click to add description.';
// TODO make it so that this would work even in sandbox mode,
// currently with Best_in_place it won't
//name editing form
$('#edit_synapse').append('<div id="edit_synapse_name"></div>');
$('#edit_synapse_name').attr('class', 'best_in_place best_in_place_desc');
$('#edit_synapse_name').attr('data-object', 'synapse');
$('#edit_synapse_name').attr('data-attribute', 'desc');
$('#edit_synapse_name').attr('data-type', 'textarea');
$('#edit_synapse_name').attr('data-nil', data_nil);
$('#edit_synapse_name').attr('data-url', '/synapses/' + synapse.id);
$('#edit_synapse_name').html(synapse.get("desc"));
//desc editing form
$('#editSynUpperBar').append('<div id="edit_synapse_desc"></div>');
$('#edit_synapse_desc').attr('class', 'best_in_place best_in_place_desc');
$('#edit_synapse_desc').attr('data-object', 'synapse');
$('#edit_synapse_desc').attr('data-attribute', 'desc');
$('#edit_synapse_desc').attr('data-type', 'textarea');
$('#edit_synapse_desc').attr('data-nil', data_nil);
$('#edit_synapse_desc').attr('data-url', '/synapses/' + synapse.id);
$('#edit_synapse_desc').html(synapse.get("desc"));
//if edge data is blank or just whitespace, populate it with data_nil
if ($('#edit_synapse_name').html().trim() == '') {
$('#edit_synapse_name').html(data_nil);
if ($('#edit_synapse_desc').html().trim() == '') {
$('#edit_synapse_desc').html(data_nil);
}
$('#edit_synapse_name').bind("ajax:success", function () {
$('#edit_synapse_desc').bind("ajax:success", function () {
var desc = $(this).html();
if (desc == data_nil) {
synapse.set("desc", '');
@ -1055,16 +1068,64 @@ Metamaps.SynapseCard = {
Metamaps.Visualize.mGraph.plot();
});
},
add_drop_down: function (edge, synapse) {
var list, i, synapses, l;
synapses = edge.getData("synapses");
l = synapses.length;
if (l > 1) {
// append the element that you click to show dropdown select
$('#editSynUpperBar').append('<div id="dropdownSynapses"></div>');
$('#dropdownSynapses').click(function(e){
e.preventDefault();
e.stopPropagation(); // stop it from immediately closing it again
$('#switchSynapseList').toggle();
});
// hide the dropdown again if you click anywhere else on the synapse card
$('#edit_synapse').click(function(){
$('#switchSynapseList').hide();
});
// generate the list of other synapses
list = '<ul id="switchSynapseList">';
for (i = 0; i < l; i++) {
if (synapses[i] !== synapse) { // don't add the current one to the list
list += '<li data-synapse-index="' + i + '">' + synapses[i].get('desc') + '</li>';
}
}
list += '</ul>'
// add the list of the other synapses
$('#editSynLowerBar').append(list);
// attach click listeners to list items that
// will cause it to switch the displayed synapse
// when you click it
$('#switchSynapseList li').click(function(e){
e.stopPropagation();
var index = parseInt($(this).attr('data-synapse-index'));
edge.setData('displayIndex', index);
Metamaps.Visualize.mGraph.plot();
Metamaps.SynapseCard.showCard(edge, false);
});
}
},
add_user_info: function (synapse) {
var u = '<div id="edgeUser" class="hoverForTip">';
u += '<img src="" width="24" height="24" />'
u += '<div class="tip">Created by ' + synapse.get("user_name") + '</div></div>';
$('#edit_synapse').append(u);
$('#editSynLowerBar').append(u);
// get mapper image
var setMapperImage = function (mapper) {
$('#edgeUser img').attr('src', mapper.get('image'));
};
Metamaps.Mapper.get(synapse.get('user_id'), setMapperImage);
},
add_perms_form: function (synapse) {
//permissions - if owner, also allow permission editing
$('#edit_synapse').append('<div class="mapPerm ' + synapse.get("permission").substring(0, 2) + '"></div>');
$('#editSynLowerBar').append('<div class="mapPerm ' + synapse.get("permission").substring(0, 2) + '"></div>');
// ability to change permission
var selectingPermission = false;
@ -1101,10 +1162,8 @@ Metamaps.SynapseCard = {
add_direction_form: function (synapse) {
//directionality checkboxes
$('#edit_synapse').append('<input type="checkbox" id="edit_synapse_left">');
$('#edit_synapse').append('<label class="left">&lt;</label>');
$('#edit_synapse').append('<input type="checkbox" id="edit_synapse_right">');
$('#edit_synapse').append('<label class="right">&gt;</label>');
$('#editSynLowerBar').append('<div id="edit_synapse_left"></div>');
$('#editSynLowerBar').append('<div id="edit_synapse_right"></div>');
var edge = synapse.get('edge');
@ -1113,11 +1172,11 @@ Metamaps.SynapseCard = {
if (edge.nodeFrom.pos.x < edge.nodeTo.pos.x ||
edge.nodeFrom.pos.x == edge.nodeTo.pos.x &&
edge.nodeFrom.pos.y < edge.nodeTo.pos.y) {
var left = edge.nodeTo;
var right = edge.nodeFrom;
var left = edge.nodeTo.getData("topic");
var right = edge.nodeFrom.getData("topic");
} else {
var left = edge.nodeFrom;
var right = edge.nodeTo;
var left = edge.nodeFrom.getData("topic");
var right = edge.nodeTo.getData("topic");
}
/*
@ -1128,22 +1187,27 @@ Metamaps.SynapseCard = {
var directionCat = synapse.get('category'); //both, none, from-to
if (directionCat == 'from-to') {
var from_to = synapse.getDirection();
var from_to = [synapse.get("node1_id"), synapse.get("node2_id")];
if (from_to[0] == left.id) {
//check left checkbox
$('#edit_synapse_left').prop('checked', true);
$('#edit_synapse_left').addClass('checked');
} else {
//check right checkbox
$('#edit_synapse_right').prop('checked', true);
$('#edit_synapse_right').addClass('checked');
}
} else if (directionCat == 'both') {
//check both checkboxes
$('#edit_synapse_left').prop('checked', true);
$('#edit_synapse_right').prop('checked', true);
$('#edit_synapse_left').addClass('checked');
$('#edit_synapse_right').addClass('checked');
}
if (synapse.authorizeToEdit(Metamaps.Active.Mapper)) {
$('#edit_synapse_left, #edit_synapse_right').click(function () {
var leftChecked = $('#edit_synapse_left').is(':checked');
var rightChecked = $('#edit_synapse_right').is(':checked');
$(this).toggleClass('checked');
var leftChecked = $('#edit_synapse_left').is('.checked');
var rightChecked = $('#edit_synapse_right').is('.checked');
var dir = synapse.getDirection();
var dirCat = 'none';
@ -1164,6 +1228,7 @@ Metamaps.SynapseCard = {
});
Metamaps.Visualize.mGraph.plot();
});
} // if
} //add_direction_form
}; // end Metamaps.SynapseCard
@ -1323,6 +1388,7 @@ Metamaps.Visualize = {
self.mGraph.loadJSON(Metamaps.JIT.vizData, rootIndex);
//compute positions and plot.
self.computePositions();
self.mGraph.busy = true;
if (self.type == "RGraph") {
self.mGraph.fx.animate(Metamaps.JIT.RGraph.animate);
} else if (self.type == "ForceDirected") {
@ -1494,7 +1560,7 @@ Metamaps.Realtime = {
});
$('body').click(self.close);
self.socket = io.connect('http://gentle-savannah-1303.herokuapp.com');
self.socket = io.connect('http://gentle-savannah-1303.herokuapp.com'); // io.connect('http://localhost:5001');
self.startActiveMap();
},
toggleBox: function (event) {
@ -2128,6 +2194,19 @@ Metamaps.Control = {
Metamaps.Selected.Nodes.splice(
Metamaps.Selected.Nodes.indexOf(node), 1);
},
deleteSelected: function () {
var n = Metamaps.Selected.Nodes.length;
var e = Metamaps.Selected.Edges.length;
var ntext = n == 1 ? "1 topic" : n + " topics";
var etext = e == 1 ? "1 synapse" : e + " synapses";
var text = "You have " + ntext + " and " + etext + " selected. ";
var r = confirm(text + "Are you sure you want to permanently delete them all? This will remove them from all maps they appear on.");
if (r == true) {
Metamaps.Control.deleteSelectedEdges();
Metamaps.Control.deleteSelectedNodes();
}
},
deleteSelectedNodes: function () { // refers to deleting topics permanently
var l = Metamaps.Selected.Nodes.length;
for (var i = l - 1; i >= 0; i -= 1) {
@ -2222,7 +2301,7 @@ Metamaps.Control = {
}
Metamaps.Visualize.mGraph.plot();
},
deselectEdge: function (edge, quick) {
deselectEdge: function (edge) {
edge.setData('showDesc', false, 'current');
edge.setDataset('current', {
@ -2233,8 +2312,7 @@ Metamaps.Control = {
if (Metamaps.Mouse.edgeHoveringOver == edge) {
edge.setDataset('current', {
showDesc: true,
lineWidth: 4,
color: Metamaps.Settings.colors.synapses.hover
lineWidth: 4
});
}
@ -2256,9 +2334,23 @@ Metamaps.Control = {
// TODO make it so that you select which one, of multiple possible synapses you want to delete
//var id = edge.getData("id");
//Metamaps.Synapses.get(id).destroy();
//Metamaps.Control.hideEdge(edge);
if (edge.getData("synapses").length - 1 === 0) {
Metamaps.Control.hideEdge(edge);
}
var index = edge.getData("displayIndex") ? edge.getData("displayIndex") : 0;
var synapse = edge.getData("synapses")[index];
var mapping = edge.getData("mappings")[index];
synapse.destroy();
// the server will destroy the mapping, we just need to remove it here
Metamaps.Mappings.remove(mapping);
edge.getData("mappings").splice(index, 1);
edge.getData("synapses").splice(index, 1);
if (edge.getData("displayIndex")) {
delete edge.data.$displayIndex;
}
},
removeSelectedEdges: function () {
var l = Metamaps.Selected.Edges.length,
@ -2277,9 +2369,23 @@ Metamaps.Control = {
// TODO make it so that you select which one, of multiple possible synapses you want
//var mappingid = edge.getData("mappingid");
//Metamaps.Mappings.get(mappingid).destroy();
//Metamaps.Control.hideEdge(edge);
if (edge.getData("mappings").length - 1 === 0) {
Metamaps.Control.hideEdge(edge);
}
var index = edge.getData("displayIndex") ? edge.getData("displayIndex") : 0;
var synapse = edge.getData("synapses")[index];
var mapping = edge.getData("mappings")[index];
mapping.destroy();
Metamaps.Synapses.remove(synapse);
edge.getData("mappings").splice(index, 1);
edge.getData("synapses").splice(index, 1);
if (edge.getData("displayIndex")) {
delete edge.data.$displayIndex;
}
},
hideSelectedEdges: function () {
var edge,
@ -2295,6 +2401,7 @@ Metamaps.Control = {
var from = edge.nodeFrom.id;
var to = edge.nodeTo.id;
edge.setData('alpha', 0, 'end');
Metamaps.Control.deselectEdge(edge);
Metamaps.Visualize.mGraph.fx.animate({
modes: ['edge-property:alpha'],
duration: 500
@ -2728,22 +2835,65 @@ Metamaps.Listeners = {
init: function () {
$(document).on('keydown', function (e) {
if (!(Metamaps.Active.Map || Metamaps.Active.Topic)) return;
switch (e.which) {
case 13:
if (Metamaps.Active.Map) Metamaps.JIT.enterKeyHandler();
case 13: // if enter key is pressed
Metamaps.JIT.enterKeyHandler();
e.preventDefault();
break;
case 27:
if (Metamaps.Active.Map) Metamaps.JIT.escKeyHandler();
case 27: // if esc key is pressed
Metamaps.JIT.escKeyHandler();
break;
case 65: //if a or A is pressed
if (e.ctrlKey){
Metamaps.Control.deselectAllNodes();
Metamaps.Control.deselectAllEdges();
e.preventDefault();
Metamaps.Visualize.mGraph.graph.eachNode(function (n) {
Metamaps.Control.selectNode(n,e);
});
Metamaps.Visualize.mGraph.plot();
}
break;
case 69: //if e or E is pressed
if (e.ctrlKey){
e.preventDefault();
Metamaps.JIT.zoomExtents();
}
break;
case 77: //if m or M is pressed
if (e.ctrlKey){
e.preventDefault();
Metamaps.Control.removeSelectedNodes();
Metamaps.Control.removeSelectedEdges();
}
break;
case 68: //if d or D is pressed
if (e.ctrlKey){
e.preventDefault();
Metamaps.Control.deleteSelected();
}
break;
case 72: //if h or H is pressed
if (e.ctrlKey){
e.preventDefault();
Metamaps.Control.hideSelectedNodes();
Metamaps.Control.hideSelectedEdges();
}
break;
default:
break; //alert(e.which);
}
});
//$(window).resize(function () {
// Metamaps.Visualize.mGraph.canvas.resize($(window).width(), $(window).height());
//});
$(window).resize(function () {
if (Metamaps.Visualize && Metamaps.Visualize.mGraph) Metamaps.Visualize.mGraph.canvas.resize($(window).width(), $(window).height());
if (Metamaps.Famous && Metamaps.Famous.maps.surf) Metamaps.Famous.maps.hide();
});
}
}; // end Metamaps.Listeners
@ -2924,6 +3074,9 @@ Metamaps.Topic = {
// update filters
Metamaps.Filter.reset();
// reset selected arrays
Metamaps.Selected.reset();
// these three update the actual filter box with the right list items
Metamaps.Filter.checkMetacodes();
Metamaps.Filter.checkSynapses();
@ -2942,6 +3095,18 @@ Metamaps.Topic = {
Metamaps.SynapseCard.hideCard();
}
},
centerOn: function (nodeid) {
if (!Metamaps.Visualize.mGraph.busy) {
var node = Metamaps.Visualize.mGraph.graph.getNode(nodeid);
Metamaps.Visualize.mGraph.onClick(node.id, {
hideLabels: false,
duration: 1000,
onComplete: function () {
}
});
}
},
/*
*
*
@ -3163,9 +3328,8 @@ Metamaps.Synapse = {
Metamaps.Visualize.mGraph.graph.addAdjacence(node1, node2, newedge.data);
edgeOnViz = Metamaps.Visualize.mGraph.graph.getAdjacence(node1.id, node2.id);
synapse.set('edge', edgeOnViz);
synapse.updateEdge(); // links the topic and the mapping to the node
synapse.updateEdge(); // links the synapse and the mapping to the edge
Metamaps.Visualize.mGraph.fx.plotLine(edgeOnViz, Metamaps.Visualize.mGraph.canvas);
Metamaps.Control.selectEdge(edgeOnViz);
var mappingSuccessCallback = function (mappingModel, response) {
@ -3261,7 +3425,7 @@ Metamaps.Synapse = {
topic1 = Metamaps.Topics.get(Metamaps.Create.newSynapse.topic1id);
node1 = topic1.get('node');
topic1 = Metamaps.Topics.get(Metamaps.Create.newSynapse.topic2id);
topic2 = Metamaps.Topics.get(Metamaps.Create.newSynapse.topic2id);
node2 = topic2.get('node');
Metamaps.Create.newSynapse.hide();
@ -3310,6 +3474,9 @@ Metamaps.Map = {
// update filters
Metamaps.Filter.reset();
// reset selected arrays
Metamaps.Selected.reset();
// set the proper mapinfobox content
Metamaps.Map.InfoBox.load();
@ -3661,3 +3828,4 @@ Metamaps.Admin = {
}
}
};

View file

@ -32,20 +32,3 @@ function fetchRelatives(node) {
}
});
}
function centerOn(nodeid) {
if (!Mconsole.busy) {
var node = Mconsole.graph.getNode(nodeid);
$('div.index img').attr('src', imgArray[node.getData('metacode')].src);
$('div.index .mapName').html(node.name);
$(document).attr('title', node.name + ' | Metamaps');
window.history.pushState(node.name, "Metamaps", "/topics/" + node.id);
Mconsole.onClick(node.id, {
hideLabels: false,
duration: 1000,
onComplete: function () {
fetchRelatives(node);
}
});
}
}

View file

@ -2425,15 +2425,6 @@ float: left;
height: 100%;
}
#edit_synapse label,
#edit_synapse_left,
#edit_synapse_right {
display: inline-block;
}
#edit_synapse label.left {
margin-right: 0.5em;
}
.templates {
display: none;
}

View file

@ -67,6 +67,7 @@
background-image: url(edit.png);
background-repeat: no-repeat;
background-position: bottom right;
cursor: text;
}
.best_in_place_name textarea, .best_in_place_name input {
@ -136,6 +137,7 @@ background: none;
background-image: url(edit.png);
background-position: top right;
background-repeat: no-repeat;
cursor: text;
}
#edit_synapse .best_in_place_desc {
@ -219,7 +221,7 @@ background: none;
.linkItem.synapseCount:hover .synapseCountIcon {
background-position: 0 -32px;
}
.linkItem.mapPerm {
.mapPerm {
width: 32px;
height: 32px;
padding: 0;
@ -228,22 +230,22 @@ background: none;
background-image: url(permissions32_sprite.png);
background-position: 0 0;
}
.linkItem.mapPerm.co {
.mapPerm.co {
background-position: 0 0;
}
.linkItem.mapPerm.pu {
.mapPerm.pu {
background-position: -64px 0;
}
.linkItem.mapPerm.pr {
.mapPerm.pr {
background-position: -32px 0;
}
.showcard .yourTopic .mapPerm:hover {
.yourTopic .mapPerm:hover, .yourEdge .mapPerm:hover {
background-image: url(arrowperms_sprite.png);
background-position-x: -32px;
cursor:pointer;
}
.showcard .yourTopic .mapPerm.minimize {
.yourTopic .mapPerm.minimize, .yourEdge .mapPerm.minimize {
background-image: url(arrowperms_sprite.png) !important;
background-position-x: 0px;
cursor: pointer;
@ -555,69 +557,107 @@ font-family: 'din-regular', helvetica, sans-serif;
display: inline-block;
}
.permActivator {
width: 16px;
height: 16px;
background: url('settings.png') no-repeat 0 0;
overflow:hidden;
position: absolute;
left: 0px;
top: 30px;
}
#edit_synapse .mapPerm,
#edit_synapse .permActivator {
position: static;
display: inline-block;
color: #000;
}
#edit_synapse .mapPerm {
width: 20px;
height:20px;
background-repeat: no-repeat;
background-size: 20px 20px;
margin: 10px 12px 0 12px;
}
#edit_synapse .mapPerm.co {
background-image: url("CO32.png");
}
#edit_synapse .mapPerm.pu {
background-image: url("PU32.png");
}
#edit_synapse .mapPerm.pr {
background-image: url("PR32.png");
}
#edit_synapse .permActivator {
position: absolute;
margin-top: -1.3em;
}
#edit_synapse {
background: url("synapse32.png") no-repeat scroll 0 center / 30px 30px #FFFFFF;
border-radius: 5px;
padding: 5px 5px 5px 30px;
color: #000;
border-radius: 2px;
width: 270px;
box-shadow: 0px 3px 3px rgba(0,0,0,0.23), 0 3px 3px rgba(0,0,0,0.16);
}
#edit_synapse_name {
margin-left: 0.4em;
border-bottom: 1px solid black;
text-align:center;
max-width: 160px;
#editSynUpperBar {
background: #FFFFFF url(synapse32.png) no-repeat 8px center;
min-height: 48px;
border-bottom: 1px solid #222222;
display: table;
width: 100%;
}
#editSynLowerBar {
background-color: #E0E0E0;
height: 48px;
position: relative;
}
#synapseCardCount {
font-size: 18px;
display: table-cell;
vertical-align: middle;
padding-left: 44px;
width: 20px;
line-height: 18px;
}
#edit_synapse_desc {
font-size: 14px;
font-family: 'din-regular', helvetica, sans-serif;
padding: 8px 38px 8px 4px;
display: table-cell;
vertical-align: middle;
line-height: 16px;
}
.canEdit #edit_synapse_desc:hover {
background-image: url(edit.png);
background-repeat: no-repeat;
background-position: 164px center;
cursor: text;
}
#edit_synapse .best_in_place_desc textarea {
font-family: 'din-regular', sans-serif;
color: #424242;
font-size: 14px;
line-height: 16px;
width: 100%;
height: auto;
margin: 0;
padding: 0;
border: 0;
outline: none;
background: none;
resize: none;
}
#dropdownSynapses {
position: absolute;
width: 24px;
height: 24px;
top: 12px;
right: 8px;
background-image: url(arrowdown_sprite.png);
background-repeat: no-repeat;
background-position: 4px -12px;
}
#dropdownSynapses:hover {
background-position: 4px -28px;
cursor: pointer;
}
#switchSynapseList {
display: none;
list-style: none;
width: 270px;
position: absolute;
z-index: 1;
background: #FFFFFF;
border-bottom: 1px solid #BBBBBB;
}
#switchSynapseList li {
padding: 8px;
cursor: pointer;
font-family: 'din-regular';
font-size: 14px;
line-height: 16px;
}
#switchSynapseList li:hover {
background: #E0E0E0;
}
#edgeUser {
display:inline-block;
background-position: center center;
background-repeat: no-repeat;
background-size: 20px 20px;
height: 20px;
min-width: 20px;
position: relative;
background-image: url("MMCCicon_mapper_black.png");
margin: 10px 0 0 10px;
margin: 12px 0 0 11px;
}
#edgeUser img {
border-radius: 12px;
}
#edgeUser.hoverForTip:hover .tip {
display:block;
@ -637,39 +677,36 @@ font-family: 'din-regular', helvetica, sans-serif;
z-index: 100;
}
#edit_synapse .click-to-edit {
margin-left: 0.3em;
#edit_synapse .mapPerm {
position: absolute;
top: 0px;
left: 40px;
}
#edit_synapse.yourEdge .mapPerm:hover {
background-image: url(MMCCicon_maximize_arrow_black.png);
background-size: 24px 17px;
background-position: 0px 2px;
cursor:pointer;
#edit_synapse_left, #edit_synapse_right {
position: absolute;
height: 24px;
width: 24px;
top: 12px;
background-repeat: no-repeat;
}
#edit_synapse.yourEdge .mapPerm.minimize {
background-image: url(MMCCicon_minimize_arrow_black.png) !important;
background-size: 24px 17px;
background-position: 0px 2px;
#edit_synapse_right {
background-image: url(synapsedirectionright_sprite.png);
right: 16px;
}
#edit_synapse_left {
background-image: url(synapsedirectionleft_sprite.png);
right: 56px;
}
#edit_synapse_left.checked, #edit_synapse_right.checked {
background-position-y: -48px;
}
.canEdit #edit_synapse_left, .canEdit #edit_synapse_right {
cursor: pointer;
}
#edit_synapse .mapPerm .permissionSelect {
list-style: none;
width: 26px;
height: 52px;
position: relative;
top: 20px;
left:-3px;
.canEdit #edit_synapse_left:not(.checked):hover, .canEdit #edit_synapse_right:not(.checked):hover {
background-position-y: -24px;
}
#edit_synapse .mapPerm .permissionSelect li {
width: 26px;
height: 26px;
background-repeat: no-repeat;
background-position: center center;
background-size: 20px 20px;
background-color:white;
}
/* Map Cards */

View file

@ -678,13 +678,15 @@
/* infoAndHelp */
.mapPage .infoAndHelp, .topicPage .infoAndHelp{
right: 70px;
}
.infoAndHelp {
position: fixed;
bottom: 24px;
right: 66px;
bottom: 20px;
right: 20px;
z-index: 3;
width: auto;
padding: 1px 10px 0px 10px;
font-style: italic;
height: 32px;
}

View file

@ -1,23 +1,21 @@
/* =Barometer feedback tab
/* =USERVOICE ICON DEFINE
--------------------------------------------------------*/
a#barometer_tab {
background-image:url(../images/feedback_tab.png);
div.uv-icon.uv-bottom-left {
background-image:url(feedback_sprite.png);
background-color:#222222;
color:#FFFFFF;
cursor:pointer;
height:102px;
height:108px;
left:0;
margin-left:-7px;
overflow:hidden;
position:fixed;
margin-left:0px;
text-indent:-100000px;
top:25%;
width:42px;
width:25px;
z-index:100000;
}
/* =Barometer Overlay
/* =NOTHING AFTER THIS POINT IS BEING USED
--------------------------------------------------------*/
#barometer_overlay {

View file

@ -55,9 +55,6 @@ class SynapsesController < ApplicationController
m.map.touch(:updated_at)
#push notify to anyone viewing same map in realtime (see mapping.rb to understand the 'message' action)
m.message 'destroy',@current.id
m.delete
end

View file

@ -108,9 +108,6 @@ class TopicsController < ApplicationController
@map = m.map
@map.touch(:updated_at)
#push notify to anyone viewing same map in realtime (see mapping.rb to understand the 'message' action)
m.message 'destroy',@current.id
m.delete
end
@ -122,9 +119,6 @@ class TopicsController < ApplicationController
@map = mapping.map
@map.touch(:updated_at)
#push notify to anyone viewing a map with this topic in realtime (see mapping.rb to understand the 'message' action)
mapping.message 'destroy',@current.id
mapping.delete
end

View file

@ -18,30 +18,4 @@ class Mapping < ActiveRecord::Base
super(:methods =>[:user_name, :user_image])
end
# sends push updates through redis to websockets for realtime updates
def message action, origin_user_id
if self.category == "Topic"
return if self.topic.permission == "private" and action == "create"
msg = { origin: origin_user_id,
mapid: self.map.id,
resource: self.category,
action: action,
id: self.topic.id,
obj: self.topic.selfonmap_as_json(self.map.id).html_safe }
elsif self.category == "Synapse"
return if self.synapse.permission == "private" and action == "create"
msg = { origin: origin_user_id,
mapid: self.map.id,
resource: self.category,
action: action,
id: self.synapse.id,
obj: self.synapse.self_as_json.html_safe }
end
$redis.publish 'maps', msg.to_json
end
end

View file

@ -20,25 +20,6 @@ class Synapse < ActiveRecord::Base
super(:methods =>[:user_name, :user_image])
end
# sends push updates through redis to websockets for realtime updates
def message action, origin_user_id
return if self.permission == "private" and action == "create"
#get array of all maps topic appears in
@maps = self.maps
#sends update to all maps that topic appears in who have realtime on
@maps.each do |map|
msg = { origin: origin_user_id,
mapid: map.id,
resource: 'Synapse',
action: action,
id: self.id,
obj: self.self_as_json.html_safe }
$redis.publish 'maps', msg.to_json
end
end
##### PERMISSIONS ######
# returns false if user not allowed to 'show' Topic, Synapse, or Map

View file

@ -58,25 +58,6 @@ class Topic < ActiveRecord::Base
super(:methods =>[:user_name, :user_image, :map_count, :synapse_count])
end
# sends push updates through redis to websockets for realtime updates
def message action, origin_user_id
return if self.permission == "private" and action == "create"
#get array of all maps topic appears in
@maps = self.maps
#sends update to all maps that topic appears in who have realtime on
@maps.each do |map|
msg = { origin: origin_user_id,
mapid: map.id,
resource: 'Topic',
action: action,
id: self.id,
obj: self.selfonmap_as_json(map.id).html_safe }
$redis.publish 'maps', msg.to_json
end
end
def topic_autocomplete_method
"Get: #{self.name}"
end

View file

@ -66,8 +66,8 @@
<%= render :partial => 'layouts/templates' %>
<%= render :partial => 'shared/metacodeBgColors' %>
<script type="text/javascript" charset="utf-8">
BAROMETER.load('Scqak8nyHdFEkezKMNeQp');
//BAROMETER.load('Scqak8nyHdFEkezKMNeQp');
USERVOICE.load();
<% if authenticated? %>
Metamaps.Active.Mapper = <%= user.to_json.html_safe %>
<% else %>

View file

@ -138,7 +138,7 @@
<div id="moreResources">
<p>For more information about Metamaps.cc, visit our Knowledge Base or skip directly to a section by clicking on one of the categories below.</p>
<div class="resourcesColumnOne resourcesColumn">
<a href="#" target="_blank" data-bypass="true" class="button">Feedback Forums</a>
<a href="http://support.metamaps.cc/forums/262715-general" target="_blank" data-bypass="true" class="button">Feedback Forums</a>
<ul>
<li>
<a href="http://support.metamaps.cc/knowledgebase/topics/61031-getting-started" target="_blank" data-bypass="true">Getting Started</a>

View file

@ -45,13 +45,14 @@
margin-bottom: 24px;
}
div.dialog {
width: 500px;
width: 380px;
border: 0px;
border-right-color: #999;
border-bottom-color: #999;
float: left;
margin-right: 100px;
padding-top: 150px;
margin-right: 50px;
padding-top: 70px;
padding-bottom: 70px;
}
.picture {
width: 450px;
@ -64,12 +65,12 @@
float: left;
background-position:50% 20%;
background-size: 100%;
margin-top: 162px;
margin-top: 110px;
}
.wrapper {
margin: 0 auto;
width: 1100px;
width: 900px;
}
.button {