2013-06-24 12:43:11 -04:00
|
|
|
$.fn.selectGuide = function(guide) {
|
2012-05-26 00:28:24 -04:00
|
|
|
$("select", this).val(guide);
|
2013-06-24 12:43:11 -04:00
|
|
|
};
|
2012-05-26 00:28:24 -04:00
|
|
|
|
2013-06-24 12:43:11 -04:00
|
|
|
var guidesIndex = {
|
|
|
|
bind: function() {
|
2012-05-26 00:28:24 -04:00
|
|
|
var currentGuidePath = window.location.pathname;
|
|
|
|
var currentGuide = currentGuidePath.substring(currentGuidePath.lastIndexOf("/")+1);
|
|
|
|
$(".guides-index-small").
|
|
|
|
on("change", "select", guidesIndex.navigate).
|
|
|
|
selectGuide(currentGuide);
|
2013-06-24 12:43:11 -04:00
|
|
|
$(document).on("click", ".more-info-button", function(e){
|
2012-05-26 00:28:24 -04:00
|
|
|
e.stopPropagation();
|
2013-06-24 12:43:11 -04:00
|
|
|
if ($(".more-info-links").is(":visible")) {
|
2012-05-26 00:28:24 -04:00
|
|
|
$(".more-info-links").addClass("s-hidden").unwrap();
|
|
|
|
} else {
|
|
|
|
$(".more-info-links").wrap("<div class='more-info-container'></div>").removeClass("s-hidden");
|
|
|
|
}
|
2013-06-24 12:43:11 -04:00
|
|
|
});
|
|
|
|
$("#guidesMenu").on("click", function(e) {
|
|
|
|
$("#guides").toggle();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
$(document).on("click", function(e){
|
|
|
|
e.stopPropagation();
|
|
|
|
var $button = $(".more-info-button");
|
|
|
|
var element;
|
2012-05-26 00:28:24 -04:00
|
|
|
|
2013-06-24 12:43:11 -04:00
|
|
|
// Cross browser find the element that had the event
|
|
|
|
if (e.target) element = e.target;
|
|
|
|
else if (e.srcElement) element = e.srcElement;
|
2012-05-26 00:28:24 -04:00
|
|
|
|
2013-06-24 12:43:11 -04:00
|
|
|
// Defeat the older Safari bug:
|
|
|
|
// http://www.quirksmode.org/js/events_properties.html
|
|
|
|
if (element.nodeType === 3) element = element.parentNode;
|
2012-05-26 00:28:24 -04:00
|
|
|
|
2013-06-24 12:43:11 -04:00
|
|
|
var $element = $(element);
|
2012-05-26 00:28:24 -04:00
|
|
|
|
2013-06-24 12:43:11 -04:00
|
|
|
var $container = $element.parents(".more-info-container");
|
2012-05-26 00:28:24 -04:00
|
|
|
|
2013-06-24 12:43:11 -04:00
|
|
|
// We've captured a click outside the popup
|
|
|
|
if($container.length === 0){
|
|
|
|
$container = $button.next(".more-info-container");
|
|
|
|
$container.find(".more-info-links").addClass("s-hidden").unwrap();
|
|
|
|
}
|
2012-05-26 00:28:24 -04:00
|
|
|
});
|
|
|
|
},
|
|
|
|
navigate: function(e){
|
|
|
|
var $list = $(e.target);
|
2013-06-24 12:43:11 -04:00
|
|
|
var url = $list.val();
|
2012-05-26 00:28:24 -04:00
|
|
|
window.location = url;
|
|
|
|
}
|
2013-06-24 12:43:11 -04:00
|
|
|
};
|