Skip to content

Commit

Permalink
code styles
Browse files Browse the repository at this point in the history
  • Loading branch information
gijsroge committed Oct 15, 2015
1 parent 09439f5 commit 975570a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 18 deletions.
2 changes: 1 addition & 1 deletion bower.json
@@ -1,7 +1,7 @@
{
"name": "priority-nav",
"title": "priority-nav",
"version": "1.0.8",
"version": "1.0.9",
"main": [
"dist/priority-nav.js",
"dist/priority-nav-core.css"
Expand Down
27 changes: 16 additions & 11 deletions dist/priority-nav.js
@@ -1,5 +1,5 @@
/*
* priority-nav - v1.0.8 | (c) 2015 @gijsroge | MIT license
* priority-nav - v1.0.9 | (c) 2015 @gijsroge | MIT license
* Repository: https://github.com/gijsroge/priority-navigation.git
* Description: Priority+ pattern navigation that hides menu items if they don't fit on screen.
* Demo: http://gijsroge.github.io/priority-nav.js/
Expand Down Expand Up @@ -169,7 +169,8 @@
* Check if dropdown menu is already on page before creating it
* @param mainNavWrapper
*/
var prepareHtml = function (_this) {
var prepareHtml = function (_this, settings) {

/**
* Create dropdow menu
* @type {HTMLElement}
Expand All @@ -189,6 +190,7 @@
* Move elements to the right spot
*/
_this.insertAfter(toggleWrapper, _this.querySelector(mainNav));

toggleWrapper.appendChild(navDropdown);
toggleWrapper.appendChild(navDropdownToggle);

Expand Down Expand Up @@ -266,7 +268,7 @@
* Move item to array
* @param item
*/
priorityNav.doesItFit = function (_this) {
priorityNav.doesItFit = function (_this, settings) {

/**
* Check if it is the first run
Expand Down Expand Up @@ -465,17 +467,17 @@
/**
* Bind eventlisteners
*/
var listeners = function (_this) {
var listeners = function (_this, settings) {

// Check if an item needs to move
if(window.attachEvent) {
window.attachEvent("onresize", function() {
if(priorityNav.doesItFit)priorityNav.doesItFit(_this);
if(priorityNav.doesItFit)priorityNav.doesItFit(_this, settings);
});
}
else if(window.addEventListener) {
window.addEventListener("resize", function() {
if(priorityNav.doesItFit)priorityNav.doesItFit(_this);
if(priorityNav.doesItFit)priorityNav.doesItFit(_this, settings);
}, true);
}

Expand Down Expand Up @@ -551,7 +553,9 @@
* @param n
* @param r
*/
Node.prototype.insertAfter = function(n,r) {this.insertBefore(n,r.nextSibling);};
if (supports && typeof Node !== "undefined"){
Node.prototype.insertAfter = function(n,r) {this.insertBefore(n,r.nextSibling);};
}


/**
Expand All @@ -561,8 +565,9 @@
*/
priorityNav.init = function (options) {


// Feature test.
if (!supports){
if (!supports && typeof Node === "undefined"){
console.warn("This browser doesn't support priorityNav");
return;
}
Expand Down Expand Up @@ -616,7 +621,7 @@
/**
* Check if we need to create the dropdown elements
*/
prepareHtml(_this);
prepareHtml(_this, settings);

/**
* Store the dropdown element
Expand All @@ -639,12 +644,12 @@
/**
* Event listeners
*/
listeners(_this);
listeners(_this, settings);

/**
* Start first check
*/
priorityNav.doesItFit(_this);
priorityNav.doesItFit(_this, settings);

});

Expand Down
4 changes: 2 additions & 2 deletions dist/priority-nav.min.js

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

2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{
"name": "priority-nav",
"title": "priority-nav",
"version": "1.0.8",
"version": "1.0.9",
"main": "dist/priority-nav.js",
"description": "Priority+ pattern navigation that hides menu items if they don't fit on screen.",
"homepage": "http://gijsroge.github.io/priority-nav.js/",
Expand Down
6 changes: 3 additions & 3 deletions src/priority-nav.js
Expand Up @@ -15,7 +15,7 @@
*/
var priorityNav = {}; // Object for public APIs
var breaks = []; // Object to store instances with breakpoints where the instances menu item"s didin"t fit.
var supports = !!document.querySelector && !!root.addEventListener // Feature test
var supports = !!document.querySelector && !!root.addEventListener; // Feature test
var settings = {};
var instance = 0;
var count = 0;
Expand Down Expand Up @@ -547,7 +547,7 @@
* @param n
* @param r
*/
if (supports && typeof Node !== 'undefined'){
if (supports && typeof Node !== "undefined"){
Node.prototype.insertAfter = function(n,r) {this.insertBefore(n,r.nextSibling);};
}

Expand All @@ -561,7 +561,7 @@


// Feature test.
if (!supports && typeof Node === 'undefined'){
if (!supports && typeof Node === "undefined"){
console.warn("This browser doesn't support priorityNav");
return;
}
Expand Down

0 comments on commit 975570a

Please sign in to comment.