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
70a5c5fc
Commit
70a5c5fc
authored
Aug 03, 2012
by
niskac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed an issue with navbar and collapse
parent
4ce49194
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
8 deletions
+34
-8
TbAlert.php
widgets/TbAlert.php
+3
-1
TbCollapse.php
widgets/TbCollapse.php
+12
-0
TbNavbar.php
widgets/TbNavbar.php
+19
-7
No files found.
widgets/TbAlert.php
View file @
70a5c5fc
...
...
@@ -45,6 +45,8 @@ class TbAlert extends CWidget
*/
public
$htmlOptions
=
array
();
private
static
$_containerId
=
0
;
/**
* Initializes the widget.
*/
...
...
@@ -128,7 +130,7 @@ class TbAlert extends CWidget
echo
'</div>'
;
$selector
=
"#
{
$id
}
.alert"
;
$id
.=
'_'
.
uniqid
(
true
,
true
)
;
$id
.=
'_'
.
self
::
$_containerId
++
;
/** @var CClientScript $cs */
$cs
=
Yii
::
app
()
->
getClientScript
();
...
...
widgets/TbCollapse.php
View file @
70a5c5fc
...
...
@@ -39,6 +39,8 @@ class TbCollapse extends CWidget
*/
public
$htmlOptions
=
array
();
private
static
$_containerId
=
0
;
/**
* Initializes the widget.
*/
...
...
@@ -76,5 +78,15 @@ class TbCollapse extends CWidget
$cs
->
registerScript
(
__CLASS__
.
'#'
.
$id
.
'_'
.
$name
,
"jQuery('#
{
$id
}
').on('
{
$name
}
',
{
$handler
}
);"
);
}
}
/**
* Returns the next collapse container ID.
* @return string the id
* @static
*/
public
static
function
getNextContainerId
()
{
return
'collapse_'
.
self
::
$_containerId
++
;
}
}
widgets/TbNavbar.php
View file @
70a5c5fc
...
...
@@ -8,6 +8,8 @@
* @since 0.9.7
*/
Yii
::
import
(
'bootstrap.widgets.TbCollapse'
);
/**
* Bootstrap navigation bar widget.
*/
...
...
@@ -107,14 +109,14 @@ class TbNavbar extends CWidget
*/
public
function
run
()
{
$containerCssClass
=
$this
->
fluid
?
'container-fluid'
:
'container'
;
echo
CHtml
::
openTag
(
'div'
,
$this
->
htmlOptions
);
echo
'<div class="navbar-inner"><div class="'
.
$
containerCssClass
.
'">'
;
echo
'<div class="navbar-inner"><div class="'
.
$
this
->
getContainerCssClass
()
.
'">'
;
if
(
$this
->
collapse
)
$collapseId
=
TbCollapse
::
getNextContainerId
();
if
(
$this
->
collapse
!==
false
)
{
echo
'<a class="btn btn-navbar" data-toggle="collapse" data-target="
.nav-collapse
">'
;
echo
'<a class="btn btn-navbar" data-toggle="collapse" data-target="
#'
.
$collapseId
.
'
">'
;
echo
'<span class="icon-bar"></span><span class="icon-bar"></span><span class="icon-bar"></span>'
;
echo
'</a>'
;
}
...
...
@@ -122,9 +124,10 @@ class TbNavbar extends CWidget
if
(
$this
->
brand
!==
false
)
echo
CHtml
::
openTag
(
'a'
,
$this
->
brandOptions
)
.
$this
->
brand
.
'</a>'
;
if
(
$this
->
collapse
)
if
(
$this
->
collapse
!==
false
)
{
$this
->
controller
->
beginWidget
(
'bootstrap.widgets.TbCollapse'
,
array
(
'id'
=>
$collapseId
,
'toggle'
=>
false
,
// navbars should be collapsed by default
'htmlOptions'
=>
array
(
'class'
=>
'nav-collapse'
),
));
...
...
@@ -146,9 +149,18 @@ class TbNavbar extends CWidget
}
}
if
(
$this
->
collapse
)
if
(
$this
->
collapse
!==
false
)
$this
->
controller
->
endWidget
();
echo
'</div></div></div>'
;
}
/**
* Returns the navbar container CSS class.
* @return string the class
*/
protected
function
getContainerCssClass
()
{
return
$this
->
fluid
?
'container-fluid'
:
'container'
;
}
}
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