]>
git.wh0rd.org - tt-rss.git/blob - lib/dijit/layout/TabController.js.uncompressed.js
2 'url:dijit/layout/templates/_TabButton.html':"<div role=\"presentation\" data-dojo-attach-point=\"titleNode\" data-dojo-attach-event='onclick:onClick'>\n <div role=\"presentation\" class='dijitTabInnerDiv' data-dojo-attach-point='innerDiv'>\n <div role=\"presentation\" class='dijitTabContent' data-dojo-attach-point='tabContent'>\n \t<div role=\"presentation\" data-dojo-attach-point='focusNode'>\n\t\t <img src=\"${_blankGif}\" alt=\"\" class=\"dijitIcon dijitTabButtonIcon\" data-dojo-attach-point='iconNode' />\n\t\t <span data-dojo-attach-point='containerNode' class='tabLabel'></span>\n\t\t <span class=\"dijitInline dijitTabCloseButton dijitTabCloseIcon\" data-dojo-attach-point='closeNode'\n\t\t \t\tdata-dojo-attach-event='onclick: onClickCloseButton' role=\"presentation\">\n\t\t <span data-dojo-attach-point='closeText' class='dijitTabCloseText'>[x]</span\n\t\t ></span>\n\t\t\t</div>\n </div>\n </div>\n</div>\n"}});
3 define("dijit/layout/TabController", [
4 "dojo/_base/declare", // declare
5 "dojo/dom", // dom.setSelectable
6 "dojo/dom-attr", // domAttr.attr
7 "dojo/dom-class", // domClass.toggle
8 "dojo/i18n", // i18n.getLocalization
9 "dojo/_base/lang", // lang.hitch lang.trim
13 "dojo/text!./templates/_TabButton.html",
14 "dojo/i18n!../nls/common"
15 ], function(declare
, dom
, domAttr
, domClass
, i18n
, lang
, StackController
, Menu
, MenuItem
, template
){
18 var StackController = dijit.layout.StackController;
19 var Menu = dijit.Menu;
20 var MenuItem = dijit.MenuItem;
24 // dijit/layout/TabController
26 // Set of tabs (the things with titles and a close button, that you click to show a tab panel).
27 // Used internally by `dijit.layout.TabContainer`.
29 var TabButton
= declare("dijit.layout._TabButton", StackController
.StackButton
, {
31 // A tab (the thing you click to select a pane).
33 // Contains the title of the pane, and optionally a close-button to destroy the pane.
34 // This is an internal widget and should not be instantiated directly.
39 // The CSS class applied to the domNode.
40 baseClass
: "dijitTab",
42 // Apply dijitTabCloseButtonHover when close button is hovered
44 closeNode
: "dijitTabCloseButton"
47 templateString
: template
,
49 // Override _FormWidget.scrollOnFocus.
50 // Don't scroll the whole tab container into view when the button is focused.
53 buildRendering: function(){
54 this.inherited(arguments
);
56 dom
.setSelectable(this.containerNode
, false);
60 this.inherited(arguments
);
63 // Required to give IE6 a kick, as it initially hides the
64 // tabs until they are focused on.
65 setTimeout(function(){
66 n
.className
= n
.className
;
70 _setCloseButtonAttr: function(/*Boolean*/ disp
){
72 // Hide/show close button
73 this._set("closeButton", disp
);
74 domClass
.toggle(this.innerDiv
, "dijitClosable", disp
);
75 this.closeNode
.style
.display
= disp
? "" : "none";
77 var _nlsResources
= i18n
.getLocalization("dijit", "common");
79 domAttr
.set(this.closeNode
,"title", _nlsResources
.itemClose
);
81 // add context menu onto title button
82 this._closeMenu
= new Menu({
86 textDir
: this.textDir
,
87 targetNodeIds
: [this.domNode
]
90 this._closeMenu
.addChild(new MenuItem({
91 label
: _nlsResources
.itemClose
,
94 textDir
: this.textDir
,
95 onClick
: lang
.hitch(this, "onClickCloseButton")
99 this._closeMenu
.destroyRecursive();
100 delete this._closeMenu
;
104 _setLabelAttr: function(/*String*/ content
){
106 // Hook for set('label', ...) to work.
108 // takes an HTML string.
109 // Inherited ToggleButton implementation will Set the label (text) of the button;
110 // Need to set the alt attribute of icon on tab buttons if no label displayed
111 this.inherited(arguments
);
112 if(!this.showLabel
&& !this.params
.title
){
113 this.iconNode
.alt
= lang
.trim(this.containerNode
.innerText
|| this.containerNode
.textContent
|| '');
119 this._closeMenu
.destroyRecursive();
120 delete this._closeMenu
;
122 this.inherited(arguments
);
126 var TabController
= declare("dijit.layout.TabController", StackController
, {
128 // Set of tabs (the things with titles and a close button, that you click to show a tab panel).
129 // Used internally by `dijit.layout.TabContainer`.
131 // Lets the user select the currently shown pane in a TabContainer or StackContainer.
132 // TabController also monitors the TabContainer, and whenever a pane is
133 // added or deleted updates itself accordingly.
137 baseClass
: "dijitTabController",
139 templateString
: "<div role='tablist' data-dojo-attach-event='onkeypress:onkeypress'></div>",
141 // tabPosition: String
142 // Defines where tabs go relative to the content.
143 // "top", "bottom", "left-h", "right-h"
146 // buttonWidget: Constructor
147 // The tab widget to create to correspond to each page
148 buttonWidget
: TabButton
,
150 _rectifyRtlTabList: function(){
152 // For left/right TabContainer when page is RTL mode, rectify the width of all tabs to be equal, otherwise the tab widths are different in IE
154 if(0 >= this.tabPosition
.indexOf('-h')){ return; }
155 if(!this.pane2button
){ return; }
158 for(var pane
in this.pane2button
){
159 var ow
= this.pane2button
[pane
].innerDiv
.scrollWidth
;
160 maxWidth
= Math
.max(maxWidth
, ow
);
162 //unify the length of all the tabs
163 for(pane
in this.pane2button
){
164 this.pane2button
[pane
].innerDiv
.style
.width
= maxWidth
+ 'px';
169 TabController
.TabButton
= TabButton
; // for monkey patching
171 return TabController
;