Skip to content

Commit

Permalink
remove smartmenus dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
leider committed Jun 6, 2022
1 parent ee62d12 commit bd7d99a
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 28 deletions.
4 changes: 1 addition & 3 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ module.exports = function (grunt) {
"node_modules/select2/dist/js/select2.full.js",
"node_modules/bootstrap-markdown/js/bootstrap-markdown.js",
"node_modules/bootstrap-markdown/locale/bootstrap-markdown.de.js",
"node_modules/smartmenus/dist/jquery.smartmenus.js",
"node_modules/smartmenus/dist/addons/bootstrap-4/jquery.smartmenus.bootstrap-4.js",
"node_modules/fullcalendar/main.js",
"node_modules/jquery-validation/dist/jquery.validate.js",
"node_modules/jquery-validation/dist/additional-methods.js",
"softwerkskammer/frontend/3rd_party_js/bootstrap5-multidropdownhack.js",
];

// filesets for uglify
Expand Down Expand Up @@ -44,7 +43,6 @@ module.exports = function (grunt) {
const filesForCss = {
"softwerkskammer/public/stylesheets/screen.css": [
"node_modules/fullcalendar/main.css",
"node_modules/smartmenus/dist/addons/bootstrap-4/jquery.smartmenus.bootstrap-4.css",
"node_modules/@fortawesome/fontawesome-free/css/all.css",
"node_modules/node-syntaxhighlighter/lib/styles/shCoreDefault.css",
"node_modules/datatables.net-bs5/css/dataTables.bootstrap5.css",
Expand Down
8 changes: 0 additions & 8 deletions package-lock.json

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

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
"sharp": "0.30.6",
"simple-configure": "0.1.6",
"simple-timepicker": "1.1.1",
"smartmenus": "1.1.1",
"superagent": "7.1.6",
"tinycolor2": "1.4.2",
"tinygradient": "1.1.5",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// shamelessly copied from https://github.com/dallaslu/bootstrap-5-multi-level-dropdown/blob/master/bootstrap5-dropdown-ml-hack.js

(function ($bs) {
const CLASS_NAME = "has-child-dropdown-show";
$bs.Dropdown.prototype.toggle = (function (_orginal) {
return function () {
document.querySelectorAll("." + CLASS_NAME).forEach(function (e) {
e.classList.remove(CLASS_NAME);
});
let dd = this._element.closest(".dropdown, .dropup").parentNode.closest(".dropdown, .dropup");
for (; dd && dd !== document; dd = dd.parentNode.closest(".dropdown")) {
dd.classList.add(CLASS_NAME);
}
return _orginal.call(this);
};
})($bs.Dropdown.prototype.toggle);

document.querySelectorAll(".dropdown").forEach(function (dd) {
dd.addEventListener("hide.bs.dropdown", function (e) {
if (this.classList.contains(CLASS_NAME)) {
this.classList.remove(CLASS_NAME);
e.preventDefault();
}
e.stopPropagation(); // do not need pop in multi level mode
});
});

// for hover
document.querySelectorAll(".dropdown-hover, .dropdown-hover-all .dropdown").forEach(function (dd) {
dd.addEventListener("mouseenter", function (e) {
let toggle = e.target.querySelector(':scope>[data-bs-toggle="dropdown"]');
if (!toggle.classList.contains("show")) {
$bs.Dropdown.getOrCreateInstance(toggle).toggle();
dd.classList.add(CLASS_NAME);
$bs.Dropdown.clearMenus();
}
});
dd.addEventListener("mouseleave", function (e) {
let toggle = e.target.querySelector(':scope>[data-bs-toggle="dropdown"]');
if (toggle.classList.contains("show")) {
$bs.Dropdown.getOrCreateInstance(toggle).toggle();
}
});
});
})(bootstrap);
1 change: 0 additions & 1 deletion softwerkskammer/lib/site/views/credits.pug
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ block content
+defItem('jquery-guillotine', 'http://matiasgagliano.github.io/guillotine/', 'sizing, rotating, cropping of images inside the browser')
+defItem('select2', 'http://ivaynberg.github.io/select2/', 'Tag Darstellung in Inputboxen')
+defItem('select2-bootstrap-5-theme', 'https://github.com/apalfrey/select2-bootstrap-5-theme/', 'Bootstrap Integration für Select2')
+defItem('smartmenus', 'https://github.com/drmonty/smartmenus', 'Hierarchische Menus / Dropdowns (http://www.smartmenus.org/)')

h4 Backend Rendering
dl.row
Expand Down
29 changes: 14 additions & 15 deletions softwerkskammer/views/layoutComponents.pug
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
mixin administrationMenu
if (accessrights.isSuperuser())
ul.navbar-nav.ml-md-auto.mr-3(data-sm-options='{ hideOnClick: false }', data-sm-skip-collapsible-behavior=true)
li.nav-item.dropdown(data-agoranav='administration')
a.nav-link.dropdown-toggle(href='#')
ul.navbar-nav.ml-md-auto.mr-3
li.nav-item.dropup(data-agoranav='administration')
a.nav-link.dropdown-toggle(href='#', data-bs-toggle='dropdown')
i.fa-solid.fa-gauge.fa-fw
|  #{t('general.administration')} 
ul.dropdown-menu
ul.dropdown-menu.dropdown-menu-end
li: a.dropdown-item.nav-link(href='/administration/activityTable')
i.fa-regular.fa-calendar-alt.fa-fw
|  #{t('activities.activities')}
Expand All @@ -24,13 +24,13 @@ mixin administrationMenu

mixin loginMenu(forInline)
li.nav-item.dropdown(class=forInline ? 'd-sm-none': '')
a.nav-link.dropdown-toggle(href='#')
a.nav-link.dropdown-toggle(href='#', data-bs-toggle='dropdown')
i.fa-solid.fa-circle-info.fa-fw
if accessrights.isRegistered()
|  #{user.member.nickname()}
else
|  #{t('general.guest')}
ul.dropdown-menu
ul.dropdown-menu.dropdown-menu-end
if accessrights.isRegistered()
li: a.dropdown-item.nav-link(href='/members/' + encodeURIComponent(user.member.nickname()))
i.fa-solid.fa-eye.fa-fw
Expand Down Expand Up @@ -67,7 +67,7 @@ mixin languageEntry(forInline, lang, title, img)

mixin navbar-inside
.navbar.navbar-collapse
ul.nav.navbar-nav.md-auto.d-flex.mr-3(data-sm-options='{ hideOnClick: false }', data-sm-skip-collapsible-behavior=true)
ul.nav.navbar-nav.md-auto.d-flex.mr-3
li.nav-item(data-agoranav='impressum'): a.nav-link(href='/impressum.html') #{t('general.legal_notice')}
li.nav-item(data-agoranav='wiki/hilfe'): a.nav-link(href='/help.html') #{t('general.faq')}
li.nav-item: a.nav-link(href='/credits.html') #{t('general.credits')}
Expand All @@ -93,7 +93,7 @@ mixin topNavbar()
i.fa-solid.fa-bars.fa-lg

.navbar-collapse.collapse.collapse-top.align-self-end
ul.nav.navbar-nav(data-sm-options='{ hideOnClick: false }', data-sm-skip-collapsible-behavior=true)
ul.nav.navbar-nav
li.nav-item(data-agoranav='dashboard'): a.nav-link(href='/dashboard')
i.fa-solid.fa-table-list.fa-fw
span.d-sm-none.d-md-inline  #{t('dashboard.dashboard')}
Expand All @@ -104,26 +104,25 @@ mixin topNavbar()
i.fa-solid.fa-users.fa-fw
span.d-sm-none.d-md-inline  #{t('groups.groups')}
li.nav-item.dropdown(data-agoranav='wiki')
a.nav-link.dropdown-toggle(href='#')
a.nav-link.dropdown-toggle(href='#', data-bs-toggle='dropdown')
i.fa-solid.fa-book.fa-fw
span.d-sm-none.d-md-inline  #{t('wiki.wiki')} 
ul.dropdown-menu
if (structuredWikisubdirs)
for wikisubdirs, key in structuredWikisubdirs
li.dropdown
a.dropdown-item.nav-link.dropdown-toggle(href='#') #{t('groups.' + key)}
ul.dropdown-menu
li.dropdown.dropend
a.dropdown-item.nav-link.dropdown-toggle(href='#', data-bs-toggle='dropdown') #{t('groups.' + key)}
.dropdown-menu
if (wikisubdirs.length)
for subdir in wikisubdirs
li
a.dropdown-item(href='/wiki/' + subdir + '/') #{subdir}
a.dropdown-item(href='/wiki/' + subdir + '/') #{subdir}
else
li.nav-item: a.nav-link(href='#') <i>#{t('general.none')}</i>
if (accessrights.isRegistered())
li.nav-item(data-agoranav='members'): a.nav-link(href='/members')
i.fa-solid.fa-user.fa-fw
span.d-sm-none.d-md-inline &nbsp;#{t('members.members')}
+loginMenu(true)
ul.navbar-nav.ms-md-auto.d-none.d-md-flex.mr-3(data-sm-options='{ hideOnClick: false }', data-sm-skip-collapsible-behavior=true)
ul.navbar-nav.ms-md-auto.d-none.d-md-flex.mr-3
+loginMenu

0 comments on commit bd7d99a

Please sign in to comment.