I've stumbled upon a issue that i can't fix.
I've implemented a autocollapse menu ..all works fine UNTILL i go to mobile version where the wp core's menu bugs out with my menu js code.
Basicly i have a js file that contains the auto-collapse menu code and would like to run this bit
$('#adminmenuwrap, #adminmenuback').mouseenter(function() { expandIt($adminMenuWrap); });
$('#wpcontent , .box').mouseenter(function() { collapseIt($adminMenuWrap); });
$('img').load(function($){collapseIt($adminMenuWrap);});
});
ONLY if you are NOT in mobile version.
fiddled around with if (wp_is_mobile() ) {} function but doesn't work.
Please guys help me fix this cuz it's giving me headakes. Thanks in advance and have a nice day!
Entire JS file :
/* Display and echo mobile specific stuff here */
// MyDash Collapse Menu
jQuery(document).ready(function($) {
// Defineste functii
$adminMenuWrap = $('#adminmenuwrap');
var collapseIt = function($adminMenuWrap) {
if ( !$(document.body).hasClass('folded') ) {
$("#collapse-menu").trigger('click');
$(document.body).toggleClass('expanded');
}
};
var expandIt = function($adminMenuWrap) {
adminMenuWrap = $('#adminmenuwrap');
if ( $(document.body).hasClass('folded') ) {
$("#collapse-menu").trigger('click');
$(document.body).toggleClass('expanded');
}
}
if ($(window).width() > 768){
// here's the magic
$('#adminmenuwrap, #adminmenuback').mouseenter(function() { expandIt($adminMenuWrap); });
$('#wpcontent , .box').mouseenter(function() { collapseIt($adminMenuWrap); });
$('img').load(function($){collapseIt($adminMenuWrap);});
});
}
// Customizer
jQuery(document).ready(function($) {
$(".boxes").mouseenter(function() {
if ( $('.wp-full-overlay').hasClass('collapsed') ) {
$(".collapse-sidebar").trigger('click');
}
});
$("#customize-preview").mouseover(function() {
if ( $('.wp-full-overlay').hasClass('expanded') ) {
$(".collapse-sidebar").trigger('click');
}
});
});
if ($(window).width() < 768)
to detemine if you want to run the codemouseenter
functions (and 768 was just an arbitrary number, you may need to change that)