Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
Yii Bootstrap 3
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
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Common
Yii Bootstrap 3
Commits
2d3271c4
Commit
2d3271c4
authored
Jul 29, 2012
by
Crisu83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added support for dropups
parent
5083ed79
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
62 additions
and
4 deletions
+62
-4
TbButtonGroup.php
widgets/TbButtonGroup.php
+33
-4
TbMenu.php
widgets/TbMenu.php
+29
-0
No files found.
widgets/TbButtonGroup.php
View file @
2d3271c4
...
...
@@ -56,15 +56,24 @@ class TbButtonGroup extends CWidget
*/
public
function
init
()
{
$classes
=
'btn-group'
;
$classes
=
array
(
'btn-group'
);
foreach
(
$this
->
buttons
as
$button
)
{
if
(
$this
->
hasDropdown
(
$button
)
&&
$this
->
isDropup
(
$button
))
{
$classes
[]
=
'dropup'
;
break
;
}
}
$classes
=
implode
(
' '
,
$classes
);
if
(
isset
(
$this
->
htmlOptions
[
'class'
]))
$this
->
htmlOptions
[
'class'
]
.=
' '
.
$classes
;
else
$this
->
htmlOptions
[
'class'
]
=
$classes
;
$validToggles
=
array
(
self
::
TOGGLE_CHECKBOX
,
self
::
TOGGLE_RADIO
);
if
(
isset
(
$this
->
toggle
)
&&
in_array
(
$this
->
toggle
,
$validToggles
))
if
(
isset
(
$this
->
toggle
)
&&
in_array
(
$this
->
toggle
,
array
(
self
::
TOGGLE_CHECKBOX
,
self
::
TOGGLE_RADIO
)))
$this
->
htmlOptions
[
'data-toggle'
]
=
'buttons-'
.
$this
->
toggle
;
}
...
...
@@ -97,4 +106,24 @@ class TbButtonGroup extends CWidget
echo
'</div>'
;
}
/**
* Returns whether the given button has a dropdown.
* @param array $button the button configuration
* @return boolean the result
*/
protected
function
hasDropdown
(
$button
)
{
return
isset
(
$button
[
'items'
])
&&
!
empty
(
$button
[
'items'
]);
}
/**
* Returns whether the given item is a dropup.
* @param array $button the button configuration
* @return boolean the result
*/
protected
function
isDropup
(
$button
)
{
return
isset
(
$button
[
'dropup'
])
&&
$button
[
'dropup'
]
===
true
;
}
}
widgets/TbMenu.php
View file @
2d3271c4
...
...
@@ -46,6 +46,15 @@ class TbMenu extends TbBaseMenu
if
(
$this
->
type
!==
self
::
TYPE_LIST
&&
$this
->
stacked
)
$classes
[]
=
'nav-stacked'
;
foreach
(
$this
->
items
as
$item
)
{
if
(
$this
->
hasDropdown
(
$item
)
&&
$this
->
isDropup
(
$item
))
{
$classes
[]
=
'dropup'
;
break
;
}
}
$classes
=
implode
(
' '
,
$classes
);
if
(
isset
(
$this
->
htmlOptions
[
'class'
]))
$this
->
htmlOptions
[
'class'
]
.=
' '
.
$classes
;
...
...
@@ -65,6 +74,26 @@ class TbMenu extends TbBaseMenu
}
/**
* Returns whether the given item has a dropdown.
* @param array $item the item configuration
* @return boolean the result
*/
protected
function
hasDropdown
(
$item
)
{
return
isset
(
$item
[
'items'
])
&&
!
empty
(
$item
[
'items'
]);
}
/**
* Returns whether the given item is a dropup.
* @param array $item the item configuration
* @return boolean the result
*/
protected
function
isDropup
(
$item
)
{
return
isset
(
$item
[
'dropup'
])
&&
$item
[
'dropup'
]
===
true
;
}
/**
* Returns the divider css class.
* @return string the class name
*/
...
...
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