Skip to content

Commit

Permalink
[Guides] Navigation styling for small devices
Browse files Browse the repository at this point in the history
  • Loading branch information
joefiorini committed Oct 6, 2012
1 parent bcbf1bb commit 03bcd41
Show file tree
Hide file tree
Showing 5 changed files with 487 additions and 231 deletions.
50 changes: 50 additions & 0 deletions guides/assets/javascripts/guides.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,53 @@ function guideMenu(){
document.getElementById('guides').style.display = "none";
}
}

$.fn.selectGuide = function(guide){
$("select", this).val(guide);
}

guidesIndex = {
bind: function(){
var currentGuidePath = window.location.pathname;
var currentGuide = currentGuidePath.substring(currentGuidePath.lastIndexOf("/")+1);
$(".guides-index-small").
on("change", "select", guidesIndex.navigate).
selectGuide(currentGuide);
$(".more-info-button:visible").click(function(e){
e.stopPropagation();
if($(".more-info-links").is(":visible")){
$(".more-info-links").addClass("s-hidden").unwrap();
} else {
$(".more-info-links").wrap("<div class='more-info-container'></div>").removeClass("s-hidden");
}
$(document).on("click", function(e){
var $button = $(".more-info-button");
var element;

// Cross browser find the element that had the event
if (e.target) element = e.target;
else if (e.srcElement) element = e.srcElement;

// Defeat the older Safari bug:
// http://www.quirksmode.org/js/events_properties.html
if (element.nodeType == 3) element = element.parentNode;

var $element = $(element);

var $container = $element.parents(".more-info-container");

// 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();
$(document).off("click");
}
});
});
},
navigate: function(e){
var $list = $(e.target);
url = $list.val();
window.location = url;
}
}
4 changes: 4 additions & 0 deletions guides/assets/javascripts/jquery.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit 03bcd41

Please sign in to comment.