From caa80c067bf9dc549c38d804788c47737785f9b3 Mon Sep 17 00:00:00 2001 From: Connor Turland Date: Thu, 27 Nov 2014 17:27:22 -0500 Subject: [PATCH] links to maps go through without refresh from topic card. --- app/assets/javascripts/src/Metamaps.Router.js | 52 ++++++++++--------- app/assets/javascripts/src/Metamaps.js | 5 +- app/assets/stylesheets/base.css | 1 + app/assets/stylesheets/clean.css | 2 +- app/views/layouts/_templates.html.erb | 2 +- 5 files changed, 35 insertions(+), 27 deletions(-) diff --git a/app/assets/javascripts/src/Metamaps.Router.js b/app/assets/javascripts/src/Metamaps.Router.js index fae8f38e..2afcbf95 100644 --- a/app/assets/javascripts/src/Metamaps.Router.js +++ b/app/assets/javascripts/src/Metamaps.Router.js @@ -194,34 +194,38 @@ Metamaps.Router = new Router(); + + Metamaps.Router.intercept = function (evt) { + var segments; + + var href = { + prop: $(this).prop("href"), + attr: $(this).attr("href") + }; + var root = location.protocol + "//" + location.host + Backbone.history.options.root; + + if (href.prop && href.prop === root) href.attr = ""; + + if (href.prop && href.prop.slice(0, root.length) === root) { + evt.preventDefault(); + + segments = href.attr.split('/'); + segments.splice(0,1); // pop off the element created by the first / + + if (href.attr === "") Metamaps.Router.home(); + else { + console.log(segments); + Metamaps.Router[segments[0]](segments[1]); + } + } + }; + Metamaps.Router.init = function () { Backbone.history.start({ silent: true, pushState: true, root: '/' }); - $(document).on("click", "a:not([data-bypass])", function (evt) { - var segments; - - var href = { - prop: $(this).prop("href"), - attr: $(this).attr("href") - }; - var root = location.protocol + "//" + location.host + Backbone.history.options.root; - - if (href.prop && href.prop === root) href.attr = "" - - if (href.prop && href.prop.slice(0, root.length) === root) { - evt.preventDefault(); - - segments = href.attr.split('/'); - segments.splice(0,1); // pop off the element created by the first / - - if (href.attr === "") Metamaps.Router.home(); - else { - Metamaps.Router[segments[0]](segments[1]); - } - } - }); - } + $(document).on("click", "a:not([data-bypass])", Metamaps.Router.intercept); + }; })(); diff --git a/app/assets/javascripts/src/Metamaps.js b/app/assets/javascripts/src/Metamaps.js index a907df8f..929e8a3f 100644 --- a/app/assets/javascripts/src/Metamaps.js +++ b/app/assets/javascripts/src/Metamaps.js @@ -1092,7 +1092,7 @@ Metamaps.TopicCard = { $('.links .mapCount').unbind().click(function(event){ $('.mapCount .tip').toggle(); - $('.hoverTip').toggleClass('hide'); + $('.showcard .hoverTip').toggleClass('hide'); event.stopPropagation(); }); $('.mapCount .tip').unbind().click(function(event){ @@ -1100,8 +1100,11 @@ Metamaps.TopicCard = { }); $('.showcard').unbind('.hideTip').bind('click.hideTip', function(){ $('.mapCount .tip').hide(); + $('.showcard .hoverTip').removeClass('hide'); }); + $('.mapCount .tip li a').click(Metamaps.Router.intercept); + var originalText = $('.showMore').html(); $('.mapCount .tip .showMore').unbind().toggle( function(event){ diff --git a/app/assets/stylesheets/base.css b/app/assets/stylesheets/base.css index 5b0f3439..b924e7a4 100644 --- a/app/assets/stylesheets/base.css +++ b/app/assets/stylesheets/base.css @@ -312,6 +312,7 @@ .showMore { cursor: pointer; + color: #4FC059; } .mapCount .tip a { diff --git a/app/assets/stylesheets/clean.css b/app/assets/stylesheets/clean.css index bca46825..b2b3e974 100644 --- a/app/assets/stylesheets/clean.css +++ b/app/assets/stylesheets/clean.css @@ -798,7 +798,7 @@ background-color: #4fb5c0; } .callToAction .learnMoreCTA:hover { - background-color: #3d8e8e; + background-color: #419599; } .fullWidthWrapper.withPartners { diff --git a/app/views/layouts/_templates.html.erb b/app/views/layouts/_templates.html.erb index ef8ea19b..820feb09 100644 --- a/app/views/layouts/_templates.html.erb +++ b/app/views/layouts/_templates.html.erb @@ -129,7 +129,7 @@