11 lines
25 KiB
JavaScript
11 lines
25 KiB
JavaScript
|
|
/*
|
||
|
|
* Flexigrid for jQuery - New Wave Grid
|
||
|
|
*
|
||
|
|
* Copyright (c) 2008 Paulo P. Marinas (webplicity.net/flexigrid)
|
||
|
|
* Dual licensed under the MIT (MIT-LICENSE.txt)
|
||
|
|
* and GPL (GPL-LICENSE.txt) licenses.
|
||
|
|
*
|
||
|
|
* $Date: 2008-04-01 00:09:43 +0800 (Tue, 01 Apr 2008) $
|
||
|
|
*/
|
||
|
|
(function(a){a.addFlex=function(n,r){if(n.grid){return false}var x,A,C,k,w,q,y,b,c,h,m,j,l,f,d,B,e,o,z,u,v;r=a.extend({height:200,width:"auto",striped:true,novstripe:false,minwidth:30,minheight:80,resizable:true,url:false,method:"POST",dataType:"xml",errormsg:"Connection Error",usepager:false,nowrap:true,page:1,total:1,useRp:true,rp:15,rpOptions:[10,15,20,25,40],title:false,pagestat:"Displaying {from} to {to} of {total} items",procmsg:"Processing, please wait ...",query:"",qtype:"",nomsg:"No items",minColToggle:1,showToggleBtn:true,hideOnSubmit:true,autoload:true,blockOpacity:0.5,onToggleCol:false,onChangeSort:false,onSuccess:false,onSubmit:false},r);a(n).show().attr({cellPadding:0,cellSpacing:0,border:0}).removeAttr("width");x={hset:{},rePosDrag:function(){var i,g;i=0-this.hDiv.scrollLeft;if(this.hDiv.scrollLeft>0){i-=Math.floor(r.cgwidth/2)}a(x.cDrag).css({top:x.hDiv.offsetTop+1});g=this.cdpad;a("div",x.cDrag).hide();a("thead tr:first th:visible",this.hDiv).each(function(){var s,p;s=a("thead tr:first th:visible",x.hDiv).index(this);if(i==0){i-=Math.floor(r.cgwidth/2)}p=parseInt(a("div",this).width())+i+g;a("div:eq("+s+")",x.cDrag).css({left:p+"px"}).show();i=p})},fixHeight:function(i){var s,p,g;if(!i){i=a(x.bDiv).height()}s=a(this.hDiv).height();a("div",this.cDrag).each(function(){a(this).height(i+s)});p=parseInt(a(x.nDiv).height());if(p>i){a(x.nDiv).height(i).width(200)}else{a(x.nDiv).height("auto").width("auto")}a(x.block).css({height:i,marginBottom:(i*-1)});g=x.bDiv.offsetTop+i;if(r.height!="auto"&&r.resizable){g=x.vDiv.offsetTop}a(x.rDiv).css({height:g})},dragStart:function(t,s,p){var D,g,i;if(t=="colresize"){a(x.nDiv).hide();a(x.nBtn).hide();D=a("div",this.cDrag).index(p);g=a("th:visible div:eq("+D+")",this.hDiv).width();a(p).addClass("dragging").siblings().hide();a(p).prev().addClass("dragging").show();this.colresize={startX:s.pageX,ol:parseInt(p.style.left),ow:g,n:D};a("body").css("cursor","col-resize")}else{if(t=="vresize"){i=false;a("body").css("cursor","row-resize");if(p){i=true;a("body").css("cursor","col-resize")}this.vresize={h:r.height,sy:s.pageY,w:r.width,sx:s.pageX,hgo:i}}else{if(t=="colMove"){a(x.nDiv).hide();a(x.nBtn).hide();this.hset=a(this.hDiv).offset();this.hset.right=this.hset.left+a("table",this.hDiv).width();this.hset.bottom=this.hset.top+a("table",this.hDiv).height();this.dcol=p;this.dcoln=a("th",this.hDiv).index(p);this.colCopy=document.createElement("div");this.colCopy.className="colCopy";this.colCopy.innerHTML=p.innerHTML;if(a.browser.msie){this.colCopy.className="colCopy ie"}a(this.colCopy).css({position:"absolute","float":"left",display:"none",textAlign:p.align});a("body").append(this.colCopy);a(this.cDrag).hide()}}}a("body").noSelect()},dragMove:function(t){var i,I,G,F,p,H,D,s,g,E;if(this.colresize){i=this.colresize.n;H=t.pageX-this.colresize.startX;D=this.colresize.ol+H;s=this.colresize.ow+H;if(s>r.minwidth){a("div:eq("+i+")",this.cDrag).css("left",D);this.colresize.nw=s}}else{if(this.vresize){I=this.vresize;F=t.pageY;H=F-I.sy;if(!r.defwidth){r.defwidth=r.width}if(r.width!="auto"&&!r.nohresize&&I.hgo){G=t.pageX;p=G-I.sx;g=I.w+p;if(g>r.defwidth){this.gDiv.style.width=g+"px";r.width=g}}E=I.h+H;if((E>r.minheight||r.height<r.minheight)&&!I.hgo){this.bDiv.style.height=E+"px";r.height=E;this.fixHeight(E)}I=null}else{if(this.colCopy){a(this.dcol).addClass("thMove").removeClass("thOver");if(t.pageX>this.hset.right||t.pageX<this.hset.left||t.pageY>this.hset.bottom||t.pageY<this.hset.top){a("body").css("cursor","move")}else{a("body").css("cursor","pointer")}a(this.colCopy).css({top:t.pageY+10,left:t.pageX+20,display:"block"})}}}},dragEnd:function(){var i,g;if(this.colresize){i=this.colresize.n;g=this.colresize.nw;a("th:visible div:eq("+i+")",this.hDiv).css("width",g);a("tr",this.bDiv).each(function(){a("td:visible div:eq("+i+")",this).css("width",g)});this.hDiv.scrollLeft=this.bDiv.scrollLeft;a("div:eq("+i+")",this.cDrag).siblings().show();a(".dragging",this.cDrag).removeClass("dragging");this.rePosDrag();this.fixHeight();this.colresize=false}else{if(this.vresize){this.vresize=false}else{if(this
|