Skip to content

Commit

Permalink
Added support for a cross-browser, accessible, responsive menu modal …
Browse files Browse the repository at this point in the history
…with a clean SVG hamburger icon! Fixes #6
  • Loading branch information
curiositry committed Oct 28, 2014
1 parent 5c044c4 commit 059d888
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 36 deletions.
11 changes: 5 additions & 6 deletions assets/js/index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
/**
* Main JS file for Casper behaviours
*/
*/

/*globals jQuery, document */
(function ($) {
"use strict";

$(document).ready(function(){

$(".post-content").fitVids();

function casperFullImg() {
Expand Down Expand Up @@ -55,7 +54,7 @@
timeout = setTimeout(delayed, threshold || 100);
};
}
// smartresize
// smartresize
jQuery.fn[sr] = function(fn){ return fn ? this.bind('resize', debounce(fn)) : this.trigger(sr); };

})(jQuery,'smartresize');
Expand All @@ -71,10 +70,10 @@
};
var options = $.extend(defaults, options);

options.elem.click(function(event){
options.elem.click(function(event){
event.preventDefault();
var offset = ($(this).attr('data-offset')) ? $(this).attr('data-offset') : false,
position = ($(this).attr('data-position')) ? $(this).attr('data-position') : false;
position = ($(this).attr('data-position')) ? $(this).attr('data-position') : false;
if (offset) {
var toMove = parseInt(offset);
$('html,body').stop(true, false).animate({scrollTop: ($(this.hash).offset().top + toMove) }, options.speed);
Expand All @@ -87,4 +86,4 @@
});

};
})(jQuery);
})(jQuery);
34 changes: 4 additions & 30 deletions partials/menu.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<style>
/*
Modal Overlay
*/
.modal-overlay {
background: slategray;
height: 100%;
Expand All @@ -28,6 +26,7 @@
z-index: 3;
}
/*
Modal Content Area
*/
Expand All @@ -51,19 +50,13 @@
transform: scale(1);
}
/*
General Modal Content
*/
#modal_title {
margin-top: 0;
font-weight: 900;
text-transform: uppercase;
color:#BBC7CC;
}
/*
Close Modal Button
*/
.btn-close {
color:#fdfdfd;
background: none;
Expand All @@ -81,7 +74,6 @@
/* Hamburger Menu Icon */
.open-menu,
.open-menu:hover,
.btn-close,
Expand All @@ -98,20 +90,6 @@
padding: 0;
}
/*
@media screen and (max-width:900px){
.post-template .open-menu{
top:1em;
}
}
*/
@media screen and (max-width:500px){
.open-menu{
/* top:1em;*/
}
}
.post-template .open-menu,
.author-template .open-menu{
top:.5rem;
Expand Down Expand Up @@ -185,7 +163,8 @@
<div class="modal-content flex-container flex-container--center" id="modal_holder" role="document">

<div class="flex-child">
<h1 class="beta" id="modal_title">Menu</h1>***
<h1 class="beta" id="modal_title">Menu</h1>
***

<nav role="navigation" class="beta">
<li><a href="{{@blog.url}}">Home</a></li>
Expand Down Expand Up @@ -216,7 +195,6 @@ function swap () {
swap();
// modal window
(function() {
Expand All @@ -232,7 +210,6 @@ swap();
lastFocus,
i;
// Let's cut down on what we need to type to get an ID
function getId ( id ) {
return document.getElementById(id);
Expand All @@ -247,7 +224,6 @@ swap();
modal.focus();
}
// binds to both the button click and the escape key to close the modal window
// but only if modalOpen is set to true
function modalClose ( event ) {
Expand All @@ -259,7 +235,6 @@ swap();
}
}
// Restrict focus to the modal window when it's open.
// Tabbing will just loop through the whole modal.
// Shift + Tab will allow backup to the top of the modal,
Expand All @@ -271,7 +246,6 @@ swap();
}
}
// Close modal window by clicking on the overlay
mOverlay.addEventListener('click', function( e ) {
if (e.target == modal.parentNode) {
Expand Down

0 comments on commit 059d888

Please sign in to comment.