Class: ojTabs

Oracle® JavaScript Extension Toolkit (JET)
1.2.0

E65435-01

QuickNav

Options


Sub-ID's

oj. ojTabs extends oj.baseComponent

Version:
  • 1.2.0
Since:
  • 0.6

JET Tabs Component

Description: Themeable, WAI-ARIA-compliant tabs with mouse and keyboard interactions for navigation.

A JET Tabs can be created from a div element as long as the root element has a tab bar in a ul with individual tabs in li preceding the content divs. Each li will be matched by position with its content in the html DOM.


<div id="tabs">
  <ul>
    <li><span>Tab 1</span></li>
    <li><span>Tab 2</span></li>
    <li><span>Tab 3</span></li>
  </ul>
  <div id="tab1">
    <p>Tab 1 content</p>
    <p>Tab 1 more content</p>
  </div>
  <div id="tab2">
    <p>Tab 2 content</p>
  </div>
  <div id="tab3">
    <p>Tab 3 content</p>
  </div>
</div>

Touch End User Information

Target Gesture Action
Tab Tap Select
Tab Close Icon Tap Delete
Tab Press and pan left/right and release Reorder

Keyboard End User Information

Target Key Action
Tab Tab Only the selected tab is in the tab order.
Tab UpArrow or LeftArrow (RightArrow in RTL) Move focus to the previous tab and select it.
Tab DownArrow or RightArrow (LeftArrow in RTL) Move focus to the next tab and select it.
Tab Home Move focus to the first tabs item.
Tab End Move focus to the last tabs item.
Tab Delete If deletion is allowed, will delete the current tab.
Tab content Shift+Tab move focus to the tab for that tab panel.

Styling

Class(es) Description
oj-tabs-icon-only Applied to an ojtabs if the tab headers contain only icons.
oj-tabs-text-icon
Applied to an ojtabs if the tab headers contain both icons and text.

Performance

Lazy Rendering

If an ojTabs has complex content in a tab, it is recommended to implement lazy rendering of tab content. The application should keep track of which tab contents have been rendered. The initial selected tab should render its content from the start. The application should then listen to the ojbeforeselect event from the ojTabs to control when to render the content.

Reading direction

As with any JET component, in the unusual case that the directionality (LTR or RTL) changes post-init, the tabs must be refresh()ed.

Pseudo-selectors

The :oj-tabs pseudo-selector can be used in jQuery expressions to select JET Tabs. For example:

$( ":oj-tabs" ) // selects all JET Tabs on the page
$myEventTarget.closest( ":oj-tabs" ) // selects the closest ancestor that is a JET Tabs

JET for jQuery UI developers

    • JQUI Tabs expects the tabs titles either in an ordered or unordered list followed by their content elements. Each tab must have an anchor with the href points to its content element.
          
            <div id="tabs">
              <ul>
                <li><a href="#tabs-1">Tab 1 Title</a></li>
                <li><a href="#tabs-2">Tab 2 Title</a></li>
              </ul>
              <div id="tabs-1">
                <p>Tab 1 content.</p>
              </div>
              <div id="tabs-2">
                <p>Tab 2 content.</p>
                <p>More Tab 2 content.</p>
              </div
            </div>
          
    • JET Tabs requires a DOM structures like the JQuery Tabs, except the tab header and their content are matched by position. It requires no anchors and pointers to the contents.
          
            <div id="tabs">
               <ul>
                 <li><span>Tab 1</span></li>
                 <li><span>Tab 2</span></li>
               </ul>
               <div id="tab1">
                 <p>Tab 1 content</p>
               </div>
               <div id="tab2">
                 <p>Tab 2 content</p>
               </div>
            </div>
          
  1. JET Tabs supports edge option: to be placed the tab bar at top(default), bottom, start or end
  2. JET Tabs supports removable option by adding a close icon to each tab header which when clicked remove the tab from the DOM.
  3. JET Tabs supports reorderable option allow the tab to be reordered by drag and drop within the Tab bar

Also, event names for all JET components are prefixed with "oj", instead of component-specific prefixes like "tabs".

Initializer

.ojTabs()

Creates a JET Tabs.
Source:
Examples

Initialize the tabs with no options specified:

$( ".selector" ).ojTabs();

Initialize the tabs with some options specified:

$( ".selector" ).ojTabs( { "edge": "start" } );

Initialize the tabs via the JET ojComponent binding:

<div id="tabs" data-bind="ojComponent: { component: 'ojTabs', edge: 'end'}">

Options

contextMenu :string|null

Identifies the JET Menu that the component should launch as a context menu on right-click or Shift-F10. If specified, the browser's native context menu will be replaced by the specified JET Menu.

To specify a JET context menu on a DOM element that is not a JET component, see the ojContextMenu binding.

To make the page semantically accurate from the outset, applications are encouraged to specify the context menu via the standard HTML5 syntax shown in the below example. When the component is initialized, the context menu thus specified will be set on the component.

When defining a contextMenu, ojTabs will provide built-in behavior for "cut" and "paste" if the following format for menu <li> item's is used (no <a> elements are required):

  • <li data-oj-command="oj-tabs-cut" />
  • <li data-oj-command="oj-tabs-paste-before" />
  • <li data-oj-command="oj-tabs-paste-after" />
  • <li data-oj-command="oj-tabs-remove" />
The available translated text will be applied to menu items defined this way.

The JET Menu should be initialized before any component using it as a context menu.

Default Value:
  • null
Source:
Examples

Initialize a JET Tabs with a context menu:

// via recommended HTML5 syntax:
<div id="myTabs" contextmenu="myMenu" data-bind="ojComponent: { ... }>

// via JET initializer (less preferred) :
$( ".selector" ).ojTabs({ "contextMenu": "#myContextMenu"  ... } });

Get or set the contextMenu option for an ojTabs after initialization:

// getter
var menu = $( ".selector" ).ojTabs( "option", "contextMenu" );

// setter
$( ".selector" ).ojTabs( "option", "contextMenu", "#myContextMenu" );

disabledTabs :Array

Array contains either ids or zero-based indices of the tabs that should be disabled.

Setter value: array of either ids or indices.

Getter value: array of either ids or indices. If a disabled tab has a page author provided id, that id is returned, otherwise that tab's index will be returned.

Default Value:
  • false
Source:
Examples
 [ 0, "myTabDiv" ] would disable the first tab and the tab with id="myTabDiv"

Initialize the tabs with the disabledTabs option specified:

$( ".selector" ).ojTabs( { "disabledTabs": [0, "myTabDiv"] } );

edge :string

The position of the tab bar. Valid Values: top, bottom, start and end.
Default Value:
  • top
Source:
Example

Get or set the edge option for an ojTabs after initialization:

// getter
var edge = $( ".selector" ).ojTabs( "option", "edge" );

// setter
$( ".selector" ).ojTabs( "option", "edge", "end" );

orientation :string

The orientation of the tab bar. Valid Values: horizontal and vertical
Default Value:
  • "horizontal"
Deprecated:
  • Use the edge option instead. If the tabs is initialized without an edge specified, the orientation value is used to convert to an equivalent edge: horizontal to top and vertical to start.
    Source:
    Example

    Get or set the orientation option for an ojTabs after initialization:

    // getter
    var orientation = $( ".selector" ).ojTabs( "option", "orientation" );
    
    // setter
    $( ".selector" ).ojTabs( "option", "orientation", "vertical" );

    removable :boolean

    Specifies if the tabs can be closed (removed)
    Default Value:
    • false
    Source:
    Example

    Get or set the removable option for an ojTabs after initialization:

    // getter
    var removable = $( ".selector" ).ojTabs( "option", "removable" );
    
    // setter
    $( ".selector" ).ojTabs( "option", "removable", true );

    reorderable :boolean

    Specifies if the tabs can be reordered within the tab bar by drag-and-drop
    Default Value:
    • false
    Source:
    Example

    Get or set the reorderable option for an ojTabs after initialization:

    // getter
    var reorderable = $( ".selector" ).ojTabs( "option", "reorderable" );
    
    // setter
    $( ".selector" ).ojTabs( "option", "reorderable", true );

    rootAttributes :Object

    Attributes specified here will be set on the component's root DOM element at creation time. This is particularly useful for components like Dialog that wrap themselves in a new root element at creation time.

    The supported attributes are id, which overwrites any existing value, and class and style, which are appended to the current class and style, if any.

    Setting this option after component creation has no effect. At that time, the root element already exists, and can be accessed directly via the widget method, per the second example below.

    Default Value:
    • null
    Inherited From:
    Source:
    Examples

    Initialize a JET component, specifying a set of attributes to be set on the component's root DOM element:

    // Foo is the component, e.g., Menu, Button, InputText, InputNumber, Select, etc.
    $( ".selector" ).ojFoo({ "rootAttributes": {
      "id": "myId",
      "style": "max-width:100%; color:blue;",
      "class": "my-class"
    }});

    After initialization, rootAttributes should not be used. It is not needed at that time, as attributes of the root DOM element can simply be set directly, using widget:

    // Foo is the component, e.g., Menu, Button, InputText, InputNumber, Select, etc.
    $( ".selector" ).ojFoo( "widget" ).css( "height", "100px" );
    $( ".selector" ).ojFoo( "widget" ).addClass( "my-class" );

    selected :number|string

    The id or zero-based index of the tab that is selected.

    Setter value: either an id or index.

    Getter value: id or index. If the selected tab has a page author provided id, that id is returned, otherwise that tab's index will be returned.

    Default Value:
    • 0
    Source:
    Examples

    Initialize the tabs with the selected option specified:

    $( ".selector" ).ojTabs( { "selected": "myTabDiv" } );

    Get or set the selected option after initialization:

    // getter
    var selected = $( ".selector" ).ojTabs( "option", "selected" );
    
    // setter
    $( ".selector" ).ojTabs( "option", "selected", "myTabDiv" );

    selectOn :string

    The type of event to select the tab. To select a tab on hover, use "mouseover".
    Default Value:
    • "click"
    Source:
    Example

    Get or set the selectOn option for an ojTabs after initialization:

    // getter
    var selectOn = $( ".selector" ).ojTabs( "option", "selectOn" );
    
    // setter
    $( ".selector" ).ojTabs( "option", "selectOn", "mouseover" );

    translations :Object

    A collection of translated resources from the translation bundle, or null if this component has no resources. Resources may be accessed and overridden individually or collectively, as seen in the examples.

    If this component has (or inherits) translations, their documentation immediately follows this doc entry.

    Default Value:
    • an object containing all resources relevant to the component and all its superclasses, or null if none
    Inherited From:
    Source:
    Examples

    Initialize the component, overriding some translated resources. This syntax leaves the other translations intact at create time, but not if called after create time:

    // Foo is InputDate, InputNumber, etc.
    $( ".selector" ).ojFoo({ "translations": { someKey: "someValue",
                                               someOtherKey: "someOtherValue" } });

    Get or set the translations option, after initialization:

    // Get one.  (Foo is InputDate, InputNumber, etc.)
    var value = $( ".selector" ).ojFoo( "option", "translations.someResourceKey" );
    
    // Get all.  (Foo is InputDate, InputNumber, etc.)
    var values = $( ".selector" ).ojFoo( "option", "translations" );
    
    // Set one, leaving the others intact.  (Foo is InputDate, InputNumber, etc.)
    $( ".selector" ).ojFoo( "option", "translations.someResourceKey", "someValue" );
    
    // Set many.  Any existing resource keys not listed are lost.  (Foo is InputDate, InputNumber, etc.)
    $( ".selector" ).ojFoo( "option", "translations", { someKey: "someValue",
                                                        someOtherKey: "someOtherValue" } );

    translations.labelCut :string

    Context menu text used for cutting a tab.

    See the translations option for usage examples.

    Default Value:
    • "Cut"
    Source:

    translations.labelPasteAfter :string

    Context menu text used for pasting a tab after another tab.

    See the translations option for usage examples.

    Default Value:
    • "Paste After"
    Source:

    translations.labelPasteBefore :string

    Context menu text used for pasting a tab before another tab.

    See the translations option for usage examples.

    Default Value:
    • "Paste Before"
    Source:

    translations.labelRemove :string

    Context menu text used for remove a tab

    See the translations option for usage examples.

    Default Value:
    • "Remove"
    Source:

    translations.labelReorder :string

    If application doesn't supply a context menu for the tabs that is reorderable, this is used as the default aria-label for the root element of the context menu.

    See the translations option for usage examples.

    Default Value:
    • "Reorder"
    Source:

    truncation :string

    Truncation option applies to the tab titles when there is not enough room to display all tabs. Valid Values: none, progressive and auto.
    • none - tabs always take up the space needed by the title texts. When there is not enough room, the conveyorBelt's navigation arrows are displayed to allow the title texts be scrolled within the conveyor.
    • progressive - If not enough space is available to display all of the tabs, then the width of each tab title is restricted just enough to allow all tabs to fit. All tab titles that are truncated are displayed with ellipses. However the width of each tab title will not be truncated below tabLabelMinWidth. If after all truncation has been applied, there still is not enough room, then the conveyorBelt's navigation arrows will appear. When the container of the tabs is resized the truncation will be reevaluated.
    • auto - same as "progressive".
    Default Value:
    • auto
    Source:
    Example

    Get or set the truncation option for an ojTabs after initialization:

    // getter
    var truncation = $( ".selector" ).ojTabs( "option", "truncation" );
    
    // setter
    $( ".selector" ).ojTabs( "option", "truncation", "none" );

    Sub-ID's

    Each subId locator object contains, at minimum, a subId property, whose value is a string that identifies a particular DOM node in this component. It can have additional properties to further specify the desired node. See getNodeBySubId and getSubIdByNode methods for more details.

    Properties:
    Name Type Description
    subId string Sub-id string to identify a particular dom node.

    Following are the valid subIds:

    oj-conveyorbelt

    Sub-ID for the conveyor belt used for horizontal overflow.

    Source:
    Example

    Get the conveyor belt:

    var node = $( ".selector" ).ojTabs( "getNodeBySubId", {'subId': 'oj-conveyorbelt'} );

    oj-tabs-close

    Sub-ID for the close icon of the specified tab, if present.

    Properties:
    Name Type Description
    index number The zero-based index of the tab.
    Source:
    Example

    Get the close icon of the second tab:

    var node = $( ".selector" ).ojTabs( "getNodeBySubId", {'subId': 'oj-tabs-close', 'index': 1} );

    oj-tabs-close-icon

    Sub-ID for the close icon of the specified tab, if present.

    Properties:
    Name Type Description
    index number The zero-based index of the tab.
    Deprecated:
    • this sub-ID is deprecated, please use oj-tabs-close instead.
      Source:
      Example

      Get the close icon of the second tab:

      var node = $( ".selector" ).ojTabs( "getNodeBySubId", {'subId': 'oj-tabs-close-icon', 'index': 1} );

      oj-tabs-panel

      Sub-ID for the content corresponding to the specified tab.

      Properties:
      Name Type Description
      index number The zero-based index of the tab.
      Deprecated:
      • This sub-ID is not needed. Since the application supplies this element, it can supply a unique ID by which the element can be accessed.
        Source:
        Example

        Get the content corresponding to the second tab:

        var node = $( ".selector" ).ojTabs( "getNodeBySubId", {'subId': 'oj-tabs-panel', 'index': 1} );

        oj-tabs-tab

        Sub-ID for the specified tab.

        Properties:
        Name Type Description
        index number The zero-based index of the tab.
        Deprecated:
        • This sub-ID is not needed. Since the application supplies this element, it can supply a unique ID by which the element can be accessed.
          Source:
          Example

          Get the second tab:

          var node = $( ".selector" ).ojTabs( "getNodeBySubId", {'subId': 'oj-tabs-tab', 'index': 1} );

          oj-tabs-title

          Sub-ID for the title of the specified tab.

          Properties:
          Name Type Description
          index number The zero-based index of the tab.
          Deprecated:
          • This sub-ID is not needed. Since the application supplies this element, it can supply a unique ID by which the element can be accessed.
            Source:
            Example

            Get the title of the second tab:

            var node = $( ".selector" ).ojTabs( "getNodeBySubId", {'subId': 'oj-tabs-title', 'index': 1} );

            Events

            #beforeDeselect

            Triggered immediately before a tab is deselected.

            beforeDeselect can be canceled to prevent the content from deselecting by returning a false in the event listener.

            Properties:
            Name Type Description
            event Event jQuery event object
            ui Object Parameters
            Properties
            Name Type Description
            fromTab jQuery The tab being navigated from
            fromContent jQuery The content being navigated from
            toTab jQuery The tab being navigated to
            toContent jQuery The content being navigated to
            Source:
            Examples

            Initialize the tabs with the beforeDeselect callback specified:

            $( ".deselector" ).ojTabs({
                "beforeDeselect": function( event, ui ) {}
            });

            Bind an event listener to the ojbeforedeselect event:

            $( ".deselector" ).on( "ojbeforedeselect", function( event, ui ) {} );

            #beforeRemove

            Triggered immediately before a tab is removed. beforeRemove can be canceled to prevent the content from removeing by returning a false in the event listener.
            Properties:
            Name Type Description
            event Event jQuery event object
            ui Object Parameters
            Properties
            Name Type Description
            tab jQuery The tab that is about to be removed.
            content jQuery The content that is about to be removed.
            Source:
            Examples

            Initialize the tabs with the beforeRemove callback specified:

            $( ".selector" ).ojTabs({
                "beforeRemove": function( event, ui ) {}
            });

            Bind an event listener to the ojbeforeremove event:

            $( ".selector" ).on( "ojbeforeremove", function( event, ui ) {} );

            #beforeReorder

            Triggered immediately before a tab is reordered. beforeReorder can be canceled to prevent the content from reordering by returning a false in the event listener.
            Properties:
            Name Type Description
            event Event jQuery event object
            ui Object Parameters
            Properties
            Name Type Description
            tab jQuery The tab that is about to be reordered.
            content jQuery The content that is about to be reordered.
            Source:
            Examples

            Initialize the tabs with the beforeReorder callback specified:

            $( ".selector" ).ojTabs({
                "beforeReorder": function( event, ui ) {}
            });

            Bind an event listener to the ojbeforereorder event:

            $( ".selector" ).on( "ojbeforereorder", function( event, ui ) {} );

            #beforeSelect

            Triggered immediately before a tab is selected.

            beforeSelect can be canceled to prevent the content from selecting by returning a false in the event listener.

            Properties:
            Name Type Description
            event Event jQuery event object
            ui Object Parameters
            Properties
            Name Type Description
            fromTab jQuery The tab being navigated from
            fromContent jQuery The content being navigated from
            toTab jQuery The tab being navigated to
            toContent jQuery The content being navigated to
            Source:
            Examples

            Initialize the tabs with the beforeSelect callback specified:

            $( ".selector" ).ojTabs({
                "beforeSelect": function( event, ui ) {}
            });

            Bind an event listener to the ojbeforeselect event:

            $( ".selector" ).on( "ojbeforeselect", function( event, ui ) {} );

            #deselect

            Triggered after a tab has been deselected.
            Properties:
            Name Type Description
            event Event jQuery event object
            ui Object Parameters
            Properties
            Name Type Description
            fromTab jQuery The tab being navigated from
            fromContent jQuery The content being navigated from
            toTab jQuery The tab being navigated to
            toContent jQuery The content being navigated to
            Source:
            Examples

            Initialize the tabs with the deselect callback specified:

            $( ".deselector" ).ojTabs({
                "deselect": function( event, ui ) {}
            });

            Bind an event listener to the ojdeselect event:

            $( ".deselector" ).on( "ojdeselect", function( event, ui ) {} );

            destroy

            Triggered before the component is destroyed. This event cannot be canceled; the component will always be destroyed regardless.

            Inherited From:
            Source:
            Examples

            Initialize component with the destroy callback

            // Foo is Button, InputText, etc.
            $(".selector").ojFoo({
              'destroy': function (event, data) {}
            });

            Bind an event listener to the destroy event

            $(".selector").on({
              'ojdestroy': function (event, data) {
                  window.console.log("The DOM node id for the destroyed component is : %s", event.target.id);
              };
            });

            #optionChange

            Fired whenever a supported component option changes, whether due to user interaction or programmatic intervention. If the new value is the same as the previous value, no event will be fired.
            Properties:
            Name Type Description
            event Event jQuery event object
            ui Object Parameters
            Properties
            Name Type Description
            option string the name of the option that is changing
            previousValue Object the previous value of the option
            value Object the current value of the option
            optionMetadata Object information about the option that is changing
            Properties
            Name Type Description
            writeback string "shouldWrite" or "shouldNotWrite". For use by the JET writeback mechanism.
            Source:

            #remove

            Triggered after a tab has been removed.
            Properties:
            Name Type Description
            event Event jQuery event object
            ui Object Parameters
            Properties
            Name Type Description
            tab jQuery The tab that was just removed.
            content jQuery The content that was just removed.
            Source:
            Examples

            Initialize the tabs with the remove callback specified:

            $( ".selector" ).ojTabs({
                "remove": function( event, ui ) {}
            });

            Bind an event listener to the ojremove event:

            $( ".selector" ).on( "ojremove", function( event, ui ) {} );

            #reorder

            Triggered after a tab has been reordered.
            Properties:
            Name Type Description
            event Event jQuery event object
            ui Object Parameters
            Properties
            Name Type Description
            tab jQuery The tab that was just reordered.
            content jQuery The content that was just reordered.
            Source:
            Examples

            Initialize the tabs with the reorder callback specified:

            $( ".selector" ).ojTabs({
                "reorder": function( event, ui ) {}
            });

            Bind an event listener to the ojreorder event:

            $( ".selector" ).on( "ojreorder", function( event, ui ) {} );

            #select

            Triggered after a tab has been selected.
            Properties:
            Name Type Description
            event Event jQuery event object
            ui Object Parameters
            Properties
            Name Type Description
            fromTab jQuery The tab being navigated from
            fromContent jQuery The content being navigated from
            toTab jQuery The tab being navigated to
            toContent jQuery The content being navigated to
            Source:
            Examples

            Initialize the tabs with the select callback specified:

            $( ".selector" ).ojTabs({
                "select": function( event, ui ) {}
            });

            Bind an event listener to the ojselect event:

            $( ".selector" ).on( "ojselect", function( event, ui ) {} );

            Methods

            #addTab(newTab)

            Add a tab to the end of the tabs
            Parameters:
            Name Type Description
            newTab Object An Object contains the properties in the following table.
            Properties:
            Name Type Description
            newTab.tab jQuery The new tab
            newTab.content jQuery The new content
            newTab.index number The index of new tab. Default is -1, newTab is appended to the end
            Source:
            Returns:
            When called via the public jQuery syntax, this method returns the object on which it was called, to facilitate method chaining.
            Example

            Invoke the addTab method:

            $( ".selector" ).ojTabs( "addTab", 
                                     {
                                       "tab" : $("<h3>New Tab</h3>"),
                                       "content" : $("<div><p>Content of New Tab</p></div>"),
                                       "index" : 2
                                     } );
            
            Please note that single jQuery object parameter is deprecated
            $( ".selector" ).ojTabs( "addTab", $("<div><h3>New Tab</h3><p>Content of New Tab</p></div>") );

            getNodeBySubId(locator) → {Element|null}

            Returns the component DOM node indicated by the locator parameter.

            If the locator or its subId is null, then this method returns the element on which this component was initialized.

            If a subId was provided but no corresponding node can be located, then this method returns null. For more details on subIds, see the subIds section.

            Parameters:
            Name Type Description
            locator Object An Object containing, at minimum, a subId property, whose value is a string that identifies a particular DOM node in this component.

            If this component has (or inherits) any subIds, then they are documented in the "Sub-ID's" section of this document.

            Subclasses of this component may support additional fields of the locator Object, to further specify the desired node.

            Inherited From:
            Source:
            Returns:
            The DOM node located by the subId string passed in locator, or null if none is found.
            Type
            Element | null
            Example

            Get the node for a certain subId:

            // Foo is ojInputNumber, ojInputDate, etc.
            var node = $( ".selector" ).ojFoo( "getNodeBySubId", {'subId': 'oj-some-sub-id'} );

            option(optionName, value) → {Object|undefined}

            This method has several overloads, which get and set component options and their fields. The functionality is unchanged from that provided by JQUI. See the examples for details on each overload.

            Parameters:
            Name Type Argument Description
            optionName string | Object <optional>
            the option name (string, first two overloads), or the map (Object, last overload). Omitted in the third overload.
            value Object <optional>
            a value to set for the option. Second overload only.
            Inherited From:
            Source:
            Returns:
            The getter overloads return the retrieved value(s). When called via the public jQuery syntax, the setter overloads return the object on which they were called, to facilitate method chaining.
            Type
            Object | undefined
            Examples

            First overload: get one option:

            This overload accepts a (possibly dot-separated) optionName param as a string, and returns the current value of that option.

            var isDisabled = $( ".selector" ).ojFoo( "option", "disabled" ); // Foo is Button, Menu, etc.
            
            // For object-valued options, dot notation can be used to get the value of a field or nested field.
            var startIcon = $( ".selector" ).ojButton( "option", "icons.start" ); // icons is object with "start" field

            Second overload: set one option:

            This overload accepts two params: a (possibly dot-separated) optionName string, and a new value to which that option will be set.

            $( ".selector" ).ojFoo( "option", "disabled", true ); // Foo is Button, Menu, etc.
            
            // For object-valued options, dot notation can be used to set the value
            // of a field or nested field, without altering the rest of the object.
            $( ".selector" ).ojButton( "option", "icons.start", myStartIcon ); // icons is object with "start" field

            Third overload: get all options:

            This overload accepts no params, and returns a map of key/value pairs representing all the component options and their values.

            var options = $( ".selector" ).ojFoo( "option" ); // Foo is Button, Menu, etc.

            Fourth overload: set one or more options:

            This overload accepts a single map of option-value pairs to set on the component. Unlike the first two overloads, dot notation cannot be used.

            $( ".selector" ).ojFoo( "option", { disabled: true, bar: 42 } ); // Foo is Button, Menu, etc.

            #refresh()

            Refreshes the visual state of the tabs. JET components require a refresh() or re-init after the DOM is programmatically changed underneath the component.

            This method does not accept any arguments.

            Source:
            Returns:
            When called via the public jQuery syntax, this method returns the object on which it was called, to facilitate method chaining.
            Example

            Invoke the refresh method:

            $( ".selector" ).ojTabs( "refresh" );

            Non-public Methods

            Note: Extending JET components is not currently supported. Thus, non-public methods are for internal use only.

            <protected> _AfterCreate()

            This method is called after _ComponentCreate, but before the create event is fired. The JET base component does tasks here that must happen after the component (subclass) has created itself in its override of _ComponentCreate. Notably, the base component handles the rootAttributes and contextMenu options here, since those options operate on the component root node, which for some components is created in their override of _ComponentCreate.

            Subclasses should override this method only if they have tasks that must happen after a superclass's implementation of this method, e.g. tasks that must happen after the context menu is set on the component.

            Overrides of this method should call this._super first.

            Inherited From:
            Source:

            <protected> _AfterCreateEvent()

            This method is called after the create event is fired. Components usually should not override this method, as it is rarely correct to wait until after the create event to perform a create-time task.

            An example of a correct usage of this method is Dialog's auto-open behavior, which needs to happen after the create event.

            Only behaviors (like Dialog auto-open behavior) should occur in this method. Component initialization must occur earlier, before the create event is fired, so that create listeners see a fully inited component.

            Overrides of this method should call this._super first.

            Do not confuse this method with the _AfterCreate method, which is more commonly used.

            Inherited From:
            Source:

            <protected> _CompareOptionValues(option, value1, value2) → {boolean}

            Compares 2 option values for equality and returns true if they are equal; false otherwise.

            Parameters:
            Name Type Description
            option String the name of the option
            value1 Object first value
            value2 Object another value
            Inherited From:
            Source:
            Returns:
            Type
            boolean

            <protected> _ComponentCreate()

            All component create-time initialization lives in this method, except the logic that specifically needs to live in _InitOptions, _AfterCreate, or _AfterCreateEvent, per the documentation for those methods. All DOM creation must happen here, since the intent of _AfterCreate, which is called next, is to contain superclass logic that must run after that DOM is created.

            Overrides of this method should call this._super first.

            Summary of create-time methods that components can override, in the order that they are called:

            1. _InitOptions
            2. _ComponentCreate (this method)
            3. _AfterCreate
            4. (The create event is fired here.)
            5. _AfterCreateEvent

            For all of these methods, the contract is that overrides must call this._super first, so e.g., the _ComponentCreate entry means baseComponent._ComponentCreate, then _ComponentCreate in any intermediate subclasses, then _ComponentCreate in the leaf subclass.

            Inherited From:
            Source:

            <protected> _create()

            This method is final in JET. Components should instead override one or more of the overridable create-time methods listed in _ComponentCreate.

            Inherited From:
            Source:

            <protected> _getCreateOptions()

            This method is not used in JET. Components should instead override _InitOptions.

            Inherited From:
            Source:

            <protected> _GetReadingDirection() → {string}

            Determines whether the component is LTR or RTL.

            Component responsibilities:

            • All components must determine directionality exclusively by calling this protected superclass method. (So that any future updates to the logic can be made in this one place.)
            • Components that need to know the directionality must call this method at create-time and from refresh(), and cache the value.
            • Components should not call this at other times, and should instead use the cached value. (This avoids constant DOM queries, and avoids any future issues with component reparenting (i.e. popups) if support for directional islands is added.)

            App responsibilities:

            • The app specifies directionality by setting the HTML "dir" attribute on the <html> node. When omitted, the default is "ltr". (Per-component directionality / directional islands are not currently supported due to inadequate CSS support.)
            • As with any DOM change, the app must refresh() the component if the directionality changes dynamically. (This provides a hook for component housekeeping, and allows caching.)
            Default Value:
            • "ltr"
            Inherited From:
            Source:
            Returns:
            the reading direction, either "ltr" or "rtl"
            Type
            string

            <protected> _GetSavedAttributes(element) → {Object|null}

            Gets the saved attributes for the provided element.

            If you don't override _SaveAttributes and _RestoreAttributes, then this will return null.

            If you override _SaveAttributes to call _SaveAllAttributes, then this will return all the attributes. If you override _SaveAttributes/_RestoreAttributes to do your own thing, then you may also have to override _GetSavedAttributes to return whatever you saved if you need access to the saved attributes.

            Parameters:
            Name Type Description
            element Object jQuery selection, should be a single entry
            Inherited From:
            Source:
            Returns:
            savedAttributes - attributes that were saved for this element in _SaveAttributes, or null if none were saved.
            Type
            Object | null

            <protected> _init()

            JET components should almost never implement this JQUI method. Please consult an architect if you believe you have an exception. Reasons:

            • This method is called at create time, after the create event is fired. It is rare for that to be the appropriate time to perform a create-time task. For those rare cases, we have the _AfterCreateEvent method, which is preferred over this method since it is called only at that time, not also at re-init time (see next).
            • This method is also called at "re-init" time, i.e. when the initializer is called after the component has already been created. JET has not yet identified any desired semantics for re-initing a component.
            Inherited From:
            Source:

            <protected> _InitOptions(originalDefaults, constructorOptions)

            This method is called before _ComponentCreate, at which point the component has not yet been rendered. Component options should be initialized in this method, so that their final values are in place when _ComponentCreate is called.

            This includes getting option values from the DOM, where applicable, and coercing option values (however derived) to their appropriate data type if needed.

            No work other than setting options should be done in this method. In particular, nothing should be set on the DOM until _ComponentCreate, e.g. setting the disabled DOM attribute from the disabled option.

            A given option (like disabled) appears in the constructorOptions param iff the app set it in the constructor:

            • If it appears in constructorOptions, it should win over what's in the DOM (e.g. disabled DOM attribute). If for some reason you need to tweak the value that the app set, then enable writeback when doing so: this.option('foo', bar, {'_context': {writeback: true, internalSet: true}}).
            • If it doesn't appear in constructorOptions, then that option definitely is not bound, so writeback is not needed. So if you need to set the option (e.g. from a DOM attribute), use this.option('foo', bar, {'_context': {internalSet: true}}).

            Overrides of this method should call this._super first.

            Parameters:
            Name Type Argument Description
            originalDefaults Object original default options defined on the component and its ancestors
            constructorOptions Object <nullable>
            options passed into the widget constructor
            Inherited From:
            Source:

            <protected> _IsEffectivelyDisabled() → {boolean}

            Determines whether this component is effectively disabled, i.e. it has its 'disabled' attribute set to true or it has been disabled by its ancestor component.

            Inherited From:
            Source:
            Returns:
            true if the component has been effectively disabled, false otherwise
            Type
            boolean

            <protected> _NotifyAttached()

            Notifies the component that its subtree has been connected to the document programmatically after the component has been created.

            Inherited From:
            Source:

            <protected> _NotifyContextMenuGesture(menu, event, eventType)

            When the contextMenu option is set, this method is called when the user invokes the context menu via the default gestures: right-click, Press & Hold, and Shift-F10. Components should not call this method directly.

            The default implementation simply calls this._OpenContextMenu(event, eventType). Overrides of this method should call that same method, perhaps with additional params, not menu.open().

            This method may be overridden by components needing to do things like the following:

            • Customize the launcher or position passed to _OpenContextMenu(). See that method for guidance on these customizations.
            • Customize the menu contents. E.g. some components need to enable/disable built-in commands like Cut and Paste, based on state at launch time.
            • Bail out in some cases. E.g. components with UX approval to use PressHoldRelease rather than Press & Hold can override this method to say if (eventType !== "touch") this._OpenContextMenu(event, eventType);. When those components detect the alternate context menu gesture (e.g. PressHoldRelease), that separate listener should call this._OpenContextMenu(), not this method (_NotifyContextMenuGesture()), and not menu.open().

            Components needing to do per-launch setup like the above tasks should do so in an override of this method, not in a beforeOpen listener or an _OpenContextMenu() override. This is discussed more fully here.

            Parameters:
            Name Type Description
            menu Object The JET Menu to open as a context menu. Always non-null.
            event Event What triggered the menu launch. Always non-null.
            eventType string "mouse", "touch", or "keyboard". Never null.
            Inherited From:
            Source:

            <protected> _NotifyDetached()

            Notifies the component that its subtree has been removed from the document programmatically after the component has been created.

            Inherited From:
            Source:

            <protected> _NotifyHidden()

            Notifies the component that its subtree has been made hidden programmatically after the component has been created.

            Inherited From:
            Source:

            <protected> _NotifyShown()

            Notifies the component that its subtree has been made visible programmatically after the component has been created.

            Inherited From:
            Source:

            <protected> _OpenContextMenu(event, eventType, openOptions, submenuOpenOptions, shallow)

            The only correct way for a component to open its context menu is by calling this method, not by calling Menu.open() or _NotifyContextMenuGesture(). This method should be called in two cases:

            • This method is called by _NotifyContextMenuGesture() and its overrides. That method is called when the baseComponent detects the default context menu gestures: right-click, Press & Hold, and Shift-F10.
            • Components with UX-approved support for alternate context menu gestures like PressHoldRelease should call this method directly when those gestures are detected.

            Components needing to customize how the context menu is launched, or do any per-launch setup, should do so in the caller of this method, (which is one of the two callers listed above), often by customizing the params passed to this method (_OpenContextMenu) per the guidance below. This setup should not be done in the following ways:

            • Components should not perform setup in a beforeOpen listener, as this can cause a race condition where behavior depends on who got their listener registered first: the component or the app. The only correct component use of a beforeOpen listener is when there's a need to detect whether something else launched the menu.
            • Components should not override this method (_OpenContextMenu), as this method is final. Instead, customize the params that are passed to it.

            Guidance on setting OpenOptions fields:

            Launcher:

            Depending on individual component needs, any focusable element within the component can be the appropriate launcher for this launch.

            Browser focus returns to the launcher on menu dismissal, so the launcher must at least be focusable. Typically a tabbable (not just focusable) element is safer, since it just focuses something the user could have focused on their own.

            By default (i.e. if openOptions is not passed, or if it lacks a launcher field), the component init node is used as the launcher for this launch. If that is not focusable or is suboptimal for a given component, that component should pass something else. E.g. components with a "roving tabstop" (like Toolbar) should typically choose the current tabstop as their launcher.

            The :focusable and :tabbable selectors may come in handy for choosing a launcher, e.g. something like this.widget().find(".my-class:tabbable").first().

            Position:

            By default, this method applies positioning that differs from Menu's default in the following ways: (The specific settings are subject to change.)

            • For mouse and touch events, the menu is positioned relative to the event, not the launcher.
            • For touch events, "my" is set to "start>40 center", to avoid having the context menu obscured by the user's finger.

            Usually, if position needs to be customized at all, the only thing that needs changing is its "of" field, and only for keyboard launches (since mouse/touch launches should almost certainly keep the default "event" positioning). This situation arises anytime the element relative to which the menu should be positioned for keyboard launches is different than the launcher element (the element to which focus should be returned upon dismissal). For this case, { "position": {"of": eventType==="keyboard" ? someElement : "event"} } can be passed as the openOptions param.

            Be careful not to clobber useful defaults by specifying too much. E.g. if you only want to customize "of", don't pass other fields like "my", since your value will be used for all modalities (mouse, touch, keyboard), replacing the modality-specific defaults that are usually correct. Likewise, don't forget the eventType==="keyboard" check if you only want to customize "of" for keyboard launches.

            InitialFocus:

            This method forces initialFocus to "menu" for this launch, so the caller needn't specify it.

            Parameters:
            Name Type Argument Description
            event Event What triggered the context menu launch. Must be non-null.
            eventType string "mouse", "touch", or "keyboard". Must be non-null. Passed explicitly since caller knows what it's listening for, and since events like contextmenu and click can be generated by various input modalities, making it potentially error-prone for this method to determine how they were generated.
            openOptions Object <optional>
            Options to merge with this method's defaults, which are discussed above. The result will be passed to Menu.open(). May be null or omitted. See also the shallow param.
            submenuOpenOptions Object <optional>
            Options to be passed through to Menu.open(). May be null or omitted.
            shallow boolean <optional>
            Whether to perform a deep or shallow merge of openOptions with this method's default value. The default and most commonly correct / useful value is false.
            • If true, a shallow merge is performed, meaning that the caller's position object, if passed, will completely replace this method's default position object.
            • If false or omitted, a deep merge is performed. For example, if the caller wishes to tweak position.of while keeping this method's defaults for position.my, position.at, etc., it can pass {"of": anOfValue} as the position value.

            The shallow param is n/a for submenuOpenOptions, since this method doesn't apply any defaults to that. (It's a direct pass-through.)

            Inherited From:
            Source:

            <protected> _RestoreAllAttributes()

            Restores all the element's attributes which were saved in _SaveAllAttributes. This method is final in JET.

            If a subclass wants to save/restore all attributes on create/destroy, then the subclass can override _SaveAttributes and call _SaveAllAttributes and also override _RestoreAttributes and call _RestoreAllAttributes.

            Inherited From:
            Source:

            <protected> _RestoreAttributes()

            Restore the attributes saved in _SaveAttributes.

            _SaveAttributes is called during _create. And _RestoreAttributes is called during _destroy.

            This base class default implementation does nothing.

            We also have _SaveAllAttributes and _RestoreAllAttributes methods that save and restore all the attributes on an element. Component subclasses can opt into these _SaveAllAttributes/_RestoreAllAttributes implementations by overriding _SaveAttributes and _RestoreAttributes to call _SaveAllAttributes/_RestoreAllAttributes. If the subclass wants a different implementation (like save only the 'class' attribute), it can provide the implementation itself in _SaveAttributes/_GetSavedAttributes/_RestoreAttributes.

            Inherited From:
            Source:

            <protected> _SaveAllAttributes(element)

            Saves all the element's attributes within an internal variable. _RestoreAllAttributes will restore the attributes from this internal variable.

            This method is final in JET. Subclasses can override _RestoreAttributes and call _RestoreAllAttributes.

            The JSON variable will be held as:

            [
              {
              "element" : element[i],
              "attributes" :
                {
                  attributes[m]["name"] : {"attr": attributes[m]["value"], "prop": $(element[i]).prop(attributes[m]["name"])
                }
              }
            ]
            
            Parameters:
            Name Type Description
            element Object jQuery selection to save attributes for
            Inherited From:
            Source:

            <protected> _SaveAttributes(element)

            Saves the element's attributes. This is called during _create. _RestoreAttributes will restore all these attributes and is called during _destroy.

            This base class default implementation does nothing.

            We also have _SaveAllAttributes and _RestoreAllAttributes methods that save and restore all the attributes on an element. Component subclasses can opt into these _SaveAllAttributes/_RestoreAllAttributes implementations by overriding _SaveAttributes and _RestoreAttributes to call _SaveAllAttributes/_RestoreAllAttributes. If the subclass wants a different implementation (like save only the 'class' attribute), it can provide the implementation itself in _SaveAttributes/_RestoreAttributes.

            Parameters:
            Name Type Description
            element Object jQuery selection to save attributes for
            Inherited From:
            Source:

            <protected> _SetRootAttributes()

            Reads the rootAttributes option, and sets the root attributes on the component's root DOM element. See rootAttributes for the set of supported attributes and how they are handled.

            Inherited From:
            Source:
            Throws:
            if unsupported attributes are supplied.

            <protected> _UnregisterChildNode()

            Remove all listener references that were attached to the element which includes _activeable, _focusable and hoverable.
            Inherited From:
            Source: