links to maps go through without refresh from topic card.

This commit is contained in:
Connor Turland 2014-11-27 17:27:22 -05:00
parent 6408f81d08
commit caa80c067b
5 changed files with 35 additions and 27 deletions

View file

@ -194,34 +194,38 @@
Metamaps.Router = new Router(); 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 () { Metamaps.Router.init = function () {
Backbone.history.start({ Backbone.history.start({
silent: true, silent: true,
pushState: true, pushState: true,
root: '/' root: '/'
}); });
$(document).on("click", "a:not([data-bypass])", function (evt) { $(document).on("click", "a:not([data-bypass])", Metamaps.Router.intercept);
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]);
}
}
});
}
})(); })();

View file

@ -1092,7 +1092,7 @@ Metamaps.TopicCard = {
$('.links .mapCount').unbind().click(function(event){ $('.links .mapCount').unbind().click(function(event){
$('.mapCount .tip').toggle(); $('.mapCount .tip').toggle();
$('.hoverTip').toggleClass('hide'); $('.showcard .hoverTip').toggleClass('hide');
event.stopPropagation(); event.stopPropagation();
}); });
$('.mapCount .tip').unbind().click(function(event){ $('.mapCount .tip').unbind().click(function(event){
@ -1100,8 +1100,11 @@ Metamaps.TopicCard = {
}); });
$('.showcard').unbind('.hideTip').bind('click.hideTip', function(){ $('.showcard').unbind('.hideTip').bind('click.hideTip', function(){
$('.mapCount .tip').hide(); $('.mapCount .tip').hide();
$('.showcard .hoverTip').removeClass('hide');
}); });
$('.mapCount .tip li a').click(Metamaps.Router.intercept);
var originalText = $('.showMore').html(); var originalText = $('.showMore').html();
$('.mapCount .tip .showMore').unbind().toggle( $('.mapCount .tip .showMore').unbind().toggle(
function(event){ function(event){

View file

@ -312,6 +312,7 @@
.showMore { .showMore {
cursor: pointer; cursor: pointer;
color: #4FC059;
} }
.mapCount .tip a { .mapCount .tip a {

View file

@ -798,7 +798,7 @@
background-color: #4fb5c0; background-color: #4fb5c0;
} }
.callToAction .learnMoreCTA:hover { .callToAction .learnMoreCTA:hover {
background-color: #3d8e8e; background-color: #419599;
} }
.fullWidthWrapper.withPartners { .fullWidthWrapper.withPartners {

View file

@ -129,7 +129,7 @@
<script type="text/template" id="mapSearchTemplate"> <script type="text/template" id="mapSearchTemplate">
<div class="result{{rtype}}"> <div class="result{{rtype}}">
<div class="searchResIconWrapper"> <div class="searchResIconWrapper">
<img class="icon" src="/assets/metamap32c.png"> <img class="icon" src="/assets/metamap36c.png">
</div> </div>
<div class="resultText"> <div class="resultText">
<p class="resultTitle">{{label}}</p> <p class="resultTitle">{{label}}</p>