Skip to content

Commit

Permalink
panels, navbars, listviews + iconpanels
Browse files Browse the repository at this point in the history
  • Loading branch information
Fred Heusschen committed Mar 20, 2019
1 parent e50fee3 commit 6c574c4
Show file tree
Hide file tree
Showing 28 changed files with 135 additions and 265 deletions.
23 changes: 9 additions & 14 deletions dist/addons/iconpanels/mmenu.iconpanels.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,14 @@ export default function () {
}
this.node.menu.classList.add(...classnames);
});
var classnames = '';
var classnames = [];
if (!keepFirst) {
for (var i = 0; i <= options.visible; i++) {
classnames += ' mm-panel_iconpanel-' + i;
}
if (classnames.length) {
classnames = classnames.slice(1);
classnames.push('mm-panel_iconpanel-' + i);
}
}
const setPanels = (panel) => {
var panels = Mmenu.DOM.children(this.node.pnls, '.mm-panels');
this.bind('openPanel:start', (panel) => {
var panels = Mmenu.DOM.children(this.node.pnls, '.mm-panel');
panel = panel || panels[0];
if (panel.parentElement.matches('.mm-listitem_vertical')) {
return;
Expand All @@ -63,7 +60,7 @@ export default function () {
else {
// Remove the "iconpanel" classnames from all panels.
panels.forEach((panel) => {
panel.classList.remove(classnames);
panel.classList.remove(...classnames);
});
// Filter out panels that are not opened.
panels = panels.filter(panel => panel.matches('.mm-panel_opened-parent'));
Expand All @@ -88,16 +85,14 @@ export default function () {
panel.classList.add('mm-panel_iconpanel-' + p);
});
}
};
this.bind('openPanel:start', setPanels);
this.bind('initPanels:after', setPanels);
});
this.bind('initListview:after', (panel) => {
if (options.blockPanel &&
!panel.parentElement.matches('.mm-listitem_vertical') &&
!Mmenu.DOM.children(panel, '.mm-panel__blocker')[0]) {
var anchor = Mmenu.DOM.create('a.mm-panel__blocker');
anchor.setAttribute('href', panel.closest('.mm-panel').id);
panel.prepend(anchor);
let blocker = Mmenu.DOM.create('a.mm-panel__blocker');
blocker.setAttribute('href', '#' + panel.closest('.mm-panel').id);
panel.prepend(blocker);
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion dist/addons/navbars/mmenu.navbars.css

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

28 changes: 2 additions & 26 deletions dist/addons/navbars/mmenu.navbars.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function () {
if (!(navs instanceof Array)) {
navs = [navs];
}
var sizes = {}, navbars = {};
var navbars = {};
if (!navs.length) {
return;
}
Expand All @@ -55,31 +55,12 @@ export default function () {
// /Extend shorthand options.
// Create the navbar element.
var navbar = Mmenu.DOM.create('div.mm-navbar');
// Get the height for the navbar.
var height = options.height;
if (typeof height != 'number') {
// Defaults to a height of 1.
height = 1;
}
else {
// Restrict the height between 1 to 4.
height = Math.min(4, Math.max(1, height)); // Typescript doesn't understand...
if (height > 1) {
// Add the height class to the navbar.
navbar.classList.add('mm-navbar_size-' + height);
}
}
// Get the position for the navbar.
var position = options.position;
// Restrict the position to either "bottom" or "top" (default).
if (position !== 'bottom') {
position = 'top';
}
// Add up the wrapper height for the navbar position.
if (!sizes[position]) {
sizes[position] = 0;
}
sizes[position] += height;
// Create the wrapper for the navbar position.
if (!navbars[position]) {
navbars[position] = Mmenu.DOM.create('div.mm-navbars_' + position);
Expand Down Expand Up @@ -107,10 +88,6 @@ export default function () {
navbar.append(ctnt);
}
}
// If buttons were added, tell the navbar.
if (navbar.querySelector('.mm-navbar__btn')) {
navbar.classList.add('mm-navbar_has-btns');
}
// The type option is set.
if (typeof options.type == 'string') {
// The function refers to one of the navbar-presets ("tabs").
Expand All @@ -121,10 +98,9 @@ export default function () {
}
}
});
// Add to menu
// Add to menu.
this.bind('initMenu:after', () => {
for (let position in navbars) {
this.node.menu.classList.add('mm-menu_navbar_' + position + '-' + sizes[position]);
this.node.menu[position == 'bottom' ? 'append' : 'prepend'](navbars[position]);
}
});
Expand Down
2 changes: 1 addition & 1 deletion dist/addons/sidebar/mmenu.sidebar.css

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

2 changes: 1 addition & 1 deletion dist/core/offcanvas/mmenu.offcanvas.css

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

Loading

0 comments on commit 6c574c4

Please sign in to comment.