/** * 绫 鍚 绉帮細 Separator|SP * 鍔熻兘璇存槑锛 鍒嗗壊鏉$被 * 鐗堟潈淇℃伅锛 CopyRight 2005-2006 JoeCom * 鍙傛暟璇存槑锛 o1,o2 : 涓や釜瀵硅薄 spTpe: 鏂瑰悜锛屾槸宸﹀彸锛岃繕鏄笂涓 w:瀹藉害;wx:left鐨勫樊鍊畸wy:top鐨勫樊鍊 wh:宸﹀彸鎷栧姩鏃讹紝鏄搴︾殑宸€硷紝涓婁笅鍒欐槸楂樺害鐨勫樊鍊 wl:涓婁笅鎷夊姩鏃舵椂鐨勪竴涓樊鍊 宸€肩殑瀛樺湪鏄洜涓烘帶浠跺彲鑳藉瓨鍦╞order,padding,top绛変竴浜涙儏鍐碉紝 杩樻湁灏辨槸鎺т欢鐨刾osition涓嶆槸涓篴bsolute * 鍒 寤 浜猴細 JoeCom | MSN:juwuyi@hotmail.com | blog:http://hi.baidu.com/joecom * 鍒涘缓鏃ユ湡锛 2006-07-27 * 淇敼璁板綍锛 * 澶 娉 锛 IE涓嬫晥鏋滄渶濂斤紝FF涓婽D鏍囩涓嶆敮鎸乷nresize浜嬩欢锛 */ //浠ヤ笅瀹氫箟鎷栨媺鏂瑰悜鐨勫父閲 SP_LEFTRIGHT = 1; //宸﹀彸鎷栨媺 SP_UPDOWN = 2; //涓婁笅鎷栨媺 function Separator(o1, o2, callback,spType, w, wx, wy, wh, wl){ var me = this; this.o1 = (typeof o1 == "string") ? document.getElementById(o1) : o1; this.o2 = (typeof o2 == "string") ? document.getElementById(o2) : o2; this.w = w || 3; //Width or Height this.wx = wx || 0; //parentOffsetLeft this.wy = wy || 0; //parentOffsetTop this.wh = wh || 0; //parentOffsetHeight this.wl = wl || 0; //parentOffsetWidth //this.wr = wr||0; //parentOffsetRight this.autoresize = false; this.spType = (spType == SP_UPDOWN) ? SP_UPDOWN : SP_LEFTRIGHT; this.allWidth = this.o1.clientWidth + this.o2.clientWidth + this.w; this.allHeight = this.o1.clientHeight + this.o2.clientHeight + this.w; this.isIE = false; this.callback = callback; this.addEvent = function(el, evname, func){ if (el.attachEvent) { // IE el.attachEvent("on" + evname, func); this.isIE = true; } else if (el.addEventListener) { // Gecko / W3C el.addEventListener(evname, func, false); } else { el["on" + evname] = func; } }; this.sp = document.createElement("div"); if (this.spType == SP_LEFTRIGHT) { $('body').append('
'); var spliterLeftDiv = document.getElementById("spliterLeftDiv"); spliterLeftDiv.innerHTML = ""; $('#spliterLeftDiv').append(""); }else{ $('body').append('
'); var spliterRightDiv = document.getElementById("spliterRightDiv"); spliterRightDiv.innerHTML = ""; $('#spliterRightDiv').append(""); } this.init = function(){ if (this.spType == SP_LEFTRIGHT) { with (this.sp) { style.position = "absolute"; style.left = this.o1.offsetLeft + this.o1.clientWidth + this.wx + "px"; style.top = this.o1.offsetTop + this.wy + "px"; style.width = this.w + "px"; style.height = this.o1.clientHeight + this.wh - 1 + "px"; className = "lrSeparator"; style.zIndex = "1000"; } var spliterLeftDiv = document.getElementById("spliterLeftDiv"); spliterLeftDiv.appendChild(this.sp); var left = $('.lrSeparator').css('left'); $('#lrB').css('left',left); } else { with (this.sp) { style.position = "absolute"; style.left = this.o1.offsetLeft + this.wx + "px"; style.top = this.o1.offsetTop + this.o1.clientHeight + this.wy - 4 + "px"; style.width = this.o1.clientWidth + this.wh + "px"; style.height = this.w + "px"; className = "udSeparator"; style.zIndex = "200"; } var spliterRightDiv = document.getElementById("spliterRightDiv"); spliterRightDiv.appendChild(this.sp); var top = $('.udSeparator').css('top'); $('#udB').css('top',top); $('#detailDiv').show(); } } if(!this.sp.attachEvent){ this.sp.innerHTML = ""; //鐏嫄绌虹櫧鍐呭涓嶆樉绀 } this.init(); this.dd = new ObjectDragDrop(this.sp); this.dd.moveStyle = (this.spType == SP_LEFTRIGHT) ? DD_HMOVE : DD_VMOVE; this.resize = function(){ this.init(); } this.addEvent(window, "resize", function(){ me.resize(); }); this.addEvent(this.o1, "resize", function(){ me.resize(); }); this.dd.isMoved = function(newPosX, newPosY){ if (me.spType == SP_LEFTRIGHT) { var mw1 = me.o1.getAttribute("minWidth"); var mw2 = me.o2.getAttribute("minWidth"); if (mw1 == null) { mw1 = 0; } if (mw2 == null) { mw2 = 0; } return { x: ((newPosX - me.o1.offsetLeft) >= mw1 && (newPosX - me.o1.offsetLeft) <= (me.allWidth - mw2)), y: false }; } else { var mh1 = me.o1.getAttribute("minHeight"); var mh2 = me.o2.getAttribute("minHeight"); if (mh1 == null) { mh1 = 0; } if (mh2 == null) { mh2 = 0; } return { x: false, y: ((newPosY - me.o1.offsetTop - me.wy) >= mh1 && (newPosY - me.o1.offsetTop - me.wy) <= (me.allHeight - mh2)) }; } } this.dd.onDrop = function(){ if (me.spType == SP_LEFTRIGHT) { me.o1.style.width = me.sp.offsetLeft - me.o1.offsetLeft - me.wx - me.wl + "px"; if (!me.autoresize) { me.o2.style.width = me.allWidth - me.o1.clientWidth - me.w + "px"; if (me.o2.tagName != "TD") { me.o2.style.left = me.sp.offsetLeft; } } } else { me.o1.style.height = me.sp.offsetTop - me.o1.offsetTop - me.wy + "px"; if (!me.autoresize) { me.o2.style.height = me.allHeight - me.o1.clientHeight + "px"; if (me.o2.tagName != "TR") { me.o2.style.top = me.sp.offsetTop; } } } if (!me.isIE) { me.init(); } //鍥炶皟鍑芥暟 if(me.callback){ me.callback(); } } } /** * 绫 鍚 绉帮細 DragDrop|DD * 鍔熻兘璇存槑锛 鍙嫋鍔ㄧ被 * 鐗堟潈淇℃伅锛 CopyRight 2005-2006 JoeCom * 鍒 寤 浜猴細 JoeCom | MSN:juwuyi@hotmail.com | blog:http://hi.baidu.com/joecom * 鍒涘缓鏃ユ湡锛 2006-07-19 * 淇敼璁板綍锛 1. 2006-07-21 鍔犱笂scrollTop 鍜 scrollLeft鐨勭浉瀵圭Щ鍔 艂. 2006-07-25 鍔犲叆moveStyle灞炴€э紝澧炲姞姘村钩绉诲姩鍜屽瀭鐩寸Щ鍔ㄧ殑鍔熻兘 艃. 2006-07-25 鍔犲叆isMoved鍑芥暟锛屽鍔犺寖鍥寸Щ鍔ㄥ姛鑳 */ //浠ヤ笅瀹氫箟绉诲姩鏂瑰悜鐨勫父閲 DD_FREEMOVE = 0; //鑷敱绉诲姩锛屾病鏈夐檺鍒 DD_HMOVE = 1; //姘村钩绉诲姩锛屼篃灏辨槸宸﹀彸绉诲姩 DD_VMOVE = 2; //鍨傜洿绉诲姩锛屼篃灏辨槸涓婁笅绉诲姩 function ObjectDragDrop(obj){ var me = this; this.moveStyle = DD_FREEMOVE; this.foo = (typeof obj == "string") ? document.getElementById(obj) : obj; this.onDrop = function(){ }; this.onDrag = function(){ }; this.isMoved = function(newPosX, newPosY){ return { x: true, y: true } };//offsetX:x鐨勭Щ鍔ㄨ窛绂蝴offsetY:y鐨勭Щ鍔ㄨ窛绂 this.foo.onmousedown = function(e){ var foo = me.foo; e = e || event; /*if(foo.attachEvent){ //IE foo.oOffset = { x: e.offsetX, y: e.offsetY }; }else{ foo.oOffset = { x: e.layerX, y: e.layerY }; }*/ //瑙e喅IE鎷栧姩BUG foo.oOffset = { x: e.offsetX, y: e.offsetY }; document.onmousemove = me.drag; document.onmouseup = me.drop; document.onselectstart = function(){ return false; }; } this.drag = function(e){ var foo = me.foo; e = e || event; var mv = me.isMoved(e.clientX - foo.oOffset.x + document.body.scrollLeft, e.clientY - foo.oOffset.y + document.body.scrollTop); if (mv.x && me.moveStyle != DD_VMOVE) { if (foo.attachEvent) { foo.style.left = e.clientX - foo.oOffset.x + document.body.scrollLeft; }else{ foo.style.left = e.clientX - foo.oOffset.x + document.documentElement.scrollLeft + "px"; //console.log("drag,e.clientX:"+e.clientX+",foo.oOffset.x:"+foo.oOffset.x+",document.documentElement.scrollLeft:"+document.documentElement.scrollLeft); } } if (mv.y && me.moveStyle != DD_HMOVE) { foo.style.top = e.clientY - foo.oOffset.y + document.body.scrollTop + "px"; } me.onDrag(); $('.ui-jqgrid-bdiv').css('overflow','hidden');//瑙e喅鐏嫄娴忚鍣ㄦ粴鍔ㄦ椂鍊 琛ㄦ牸浼氫笂绉诲姩bug 璋㈣崳瓒?017-10-27 } this.drop = function(e){ e = e || event; document.onmousemove = document.onmouseup = document.onselectstart = null; me.onDrop(); } }