Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
aad5c84f
Commit
aad5c84f
authored
May 26, 2013
by
Alexander Kochetov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
jQuery UI accordion rework
parent
9d46f8e4
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
25 deletions
+26
-25
Accordion.php
framework/yii/jui/Accordion.php
+26
-25
No files found.
framework/yii/jui/Accordion.php
View file @
aad5c84f
...
@@ -40,23 +40,20 @@ use yii\helpers\Html;
...
@@ -40,23 +40,20 @@ use yii\helpers\Html;
class
Accordion
extends
Widget
class
Accordion
extends
Widget
{
{
/**
/**
* @var array list of sections in the accordion widget. Each array element represents a single
* @var array.
* section with the following structure:
* @todo comments.
*
* ```php
* array(
* // required, the header (HTML) of the section
* 'header' => 'Section label',
* // required, the content (HTML) of the section
* 'content' => 'Mauris mauris ante, blandit et, ultrices a, suscipit eget...',
* // optional the HTML attributes of the section content container
* 'options'=> array(...),
* // optional the HTML attributes of the section header container
* 'headerOptions'=> array(...),
* )
* ```
*/
*/
public
$items
=
array
();
public
$items
=
array
();
/**
* @var array.
* @todo comments.
*/
public
$itemOptions
=
array
();
/**
* @var array.
* @todo comments.
*/
public
$headerOptions
=
array
();
/**
/**
...
@@ -64,9 +61,11 @@ class Accordion extends Widget
...
@@ -64,9 +61,11 @@ class Accordion extends Widget
*/
*/
public
function
run
()
public
function
run
()
{
{
echo
Html
::
beginTag
(
'div'
,
$this
->
options
)
.
"
\n
"
;
$options
=
$this
->
options
;
echo
$this
->
renderSections
()
.
"
\n
"
;
$tag
=
ArrayHelper
::
remove
(
$options
,
'tag'
,
'div'
);
echo
Html
::
endTag
(
'div'
)
.
"
\n
"
;
echo
Html
::
beginTag
(
$tag
,
$options
)
.
"
\n
"
;
echo
$this
->
renderItems
()
.
"
\n
"
;
echo
Html
::
endTag
(
$tag
)
.
"
\n
"
;
$this
->
registerWidget
(
'accordion'
);
$this
->
registerWidget
(
'accordion'
);
}
}
...
@@ -75,9 +74,9 @@ class Accordion extends Widget
...
@@ -75,9 +74,9 @@ class Accordion extends Widget
* @return string the rendering result.
* @return string the rendering result.
* @throws InvalidConfigException.
* @throws InvalidConfigException.
*/
*/
protected
function
render
Section
s
()
protected
function
render
Item
s
()
{
{
$
section
s
=
array
();
$
item
s
=
array
();
foreach
(
$this
->
items
as
$item
)
{
foreach
(
$this
->
items
as
$item
)
{
if
(
!
isset
(
$item
[
'header'
]))
{
if
(
!
isset
(
$item
[
'header'
]))
{
throw
new
InvalidConfigException
(
"The 'header' option is required."
);
throw
new
InvalidConfigException
(
"The 'header' option is required."
);
...
@@ -85,12 +84,14 @@ class Accordion extends Widget
...
@@ -85,12 +84,14 @@ class Accordion extends Widget
if
(
!
isset
(
$item
[
'content'
]))
{
if
(
!
isset
(
$item
[
'content'
]))
{
throw
new
InvalidConfigException
(
"The 'content' option is required."
);
throw
new
InvalidConfigException
(
"The 'content' option is required."
);
}
}
$headerOptions
=
ArrayHelper
::
getValue
(
$item
,
'headerOptions'
,
array
());
$headerOptions
=
array_merge
(
$this
->
headerOptions
,
ArrayHelper
::
getValue
(
$item
,
'headerOptions'
,
array
()));
$sections
[]
=
Html
::
tag
(
'h3'
,
$item
[
'header'
],
$headerOptions
);
$headerTag
=
ArrayHelper
::
remove
(
$headerOptions
,
'tag'
,
ArrayHelper
::
remove
(
$headerOptions
,
'tag'
,
'h3'
));
$options
=
ArrayHelper
::
getValue
(
$item
,
'options'
,
array
());
$items
[]
=
Html
::
tag
(
$headerTag
,
$item
[
'header'
],
$headerOptions
);
$sections
[]
=
Html
::
tag
(
'div'
,
$item
[
'content'
],
$options
);;
$options
=
array_merge
(
$this
->
itemOptions
,
ArrayHelper
::
getValue
(
$item
,
'options'
,
array
()));
$tag
=
ArrayHelper
::
remove
(
$options
,
'tag'
,
ArrayHelper
::
remove
(
$options
,
'tag'
,
'div'
));
$items
[]
=
Html
::
tag
(
$tag
,
$item
[
'content'
],
$options
);;
}
}
return
implode
(
"
\n
"
,
$
section
s
);
return
implode
(
"
\n
"
,
$
item
s
);
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment