forked from saurabh/orbit4-5
43 lines
1.1 KiB
JavaScript
43 lines
1.1 KiB
JavaScript
|
|
var response = function(width, element, fns) {
|
|
var wR = this,
|
|
width = width,
|
|
fns = fns,
|
|
timer = 0,
|
|
lastVal,
|
|
lastDir;
|
|
wR.element = element;
|
|
wR.run = function() {
|
|
if(window.innerWidth > width){
|
|
thisDir = true;
|
|
}else{
|
|
thisDir = false;
|
|
}
|
|
if(lastDir != thisDir) {
|
|
if(window.innerWidth > width) {
|
|
fns.over.call();
|
|
} else {
|
|
fns.less.call();
|
|
}
|
|
}
|
|
lastDir = thisDir;
|
|
};
|
|
$(window).resize(function(event) {
|
|
clearTimeout(timer);
|
|
timer = setTimeout(wR.run(), 3000);
|
|
});
|
|
}
|
|
$(function() {
|
|
$('.modules-menu-level-1, .modules-menu-level-2').before('<i class="fa fa-angle-down"></i>');
|
|
$('.modules-menu').on('click', '.fa', function(event) {
|
|
$(this).next('ul').slideToggle(300);
|
|
});
|
|
var menuLevel1 = new response(786, $('.modules-menu-level-1'), {
|
|
"over": function() {menuLevel1.element.removeAttr('style');},
|
|
"less": function() {return false}
|
|
});
|
|
var menuLevel2 = new response(786, $('.modules-menu-level-2'), {
|
|
"over": function() {menuLevel2.element.removeAttr('style');},
|
|
"less": function() {return false}
|
|
});
|
|
}); |