root / trunk / web / dojo / dijit / layout / TabController.js
History | View | Annotate | Download (3.57 KB)
| 1 | 9 | andrej.cim | /*
 | 
      
|---|---|---|---|
| 2 |         Copyright (c) 2004-2010, The Dojo Foundation All Rights Reserved.
 | 
      ||
| 3 |         Available via Academic Free License >= 2.1 OR the modified BSD license.
 | 
      ||
| 4 |         see: http://dojotoolkit.org/license for details
 | 
      ||
| 5 | */
 | 
      ||
| 6 | |||
| 7 | |||
| 8 | if(!dojo._hasResource["dijit.layout.TabController"]){  | 
      ||
| 9 | dojo._hasResource["dijit.layout.TabController"]=true;  | 
      ||
| 10 | dojo.provide("dijit.layout.TabController");
 | 
      ||
| 11 | dojo.require("dijit.layout.StackController");
 | 
      ||
| 12 | dojo.require("dijit.Menu");
 | 
      ||
| 13 | dojo.require("dijit.MenuItem");
 | 
      ||
| 14 | dojo.requireLocalization("dijit","common",null,"ROOT,ar,ca,cs,da,de,el,es,fi,fr,he,hu,it,ja,ko,nb,nl,pl,pt,pt-pt,ro,ru,sk,sl,sv,th,tr,zh,zh-tw");  | 
      ||
| 15 | dojo.declare("dijit.layout.TabController",dijit.layout.StackController,{templateString:"<div wairole='tablist' dojoAttachEvent='onkeypress:onkeypress'></div>",tabPosition:"top",buttonWidget:"dijit.layout._TabButton",_rectifyRtlTabList:function(){  | 
      ||
| 16 | if(0>=this.tabPosition.indexOf("-h")){  | 
      ||
| 17 | return;
 | 
      ||
| 18 | }  | 
      ||
| 19 | if(!this.pane2button){  | 
      ||
| 20 | return;
 | 
      ||
| 21 | }  | 
      ||
| 22 | var _1=0;  | 
      ||
| 23 | for(var _2 in this.pane2button){  | 
      ||
| 24 | var ow=this.pane2button[_2].innerDiv.scrollWidth;  | 
      ||
| 25 | _1=Math.max(_1,ow);  | 
      ||
| 26 | }  | 
      ||
| 27 | for(_2 in this.pane2button){  | 
      ||
| 28 | this.pane2button[_2].innerDiv.style.width=_1+"px";  | 
      ||
| 29 | }  | 
      ||
| 30 | }});  | 
      ||
| 31 | dojo.declare("dijit.layout._TabButton",dijit.layout._StackButton,{baseClass:"dijitTab",cssStateNodes:{closeNode:"dijitTabCloseButton"},templateString:dojo.cache("dijit.layout","templates/_TabButton.html","<div waiRole=\"presentation\" dojoAttachPoint=\"titleNode\" dojoAttachEvent='onclick:onClick'>\n <div waiRole=\"presentation\" class='dijitTabInnerDiv' dojoAttachPoint='innerDiv'>\n <div waiRole=\"presentation\" class='dijitTabContent' dojoAttachPoint='tabContent'>\n \t<div waiRole=\"presentation\" dojoAttachPoint='focusNode'>\n\t\t <img src=\"${_blankGif}\" alt=\"\" class=\"dijitIcon\" dojoAttachPoint='iconNode' />\n\t\t <span dojoAttachPoint='containerNode' class='tabLabel'></span>\n\t\t <span class=\"dijitInline dijitTabCloseButton dijitTabCloseIcon\" dojoAttachPoint='closeNode'\n\t\t \t\tdojoAttachEvent='onclick: onClickCloseButton' waiRole=\"presentation\">\n\t\t <span dojoAttachPoint='closeText' class='dijitTabCloseText'>x</span\n\t\t ></span>\n\t\t\t</div>\n </div>\n </div>\n</div>\n"),scrollOnFocus:false,postMixInProperties:function(){  | 
      ||
| 32 | if(!this.iconClass){  | 
      ||
| 33 | this.iconClass="dijitTabButtonIcon";  | 
      ||
| 34 | }  | 
      ||
| 35 | },postCreate:function(){  | 
      ||
| 36 | this.inherited(arguments);  | 
      ||
| 37 | dojo.setSelectable(this.containerNode,false);  | 
      ||
| 38 | if(this.iconNode.className=="dijitTabButtonIcon"){  | 
      ||
| 39 | dojo.style(this.iconNode,"width","1px");  | 
      ||
| 40 | }  | 
      ||
| 41 | },startup:function(){  | 
      ||
| 42 | this.inherited(arguments);  | 
      ||
| 43 | var n=this.domNode;  | 
      ||
| 44 | setTimeout(function(){
 | 
      ||
| 45 | n.className=n.className;  | 
      ||
| 46 | },1);
 | 
      ||
| 47 | },_setCloseButtonAttr:function(_3){  | 
      ||
| 48 | this.closeButton=_3;
 | 
      ||
| 49 | dojo.toggleClass(this.innerDiv,"dijitClosable",_3);  | 
      ||
| 50 | this.closeNode.style.display=_3?"":"none";  | 
      ||
| 51 | if(_3){
 | 
      ||
| 52 | var _4=dojo.i18n.getLocalization("dijit","common");  | 
      ||
| 53 | if(this.closeNode){  | 
      ||
| 54 | dojo.attr(this.closeNode,"title",_4.itemClose);  | 
      ||
| 55 | }  | 
      ||
| 56 | var _4=dojo.i18n.getLocalization("dijit","common");  | 
      ||
| 57 | this._closeMenu=new dijit.Menu({id:this.id+"_Menu",dir:this.dir,lang:this.lang,targetNodeIds:[this.domNode]});  | 
      ||
| 58 | this._closeMenu.addChild(new dijit.MenuItem({label:_4.itemClose,dir:this.dir,lang:this.lang,onClick:dojo.hitch(this,"onClickCloseButton")}));  | 
      ||
| 59 | }else{
 | 
      ||
| 60 | if(this._closeMenu){  | 
      ||
| 61 | this._closeMenu.destroyRecursive();
 | 
      ||
| 62 | delete this._closeMenu;  | 
      ||
| 63 | }  | 
      ||
| 64 | }  | 
      ||
| 65 | },_setLabelAttr:function(_5){  | 
      ||
| 66 | this.inherited(arguments);  | 
      ||
| 67 | if(this.showLabel==false&&!this.params.title){  | 
      ||
| 68 | this.iconNode.alt=dojo.trim(this.containerNode.innerText||this.containerNode.textContent||"");  | 
      ||
| 69 | }  | 
      ||
| 70 | },destroy:function(){  | 
      ||
| 71 | if(this._closeMenu){  | 
      ||
| 72 | this._closeMenu.destroyRecursive();
 | 
      ||
| 73 | delete this._closeMenu;  | 
      ||
| 74 | }  | 
      ||
| 75 | this.inherited(arguments);  | 
      ||
| 76 | }});  | 
      ||
| 77 | }  |