]>
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,innerDiv,tabContent\" class=\"dijitTabInner dijitTabContent\">\n\t<img src=\"${_blankGif}\" alt=\"\" class=\"dijitIcon dijitTabButtonIcon\" data-dojo-attach-point='iconNode'/>\n\t<span data-dojo-attach-point='containerNode,focusNode' class='tabLabel'></span>\n\t<span class=\"dijitInline dijitTabCloseButton dijitTabCloseIcon\" data-dojo-attach-point='closeNode'\n\t\t role=\"presentation\">\n\t\t<span data-dojo-attach-point='closeText' class='dijitTabCloseText'>[x]</span\n\t\t\t\t></span>\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
14 "dojo/text!./templates/_TabButton.html",
15 "dojo/i18n!../nls/common"
16 ], function(declare
, dom
, domAttr
, domClass
, i18n
, lang
, StackController
, registry
, Menu
, MenuItem
, template
){
19 // dijit/layout/TabController
21 var TabButton
= declare("dijit.layout._TabButton", StackController
.StackButton
, {
23 // A tab (the thing you click to select a pane).
25 // Contains the title of the pane, and optionally a close-button to destroy the pane.
26 // This is an internal widget and should not be instantiated directly.
31 // The CSS class applied to the domNode.
32 baseClass
: "dijitTab",
34 // Apply dijitTabCloseButtonHover when close button is hovered
36 closeNode
: "dijitTabCloseButton"
39 templateString
: template
,
41 // Override _FormWidget.scrollOnFocus.
42 // Don't scroll the whole tab container into view when the button is focused.
45 buildRendering: function(){
46 this.inherited(arguments
);
48 dom
.setSelectable(this.containerNode
, false);
52 this.inherited(arguments
);
55 // Required to give IE6 a kick, as it initially hides the
56 // tabs until they are focused on.
57 this.defer(function(){
58 n
.className
= n
.className
;
62 _setCloseButtonAttr: function(/*Boolean*/ disp
){
64 // Hide/show close button
65 this._set("closeButton", disp
);
66 domClass
.toggle(this.domNode
, "dijitClosable", disp
);
67 this.closeNode
.style
.display
= disp
? "" : "none";
69 var _nlsResources
= i18n
.getLocalization("dijit", "common");
71 domAttr
.set(this.closeNode
, "title", _nlsResources
.itemClose
);
76 _setDisabledAttr: function(/*Boolean*/ disabled
){
78 // Make tab selected/unselectable
80 this.inherited(arguments
);
82 // Don't show tooltip for close button when tab is disabled
85 domAttr
.remove(this.closeNode
, "title");
87 var _nlsResources
= i18n
.getLocalization("dijit", "common");
88 domAttr
.set(this.closeNode
, "title", _nlsResources
.itemClose
);
93 _setLabelAttr: function(/*String*/ content
){
95 // Hook for set('label', ...) to work.
97 // takes an HTML string.
98 // Inherited ToggleButton implementation will Set the label (text) of the button;
99 // Need to set the alt attribute of icon on tab buttons if no label displayed
100 this.inherited(arguments
);
101 if(!this.showLabel
&& !this.params
.title
){
102 this.iconNode
.alt
= lang
.trim(this.containerNode
.innerText
|| this.containerNode
.textContent
|| '');
107 var TabController
= declare("dijit.layout.TabController", StackController
, {
109 // Set of tabs (the things with titles and a close button, that you click to show a tab panel).
110 // Used internally by `dijit/layout/TabContainer`.
112 // Lets the user select the currently shown pane in a TabContainer or StackContainer.
113 // TabController also monitors the TabContainer, and whenever a pane is
114 // added or deleted updates itself accordingly.
118 baseClass
: "dijitTabController",
120 templateString
: "<div role='tablist' data-dojo-attach-event='onkeypress:onkeypress'></div>",
122 // tabPosition: String
123 // Defines where tabs go relative to the content.
124 // "top", "bottom", "left-h", "right-h"
127 // buttonWidget: Constructor
128 // The tab widget to create to correspond to each page
129 buttonWidget
: TabButton
,
131 // buttonWidgetCloseClass: String
132 // Class of [x] close icon, used by event delegation code to tell when close button was clicked
133 buttonWidgetCloseClass
: "dijitTabCloseButton",
135 postCreate: function(){
136 this.inherited(arguments
);
138 // Setup a close menu to be shared between all the closable tabs (excluding disabled tabs)
139 var closeMenu
= new Menu({
141 ownerDocument
: this.ownerDocument
,
144 textDir
: this.textDir
,
145 targetNodeIds
: [this.domNode
],
146 selector: function(node
){
147 return domClass
.contains(node
, "dijitClosable") && !domClass
.contains(node
, "dijitTabDisabled");
152 var _nlsResources
= i18n
.getLocalization("dijit", "common"),
154 closeMenu
.addChild(new MenuItem({
155 label
: _nlsResources
.itemClose
,
156 ownerDocument
: this.ownerDocument
,
159 textDir
: this.textDir
,
160 onClick: function(evt
){
161 var button
= registry
.byNode(this.getParent().currentTarget
);
162 controller
.onCloseButtonClick(button
.page
);
168 TabController
.TabButton
= TabButton
; // for monkey patching
170 return TabController
;