Skip to content
This repository was archived by the owner on Sep 5, 2019. It is now read-only.

Commit 4efd740

Browse files
committed
JS moved to an external file.
1 parent 12fc5d0 commit 4efd740

File tree

4 files changed

+33
-29
lines changed

4 files changed

+33
-29
lines changed

js/responsive.menu.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
2+
/*
3+
* Responsive menu.
4+
*/
5+
(function($) {
6+
7+
// perfect scrollbar
8+
new PerfectScrollbar('.scrollbar');
9+
10+
// click show/hide menu
11+
$('.nav .click').on('click', function() {
12+
$('.nav .responsive').toggleClass('expandable');
13+
});
14+
15+
// responsive menu
16+
$('ul.menu li').each(function() {
17+
if ($(this).children('li.parent a.current').length > 0 ) {
18+
$(this).parent().find('ul.submenu').toggle();
19+
$(this).parent().find('li.parent a.employ').addClass('active');
20+
}
21+
});
22+
23+
// responsive active menu
24+
$('ul.menu li a').on('click', function() {
25+
$(this).parent('li.parent').find('a.employ').toggleClass('active');
26+
$(this).parent().find('ul.submenu').slideToggle('fast');
27+
$(this).parent().find('ul.submenu ul.submenu').toggle();
28+
});
29+
30+
}(jQuery));

package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "css-ui-responsive-menu",
3-
"version": "3.1.3",
3+
"version": "3.1.4",
44
"description": "Simple responsive menu.",
55
"main": "css/style.menu.css",
66
"repository": {

readme.md

+1-27
Original file line numberDiff line numberDiff line change
@@ -143,33 +143,7 @@ javascript libraries and plugins.
143143
```html
144144
<script src="path/to/jquery.js"></script>
145145
<script src="path/to/perfect-scrollbar.js"></script>
146-
<script>
147-
$(function() {
148-
149-
// perfect scrollbar
150-
const ps = new PerfectScrollbar('.scrollbar');
151-
152-
// click show/hide menu
153-
$('.nav .click').on('click', function() {
154-
$('.nav .responsive').toggleClass('expandable');
155-
});
156-
157-
// responsive menu
158-
$('ul.menu li').each(function() {
159-
if ($(this).children('li.parent a.current').length > 0 ) {
160-
$(this).parent().find('ul.submenu').toggle();
161-
$(this).parent().find('li.parent a.employ').addClass('active');
162-
}
163-
});
164-
165-
// responsive active menu
166-
$('ul.menu li a').on('click', function() {
167-
$(this).parent('li.parent').find('a.employ').toggleClass('active');
168-
$(this).parent().find('ul.submenu').slideToggle('fast');
169-
$(this).parent().find('ul.submenu ul.submenu').toggle();
170-
});
171-
});
172-
</script>
146+
<script src="path/to/responsive.menu.js"></script>
173147
```
174148

175149
Enjoy responsive menu.

0 commit comments

Comments
 (0)