Skip to content

Commit 7fa33a4

Browse files
authored
Add files via upload
1 parent d75a230 commit 7fa33a4

File tree

1 file changed

+105
-0
lines changed

1 file changed

+105
-0
lines changed

js/jquery.jside.menu.js

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
/* Plugin: jSide Menu (Responsive Side Menu)
2+
* Frameworks: jQuery 3.3.1 & Material Design Iconic Font 2.0
3+
* Author: Asif Mughal
4+
* GitHub: https://github.com/CodeHimBlog
5+
* URL: https://www.codehim.com
6+
* License: MIT License
7+
* Copyright (c) 2018 - Asif Mughal
8+
*/
9+
/* File: jquery.jside.menu.js */
10+
(function($){
11+
$.fn.jSideMenu = function(options){
12+
var setting = $.extend({
13+
jSidePosition: "position-left", //possible options position-left or position-right
14+
jSideSticky: true, // menubar will be fixed on top, false to set static
15+
jSideSkin: "default-skin", // to apply custom skin, just put its name in this string
16+
17+
}, options);
18+
19+
return this.each(function() {
20+
var target, $headHeight,
21+
$devHeight,
22+
jSide,
23+
arrow,
24+
dimBackground;
25+
target = $(this);
26+
27+
/* Accessing DOM */
28+
jSide = $(".menu-container, .menu-head");
29+
$devHeight = $(window).height();
30+
$headHeight = $(".menu-head").height();
31+
arrow = document.createElement("i");
32+
dimBackground = $(".dim-overlay");
33+
// Set the height of side menu according to the available height of device
34+
$(target).css({
35+
'height' : $devHeight-$headHeight,
36+
37+
});
38+
39+
if (setting.jSideSticky == true){
40+
$(".menubar").addClass("sticky");
41+
} else{
42+
$(".menubar").removeClass("sticky");
43+
}
44+
45+
$(".menubar").addClass(setting.jSideSkin);
46+
$(jSide).addClass(setting.jSideSkin).addClass(setting.jSidePosition);
47+
48+
if ($(jSide).hasClass("position-left")){
49+
$(".menu-trigger").addClass("left").removeClass("right");
50+
}
51+
else{
52+
$(".menu-trigger").removeClass("left").addClass("right");
53+
}
54+
55+
//Dropdown Arrow
56+
$(arrow).addClass("zmdi zmdi-chevron-down arrow").appendTo(".dropdown-heading");
57+
58+
//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+
}
75+
});
76+
77+
$(".menu-trigger").click(function(){
78+
$(jSide).toggleClass("open");
79+
$(dimBackground).show(500);
80+
81+
});
82+
83+
//close menu if user click outside of it
84+
$(window).click(function(e) {
85+
if ($(e.target).closest('.menu-trigger').length){
86+
return;}
87+
if ($(e.target).closest(jSide).length){
88+
return;}
89+
90+
$(jSide).removeClass("open");
91+
if (!$(jSide).hasClass("open")) {
92+
$(dimBackground).hide(500);
93+
}
94+
});
95+
});
96+
};
97+
98+
})(jQuery);
99+
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
100+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
101+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
102+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
103+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
104+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
105+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */

0 commit comments

Comments
 (0)