Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Following the steps below you will be able to get the plugin up and running. If
4. Customizable options:
```javascript
var nav = responsiveNav(".nav-collapse", { // Selector
alwaysDropdown: false, // Boolean: Override breakpoint to always use mobile-style nav
animate: true, // Boolean: Use CSS3 transitions, true or false
transition: 284, // Integer: Speed of the transition, in milliseconds
label: "Menu", // String: Label for the navigation toggle
Expand Down Expand Up @@ -218,6 +219,7 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI

# Changelog

`1.0.33` (2014-12-05) - Adds `alwaysDropdown` option to enable mobile-style navigation regardless of the MQ breakpoint.

`1.0.32` (2014-03-05) - Ditching the `[].forEach.call(NodeList)` hack to make the code more sensible and future-proof.

Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "responsive-nav",
"version": "1.0.32",
"version": "1.0.33",
"main": [
"responsive-nav.css",
"responsive-nav.js"
Expand Down
7 changes: 7 additions & 0 deletions client/dist/responsive-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@

// Default options
this.options = {
alwaysDropdown: false,
animate: true, // Boolean: Use CSS3 transitions, true or false
transition: 284, // Integer: Speed of the transition, in milliseconds
label: "Menu", // String: Label for the navigation toggle
Expand All @@ -165,6 +166,11 @@
// Adds "js" class for <html>
addClass(htmlEl, this.options.jsClass);

// Disable media query at breakpoint
if (!this.options.alwaysDropdown) {
addClass(htmlEl, "nav-multiple-layouts");
}

// Wrapper
this.wrapperEl = el.replace("#", "");

Expand Down Expand Up @@ -202,6 +208,7 @@
removeClass(nav, opts.navClass);
removeClass(nav, opts.navClass + "-" + this.index);
removeClass(htmlEl, opts.navActiveClass);
removeClass(htmlEl, "nav-multiple-layouts");
nav.removeAttribute("style");
nav.removeAttribute("aria-hidden");

Expand Down
2 changes: 1 addition & 1 deletion client/dist/responsive-nav.min.js

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

6 changes: 3 additions & 3 deletions client/dist/styles/responsive-nav.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
}

@media screen and (min-width: 40em) {
.js .nav-collapse {
.js.nav-multiple-layouts .nav-collapse {
position: relative;
}
.js .nav-collapse.closed {
.js.nav-multiple-layouts .nav-collapse.closed {
max-height: none;
}
.nav-toggle {
.nav-multiple-layouts .nav-toggle {
display: none;
}
}
7 changes: 7 additions & 0 deletions client/src/responsive-nav.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

// Default options
this.options = {
alwaysDropdown: false,
animate: true, // Boolean: Use CSS3 transitions, true or false
transition: 284, // Integer: Speed of the transition, in milliseconds
label: "Menu", // String: Label for the navigation toggle
Expand All @@ -52,6 +53,11 @@
// Adds "js" class for <html>
addClass(htmlEl, this.options.jsClass);

// Disable media query at breakpoint
if (!this.options.alwaysDropdown) {
addClass(htmlEl, "nav-multiple-layouts");
}

// Wrapper
this.wrapperEl = el.replace("#", "");

Expand Down Expand Up @@ -89,6 +95,7 @@
removeClass(nav, opts.navClass);
removeClass(nav, opts.navClass + "-" + this.index);
removeClass(htmlEl, opts.navActiveClass);
removeClass(htmlEl, "nav-multiple-layouts");
nav.removeAttribute("style");
nav.removeAttribute("aria-hidden");

Expand Down
6 changes: 3 additions & 3 deletions client/src/styles/responsive-nav.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@
}

@media screen and (min-width: 40em) {
.js .nav-collapse {
.js.nav-multiple-layouts .nav-collapse {
position: relative;
}
.js .nav-collapse.closed {
.js.nav-multiple-layouts .nav-collapse.closed {
max-height: none;
}
.nav-toggle {
.nav-multiple-layouts .nav-toggle {
display: none;
}
}
13 changes: 10 additions & 3 deletions client/test/responsive-nav.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe("responsive-nav", function () {

it("adds a 'js' class", function () {
insertNav();
expect(document.documentElement.className).toBe("js");
expect(document.documentElement.className).toBe("js nav-multiple-layouts");
nav.destroy();
});

Expand Down Expand Up @@ -242,6 +242,13 @@ describe("responsive-nav", function () {
*/
describe("options", function () {

it("allows user to always use dropdown navigation", function() {
document.getElementsByTagName("body")[0].appendChild(el);
nav = responsiveNav("#" + selector, { alwaysDropdown: true });
expect(document.documentElement.className).not.toBe("js nav-multiple-layouts");
nav.destroy();
});

it("turns off animation if needed", function () {
document.getElementsByTagName("body")[0].appendChild(el);
nav = responsiveNav("#" + selector, { animate: false });
Expand Down Expand Up @@ -295,14 +302,14 @@ describe("responsive-nav", function () {
it("allows users to change the default container class", function () {
document.getElementsByTagName("body")[0].appendChild(el);
nav = responsiveNav("#" + selector, { navClass: "random-class" });
expect(el.className).toBe("random-class random-class-22 closed");
expect(el.className).toBe("random-class random-class-23 closed");
nav.destroy();
});

it("allows users to specify custom JS class", function () {
document.getElementsByTagName("body")[0].appendChild(el);
nav = responsiveNav("#" + selector, { jsClass: "foobar" });
expect(document.documentElement.className).toBe("js foobar");
expect(document.documentElement.className).toBe("js foobar nav-multiple-layouts");
nav.destroy();
});

Expand Down
Loading