Initializer
.ojTabs()
- Source:
- ojtabs/ojtabs.js, line 2
Examples
Initialize the tabs with no options specified:
$( ".selector" ).ojTabs();
Initialize the tabs with some options and callbacks specified:
$( ".selector" ).ojTabs( { "disabled": true, "create": function( event, ui ) {} } );
Initialize the tabs via the JET ojComponent binding:
<div id="tabs" data-bind="ojComponent: { component: 'ojTabs',
disabled: [1],
reorderable: true }">
Options
-
#contextMenu :Object
-
JQ selector identifying 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
ojContextMenubinding.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.
The JET Menu should be initialized before any component using it as a context menu.
- Default Value:
null
- Inherited From:
- Source:
- ojcomponentcore/jqueryui-base.js, line 51
Examples
Initialize a JET component with a context menu:
// via recommended HTML5 syntax: <div id="myComponent" contextmenu="myMenu" data-bind="ojComponent: { ... }> // via JET initializer (less preferred) : $( ".selector" ).ojFoo({ "contextMenu": "#myMenu" });Get or set the
contextMenuoption, after initialization:// getter var menu = $( ".selector" ).ojFoo( "option", "contextMenu" ); // setter $( ".selector" ).ojFoo( "option", "contextMenu", ".my-marker-class" );Set a JET context menu on an ordinary HTML element:
<a href="#" id="myAnchor" contextmenu="myMenu" data-bind="ojContextMenu: {}">Some text -
#disabled :{boolean|Array} Boolean: Enable or disable all tabs. Array: An array containing the zero-based indexes of the tabs that should be disabled.
-
Which tabs are disabled.
- Default Value:
false
- Source:
- ojtabs/ojtabs.js, line 248
Example
[ 0, 2 ] would disable the first and third tab. -
#orientation :string
-
The orientation of the tab bar. Valid Values: horizontal and vertical
- Default Value:
"horizontal"
- Source:
- ojtabs/ojtabs.js, line 301
-
#removable :boolean
-
Specifies if the tabs can be closed (removed)
- Default Value:
false
- Source:
- ojtabs/ojtabs.js, line 312
-
#removeCueText :string
-
This text is used to provide audible feedback for screen reader users
- Default Value:
Tab is removable
- Source:
- ojtabs/ojtabs.js, line 323
-
#reorderable :boolean
-
Specifies if the tabs can be reordered within the tab bar by drag-and-drop
- Default Value:
false
- Source:
- ojtabs/ojtabs.js, line 334
-
#rootAttributes :Object|undefined
-
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 root element at creation time.
The specified
classandstyleare appended to the current class and style, respectively. All other attributes overwrite any existing value.Setting this option after component creation has no effect.
- Default Value:
undefined
- Inherited From:
- Source:
- ojcomponentcore/jqueryui-base.js, line 77
Example
Initialize a JET component, specifying a set of attributes to be set on the component's root DOM element:
$( ".selector" ).ojFoo({ "rootAttributes": { 'id': 'myId', 'style': 'max-width:100%; color:blue;', 'class': 'my-class' }}); -
#selected :number
-
The zero-based index of the panel that is selected (open).
- Default Value:
0
- Source:
- ojtabs/ojtabs.js, line 234
-
#selectOn :string
-
The type of event to select the tab. To select a tab on hover, use "mouseover".
- Default Value:
"click"
- Source:
- ojtabs/ojtabs.js, line 289
-
#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 label texts. When there is not enough room, the conveyorBelt's navigation arrows are displayed to allow the label 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 label is restricted just enough to allow all tabs to fit. All tab labels that are truncated are displayed with ellipses. However the width of each tab 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:
- ojtabs/ojtabs.js, line 277
Events
-
#afterDeselect
-
Triggered after a tab has been deselected. The afterDeselect can be cancelled by calling
event.preventDefault().- Source:
- ojtabs/ojtabs.js, line 435
Properties:
Name Type Description eventEvent jQueryevent objectuiObject Parameters Properties
Name Type Description newHeaderjQuery The tab that was just deselected. newContentjQuery The panel that was just deselected. oldHeaderjQuery The tab that was just selected. oldContentjQuery The panel that was just selected. Examples
Initialize the tabs with the
afterDeselectcallback specified:$( ".deselector" ).ojTabs({ "afterDeselect": function( event, ui ) {} });Bind an event listener to the
ojafterdeselectevent:$( ".deselector" ).on( "ojafterdeselect", function( event, ui ) {} ); -
#afterRemove
-
Triggered after a tab has been removed.
- Source:
- ojtabs/ojtabs.js, line 480
Properties:
Name Type Description eventEvent jQueryevent objectuiObject Parameters Properties
Name Type Description headerjQuery The tab that was just removed. contentjQuery The panel that was just removed. Examples
Initialize the tabs with the
afterRemovecallback specified:$( ".selector" ).ojTabs({ "afterRemove": function( event, ui ) {} });Bind an event listener to the
ojafterremoveevent:$( ".selector" ).on( "ojafterremove", function( event, ui ) {} ); -
#afterSelect
-
Triggered after a tab has been selected. The afterSelect can be cancelled by calling
event.preventDefault().- Source:
- ojtabs/ojtabs.js, line 385
Properties:
Name Type Description eventEvent jQueryevent objectuiObject Parameters Properties
Name Type Description newHeaderjQuery The tab that was just selected. newContentjQuery The panel that was just selected. oldHeaderjQuery The tab that was just deselected. oldContentjQuery The panel that was just deselected. Examples
Initialize the tabs with the
afterSelectcallback specified:$( ".selector" ).ojTabs({ "afterSelect": function( event, ui ) {} });Bind an event listener to the
ojafterselectevent:$( ".selector" ).on( "ojafterselect", function( event, ui ) {} ); -
#beforeDeselect
-
Triggered immediately before a tab is deselected. The beforeDeselect can be cancelled by calling
event.preventDefault().- Source:
- ojtabs/ojtabs.js, line 410
Properties:
Name Type Description eventEvent jQueryevent objectuiObject Parameters Properties
Name Type Description newHeaderjQuery The tab that is about to be deselected. newContentjQuery The panel that is about to be deselected. oldHeaderjQuery The tab that is about to be selected. oldContentjQuery The panel that is about to be selected. Examples
Initialize the tabs with the
beforeDeselectcallback specified:$( ".deselector" ).ojTabs({ "beforeDeselect": function( event, ui ) {} });Bind an event listener to the
ojbeforedeselectevent:$( ".deselector" ).on( "ojbeforedeselect", function( event, ui ) {} ); -
#beforeRemove
-
Triggered immediately before a tab is removed. The beforeRemove can be cancelled by calling
event.preventDefault().- Source:
- ojtabs/ojtabs.js, line 458
Properties:
Name Type Description eventEvent jQueryevent objectuiObject Parameters Properties
Name Type Description headerjQuery The tab that is about to be removed. contentjQuery The panel that is about to be removed. Examples
Initialize the tabs with the
beforeRemovecallback specified:$( ".selector" ).ojTabs({ "beforeRemove": function( event, ui ) {} });Bind an event listener to the
ojbeforeremoveevent:$( ".selector" ).on( "ojbeforeremove", function( event, ui ) {} ); -
#beforeSelect
-
Triggered immediately before a tab is selected. The beforeSelect can be cancelled by calling
event.preventDefault().- Source:
- ojtabs/ojtabs.js, line 360
Properties:
Name Type Description eventEvent jQueryevent objectuiObject Parameters Properties
Name Type Description newHeaderjQuery The tab that is about to be selected. newContentjQuery The panel that is about to be selected. oldHeaderjQuery The tab that is about to be deselected. oldContentjQuery The panel that is about to be deselected. Examples
Initialize the tabs with the
beforeSelectcallback specified:$( ".selector" ).ojTabs({ "beforeSelect": function( event, ui ) {} });Bind an event listener to the
ojbeforeselectevent:$( ".selector" ).on( "ojbeforeselect", function( event, ui ) {} ); -
#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. Currently there is one supported option,
"selected". Additional options may be supported in the future, so listeners should verify which option is changing before taking any action.- Source:
- ojtabs/ojtabs.js, line 504
Properties:
Name Type Description eventEvent jQueryevent objectuiObject Parameters Properties
Name Type Description optionstring the name of the option that is changing previousValueObject the previous value of the option valueObject the current value of the option optionMetadataObject information about the option that is changing Properties
Name Type Description writebackstring "shouldWrite"or"shouldNotWrite". For use by the JET writeback mechanism.
Methods
-
#addTab(newTab)
-
Add a tab to the end of the tabs
Parameters:
Name Type Description newTabjQuery jQuery object of the new tab - Source:
- ojtabs/ojtabs.js, line 1597
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
addTabmethod:$( ".selector" ).ojTabs( "addTab", $("<div><h3>New Tab</h3><p>Content of New Tab</p></div>") ); -
#disable(index)
-
Disables a tab.
Parameters:
Name Type Description indexnumber zero-based index of the tabs to disable - Source:
- ojtabs/ojtabs.js, line 1495
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
disablemethod:$( ".selector" ).ojTabs( "disable", 1 ); -
#enable(index)
-
Enables a tab.
Parameters:
Name Type Description indexnumber zero-based index of the tabs to enable - Source:
- ojtabs/ojtabs.js, line 1455
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
enablemethod:$( ".selector" ).ojTabs( "enable", 1 ); -
#getNodeBySubId(locator) → {Element|null}
-
Return the subcomponent node represented by the documented locator attribute values. To lookup a title text the locator object should have the following: subId: 'oj-tabs-title' index: number To lookup a close icon the locator object should have the following: subId: 'oj-tabs-close-icon' index: number To lookup a panel content the locator object should have the following: subId: 'oj-tabs-panel' index: number To lookup the conveyorbelt the locator object should have the following: subId: 'oj-conveyorbelt'
Parameters:
Name Type Description locatorObject An Object containing at minimum a subId property whose value is a string, documented by the component, that allows the component to look up the subcomponent associated with that string. It contains: component: optional - in the future there may be more than one component contained within a page element
subId: the string, documented by the component, that the component expects in getNodeBySubId to locate a particular subcomponent
- Source:
- ojtabs/ojtabs.js, line 1754
Returns:
the subcomponent located by the subId string passed in locator, if found.- Type
- Element | null
-
#getSubIdByNode(node) → {string|null}
-
Return the subId string for the given child DOM node
Parameters:
Name Type Description nodeElement child DOM node - Inherited From:
- Source:
- ojcomponentcore/jqueryui-base.js, line 548
Returns:
- the subId for the DOM node or null when none is found- Type
- string | null
-
#option(optionName, value) → {Object|undefined}
-
This method has several overloads, which gets and set component options.
The first overload accepts a single
optionNameparam as a string, and returns the current value of that option.The second overload accepts two params, an
optionNamestring and a new value to which that option will be set.The third overload accepts no params, and returns a map of key/value pairs representing all the component options and their values.
The fourth overload accepts a single map of option-value pairs to set on the component.
Parameters:
Name Type Argument Description optionNamestring | Object <optional>
the option name (string, first two overloads), or the map (Object, last overload). Omitted in the third overload. valueObject <optional>
a value to set for the option. Second overload only. - Inherited From:
- Source:
- ojcomponentcore/jqueryui-base.js, line 600
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:
var isDisabled = $( ".selector" ).ojFoo( "option", "disabled" ); // Foo is Button, Menu, etc.Second overload: set one option:
$( ".selector" ).ojFoo( "option", "disabled", true ); // Foo is Button, Menu, etc.Third overload: get all options:
var options = $( ".selector" ).ojFoo( "option" ); // Foo is Button, Menu, etc.Fourth overload: set one or more options:
$( ".selector" ).ojFoo( "option", { disabled: true } ); // 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:
- ojtabs/ojtabs.js, line 790
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
refreshmethod:$( ".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. 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 therootAttributesandcontextMenuoptions 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._superfirst.- Inherited From:
- Source:
- ojcomponentcore/jqueryui-base.js, line 292
Returns:
When called via the public jQuery syntax, this method returns the object on which it was called, to facilitate method chaining. -
<protected> #_ComponentCreate()
-
All component create-time initialization lives in this method, except the logic that specifically needs to live in
_InitOptionsor_AfterCreate, per the documentation for those methods. All DOM creation must happen here, since the intent of_AfterCreateis to contain superclass logic that must run after that DOM is created.Overrides of this method should call
this._superfirst.- Inherited From:
- Source:
- ojcomponentcore/jqueryui-base.js, line 266
Returns:
When called via the public jQuery syntax, this method returns the object on which it was called, to facilitate method chaining. -
<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 from
_create()andrefresh(), 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 if directional islands and component reparenting (e.g. popups) should coexist.)
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:
- ojcomponentcore/jqueryui-base.js, line 888
Returns:
the reading direction, either"ltr"or"rtl"- Type
- string
-
<protected> #_GetSavedAttributes(element) → {Object}
-
Gets the saved attributes for the provided element. This is usually the original list of attributes set on the element.
Parameters:
Name Type Description elementObject jQuery selection, should be a single entry - Inherited From:
- Source:
- ojcomponentcore/jqueryui-base.js, line 359
Returns:
savedAttributes - attributes that were saved for this element.- Type
- Object
-
<protected> #_InitOptions()
-
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_ComponentCreateis called.This includes getting option values from the DOM, where applicable, and coercing option values (however derived) to their appropriate data type. No other work should be done in this method. See below for details.
Overrides of this method should call
this._superfirst.Usage:
- If the component has an option like
disabledthat can be set from the DOM at create time, then the "get from DOM" logic should live in this method. E.g. a typical override might say "if thedisabledoption still has its initial value ofundefined(i.e., the option has not been set), then get the DOM property and set it on the option." (See also next bullet.) - For attributes that live on the component's root node, keep in mind that anything specified via
the
rootAttributesoption will not be placed on the DOM until_AfterCreate. So when getting attributes from the root node, components must first look in therootAttributesoption, and then, only if the attribute is not found there, look on the component root (if it already exists). - For options that, unlike
disabled, have no corresponding DOM property, and are not otherwise set from the DOM, there is nothing to do in this method. - Do NOT set anything on the DOM in this method (like the resolved
disabledvalue, or anyrootAttributesvalues). The resolved option values should be set on the DOM later, in_ComponentCreate, and therootAttributesvalues are set inbaseComponent._AfterCreate.
- Inherited From:
- Source:
- ojcomponentcore/jqueryui-base.js, line 249
Returns:
When called via the public jQuery syntax, this method returns the object on which it was called, to facilitate method chaining. - If the component has an option like
-
<protected> #_RestoreAttributes()
-
Restores the saved element's attributes
- Inherited From:
- Source:
- ojcomponentcore/jqueryui-base.js, line 385
Returns:
When called via the public jQuery syntax, this method returns the object on which it was called, to facilitate method chaining. -
<protected> #_SaveAttributes(element)
-
Saves the element's attributes within an internal variable to be reset during the destroy function 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 elementObject jQuery selection to save attributes for - Inherited From:
- Source:
- ojcomponentcore/jqueryui-base.js, line 320
Returns:
When called via the public jQuery syntax, this method returns the object on which it was called, to facilitate method chaining. -
<protected> #_SetRootAttributes()
-
Reads the
rootAttributesoption, and sets the root attributes on the component's root DOM element.classandstyleare appended to the current class and style, respectively. All other attributes overwrite any existing value.- Inherited From:
- Source:
- ojcomponentcore/jqueryui-base.js, line 103
Returns:
When called via the public jQuery syntax, this method returns the object on which it was called, to facilitate method chaining.