Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F5978583
StackLayout.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
StackLayout.php
View Options
<?php
namespace
OOUI
;
/**
* StackLayouts contain a series of PanelLayouts
*/
class
StackLayout
extends
PanelLayout
{
use
GroupElement
;
/** @var bool */
protected
$continuous
;
/** @var PanelLayout|null */
protected
$currentItem
;
/**
* @param array $config Configuration options
* - bool $config['continuous'] Show all panels, one after another (default: false)
* - PanelLayout[] $config['items'] Panel layouts to add to the stack layout.
*/
public
function
__construct
(
array
$config
=
[]
)
{
$config
=
array_merge
(
[
'preserveContent'
=>
false
,
'scrollable'
=>
$config
[
'continuous'
]
??
false
],
$config
);
// Parent constructor
parent
::
__construct
(
$config
);
// Properties
$this
->
continuous
=
$config
[
'continuous'
]
??
false
;
// Traits
$this
->
initializeGroupElement
(
array_merge
(
$config
,
[
'group'
=>
$this
]
)
);
// Initialization
$this
->
addClasses
(
[
'oo-ui-stackLayout'
]
);
if
(
$this
->
continuous
)
{
$this
->
addClasses
(
[
'oo-ui-stackLayout-continuous'
]
);
}
$this
->
addItems
(
$config
[
'items'
]
??
[]
);
}
/**
* @param PanelLayout|null $item
*/
public
function
setItem
(
$item
)
{
if
(
$item
!==
$this
->
currentItem
)
{
$items
=
$this
->
getItems
();
$this
->
updateHiddenState
(
$items
,
$item
);
$this
->
currentItem
=
$item
;
}
}
/**
* @param Element[] $items
* @param PanelLayout|null $selectedItem
*/
private
function
updateHiddenState
(
$items
,
$selectedItem
)
{
if
(
!
$this
->
continuous
)
{
foreach
(
$items
as
$item
)
{
if
(
!
$selectedItem
||
$selectedItem
!==
$item
)
{
$item
->
toggle
(
false
);
$item
->
setAttributes
(
[
'aria-hidden'
=>
'true'
]
);
}
}
if
(
$selectedItem
)
{
$selectedItem
->
toggle
(
true
);
$selectedItem
->
removeAttributes
(
[
'aria-hidden'
]
);
}
}
}
/** @inheritDoc */
public
function
getConfig
(
&
$config
)
{
$config
=
parent
::
getConfig
(
$config
);
if
(
$this
->
continuous
)
{
$config
[
'continuous'
]
=
$this
->
continuous
;
// scrollable default has changed to true
if
(
!
$this
->
hasClass
(
'oo-ui-panelLayout-scrollable'
)
)
{
$config
[
'scrollable'
]
=
false
;
}
else
{
unset
(
$config
[
'scrollable'
]
);
}
}
return
$config
;
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, Oct 3, 20:28 (3 d, 20 h ago)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
b8/d5/d90cfa3287cfbaf8a05c8a519134
Default Alt Text
StackLayout.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment