The function “list_resize” is exactly what it implies: it resizes a UL based on whether or not the UL is bigger than the parent element containing it. I placed it inside an onload and onresize event to synthesize a constant state of being ran, but I would like to make it easier to pass arguments to as setting more and more calls inside the above functions isn’t very practical.
Any suggestions? The argument is the ID of a given UL.
You could make he function capable of handling an array of id’s, so that you can store a list of them in a globally accessible variable
function list_resizeItems(items) {
var i;
for (i = 0; i < items.length; i += 1) {
list_resize(items[i]);
}
}
window.resizeList = [];
window.resizeList.push('test');
window.onresize = function () {
list_resizeItems(window.resizeList)
};
Then you can push more items on to window.resizeList at any time you want, or use splice to remove one of them.
For example, if you had:
window.resizeList = [‘test’, ‘this’, ‘that’, ‘other’];
Then to remove the middle one, at index 2, you would use:
window.resizeList.splice(2, 1)
Which results in the ‘that’ one being removed, leaving you with
[‘test’, ‘this’, ‘other’]