Skip to content
This repository has been archived by the owner on Apr 24, 2020. It is now read-only.

Commit

Permalink
fixed bug with positioning of responsive dropdown on first opening
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Jul 2, 2014
1 parent f90a920 commit 388bca3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/js/ResponsiveNav.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,15 @@ function ResponsiveNav(rootEl) {
nav.resize();
if (contentFilter) {
contentFilter.squish();
populateMoreList(contentFilter.getHiddenItems());
}
}

function emptyMoreList() {
moreListEl.innerHTML = '';
}

function addItemToMoreList(text, href) {
function addItemToMoreList(text, href, ul) {
var itemEl = document.createElement('li'),
aEl = document.createElement('a');
aEl.innerText = text;
Expand All @@ -43,7 +44,8 @@ function ResponsiveNav(rootEl) {
emptyMoreList();
for (var c = 0, l = hiddenEls.length; c < l; c++) {
var aEl = hiddenEls[c].querySelector('a');
addItemToMoreList(aEl.innerText, aEl.href);
var ulEl = hiddenEls[c].querySelector('ul');
addItemToMoreList(aEl.innerText, aEl.href, ulEl);
}
}

Expand Down Expand Up @@ -75,15 +77,16 @@ function ResponsiveNav(rootEl) {
rootDelegate = new DomDelegate(rootEl);
contentFilterEl = rootEl.querySelector('ul');
moreEl = rootEl.querySelector('[data-more]');
if (contentFilterEl) {
contentFilter = new SquishyList(contentFilterEl, { filterOnResize: false });
}
if (moreEl && !isMegaDropdownControl(moreEl)) {
moreListEl = document.createElement('ul');
moreListEl.setAttribute('data-o-hierarchical-nav-level', '2');
moreEl.appendChild(moreListEl);
rootDelegate.on('oLayers.new', navExpandHandler);
}
if (contentFilterEl) {
contentFilter = new SquishyList(contentFilterEl, { filterOnResize: false });
}

rootDelegate.on('oSquishyList.change', contentFilterChangeHandler);

var bodyDelegate = new DomDelegate(document.body);
Expand Down

0 comments on commit 388bca3

Please sign in to comment.