Skip to content

Commit

Permalink
Adding active class for menu-button
Browse files Browse the repository at this point in the history
  • Loading branch information
mrjasonweaver committed Nov 5, 2013
1 parent 5f81166 commit 26e88f0
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ Initialize
* * *
### Changelog

#### v.1.2.2 : November 5th, 2013
* [Adding active classes to main menu button and touch-icon](https://github.com/indyplanets/flexnav/issues/67)

#### v.1.2.1 : November 4th, 2013
* [Calculate number of top level nav items with js](https://github.com/indyplanets/flexnav/issues/91)

Expand Down
15 changes: 9 additions & 6 deletions coffeescripts/jquery.flexnav.coffee
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
###
FlexNav.js 1.2.1
FlexNav.js 1.2.2
Created by Jason Weaver http://jasonweaver.name
Released under http://unlicense.org/
Expand All @@ -20,7 +20,7 @@ $.fn.flexNav = (options) ->
options

$nav = $(@)

# Set some classes in the markup
$nav.addClass('with-js')
if settings.transitionOpacity is true
Expand Down Expand Up @@ -83,6 +83,8 @@ $.fn.flexNav = (options) ->
if $(window).width() <= breakpoint
$nav.removeClass("lg-screen").addClass("sm-screen")
$top_nav_items.css('width','100%')
selector = settings['buttonSelector'] + ', ' + settings['buttonSelector'] + ' .touch-button'
$(selector).removeClass('active')
# Toggle nav menu closed for one pager after anchor clicked
$('.one-page li a').on( 'click', ->
$nav.removeClass('show')
Expand All @@ -106,12 +108,13 @@ $.fn.flexNav = (options) ->
$(settings['buttonSelector']).data('navEl', $nav)

# Add in touch buttons
selector = '.item-with-ul, ' + settings['buttonSelector']
$(selector).append('<span class="touch-button"><i class="navicon">&#9660;</i></span>')
touch_selector = '.item-with-ul, ' + settings['buttonSelector']
$(touch_selector).append('<span class="touch-button"><i class="navicon">&#9660;</i></span>')

# Toggle touch for nav menu
selector = settings['buttonSelector'] + ', ' + settings['buttonSelector'] + ' .touch-button'
$(selector).on('click', (e) ->
toggle_selector = settings['buttonSelector'] + ', ' + settings['buttonSelector'] + ' .touch-button'
$(toggle_selector).on('click', (e) ->
$(toggle_selector).toggleClass('active')
e.preventDefault()
e.stopPropagation()
bs = settings['buttonSelector']
Expand Down
16 changes: 10 additions & 6 deletions js/jquery.flexnav.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
FlexNav.js 1.2.1
FlexNav.js 1.2.2
Created by Jason Weaver http://jasonweaver.name
Released under http://unlicense.org/
Expand All @@ -14,7 +14,7 @@
$ = jQuery;

$.fn.flexNav = function(options) {
var $nav, $top_nav_items, breakpoint, count, nav_percent, nav_width, resetMenu, resizer, selector, settings, showMenu;
var $nav, $top_nav_items, breakpoint, count, nav_percent, nav_width, resetMenu, resizer, settings, showMenu, toggle_selector, touch_selector;
settings = $.extend({
'animationSpeed': 250,
'transitionOpacity': true,
Expand Down Expand Up @@ -68,9 +68,12 @@
}
};
resizer = function() {
var selector;
if ($(window).width() <= breakpoint) {
$nav.removeClass("lg-screen").addClass("sm-screen");
$top_nav_items.css('width', '100%');
selector = settings['buttonSelector'] + ', ' + settings['buttonSelector'] + ' .touch-button';
$(selector).removeClass('active');
return $('.one-page li a').on('click', function() {
return $nav.removeClass('show');
});
Expand All @@ -90,11 +93,12 @@
}
};
$(settings['buttonSelector']).data('navEl', $nav);
selector = '.item-with-ul, ' + settings['buttonSelector'];
$(selector).append('<span class="touch-button"><i class="navicon">&#9660;</i></span>');
selector = settings['buttonSelector'] + ', ' + settings['buttonSelector'] + ' .touch-button';
$(selector).on('click', function(e) {
touch_selector = '.item-with-ul, ' + settings['buttonSelector'];
$(touch_selector).append('<span class="touch-button"><i class="navicon">&#9660;</i></span>');
toggle_selector = settings['buttonSelector'] + ', ' + settings['buttonSelector'] + ' .touch-button';
$(toggle_selector).on('click', function(e) {
var $btnParent, $thisNav, bs;
$(toggle_selector).toggleClass('active');
e.preventDefault();
e.stopPropagation();
bs = settings['buttonSelector'];
Expand Down
2 changes: 1 addition & 1 deletion js/jquery.flexnav.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 26e88f0

Please sign in to comment.