Skip to content

Commit 0867edf

Browse files
authored
Update jquery.jside.menu.js
1 parent 34d433e commit 0867edf

File tree

1 file changed

+27
-37
lines changed

1 file changed

+27
-37
lines changed

js/jquery.jside.menu.js

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
/* Plugin: jSide Menu (Responsive Side Menu)
2-
* Frameworks: jQuery 3.3.1 & Material Design Iconic Font 2.0
1+
/*! Plugin: jSide Menu (Responsive Side Menu)
2+
* Dependency: jQuery 3.4.1 & Material Design Iconic Font 2.0
33
* Author: Asif Mughal
44
* GitHub: https://github.com/CodeHimBlog
55
* URL: https://www.codehim.com
@@ -13,26 +13,28 @@
1313
jSidePosition: "position-left", //possible options position-left or position-right
1414
jSideSticky: true, // menubar will be fixed on top, false to set static
1515
jSideSkin: "default-skin", // to apply custom skin, just put its name in this string
16-
16+
17+
jSideTransition: 400, //Define the transition duration in milliseconds
18+
1719
}, options);
1820

1921
return this.each(function() {
20-
var target, $headHeight,
21-
$devHeight,
22-
jSide,
23-
arrow,
24-
dimBackground;
22+
var jSide, target, headHeight, devHeight, arrow, dimBackground;
23+
2524
target = $(this);
26-
27-
/* Accessing DOM */
25+
26+
//Accessing DOM
2827
jSide = $(".menu-container, .menu-head");
29-
$devHeight = $(window).height();
30-
$headHeight = $(".menu-head").height();
31-
arrow = document.createElement("i");
32-
dimBackground = $(".dim-overlay");
28+
devHeight = $(window).height();
29+
headHeight = $(".menu-head").height();
30+
dHeading = $(".dropdown-heading");
31+
menuTrigger = $(".menu-trigger");
32+
arrow = $("<i></i>");
33+
dimBackground = $("<div>");
34+
3335
// Set the height of side menu according to the available height of device
3436
$(target).css({
35-
'height' : $devHeight-$headHeight,
37+
'height' : devHeight-headHeight,
3638

3739
});
3840

@@ -53,31 +55,19 @@ $(".menu-trigger").removeClass("left").addClass("right");
5355
}
5456

5557
//Dropdown Arrow
56-
$(arrow).addClass("zmdi zmdi-chevron-down arrow").appendTo(".dropdown-heading");
57-
58+
$(arrow).addClass("material-icons d-arrow").html("keyboard_arrow_down").appendTo(dHeading);
59+
//Dim Layer
60+
$(dimBackground).addClass("dim-overlay").appendTo("body");
5861
//Dropdowns
59-
$(".dropdown-heading").click(function(){
60-
var n = $(".has-sub").find("span:hover + ul li").length;
61-
var h = $(".has-sub").find("span:hover + ul li").outerHeight();
62-
var dropdown = h*n;
63-
var todrop = $(".has-sub").find("span:hover + ul");
64-
var nodrop = $(".has-sub ul");
65-
66-
$(todrop).animate({"height" : dropdown}, 100);
67-
$(this).find("i").toggleClass("arrowdown");
68-
if ($(todrop).height() == dropdown){
69-
$(todrop).animate({"height" : 0}, 100);
70-
}
71-
72-
if ($(nodrop).height(dropdown)){
73-
$(nodrop).not(todrop).height(0); $(".dropdown-heading").not(this).find("i").removeClass("arrowdown");
74-
}
62+
$(dHeading).click(function(){
63+
$(this).parent().find("ul").slideToggle(setting.jSideTransition);
64+
$(this).find(".d-arrow").toggleClass("d-down");
65+
7566
});
7667

77-
$(".menu-trigger").click(function(){
68+
$(menuTrigger).click(function(){
7869
$(jSide).toggleClass("open");
79-
$(dimBackground).show(500);
80-
70+
$(dimBackground).show(setting.jSideTransition);
8171
});
8272

8373
//close menu if user click outside of it
@@ -89,7 +79,7 @@ $(".menu-trigger").click(function(){
8979

9080
$(jSide).removeClass("open");
9181
if (!$(jSide).hasClass("open")) {
92-
$(dimBackground).hide(500);
82+
$(dimBackground).hide(setting.jSideTransition);
9383
}
9484
});
9585
});

0 commit comments

Comments
 (0)