(function($){var base=$.fn.layout.methods;$.fn.fit=function(){this._extend($.fn.layout,arguments);this.initSkin=function(){base.initSkin.call(this);this.skin.width=1;this.skin.height=1;this.skin.css+="fit";this.skin.html=this.html()};this.initSize=function(){var par=this.autoSizeBox;if(par[0].tagName=="BODY"||par[0].tagName=="FORM"){par=ke.ui}var w=par.width();var h=par.height();var items=this.parent().children();for(var i=0;i ';return ke.format('
{title}{btnClose}
',opt,temp)}function getBodyItem(opt){var htm='
{html}
';return ke.format(htm,opt,opt.data)}function getTabOptions(con,index,el,config){var opt=new ke.options(el,config);opt.parse({closable:con.skin.closable,title:"tab"+index,tabId:"",urlParms:null});opt.index=index;opt.id=con.skin.id;if(el)opt.html=el.innerHTML;if(opt.tabId)opt.tabId=' id="'+opt.tabId+'" ';opt.data.title="";opt.data.hidden=true;return opt}function scroll(i){var of=con.$headBox;var left=of.position().left;var items=of.children();var width=con.$head.width()-42;var el=$(items[i]);var t=parseInt(el.position().left+el._width());if(t>width-left){left=width-t}else left=0;of.animate({left:left})}function getIndex(el){var items=con.$headBox.children();for(var i=0;icon.$head.width()){con.$head.find(".tab-header-expand").show()}else{con.$headBox.css({left:0});con.$head.find(".tab-header-expand").hide();con.layerHide()}}this._extend($.fn.layout,arguments);this.initSkin=function(){this.skin.parse({closable:false,tabIndex:0,tabs:{},position:"top",autoHeight:false});this.skin.css+=" tab";var hh="";var by="";var items=this.children();for(var i=0;i
'+hh+"
";by='
'+by+"
";if(this.skin.position=="top")this.skin.html=hh+by;else this.skin.html=by+hh};this.initHandler=function(){this.$head=this.find(".tab-header");this.$headBox=this.$head.find(".tab-header-box");this.$body=this.find(".tab-body");this.$head.click(this,function(e){var el=e.target;var con=e.data;if(el.className.indexOf("icon-btn")>-1)con.close(getIndex(el.parentNode));else if(el.className.indexOf("tab-header-item")>-1)con.select(getIndex(el))});this.$head.find(".tab-header-expand").click(function(e){con.showLayer();con.layerCompnent.showAt($(e.target));con.layerCompnent.click(function(e){var el=e.target;if(el.className.indexOf("tab-header-item")>-1){var items=con.layerCompnent.find(".tab-header-list").children();for(var i=0;i'+this.find(".tab-header-box").html()+""};this.initSize=function(first){var wh=this.getSize();if(this.skin.autoHeight&&this.controls.length)wh[1]=this.controls[0].height()+this.$head.height();this._setSize(true,wh[0],wh[1]);this.$head._setSize(false,wh[0]);this.$body._setSize(true,wh[0],this.height()-this.$head._height());renderScroll();if(first){base.initSize.call(this,first);this.select(this.skin.tabIndex)}};this.select=function(i,sc){var cls="tab-active";if(!$.isNumeric(i)){i=getIndex(i)}this.$headBox.find("."+cls).removeClass(cls);this.$headBox.children().eq(i).addClass(cls);this.controls.forEach(function(d,k){if(k!=i)d.hide()});this.controls[i].show();this.controls[i].initSize();this.skin.tabIndex=i;this.trigger("tabShow");if(sc)scroll(i);return this.controls[i]};this.close=function(i){if(i==null)i=this.skin.tabIndex;var items=this.$headBox.children();if(i==this.skin.tabIndex){if(i>0)this.select(i-1);else if(items.length>1&&i==0){this.select(1);this.skin.tabIndex=0}}$(items[i]).remove();ke.ui.destroy(this.controls[i]);items=this.$headBox.children();renderScroll()};this.add=function(config){var opt=getTabOptions(this,this.controls.length,null,config);this.$headBox.append(getHeaderItem(opt));this.$body.append(getBodyItem(opt));renderScroll();ke.ui.render(this.$body,this);return this.select(opt.index)};this.tabShow=function(){ke.bindOrTrriger(this,"tabShow",arguments)};this.setHeaderTitle=function(title,i){var items=this.$headBox.children();$(items[i||this.skin.tabIndex]).html(title+(this.skin.closeable?'
 
':"")).attr("title",title)};return this};$.fn.float=function(){this._extend($.fn.layout,arguments);function calClass(groups,l){groups.forEach(function(el,i){var cls="";if(groups.length==1)cls="f-fixed";else if(i==0)cls="f-left";else if(i==groups.length-1&&l<=.01)cls="f-right";else cls="f-center";el.className+=" "+cls})}this.initSkin=function(){base.initSkin.call(this);this.skin.parse({columns:1,marginH:16,marginV:8,fitHeight:false});this.skin.css+=" float-layout clear";var items=this.children();this.skin.id=this.skin.id||"kefloat"+($(".float-layout").length+1);var id=" "+this.skin.id+"-";var groups=[];var l=1;var rate=1/this.skin.columns;for(var i=0;i-1){var w=this.skin.getSize("width",el);if(w<0){w=rate;el.style.width=rate*100+"%"}l=ke.getFloat(l-w,2);if(l>=0)groups.push(el);else{calClass(groups,l);l=1-w;groups=[];groups.push(el)}}}calClass(groups,l);this.skin.html=this.html()};this.initSize=function(first){var wh=this.getSize();this._setSize(true,wh[0],this.skin.height>0?wh[1]:null);if(first){var css="";var mx=this.skin.marginH/2+"px";var top=this.skin.marginV+"px ";var id=this.skin.id;css+="\n#"+id+" .f-fixed{ margin-top:"+top+";float:left;}";css+="\n#"+id+" .f-left{ margin:"+top+mx+" 0px 0px"+";float:left;}";css+="\n#"+id+" .f-center{ margin:"+top+" "+mx+" 0px "+mx+";float:left;}";css+="\n#"+id+" .f-right{ margin:"+top+" 0px 0px "+mx+";float:right;}";css='";this.append(css)}base.initSize.call(this,first)};return this};$.fn.columnLayout=function(){this._extend($.fn.layout,arguments);var avg=[];var fixed=[];this.initSkin=function(){base.initSkin.call(this);this.skin.css+=" column-layout clear";var items=this.children();for(var i=0;i0)fixed.push({index:i,width:w});else avg.push(i)}this.skin.html=this.html()};this.initSize=function(){var wh=this.getSize();var h=this.skin.height>0?wh[1]:null;this._setSize(true,wh[0],h);h=this.height();var w=this.width();var leftWidth=w;var items=this.children();fixed.forEach(function(d,i){var el=ke.setElSize(items[d.index],d.width>1?null:w*d.width,h);if(el.is(":visible")||el[0].className.indexOf("keui-")>-1)leftWidth-=el._width()});avg.forEach(function(d){ke.setElSize(items[d],parseInt(leftWidth/avg.length),h)});ke.ui.size(this)};return this};$.fn.rowLayout=function(){this._extend($.fn.layout,arguments);var avg=[];var fixed=[];this.initSkin=function(){base.initSkin.call(this);this.skin.css="row-layout";if(this.skin.height<0)this.skin.height=1;var items=this.children();for(var i=0;i0)fixed.push({index:i,height:h});else avg.push(i)}this.skin.html=this.html()};this.initSize=function(){var wh=this.getSize();this._setSize(true,wh[0],wh[1]);var h=this._height();var leftHeight=h;var items=this.children();fixed.forEach(function(d,i){var el=ke.setElSize(items[d.index],null,d.height>1?null:h*d.height);if(el.is(":visible")||el[0].className.indexOf("keui-")>-1)leftHeight-=el._height()});avg.forEach(function(d){ke.setElSize(items[d],null,parseInt(leftHeight/avg.length))});ke.ui.size(this)};return this};$.fn.center=function(){this._extend($.fn.layout,arguments);this.initSkin=function(){base.initSkin.call(this);this.skin.html=this.html()};this.initSize=function(){var par=this.autoSizeBox;var w,h;if(par[0].tagName=="BODY"||par[0].tagName=="FORM"){w=$(window).width();h=$(window).height()}else{w=par.width();h=par.height()}this.css({marginTop:(h-(this.height()||this.skin.height))/2,marginLeft:(w-this.width())/2})};return this}})(jQuery);