JS
Implemented - Curtis Wilkinson
$(document).ready(function() { | |
//3 column dicer | |
function columnDicer(menuClass, colNum) { | |
var itemTotal = $('' + menuClass + ' .first-col' + ' ' + '>.menu-li').length; | |
var spliceValue = (itemTotal/colNum) - 1; | |
var roundedVal = Math.floor(spliceValue); | |
$('<ul class="column second-col col-xs-12 col-sm-4"></ul><ul class="column third-col col-xs-12 col-sm-4"></ul>').insertAfter($(menuClass + ' .first-col')); | |
$(menuClass + ' .column.first-col .lv2-li:gt(' + roundedVal + ')').each(function() { | |
$(this).appendTo($(menuClass + ' .second-col')); | |
}); | |
$(menuClass + ' .column.second-col .lv2-li:gt(' + roundedVal + ')').each(function() { | |
$(this).appendTo($(menuClass + ' .third-col')); | |
}); | |
} | |
// Class name of top level menu, Cut after this index (zero based) | |
columnDicer('.sub-cat', 3); | |
}); |