Ã'nÃ'n ¨ø ¨ø addClass: function (elem, cls) { if (!utils.hasClass(elem, cls)) { elem.className += ' ' + cls; } }, viewData: function () { var e = 0, l = 0, i = 0, g = 0, f = 0, m = 0; var j = window, h = document, k = h.documentElement; e = k.clientWidth || h.body.clientWidth || 0; l = j.innerHeight || k.clientHeight || h.body.clientHeight || 0; g = h.body.scrollTop || k.scrollTop || j.pageYOffset || 0; i = h.body.scrollLeft || k.scrollLeft || j.pageXOffset || 0; f = Math.max(h.body.scrollWidth, k.scrollWidth || 0); m = Math.max(h.body.scrollHeight, k.scrollHeight || 0, l); return {scrollTop: g, scrollLeft: i, documentWidth: f, documentHeight: m, viewWidth: e, viewHeight: l}; } }; function getPosition(a) { for (var b = {x: 0, y: 0}; a.offsetParent;) b.x += a.offsetLeft, b.y += a.offsetTop, a = a.offsetParent; return b } function addEvent(obj, eventType, func) { if (obj.attachEvent) { obj.attachEvent("on" + eventType, func); } else { obj.addEventListener(eventType, func, false) } }; // mod lqf 20140618 {fix view too low} if (browser.ie != 6) { var container = document.getElementById('rightFixedArea'); var sidebar = $('.sidebar')[0]; var theY = getPosition(sidebar).y + sidebar.offsetHeight; setTimeout(function () { theY = getPosition(sidebar).y + sidebar.offsetHeight; }, 1000); function adjustADPosition(bottomHeight) { var adY = getPosition(sidebar).y + sidebar.offsetHeight; if (adY != 0) { if ($(container).hasClass("right_fixed")) { theY = adY + $(container).outerHeight(true); } else { theY = adY; } } var adH = container.offsetHeight; var vD = utils.viewData(); if (vD.documentHeight - bottomHeight - vD.scrollTop >= adH) { if (vD.scrollTop >= theY) { utils.addClass(container, 'right_fixed'); if ($(".navTop").css("position") === "fixed") { var h = $(".navTop").outerHeight(true); $(".right_fixed").css("top", h); } else { $(".right_fixed").css("top", 0); } } else { utils.removeClass(container, 'right_fixed'); } } else { utils.removeClass(container, 'right_fixed'); } } var scrollTimeout = null; var scrollCallback = function () { adjustADPosition(160); }; var resizeTimeout = null; addEvent(window, 'scroll', function () { if (scrollTimeout) window.clearTimeout(scrollTimeout); scrollTimeout = window.setTimeout(scrollCallback, 10); }); addEvent(window, 'resize', function () { if (resizeTimeout) window.clearTimeout(resizeTimeout); resizeTimeout = window.setTimeout(scrollCallback, 10); }); } // mod lqf 20140618 {fix view too low} end })(); });