code cleaning

This commit is contained in:
Connor Turland 2014-05-30 11:00:31 -04:00
parent f121661858
commit 1970f794c4
11 changed files with 864 additions and 727 deletions

View file

@ -14,7 +14,7 @@ gem 'formtastic'
gem 'json' gem 'json'
gem 'rails3-jquery-autocomplete' gem 'rails3-jquery-autocomplete'
gem 'best_in_place' gem 'best_in_place'
gem 'therubyracer' #optional #gem 'therubyracer' #optional
#gem 'rb-readline' #gem 'rb-readline'
# Gems used only for assets and not required # Gems used only for assets and not required

View file

@ -64,7 +64,6 @@ GEM
railties (>= 3.1.0, < 5.0) railties (>= 3.1.0, < 5.0)
thor (~> 0.14) thor (~> 0.14)
json (1.8.1) json (1.8.1)
libv8 (3.16.14.3)
mail (2.5.4) mail (2.5.4)
mime-types (~> 1.16) mime-types (~> 1.16)
treetop (~> 1.4.8) treetop (~> 1.4.8)
@ -112,9 +111,6 @@ GEM
multi_json (~> 1.0) multi_json (~> 1.0)
rack (~> 1.0) rack (~> 1.0)
tilt (~> 1.1, != 1.3.0) tilt (~> 1.1, != 1.3.0)
therubyracer (0.12.1)
libv8 (~> 3.16.14.0)
ref
thor (0.19.1) thor (0.19.1)
thread_safe (0.3.3) thread_safe (0.3.3)
tilt (1.4.1) tilt (1.4.1)
@ -147,5 +143,4 @@ DEPENDENCIES
rails3-jquery-autocomplete rails3-jquery-autocomplete
redis redis
sass-rails sass-rails
therubyracer
uglifier (>= 1.0.3) uglifier (>= 1.0.3)

47
Gemfile~ Normal file
View file

@ -0,0 +1,47 @@
source 'https://rubygems.org'
gem 'rails', '3.2.17'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'devise'
gem 'redis'
gem 'pg'
gem 'cancan'
gem 'formula'
gem 'formtastic'
gem 'json'
gem 'rails3-jquery-autocomplete'
gem 'best_in_place'
gem 'therubyracer' #optional
#gem 'rb-readline'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails'
gem 'coffee-rails', '~> 3.2.1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer'
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails', '2.1.2'
# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'
# To use Jbuilder templates for JSON
gem 'jbuilder', '0.8.2'
# Use unicorn as the web server
# gem 'unicorn'
# Deploy with Capistrano
# gem 'capistrano'
# To use debugger
# gem 'ruby-debug19', :require => 'ruby-debug'

View file

@ -144,16 +144,7 @@ function graphSettings(type, embed) {
//Number of iterations for the FD algorithm //Number of iterations for the FD algorithm
iterations: 200, iterations: 200,
//Edge length //Edge length
levelDistance: 200, levelDistance: 200
// Add text to the labels. This method is only triggered
// on label creation and only for DOM labels (not native canvas ones).
//onCreateLabel: function (domElement, node) {
// onCreateLabelHandler(type, domElement, node);
//},
// Change node styles when DOM labels are placed or moved.
//onPlaceLabel: function (domElement, node) {
// onPlaceLabelHandler(domElement, node);
//}
}; };
if (embed) { if (embed) {
@ -177,24 +168,6 @@ function graphSettings(type, embed) {
//different because we're centred //different because we're centred
onDragCancelHandler(node, eventInfo, e, true); onDragCancelHandler(node, eventInfo, e, true);
}; };
/*t.Events.onClick = function(node, eventInfo, e) {
//this is handled mostly differently than in arranged/chaotic
if (e.target.id != "infovis-canvas") return false;
//hide synapse and topic editing dialog
hideCards();
//clicking on an edge, a node, or clicking on blank part of canvas?
if (node.nodeFrom) {
selectEdgeOnClickHandler(node, e);
} else if (node && !node.nodeFrom) {
//node is actually a node :)
selectNodeOnClickHandler(node, e);
} else {
canvasDoubleClickHandler(eventInfo.getPos(), e);
}
};*/
}//if }//if
return t; return t;
@ -258,18 +231,9 @@ var nodeSettings = {
var pos = node.pos.getc(true), var pos = node.pos.getc(true),
dim = node.getData('dim'), dim = node.getData('dim'),
cat = node.getData('metacode'), cat = node.getData('metacode'),
greenCircle = node.getData('greenCircle'),
whiteCircle = node.getData('whiteCircle'), whiteCircle = node.getData('whiteCircle'),
ctx = canvas.getCtx(); ctx = canvas.getCtx();
// if the topic is from the Commons draw a green circle around it
if (greenCircle) {
ctx.beginPath();
ctx.arc(pos.x, pos.y, dim+3, 0, 2 * Math.PI, false);
ctx.strokeStyle = '#67be5f'; // green
ctx.lineWidth = 2;
ctx.stroke();
}
// if the topic is on the Canvas draw a white circle around it // if the topic is on the Canvas draw a white circle around it
if (whiteCircle) { if (whiteCircle) {
ctx.beginPath(); ctx.beginPath();
@ -591,31 +555,6 @@ function onDragCancelHandler(node, eventInfo, e, centred) {
Mconsole.plot(); Mconsole.plot();
} }
function onPlaceLabelHandler(domElement, node) {
var style = domElement.style;
var left = parseInt(style.left);
var top = parseInt(style.top);
var w = $('#topic_' + node.id + '_label').width();
style.left = (left - w / 2) + 'px';
style.top = (top+20) + 'px';
style.display = '';
// now position the showcard
if (MetamapsModel.showcardInUse != null) {
top = $('#' + MetamapsModel.showcardInUse).css('top');
left = parseInt($('#' + MetamapsModel.showcardInUse).css('left'));
if (0 != $('#topic_' + MetamapsModel.showcardInUse + '_label').width()) {
MetamapsModel.widthOfLabel = $('#topic_' + MetamapsModel.showcardInUse + '_label').width();
}
w = MetamapsModel.widthOfLabel/2;
left = (left + w) + 'px';
$('#showcard').css('top', top);
$('#showcard').css('left', left);
Mconsole.labels.hideLabel(Mconsole.graph.getNode(MetamapsModel.showcardInUse));
}
}
// thanks to http://stackoverflow.com/questions/4338963/ // thanks to http://stackoverflow.com/questions/4338963/
// convert-html-character-entities-back-to-regular-text-using-javascript // convert-html-character-entities-back-to-regular-text-using-javascript
function decodeEntities(desc) { function decodeEntities(desc) {
@ -625,4 +564,3 @@ function decodeEntities(desc) {
temp = null; //delete the element; temp = null; //delete the element;
return str; return str;
}//decodeEntities }//decodeEntities

View file

@ -25,9 +25,17 @@
// other options are 'graph' // other options are 'graph'
var viewMode = "list"; var viewMode = "list";
var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null, gType, tempNode = null, tempInit = false, tempNode2 = null, metacodeIMGinit = false, goRealtime = false, mapid = null, mapperm = false, touchPos, touchDragNode, mouseIsDown = false; var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
gType, tempNode = null,
tempInit = false,
tempNode2 = null,
metacodeIMGinit = false,
goRealtime = false,
mapid = null,
mapperm = false,
touchPos, touchDragNode, mouseIsDown = false;
$(document).ready(function() { $(document).ready(function () {
function bindMainMenuHover() { function bindMainMenuHover() {
@ -37,9 +45,9 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
var sliding1 = false; var sliding1 = false;
var lT; var lT;
var closeMenu = function() { var closeMenu = function () {
lT = setTimeout(function() { lT = setTimeout(function () {
if (! sliding1) { if (!sliding1) {
sliding1 = true; sliding1 = true;
// $('.footer .menu').animate({ // $('.footer .menu').animate({
// height: '0px' // height: '0px'
@ -47,21 +55,21 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
// sliding1 = false; // sliding1 = false;
// menuIsOpen = false; // menuIsOpen = false;
// }); // });
$('.footer').css('border-top-right-radius','5px'); $('.footer').css('border-top-right-radius', '5px');
$('.logo').animate({ $('.logo').animate({
'background-position-x':'-10px' 'background-position-x': '-10px'
}, 200); }, 200);
$('.footer .menu').fadeOut(200, function() { $('.footer .menu').fadeOut(200, function () {
sliding1 = false; sliding1 = false;
menuIsOpen = false; menuIsOpen = false;
}); });
} }
},500); }, 500);
} }
var openMenu = function() { var openMenu = function () {
clearTimeout(lT); clearTimeout(lT);
if (! sliding1) { if (!sliding1) {
sliding1 = true; sliding1 = true;
// $('.footer .menu').animate({ // $('.footer .menu').animate({
@ -69,11 +77,11 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
// }, 300, function() { // }, 300, function() {
// sliding1 = false; // sliding1 = false;
// }); // });
$('.footer').css('border-top-right-radius','0'); $('.footer').css('border-top-right-radius', '0');
$('.logo').animate({ $('.logo').animate({
'background-position-x':'-7px' 'background-position-x': '-7px'
}, 200); }, 200);
$('.footer .menu').fadeIn(200, function() { $('.footer .menu').fadeIn(200, function () {
sliding1 = false; sliding1 = false;
}); });
} }
@ -82,7 +90,7 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
$(".logo").hover(openMenu, closeMenu); $(".logo").hover(openMenu, closeMenu);
// when on touch screen, make touching on the logo do what hovering does on desktop // when on touch screen, make touching on the logo do what hovering does on desktop
$("#mainTitle a").bind('touchend', function(evt) { $("#mainTitle a").bind('touchend', function (evt) {
if (!menuIsOpen) { if (!menuIsOpen) {
openMenu(); openMenu();
evt.preventDefault(); evt.preventDefault();
@ -99,59 +107,70 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
var sliding1 = false; var sliding1 = false;
var lT; var lT;
var openSearch = function() { var openSearch = function () {
clearTimeout(lT); clearTimeout(lT);
if (!sliding1 && !searchIsOpen) { if (!sliding1 && !searchIsOpen) {
hideCards(); hideCards();
sliding1 = true; sliding1 = true;
$('.sidebarSearch .twitter-typeahead, .sidebarSearch .tt-hint, .sidebarSearchField').animate({ $('.sidebarSearch .twitter-typeahead, .sidebarSearch .tt-hint, .sidebarSearchField').animate({
width: '200px' width: '200px'
}, 200, function() { }, 200, function () {
$('.sidebarSearchField, .sidebarSearch .tt-hint').css({padding:'5px 10px', width:'180px'}); $('.sidebarSearchField, .sidebarSearch .tt-hint').css({
padding: '5px 10px',
width: '180px'
});
$('.sidebarSearchField').focus(); $('.sidebarSearchField').focus();
sliding1 = false sliding1 = false
searchIsOpen = true; searchIsOpen = true;
}); });
} }
} }
var closeSearch = function(closeAfter) { var closeSearch = function (closeAfter) {
lT = setTimeout(function() { lT = setTimeout(function () {
if (!sliding1 && searchIsOpen && $('.sidebarSearchField').val() == '') { if (!sliding1 && searchIsOpen && $('.sidebarSearchField').val() == '') {
sliding1 = true; sliding1 = true;
$('.sidebarSearchField, .sidebarSearch .tt-hint').css({padding:'5px 0', width:'200px'}); $('.sidebarSearchField, .sidebarSearch .tt-hint').css({
padding: '5px 0',
width: '200px'
});
$('.sidebarSearch .twitter-typeahead, .sidebarSearch .tt-hint, .sidebarSearchField').animate({ $('.sidebarSearch .twitter-typeahead, .sidebarSearch .tt-hint, .sidebarSearchField').animate({
width: '0' width: '0'
}, 200, function() { }, 200, function () {
$('.sidebarSearchField').typeahead('setQuery',''); $('.sidebarSearchField').typeahead('setQuery', '');
sliding1 = false; sliding1 = false;
searchIsOpen = false; searchIsOpen = false;
}); });
} }
},closeAfter); }, closeAfter);
} }
// bind the hover events // bind the hover events
$(".sidebarSearch").hover(function(){ openSearch() }, function() { closeSearch(800) }); $(".sidebarSearch").hover(function () {
openSearch()
}, function () {
closeSearch(800)
});
$('.sidebarSearchIcon').click(function(e) { $('.sidebarSearchIcon').click(function (e) {
$('.sidebarSearchField').focus(); $('.sidebarSearchField').focus();
}); });
$('.sidebarSearch').click(function(e) { $('.sidebarSearch').click(function (e) {
e.stopPropagation(); e.stopPropagation();
}); });
$('body').click(function(e) { $('body').click(function (e) {
closeSearch(0); closeSearch(0);
}); });
// if the search is closed and user hits SHIFT+S // if the search is closed and user hits SHIFT+S
$('body').bind('keydown', function(e) { $('body').bind('keydown', function (e) {
switch(e.which) { switch (e.which) {
case 191: case 191:
if (e.ctrlKey && !searchIsOpen) { if (e.ctrlKey && !searchIsOpen) {
openSearch(); openSearch();
} }
break; break;
default: break; //console.log(e.which); default:
break; //console.log(e.which);
} }
}); });
@ -161,7 +180,7 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
$('.sidebarSearchField').typeahead([ $('.sidebarSearchField').typeahead([
{ {
name: 'topics', name: 'topics',
dupChecker: function (datum1,datum2) { dupChecker: function (datum1, datum2) {
return false; return false;
}, },
template: $('.topicTemplate').html(), template: $('.topicTemplate').html(),
@ -174,12 +193,12 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
} }
return q; return q;
}, },
filter: function(dataset) { filter: function (dataset) {
if (dataset.length == 0) { if (dataset.length == 0) {
dataset.push({ dataset.push({
value: "No results", value: "No results",
label: "No results", label: "No results",
typeImageURL: "/assets/wildcard.png", typeImageURL: "/assets/icons/wildcard.png",
rtype: "noresult" rtype: "noresult"
}); });
} }
@ -191,7 +210,7 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
}, },
{ {
name: 'maps', name: 'maps',
dupChecker: function (datum1,datum2) { dupChecker: function (datum1, datum2) {
return false; return false;
}, },
template: $('.mapTemplate').html(), template: $('.mapTemplate').html(),
@ -204,7 +223,7 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
} }
return q; return q;
}, },
filter: function(dataset) { filter: function (dataset) {
if (dataset.length == 0) { if (dataset.length == 0) {
dataset.push({ dataset.push({
value: "No results", value: "No results",
@ -220,13 +239,13 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
}, },
{ {
name: 'mappers', name: 'mappers',
dupChecker: function (datum1,datum2) { dupChecker: function (datum1, datum2) {
return false; return false;
}, },
template: $('.mapperTemplate').html(), template: $('.mapperTemplate').html(),
remote: { remote: {
url: '/search/mappers?term=%QUERY', url: '/search/mappers?term=%QUERY',
filter: function(dataset) { filter: function (dataset) {
if (dataset.length == 0) { if (dataset.length == 0) {
dataset.push({ dataset.push({
value: "No results", value: "No results",
@ -247,13 +266,11 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
if (datum.rtype != "noresult") { if (datum.rtype != "noresult") {
var win; var win;
if (dataset == "topics") { if (dataset == "topics") {
win=window.open('/topics/' + datum.id, '_blank'); win = window.open('/topics/' + datum.id, '_blank');
} } else if (dataset == "maps") {
else if (dataset == "maps") { win = window.open('/maps/' + datum.id, '_blank');
win=window.open('/maps/' + datum.id, '_blank'); } else if (dataset == "mappers") {
} win = window.open('/maps/mappers/' + datum.id, '_blank');
else if (dataset == "mappers") {
win=window.open('/maps/mappers/' + datum.id, '_blank');
} }
win.focus(); win.focus();
closeSearch(0); closeSearch(0);
@ -261,53 +278,78 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
}); });
var checkboxChangeInit = false, minimizeInit = false; var checkboxChangeInit = false,
minimizeInit = false;
$('.sidebarSearchField').bind('keyup', function () { $('.sidebarSearchField').bind('keyup', function () {
// when the user selects 'added by me' resend the query with their userid attached // when the user selects 'added by me' resend the query with their userid attached
if (!checkboxChangeInit) { if (!checkboxChangeInit) {
$('.limitToMe').bind("change", function(e) { $('.limitToMe').bind("change", function (e) {
// set the value of the search equal to itself to retrigger the autocomplete event // set the value of the search equal to itself to retrigger the autocomplete event
searchIsOpen = false; searchIsOpen = false;
$('.sidebarSearchField').typeahead('setQuery',$('.sidebarSearchField').val()); $('.sidebarSearchField').typeahead('setQuery', $('.sidebarSearchField').val());
setTimeout(function() { searchIsOpen = true; }, 2000); setTimeout(function () {
searchIsOpen = true;
}, 2000);
}); });
checkboxChangeInit = true; checkboxChangeInit = true;
} }
// when the user clicks minimize section, hide the results for that section // when the user clicks minimize section, hide the results for that section
if (!minimizeInit) { if (!minimizeInit) {
$('.minimizeMapperResults').click(function(e) { $('.minimizeMapperResults').click(function (e) {
var s = $('.tt-dataset-mappers .tt-suggestions'); var s = $('.tt-dataset-mappers .tt-suggestions');
console.log(s.css('height')); console.log(s.css('height'));
if (s.css('height') == '0px') { if (s.css('height') == '0px') {
$('.tt-dataset-mappers .tt-suggestions').css({'height':'auto','overflow':'visible'}); $('.tt-dataset-mappers .tt-suggestions').css({
'height': 'auto',
'overflow': 'visible'
});
$(this).removeClass('maximizeResults').addClass('minimizeResults'); $(this).removeClass('maximizeResults').addClass('minimizeResults');
} else { } else {
$('.tt-dataset-mappers .tt-suggestions').css({'height':'0','overflow':'hidden'}); $('.tt-dataset-mappers .tt-suggestions').css({
'height': '0',
'overflow': 'hidden'
});
$(this).removeClass('minimizeResults').addClass('maximizeResults'); $(this).removeClass('minimizeResults').addClass('maximizeResults');
} }
}); });
$('.minimizeTopicResults').click(function(e) { $('.minimizeTopicResults').click(function (e) {
var s = $('.tt-dataset-topics .tt-suggestions'); var s = $('.tt-dataset-topics .tt-suggestions');
console.log(s.css('height')); console.log(s.css('height'));
if (s.css('height') == '0px') { if (s.css('height') == '0px') {
s.css({'height':'auto','border-top':'none','overflow':'visible'}); s.css({
'height': 'auto',
'border-top': 'none',
'overflow': 'visible'
});
$(this).removeClass('maximizeResults').addClass('minimizeResults'); $(this).removeClass('maximizeResults').addClass('minimizeResults');
} else { } else {
s.css({'height':'0','border-top':'1px solid rgb(56, 56, 56)','overflow':'hidden'}); s.css({
'height': '0',
'border-top': '1px solid rgb(56, 56, 56)',
'overflow': 'hidden'
});
$(this).removeClass('minimizeResults').addClass('maximizeResults'); $(this).removeClass('minimizeResults').addClass('maximizeResults');
} }
}); });
$('.minimizeMapResults').click(function(e) { $('.minimizeMapResults').click(function (e) {
var s = $('.tt-dataset-maps .tt-suggestions'); var s = $('.tt-dataset-maps .tt-suggestions');
console.log(s.css('height')); console.log(s.css('height'));
if (s.css('height') == '0px') { if (s.css('height') == '0px') {
s.css({'height':'auto','border-top':'none','overflow':'visible'}); s.css({
'height': 'auto',
'border-top': 'none',
'overflow': 'visible'
});
$(this).removeClass('maximizeResults').addClass('minimizeResults'); $(this).removeClass('maximizeResults').addClass('minimizeResults');
} else { } else {
s.css({'height':'0','border-top':'1px solid rgb(56, 56, 56)','overflow':'hidden'}); s.css({
'height': '0',
'border-top': '1px solid rgb(56, 56, 56)',
'overflow': 'hidden'
});
$(this).removeClass('minimizeResults').addClass('maximizeResults'); $(this).removeClass('minimizeResults').addClass('maximizeResults');
} }
}); });
@ -317,7 +359,7 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
// //
$('.sidebarSearch button.addToMap').click(function(event){ $('.sidebarSearch button.addToMap').click(function (event) {
event.stopPropagation(); event.stopPropagation();
}); });
} // end bindSearchHover } // end bindSearchHover
@ -330,32 +372,32 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
var sliding1 = false; var sliding1 = false;
var lT; var lT;
var closeAccount = function() { var closeAccount = function () {
lT = setTimeout(function() { lT = setTimeout(function () {
if (! sliding1) { if (!sliding1) {
sliding1 = true; sliding1 = true;
$('.sidebarAccountIcon').css('background-color','#0F1519'); $('.sidebarAccountIcon').css('background-color', '#0F1519');
$('.sidebarAccountBox').fadeOut(200, function() { $('.sidebarAccountBox').fadeOut(200, function () {
sliding1 = false; sliding1 = false;
accountIsOpen = false; accountIsOpen = false;
}); });
} }
},300); }, 300);
} }
var openAccount = function() { var openAccount = function () {
clearTimeout(lT); clearTimeout(lT);
if (! sliding1) { if (!sliding1) {
sliding1 = true; sliding1 = true;
// hide the other two // hide the other two
$('.sidebarFilterBox').hide(); $('.sidebarFilterBox').hide();
$('.sidebarWandBox').hide(); $('.sidebarWandBox').hide();
$('.sidebarFilterIcon').css('background-color','#0F1519'); $('.sidebarFilterIcon').css('background-color', '#0F1519');
$('.sidebarWandIcon').css('background-color','#0F1519'); $('.sidebarWandIcon').css('background-color', '#0F1519');
$('.sidebarAccountIcon').css('background-color','#000'); $('.sidebarAccountIcon').css('background-color', '#000');
$('.sidebarAccountBox').fadeIn(200, function() { $('.sidebarAccountBox').fadeIn(200, function () {
sliding1 = false; sliding1 = false;
accountIsOpen = true; accountIsOpen = true;
}); });
@ -371,7 +413,7 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
bindAccountHover(); bindAccountHover();
// disable right click events on the new topic and new synapse input fields // disable right click events on the new topic and new synapse input fields
$('#new_topic, #new_synapse').bind('contextmenu', function(e){ $('#new_topic, #new_synapse').bind('contextmenu', function (e) {
return false; return false;
}); });
@ -394,12 +436,13 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
event.stopPropagation(); event.stopPropagation();
}); });
// bind keyboard handlers // bind keyboard handlers
$('#topic_name').bind('keyup', function(e) { $('#topic_name').bind('keyup', function (e) {
switch(e.which) { switch (e.which) {
case 13: case 13:
$('.new_topic').submit(); $('.new_topic').submit();
break; break;
default: break; default:
break;
} }
}); });
@ -437,17 +480,18 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
event.stopPropagation(); event.stopPropagation();
}); });
// bind keyboard handlers // bind keyboard handlers
$('#synapse_desc').bind('keyup', function(e) { $('#synapse_desc').bind('keyup', function (e) {
switch(e.which) { switch (e.which) {
case 13: case 13:
$('.new_synapse').submit(); $('.new_synapse').submit();
break; break;
default: break; default:
break;
} }
}); });
// when either form submits, don't leave the page // when either form submits, don't leave the page
$('.new_topic, .new_synapse').bind('submit', function(event, data){ $('.new_topic, .new_synapse').bind('submit', function (event, data) {
event.preventDefault(); event.preventDefault();
}); });
@ -455,21 +499,25 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
//$(".scroll").mCustomScrollbar(); //$(".scroll").mCustomScrollbar();
// initialize scroll bar for filter by metacode, then hide it and position it correctly again // initialize scroll bar for filter by metacode, then hide it and position it correctly again
$("#filter_by_metacode").mCustomScrollbar({advanced: { updateOnContentResize: true }}); $("#filter_by_metacode").mCustomScrollbar({
advanced: {
updateOnContentResize: true
}
});
$('.sidebarFilterBox').hide().css({ $('.sidebarFilterBox').hide().css({
position:'absolute', position: 'absolute',
top: '35px', top: '35px',
right: '-36px' right: '-36px'
}); });
// initialize metacode spinner and then hide it // initialize metacode spinner and then hide it
$("#metacodeImg").CloudCarousel( { $("#metacodeImg").CloudCarousel({
titleBox: $('#metacodeImgTitle'), titleBox: $('#metacodeImgTitle'),
yRadius:40, yRadius: 40,
xPos: 150, xPos: 150,
yPos: 40, yPos: 40,
speed:0.3, speed: 0.3,
mouseWheel:true, mouseWheel: true,
bringToFront: true bringToFront: true
}); });
$('.new_topic').hide(); $('.new_topic').hide();
@ -478,41 +526,46 @@ var labelType, useGradients, nativeTextSupport, animate, json, Mconsole = null,
$('.notice.metamaps').delay(10000).fadeOut('fast'); $('.notice.metamaps').delay(10000).fadeOut('fast');
$('.alert.metamaps').delay(10000).fadeOut('fast'); $('.alert.metamaps').delay(10000).fadeOut('fast');
$('#center-container').bind('contextmenu', function(e){ $('#center-container').bind('contextmenu', function (e) {
return false; return false;
}); });
addHoverForSettings(); addHoverForSettings();
//bind best_in_place ajax callbacks //bind best_in_place ajax callbacks
$('.best_in_place_desc').bind("ajax:success", function() { $('.best_in_place_desc').bind("ajax:success", function () {
$(this).parents('.CardOnGraph').find('.scroll').mCustomScrollbar("update"); $(this).parents('.CardOnGraph').find('.scroll').mCustomScrollbar("update");
}); });
$('.best_in_place_link').bind("ajax:success", function() { $('.best_in_place_link').bind("ajax:success", function () {
var link = $(this).html(); var link = $(this).html();
$(this).parents('.CardOnGraph').find('.go-link').attr('href', link); $(this).parents('.CardOnGraph').find('.go-link').attr('href', link);
}); });
//bind lightbox clicks //bind lightbox clicks
$('.openLightbox').click(function(event) { $('.openLightbox').click(function (event) {
openLightbox($(this).attr('data-open')); openLightbox($(this).attr('data-open'));
event.preventDefault(); event.preventDefault();
return false; return false;
}); });
// bind permission changer events // bind permission changer events
$('.permIcon').click(function() { $('.permIcon').click(function () {
$(this).siblings('#map_permission').val( $(this).attr('data-permission') ); $(this).siblings('#map_permission').val($(this).attr('data-permission'));
$(this).siblings('.permIcon').find('.mapPermIcon').removeClass('selected'); $(this).siblings('.permIcon').find('.mapPermIcon').removeClass('selected');
$(this).find('.mapPermIcon').addClass('selected'); $(this).find('.mapPermIcon').addClass('selected');
}); });
// bind keyboard handlers // bind keyboard handlers
$('body').bind('keyup', function(e) { $('body').bind('keyup', function (e) {
switch(e.which) { switch (e.which) {
case 13: enterKeyHandler(e); break; case 13:
case 27: escKeyHandler(); break; enterKeyHandler(e);
default: break; //console.log(e.which); break;
case 27:
escKeyHandler();
break;
default:
break; //console.log(e.which);
} }
}); });
@ -523,18 +576,18 @@ function addHoverForSettings() {
$(".permActivator").unbind('mouseover'); $(".permActivator").unbind('mouseover');
$(".permActivator").unbind('mouseout'); $(".permActivator").unbind('mouseout');
var sliding2 = false; var sliding2 = false;
var lT1,lT2; var lT1, lT2;
$(".permActivator").bind('mouseover', $(".permActivator").bind('mouseover',
function () { function () {
clearTimeout(lT2); clearTimeout(lT2);
that = this; that = this;
lT1 = setTimeout(function() { lT1 = setTimeout(function () {
if (! sliding2) { if (!sliding2) {
sliding2 = true; sliding2 = true;
$(that).animate({ $(that).animate({
width: '203px', width: '203px',
height: '37px' height: '37px'
}, 300, function() { }, 300, function () {
sliding2 = false; sliding2 = false;
}); });
} }
@ -545,23 +598,23 @@ function addHoverForSettings() {
function () { function () {
clearTimeout(lT1); clearTimeout(lT1);
that = this; that = this;
lT2 = setTimeout(function() { lT2 = setTimeout(function () {
if (! sliding2) { if (!sliding2) {
sliding2 = true; sliding2 = true;
$(that).animate({ $(that).animate({
height: '16px', height: '16px',
width: '16px' width: '16px'
}, 300, function() { }, 300, function () {
sliding2 = false; sliding2 = false;
}); });
} }
},800); }, 800);
} }
); );
$('.best_in_place_permission').unbind("ajax:success"); $('.best_in_place_permission').unbind("ajax:success");
//bind best_in_place ajax callbacks //bind best_in_place ajax callbacks
$('.best_in_place_permission').bind("ajax:success", function() { $('.best_in_place_permission').bind("ajax:success", function () {
var permission = $(this).html(); var permission = $(this).html();
var el = $(this).parents('.cardSettings').find('.mapPerm'); var el = $(this).parents('.cardSettings').find('.mapPerm');
el.attr('title', permission); el.attr('title', permission);
@ -569,14 +622,14 @@ function addHoverForSettings() {
else if (permission == "public") el.html("pu"); else if (permission == "public") el.html("pu");
else if (permission == "private") el.html("pr"); else if (permission == "private") el.html("pr");
}); });
} } // end addHoverForSettings
// this is to save the layout of a map // this is to save the layout of a map
function saveLayoutAll() { function saveLayoutAll() {
$('.sidebarSave .tip').html('Saving...'); $('.sidebarSave .tip').html('Saving...');
var coor = ""; var coor = "";
if (gType == "arranged" || gType == "chaotic") { if (gType == "arranged" || gType == "chaotic") {
Mconsole.graph.eachNode(function(n) { Mconsole.graph.eachNode(function (n) {
coor = coor + n.getData("mappingid") + '/' + n.pos.x + '/' + n.pos.y + ','; coor = coor + n.getData("mappingid") + '/' + n.pos.x + '/' + n.pos.y + ',';
}); });
coor = coor.slice(0, -1); coor = coor.slice(0, -1);
@ -597,9 +650,10 @@ function saveLayout(id) {
// this is to save your console to a map // this is to save your console to a map
function saveToMap() { function saveToMap() {
var nodes_data = "", synapses_data = ""; var nodes_data = "",
synapses_data = "";
var synapses_array = new Array(); var synapses_array = new Array();
Mconsole.graph.eachNode(function(n) { Mconsole.graph.eachNode(function (n) {
//don't add to the map if it was filtered out //don't add to the map if it was filtered out
if (categoryVisible[n.getData('metacode')] == false) { if (categoryVisible[n.getData('metacode')] == false) {
return; return;
@ -614,13 +668,13 @@ function saveToMap() {
var y = Math.sin(n.pos.theta) * n.pos.rho; var y = Math.sin(n.pos.theta) * n.pos.rho;
} }
nodes_data += n.id + '/' + x + '/' + y + ','; nodes_data += n.id + '/' + x + '/' + y + ',';
n.eachAdjacency(function(adj) { n.eachAdjacency(function (adj) {
synapses_array.push(adj.getData("id")); synapses_array.push(adj.getData("id"));
}); });
}); });
//get unique values only //get unique values only
synapses_array = $.grep(synapses_array, function(value, key){ synapses_array = $.grep(synapses_array, function (value, key) {
return $.inArray(value, synapses_array) === key; return $.inArray(value, synapses_array) === key;
}); });
@ -636,7 +690,7 @@ function fetchRelatives(node) {
var myA = $.ajax({ var myA = $.ajax({
type: "Get", type: "Get",
url: "/topics/" + node.id + "?format=json", url: "/topics/" + node.id + "?format=json",
success: function(data) { success: function (data) {
if (gType == "centered") { if (gType == "centered") {
Mconsole.busy = true; Mconsole.busy = true;
Mconsole.op.sum(data, { Mconsole.op.sum(data, {
@ -654,8 +708,7 @@ function fetchRelatives(node) {
}); });
}); });
Mconsole.busy = false; Mconsole.busy = false;
} } else {
else {
Mconsole.op.sum(data, { Mconsole.op.sum(data, {
type: 'nothing', type: 'nothing',
}); });
@ -670,7 +723,7 @@ function fetchRelatives(node) {
duration: 1000 duration: 1000
});*/ });*/
}, },
error: function(){ error: function () {
alert('failure'); alert('failure');
} }
}); });
@ -679,75 +732,94 @@ function fetchRelatives(node) {
// @param node = JIT node object // @param node = JIT node object
// @param metacode = STRING like "Idea", "Action", etc. // @param metacode = STRING like "Idea", "Action", etc.
function updateMetacode(node, metacode) { function updateMetacode(node, metacode) {
var mdata = { "topic": { "metacode": metacode } }; var mdata = {
"topic": {
"metacode": metacode
}
};
$.ajax({ $.ajax({
type: "PUT", type: "PUT",
dataType: 'json', dataType: 'json',
url: "/topics/" + node.id, url: "/topics/" + node.id,
data: mdata, data: mdata,
success: function(data) { success: function (data) {
$('.CardOnGraph').find('.metacodeTitle').text(metacode); $('.CardOnGraph').find('.metacodeTitle').text(metacode);
$('.CardOnGraph').find('.metacodeImage').css('background-image', 'url(' + imgArray[metacode].src + ')'); $('.CardOnGraph').find('.metacodeImage').css('background-image', 'url(' + imgArray[metacode].src + ')');
node.setData("metacode", metacode); node.setData("metacode", metacode);
Mconsole.plot(); Mconsole.plot();
$('.metacodeTitle').removeClass('minimize'); // this line flips the pull up arrow to a drop down arrow $('.metacodeTitle').removeClass('minimize'); // this line flips the pull up arrow to a drop down arrow
$('.metacodeSelect').hide(); $('.metacodeSelect').hide();
setTimeout(function() { $('.metacodeTitle').hide(); $('.showcard .icon').css('z-index','1'); }, 500); setTimeout(function () {
$('.metacodeTitle').hide();
$('.showcard .icon').css('z-index', '1');
}, 500);
}, },
error: function(){ error: function () {
alert('failed to update metacode'); alert('failed to update metacode');
} }
}); });
} }
function updateTopicPermission(node, permission) { function updateTopicPermission(node, permission) {
var mdata = { "topic": { "permission": permission } }; var mdata = {
"topic": {
"permission": permission
}
};
$.ajax({ $.ajax({
type: "PUT", type: "PUT",
dataType: 'json', dataType: 'json',
url: "/topics/" + node.id, url: "/topics/" + node.id,
data: mdata, data: mdata,
success: function(data) { success: function (data) {
$('.showcard .mapPerm').removeClass('co pu pr minimize').addClass( permission.substring(0,2) ); $('.showcard .mapPerm').removeClass('co pu pr minimize').addClass(permission.substring(0, 2));
$('.permissionSelect').remove(); $('.permissionSelect').remove();
node.setData("permission", permission); node.setData("permission", permission);
}, },
error: function(){ error: function () {
alert('failed to update permission'); alert('failed to update permission');
} }
}); });
} }
function updateSynapsePermission(edge, permission) { function updateSynapsePermission(edge, permission) {
var mdata = { "synapse": { "permission": permission } }; var mdata = {
"synapse": {
"permission": permission
}
};
$.ajax({ $.ajax({
type: "PUT", type: "PUT",
dataType: 'json', dataType: 'json',
url: "/synapses/" + edge.data.$id, url: "/synapses/" + edge.data.$id,
data: mdata, data: mdata,
success: function(data) { success: function (data) {
$('#edit_synapse .mapPerm').removeClass('co pu pr minimize').addClass( permission.substring(0,2) ); $('#edit_synapse .mapPerm').removeClass('co pu pr minimize').addClass(permission.substring(0, 2));
$('#edit_synapse .permissionSelect').remove(); $('#edit_synapse .permissionSelect').remove();
edge.setData("permission", permission); edge.setData("permission", permission);
}, },
error: function(){ error: function () {
alert('failed to update permission'); alert('failed to update permission');
} }
}); });
} }
function updateMapPermission(mapid, permission) { function updateMapPermission(mapid, permission) {
var mdata = { "map": { "permission": permission } }; var mdata = {
"map": {
"permission": permission
}
};
$.ajax({ $.ajax({
type: "PUT", type: "PUT",
dataType: 'json', dataType: 'json',
url: "/maps/" + mapid, url: "/maps/" + mapid,
data: mdata, data: mdata,
success: function(data) { success: function (data) {
$('.mapPermission').removeClass('commons public private minimize').addClass( permission ); $('.mapPermission').removeClass('commons public private minimize').addClass(permission);
$('.mapPermission .permissionSelect').remove(); $('.mapPermission .permissionSelect').remove();
}, },
error: function(){ error: function () {
alert('failed to update permission'); alert('failed to update permission');
} }
}); });
@ -757,11 +829,11 @@ function MconsoleReset() {
var tX = Mconsole.canvas.translateOffsetX; var tX = Mconsole.canvas.translateOffsetX;
var tY = Mconsole.canvas.translateOffsetY; var tY = Mconsole.canvas.translateOffsetY;
Mconsole.canvas.translate(-tX,-tY); Mconsole.canvas.translate(-tX, -tY);
var mX = Mconsole.canvas.scaleOffsetX; var mX = Mconsole.canvas.scaleOffsetX;
var mY = Mconsole.canvas.scaleOffsetY; var mY = Mconsole.canvas.scaleOffsetY;
Mconsole.canvas.scale((1/mX),(1/mY)); Mconsole.canvas.scale((1 / mX), (1 / mY));
} }
function openNodeShowcard(node) { function openNodeShowcard(node) {
@ -770,7 +842,7 @@ function openNodeShowcard(node) {
$('.showcard').fadeIn('fast'); $('.showcard').fadeIn('fast');
var s = $('.showcard').find('.scroll'); var s = $('.showcard').find('.scroll');
s.height( s.height() ).mCustomScrollbar(); s.height(s.height()).mCustomScrollbar();
//node.setData('dim', 1, 'current'); //node.setData('dim', 1, 'current');
MetamapsModel.showcardInUse = node.id; MetamapsModel.showcardInUse = node.id;
} }
@ -780,7 +852,7 @@ function openLightbox(which) {
$('#' + which).show(); $('#' + which).show();
$('#lightbox_overlay').show(); $('#lightbox_overlay').show();
$('#lightbox_main').css('margin-top', '-' + ($('#lightbox_main').height() / 2) + 'px' ); $('#lightbox_main').css('margin-top', '-' + ($('#lightbox_main').height() / 2) + 'px');
} }
function cancelMapCreate(id) { function cancelMapCreate(id) {

View file

@ -0,0 +1,75 @@
window.realtime = {};
window.realtime.addTopicToMap = function(topic) {
var newPos, tempForT;
Mconsole.graph.addNode(topic);
tempForT = Mconsole.graph.getNode(topic.id);
tempForT.setData('dim', 1, 'start');
tempForT.setData('dim', 25, 'end');
newPos = new $jit.Complex();
newPos.x = tempForT.data.$xloc;
newPos.y = tempForT.data.$yloc;
tempForT.setPos(newPos, 'start');
tempForT.setPos(newPos, 'current');
tempForT.setPos(newPos, 'end');
Mconsole.fx.plotNode(tempForT, Mconsole.canvas);
return Mconsole.labels.plotLabel(Mconsole.canvas, tempForT, Mconsole.config);
};
window.realtime.updateTopicOnMap = function(topic) {
var newPos, tempForT;
tempForT = Mconsole.graph.getNode(topic.id);
tempForT.data = topic.data;
tempForT.name = topic.name;
if (MetamapsModel.showcardInUse === topic.id) {
populateShowCard(tempForT);
}
newPos = new $jit.Complex();
newPos.x = tempForT.data.$xloc;
newPos.y = tempForT.data.$yloc;
tempForT.setPos(newPos, 'start');
tempForT.setPos(newPos, 'current');
tempForT.setPos(newPos, 'end');
return Mconsole.fx.animate({
modes: ['linear', 'node-property:dim', 'edge-property:lineWidth'],
transition: $jit.Trans.Quad.easeInOut,
duration: 500
});
};
window.realtime.addSynapseToMap = function(synapse) {
var Node1, Node2, tempForS;
Node1 = Mconsole.graph.getNode(synapse.data.$direction[0]);
Node2 = Mconsole.graph.getNode(synapse.data.$direction[1]);
Mconsole.graph.addAdjacence(Node1, Node2, {});
tempForS = Mconsole.graph.getAdjacence(Node1.id, Node2.id);
tempForS.setDataset('start', {
lineWidth: 0.4
});
tempForS.setDataset('end', {
lineWidth: 2
});
tempForS.data = synapse.data;
Mconsole.fx.plotLine(tempForS, Mconsole.canvas);
return Mconsole.fx.animate({
modes: ['linear', 'node-property:dim', 'edge-property:lineWidth'],
transition: $jit.Trans.Quad.easeInOut,
duration: 500
});
};
window.realtime.updateSynapseOnMap = function(synapse) {
var k, tempForS, v, wasShowDesc, _ref;
tempForS = Mconsole.graph.getAdjacence(synapse.data.$direction[0], synapse.data.$direction[1]);
wasShowDesc = tempForS.data.$showDesc;
_ref = synapse.data;
for (k in _ref) {
v = _ref[k];
tempForS.data[k] = v;
}
tempForS.data.$showDesc = wasShowDesc;
if (MetamapsModel.edgecardInUse === synapse.data.$id) {
editEdge(tempForS, false);
}
return Mconsole.plot();
};

View file

@ -10,7 +10,7 @@ module TopicsHelper
topic['value'] = t.name topic['value'] = t.name
topic['description'] = t.desc.truncate(35) # make this return matched results topic['description'] = t.desc.truncate(35) # make this return matched results
topic['type'] = t.metacode.name topic['type'] = t.metacode.name
topic['typeImageURL'] = '/assets/' + t.metacode.icon topic['typeImageURL'] = t.metacode.icon
topic['permission'] = t.permission topic['permission'] = t.permission
topic['mapCount'] = t.maps.count topic['mapCount'] = t.maps.count
topic['synapseCount'] = t.synapses.count topic['synapseCount'] = t.synapses.count

View file

@ -77,7 +77,7 @@
$(document).ready(function() { $(document).ready(function() {
function bindFilterHover() { function bindFilterHover() {
var filterIsOpen = false var filterIsOpen = false;
// controls the sliding hover of the bottom left menu // controls the sliding hover of the bottom left menu
var sliding1 = false; var sliding1 = false;
@ -121,7 +121,7 @@
function bindInfoHover() { function bindInfoHover() {
var infoIsOpen = false var infoIsOpen = false;
// controls the sliding hover of the bottom left menu // controls the sliding hover of the bottom left menu
var sliding1 = false; var sliding1 = false;
@ -254,9 +254,9 @@
initialize("chaotic", true); initialize("chaotic", true);
}); });
} }
window.realtime.socket = io.connect('http://gentle-savannah-1303.herokuapp.com'); // this is for the heroku staging environment //window.realtime.socket = io.connect('http://gentle-savannah-1303.herokuapp.com'); // this is for the heroku staging environment
//window.realtime.socket = io.connect('http://metamaps.cc:5001'); // this is for metamaps.cc //window.realtime.socket = io.connect('http://metamaps.cc:5001'); // this is for metamaps.cc
//window.realtime.socket = io.connect('http://localhost:5001'); // this is for localhost development window.realtime.socket = io.connect('http://localhost:5001'); // this is for localhost development
window.realtime.socket.on('connect', function() { window.realtime.socket.on('connect', function() {
subscribeToRooms(); subscribeToRooms();

View file

@ -5,8 +5,8 @@
#%> #%>
<% content_for :title, @user.name + "'s Settings | Metamaps" %> <% content_for :title, @user.name + "'s Settings | Metamaps" %>
<%= formula_form_for @user, url: user_url do |form| %>
<h1 class="index">Your Settings</h1> <h1 class="index">Your Settings</h1>
<%= formula_form_for @user, url: user_url do |form| %>
<h3>Edit Account</h3> <h3>Edit Account</h3>
<%= form.input :name, label: "Name", class: "name" %> <%= form.input :name, label: "Name", class: "name" %>
<%= form.input :email, label: "Email", class: "email" %> <%= form.input :email, label: "Email", class: "email" %>

View file

@ -0,0 +1,10 @@
development:
min_messages: WARNING
adapter: postgresql
host: 127.0.0.1
port: 5432
encoding: unicode
database: metamap002_development
pool: 5
username: postgres
password: "3112"

View file

@ -10,8 +10,8 @@ Devise.setup do |config|
# config.mailer = "Devise::Mailer" # config.mailer = "Devise::Mailer"
if Rails.env.development? if Rails.env.development? # this is for Connors localhost
#config.secret_key = 'f71c467e526f23d614b3b08866cad4788c502bed869c282f06e73ee6c94675b62fe1f6d52fa7ba8196b33031f0d2f3b67e27ea07693c52ecebccb01700cad614' config.secret_key = 'f71c467e526f23d614b3b08866cad4788c502bed869c282f06e73ee6c94675b62fe1f6d52fa7ba8196b33031f0d2f3b67e27ea07693c52ecebccb01700cad614'
end end
if Rails.env.production? # this is for the heroku staging environment if Rails.env.production? # this is for the heroku staging environment
config.secret_key = 'd91ba0da95749174ee2b8922034783cbde4945409ed28b13383e18e72844beb74467f8199e9e216f0687cd2290c6e46bf74da24486d14bba3671d76c5b10c753' config.secret_key = 'd91ba0da95749174ee2b8922034783cbde4945409ed28b13383e18e72844beb74467f8199e9e216f0687cd2290c6e46bf74da24486d14bba3671d76c5b10c753'