TabContainer.js 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. define("dijit/layout/TabContainer", [
  2. "dojo/_base/lang", // lang.getObject
  3. "dojo/_base/declare", // declare
  4. "./_TabContainerBase",
  5. "./TabController",
  6. "./ScrollingTabController"
  7. ], function(lang, declare, _TabContainerBase, TabController, ScrollingTabController){
  8. /*=====
  9. var _TabContainerBase = dijit.layout._TabContainerBase;
  10. var TabController = dijit.layout.TabController;
  11. var ScrollingTabController = dijit.layout.ScrollingTabController;
  12. =====*/
  13. // module:
  14. // dijit/layout/TabContainer
  15. // summary:
  16. // A Container with tabs to select each child (only one of which is displayed at a time).
  17. return declare("dijit.layout.TabContainer", _TabContainerBase, {
  18. // summary:
  19. // A Container with tabs to select each child (only one of which is displayed at a time).
  20. // description:
  21. // A TabContainer is a container that has multiple panes, but shows only
  22. // one pane at a time. There are a set of tabs corresponding to each pane,
  23. // where each tab has the name (aka title) of the pane, and optionally a close button.
  24. // useMenu: [const] Boolean
  25. // True if a menu should be used to select tabs when they are too
  26. // wide to fit the TabContainer, false otherwise.
  27. useMenu: true,
  28. // useSlider: [const] Boolean
  29. // True if a slider should be used to select tabs when they are too
  30. // wide to fit the TabContainer, false otherwise.
  31. useSlider: true,
  32. // controllerWidget: String
  33. // An optional parameter to override the widget used to display the tab labels
  34. controllerWidget: "",
  35. _makeController: function(/*DomNode*/ srcNode){
  36. // summary:
  37. // Instantiate tablist controller widget and return reference to it.
  38. // Callback from _TabContainerBase.postCreate().
  39. // tags:
  40. // protected extension
  41. var cls = this.baseClass + "-tabs" + (this.doLayout ? "" : " dijitTabNoLayout"),
  42. TabController = lang.getObject(this.controllerWidget);
  43. return new TabController({
  44. id: this.id + "_tablist",
  45. dir: this.dir,
  46. lang: this.lang,
  47. textDir: this.textDir,
  48. tabPosition: this.tabPosition,
  49. doLayout: this.doLayout,
  50. containerId: this.id,
  51. "class": cls,
  52. nested: this.nested,
  53. useMenu: this.useMenu,
  54. useSlider: this.useSlider,
  55. tabStripClass: this.tabStrip ? this.baseClass + (this.tabStrip ? "":"No") + "Strip": null
  56. }, srcNode);
  57. },
  58. postMixInProperties: function(){
  59. this.inherited(arguments);
  60. // Scrolling controller only works for horizontal non-nested tabs
  61. if(!this.controllerWidget){
  62. this.controllerWidget = (this.tabPosition == "top" || this.tabPosition == "bottom") && !this.nested ?
  63. "dijit.layout.ScrollingTabController" : "dijit.layout.TabController";
  64. }
  65. }
  66. });
  67. });