I have the following code.
Looking at the first line, it sets 'menu' equal to whatever selector I put. In this case, I put #Messages
What I want to do is be able to provide the #messages part as an argument and rewrite this code as a re-usable function named 'menuCollapse'.
I need to apply this code to about 15 different selectors so I want to write it as a function with an argument.
Thoughts?
Looking at the first line, it sets 'menu' equal to whatever selector I put. In this case, I put #Messages
What I want to do is be able to provide the #messages part as an argument and rewrite this code as a re-usable function named 'menuCollapse'.
I need to apply this code to about 15 different selectors so I want to write it as a function with an argument.
Thoughts?
Code:
$(document).ready(function {
var menu = $('#Messages');
menu.menu();
var blurTimer;
var blurTimeAbandoned = 30; // time in ms for when menu is consider no longer in focus
menu.on('menufocus', function() {
clearTimeout(blurTimer);
});
menu.on('menublur', function(event) {
blurTimer = setTimeout(function() {
menu.menu("collapseAll", null, true );
}, blurTimeAbandoned);
});
});