From 0ebc3dbc372d677f5481c6007fbb292c1b93fd28 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Fri, 21 Nov 2014 15:45:44 -0500 Subject: [PATCH] filter and realtime button active states. zoomExtents excludes filtered topics --- app/assets/javascripts/src/Metamaps.JIT.js | 15 +++-- app/assets/javascripts/src/Metamaps.js | 70 +++++++++++++++++++--- app/assets/stylesheets/application.css | 4 +- app/assets/stylesheets/clean.css | 6 +- app/views/shared/_filterBox.html.erb | 6 +- 5 files changed, 82 insertions(+), 19 deletions(-) diff --git a/app/assets/javascripts/src/Metamaps.JIT.js b/app/assets/javascripts/src/Metamaps.JIT.js index 88436a80..370a5f91 100644 --- a/app/assets/javascripts/src/Metamaps.JIT.js +++ b/app/assets/javascripts/src/Metamaps.JIT.js @@ -1861,7 +1861,7 @@ Metamaps.JIT = { var x = n.pos.x, y = n.pos.y; - if (counter == 0){ + if (counter == 0 && n.getData('alpha') == 1){ maxX = x; minX = x; maxY = y; @@ -1880,12 +1880,15 @@ Metamaps.JIT = { } 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); + // only adjust these values if the node is not filtered + if (n.getData('alpha') == 1) { + 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++; + counter++; + } }); var spanX = maxX - minX; diff --git a/app/assets/javascripts/src/Metamaps.js b/app/assets/javascripts/src/Metamaps.js index f52f997a..d3ba78ea 100644 --- a/app/assets/javascripts/src/Metamaps.js +++ b/app/assets/javascripts/src/Metamaps.js @@ -1888,13 +1888,13 @@ Metamaps.Realtime = { turnOn: function (notify) { var self = Metamaps.Realtime; - if (!self.status) { - if (notify) self.sendRealtimeOn(); - $(".rtMapperSelf").removeClass('littleRtOff').addClass('littleRtOn'); - self.status = true; - $(".sidebarCollaborateIcon").addClass("blue"); - $(".collabCompass").show(); - } + if (notify) self.sendRealtimeOn(); + $(".rtMapperSelf").removeClass('littleRtOff').addClass('littleRtOn'); + $('.rtOn').addClass('active'); + $('.rtOff').removeClass('active'); + self.status = true; + $(".sidebarCollaborateIcon").addClass("blue"); + $(".collabCompass").show(); }, turnOff: function (silent) { var self = Metamaps.Realtime; @@ -1902,6 +1902,8 @@ Metamaps.Realtime = { if (self.status) { if (!silent) self.sendRealtimeOff(); $(".rtMapperSelf").removeClass('littleRtOn').addClass('littleRtOff'); + $('.rtOn').removeClass('active'); + $('.rtOff').addClass('active'); self.status = false; $(".sidebarCollaborateIcon").removeClass("blue"); $(".collabCompass").hide(); @@ -3111,6 +3113,8 @@ Metamaps.Filter = { $('#filter_by_metacode ul').empty(); $('#filter_by_mapper ul').empty(); $('#filter_by_synapse ul').empty(); + + $('.filterBox .showAll').addClass('active'); }, /* Most of this data essentially depends on the ruby function which are happening for filter inside view filterBox @@ -3239,36 +3243,48 @@ Metamaps.Filter = { filterAllMetacodes: function (e) { var self = Metamaps.Filter; $('#filter_by_metacode ul li').addClass('toggledOff'); + $('.showAllMetacodes').removeClass('active'); + $('.hideAllMetacodes').addClass('active'); self.visible.metacodes = []; self.passFilters(); }, filterNoMetacodes: function (e) { var self = Metamaps.Filter; $('#filter_by_metacode ul li').removeClass('toggledOff'); + $('.showAllMetacodes').addClass('active'); + $('.hideAllMetacodes').removeClass('active'); self.visible.metacodes = self.filters.metacodes.slice(); self.passFilters(); }, filterAllMappers: function (e) { var self = Metamaps.Filter; $('#filter_by_mapper ul li').addClass('toggledOff'); + $('.showAllMappers').removeClass('active'); + $('.hideAllMappers').addClass('active'); self.visible.mappers = []; self.passFilters(); }, filterNoMappers: function (e) { var self = Metamaps.Filter; $('#filter_by_mapper ul li').removeClass('toggledOff'); + $('.showAllMappers').addClass('active'); + $('.hideAllMappers').removeClass('active'); self.visible.mappers = self.filters.mappers.slice(); self.passFilters(); }, filterAllSynapses: function (e) { var self = Metamaps.Filter; $('#filter_by_synapse ul li').addClass('toggledOff'); + $('.showAllSynapses').removeClass('active'); + $('.hideAllSynapses').addClass('active'); self.visible.synapses = []; self.passFilters(); }, filterNoSynapses: function (e) { var self = Metamaps.Filter; $('#filter_by_synapse ul li').removeClass('toggledOff'); + $('.showAllSynapses').addClass('active'); + $('.hideAllSynapses').removeClass('active'); self.visible.synapses = self.filters.synapses.slice(); self.passFilters(); }, @@ -3292,14 +3308,53 @@ Metamaps.Filter = { toggleMetacode: function () { var self = Metamaps.Filter; self.toggleLi.call(this, 'metacodes'); + + if (self.visible.metacodes.length === self.filters.metacodes.length) { + $('.showAllMetacodes').addClass('active'); + $('.hideAllMetacodes').removeClass('active'); + } + else if (self.visible.metacodes.length === 0) { + $('.showAllMetacodes').removeClass('active'); + $('.hideAllMetacodes').addClass('active'); + } + else { + $('.showAllMetacodes').removeClass('active'); + $('.hideAllMetacodes').removeClass('active'); + } }, toggleMapper: function () { var self = Metamaps.Filter; self.toggleLi.call(this, 'mappers'); + + if (self.visible.mappers.length === self.filters.mappers.length) { + $('.showAllMappers').addClass('active'); + $('.hideAllMappers').removeClass('active'); + } + else if (self.visible.mappers.length === 0) { + $('.showAllMappers').removeClass('active'); + $('.hideAllMappers').addClass('active'); + } + else { + $('.showAllMappers').removeClass('active'); + $('.hideAllMappers').removeClass('active'); + } }, toggleSynapse: function () { var self = Metamaps.Filter; self.toggleLi.call(this, 'synapses'); + + if (self.visible.synapses.length === self.filters.synapses.length) { + $('.showAllSynapses').addClass('active'); + $('.hideAllSynapses').removeClass('active'); + } + else if (self.visible.synapses.length === 0) { + $('.showAllSynapses').removeClass('active'); + $('.hideAllSynapses').addClass('active'); + } + else { + $('.showAllSynapses').removeClass('active'); + $('.hideAllSynapses').removeClass('active'); + } }, passFilters: function () { var self = Metamaps.Filter; @@ -4204,6 +4259,7 @@ Metamaps.Map = { Metamaps.Create.newTopic.hide(); Metamaps.Create.newSynapse.hide(); Metamaps.Filter.close(); + Metamaps.Map.InfoBox.close(); Metamaps.Realtime.endActiveMap(); } }, diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index bd0a5d84..893c67d3 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1007,7 +1007,7 @@ h3.filterBox { cursor: pointer; font-size:12px; } -.sidebarFilterBox span:hover { +.sidebarFilterBox span:hover, .sidebarFilterBox span.active { color: #00BCD4; } .sidebarFilterBox ul { @@ -1104,7 +1104,7 @@ h3.realtimeBoxTitle { text-align: center; font-size:12px; } -.sidebarCollaborateBox .realtimeOnOff:hover { +.sidebarCollaborateBox .realtimeOnOff:hover, .sidebarCollaborateBox .realtimeOnOff.active { color: #00bcd4; } .sidebarCollaborateBox .rtOff { diff --git a/app/assets/stylesheets/clean.css b/app/assets/stylesheets/clean.css index a19a8bfc..4d794d54 100644 --- a/app/assets/stylesheets/clean.css +++ b/app/assets/stylesheets/clean.css @@ -701,7 +701,7 @@ /* infoAndHelp */ -.mapPage .infoAndHelp, .topicPage .infoAndHelp{ +.mapPage .infoAndHelp, .topicPage .infoAndHelp { right: 70px; } .mapPage .openCheatsheet .tooltipsAbove, .topicPage .openCheatsheet .tooltipsAbove { @@ -759,6 +759,10 @@ right: 24px; } +.topicPage .zoomExtents { + display: none; +} + .mapControl { width:32px; height:32px; diff --git a/app/views/shared/_filterBox.html.erb b/app/views/shared/_filterBox.html.erb index 67a8a61e..3a1be35f 100644 --- a/app/views/shared/_filterBox.html.erb +++ b/app/views/shared/_filterBox.html.erb @@ -91,7 +91,7 @@

<%= @map ? "MAPPERS" : @topic ? "CREATORS" : "" %>

NONE - ALL + ALL