/* domucgiare - sua menu ngang (v2): khung "Ve Than Vu" khong bi menu ben trai che, an khung co so cu bi chong, canh khung trong khung trang */ (function () { var st = document.createElement('style'); st.id = 'tvmf-css'; st.textContent = '@media (min-width:992px){' + '#nav-menu nav.navbar{z-index:1050}' + '#nav-menu li.tvab .tvcs-p{display:none!important}' + '#nav-menu .tvab-p,#nav-menu .tvkt-p{z-index:1060}' + '}@media (min-width:992px) and (max-width:1199px){#nav-menu li.tvhot{display:none!important}' + '}'; document.head.appendChild(st); function place(li, sel, w) { var p = li.querySelector(sel), c = document.querySelector('#nav-menu .container'); if (!p || !c || window.innerWidth < 992) return; var lr = li.getBoundingClientRect(), cr = c.getBoundingClientRect(); var left = lr.left - 20; if (left + w > cr.right - 15) left = cr.right - 15 - w; if (left < cr.left + 15) left = cr.left + 15; p.style.setProperty('left', Math.round(left - lr.left) + 'px', 'important'); p.style.setProperty('right', 'auto', 'important'); } function bind() { [['li.tvab', '.tvab-p', 640], ['li.tvkt', '.tvkt-p', 660]].forEach(function (x) { var li = document.querySelector('#nav-menu ' + x[0]); if (!li || li.getAttribute('data-tvmf')) return; li.setAttribute('data-tvmf', '1'); var f = function () { place(li, x[1], x[2]); }; li.addEventListener('mouseenter', f); li.addEventListener('focusin', f); f(); }); } bind(); window.addEventListener('load', bind); window.addEventListener('resize', function () { [].forEach.call(document.querySelectorAll('#nav-menu [data-tvmf]'), function (li) { li.removeAttribute('data-tvmf'); }); bind(); }); })();