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
c1b74ba9
Commit
c1b74ba9
authored
May 29, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactored Nav and NavBar.
parent
1bf739dd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
29 deletions
+17
-29
Nav.php
framework/yii/bootstrap/Nav.php
+8
-14
NavBar.php
framework/yii/bootstrap/NavBar.php
+9
-15
No files found.
framework/yii/bootstrap/Nav.php
View file @
c1b74ba9
...
...
@@ -57,14 +57,8 @@ class Nav extends Widget
* - linkOptions: array, optional, the HTML attributes of the item's link.
* - options: array, optional, the HTML attributes of the item container (LI).
* - active: boolean, optional, whether the item should be on active state or not.
* - items: array, optional, the configuration of specify the item's dropdown menu. You can optionally set this as
* a string (ie. `'items'=> Dropdown::widget(array(...))`
* - important: there is an issue with sub-dropdown menus, and as of 3.0, bootstrap won't support sub-dropdown.
*
* **Note:** Optionally, you can also use a plain string instead of an array element.
*
* @see https://github.com/twitter/bootstrap/issues/5050#issuecomment-11741727
* @see [[Dropdown]]
* - dropdown: array|string, optional, the configuration array for creating a [[Dropdown]] widget,
* or a string representing the dropdown menu. Note that Bootstrap does not support sub-dropdown menus.
*/
public
$items
=
array
();
/**
...
...
@@ -120,7 +114,7 @@ class Nav extends Widget
}
$label
=
$this
->
encodeLabels
?
Html
::
encode
(
$item
[
'label'
])
:
$item
[
'label'
];
$options
=
ArrayHelper
::
getValue
(
$item
,
'options'
,
array
());
$dropdown
=
ArrayHelper
::
getValue
(
$item
,
'
items
'
);
$dropdown
=
ArrayHelper
::
getValue
(
$item
,
'
dropdown
'
);
$url
=
Html
::
url
(
ArrayHelper
::
getValue
(
$item
,
'url'
,
'#'
));
$linkOptions
=
ArrayHelper
::
getValue
(
$item
,
'linkOptions'
,
array
());
...
...
@@ -133,11 +127,12 @@ class Nav extends Widget
$this
->
addCssClass
(
$options
,
'dropdown'
);
$this
->
addCssClass
(
$urlOptions
,
'dropdown-toggle'
);
$label
.=
' '
.
Html
::
tag
(
'b'
,
''
,
array
(
'class'
=>
'caret'
));
$dropdown
=
is_string
(
$dropdown
)
?
$dropdown
:
Dropdown
::
widget
(
array
(
'items'
=>
$item
[
'items'
],
'clientOptions'
=>
false
));
if
(
is_array
(
$dropdown
))
{
$dropdown
[
'clientOptions'
]
=
false
;
$dropdown
=
Dropdown
::
widget
(
$dropdown
);
}
}
return
Html
::
tag
(
'li'
,
Html
::
a
(
$label
,
$url
,
$linkOptions
)
.
$dropdown
,
$options
);
}
}
\ No newline at end of file
}
framework/yii/bootstrap/NavBar.php
View file @
c1b74ba9
...
...
@@ -73,7 +73,7 @@ class NavBar extends Widget
* @param array|string $url the URL for the brand's hyperlink tag. This parameter will be processed by [[Html::url()]]
* and will be used for the "href" attribute of the brand link. Defaults to site root.
*/
public
$brand
Route
=
'/'
;
public
$brand
Url
=
'/'
;
/**
* @var array the HTML attributes of the brand link.
*/
...
...
@@ -98,10 +98,6 @@ class NavBar extends Widget
* Optionally, you can also use a plain string instead of an array element.
*/
public
$items
=
array
();
/**
* @var string the generated brand url if specified by [[brandLabel]]
*/
protected
$brand
;
/**
...
...
@@ -113,7 +109,6 @@ class NavBar extends Widget
$this
->
clientOptions
=
false
;
$this
->
addCssClass
(
$this
->
options
,
'navbar'
);
$this
->
addCssClass
(
$this
->
brandOptions
,
'brand'
);
$this
->
brand
=
Html
::
a
(
$this
->
brandLabel
,
$this
->
brandRoute
,
$this
->
brandOptions
);
}
/**
...
...
@@ -124,7 +119,7 @@ class NavBar extends Widget
echo
Html
::
beginTag
(
'div'
,
$this
->
options
);
echo
$this
->
renderItems
();
echo
Html
::
endTag
(
'div'
);
$this
->
getView
()
->
registerAssetBundle
(
'yii/bootstrap'
);
$this
->
getView
()
->
registerAssetBundle
(
self
::
$responsive
?
'yii/bootstrap/responsive'
:
'yii/bootstrap'
);
}
/**
...
...
@@ -138,17 +133,17 @@ class NavBar extends Widget
$items
[]
=
$this
->
renderItem
(
$item
);
}
$contents
=
implode
(
"
\n
"
,
$items
);
if
(
self
::
$responsive
===
true
)
{
$brand
=
Html
::
a
(
$this
->
brandLabel
,
$this
->
brandUrl
,
$this
->
brandOptions
);
if
(
self
::
$responsive
)
{
$this
->
getView
()
->
registerAssetBundle
(
'yii/bootstrap/collapse'
);
$contents
=
Html
::
tag
(
'div'
,
$contents
=
Html
::
tag
(
'div'
,
$this
->
renderToggleButton
()
.
$
this
->
brand
.
"
\n
"
.
$brand
.
"
\n
"
.
Html
::
tag
(
'div'
,
$contents
,
array
(
'class'
=>
'nav-collapse collapse navbar-collapse'
)),
array
(
'class'
=>
'container'
));
}
else
{
$contents
=
$
this
->
brand
.
"
\n
"
.
$contents
;
$contents
=
$brand
.
"
\n
"
.
$contents
;
}
return
Html
::
tag
(
'div'
,
$contents
,
array
(
'class'
=>
'navbar-inner'
));
...
...
@@ -190,4 +185,4 @@ class NavBar extends Widget
'data-target'
=>
'div.navbar-collapse'
,
));
}
}
\ No newline at end of file
}
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