Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Y
yii2bootstrap
Project
Project
Details
Activity
Releases
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
夏彬
yii2bootstrap
Commits
1db3f49f
Commit
1db3f49f
authored
Jan 11, 2018
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added `yii\bootstrap\Collapse::$itemToggleOptions`
parent
3ed9dcbd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
5 deletions
+66
-5
CHANGELOG.md
CHANGELOG.md
+1
-0
Collapse.php
Collapse.php
+28
-5
CollapseTest.php
tests/CollapseTest.php
+37
-0
No files found.
CHANGELOG.md
View file @
1db3f49f
...
@@ -7,6 +7,7 @@ Yii Framework 2 bootstrap extension Change Log
...
@@ -7,6 +7,7 @@ Yii Framework 2 bootstrap extension Change Log
-
Bug #126: Fixed
`yii\bootstrap\ToggleButtonGroup`
toggles dropdown for both buttons in case
`split`
is enabled (klimov-paul)
-
Bug #126: Fixed
`yii\bootstrap\ToggleButtonGroup`
toggles dropdown for both buttons in case
`split`
is enabled (klimov-paul)
-
Enh #219: Add ability to use custom HTML in navbar-header (razvanphp)
-
Enh #219: Add ability to use custom HTML in navbar-header (razvanphp)
-
Enh #171: Add ability to use a brandImage with the navbar (razvanphp)
-
Enh #171: Add ability to use a brandImage with the navbar (razvanphp)
-
Enh #227: Added
`yii\bootstrap\Collapse::$itemToggleOptions`
allowing setup custom collapse tag name and HTML options (mskayali, klimov-paul)
2.0.7 October 09, 2017
2.0.7 October 09, 2017
...
...
Collapse.php
View file @
1db3f49f
...
@@ -96,6 +96,20 @@ class Collapse extends Widget
...
@@ -96,6 +96,20 @@ class Collapse extends Widget
* @since 2.0.7
* @since 2.0.7
*/
*/
public
$autoCloseItems
=
true
;
public
$autoCloseItems
=
true
;
/**
* @var string the HTML options for the item toggle tag. Key 'tag' might be used here for the tag name specification.
* For example:
*
* ```php
* [
* 'tag' => 'div',
* 'class' => 'custom-toggle',
* ]
* ```
*
* @since 2.0.8
*/
public
$itemToggleOptions
=
[];
/**
/**
...
@@ -170,14 +184,23 @@ class Collapse extends Widget
...
@@ -170,14 +184,23 @@ class Collapse extends Widget
$header
=
Html
::
encode
(
$header
);
$header
=
Html
::
encode
(
$header
);
}
}
$
headerOptions
=
[
$
itemToggleOptions
=
array_merge
(
[
'
class'
=>
'collapse-toggle
'
,
'
tag'
=>
'a
'
,
'data-toggle'
=>
'collapse'
,
'data-toggle'
=>
'collapse'
,
];
],
$this
->
itemToggleOptions
);
Html
::
addCssClass
(
$itemToggleOptions
,
[
'widget'
=>
'collapse-toggle'
]);
if
(
$this
->
autoCloseItems
)
{
if
(
$this
->
autoCloseItems
)
{
$headerOptions
[
'data-parent'
]
=
'#'
.
$this
->
options
[
'id'
];
$itemToggleOptions
[
'data-parent'
]
=
'#'
.
$this
->
options
[
'id'
];
}
$itemToggleTag
=
ArrayHelper
::
remove
(
$itemToggleOptions
,
'tag'
,
'a'
);
if
(
$itemToggleTag
===
'a'
)
{
$headerToggle
=
Html
::
a
(
$header
,
'#'
.
$id
,
$itemToggleOptions
)
.
"
\n
"
;
}
else
{
$itemToggleOptions
[
'data-target'
]
=
'#'
.
$id
;
$headerToggle
=
Html
::
tag
(
$itemToggleTag
,
$header
,
$itemToggleOptions
)
.
"
\n
"
;
}
}
$headerToggle
=
Html
::
a
(
$header
,
'#'
.
$id
,
$headerOptions
)
.
"
\n
"
;
$header
=
Html
::
tag
(
'h4'
,
$headerToggle
,
[
'class'
=>
'panel-title'
]);
$header
=
Html
::
tag
(
'h4'
,
$headerToggle
,
[
'class'
=>
'panel-title'
]);
...
...
tests/CollapseTest.php
View file @
1db3f49f
...
@@ -238,4 +238,41 @@ HTML
...
@@ -238,4 +238,41 @@ HTML
]);
]);
$this
->
assertNotContains
(
'data-parent="'
,
$output
);
$this
->
assertNotContains
(
'data-parent="'
,
$output
);
}
}
/**
* @depends testRender
*/
public
function
testItemToggleTag
()
{
$items
=
[
[
'label'
=>
'Item 1'
,
'content'
=>
'Content 1'
,
],
[
'label'
=>
'Item 2'
,
'content'
=>
'Content 2'
,
],
];
$output
=
Collapse
::
widget
([
'items'
=>
$items
,
'itemToggleOptions'
=>
[
'tag'
=>
'span'
,
'class'
=>
'custom-toggle'
,
],
]);
$this
->
assertContains
(
'<h4 class="panel-title"><span class="custom-toggle collapse-toggle" data-toggle="collapse" '
,
$output
);
$this
->
assertNotContains
(
'<a'
,
$output
);
$output
=
Collapse
::
widget
([
'items'
=>
$items
,
'itemToggleOptions'
=>
[
'tag'
=>
'span'
,
'class'
=>
[
'widget'
=>
'custom-toggle'
],
],
]);
$this
->
assertContains
(
'<h4 class="panel-title"><span class="custom-toggle" data-toggle="collapse" '
,
$output
);
$this
->
assertNotContains
(
'collapse-toggle'
,
$output
);
}
}
}
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