Class kartik\tabs\TabsX
Inheritance | kartik\tabs\TabsX » kartik\base\Widget » yii\base\Widget » yii\base\Component » yii\base\BaseObject |
---|---|
Implements | kartik\base\BootstrapInterface, yii\base\Configurable, yii\base\ViewContextInterface |
Uses Traits | kartik\base\BootstrapTrait, kartik\base\TranslationTrait, kartik\base\WidgetTrait |
Available since version | 1.0 |
TabsX is an extended Bootstrap Tabs navigation widget for Yii Framework 2 based on the bootstrap-tabs-x plugin by Krajee. This widget enhances the default bootstrap tabs plugin with various new styling enhancements.
echo TabsX::widget([
'position' => TabsX::POS_ABOVE,
'align' => TabsX::ALIGN_LEFT,
'items' => [
[
'label' => 'One',
'content' => 'Anim pariatur cliche...',
'active' => true
],
[
'label' => 'Two',
'content' => 'Anim pariatur cliche...',
'headerOptions' => [],
'options' => ['id' => 'myveryownID'],
],
[
'label' => 'Dropdown',
'items' => [
[
'label' => 'DropdownA',
'content' => 'DropdownA, Anim pariatur cliche...',
],
[
'label' => 'DropdownB',
'content' => 'DropdownB, Anim pariatur cliche...',
],
],
],
],
]);
See also:
Public Properties
Property | Type | Description | Defined By |
---|---|---|---|
$align | string | The alignment of the tab headers with respect to the tab content. | kartik\tabs\TabsX |
$autoIdPrefix | string | The prefix to the automatically generated widget IDs. | yii\base\Widget |
$baseSourcePath | string|false | Get parsed base source path based on $sourcePath setting. If $sourcePath is not set, it will return the current working directory of this widget class. | kartik\base\WidgetTrait |
$behaviors | yii\base\Behavior[] | List of behaviors attached to this component. | yii\base\Component |
$bordered | boolean | Whether the tab content should be boxed within a bordered container. | kartik\tabs\TabsX |
$bsColCssPrefixes | array | The bootstrap grid column css prefixes mapping, the key is the bootstrap versions, and the value is an array containing the sizes and their corresponding grid column css prefixes. | kartik\base\BootstrapTrait |
$bsCssMap | array | CSS conversion mappings across bootstrap library versions. | kartik\base\BootstrapTrait |
$bsExtBasename | integer | The yii2 bootstrap extension base name (readonly property available via getter method getBsExtBasename()) | kartik\base\BootstrapTrait |
$bsVer | integer | Bootstrap version number currently set (readonly property available via getter method getBsVer()) | kartik\base\BootstrapTrait |
$bsVersion | integer|string | The bootstrap library version that you wish to use for this specific extension / widget. | kartik\base\BootstrapTrait |
$containerOptions | array | The HTML attributes for the TabsX container. | kartik\tabs\TabsX |
$counter | integer | A counter used to generate $id for widgets. | yii\base\Widget |
$defaultBtnCss | string | Default bootstrap button CSS (readonly property available via getter method getDefaultBtnCss()) | kartik\base\BootstrapTrait |
$defaultIconPrefix | string | Default icon prefix (readonly property available via getter method getDefaultIconPrefix()) | kartik\base\BootstrapTrait |
$defaultOptions | array | Default HTML attributes or other settings for widgets. | kartik\base\WidgetTrait |
$defaultPluginOptions | array | Default plugin options for the widget | kartik\base\WidgetTrait |
$dropdownClass | string | Name of a class to use for rendering dropdowns withing this widget. | kartik\tabs\TabsX |
$enableStickyTabs | boolean | Whether to enable sticky tabs plugin to maintain tabs push state on browser back and forward. | kartik\tabs\TabsX |
$encodeLabels | boolean | Whether the labels for header items should be HTML-encoded. | kartik\tabs\TabsX |
$fade | boolean | Whether to fade in each tab pane using the fade animation effect. | kartik\tabs\TabsX |
$hashVarLoadPosition | integer | The position where the client JS hash variables for the input widget will be loaded. | kartik\base\WidgetTrait |
$headerOptions | array | List of HTML attributes for the header container tags. | kartik\tabs\TabsX |
$height | string | Whether the tab body content height should be of a fixed size. | kartik\tabs\TabsX |
$i18n | array | The the internalization configuration for this widget. | kartik\base\TranslationTrait |
$id | string|null | ID of the widget. Note that the type of this property differs in getter and setter. See getId() and setId() for details. | yii\base\Widget |
$itemOptions | array | List of HTML attributes for the item container tags. | kartik\tabs\TabsX |
$items | array | List of tabs in the tabs widget. | kartik\tabs\TabsX |
$linkOptions | array | List of HTML attributes for the tab header link tags. | kartik\tabs\TabsX |
$moduleId | string | The module identifier if this widget is part of a module. | kartik\base\WidgetTrait |
$navType | string | Specifies the Bootstrap tab styling. | kartik\tabs\TabsX |
$options | array | HTML attributes or other settings for widgets. | kartik\base\Widget |
$pjaxContainerId | string | The identifier for the PJAX widget container if the widget is to be rendered inside a PJAX container. | kartik\base\WidgetTrait |
$pjaxDuplicationFix | boolean | Prevent duplication of pjax containers when browser back & forward buttons are pressed. | kartik\base\WidgetTrait |
$pluginDestroyJs | string | The javascript that will be used to destroy the jQuery plugin | kartik\base\WidgetTrait |
$pluginEvents | array | Widget JQuery events. | kartik\base\WidgetTrait |
$pluginName | string | The plugin name | kartik\base\WidgetTrait |
$pluginOptions | array | Widget plugin options. | kartik\base\WidgetTrait |
$position | string | The position of the tabs with respect to the tab content Should be one of the TabsX::POS constants. | kartik\tabs\TabsX |
$printCrumbSeparator | string | The crumb separator for the dropdown headers in the print view when printHeaderCrumbs is true |
kartik\tabs\TabsX |
$printHeaderCrumbs | boolean | Whether the headers in print view will prepend the main label to the item label in case of dropdowns. | kartik\tabs\TabsX |
$printHeaderOptions | array | The HTML attributes for the tab content header in print view. | kartik\tabs\TabsX |
$printable | boolean | Whether this tab widget should be printable. | kartik\tabs\TabsX |
$renderTabContent | boolean | Whether to render the tab-content container and its content. |
kartik\tabs\TabsX |
$sideways | boolean | Whether the tab header text orientation should be rotated sideways. | kartik\tabs\TabsX |
$sourcePath | string | Directory path to the original widget source. | kartik\base\WidgetTrait |
$stack | yii\base\Widget[] | The widgets that are currently being rendered (not ended). | yii\base\Widget |
$stickyTabsOptions | array | Sticky tabs plugin options. | kartik\tabs\TabsX |
$tabContentOptions | array | List of HTML attributes for the tab-content container. |
kartik\tabs\TabsX |
$view | yii\web\View | The view object that can be used to render views or view files. Note that the type of this property differs in getter and setter. See getView() and setView() for details. | yii\base\Widget |
$viewPath | string | The directory containing the view files for this widget. | yii\base\Widget |
Protected Properties
Public Methods
Method | Description | Defined By |
---|---|---|
__call() | Calls the named method which is not a class method. | yii\base\Component |
__clone() | This method is called after the object is created by cloning an existing one. | yii\base\Component |
__construct() | Constructor. | yii\base\BaseObject |
__get() | Returns the value of a component property. | yii\base\Component |
__isset() | Checks if a property is set, i.e. defined and not null. | yii\base\Component |
__set() | Sets the value of a component property. | yii\base\Component |
__unset() | Sets a component property to be null. | yii\base\Component |
addCssClass() | Adds bootstrap CSS class to options by parsing the bootstrap version for the specified Bootstrap CSS type. | kartik\base\BootstrapTrait |
afterRun() | This method is invoked right after a widget is executed. | yii\base\Widget |
attachBehavior() | Attaches a behavior to this component. | yii\base\Component |
attachBehaviors() | Attaches a list of behaviors to the component. | yii\base\Component |
beforeRun() | This method is invoked right before the widget is executed. | yii\base\Widget |
begin() | Begins a widget. | yii\base\Widget |
behaviors() | Returns a list of behaviors that this component should behave as. | yii\base\Component |
canGetProperty() | Returns a value indicating whether a property can be read. | yii\base\Component |
canSetProperty() | Returns a value indicating whether a property can be set. | yii\base\Component |
className() | Returns the fully qualified name of this class. | yii\base\BaseObject |
detachBehavior() | Detaches a behavior from the component. | yii\base\Component |
detachBehaviors() | Detaches all behaviors from the component. | yii\base\Component |
end() | Ends a widget. | yii\base\Widget |
ensureBehaviors() | Makes sure that the behaviors declared in behaviors() are attached to this component. | yii\base\Component |
getBSClass() | Gets the respective Bootstrap class based on currently configured bootstrap version. | kartik\base\BootstrapTrait |
getBaseSourcePath() | Get parsed base source path based on $sourcePath setting. If $sourcePath is not set, it will return the current working directory of this widget class. | kartik\base\WidgetTrait |
getBehavior() | Returns the named behavior object. | yii\base\Component |
getBehaviors() | Returns all behaviors attached to this component. | yii\base\Component |
getBsVer() | Gets the current set bootstrap version number. | kartik\base\BootstrapTrait |
getCssClass() | Gets bootstrap css class by parsing the bootstrap version for the specified BS CSS type. | kartik\base\BootstrapTrait |
getDefaultBtnCss() | Gets the default button CSS | kartik\base\BootstrapTrait |
getDefaultIconPrefix() | Gets the default icon css prefix | kartik\base\BootstrapTrait |
getDropdownClass() | Gets the respective bootstrap dropdown class name based on currently configured bootstrap version. | kartik\base\BootstrapTrait |
getId() | Returns the ID of the widget. | yii\base\Widget |
getView() | kartik\base\WidgetTrait | |
getViewPath() | Returns the directory containing the view files for this widget. | yii\base\Widget |
hasEventHandlers() | Returns a value indicating whether there is any handler attached to the named event. | yii\base\Component |
hasMethod() | Returns a value indicating whether a method is defined. | yii\base\Component |
hasProperty() | Returns a value indicating whether a property is defined for this component. | yii\base\Component |
init() | Initializes the object. | kartik\base\Widget |
initI18N() | Yii i18n messages configuration for generating translations | kartik\base\TranslationTrait |
initWidget() | Initializes the widget settings. | kartik\tabs\TabsX |
isBs() | Validate Bootstrap version | kartik\base\BootstrapTrait |
isBs4() | Validate if Bootstrap 4.x version. | kartik\base\BootstrapTrait |
off() | Detaches an existing event handler from this component. | yii\base\Component |
on() | Attaches an event handler to an event. | yii\base\Component |
registerAssets() | Registers the assets for kartik\tabs\TabsX widget. | kartik\tabs\TabsX |
registerWidgetJs() | Registers a JS code block for the widget. | kartik\base\WidgetTrait |
removeCssClass() | Removes bootstrap CSS class from options by parsing the bootstrap version for the specified Bootstrap CSS type. | kartik\base\BootstrapTrait |
render() | Renders a view. | yii\base\Widget |
renderFile() | Renders a view file. | yii\base\Widget |
run() | Executes the widget. | kartik\tabs\TabsX |
setId() | Sets the ID of the widget. | yii\base\Widget |
setView() | Sets the view object to be used by this widget. | yii\base\Widget |
trigger() | Triggers an event. | yii\base\Component |
widget() | Creates a widget instance and runs it. | yii\base\Widget |
Protected Methods
Method | Description | Defined By |
---|---|---|
activateFirstVisibleTab() | Sets the first visible tab as active. | kartik\tabs\TabsX |
addAsset() | Adds an asset to the view. | kartik\base\WidgetTrait |
configureBsVersion() | Configures the bootstrap version settings | kartik\base\BootstrapTrait |
fixPjaxDuplication() | Fix for weird PJAX container duplication behavior on pressing browser back and forward buttons. | kartik\base\WidgetTrait |
getBsExtBasename() | The yii2-bootstrap extension base name. | kartik\base\BootstrapTrait |
getCss() | Parse the CSS content to append based on condition. | kartik\tabs\TabsX |
getLabel() | Gets the label for an item configuration. | kartik\tabs\TabsX |
getPluginScript() | Returns the plugin registration script. | kartik\base\WidgetTrait |
hasActiveTab() | kartik\tabs\TabsX | |
hashPluginOptions() | Generates a hashed variable to store the pluginOptions. | kartik\base\WidgetTrait |
initBsVersion() | Initializes bootstrap versions for the widgets and asset bundles. | kartik\base\BootstrapTrait |
initDestroyJs() | Generates the pluginDestroyJs script if it is not set. |
kartik\base\WidgetTrait |
isSameVersion() | Compares two versions and checks if they are of the same major BS version. | kartik\base\BootstrapTrait |
mergeDefaultOptions() | Merge default options | kartik\base\WidgetTrait |
parseVer() | Parses and returns the major BS version | kartik\base\BootstrapTrait |
registerPlugin() | Registers a specific plugin and the related events | kartik\base\WidgetTrait |
registerPluginOptions() | Registers plugin options by storing within a uniquely generated javascript variable. | kartik\base\WidgetTrait |
renderDropdown() | Normalizes dropdown item options by removing tab specific keys content and contentOptions , and also
configure panes accordingly. |
kartik\tabs\TabsX |
renderItems() | Renders tab items as specified in $items. | kartik\tabs\TabsX |
setDataVar() | Sets a HTML5 data variable. | kartik\base\WidgetTrait |
Events
Event | Type | Description | Defined By |
---|---|---|---|
EVENT_AFTER_RUN | yii\base\WidgetEvent | An event raised right after executing a widget. (available since version 2.0.11) | yii\base\Widget |
EVENT_BEFORE_RUN | yii\base\WidgetEvent | An event raised right before executing a widget. (available since version 2.0.11) | yii\base\Widget |
EVENT_INIT | yii\base\Event | An event that is triggered when the widget is initialized via init(). (available since version 2.0.11) | yii\base\Widget |
Constants
Constant | Value | Description | Defined By |
---|---|---|---|
ALIGN_CENTER | 'center' | Tab aligned to the center | kartik\tabs\TabsX |
ALIGN_LEFT | 'left' | Tab aligned to the left | kartik\tabs\TabsX |
ALIGN_RIGHT | 'right' | Tab aligned to the right | kartik\tabs\TabsX |
POS_ABOVE | 'above' | Tabs position above | kartik\tabs\TabsX |
POS_BELOW | 'below' | Tabs position below | kartik\tabs\TabsX |
POS_LEFT | 'left' | Tabs position on left | kartik\tabs\TabsX |
POS_RIGHT | 'right' | Tabs position on right | kartik\tabs\TabsX |
Property Details
Whether the $position is set to kartik\tabs\TabsX::POS_ABOVE
Whether the $position is set to kartik\tabs\TabsX::POS_BELOW
Whether the $position is set to kartik\tabs\TabsX::POS_LEFT
Whether the $position is set to kartik\tabs\TabsX::POS_RIGHT
The alignment of the tab headers with respect to the tab content. Should be one of the TabsX::ALIGN constants.
Whether the tab content should be boxed within a bordered container.
The HTML attributes for the TabsX container.
Name of a class to use for rendering dropdowns withing this widget. Defaults to Dropdown.
Whether to enable sticky tabs plugin to maintain tabs push state on browser back and forward.
Whether the labels for header items should be HTML-encoded.
Whether to fade in each tab pane using the fade animation effect.
List of HTML attributes for the header container tags. This will be overwritten by the "headerOptions" set in individual $items.
See also yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
Whether the tab body content height should be of a fixed size. You should pass one of the
TabsX::SIZE
constants. Applicable only when position is one of kartik\tabs\TabsX::POS_ABOVE or kartik\tabs\TabsX::POS_BELOW.
Defaults to empty string (meaning dynamic height).
List of HTML attributes for the item container tags. This will be overwritten by the "options" set in individual $items. The following special options are recognized:
- tag: string, defaults to "div", the tag name of the item container tags.
See also yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
List of tabs in the tabs widget. Each array element represents a single tab with the following structure:
- label: string, required, the tab header label.
- encode: bool, optional, whether this label should be HTML-encoded. This param will override
global
$this->encodeLabels
param. - headerOptions: array, optional, the HTML attributes of the tab header.
- linkOptions: array, optional, the HTML attributes of the tab header link tags.
- content: string, optional, the content (HTML) of the tab pane.
- url: string, optional, an external URL. When this is specified, clicking on this tab will bring the browser to this URL. This option is available since version 2.0.4.
- options: array, optional, the HTML attributes of the tab pane container.
- active: bool, optional, whether this item tab header and pane should be active. If no item is marked as 'active' explicitly - the first one will be activated.
- visible: bool, optional, whether the item tab header and pane should be visible or not. Defaults to true.
- items: array, optional, can be used instead of
content
to specify a dropdown items configuration array. Each item can hold three extra keys, besides the above ones:- active: bool, optional, whether the item tab header and pane should be visible or not.
- content: string, required if
items
is not set. The content (HTML) of the tab pane. - contentOptions: optional, array, the HTML attributes of the tab content container.
List of HTML attributes for the tab header link tags. This will be overwritten by the "linkOptions" set in individual $items.
See also yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
Specifies the Bootstrap tab styling.
The position of the tabs with respect to the tab content Should be one of the TabsX::POS constants.
The crumb separator for the dropdown headers in the print view when printHeaderCrumbs
is true
Whether the headers in print view will prepend the main label to the item label in case of dropdowns.
The HTML attributes for the tab content header in print view.
Whether this tab widget should be printable.
Whether to render the tab-content
container and its content. You may set this property
to be false so that you can manually render tab-content
yourself in case your tab contents are complex.
Whether the tab header text orientation should be rotated sideways. Applicable only when position
is one of [[TabsX::POS_LEFT]] or [[TabsX::POS_RIGHT]].
Sticky tabs plugin options.
List of HTML attributes for the tab-content
container. This will always contain the CSS class tab-content
.
See also yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
Method Details
Sets the first visible tab as active.
This method activates the first tab that is visible and
not explicitly set to inactive ('active' => false
).
protected void activateFirstVisibleTab ( ) |
Parse the CSS content to append based on condition.
protected static string getCss ( $prop = '', $condition = true ) | ||
$prop | string | The css property |
$condition | boolean | The validation to append the CSS class |
return | string | The parsed CSS |
---|
Gets the label for an item configuration.
protected string getLabel ( $item = [] ) | ||
$item | array | Tabs item configuration |
throws | yii\base\InvalidConfigException |
---|
protected boolean hasActiveTab ( ) | ||
return | boolean | If there's active tab defined |
---|
Initializes the widget settings.
public void initWidget ( ) | ||
throws | yii\base\InvalidConfigException |
---|
Registers the assets for kartik\tabs\TabsX widget.
public void registerAssets ( ) |
Normalizes dropdown item options by removing tab specific keys content
and contentOptions
, and also
configure panes
accordingly.
protected boolean renderDropdown ( $itemNumber, &$items, &$panes ) | ||
$itemNumber | string | Number of the item |
$items | array | The dropdown items configuration. |
$panes | array | The panes reference array. |
return | boolean | Whether any of the dropdown items is |
---|---|---|
throws | yii\base\InvalidConfigException |
Renders tab items as specified in $items.
protected string renderItems ( ) | ||
return | string | The rendering result. |
---|---|---|
throws | yii\base\InvalidConfigException | |
throws | Exception |
Executes the widget.
public string|void run ( ) | ||
return | string|void | The rendering result may be directly "echoed" or returned as a string |
---|---|---|
throws | yii\base\InvalidConfigException |