Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

priority-nav

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

priority-nav - npm Package Compare versions

Comparing version 1.0.11 to 1.0.12

10

dist/priority-nav.js
/*
* priority-nav - v1.0.11 | (c) 2016 @gijsroge | MIT license
* priority-nav - v1.0.12 | (c) 2016 @gijsroge | MIT license
* Repository: https://github.com/gijsroge/priority-navigation.git

@@ -28,3 +28,2 @@ * Description: Priority+ pattern navigation that hides menu items if they don't fit on screen.

var count = 0;
var options;
var mainNavWrapper, totalWidth, restWidth, mainNav, navDropdown, navDropdownToggle, dropDownWidth, toggleWrapper;

@@ -194,2 +193,3 @@ var viewportWidth = 0;

navDropdownToggle.setAttribute("aria-controls", "menu");
navDropdownToggle.setAttribute("type", "button");
navDropdown.setAttribute("aria-hidden", "true");

@@ -287,4 +287,2 @@

settings = extend(defaults, options || {});
/**

@@ -550,4 +548,4 @@ * Check if it is the first run

if (evt.keyCode === 27) {
navDropdown.classList.remove("show");
navDropdownToggle.classList.remove("is-open");
document.querySelector(navDropdown).classList.remove("show");
document.querySelector(navDropdownToggle).classList.remove("is-open");
mainNavWrapper.classList.remove("is-open");

@@ -554,0 +552,0 @@ }

4

dist/priority-nav.min.js
/*
* priority-nav - v1.0.11 | (c) 2016 @gijsroge | MIT license
* priority-nav - v1.0.12 | (c) 2016 @gijsroge | MIT license
* Repository: https://github.com/gijsroge/priority-navigation.git

@@ -7,2 +7,2 @@ * Description: Priority+ pattern navigation that hides menu items if they don't fit on screen.

*/
!function(a,b){"function"==typeof define&&define.amd?define("priorityNav",b(a)):"object"==typeof exports?module.exports=b(a):a.priorityNav=b(a)}(window||this,function(a){"use strict";function b(a,b,c){var d;return function(){var e=this,f=arguments,g=function(){d=null,c||a.apply(e,f)},h=c&&!d;clearTimeout(d),d=setTimeout(g,b),h&&a.apply(e,f)}}var c,d,e,f,g,h,i,j,k,l={},m=[],n=!!document.querySelector&&!!a.addEventListener,o={},p=0,q=0,r=0,s={initClass:"js-priorityNav",mainNavWrapper:"nav",mainNav:"ul",navDropdownClassName:"nav__dropdown",navDropdownToggleClassName:"nav__dropdown-toggle",navDropdownLabel:"more",navDropdownBreakpointLabel:"menu",breakPoint:500,throttleDelay:50,offsetPixels:0,count:!0,moved:function(){},movedBack:function(){}},t=function(a,b,c){if("[object Object]"===Object.prototype.toString.call(a))for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&b.call(c,a[d],d,a);else for(var e=0,f=a.length;f>e;e++)b.call(c,a[e],e,a)},u=function(a,b){for(var c=b.charAt(0);a&&a!==document;a=a.parentNode)if("."===c){if(a.classList.contains(b.substr(1)))return a}else if("#"===c){if(a.id===b.substr(1))return a}else if("["===c&&a.hasAttribute(b.substr(1,b.length-2)))return a;return!1},v=function(a,b){var c={};return t(a,function(b,d){c[d]=a[d]}),t(b,function(a,d){c[d]=b[d]}),c},w=function(a,b){if(a.classList)a.classList.toggle(b);else{var c=a.className.split(" "),d=c.indexOf(b);d>=0?c.splice(d,1):c.push(b),a.className=c.join(" ")}},x=function(a,b){return k=document.createElement("span"),h=document.createElement("ul"),i=document.createElement("button"),i.innerHTML=b.navDropdownLabel,i.setAttribute("aria-controls","menu"),h.setAttribute("aria-hidden","true"),a.querySelector(g).parentNode!==a?void console.warn("mainNav is not a direct child of mainNavWrapper, double check please"):(a.insertAfter(k,a.querySelector(g)),k.appendChild(i),k.appendChild(h),h.classList.add(b.navDropdownClassName),h.classList.add("priority-nav__dropdown"),i.classList.add(b.navDropdownToggleClassName),i.classList.add("priority-nav__dropdown-toggle"),k.classList.add(b.navDropdownClassName+"-wrapper"),k.classList.add("priority-nav__wrapper"),void a.classList.add("priority-nav"))},y=function(a){var b=window.getComputedStyle(a),c=parseFloat(b.paddingLeft)+parseFloat(b.paddingRight);return a.clientWidth-c},z=function(){var a=document,b=window,c=a.compatMode&&"CSS1Compat"===a.compatMode?a.documentElement:a.body,d=c.clientWidth,e=c.clientHeight;return b.innerWidth&&d>b.innerWidth&&(d=b.innerWidth,e=b.innerHeight),{width:d,height:e}},A=function(a){e=y(a),j=a.querySelector(h).parentNode===a?a.querySelector(h).offsetWidth:0,f=E(a)+o.offsetPixels,r=z().width};l.doesItFit=function(a){o=v(s,c||{});var d=0===a.getAttribute("instance")?d:o.throttleDelay;p++,b(function(){var b=a.getAttribute("instance");for(A(a);f>=e&&a.querySelector(g).children.length>0||r<o.breakPoint&&a.querySelector(g).children.length>0;)l.toDropdown(a,b),A(a,b),r<o.breakPoint&&D(a,b,o.navDropdownBreakpointLabel);for(;e>=m[b][m[b].length-1]&&r>o.breakPoint;)l.toMenu(a,b),r>o.breakPoint&&D(a,b,o.navDropdownLabel);m[b].length<1&&(a.querySelector(h).classList.remove("show"),D(a,b,o.navDropdownLabel)),a.querySelector(g).children.length<1?(a.classList.add("is-empty"),D(a,b,o.navDropdownBreakpointLabel)):a.classList.remove("is-empty"),B(a,b)},d)()};var B=function(a,b){m[b].length<1?(a.querySelector(i).classList.add("priority-nav-is-hidden"),a.querySelector(i).classList.remove("priority-nav-is-visible"),a.classList.remove("priority-nav-has-dropdown"),a.querySelector(".priority-nav__wrapper").setAttribute("aria-haspopup","false")):(a.querySelector(i).classList.add("priority-nav-is-visible"),a.querySelector(i).classList.remove("priority-nav-is-hidden"),a.classList.add("priority-nav-has-dropdown"),a.querySelector(".priority-nav__wrapper").setAttribute("aria-haspopup","true"))},C=function(a,b){a.querySelector(i).setAttribute("priorityNav-count",m[b].length)},D=function(a,b,c){a.querySelector(i).innerHTML=c};l.toDropdown=function(a,b){a.querySelector(h).firstChild&&a.querySelector(g).children.length>0?a.querySelector(h).insertBefore(a.querySelector(g).lastElementChild,a.querySelector(h).firstChild):a.querySelector(g).children.length>0&&a.querySelector(h).appendChild(a.querySelector(g).lastElementChild),m[b].push(f),B(a,b),a.querySelector(g).children.length>0&&o.count&&C(a,b),o.moved()},l.toMenu=function(a,b){a.querySelector(h).children.length>0&&a.querySelector(g).appendChild(a.querySelector(h).firstElementChild),m[b].pop(),B(a,b),a.querySelector(g).children.length>0&&o.count&&C(a,b),o.movedBack()};var E=function(a){for(var b=a.childNodes,c=0,d=0;d<b.length;d++)3!==b[d].nodeType&&(isNaN(b[d].offsetWidth)||(c+=b[d].offsetWidth));return c},F=function(a,b){window.attachEvent?window.attachEvent("onresize",function(){l.doesItFit&&l.doesItFit(a)}):window.addEventListener&&window.addEventListener("resize",function(){l.doesItFit&&l.doesItFit(a)},!0),a.querySelector(i).addEventListener("click",function(){w(a.querySelector(h),"show"),w(this,"is-open"),w(a,"is-open"),-1!==a.className.indexOf("is-open")?a.querySelector(h).setAttribute("aria-hidden","false"):(a.querySelector(h).setAttribute("aria-hidden","true"),a.querySelector(h).blur())}),document.addEventListener("click",function(c){u(c.target,"."+b.navDropdownClassName)||c.target===a.querySelector(i)||(a.querySelector(h).classList.remove("show"),a.querySelector(i).classList.remove("is-open"),a.classList.remove("is-open"))}),document.onkeydown=function(a){a=a||window.event,27===a.keyCode&&(h.classList.remove("show"),i.classList.remove("is-open"),d.classList.remove("is-open"))}};Element.prototype.remove=function(){this.parentElement.removeChild(this)},NodeList.prototype.remove=HTMLCollection.prototype.remove=function(){for(var a=0,b=this.length;b>a;a++)this[a]&&this[a].parentElement&&this[a].parentElement.removeChild(this[a])},l.destroy=function(){o&&(document.documentElement.classList.remove(o.initClass),k.remove(),o=null,delete l.init,delete l.doesItFit)},n&&"undefined"!=typeof Node&&(Node.prototype.insertAfter=function(a,b){this.insertBefore(a,b.nextSibling)});var G=function(a){var b=a.charAt(0);return"."===b||"#"===b?!1:!0};return l.init=function(a){if(o=v(s,a||{}),!n&&"undefined"==typeof Node)return void console.warn("This browser doesn't support priorityNav");if(!G(o.navDropdownClassName)||!G(o.navDropdownToggleClassName))return void console.warn("No symbols allowed in navDropdownClassName & navDropdownToggleClassName. These are not selectors.");var b=document.querySelectorAll(o.mainNavWrapper);t(b,function(a){return m[q]=[],a.setAttribute("instance",q++),(d=a)?(g=o.mainNav,a.querySelector(g)?(x(a,o),h="."+o.navDropdownClassName,a.querySelector(h)?(i="."+o.navDropdownToggleClassName,a.querySelector(i)?(F(a,o),void l.doesItFit(a)):void console.warn("couldn't find the specified navDropdownToggle element")):void console.warn("couldn't find the specified navDropdown element")):void console.warn("couldn't find the specified mainNav element")):void console.warn("couldn't find the specified mainNavWrapper element")}),p++,document.documentElement.classList.add(o.initClass)},l});
!function(a,b){"function"==typeof define&&define.amd?define("priorityNav",b(a)):"object"==typeof exports?module.exports=b(a):a.priorityNav=b(a)}(window||this,function(a){"use strict";function b(a,b,c){var d;return function(){var e=this,f=arguments,g=function(){d=null,c||a.apply(e,f)},h=c&&!d;clearTimeout(d),d=setTimeout(g,b),h&&a.apply(e,f)}}var c,d,e,f,g,h,i,j,k={},l=[],m=!!document.querySelector&&!!a.addEventListener,n={},o=0,p=0,q=0,r={initClass:"js-priorityNav",mainNavWrapper:"nav",mainNav:"ul",navDropdownClassName:"nav__dropdown",navDropdownToggleClassName:"nav__dropdown-toggle",navDropdownLabel:"more",navDropdownBreakpointLabel:"menu",breakPoint:500,throttleDelay:50,offsetPixels:0,count:!0,moved:function(){},movedBack:function(){}},s=function(a,b,c){if("[object Object]"===Object.prototype.toString.call(a))for(var d in a)Object.prototype.hasOwnProperty.call(a,d)&&b.call(c,a[d],d,a);else for(var e=0,f=a.length;f>e;e++)b.call(c,a[e],e,a)},t=function(a,b){for(var c=b.charAt(0);a&&a!==document;a=a.parentNode)if("."===c){if(a.classList.contains(b.substr(1)))return a}else if("#"===c){if(a.id===b.substr(1))return a}else if("["===c&&a.hasAttribute(b.substr(1,b.length-2)))return a;return!1},u=function(a,b){var c={};return s(a,function(b,d){c[d]=a[d]}),s(b,function(a,d){c[d]=b[d]}),c},v=function(a,b){if(a.classList)a.classList.toggle(b);else{var c=a.className.split(" "),d=c.indexOf(b);d>=0?c.splice(d,1):c.push(b),a.className=c.join(" ")}},w=function(a,b){return j=document.createElement("span"),g=document.createElement("ul"),h=document.createElement("button"),h.innerHTML=b.navDropdownLabel,h.setAttribute("aria-controls","menu"),h.setAttribute("type","button"),g.setAttribute("aria-hidden","true"),a.querySelector(f).parentNode!==a?void console.warn("mainNav is not a direct child of mainNavWrapper, double check please"):(a.insertAfter(j,a.querySelector(f)),j.appendChild(h),j.appendChild(g),g.classList.add(b.navDropdownClassName),g.classList.add("priority-nav__dropdown"),h.classList.add(b.navDropdownToggleClassName),h.classList.add("priority-nav__dropdown-toggle"),j.classList.add(b.navDropdownClassName+"-wrapper"),j.classList.add("priority-nav__wrapper"),void a.classList.add("priority-nav"))},x=function(a){var b=window.getComputedStyle(a),c=parseFloat(b.paddingLeft)+parseFloat(b.paddingRight);return a.clientWidth-c},y=function(){var a=document,b=window,c=a.compatMode&&"CSS1Compat"===a.compatMode?a.documentElement:a.body,d=c.clientWidth,e=c.clientHeight;return b.innerWidth&&d>b.innerWidth&&(d=b.innerWidth,e=b.innerHeight),{width:d,height:e}},z=function(a){d=x(a),i=a.querySelector(g).parentNode===a?a.querySelector(g).offsetWidth:0,e=D(a)+n.offsetPixels,q=y().width};k.doesItFit=function(a){var c=0===a.getAttribute("instance")?c:n.throttleDelay;o++,b(function(){var b=a.getAttribute("instance");for(z(a);e>=d&&a.querySelector(f).children.length>0||q<n.breakPoint&&a.querySelector(f).children.length>0;)k.toDropdown(a,b),z(a,b),q<n.breakPoint&&C(a,b,n.navDropdownBreakpointLabel);for(;d>=l[b][l[b].length-1]&&q>n.breakPoint;)k.toMenu(a,b),q>n.breakPoint&&C(a,b,n.navDropdownLabel);l[b].length<1&&(a.querySelector(g).classList.remove("show"),C(a,b,n.navDropdownLabel)),a.querySelector(f).children.length<1?(a.classList.add("is-empty"),C(a,b,n.navDropdownBreakpointLabel)):a.classList.remove("is-empty"),A(a,b)},c)()};var A=function(a,b){l[b].length<1?(a.querySelector(h).classList.add("priority-nav-is-hidden"),a.querySelector(h).classList.remove("priority-nav-is-visible"),a.classList.remove("priority-nav-has-dropdown"),a.querySelector(".priority-nav__wrapper").setAttribute("aria-haspopup","false")):(a.querySelector(h).classList.add("priority-nav-is-visible"),a.querySelector(h).classList.remove("priority-nav-is-hidden"),a.classList.add("priority-nav-has-dropdown"),a.querySelector(".priority-nav__wrapper").setAttribute("aria-haspopup","true"))},B=function(a,b){a.querySelector(h).setAttribute("priorityNav-count",l[b].length)},C=function(a,b,c){a.querySelector(h).innerHTML=c};k.toDropdown=function(a,b){a.querySelector(g).firstChild&&a.querySelector(f).children.length>0?a.querySelector(g).insertBefore(a.querySelector(f).lastElementChild,a.querySelector(g).firstChild):a.querySelector(f).children.length>0&&a.querySelector(g).appendChild(a.querySelector(f).lastElementChild),l[b].push(e),A(a,b),a.querySelector(f).children.length>0&&n.count&&B(a,b),n.moved()},k.toMenu=function(a,b){a.querySelector(g).children.length>0&&a.querySelector(f).appendChild(a.querySelector(g).firstElementChild),l[b].pop(),A(a,b),a.querySelector(f).children.length>0&&n.count&&B(a,b),n.movedBack()};var D=function(a){for(var b=a.childNodes,c=0,d=0;d<b.length;d++)3!==b[d].nodeType&&(isNaN(b[d].offsetWidth)||(c+=b[d].offsetWidth));return c},E=function(a,b){window.attachEvent?window.attachEvent("onresize",function(){k.doesItFit&&k.doesItFit(a)}):window.addEventListener&&window.addEventListener("resize",function(){k.doesItFit&&k.doesItFit(a)},!0),a.querySelector(h).addEventListener("click",function(){v(a.querySelector(g),"show"),v(this,"is-open"),v(a,"is-open"),-1!==a.className.indexOf("is-open")?a.querySelector(g).setAttribute("aria-hidden","false"):(a.querySelector(g).setAttribute("aria-hidden","true"),a.querySelector(g).blur())}),document.addEventListener("click",function(c){t(c.target,"."+b.navDropdownClassName)||c.target===a.querySelector(h)||(a.querySelector(g).classList.remove("show"),a.querySelector(h).classList.remove("is-open"),a.classList.remove("is-open"))}),document.onkeydown=function(a){a=a||window.event,27===a.keyCode&&(document.querySelector(g).classList.remove("show"),document.querySelector(h).classList.remove("is-open"),c.classList.remove("is-open"))}};Element.prototype.remove=function(){this.parentElement.removeChild(this)},NodeList.prototype.remove=HTMLCollection.prototype.remove=function(){for(var a=0,b=this.length;b>a;a++)this[a]&&this[a].parentElement&&this[a].parentElement.removeChild(this[a])},k.destroy=function(){n&&(document.documentElement.classList.remove(n.initClass),j.remove(),n=null,delete k.init,delete k.doesItFit)},m&&"undefined"!=typeof Node&&(Node.prototype.insertAfter=function(a,b){this.insertBefore(a,b.nextSibling)});var F=function(a){var b=a.charAt(0);return"."===b||"#"===b?!1:!0};return k.init=function(a){if(n=u(r,a||{}),!m&&"undefined"==typeof Node)return void console.warn("This browser doesn't support priorityNav");if(!F(n.navDropdownClassName)||!F(n.navDropdownToggleClassName))return void console.warn("No symbols allowed in navDropdownClassName & navDropdownToggleClassName. These are not selectors.");var b=document.querySelectorAll(n.mainNavWrapper);s(b,function(a){return l[p]=[],a.setAttribute("instance",p++),(c=a)?(f=n.mainNav,a.querySelector(f)?(w(a,n),g="."+n.navDropdownClassName,a.querySelector(g)?(h="."+n.navDropdownToggleClassName,a.querySelector(h)?(E(a,n),void k.doesItFit(a)):void console.warn("couldn't find the specified navDropdownToggle element")):void console.warn("couldn't find the specified navDropdown element")):void console.warn("couldn't find the specified mainNav element")):void console.warn("couldn't find the specified mainNavWrapper element")}),o++,document.documentElement.classList.add(n.initClass)},k});
{
"name": "priority-nav",
"title": "priority-nav",
"version": "1.0.11",
"version": "1.0.12",
"main": "dist/priority-nav.js",

@@ -6,0 +6,0 @@ "description": "Priority+ pattern navigation that hides menu items if they don't fit on screen.",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc