Changeset 5907
- Timestamp:
- 08/08/08 16:32:35 (4 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
spinelz/trunk/compress/javascripts/spinelz/spinelz_for_rubricks.js
r5905 r5907 4423 4423 } 4424 4424 },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}); 4425 Sortable.create(this.tabContainerId,{tag:"div",overlap:"horizontal",constraint:"horizontal",onChange:function(_5){ 4426 this.options.onSort(_5); 4427 this._setBrTag(); 4428 }.bind(this),onUpdate:this.options.afterSort,starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction}); 4426 4429 },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));4430 this.ids.each(function(_6){ 4431 Event.observe(_6.tab,"click",this.selectTab.bindAsEventListener(this)); 4432 Event.observe(_6.tab,"mouseover",this.onMouseOver.bindAsEventListener(this)); 4433 Event.observe(_6.tab,"mouseout",this.onMouseOut.bindAsEventListener(this)); 4431 4434 if(this.options.closeButton){ 4432 Event.observe(_ 5.button,"click",this.onRemove.bindAsEventListener(this));4435 Event.observe(_6.button,"click",this.onRemove.bindAsEventListener(this)); 4433 4436 } 4434 4437 }.bind(this)); 4435 4438 },appendElements:function(){ 4436 this.holder.each(function(_ 6){4437 $(this.tabTitleId+_ 6.number).appendChild(_6.tab);4438 this.panelList[_6.number].appendChild(_6.content);4439 this.holder.each(function(_7){ 4440 $(this.tabTitleId+_7.number).appendChild(_7.tab); 4441 $(this.panelId+_7.number).appendChild(_7.content); 4439 4442 }.bind(this)); 4440 4443 },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++; 4444 var _8=(UserAgent.isIE7())?" style='height: 90%;'":""; 4445 var _9="<div id='"+this.tabContainerId+"' class='"+this.classNames["tabContainer"]+"'"+_8+">"; 4446 var _a="<div id='"+this.panelContainerId+"' class='"+this.classNames["panelContainer"]+"'>"; 4447 var _b=0; 4448 $A(this.element.childNodes).each(function(_c){ 4449 if(Element.isElementNode(_c)){ 4450 var _d=this.buildTabSet(_c,_b); 4451 _9+=_d.tab; 4452 _a+=_d.panel; 4453 _b++; 4450 4454 } 4451 4455 }.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>"; 4458 this.element.innerHTML=_9+"<div class='"+this.classNames["tabBar"]+"'></div>"+_a; 4459 },buildTabSet:function(_e,i,_10){ 4460 var _11=Element.getChildNodesWithoutWhitespace(_e); 4461 this.holdElements(_11[0],_11[1],i); 4462 return {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; 4465 var _16=this.tabId+i; 4466 var ids={tab:_16}; 4462 4467 this.ids.push(ids); 4463 this.tabs[ i]=_12;4464 var _1 4="";4468 this.tabs[_15]=_16; 4469 var _18=""; 4465 4470 if(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,"""); 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){ 4471 var _19=this.element.id.appendSuffix("closeButton_"+i); 4472 ids.button=_19; 4473 _18="<div id='"+_19+"' class='"+this.classNames["closeButton"]+"'></div>"; 4474 } 4475 var _1a=""; 4476 var br=""; 4477 if(this.options.tabRow&&!isNaN(this.options.tabRow)&&((_15.succ()%this.options.tabRow)==0)){ 4478 br="<br style=\"clear: both;\" />"; 4479 } 4480 var _1c=this.getTabText(tab); 4481 this.setTabText(tab,this.chopTabText(_1c)); 4482 var _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; 4483 return _1d; 4484 },setTabText:function(_1e,_1f){ 4485 if(Element.isTextNode(_1e)){ 4486 _1e.nodeValue=_1f; 4487 }else{ 4488 if(Element.isElementNode(_1e)){ 4489 _1e.innerHTML=_1f; 4490 } 4491 } 4492 },getTabText:function(_20){ 4493 return Element.collectTextNodes(_20).escapeHTML().replace(/"/g,""").replace(/[\r\n\t\v]/g,"").replace(/(^(\s)*) | ((\s)*$)/g,""); 4494 },chopTabText:function(_21){ 4495 _21=_21.unescapeHTML(); 4496 var _22=this.options.titleLength; 4497 if(_22&&!isNaN(_22)&&(_21.length>_22)){ 4498 _21=_21.truncate(_22+3); 4499 } 4500 return _21.escapeHTML(); 4501 },buildPanel:function(_23,i,_25){ 4502 _25=_25||i; 4503 4503 var id=this.panelId+i; 4504 this.panelList[ i]=id;4504 this.panelList[_25]=id; 4505 4505 return "<div id='"+id+"' style='display: none;'></div>"; 4506 },holdElements:function(tab,_2 1,_22){4507 this.holder.push({number:_2 2,tab:tab,content:_21});4508 var _2 3=document.createDocumentFragment();4509 _2 3.appendChild(tab);4510 _2 3.appendChild(_21);4506 },holdElements:function(tab,_28,_29){ 4507 this.holder.push({number:_29,tab:tab,content:_28}); 4508 var _2a=document.createDocumentFragment(); 4509 _2a.appendChild(tab); 4510 _2a.appendChild(_28); 4511 4511 },selectTab:function(e){ 4512 4512 if(!e){ … … 4518 4518 return; 4519 4519 } 4520 var _2 5=this.getCurrentPanel();4521 var _2 6=this.getCurrentTab();4522 var _2 7=null;4520 var _2c=this.getCurrentPanel(); 4521 var _2d=this.getCurrentTab(); 4522 var _2e=null; 4523 4523 if(e.nodeType){ 4524 _2 7=e;4525 }else{ 4526 _2 7=Event.element(e);4527 } 4528 var _2 8=this.getTargetIndex(_27);4529 if(_2 8==this.selected){4530 return; 4531 } 4532 var _ 29=this.panelList[_28];4533 var _ 2a=this.tabs[_28];4534 if(this._callBeforeSelect(_ 29)){4535 if(_2 6){4536 this.setTabInactive(_2 6);4537 } 4538 this.setTabActive(_ 2a);4539 if(_2 5){4540 Element. toggle(_25);4541 } 4542 Element. toggle(_29);4543 this.selected=_2 8;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 } 4528 var _2f=this.getTargetIndex(_2e); 4529 if(_2f==this.selected){ 4530 return; 4531 } 4532 var _30=this.panelList[_2f]; 4533 var _31=this.tabs[_2f]; 4534 if(this._callBeforeSelect(_30)){ 4535 if(_2d){ 4536 this.setTabInactive(_2d); 4537 } 4538 this.setTabActive(_31); 4539 if(_2c){ 4540 Element.hide(_2c); 4541 } 4542 Element.show(_30); 4543 this.selected=_2f; 4544 this._callAfterSelect(_30,_2c); 4545 if(!_30.selected){ 4546 this._callAfterSelectOnce(_30); 4547 _30.selected=true; 4548 4548 } 4549 4549 } … … 4552 4552 return; 4553 4553 } 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");4554 var _33=$(tab).immediateDescendants(); 4555 this.css.refreshClassNames(_33[0],"tabLeftActive"); 4556 this.css.refreshClassNames(_33[1],"tabMiddleActive"); 4557 this.css.refreshClassNames(_33[2],"tabRightActive"); 4558 4558 },setTabInactive:function(tab){ 4559 4559 if(!$(tab)){ 4560 4560 return; 4561 4561 } 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 _3 0=_2f.id.substring(this.tabId.length);4570 if(!isNaN(_3 0)){4571 return _30;4572 } 4573 } 4574 _ 2f=_2f.parentNode;4575 } 4576 },onRemove:function(_3 1){4577 Event.stop(_3 1);4578 var _3 2=Event.element(_31);4579 var _3 3=this.getTargetIndex(_32);4580 var tab=this.tabs[_3 3];4581 if( this.options.onRemove(tab)){4562 var _35=$(tab).immediateDescendants(); 4563 this.css.refreshClassNames(_35[0],"tabLeftInactive"); 4564 this.css.refreshClassNames(_35[1],"tabMiddleInactive"); 4565 this.css.refreshClassNames(_35[2],"tabRightInactive"); 4566 },getTargetIndex:function(_36){ 4567 while(_36){ 4568 if(_36.id&&_36.id.indexOf(this.tabId,0)>=0){ 4569 var _37=_36.id.substring(this.tabId.length); 4570 if(!isNaN(_37)){ 4571 return this.tabs.indexOf(_36); 4572 } 4573 } 4574 _36=_36.parentNode; 4575 } 4576 },onRemove:function(_38){ 4577 Event.stop(_38); 4578 var _39=Event.element(_38); 4579 var _3a=this.getTargetIndex(_39); 4580 var tab=this.tabs[_3a]; 4581 if(r=this.options.onRemove(tab)){ 4582 4582 this.remove(tab); 4583 4583 } 4584 4584 },remove:function(tab){ 4585 4585 if(tab){ 4586 var _36=this.getTargetIndex(tab); 4587 var _37=this.getNextTab(); 4588 if(!_37){ 4589 _37=this.getPreviousTab(); 4590 } 4586 var _3d=tab.parentNode; 4587 var _3e=this.getTargetIndex(tab); 4588 var _3f=this.getNextTab(); 4589 if(!_3f){ 4590 _3f=this.getPreviousTab(); 4591 } 4592 var _40=this.tabs[this.selected]; 4591 4593 Element.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){ 4594 Element.remove(this.panelList[_3e]); 4595 this.tabs[_3e]=null; 4596 this.panelList[_3e]=null; 4597 this.tabs=this.tabs.select(function(t){ 4598 return t; 4599 }); 4600 this.panelList=this.panelList.select(function(t){ 4601 return t; 4602 }); 4603 if(_3e==this.selected){ 4604 if(_3f){ 4605 this.selectTab(_3f); 4606 } 4607 }else{ 4608 this.selected=this.getTargetIndex(_40); 4609 } 4610 this._setBrTag(); 4611 } 4612 },addByElement:function(_43){ 4602 4613 this.holder=[]; 4603 4614 this.ids=[]; 4604 4615 this.contents=[]; 4605 var _39=this.buildTabSet($(_38),this.tabs.length); 4606 this.tabContainer.appendChild(_39.tab.toElement()); 4607 this.panelContainer.appendChild(_39.panel.toElement()); 4616 var _44=0; 4617 var _45=this.getLastTab(); 4618 if(_45){ 4619 _44=parseInt(_45.id.match(/[0-9]+$/)[0],10).succ(); 4620 } 4621 var _46=this.buildTabSet($(_43),_44,this.tabs.length); 4622 var _47=_46.tab.toElements(); 4623 this.tabContainer.appendChild(_47[0]); 4624 if(_47[1]){ 4625 this.tabContainer.appendChild(_47[1]); 4626 } 4627 this.panelContainer.appendChild(_46.panel.toElement()); 4608 4628 this.tabs[this.tabs.length-1]=$(this.tabs.last()); 4609 4629 this.panelList[this.panelList.length-1]=$(this.panelList.last()); … … 4613 4633 this.setDrag(); 4614 4634 } 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){ 4636 var _4a=[]; 4637 var _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); 4643 this.addByElement(Builder.node("div",_4a)); 4644 },lazyLoad:function(_4c){ 4625 4645 this.errorCount=0; 4626 4646 this.loadedList=[]; 4627 this.load(_ 3e);4628 },load:function(_ 3f){4629 var _4 0=this.panelList[_3f];4630 var url=this.options.lazyLoadUrl[_ 3f];4631 var _ 42=this;4632 if(_4 0&&url){4633 new Ajax.Updater({success:_4 0},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);4647 this.load(_4c); 4648 },load:function(_4d){ 4649 var _4e=this.panelList[_4d]; 4650 var url=this.options.lazyLoadUrl[_4d]; 4651 var _50=this; 4652 if(_4e&&url){ 4653 new Ajax.Updater({success:_4e},url,{onSuccess:function(){ 4654 _50.setLoaded(_4d); 4655 _50.options.onLazyLoad(_4e,_50); 4656 _50.load(++_4d); 4657 if(_50.isFinishLazyLoad()){ 4658 _50.options.afterLazyLoad(_50); 4639 4659 } 4640 4660 },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); 4663 if(_50.errorCount<=_50.options.failureLimit){ 4664 _50.load(_4d); 4665 }else{ 4666 _50.options.failureLimitOver(_50); 4647 4667 } 4648 4668 },asynchronous:true,evalScripts:true}); … … 4652 4672 },setLoaded:function(i){ 4653 4673 this.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){ 4675 var _53=Event.element(_52); 4676 var _54=this.getTargetIndex(_53); 4677 if(_54!=this.selected){ 4678 var _55=this.tabs[_54]; 4679 this.setTabActive(_55); 4680 } 4681 },onMouseOut:function(_56){ 4682 var _57=Event.element(_56); 4683 var _58=this.getTargetIndex(_57); 4684 if(_58!=this.selected){ 4685 var _59=this.tabs[_58]; 4686 this.setTabInactive(_59); 4667 4687 } 4668 4688 },hasNextTab:function(){ … … 4686 4706 },getCurrentTab:function(){ 4687 4707 return 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(){ 4709 return this.tabs.last(); 4710 },_callBeforeSelect:function(_5c){ 4711 var _5d=this._findCallback(this.options.beforeSelect,_5c); 4712 return (_5d)?_5d():true; 4713 },_callAfterSelect:function(_5e,_5f){ 4714 var _60=this._findCallback(this.options.afterSelect,_5e); 4715 if(_60){ 4716 _60(_5e,_5f); 4717 } 4718 },_callAfterSelectOnce:function(_61){ 4719 var _62=this._findCallback(this.options.afterSelectOnce,_61); 4720 if(_62){ 4721 _62(_61); 4722 } 4723 },_findCallback:function(_63,_64){ 4724 if(!_63){ 4725 return; 4726 } 4727 if(_63.constructor!=Function){ 4728 if(_63.constructor==Array){ 4729 _63=_63[this.panelList.indexOf(_64)]; 4730 }else{ 4731 _63=_63[this.panelList.indexOf(_64).succ()]; 4732 } 4733 } 4734 return _63; 4735 },_setBrTag:function(){ 4736 if(this.options.tabRow){ 4737 var _65=this.tabContainer; 4738 var _66=[]; 4739 var brs=[]; 4740 Element.getTagNodes(_65).each(function(n){ 4741 ((n.tagName.toLowerCase()=="div")?_66:brs).push(n); 4742 }); 4743 _66.each(function(t,i){ 4744 if((i.succ()%this.options.tabRow)==0){ 4745 if(brs[0]){ 4746 _65.insertBefore(brs[0],t.nextSibling); 4747 brs.shift(); 4748 }else{ 4749 _65.insertBefore(Builder.node("br",{style:"clear: both"}),t.nextSibling); 4750 } 4751 } 4752 }.bind(this)); 4753 (brs||[]).each(function(b){ 4754 Element.remove(b); 4755 }); 4756 } 4713 4757 }}; 4714 4758 spinelz/trunk/compress/javascripts/spinelz/tabBox.js
r5754 r5907 58 58 } 59 59 },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}); 60 Sortable.create(this.tabContainerId,{tag:"div",overlap:"horizontal",constraint:"horizontal",onChange:function(_5){ 61 this.options.onSort(_5); 62 this._setBrTag(); 63 }.bind(this),onUpdate:this.options.afterSort,starteffect:Prototype.emptyFunction,endeffect:Prototype.emptyFunction}); 61 64 },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));65 this.ids.each(function(_6){ 66 Event.observe(_6.tab,"click",this.selectTab.bindAsEventListener(this)); 67 Event.observe(_6.tab,"mouseover",this.onMouseOver.bindAsEventListener(this)); 68 Event.observe(_6.tab,"mouseout",this.onMouseOut.bindAsEventListener(this)); 66 69 if(this.options.closeButton){ 67 Event.observe(_ 5.button,"click",this.onRemove.bindAsEventListener(this));70 Event.observe(_6.button,"click",this.onRemove.bindAsEventListener(this)); 68 71 } 69 72 }.bind(this)); 70 73 },appendElements:function(){ 71 this.holder.each(function(_ 6){72 $(this.tabTitleId+_ 6.number).appendChild(_6.tab);73 this.panelList[_6.number].appendChild(_6.content);74 this.holder.each(function(_7){ 75 $(this.tabTitleId+_7.number).appendChild(_7.tab); 76 $(this.panelId+_7.number).appendChild(_7.content); 74 77 }.bind(this)); 75 78 },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++; 79 var _8=(UserAgent.isIE7())?" style='height: 90%;'":""; 80 var _9="<div id='"+this.tabContainerId+"' class='"+this.classNames["tabContainer"]+"'"+_8+">"; 81 var _a="<div id='"+this.panelContainerId+"' class='"+this.classNames["panelContainer"]+"'>"; 82 var _b=0; 83 $A(this.element.childNodes).each(function(_c){ 84 if(Element.isElementNode(_c)){ 85 var _d=this.buildTabSet(_c,_b); 86 _9+=_d.tab; 87 _a+=_d.panel; 88 _b++; 85 89 } 86 90 }.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>"; 93 this.element.innerHTML=_9+"<div class='"+this.classNames["tabBar"]+"'></div>"+_a; 94 },buildTabSet:function(_e,i,_10){ 95 var _11=Element.getChildNodesWithoutWhitespace(_e); 96 this.holdElements(_11[0],_11[1],i); 97 return {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; 100 var _16=this.tabId+i; 101 var ids={tab:_16}; 97 102 this.ids.push(ids); 98 this.tabs[ i]=_12;99 var _1 4="";103 this.tabs[_15]=_16; 104 var _18=""; 100 105 if(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,"""); 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){ 106 var _19=this.element.id.appendSuffix("closeButton_"+i); 107 ids.button=_19; 108 _18="<div id='"+_19+"' class='"+this.classNames["closeButton"]+"'></div>"; 109 } 110 var _1a=""; 111 var br=""; 112 if(this.options.tabRow&&!isNaN(this.options.tabRow)&&((_15.succ()%this.options.tabRow)==0)){ 113 br="<br style=\"clear: both;\" />"; 114 } 115 var _1c=this.getTabText(tab); 116 this.setTabText(tab,this.chopTabText(_1c)); 117 var _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; 118 return _1d; 119 },setTabText:function(_1e,_1f){ 120 if(Element.isTextNode(_1e)){ 121 _1e.nodeValue=_1f; 122 }else{ 123 if(Element.isElementNode(_1e)){ 124 _1e.innerHTML=_1f; 125 } 126 } 127 },getTabText:function(_20){ 128 return Element.collectTextNodes(_20).escapeHTML().replace(/"/g,""").replace(/[\r\n\t\v]/g,"").replace(/(^(\s)*) | ((\s)*$)/g,""); 129 },chopTabText:function(_21){ 130 _21=_21.unescapeHTML(); 131 var _22=this.options.titleLength; 132 if(_22&&!isNaN(_22)&&(_21.length>_22)){ 133 _21=_21.truncate(_22+3); 134 } 135 return _21.escapeHTML(); 136 },buildPanel:function(_23,i,_25){ 137 _25=_25||i; 138 138 var id=this.panelId+i; 139 this.panelList[ i]=id;139 this.panelList[_25]=id; 140 140 return "<div id='"+id+"' style='display: none;'></div>"; 141 },holdElements:function(tab,_2 1,_22){142 this.holder.push({number:_2 2,tab:tab,content:_21});143 var _2 3=document.createDocumentFragment();144 _2 3.appendChild(tab);145 _2 3.appendChild(_21);141 },holdElements:function(tab,_28,_29){ 142 this.holder.push({number:_29,tab:tab,content:_28}); 143 var _2a=document.createDocumentFragment(); 144 _2a.appendChild(tab); 145 _2a.appendChild(_28); 146 146 },selectTab:function(e){ 147 147 if(!e){ … … 153 153 return; 154 154 } 155 var _2 5=this.getCurrentPanel();156 var _2 6=this.getCurrentTab();157 var _2 7=null;155 var _2c=this.getCurrentPanel(); 156 var _2d=this.getCurrentTab(); 157 var _2e=null; 158 158 if(e.nodeType){ 159 _2 7=e;160 }else{ 161 _2 7=Event.element(e);162 } 163 var _2 8=this.getTargetIndex(_27);164 if(_2 8==this.selected){165 return; 166 } 167 var _ 29=this.panelList[_28];168 var _ 2a=this.tabs[_28];169 if(this._callBeforeSelect(_ 29)){170 if(_2 6){171 this.setTabInactive(_2 6);172 } 173 this.setTabActive(_ 2a);174 if(_2 5){175 Element. toggle(_25);176 } 177 Element. toggle(_29);178 this.selected=_2 8;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 } 163 var _2f=this.getTargetIndex(_2e); 164 if(_2f==this.selected){ 165 return; 166 } 167 var _30=this.panelList[_2f]; 168 var _31=this.tabs[_2f]; 169 if(this._callBeforeSelect(_30)){ 170 if(_2d){ 171 this.setTabInactive(_2d); 172 } 173 this.setTabActive(_31); 174 if(_2c){ 175 Element.hide(_2c); 176 } 177 Element.show(_30); 178 this.selected=_2f; 179 this._callAfterSelect(_30,_2c); 180 if(!_30.selected){ 181 this._callAfterSelectOnce(_30); 182 _30.selected=true; 183 183 } 184 184 } … … 187 187 return; 188 188 } 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");189 var _33=$(tab).immediateDescendants(); 190 this.css.refreshClassNames(_33[0],"tabLeftActive"); 191 this.css.refreshClassNames(_33[1],"tabMiddleActive"); 192 this.css.refreshClassNames(_33[2],"tabRightActive"); 193 193 },setTabInactive:function(tab){ 194 194 if(!$(tab)){ 195 195 return; 196 196 } 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 _3 0=_2f.id.substring(this.tabId.length);205 if(!isNaN(_3 0)){206 return _30;207 } 208 } 209 _ 2f=_2f.parentNode;210 } 211 },onRemove:function(_3 1){212 Event.stop(_3 1);213 var _3 2=Event.element(_31);214 var _3 3=this.getTargetIndex(_32);215 var tab=this.tabs[_3 3];216 if( this.options.onRemove(tab)){197 var _35=$(tab).immediateDescendants(); 198 this.css.refreshClassNames(_35[0],"tabLeftInactive"); 199 this.css.refreshClassNames(_35[1],"tabMiddleInactive"); 200 this.css.refreshClassNames(_35[2],"tabRightInactive"); 201 },getTargetIndex:function(_36){ 202 while(_36){ 203 if(_36.id&&_36.id.indexOf(this.tabId,0)>=0){ 204 var _37=_36.id.substring(this.tabId.length); 205 if(!isNaN(_37)){ 206 return this.tabs.indexOf(_36); 207 } 208 } 209 _36=_36.parentNode; 210 } 211 },onRemove:function(_38){ 212 Event.stop(_38); 213 var _39=Event.element(_38); 214 var _3a=this.getTargetIndex(_39); 215 var tab=this.tabs[_3a]; 216 if(r=this.options.onRemove(tab)){ 217 217 this.remove(tab); 218 218 } 219 219 },remove:function(tab){ 220 220 if(tab){ 221 var _36=this.getTargetIndex(tab); 222 var _37=this.getNextTab(); 223 if(!_37){ 224 _37=this.getPreviousTab(); 225 } 221 var _3d=tab.parentNode; 222 var _3e=this.getTargetIndex(tab); 223 var _3f=this.getNextTab(); 224 if(!_3f){ 225 _3f=this.getPreviousTab(); 226 } 227 var _40=this.tabs[this.selected]; 226 228 Element.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){ 229 Element.remove(this.panelList[_3e]); 230 this.tabs[_3e]=null; 231 this.panelList[_3e]=null; 232 this.tabs=this.tabs.select(function(t){ 233 return t; 234 }); 235 this.panelList=this.panelList.select(function(t){ 236 return t; 237 }); 238 if(_3e==this.selected){ 239 if(_3f){ 240 this.selectTab(_3f); 241 } 242 }else{ 243 this.selected=this.getTargetIndex(_40); 244 } 245 this._setBrTag(); 246 } 247 },addByElement:function(_43){ 237 248 this.holder=[]; 238 249 this.ids=[]; 239 250 this.contents=[]; 240 var _39=this.buildTabSet($(_38),this.tabs.length); 241 this.tabContainer.appendChild(_39.tab.toElement()); 242 this.panelContainer.appendChild(_39.panel.toElement()); 251 var _44=0; 252 var _45=this.getLastTab(); 253 if(_45){ 254 _44=parseInt(_45.id.match(/[0-9]+$/)[0],10).succ(); 255 } 256 var _46=this.buildTabSet($(_43),_44,this.tabs.length); 257 var _47=_46.tab.toElements(); 258 this.tabContainer.appendChild(_47[0]); 259 if(_47[1]){ 260 this.tabContainer.appendChild(_47[1]); 261 } 262 this.panelContainer.appendChild(_46.panel.toElement()); 243 263 this.tabs[this.tabs.length-1]=$(this.tabs.last()); 244 264 this.panelList[this.panelList.length-1]=$(this.panelList.last()); … … 248 268 this.setDrag(); 249 269 } 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){ 271 var _4a=[]; 272 var _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); 278 this.addByElement(Builder.node("div",_4a)); 279 },lazyLoad:function(_4c){ 260 280 this.errorCount=0; 261 281 this.loadedList=[]; 262 this.load(_ 3e);263 },load:function(_ 3f){264 var _4 0=this.panelList[_3f];265 var url=this.options.lazyLoadUrl[_ 3f];266 var _ 42=this;267 if(_4 0&&url){268 new Ajax.Updater({success:_4 0},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);282 this.load(_4c); 283 },load:function(_4d){ 284 var _4e=this.panelList[_4d]; 285 var url=this.options.lazyLoadUrl[_4d]; 286 var _50=this; 287 if(_4e&&url){ 288 new Ajax.Updater({success:_4e},url,{onSuccess:function(){ 289 _50.setLoaded(_4d); 290 _50.options.onLazyLoad(_4e,_50); 291 _50.load(++_4d); 292 if(_50.isFinishLazyLoad()){ 293 _50.options.afterLazyLoad(_50); 274 294 } 275 295 },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); 298 if(_50.errorCount<=_50.options.failureLimit){ 299 _50.load(_4d); 300 }else{ 301 _50.options.failureLimitOver(_50); 282 302 } 283 303 },asynchronous:true,evalScripts:true}); … … 287 307 },setLoaded:function(i){ 288 308 this.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){ 310 var _53=Event.element(_52); 311 var _54=this.getTargetIndex(_53); 312 if(_54!=this.selected){ 313 var _55=this.tabs[_54]; 314 this.setTabActive(_55); 315 } 316 },onMouseOut:function(_56){ 317 var _57=Event.element(_56); 318 var _58=this.getTargetIndex(_57); 319 if(_58!=this.selected){ 320 var _59=this.tabs[_58]; 321 this.setTabInactive(_59); 302 322 } 303 323 },hasNextTab:function(){ … … 321 341 },getCurrentTab:function(){ 322 342 return 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(){ 344 return this.tabs.last(); 345 },_callBeforeSelect:function(_5c){ 346 var _5d=this._findCallback(this.options.beforeSelect,_5c); 347 return (_5d)?_5d():true; 348 },_callAfterSelect:function(_5e,_5f){ 349 var _60=this._findCallback(this.options.afterSelect,_5e); 350 if(_60){ 351 _60(_5e,_5f); 352 } 353 },_callAfterSelectOnce:function(_61){ 354 var _62=this._findCallback(this.options.afterSelectOnce,_61); 355 if(_62){ 356 _62(_61); 357 } 358 },_findCallback:function(_63,_64){ 359 if(!_63){ 360 return; 361 } 362 if(_63.constructor!=Function){ 363 if(_63.constructor==Array){ 364 _63=_63[this.panelList.indexOf(_64)]; 365 }else{ 366 _63=_63[this.panelList.indexOf(_64).succ()]; 367 } 368 } 369 return _63; 370 },_setBrTag:function(){ 371 if(this.options.tabRow){ 372 var _65=this.tabContainer; 373 var _66=[]; 374 var brs=[]; 375 Element.getTagNodes(_65).each(function(n){ 376 ((n.tagName.toLowerCase()=="div")?_66:brs).push(n); 377 }); 378 _66.each(function(t,i){ 379 if((i.succ()%this.options.tabRow)==0){ 380 if(brs[0]){ 381 _65.insertBefore(brs[0],t.nextSibling); 382 brs.shift(); 383 }else{ 384 _65.insertBefore(Builder.node("br",{style:"clear: both"}),t.nextSibling); 385 } 386 } 387 }.bind(this)); 388 (brs||[]).each(function(b){ 389 Element.remove(b); 390 }); 391 } 348 392 }}; 349 393 spinelz/trunk/src/javascripts/spinelz/tabBox.js
r5754 r5907 118 118 overlap: 'horizontal', 119 119 constraint: 'horizontal', 120 onChange: this.options.onSort, 120 onChange: function(tab) { 121 this.options.onSort(tab); 122 this._setBrTag(); 123 }.bind(this), 121 124 onUpdate: this.options.afterSort, 122 125 starteffect: Prototype.emptyFunction, … … 139 142 this.holder.each(function(set) { 140 143 $(this.tabTitleId + set.number).appendChild(set.tab); 141 this.panelList[set.number].appendChild(set.content);144 $(this.panelId + set.number).appendChild(set.content); 142 145 }.bind(this)); 143 146 }, 144 147 145 148 build: function() { 149 var style = (UserAgent.isIE7()) ? " style='height: 90%;'" : ""; 146 150 var tabContainer = 147 "<div id='" + this.tabContainerId + "' class='" + this.classNames['tabContainer'] + "' >";151 "<div id='" + this.tabContainerId + "' class='" + this.classNames['tabContainer'] + "'" + style + ">"; 148 152 var panelContainer = 149 153 "<div id='" + this.panelContainerId + "' class='" + this.classNames['panelContainer'] + "'>"; … … 165 169 }, 166 170 167 buildTabSet: function(element, i ) {171 buildTabSet: function(element, i, count) { 168 172 var nodes = Element.getChildNodesWithoutWhitespace(element); 169 173 this.holdElements(nodes[0], nodes[1], i); 170 174 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) 173 177 }; 174 178 }, 175 179 176 buildTab: function(tab, i, events) { 180 buildTab: function(tab, i, events, count) { 181 count = count || i; 177 182 var tabId = this.tabId + i; 178 183 var ids = {tab: tabId}; 179 184 this.ids.push(ids); 180 this.tabs[ i] = tabId;185 this.tabs[count] = tabId; 181 186 182 187 var button = ""; … … 188 193 189 194 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, '"'); 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); 195 201 this.setTabText(tab, this.chopTabText(tabText)); 196 202 … … 204 210 "</div>" + 205 211 "<div id='" + this.tabRightId + i + "' class='" + this.classNames['tabRightInactive'] + "'></div>" + 206 "</div>" ;212 "</div>" + br; 207 213 return html; 208 214 }, … … 217 223 218 224 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, '"'). 226 replace(/[\r\n\t\v]/g, '').replace(/(^(\s)*) | ((\s)*$)/g, ''); 227 227 }, 228 228 229 229 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; 237 240 var id = this.panelId + i; 238 this.panelList[ i] = id;241 this.panelList[count] = id; 239 242 return "<div id='" + id + "' style='display: none;'></div>"; 240 243 }, … … 274 277 this.setTabActive(targetTab); 275 278 276 if (currentPanel) Element. toggle(currentPanel);277 Element. toggle(targetPanel);279 if (currentPanel) Element.hide(currentPanel); 280 Element.show(targetPanel); 278 281 279 282 this.selected = targetIndex; … … 307 310 var index = element.id.substring(this.tabId.length); 308 311 if (!isNaN(index)) { 309 return index;312 return this.tabs.indexOf(element); 310 313 } 311 314 } … … 319 322 var index = this.getTargetIndex(element); 320 323 var tab = this.tabs[index]; 321 if ( this.options.onRemove(tab)) {324 if (r = this.options.onRemove(tab)) { 322 325 this.remove(tab); 323 326 } … … 326 329 remove: function(tab) { 327 330 if (tab) { 331 var parent = tab.parentNode; 328 332 var index = this.getTargetIndex(tab); 329 333 var nextActiveTab = this.getNextTab(); 330 334 if (!nextActiveTab) nextActiveTab = this.getPreviousTab(); 335 var selectedTab = this.tabs[this.selected]; 331 336 Element.remove(tab); 332 337 Element.remove(this.panelList[index]); 333 338 this.tabs[index] = null; 334 339 this.panelList[index] = null; 340 this.tabs = this.tabs.select(function(t) { return t; }); 341 this.panelList = this.panelList.select(function(t) { return t; }); 335 342 336 343 if (index == this.selected) { … … 338 345 this.selectTab(nextActiveTab); 339 346 } 347 } else { 348 this.selected = this.getTargetIndex(selectedTab); 340 349 } 350 this._setBrTag(); 341 351 } 342 352 }, … … <
