Fish.Member/wwwroot/Content/ligerUI/ligerLayout.js
(完整代码) 16KB(function($){$.fn.ligerLayout=function(options){return $.ligerui.run.call(this,"ligerLayout",arguments)};$.fn.ligerGetLayoutManager=function(){return $.ligerui.run.call(this,"ligerGetLayoutManager",arguments)};$.ligerDefaults.Layout={topHeight:50,bottomHeight:50,leftWidth:110,centerWidth:300,rightWidth:170,InWindow:true,heightDiff:0,height:"100%",onHeightChanged:null,isLeftCollapse:false,isRightCollapse:false,allowLeftCollapse:true,allowRightCollapse:true,allowLeftResize:true,allowRightResize:true,allowTopResize:true,allowBottomResize:true,space:3,onEndResize:null,minLeftWidth:80,minRightWidth:80};$.ligerMethos.Layout={};$.ligerui.controls.Layout=function(element,options){$.ligerui.controls.Layout.base.constructor.call(this,element,options)};$.ligerui.controls.Layout.ligerExtend($.ligerui.core.UIComponent,{__getType:function(){return "Layout"},__idPrev:function(){return "Layout"},_extendMethods:function(){return $.ligerMethos.Layout},_render:function(){var g=this,p=this.options;g.layout=$(this.element);g.layout.addClass("l-layout");g.width=g.layout.width();if($("> div[position=top]",g.layout).length>0){g.top=$("> div[position=top]",g.layout).wrap('<div class="l-layout-top" style="top:0px;"></div>').parent();g.top.content=$("> div[position=top]",g.top);!g.top.content.hasClass("l-layout-content")&&g.top.content.addClass("l-layout-content");g.topHeight=p.topHeight;g.topHeight&&g.top.height(g.topHeight)}if($("> div[position=bottom]",g.layout).length>0){g.bottom=$("> div[position=bottom]",g.layout).wrap('<div class="l-layout-bottom"></div>').parent();g.bottom.content=$("> div[position=bottom]",g.bottom);!g.bottom.content.hasClass("l-layout-content")&&g.bottom.content.addClass("l-layout-content");g.bottomHeight=p.bottomHeight;g.bottomHeight&&g.bottom.height(g.bottomHeight);var bottomtitle=g.bottom.content.attr("title");if(bottomtitle){g.bottom.header=$('<div class="l-layout-header"></div>');g.bottom.prepend(g.bottom.header);g.bottom.header.html(bottomtitle);g.bottom.content.attr("title","")}}if($("> div[position=left]",g.layout).length>0){g.left=$("> div[position=left]",g.layout).wrap('<div class="l-layout-left" style="left:0px;"></div>').parent();g.left.header=$('<div class="l-layout-header"><div class="l-layout-header-toggle"></div><div class="l-layout-header-inner"></div></div>');g.left.prepend(g.left.header);g.left.header.toggle=$(".l-layout-header-toggle",g.left.header);g.left.content=$("> div[position=left]",g.left);!g.left.content.hasClass("l-layout-content")&&g.left.content.addClass("l-layout-content");!p.allowLeftCollapse&&$(".l-layout-header-toggle",g.left.header).remove();var lefttitle=g.left.content.attr("title");if(lefttitle){g.left.content.attr("title","");$(".l-layout-header-inner",g.left.header).html(lefttitle)}g.leftWidth=p.leftWidth;g.leftWidth&&g.left.width(g.leftWidth)}if($("> div[position=center]",g.layout).length>0){g.center=$("> div[position=center]",g.layout).wrap('<div class="l-layout-center" ></div>').parent();g.center.content=$("> div[position=center]",g.center);g.center.content.addClass("l-layout-content");var centertitle=g.center.content.attr("title");if(centertitle){g.center.content.attr("title","");g.center.header=$('<div class="l-layout-header"></div>');g.center.prepend(g.center.header);g.center.header.html(centertitle)}g.centerWidth=p.centerWidth;g.centerWidth&&g.center.width(g.centerWidth)}if($("> div[position=right]",g.layout).length>0){g.right=$("> div[position=right]",g.layout).wrap('<div class="l-layout-right"></div>').parent();g.right.header=$('<div class="l-layout-header"><div class="l-layout-header-toggle"></div><div class="l-layout-header-inner"></div></div>');g.right.prepend(g.right.header);g.right.header.toggle=$(".l-layout-header-toggle",g.right.header);!p.allowRightCollapse&&$(".l-layout-header-toggle",g.right.header).remove();g.right.content=$("> div[position=right]",g.right);!g.right.content.hasClass("l-layout-content")&&g.right.content.addClass("l-layout-content");var righttitle=g.right.content.attr("title");if(righttitle){g.right.content.attr("title","");$(".l-layout-header-inner",g.right.header).html(righttitle)}g.rightWidth=p.rightWidth;g.rightWidth&&g.right.width(g.rightWidth)}g.layout.lock=$("<div class='l-layout-lock'></div>");g.layout.append(g.layout.lock);g._addDropHandle();g.isLeftCollapse=p.isLeftCollapse;g.isRightCollapse=p.isRightCollapse;g.leftCollapse=$('<div class="l-layout-collapse-left" style="display: none; "><div class="l-layout-collapse-left-toggle"></div></div>');g.rightCollapse=$('<div class="l-layout-collapse-right" style="display: none; "><div class="l-layout-collapse-right-toggle"></div></div>');g.layout.append(g.leftCollapse).append(g.rightCollapse);g.leftCollapse.toggle=$("> .l-layout-collapse-left-toggle",g.leftCollapse);g.rightCollapse.toggle=$("> .l-layout-collapse-right-toggle",g.rightCollapse);g._setCollapse();g._bulid();$(window).resize(function(){g._onResize()});g.set(p)},setLeftCollapse:function(isCollapse){var g=this,p=this.options;if(!g.left)return false;g.isLeftCollapse=isCollapse;if(g.isLeftCollapse){g.leftCollapse.show();g.leftDropHandle&&g.leftDropHandle.hide();g.left.hide()}else{g.leftCollapse.hide();g.leftDropHandle&&g.leftDropHandle.show();g.left.show()}g._onResize()},setRightCollapse:function(isCollapse){var g=this,p=this.options;if(!g.right)return false;g.isRightCollapse=isCollapse;g._onResize();if(g.isRightCollapse){g.rightCollapse.show();g.rightDropHandle&&g.rightDropHandle.hide();g.right.hide()}else{g.rightCollapse.hide();g.rightDropHandle&&g.rightDropHandle.show();g.right.show()}g._onResize()},_bulid:function(){var g=this,p=this.options;$("> .l-layout-left .l-layout-header,> .l-layout-right .l-layout-header",g.layout).hover(function(){$(this).addClass("l-layout-header-over")},function(){$(this).removeClass("l-layout-header-over")});$(".l-layout-header-toggle",g.layout).hover(function(){$(this).addClass("l-layout-header-toggle-over")},function(){$(this).removeClass("l-layout-header-toggle-over")});$(".l-layout-header-toggle",g.left).click(function(){g.setLeftCollapse(true)});$(".l-layout-header-toggle",g.right).click(function(){g.setRightCollapse(true)});g.middleTop=0;if(g.top){g.middleTop+=g.top.height();g.middleTop+=parseInt(g.top.css("borderTopWidth"));g.middleTop+=parseInt(g.top.css("borderBottomWidth"));g.middleTop+=p.space}if(g.left){g.left.css({top:g.middleTop});g.leftCollapse.css({top:g.middleTop})}g.center&&g.center.css({top:g.middleTop});if(g.right){g.right.css({top:g.middleTop});g.rightCollapse.css({top:g.middleTop})}g.left&&g.left.css({left:0});g._onResize();g._onResize()},_setCollapse:function(){var g=this,p=this.options;g.leftCollapse.hover(function(){$(this).addClass("l-layout-collapse-left-over")},function(){$(this).removeClass("l-layout-collapse-left-over")});g.leftCollapse.toggle.hover(function(){$(this).addClass("l-layout-collapse-left-toggle-over")},function(){$(this).removeClass("l-layout-collapse-left-toggle-over")});g.rightCollapse.hover(function(){$(this).addClass("l-layout-collapse-right-over")},function(){$(this).removeClass("l-layout-collapse-right-over")});g.rightCollapse.toggle.hover(function(){$(this).addClass("l-layout-collapse-right-toggle-over")},function(){$(this).removeClass("l-layout-collapse-right-toggle-over")});g.leftCollapse.toggle.click(function(){g.setLeftCollapse(false)});g.rightCollapse.toggle.click(function(){g.setRightCollapse(false)});if(g.left&&g.isLeftCollapse){g.leftCollapse.show();g.leftDropHandle&&g.leftDropHandle.hide();g.left.hide()}if(g.right&&g.isRightCollapse){g.rightCollapse.show();g.rightDropHandle&&g.rightDropHandle.hide();g.right.hide()}},_addDropHandle:function(){var g=this,p=this.options;if(g.left&&p.allowLeftResize){g.leftDropHandle=$("<div class='l-layout-drophandle-left'></div>");g.layout.append(g.leftDropHandle);g.leftDropHandle&&g.leftDropHandle.show();g.leftDropHandle.mousedown(function(e){g._start("leftresize",e)})}if(g.right&&p.allowRightResize){g.rightDropHandle=$("<div class='l-layout-drophandle-right'></div>");g.layout.append(g.rightDropHandle);g.rightDropHandle&&g.rightDropHandle.show();g.rightDropHandle.mousedown(function(e){g._start("rightresize",e)})}if(g.top&&p.allowTopResize){g.topDropHandle=$("<div class='l-layout-drophandle-top'></div>");g.layout.append(g.topDropHandle);g.topDropHandle.show();g.topDropHandle.mousedown(function(e){g._start("topresize",e)})}if(g.bottom&&p.allowBottomResize){g.bottomDropHandle=$("<div class='l-layout-drophandle-bottom'></div>");g.layout.append(g.bottomDropHandle);g.bottomDropHandle.show();g.bottomDropHandle.mousedown(function(e){g._start("bottomresize",e)})}g.draggingxline=$("<div class='l-layout-dragging-xline'></div>");g.draggingyline=$("<div class='l-layout-dragging-yline'></div>");g.layout.append(g.draggingxline).append(g.draggingyline)},_setDropHandlePosition:function(){var g=this,p=this.options;g.leftDropHandle&&g.leftDropHandle.css({left:g.left.width()+parseInt(g.left.css("left")),height:g.middleHeight,top:g.middleTop});g.rightDropHandle&&g.rightDropHandle.css({left:parseInt(g.right.css("left"))-p.space,height:g.middleHeight,top:g.middleTop});g.topDropHandle&&g.topDropHandle.css({top:g.top.height()+parseInt(g.top.css("top")),width:g.top.width()});g.bottomDropHandle&&g.bottomDropHandle.css({top:parseInt(g.bottom.css("top"))-p.space,width:g.bottom.width()})},_onResize:function(){var g=this,p=this.options,oldheight=g.layout.height(),h=0,windowHeight=$(window).height(),parentHeight=null;if(typeof p.height=="string"&&p.height.indexOf("%")>0){var layoutparent=g.layout.parent();if(p.InWindow||layoutparent[0].tagName.toLowerCase()=="body"){parentHeight=windowHeight;parentHeight-=parseInt($("body").css("paddingTop"));parentHeight-=parseInt($("body").css("paddingBottom"))}else parentHeight=layoutparent.height();h=parentHeight*parseFloat(p.height)*.01;if(p.InWindow||layoutparent[0].tagName.toLowerCase()=="body")h-=g.layout.offset().top-parseInt($("body").css("paddingTop"))}else h=parseInt(p.height);h+=p.heightDiff;g.layout.height(h);g.layoutHeight=g.layout.height();g.middleWidth=g.layout.width();g.middleHeight=g.layout.height();if(g.top){g.middleHeight-=g.top.height();g.middleHeight-=parseInt(g.top.css("borderTopWidth"));g.middleHeight-=parseInt(g.top.css("borderBottomWidth"));g.middleHeight-=p.space}if(g.bottom){g.middleHeight-=g.bottom.height();g.middleHeight-=parseInt(g.bottom.css("borderTopWidth"));g.middleHeight-=parseInt(g.bottom.css("borderBottomWidth"));g.middleHeight-=p.space}g.middleHeight-=2;g.hasBind("heightChanged")&&g.layoutHeight!=oldheight&&g.trigger("heightChanged",[{layoutHeight:g.layoutHeight,diff:g.layoutHeight-oldheight,middleHeight:g.middleHeight}]);if(g.center){g.centerWidth=g.middleWidth;if(g.left)if(g.isLeftCollapse){g.centerWidth-=g.leftCollapse.width();g.centerWidth-=parseInt(g.leftCollapse.css("borderLeftWidth"));g.centerWidth-=parseInt(g.leftCollapse.css("borderRightWidth"));g.centerWidth-=parseInt(g.leftCollapse.css("left"));g.centerWidth-=p.space}else{g.centerWidth-=g.leftWidth;g.centerWidth-=parseInt(g.left.css("borderLeftWidth"));g.centerWidth-=parseInt(g.left.css("borderRightWidth"));g.centerWidth-=parseInt(g.left.css("left"));g.centerWidth-=p.space}if(g.right)if(g.isRightCollapse){g.centerWidth-=g.rightCollapse.width();g.centerWidth-=parseInt(g.rightCollapse.css("borderLeftWidth"));g.centerWidth-=parseInt(g.rightCollapse.css("borderRightWidth"));g.centerWidth-=parseInt(g.rightCollapse.css("right"));g.centerWidth-=p.space}else{g.centerWidth-=g.rightWidth;g.centerWidth-=parseInt(g.right.css("borderLeftWidth"));g.centerWidth-=parseInt(g.right.css("borderRightWidth"));g.centerWidth-=p.space}g.centerLeft=0;if(g.left)if(g.isLeftCollapse){g.centerLeft+=g.leftCollapse.width();g.centerLeft+=parseInt(g.leftCollapse.css("borderLeftWidth"));g.centerLeft+=parseInt(g.leftCollapse.css("borderRightWidth"));g.centerLeft+=parseInt(g.leftCollapse.css("left"));g.centerLeft+=p.space}else{g.centerLeft+=g.left.width();g.centerLeft+=parseInt(g.left.css("borderLeftWidth"));g.centerLeft+=parseInt(g.left.css("borderRightWidth"));g.centerLeft+=p.space}g.center.css({left:g.centerLeft});g.center.width(g.centerWidth);g.center.height(g.middleHeight);var contentHeight=g.middleHeight;if(g.center.header)contentHeight-=g.center.header.height();g.center.content.height(contentHeight)}if(g.left){g.leftCollapse.height(g.middleHeight);g.left.height(g.middleHeight)}if(g.right){g.rightCollapse.height(g.middleHeight);g.right.height(g.middleHeight);g.rightLeft=0;if(g.left)if(g.isLeftCollapse){g.rightLeft+=g.leftCollapse.width();g.rightLeft+=parseInt(g.leftCollapse.css("borderLeftWidth"));g.rightLeft+=parseInt(g.leftCollapse.css("borderRightWidth"));g.rightLeft+=p.space}else{g.rightLeft+=g.left.width();g.rightLeft+=parseInt(g.left.css("borderLeftWidth"));g.rightLeft+=parseInt(g.left.css("borderRightWidth"));g.rightLeft+=parseInt(g.left.css("left"));g.rightLeft+=p.space}if(g.center){g.rightLeft+=g.center.width();g.rightLeft+=parseInt(g.center.css("borderLeftWidth"));g.rightLeft+=parseInt(g.center.css("borderRightWidth"));g.rightLeft+=p.space}g.right.css({left:g.rightLeft})}if(g.bottom){g.bottomTop=g.layoutHeight-g.bottom.height()-2;g.bottom.css({top:g.bottomTop})}g._setDropHandlePosition()},_start:function(dragtype,e){var g=this,p=this.options;g.dragtype=dragtype;if(dragtype=="leftresize"||dragtype=="rightresize"){g.xresize={startX:e.pageX};g.draggingyline.css({left:e.pageX-g.layout.offset().left,height:g.middleHeight,top:g.middleTop}).show();$("body").css("cursor","col-resize")}else if(dragtype=="topresize"||dragtype=="bottomresize"){g.yresize={startY:e.pageY};g.draggingxline.css({top:e.pageY-g.layout.offset().top,width:g.layout.width()}).show();$("body").css("cursor","row-resize")}else return;g.layout.lock.width(g.layout.width());g.layout.lock.height(g.layout.height());g.layout.lock.show();($.browser.msie||$.browser.safari)&&$("body").bind("selectstart",function(){return false});$(document).bind("mouseup",function(){g._stop.apply(g,arguments)});$(document).bind("mousemove",function(){g._drag.apply(g,arguments)})},_drag:function(e){var g=this,p=this.options;if(g.xresize){g.xresize.diff=e.pageX-g.xresize.startX;g.draggingyline.css({left:e.pageX-g.layout.offset().left});$("body").css("cursor","col-resize")}else if(g.yresize){g.yresize.diff=e.pageY-g.yresize.startY;g.draggingxline.css({top:e.pageY-g.layout.offset().top});$("body").css("cursor","row-resize")}},_stop:function(e){var g=this,p=this.options,diff;if(g.xresize&&g.xresize.diff!=undefined){diff=g.xresize.diff;if(g.dragtype=="leftresize"){if(p.minLeftWidth)if(g.leftWidth+g.xresize.diff<p.minLeftWidth)return;g.leftWidth+=g.xresize.diff;g.left.width(g.leftWidth);if(g.center)g.center.width(g.center.width()-g.xresize.diff).css({left:parseInt(g.center.css("left"))+g.xresize.diff});else g.right&&g.right.width(g.left.width()-g.xresize.diff).css({left:parseInt(g.right.css("left"))+g.xresize.diff})}else if(g.dragtype=="rightresize"){if(p.minRightWidth)if(g.rightWidth-g.xresize.diff<p.minRightWidth)return;g.rightWidth-=g.xresize.diff;g.right.width(g.rightWidth).css({left:parseInt(g.right.css("left"))+g.xresize.diff});if(g.center)g.center.width(g.center.width()+g.xresize.diff);else g.left&&g.left.width(g.left.width()+g.xresize.diff)}}else if(g.yresize&&g.yresize.diff!=undefined){diff=g.yresize.diff;if(g.dragtype=="topresize"){g.top.height(g.top.height()+g.yresize.diff);g.middleTop+=g.yresize.diff;g.middleHeight-=g.yresize.diff;if(g.left){g.left.css({top:g.middleTop}).height(g.middleHeight);g.leftCollapse.css({top:g.middleTop}).height(g.middleHeight)}g.center&&g.center.css({top:g.middleTop}).height(g.middleHeight);if(g.right){g.right.css({top:g.middleTop}).height(g.middleHeight);g.rightCollapse.css({top:g.middleTop}).height(g.middleHeight)}}else if(g.dragtype=="bottomresize"){g.bottom.height(g.bottom.height()-g.yresize.diff);g.middleHeight+=g.yresize.diff;g.bottomTop+=g.yresize.diff;g.bottom.css({top:g.bottomTop});if(g.left){g.left.height(g.middleHeight);g.leftCollapse.height(g.middleHeight)}g.center&&g.center.height(g.middleHeight);if(g.right){g.right.height(g.middleHeight);g.rightCollapse.height(g.middleHeight)}}}g.trigger("endResize",[{direction:g.dragtype?g.dragtype.replace(/resize/,""):"",diff:diff},e]);g._setDropHandlePosition();g.draggingxline.hide();g.draggingyline.hide();g.xresize=g.yresize=g.dragtype=false;g.layout.lock.hide();($.browser.msie||$.browser.safari)&&$("body").unbind("selectstart");$(document).unbind("mousemove",g._drag);$(document).unbind("mouseup",g._stop);$("body").css("cursor","")}})})(jQuery)
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。