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.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);
};
})();

View file

@ -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){

View file

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

View file

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

View file

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