Changeset 5907

Show
Ignore:
Timestamp:
08/08/08 16:32:35 (4 months ago)
Author:
kinoshita
Message:

4945

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • spinelz/trunk/compress/javascripts/spinelz/spinelz_for_rubricks.js

    r5905 r5907  
    44234423} 
    44244424},setDrag:function(){ 
    4425 Sortable.create(this.tabContainerId,{tag:"div",overlap:"horizontal",constraint:"horizontal",onChange:this.options.onSort,onUpdate:this.options.afterSort,starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction}); 
     4425Sortable.create(this.tabContainerId,{tag:"div",overlap:"horizontal",constraint:"horizontal",onChange:function(_5){ 
     4426this.options.onSort(_5); 
     4427this._setBrTag(); 
     4428}.bind(this),onUpdate:this.options.afterSort,starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction}); 
    44264429},setEvent:function(){ 
    4427 this.ids.each(function(_5){ 
    4428 Event.observe(_5.tab,"click",this.selectTab.bindAsEventListener(this)); 
    4429 Event.observe(_5.tab,"mouseover",this.onMouseOver.bindAsEventListener(this)); 
    4430 Event.observe(_5.tab,"mouseout",this.onMouseOut.bindAsEventListener(this)); 
     4430this.ids.each(function(_6){ 
     4431Event.observe(_6.tab,"click",this.selectTab.bindAsEventListener(this)); 
     4432Event.observe(_6.tab,"mouseover",this.onMouseOver.bindAsEventListener(this)); 
     4433Event.observe(_6.tab,"mouseout",this.onMouseOut.bindAsEventListener(this)); 
    44314434if(this.options.closeButton){ 
    4432 Event.observe(_5.button,"click",this.onRemove.bindAsEventListener(this)); 
     4435Event.observe(_6.button,"click",this.onRemove.bindAsEventListener(this)); 
    44334436} 
    44344437}.bind(this)); 
    44354438},appendElements:function(){ 
    4436 this.holder.each(function(_6){ 
    4437 $(this.tabTitleId+_6.number).appendChild(_6.tab); 
    4438 this.panelList[_6.number].appendChild(_6.content); 
     4439this.holder.each(function(_7){ 
     4440$(this.tabTitleId+_7.number).appendChild(_7.tab); 
     4441$(this.panelId+_7.number).appendChild(_7.content); 
    44394442}.bind(this)); 
    44404443},build:function(){ 
    4441 var _7="<div id='"+this.tabContainerId+"' class='"+this.classNames["tabContainer"]+"'>"; 
    4442 var _8="<div id='"+this.panelContainerId+"' class='"+this.classNames["panelContainer"]+"'>"; 
    4443 var _9=0; 
    4444 $A(this.element.childNodes).each(function(_a){ 
    4445 if(Element.isElementNode(_a)){ 
    4446 var _b=this.buildTabSet(_a,_9); 
    4447 _7+=_b.tab; 
    4448 _8+=_b.panel; 
    4449 _9++; 
     4444var _8=(UserAgent.isIE7())?" style='height: 90%;'":""; 
     4445var _9="<div id='"+this.tabContainerId+"' class='"+this.classNames["tabContainer"]+"'"+_8+">"; 
     4446var _a="<div id='"+this.panelContainerId+"' class='"+this.classNames["panelContainer"]+"'>"; 
     4447var _b=0; 
     4448$A(this.element.childNodes).each(function(_c){ 
     4449if(Element.isElementNode(_c)){ 
     4450var _d=this.buildTabSet(_c,_b); 
     4451_9+=_d.tab; 
     4452_a+=_d.panel; 
     4453_b++; 
    44504454} 
    44514455}.bind(this)); 
    4452 _7+="</div>"; 
    4453 _8+="</div>"; 
    4454 this.element.innerHTML=_7+"<div class='"+this.classNames["tabBar"]+"'></div>"+_8; 
    4455 },buildTabSet:function(_c,i){ 
    4456 var _e=Element.getChildNodesWithoutWhitespace(_c); 
    4457 this.holdElements(_e[0],_e[1],i); 
    4458 return {tab:this.buildTab(_e[0],i,Element.attributeHTML(_c,"onclick")),panel:this.buildPanel(_e[1],i)}; 
    4459 },buildTab:function(_f,i,_11){ 
    4460 var _12=this.tabId+i; 
    4461 var ids={tab:_12}; 
     4456_9+="</div>"; 
     4457_a+="</div>"; 
     4458this.element.innerHTML=_9+"<div class='"+this.classNames["tabBar"]+"'></div>"+_a; 
     4459},buildTabSet:function(_e,i,_10){ 
     4460var _11=Element.getChildNodesWithoutWhitespace(_e); 
     4461this.holdElements(_11[0],_11[1],i); 
     4462return {tab:this.buildTab(_11[0],i,Element.attributeHTML(_e,"onclick"),_10),panel:this.buildPanel(_11[1],i,_10)}; 
     4463},buildTab:function(tab,i,_14,_15){ 
     4464_15=_15||i; 
     4465var _16=this.tabId+i; 
     4466var ids={tab:_16}; 
    44624467this.ids.push(ids); 
    4463 this.tabs[i]=_12
    4464 var _14=""; 
     4468this.tabs[_15]=_16
     4469var _18=""; 
    44654470if(this.options.closeButton){ 
    4466 var _15=this.element.id.appendSuffix("closeButton_"+i); 
    4467 ids.button=_15; 
    4468 _14="<div id='"+_15+"' class='"+this.classNames["closeButton"]+"'></div>"; 
    4469 
    4470 var _16=""; 
    4471 if(this.options.tabRow&&!isNaN(this.options.tabRow)&&((i%this.options.tabRow)==0)){ 
    4472 _16=" style='clear: left; float: none;'"; 
    4473 
    4474 var _17=this.getTabText(_f).escapeHTML().replace(/"/g,"&quot;"); 
    4475 this.setTabText(_f,this.chopTabText(_17)); 
    4476 var _18="<div id='"+_12+"' class='"+this.classNames["tab"]+"'"+_16+" "+_11+">"+"<div id='"+this.tabLeftId+i+"' class='"+this.classNames["tabLeftInactive"]+"'></div>"+"<div id='"+this.tabMiddleId+i+"' class='"+this.classNames["tabMiddleInactive"]+"'>"+"<div id=\""+this.tabTitleId+i+"\" class=\""+this.classNames["tabTitle"]+"\" title=\""+_17+"\">"+"</div>"+_14+"</div>"+"<div id='"+this.tabRightId+i+"' class='"+this.classNames["tabRightInactive"]+"'></div>"+"</div>"; 
    4477 return _18; 
    4478 },setTabText:function(_19,_1a){ 
    4479 if(Element.isTextNode(_19)){ 
    4480 _19.nodeValue=_1a; 
    4481 }else{ 
    4482 if(Element.isElementNode(_19)){ 
    4483 _19.innerHTML=_1a; 
    4484 
    4485 
    4486 },getTabText:function(_1b){ 
    4487 if(Element.isTextNode(_1b)){ 
    4488 textNode=_1b; 
    4489 }else{ 
    4490 if(Element.isElementNode(_1b)){ 
    4491 textNode=Element.getTextNodes(_1b,true)[0]; 
    4492 }else{ 
    4493 return ""; 
    4494 
    4495 
    4496 return textNode.nodeValue.replace(/(^(\s)*) | ((\s)*$)/,""); 
    4497 },chopTabText:function(_1c){ 
    4498 if(this.options.titleLength&&!isNaN(this.options.titleLength)){ 
    4499 _1c=_1c.substring(0,this.options.titleLength); 
    4500 
    4501 return _1c; 
    4502 },buildPanel:function(_1d,i){ 
     4471var _19=this.element.id.appendSuffix("closeButton_"+i); 
     4472ids.button=_19; 
     4473_18="<div id='"+_19+"' class='"+this.classNames["closeButton"]+"'></div>"; 
     4474
     4475var _1a=""; 
     4476var br=""; 
     4477if(this.options.tabRow&&!isNaN(this.options.tabRow)&&((_15.succ()%this.options.tabRow)==0)){ 
     4478br="<br style=\"clear: both;\" />"; 
     4479
     4480var _1c=this.getTabText(tab); 
     4481this.setTabText(tab,this.chopTabText(_1c)); 
     4482var _1d="<div id='"+_16+"' class='"+this.classNames["tab"]+"'"+_1a+" "+_14+">"+"<div id='"+this.tabLeftId+i+"' class='"+this.classNames["tabLeftInactive"]+"'></div>"+"<div id='"+this.tabMiddleId+i+"' class='"+this.classNames["tabMiddleInactive"]+"'>"+"<div id=\""+this.tabTitleId+i+"\" class=\""+this.classNames["tabTitle"]+"\" title=\""+_1c+"\">"+"</div>"+_18+"</div>"+"<div id='"+this.tabRightId+i+"' class='"+this.classNames["tabRightInactive"]+"'></div>"+"</div>"+br; 
     4483return _1d; 
     4484},setTabText:function(_1e,_1f){ 
     4485if(Element.isTextNode(_1e)){ 
     4486_1e.nodeValue=_1f; 
     4487}else{ 
     4488if(Element.isElementNode(_1e)){ 
     4489_1e.innerHTML=_1f; 
     4490
     4491
     4492},getTabText:function(_20){ 
     4493return Element.collectTextNodes(_20).escapeHTML().replace(/"/g,"&quot;").replace(/[\r\n\t\v]/g,"").replace(/(^(\s)*) | ((\s)*$)/g,""); 
     4494},chopTabText:function(_21){ 
     4495_21=_21.unescapeHTML(); 
     4496var _22=this.options.titleLength; 
     4497if(_22&&!isNaN(_22)&&(_21.length>_22)){ 
     4498_21=_21.truncate(_22+3); 
     4499
     4500return _21.escapeHTML(); 
     4501},buildPanel:function(_23,i,_25){ 
     4502_25=_25||i; 
    45034503var id=this.panelId+i; 
    4504 this.panelList[i]=id; 
     4504this.panelList[_25]=id; 
    45054505return "<div id='"+id+"' style='display: none;'></div>"; 
    4506 },holdElements:function(tab,_21,_22){ 
    4507 this.holder.push({number:_22,tab:tab,content:_21}); 
    4508 var _23=document.createDocumentFragment(); 
    4509 _23.appendChild(tab); 
    4510 _23.appendChild(_21); 
     4506},holdElements:function(tab,_28,_29){ 
     4507this.holder.push({number:_29,tab:tab,content:_28}); 
     4508var _2a=document.createDocumentFragment(); 
     4509_2a.appendChild(tab); 
     4510_2a.appendChild(_28); 
    45114511},selectTab:function(e){ 
    45124512if(!e){ 
     
    45184518return; 
    45194519} 
    4520 var _25=this.getCurrentPanel(); 
    4521 var _26=this.getCurrentTab(); 
    4522 var _27=null; 
     4520var _2c=this.getCurrentPanel(); 
     4521var _2d=this.getCurrentTab(); 
     4522var _2e=null; 
    45234523if(e.nodeType){ 
    4524 _27=e; 
    4525 }else{ 
    4526 _27=Event.element(e); 
    4527 } 
    4528 var _28=this.getTargetIndex(_27); 
    4529 if(_28==this.selected){ 
    4530 return; 
    4531 } 
    4532 var _29=this.panelList[_28]; 
    4533 var _2a=this.tabs[_28]; 
    4534 if(this._callBeforeSelect(_29)){ 
    4535 if(_26){ 
    4536 this.setTabInactive(_26); 
    4537 } 
    4538 this.setTabActive(_2a); 
    4539 if(_25){ 
    4540 Element.toggle(_25); 
    4541 } 
    4542 Element.toggle(_29); 
    4543 this.selected=_28
    4544 this._callAfterSelect(_29,_25); 
    4545 if(!_29.selected){ 
    4546 this._callAfterSelectOnce(_29); 
    4547 _29.selected=true; 
     4524_2e=e; 
     4525}else{ 
     4526_2e=Event.element(e); 
     4527} 
     4528var _2f=this.getTargetIndex(_2e); 
     4529if(_2f==this.selected){ 
     4530return; 
     4531} 
     4532var _30=this.panelList[_2f]; 
     4533var _31=this.tabs[_2f]; 
     4534if(this._callBeforeSelect(_30)){ 
     4535if(_2d){ 
     4536this.setTabInactive(_2d); 
     4537} 
     4538this.setTabActive(_31); 
     4539if(_2c){ 
     4540Element.hide(_2c); 
     4541} 
     4542Element.show(_30); 
     4543this.selected=_2f
     4544this._callAfterSelect(_30,_2c); 
     4545if(!_30.selected){ 
     4546this._callAfterSelectOnce(_30); 
     4547_30.selected=true; 
    45484548} 
    45494549} 
     
    45524552return; 
    45534553} 
    4554 var _2c=$(tab).immediateDescendants(); 
    4555 this.css.refreshClassNames(_2c[0],"tabLeftActive"); 
    4556 this.css.refreshClassNames(_2c[1],"tabMiddleActive"); 
    4557 this.css.refreshClassNames(_2c[2],"tabRightActive"); 
     4554var _33=$(tab).immediateDescendants(); 
     4555this.css.refreshClassNames(_33[0],"tabLeftActive"); 
     4556this.css.refreshClassNames(_33[1],"tabMiddleActive"); 
     4557this.css.refreshClassNames(_33[2],"tabRightActive"); 
    45584558},setTabInactive:function(tab){ 
    45594559if(!$(tab)){ 
    45604560return; 
    45614561} 
    4562 var _2e=$(tab).immediateDescendants(); 
    4563 this.css.refreshClassNames(_2e[0],"tabLeftInactive"); 
    4564 this.css.refreshClassNames(_2e[1],"tabMiddleInactive"); 
    4565 this.css.refreshClassNames(_2e[2],"tabRightInactive"); 
    4566 },getTargetIndex:function(_2f){ 
    4567 while(_2f){ 
    4568 if(_2f.id&&_2f.id.indexOf(this.tabId,0)>=0){ 
    4569 var _30=_2f.id.substring(this.tabId.length); 
    4570 if(!isNaN(_30)){ 
    4571 return _30
    4572 } 
    4573 } 
    4574 _2f=_2f.parentNode; 
    4575 } 
    4576 },onRemove:function(_31){ 
    4577 Event.stop(_31); 
    4578 var _32=Event.element(_31); 
    4579 var _33=this.getTargetIndex(_32); 
    4580 var tab=this.tabs[_33]; 
    4581 if(this.options.onRemove(tab)){ 
     4562var _35=$(tab).immediateDescendants(); 
     4563this.css.refreshClassNames(_35[0],"tabLeftInactive"); 
     4564this.css.refreshClassNames(_35[1],"tabMiddleInactive"); 
     4565this.css.refreshClassNames(_35[2],"tabRightInactive"); 
     4566},getTargetIndex:function(_36){ 
     4567while(_36){ 
     4568if(_36.id&&_36.id.indexOf(this.tabId,0)>=0){ 
     4569var _37=_36.id.substring(this.tabId.length); 
     4570if(!isNaN(_37)){ 
     4571return this.tabs.indexOf(_36)
     4572} 
     4573} 
     4574_36=_36.parentNode; 
     4575} 
     4576},onRemove:function(_38){ 
     4577Event.stop(_38); 
     4578var _39=Event.element(_38); 
     4579var _3a=this.getTargetIndex(_39); 
     4580var tab=this.tabs[_3a]; 
     4581if(r=this.options.onRemove(tab)){ 
    45824582this.remove(tab); 
    45834583} 
    45844584},remove:function(tab){ 
    45854585if(tab){ 
    4586 var _36=this.getTargetIndex(tab); 
    4587 var _37=this.getNextTab(); 
    4588 if(!_37){ 
    4589 _37=this.getPreviousTab(); 
    4590 
     4586var _3d=tab.parentNode; 
     4587var _3e=this.getTargetIndex(tab); 
     4588var _3f=this.getNextTab(); 
     4589if(!_3f){ 
     4590_3f=this.getPreviousTab(); 
     4591
     4592var _40=this.tabs[this.selected]; 
    45914593Element.remove(tab); 
    4592 Element.remove(this.panelList[_36]); 
    4593 this.tabs[_36]=null; 
    4594 this.panelList[_36]=null; 
    4595 if(_36==this.selected){ 
    4596 if(_37){ 
    4597 this.selectTab(_37); 
    4598 
    4599 
    4600 
    4601 },addByElement:function(_38){ 
     4594Element.remove(this.panelList[_3e]); 
     4595this.tabs[_3e]=null; 
     4596this.panelList[_3e]=null; 
     4597this.tabs=this.tabs.select(function(t){ 
     4598return t; 
     4599}); 
     4600this.panelList=this.panelList.select(function(t){ 
     4601return t; 
     4602}); 
     4603if(_3e==this.selected){ 
     4604if(_3f){ 
     4605this.selectTab(_3f); 
     4606
     4607}else{ 
     4608this.selected=this.getTargetIndex(_40); 
     4609
     4610this._setBrTag(); 
     4611
     4612},addByElement:function(_43){ 
    46024613this.holder=[]; 
    46034614this.ids=[]; 
    46044615this.contents=[]; 
    4605 var _39=this.buildTabSet($(_38),this.tabs.length); 
    4606 this.tabContainer.appendChild(_39.tab.toElement()); 
    4607 this.panelContainer.appendChild(_39.panel.toElement()); 
     4616var _44=0; 
     4617var _45=this.getLastTab(); 
     4618if(_45){ 
     4619_44=parseInt(_45.id.match(/[0-9]+$/)[0],10).succ(); 
     4620
     4621var _46=this.buildTabSet($(_43),_44,this.tabs.length); 
     4622var _47=_46.tab.toElements(); 
     4623this.tabContainer.appendChild(_47[0]); 
     4624if(_47[1]){ 
     4625this.tabContainer.appendChild(_47[1]); 
     4626
     4627this.panelContainer.appendChild(_46.panel.toElement()); 
    46084628this.tabs[this.tabs.length-1]=$(this.tabs.last()); 
    46094629this.panelList[this.panelList.length-1]=$(this.panelList.last()); 
     
    46134633this.setDrag(); 
    46144634} 
    4615 },add:function(_3a,_3b){ 
    4616 var _3c=[]; 
    4617 var _3d=Builder.node("div"); 
    4618 _3d.innerHTML=_3a
    4619 _3c.push(_3d); 
    4620 _3d=Builder.node("div"); 
    4621 _3d.innerHTML=_3b
    4622 _3c.push(_3d); 
    4623 this.addByElement(Builder.node("div",_3c)); 
    4624 },lazyLoad:function(_3e){ 
     4635},add:function(_48,_49){ 
     4636var _4a=[]; 
     4637var _4b=Builder.node("div"); 
     4638_4b.innerHTML=_48
     4639_4a.push(_4b); 
     4640_4b=Builder.node("div"); 
     4641_4b.innerHTML=_49
     4642_4a.push(_4b); 
     4643this.addByElement(Builder.node("div",_4a)); 
     4644},lazyLoad:function(_4c){ 
    46254645this.errorCount=0; 
    46264646this.loadedList=[]; 
    4627 this.load(_3e); 
    4628 },load:function(_3f){ 
    4629 var _40=this.panelList[_3f]; 
    4630 var url=this.options.lazyLoadUrl[_3f]; 
    4631 var _42=this; 
    4632 if(_40&&url){ 
    4633 new Ajax.Updater({success:_40},url,{onSuccess:function(){ 
    4634 _42.setLoaded(_3f); 
    4635 _42.options.onLazyLoad(_40,_42); 
    4636 _42.load(++_3f); 
    4637 if(_42.isFinishLazyLoad()){ 
    4638 _42.options.afterLazyLoad(_42); 
     4647this.load(_4c); 
     4648},load:function(_4d){ 
     4649var _4e=this.panelList[_4d]; 
     4650var url=this.options.lazyLoadUrl[_4d]; 
     4651var _50=this; 
     4652if(_4e&&url){ 
     4653new Ajax.Updater({success:_4e},url,{onSuccess:function(){ 
     4654_50.setLoaded(_4d); 
     4655_50.options.onLazyLoad(_4e,_50); 
     4656_50.load(++_4d); 
     4657if(_50.isFinishLazyLoad()){ 
     4658_50.options.afterLazyLoad(_50); 
    46394659} 
    46404660},onFailure:function(){ 
    4641 _42.errorCount++; 
    4642 _42.options.lazyLoadFailure(_40,_42); 
    4643 if(_42.errorCount<=_42.options.failureLimit){ 
    4644 _42.load(_3f); 
    4645 }else{ 
    4646 _42.options.failureLimitOver(_42); 
     4661_50.errorCount++; 
     4662_50.options.lazyLoadFailure(_4e,_50); 
     4663if(_50.errorCount<=_50.options.failureLimit){ 
     4664_50.load(_4d); 
     4665}else{ 
     4666_50.options.failureLimitOver(_50); 
    46474667} 
    46484668},asynchronous:true,evalScripts:true}); 
     
    46524672},setLoaded:function(i){ 
    46534673this.loadedList.push(i); 
    4654 },onMouseOver:function(_44){ 
    4655 var _45=Event.element(_44); 
    4656 var _46=this.getTargetIndex(_45); 
    4657 if(_46!=this.selected){ 
    4658 var _47=this.tabs[_46]; 
    4659 this.setTabActive(_47); 
    4660 } 
    4661 },onMouseOut:function(_48){ 
    4662 var _49=Event.element(_48); 
    4663 var _4a=this.getTargetIndex(_49); 
    4664 if(_4a!=this.selected){ 
    4665 var _4b=this.tabs[_4a]; 
    4666 this.setTabInactive(_4b); 
     4674},onMouseOver:function(_52){ 
     4675var _53=Event.element(_52); 
     4676var _54=this.getTargetIndex(_53); 
     4677if(_54!=this.selected){ 
     4678var _55=this.tabs[_54]; 
     4679this.setTabActive(_55); 
     4680} 
     4681},onMouseOut:function(_56){ 
     4682var _57=Event.element(_56); 
     4683var _58=this.getTargetIndex(_57); 
     4684if(_58!=this.selected){ 
     4685var _59=this.tabs[_58]; 
     4686this.setTabInactive(_59); 
    46674687} 
    46684688},hasNextTab:function(){ 
     
    46864706},getCurrentTab:function(){ 
    46874707return this.tabs[this.selected]; 
    4688 },_callBeforeSelect:function(_4e){ 
    4689 var _4f=this._findCallback(this.options.beforeSelect,_4e); 
    4690 return (_4f)?_4f():true; 
    4691 },_callAfterSelect:function(_50,_51){ 
    4692 var _52=this._findCallback(this.options.afterSelect,_50); 
    4693 if(_52){ 
    4694 _52(_50,_51); 
    4695 
    4696 },_callAfterSelectOnce:function(_53){ 
    4697 var _54=this._findCallback(this.options.afterSelectOnce,_53); 
    4698 if(_54){ 
    4699 _54(_53); 
    4700 
    4701 },_findCallback:function(_55,_56){ 
    4702 if(!_55){ 
    4703 return; 
    4704 
    4705 if(_55.constructor!=Function){ 
    4706 if(_55.constructor==Array){ 
    4707 _55=_55[this.panelList.indexOf(_56)]; 
    4708 }else{ 
    4709 _55=_55[this.panelList.indexOf(_56).succ()]; 
    4710 
    4711 
    4712 return _55; 
     4708},getLastTab:function(){ 
     4709return this.tabs.last(); 
     4710},_callBeforeSelect:function(_5c){ 
     4711var _5d=this._findCallback(this.options.beforeSelect,_5c); 
     4712return (_5d)?_5d():true; 
     4713},_callAfterSelect:function(_5e,_5f){ 
     4714var _60=this._findCallback(this.options.afterSelect,_5e); 
     4715if(_60){ 
     4716_60(_5e,_5f); 
     4717
     4718},_callAfterSelectOnce:function(_61){ 
     4719var _62=this._findCallback(this.options.afterSelectOnce,_61); 
     4720if(_62){ 
     4721_62(_61); 
     4722
     4723},_findCallback:function(_63,_64){ 
     4724if(!_63){ 
     4725return; 
     4726
     4727if(_63.constructor!=Function){ 
     4728if(_63.constructor==Array){ 
     4729_63=_63[this.panelList.indexOf(_64)]; 
     4730}else{ 
     4731_63=_63[this.panelList.indexOf(_64).succ()]; 
     4732
     4733
     4734return _63; 
     4735},_setBrTag:function(){ 
     4736if(this.options.tabRow){ 
     4737var _65=this.tabContainer; 
     4738var _66=[]; 
     4739var brs=[]; 
     4740Element.getTagNodes(_65).each(function(n){ 
     4741((n.tagName.toLowerCase()=="div")?_66:brs).push(n); 
     4742}); 
     4743_66.each(function(t,i){ 
     4744if((i.succ()%this.options.tabRow)==0){ 
     4745if(brs[0]){ 
     4746_65.insertBefore(brs[0],t.nextSibling); 
     4747brs.shift(); 
     4748}else{ 
     4749_65.insertBefore(Builder.node("br",{style:"clear: both"}),t.nextSibling); 
     4750
     4751
     4752}.bind(this)); 
     4753(brs||[]).each(function(b){ 
     4754Element.remove(b); 
     4755}); 
     4756
    47134757}}; 
    47144758 
  • spinelz/trunk/compress/javascripts/spinelz/tabBox.js

    r5754 r5907  
    5858} 
    5959},setDrag:function(){ 
    60 Sortable.create(this.tabContainerId,{tag:"div",overlap:"horizontal",constraint:"horizontal",onChange:this.options.onSort,onUpdate:this.options.afterSort,starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction}); 
     60Sortable.create(this.tabContainerId,{tag:"div",overlap:"horizontal",constraint:"horizontal",onChange:function(_5){ 
     61this.options.onSort(_5); 
     62this._setBrTag(); 
     63}.bind(this),onUpdate:this.options.afterSort,starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction}); 
    6164},setEvent:function(){ 
    62 this.ids.each(function(_5){ 
    63 Event.observe(_5.tab,"click",this.selectTab.bindAsEventListener(this)); 
    64 Event.observe(_5.tab,"mouseover",this.onMouseOver.bindAsEventListener(this)); 
    65 Event.observe(_5.tab,"mouseout",this.onMouseOut.bindAsEventListener(this)); 
     65this.ids.each(function(_6){ 
     66Event.observe(_6.tab,"click",this.selectTab.bindAsEventListener(this)); 
     67Event.observe(_6.tab,"mouseover",this.onMouseOver.bindAsEventListener(this)); 
     68Event.observe(_6.tab,"mouseout",this.onMouseOut.bindAsEventListener(this)); 
    6669if(this.options.closeButton){ 
    67 Event.observe(_5.button,"click",this.onRemove.bindAsEventListener(this)); 
     70Event.observe(_6.button,"click",this.onRemove.bindAsEventListener(this)); 
    6871} 
    6972}.bind(this)); 
    7073},appendElements:function(){ 
    71 this.holder.each(function(_6){ 
    72 $(this.tabTitleId+_6.number).appendChild(_6.tab); 
    73 this.panelList[_6.number].appendChild(_6.content); 
     74this.holder.each(function(_7){ 
     75$(this.tabTitleId+_7.number).appendChild(_7.tab); 
     76$(this.panelId+_7.number).appendChild(_7.content); 
    7477}.bind(this)); 
    7578},build:function(){ 
    76 var _7="<div id='"+this.tabContainerId+"' class='"+this.classNames["tabContainer"]+"'>"; 
    77 var _8="<div id='"+this.panelContainerId+"' class='"+this.classNames["panelContainer"]+"'>"; 
    78 var _9=0; 
    79 $A(this.element.childNodes).each(function(_a){ 
    80 if(Element.isElementNode(_a)){ 
    81 var _b=this.buildTabSet(_a,_9); 
    82 _7+=_b.tab; 
    83 _8+=_b.panel; 
    84 _9++; 
     79var _8=(UserAgent.isIE7())?" style='height: 90%;'":""; 
     80var _9="<div id='"+this.tabContainerId+"' class='"+this.classNames["tabContainer"]+"'"+_8+">"; 
     81var _a="<div id='"+this.panelContainerId+"' class='"+this.classNames["panelContainer"]+"'>"; 
     82var _b=0; 
     83$A(this.element.childNodes).each(function(_c){ 
     84if(Element.isElementNode(_c)){ 
     85var _d=this.buildTabSet(_c,_b); 
     86_9+=_d.tab; 
     87_a+=_d.panel; 
     88_b++; 
    8589} 
    8690}.bind(this)); 
    87 _7+="</div>"; 
    88 _8+="</div>"; 
    89 this.element.innerHTML=_7+"<div class='"+this.classNames["tabBar"]+"'></div>"+_8; 
    90 },buildTabSet:function(_c,i){ 
    91 var _e=Element.getChildNodesWithoutWhitespace(_c); 
    92 this.holdElements(_e[0],_e[1],i); 
    93 return {tab:this.buildTab(_e[0],i,Element.attributeHTML(_c,"onclick")),panel:this.buildPanel(_e[1],i)}; 
    94 },buildTab:function(_f,i,_11){ 
    95 var _12=this.tabId+i; 
    96 var ids={tab:_12}; 
     91_9+="</div>"; 
     92_a+="</div>"; 
     93this.element.innerHTML=_9+"<div class='"+this.classNames["tabBar"]+"'></div>"+_a; 
     94},buildTabSet:function(_e,i,_10){ 
     95var _11=Element.getChildNodesWithoutWhitespace(_e); 
     96this.holdElements(_11[0],_11[1],i); 
     97return {tab:this.buildTab(_11[0],i,Element.attributeHTML(_e,"onclick"),_10),panel:this.buildPanel(_11[1],i,_10)}; 
     98},buildTab:function(tab,i,_14,_15){ 
     99_15=_15||i; 
     100var _16=this.tabId+i; 
     101var ids={tab:_16}; 
    97102this.ids.push(ids); 
    98 this.tabs[i]=_12
    99 var _14=""; 
     103this.tabs[_15]=_16
     104var _18=""; 
    100105if(this.options.closeButton){ 
    101 var _15=this.element.id.appendSuffix("closeButton_"+i); 
    102 ids.button=_15; 
    103 _14="<div id='"+_15+"' class='"+this.classNames["closeButton"]+"'></div>"; 
    104 
    105 var _16=""; 
    106 if(this.options.tabRow&&!isNaN(this.options.tabRow)&&((i%this.options.tabRow)==0)){ 
    107 _16=" style='clear: left; float: none;'"; 
    108 
    109 var _17=this.getTabText(_f).escapeHTML().replace(/"/g,"&quot;"); 
    110 this.setTabText(_f,this.chopTabText(_17)); 
    111 var _18="<div id='"+_12+"' class='"+this.classNames["tab"]+"'"+_16+" "+_11+">"+"<div id='"+this.tabLeftId+i+"' class='"+this.classNames["tabLeftInactive"]+"'></div>"+"<div id='"+this.tabMiddleId+i+"' class='"+this.classNames["tabMiddleInactive"]+"'>"+"<div id=\""+this.tabTitleId+i+"\" class=\""+this.classNames["tabTitle"]+"\" title=\""+_17+"\">"+"</div>"+_14+"</div>"+"<div id='"+this.tabRightId+i+"' class='"+this.classNames["tabRightInactive"]+"'></div>"+"</div>"; 
    112 return _18; 
    113 },setTabText:function(_19,_1a){ 
    114 if(Element.isTextNode(_19)){ 
    115 _19.nodeValue=_1a; 
    116 }else{ 
    117 if(Element.isElementNode(_19)){ 
    118 _19.innerHTML=_1a; 
    119 
    120 
    121 },getTabText:function(_1b){ 
    122 if(Element.isTextNode(_1b)){ 
    123 textNode=_1b; 
    124 }else{ 
    125 if(Element.isElementNode(_1b)){ 
    126 textNode=Element.getTextNodes(_1b,true)[0]; 
    127 }else{ 
    128 return ""; 
    129 
    130 
    131 return textNode.nodeValue.replace(/(^(\s)*) | ((\s)*$)/,""); 
    132 },chopTabText:function(_1c){ 
    133 if(this.options.titleLength&&!isNaN(this.options.titleLength)){ 
    134 _1c=_1c.substring(0,this.options.titleLength); 
    135 
    136 return _1c; 
    137 },buildPanel:function(_1d,i){ 
     106var _19=this.element.id.appendSuffix("closeButton_"+i); 
     107ids.button=_19; 
     108_18="<div id='"+_19+"' class='"+this.classNames["closeButton"]+"'></div>"; 
     109
     110var _1a=""; 
     111var br=""; 
     112if(this.options.tabRow&&!isNaN(this.options.tabRow)&&((_15.succ()%this.options.tabRow)==0)){ 
     113br="<br style=\"clear: both;\" />"; 
     114
     115var _1c=this.getTabText(tab); 
     116this.setTabText(tab,this.chopTabText(_1c)); 
     117var _1d="<div id='"+_16+"' class='"+this.classNames["tab"]+"'"+_1a+" "+_14+">"+"<div id='"+this.tabLeftId+i+"' class='"+this.classNames["tabLeftInactive"]+"'></div>"+"<div id='"+this.tabMiddleId+i+"' class='"+this.classNames["tabMiddleInactive"]+"'>"+"<div id=\""+this.tabTitleId+i+"\" class=\""+this.classNames["tabTitle"]+"\" title=\""+_1c+"\">"+"</div>"+_18+"</div>"+"<div id='"+this.tabRightId+i+"' class='"+this.classNames["tabRightInactive"]+"'></div>"+"</div>"+br; 
     118return _1d; 
     119},setTabText:function(_1e,_1f){ 
     120if(Element.isTextNode(_1e)){ 
     121_1e.nodeValue=_1f; 
     122}else{ 
     123if(Element.isElementNode(_1e)){ 
     124_1e.innerHTML=_1f; 
     125
     126
     127},getTabText:function(_20){ 
     128return Element.collectTextNodes(_20).escapeHTML().replace(/"/g,"&quot;").replace(/[\r\n\t\v]/g,"").replace(/(^(\s)*) | ((\s)*$)/g,""); 
     129},chopTabText:function(_21){ 
     130_21=_21.unescapeHTML(); 
     131var _22=this.options.titleLength; 
     132if(_22&&!isNaN(_22)&&(_21.length>_22)){ 
     133_21=_21.truncate(_22+3); 
     134
     135return _21.escapeHTML(); 
     136},buildPanel:function(_23,i,_25){ 
     137_25=_25||i; 
    138138var id=this.panelId+i; 
    139 this.panelList[i]=id; 
     139this.panelList[_25]=id; 
    140140return "<div id='"+id+"' style='display: none;'></div>"; 
    141 },holdElements:function(tab,_21,_22){ 
    142 this.holder.push({number:_22,tab:tab,content:_21}); 
    143 var _23=document.createDocumentFragment(); 
    144 _23.appendChild(tab); 
    145 _23.appendChild(_21); 
     141},holdElements:function(tab,_28,_29){ 
     142this.holder.push({number:_29,tab:tab,content:_28}); 
     143var _2a=document.createDocumentFragment(); 
     144_2a.appendChild(tab); 
     145_2a.appendChild(_28); 
    146146},selectTab:function(e){ 
    147147if(!e){ 
     
    153153return; 
    154154} 
    155 var _25=this.getCurrentPanel(); 
    156 var _26=this.getCurrentTab(); 
    157 var _27=null; 
     155var _2c=this.getCurrentPanel(); 
     156var _2d=this.getCurrentTab(); 
     157var _2e=null; 
    158158if(e.nodeType){ 
    159 _27=e; 
    160 }else{ 
    161 _27=Event.element(e); 
    162 } 
    163 var _28=this.getTargetIndex(_27); 
    164 if(_28==this.selected){ 
    165 return; 
    166 } 
    167 var _29=this.panelList[_28]; 
    168 var _2a=this.tabs[_28]; 
    169 if(this._callBeforeSelect(_29)){ 
    170 if(_26){ 
    171 this.setTabInactive(_26); 
    172 } 
    173 this.setTabActive(_2a); 
    174 if(_25){ 
    175 Element.toggle(_25); 
    176 } 
    177 Element.toggle(_29); 
    178 this.selected=_28
    179 this._callAfterSelect(_29,_25); 
    180 if(!_29.selected){ 
    181 this._callAfterSelectOnce(_29); 
    182 _29.selected=true; 
     159_2e=e; 
     160}else{ 
     161_2e=Event.element(e); 
     162} 
     163var _2f=this.getTargetIndex(_2e); 
     164if(_2f==this.selected){ 
     165return; 
     166} 
     167var _30=this.panelList[_2f]; 
     168var _31=this.tabs[_2f]; 
     169if(this._callBeforeSelect(_30)){ 
     170if(_2d){ 
     171this.setTabInactive(_2d); 
     172} 
     173this.setTabActive(_31); 
     174if(_2c){ 
     175Element.hide(_2c); 
     176} 
     177Element.show(_30); 
     178this.selected=_2f
     179this._callAfterSelect(_30,_2c); 
     180if(!_30.selected){ 
     181this._callAfterSelectOnce(_30); 
     182_30.selected=true; 
    183183} 
    184184} 
     
    187187return; 
    188188} 
    189 var _2c=$(tab).immediateDescendants(); 
    190 this.css.refreshClassNames(_2c[0],"tabLeftActive"); 
    191 this.css.refreshClassNames(_2c[1],"tabMiddleActive"); 
    192 this.css.refreshClassNames(_2c[2],"tabRightActive"); 
     189var _33=$(tab).immediateDescendants(); 
     190this.css.refreshClassNames(_33[0],"tabLeftActive"); 
     191this.css.refreshClassNames(_33[1],"tabMiddleActive"); 
     192this.css.refreshClassNames(_33[2],"tabRightActive"); 
    193193},setTabInactive:function(tab){ 
    194194if(!$(tab)){ 
    195195return; 
    196196} 
    197 var _2e=$(tab).immediateDescendants(); 
    198 this.css.refreshClassNames(_2e[0],"tabLeftInactive"); 
    199 this.css.refreshClassNames(_2e[1],"tabMiddleInactive"); 
    200 this.css.refreshClassNames(_2e[2],"tabRightInactive"); 
    201 },getTargetIndex:function(_2f){ 
    202 while(_2f){ 
    203 if(_2f.id&&_2f.id.indexOf(this.tabId,0)>=0){ 
    204 var _30=_2f.id.substring(this.tabId.length); 
    205 if(!isNaN(_30)){ 
    206 return _30
    207 } 
    208 } 
    209 _2f=_2f.parentNode; 
    210 } 
    211 },onRemove:function(_31){ 
    212 Event.stop(_31); 
    213 var _32=Event.element(_31); 
    214 var _33=this.getTargetIndex(_32); 
    215 var tab=this.tabs[_33]; 
    216 if(this.options.onRemove(tab)){ 
     197var _35=$(tab).immediateDescendants(); 
     198this.css.refreshClassNames(_35[0],"tabLeftInactive"); 
     199this.css.refreshClassNames(_35[1],"tabMiddleInactive"); 
     200this.css.refreshClassNames(_35[2],"tabRightInactive"); 
     201},getTargetIndex:function(_36){ 
     202while(_36){ 
     203if(_36.id&&_36.id.indexOf(this.tabId,0)>=0){ 
     204var _37=_36.id.substring(this.tabId.length); 
     205if(!isNaN(_37)){ 
     206return this.tabs.indexOf(_36)
     207} 
     208} 
     209_36=_36.parentNode; 
     210} 
     211},onRemove:function(_38){ 
     212Event.stop(_38); 
     213var _39=Event.element(_38); 
     214var _3a=this.getTargetIndex(_39); 
     215var tab=this.tabs[_3a]; 
     216if(r=this.options.onRemove(tab)){ 
    217217this.remove(tab); 
    218218} 
    219219},remove:function(tab){ 
    220220if(tab){ 
    221 var _36=this.getTargetIndex(tab); 
    222 var _37=this.getNextTab(); 
    223 if(!_37){ 
    224 _37=this.getPreviousTab(); 
    225 
     221var _3d=tab.parentNode; 
     222var _3e=this.getTargetIndex(tab); 
     223var _3f=this.getNextTab(); 
     224if(!_3f){ 
     225_3f=this.getPreviousTab(); 
     226
     227var _40=this.tabs[this.selected]; 
    226228Element.remove(tab); 
    227 Element.remove(this.panelList[_36]); 
    228 this.tabs[_36]=null; 
    229 this.panelList[_36]=null; 
    230 if(_36==this.selected){ 
    231 if(_37){ 
    232 this.selectTab(_37); 
    233 
    234 
    235 
    236 },addByElement:function(_38){ 
     229Element.remove(this.panelList[_3e]); 
     230this.tabs[_3e]=null; 
     231this.panelList[_3e]=null; 
     232this.tabs=this.tabs.select(function(t){ 
     233return t; 
     234}); 
     235this.panelList=this.panelList.select(function(t){ 
     236return t; 
     237}); 
     238if(_3e==this.selected){ 
     239if(_3f){ 
     240this.selectTab(_3f); 
     241
     242}else{ 
     243this.selected=this.getTargetIndex(_40); 
     244
     245this._setBrTag(); 
     246
     247},addByElement:function(_43){ 
    237248this.holder=[]; 
    238249this.ids=[]; 
    239250this.contents=[]; 
    240 var _39=this.buildTabSet($(_38),this.tabs.length); 
    241 this.tabContainer.appendChild(_39.tab.toElement()); 
    242 this.panelContainer.appendChild(_39.panel.toElement()); 
     251var _44=0; 
     252var _45=this.getLastTab(); 
     253if(_45){ 
     254_44=parseInt(_45.id.match(/[0-9]+$/)[0],10).succ(); 
     255
     256var _46=this.buildTabSet($(_43),_44,this.tabs.length); 
     257var _47=_46.tab.toElements(); 
     258this.tabContainer.appendChild(_47[0]); 
     259if(_47[1]){ 
     260this.tabContainer.appendChild(_47[1]); 
     261
     262this.panelContainer.appendChild(_46.panel.toElement()); 
    243263this.tabs[this.tabs.length-1]=$(this.tabs.last()); 
    244264this.panelList[this.panelList.length-1]=$(this.panelList.last()); 
     
    248268this.setDrag(); 
    249269} 
    250 },add:function(_3a,_3b){ 
    251 var _3c=[]; 
    252 var _3d=Builder.node("div"); 
    253 _3d.innerHTML=_3a
    254 _3c.push(_3d); 
    255 _3d=Builder.node("div"); 
    256 _3d.innerHTML=_3b
    257 _3c.push(_3d); 
    258 this.addByElement(Builder.node("div",_3c)); 
    259 },lazyLoad:function(_3e){ 
     270},add:function(_48,_49){ 
     271var _4a=[]; 
     272var _4b=Builder.node("div"); 
     273_4b.innerHTML=_48
     274_4a.push(_4b); 
     275_4b=Builder.node("div"); 
     276_4b.innerHTML=_49
     277_4a.push(_4b); 
     278this.addByElement(Builder.node("div",_4a)); 
     279},lazyLoad:function(_4c){ 
    260280this.errorCount=0; 
    261281this.loadedList=[]; 
    262 this.load(_3e); 
    263 },load:function(_3f){ 
    264 var _40=this.panelList[_3f]; 
    265 var url=this.options.lazyLoadUrl[_3f]; 
    266 var _42=this; 
    267 if(_40&&url){ 
    268 new Ajax.Updater({success:_40},url,{onSuccess:function(){ 
    269 _42.setLoaded(_3f); 
    270 _42.options.onLazyLoad(_40,_42); 
    271 _42.load(++_3f); 
    272 if(_42.isFinishLazyLoad()){ 
    273 _42.options.afterLazyLoad(_42); 
     282this.load(_4c); 
     283},load:function(_4d){ 
     284var _4e=this.panelList[_4d]; 
     285var url=this.options.lazyLoadUrl[_4d]; 
     286var _50=this; 
     287if(_4e&&url){ 
     288new Ajax.Updater({success:_4e},url,{onSuccess:function(){ 
     289_50.setLoaded(_4d); 
     290_50.options.onLazyLoad(_4e,_50); 
     291_50.load(++_4d); 
     292if(_50.isFinishLazyLoad()){ 
     293_50.options.afterLazyLoad(_50); 
    274294} 
    275295},onFailure:function(){ 
    276 _42.errorCount++; 
    277 _42.options.lazyLoadFailure(_40,_42); 
    278 if(_42.errorCount<=_42.options.failureLimit){ 
    279 _42.load(_3f); 
    280 }else{ 
    281 _42.options.failureLimitOver(_42); 
     296_50.errorCount++; 
     297_50.options.lazyLoadFailure(_4e,_50); 
     298if(_50.errorCount<=_50.options.failureLimit){ 
     299_50.load(_4d); 
     300}else{ 
     301_50.options.failureLimitOver(_50); 
    282302} 
    283303},asynchronous:true,evalScripts:true}); 
     
    287307},setLoaded:function(i){ 
    288308this.loadedList.push(i); 
    289 },onMouseOver:function(_44){ 
    290 var _45=Event.element(_44); 
    291 var _46=this.getTargetIndex(_45); 
    292 if(_46!=this.selected){ 
    293 var _47=this.tabs[_46]; 
    294 this.setTabActive(_47); 
    295 } 
    296 },onMouseOut:function(_48){ 
    297 var _49=Event.element(_48); 
    298 var _4a=this.getTargetIndex(_49); 
    299 if(_4a!=this.selected){ 
    300 var _4b=this.tabs[_4a]; 
    301 this.setTabInactive(_4b); 
     309},onMouseOver:function(_52){ 
     310var _53=Event.element(_52); 
     311var _54=this.getTargetIndex(_53); 
     312if(_54!=this.selected){ 
     313var _55=this.tabs[_54]; 
     314this.setTabActive(_55); 
     315} 
     316},onMouseOut:function(_56){ 
     317var _57=Event.element(_56); 
     318var _58=this.getTargetIndex(_57); 
     319if(_58!=this.selected){ 
     320var _59=this.tabs[_58]; 
     321this.setTabInactive(_59); 
    302322} 
    303323},hasNextTab:function(){ 
     
    321341},getCurrentTab:function(){ 
    322342return this.tabs[this.selected]; 
    323 },_callBeforeSelect:function(_4e){ 
    324 var _4f=this._findCallback(this.options.beforeSelect,_4e); 
    325 return (_4f)?_4f():true; 
    326 },_callAfterSelect:function(_50,_51){ 
    327 var _52=this._findCallback(this.options.afterSelect,_50); 
    328 if(_52){ 
    329 _52(_50,_51); 
    330 
    331 },_callAfterSelectOnce:function(_53){ 
    332 var _54=this._findCallback(this.options.afterSelectOnce,_53); 
    333 if(_54){ 
    334 _54(_53); 
    335 
    336 },_findCallback:function(_55,_56){ 
    337 if(!_55){ 
    338 return; 
    339 
    340 if(_55.constructor!=Function){ 
    341 if(_55.constructor==Array){ 
    342 _55=_55[this.panelList.indexOf(_56)]; 
    343 }else{ 
    344 _55=_55[this.panelList.indexOf(_56).succ()]; 
    345 
    346 
    347 return _55; 
     343},getLastTab:function(){ 
     344return this.tabs.last(); 
     345},_callBeforeSelect:function(_5c){ 
     346var _5d=this._findCallback(this.options.beforeSelect,_5c); 
     347return (_5d)?_5d():true; 
     348},_callAfterSelect:function(_5e,_5f){ 
     349var _60=this._findCallback(this.options.afterSelect,_5e); 
     350if(_60){ 
     351_60(_5e,_5f); 
     352
     353},_callAfterSelectOnce:function(_61){ 
     354var _62=this._findCallback(this.options.afterSelectOnce,_61); 
     355if(_62){ 
     356_62(_61); 
     357
     358},_findCallback:function(_63,_64){ 
     359if(!_63){ 
     360return; 
     361
     362if(_63.constructor!=Function){ 
     363if(_63.constructor==Array){ 
     364_63=_63[this.panelList.indexOf(_64)]; 
     365}else{ 
     366_63=_63[this.panelList.indexOf(_64).succ()]; 
     367
     368
     369return _63; 
     370},_setBrTag:function(){ 
     371if(this.options.tabRow){ 
     372var _65=this.tabContainer; 
     373var _66=[]; 
     374var brs=[]; 
     375Element.getTagNodes(_65).each(function(n){ 
     376((n.tagName.toLowerCase()=="div")?_66:brs).push(n); 
     377}); 
     378_66.each(function(t,i){ 
     379if((i.succ()%this.options.tabRow)==0){ 
     380if(brs[0]){ 
     381_65.insertBefore(brs[0],t.nextSibling); 
     382brs.shift(); 
     383}else{ 
     384_65.insertBefore(Builder.node("br",{style:"clear: both"}),t.nextSibling); 
     385
     386
     387}.bind(this)); 
     388(brs||[]).each(function(b){ 
     389Element.remove(b); 
     390}); 
     391
    348392}}; 
    349393 
  • spinelz/trunk/src/javascripts/spinelz/tabBox.js

    <
    r5754 r5907  
    118118      overlap:     'horizontal', 
    119119      constraint:  'horizontal', 
    120       onChange:    this.options.onSort, 
     120      onChange:    function(tab) { 
     121        this.options.onSort(tab); 
     122        this._setBrTag(); 
     123      }.bind(this), 
    121124      onUpdate:    this.options.afterSort, 
    122125      starteffect: Prototype.emptyFunction, 
     
    139142    this.holder.each(function(set) { 
    140143      $(this.tabTitleId + set.number).appendChild(set.tab); 
    141       this.panelList[set.number].appendChild(set.content); 
     144      $(this.panelId + set.number).appendChild(set.content); 
    142145    }.bind(this)); 
    143146  }, 
    144147   
    145148  build: function() { 
     149    var style = (UserAgent.isIE7()) ? " style='height: 90%;'" : ""; 
    146150    var tabContainer = 
    147       "<div id='" + this.tabContainerId + "' class='" + this.classNames['tabContainer'] + "'>"; 
     151      "<div id='" + this.tabContainerId + "' class='" + this.classNames['tabContainer'] + "'" + style + ">"; 
    148152    var panelContainer = 
    149153      "<div id='" + this.panelContainerId + "' class='" + this.classNames['panelContainer'] + "'>"; 
     
    165169  }, 
    166170 
    167   buildTabSet: function(element, i) { 
     171  buildTabSet: function(element, i, count) { 
    168172    var nodes = Element.getChildNodesWithoutWhitespace(element); 
    169173    this.holdElements(nodes[0], nodes[1], i); 
    170174    return { 
    171       tab:  this.buildTab(nodes[0], i, Element.attributeHTML(element, 'onclick')), 
    172       panel: this.buildPanel(nodes[1], i
     175      tab:  this.buildTab(nodes[0], i, Element.attributeHTML(element, 'onclick'), count), 
     176      panel: this.buildPanel(nodes[1], i, count
    173177    }; 
    174178  }, 
    175179 
    176   buildTab: function(tab, i, events) { 
     180  buildTab: function(tab, i, events, count) { 
     181    count = count || i; 
    177182    var tabId = this.tabId + i; 
    178183    var ids = {tab: tabId}; 
    179184    this.ids.push(ids); 
    180     this.tabs[i] = tabId; 
     185    this.tabs[count] = tabId; 
    181186 
    182187    var button = ""; 
     
    188193 
    189194    var tabStyle = ""; 
    190     if (this.options.tabRow && !isNaN(this.options.tabRow) && ((i % this.options.tabRow) == 0)) { 
    191       tabStyle = " style='clear: left; float: none;'"; 
    192     } 
    193  
    194     var tabText = this.getTabText(tab).escapeHTML().replace(/"/g, '&quot;'); 
     195    var br = ""; 
     196    if (this.options.tabRow && !isNaN(this.options.tabRow) && ((count.succ() % this.options.tabRow) == 0)) { 
     197      br = "<br style=\"clear: both;\" />"; 
     198    } 
     199 
     200    var tabText = this.getTabText(tab); 
    195201    this.setTabText(tab, this.chopTabText(tabText)); 
    196202 
     
    204210        "</div>" + 
    205211        "<div id='" + this.tabRightId + i + "' class='" + this.classNames['tabRightInactive'] + "'></div>" + 
    206       "</div>"
     212      "</div>" + br
    207213    return html; 
    208214  }, 
     
    217223 
    218224  getTabText: function(element) { 
    219     if (Element.isTextNode(element)) { 
    220       textNode = element; 
    221     } else if (Element.isElementNode(element)) { 
    222       textNode = Element.getTextNodes(element, true)[0]; 
    223     } else { 
    224       return ''; 
    225     } 
    226     return textNode.nodeValue.replace(/(^(\s)*) | ((\s)*$)/, ''); 
     225    return Element.collectTextNodes(element).escapeHTML().replace(/"/g, '&quot;'). 
     226      replace(/[\r\n\t\v]/g, '').replace(/(^(\s)*) | ((\s)*$)/g, ''); 
    227227  }, 
    228228 
    229229  chopTabText: function(title) { 
    230     if (this.options.titleLength && !isNaN(this.options.titleLength)) { 
    231       title = title.substring(0, this.options.titleLength); 
    232     } 
    233     return title; 
    234   }, 
    235  
    236   buildPanel: function(panelContent, i) { 
     230    title = title.unescapeHTML(); 
     231    var length = this.options.titleLength; 
     232    if (length && !isNaN(length) && (title.length > length)) { 
     233      title = title.truncate(length + 3); 
     234    } 
     235    return title.escapeHTML(); 
     236  }, 
     237 
     238  buildPanel: function(panelContent, i, count) { 
     239    count = count || i; 
    237240    var id = this.panelId + i; 
    238     this.panelList[i] = id; 
     241    this.panelList[count] = id; 
    239242    return "<div id='" + id + "' style='display: none;'></div>"; 
    240243  }, 
     
    274277      this.setTabActive(targetTab); 
    275278 
    276       if (currentPanel) Element.toggle(currentPanel); 
    277       Element.toggle(targetPanel); 
     279      if (currentPanel) Element.hide(currentPanel); 
     280      Element.show(targetPanel); 
    278281 
    279282      this.selected = targetIndex; 
     
    307310        var index = element.id.substring(this.tabId.length); 
    308311        if (!isNaN(index)) { 
    309           return index
     312          return this.tabs.indexOf(element)
    310313        } 
    311314      } 
     
    319322    var index = this.getTargetIndex(element); 
    320323    var tab = this.tabs[index]; 
    321     if (this.options.onRemove(tab)) { 
     324    if (r = this.options.onRemove(tab)) { 
    322325      this.remove(tab); 
    323326    } 
     
    326329  remove: function(tab) { 
    327330    if (tab) { 
     331      var parent = tab.parentNode; 
    328332      var index = this.getTargetIndex(tab); 
    329333      var nextActiveTab = this.getNextTab(); 
    330334      if (!nextActiveTab) nextActiveTab = this.getPreviousTab(); 
     335      var selectedTab = this.tabs[this.selected]; 
    331336      Element.remove(tab); 
    332337      Element.remove(this.panelList[index]); 
    333338      this.tabs[index] = null; 
    334339      this.panelList[index] = null; 
     340      this.tabs = this.tabs.select(function(t) { return t; }); 
     341      this.panelList = this.panelList.select(function(t) { return t; }); 
    335342   
    336343      if (index == this.selected) { 
     
    338345          this.selectTab(nextActiveTab); 
    339346        } 
     347      } else { 
     348        this.selected = this.getTargetIndex(selectedTab); 
    340349      } 
     350      this._setBrTag(); 
    341351    } 
    342352  },