左导航宽度手动拉伸的问题
如题。
用JS是一个方法。不过下面这断好像有问题,大家帮我看一看。或者还有其他方法可以实现手动拉伸左导航宽度的,也希望大家提出来。
javascript sharepoint
<script type="text/javascript">
var _tk_spDragProps = new Object();
function setGrab()
{
var oNavigation = document.getElementById("LeftNavigationAreaCell");
var oDivider = oNavigation.nextSibling;
oDivider.style.cursor = "col-resize";
oDivider.onmousedown = _tk_spStartDrag;
setWidthOnTreeView(oNavigation);
}
function setWidthOnTreeView(e)
{
for (var c=0; c<e.children.length; c++)
{
var oChild = e.children[c];
if (oChild.id.indexOf("TreeViewNavigationManager") > 0)
_tk_spDragProps.navMan = oChild;
if (oChild.id.indexOf("TreeViewRememberScroll") > 0)
{
_tk_spDragProps.navScroll = oChild;
return;
}
setWidthOnTreeView(oChild);
}
}
function _tk_spStartDrag(e)
{
_tk_sp_startDrag(window.event, document.getElementById("LeftNavigationAreaCell"));
}
setTimeout("setGrab()", 1000);
function _tk_sp_startDrag(e, obj)
{
_tk_spDragProps.element = obj.nextSibling;
_tk_spDragProps.sidePanel = obj;
var x = e.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
_tk_spDragProps.mouseX = x;
_tk_spDragProps.dragStartLeft = parseInt(_tk_spDragProps.sidePanel.style.width, 10);
if (isNaN(_tk_spDragProps.dragStartLeft))
_tk_spDragProps.dragStartLeft = 150;
_tk_spDragProps.element.style.zIndex = ++_tk_spDragProps.zIndex;
document.attachEvent("onmousemove", _tk_sp_dragMove);
document.attachEvent("onmouseup", _tk_sp_dragEnd);
window.event.cancelBubble = true;
window.event.returnValue = false;
}
function _tk_sp_dragMove()
{
var x = window.event.clientX + document.documentElement.scrollLeft + document.body.scrollLeft;
var width = (_tk_spDragProps.dragStartLeft + x - _tk_spDragProps.mouseX);
if (width < 150)
width = 150;
_tk_spDragProps.sidePanel.style.width = width + "px";
_tk_spDragProps.navScroll.style.width = _tk_spDragProps.sidePanel.style.width;
_tk_spDragProps.navMan.style.width = _tk_spDragProps.sidePanel.style.width;
_tk_spDragProps.element.nextSibling.style.width = "0px";
_tk_spDragProps.element.style.width = "5px";
_tk_spDragProps.element.nextSibling.nextSibling.style.width = "5px";
window.event.cancelBubble = true;
window.event.returnValue = false;
}
function _tk_sp_dragEnd()
{
document.detachEvent("onmousemove", _tk_sp_dragMove);
document.detachEvent("onmouseup", _tk_sp_dragEnd);
}
</script>