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
ca5b8745
Commit
ca5b8745
authored
Dec 06, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes #5494: Added support for specifying a menu header as a configuration array…
Fixes #5494: Added support for specifying a menu header as a configuration array in `yii\bootstrap\Dropdown`
parent
7929ac6f
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
21 deletions
+28
-21
widget-jui.md
docs/guide/widget-jui.md
+2
-3
CHANGELOG.md
extensions/bootstrap/CHANGELOG.md
+1
-0
Dropdown.php
extensions/bootstrap/Dropdown.php
+24
-17
CHANGELOG.md
framework/CHANGELOG.md
+1
-0
MenuTest.php
tests/unit/framework/widgets/MenuTest.php
+0
-1
No files found.
docs/guide/widget-jui.md
View file @
ca5b8745
...
...
@@ -3,7 +3,7 @@ Jquery UI Widgets
> Note: This section is under development.
Yii includes support for the
[
jQuery UI
](
http://api.jqueryui.com/
)
library in an offic
ai
l extension. jQuery UI is
Yii includes support for the
[
jQuery UI
](
http://api.jqueryui.com/
)
library in an offic
ia
l extension. jQuery UI is
a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library.
Installation
...
...
@@ -45,4 +45,4 @@ framework features. All widgets belong to `\yii\jui` namespace:
-
[
[yii\jui\SliderInput|SliderInput
]
]
-
[
[yii\jui\Sortable|Sortable
]
]
-
[
[yii\jui\Spinner|Spinner
]
]
-
[
[yii\jui\Tabs|Tabs
]
]
\ No newline at end of file
-
[
[yii\jui\Tabs|Tabs
]
]
extensions/bootstrap/CHANGELOG.md
View file @
ca5b8745
...
...
@@ -9,6 +9,7 @@ Yii Framework 2 bootstrap extension Change Log
-
Enh #4146: Added
`yii\bootstrap\ButtonDropdown::$containerOptions`
(samdark)
-
Enh #4181: Added
`yii\bootstrap\Modal::$headerOptions`
and
`yii\bootstrap\Modal::$footerOptions`
(tuxoff, samdark)
-
Enh #4450: Added
`yii\bootstrap\Nav::renderDropdown()`
(qiangxue)
-
Enh #5494: Added support for specifying a menu header as a configuration array in
`yii\bootstrap\Dropdown`
(hiltonjanfield, qiangxue)
-
Enh #5735: Added
`yii\bootstrap\Tabs::renderTabContent`
to support manually rendering tab contents (RomeroMsk)
-
Enh #5799:
`yii\bootstrap\ButtonGroup::buttons`
can take all options that are supported by
`yii\bootstrap\Button`
(aleksanderd)
-
Chg #5874: Upgraded Twitter Bootstrap to 3.3.x (samdark)
...
...
extensions/bootstrap/Dropdown.php
View file @
ca5b8745
...
...
@@ -10,6 +10,7 @@ namespace yii\bootstrap;
use
yii\base\InvalidConfigException
;
use
yii\helpers\ArrayHelper
;
use
yii\helpers\Html
;
use
yii\helpers\Url
;
/**
* Dropdown renders a Bootstrap dropdown menu component.
...
...
@@ -25,7 +26,8 @@ class Dropdown extends Widget
* or an array representing a single menu with the following structure:
*
* - label: string, required, the label of the item link
* - url: string, optional, the url of the item link. Defaults to "#".
* - url: string|array, optional, the url of the item link. This will be processed by [[Url::to()]].
* If not set, the item will be treated as a menu header when the item has no sub-menu.
* - visible: boolean, optional, whether this menu item is visible. Defaults to true.
* - linkOptions: array, optional, the HTML attributes of the item link.
* - options: array, optional, the HTML attributes of the item.
...
...
@@ -40,11 +42,6 @@ class Dropdown extends Widget
*/
public
$encodeLabels
=
true
;
/**
* @var array the HTML attributes for the widget container tag.
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
protected
$_containerOptions
=
[];
/**
* Initializes the widget.
...
...
@@ -54,7 +51,6 @@ class Dropdown extends Widget
{
parent
::
init
();
Html
::
addCssClass
(
$this
->
options
,
'dropdown-menu'
);
$this
->
_containerOptions
=
$this
->
options
;
}
/**
...
...
@@ -62,17 +58,18 @@ class Dropdown extends Widget
*/
public
function
run
()
{
echo
$this
->
renderItems
(
$this
->
items
);
echo
$this
->
renderItems
(
$this
->
items
,
$this
->
options
);
BootstrapPluginAsset
::
register
(
$this
->
getView
());
}
/**
* Renders menu items.
* @param array $items the menu items to be rendered
* @param array $options the container HTML attributes
* @return string the rendering result.
* @throws InvalidConfigException if the label option is not specified in one of the items.
*/
protected
function
renderItems
(
$items
)
protected
function
renderItems
(
$items
,
$options
=
[]
)
{
$lines
=
[];
foreach
(
$items
as
$i
=>
$item
)
{
...
...
@@ -89,18 +86,28 @@ class Dropdown extends Widget
}
$encodeLabel
=
isset
(
$item
[
'encode'
])
?
$item
[
'encode'
]
:
$this
->
encodeLabels
;
$label
=
$encodeLabel
?
Html
::
encode
(
$item
[
'label'
])
:
$item
[
'label'
];
$
o
ptions
=
ArrayHelper
::
getValue
(
$item
,
'options'
,
[]);
$
itemO
ptions
=
ArrayHelper
::
getValue
(
$item
,
'options'
,
[]);
$linkOptions
=
ArrayHelper
::
getValue
(
$item
,
'linkOptions'
,
[]);
$linkOptions
[
'tabindex'
]
=
'-1'
;
$content
=
Html
::
a
(
$label
,
ArrayHelper
::
getValue
(
$item
,
'url'
,
'#'
),
$linkOptions
);
if
(
!
empty
(
$item
[
'items'
]))
{
unset
(
$this
->
_containerOptions
[
'id'
]);
$content
.=
$this
->
renderItems
(
$item
[
'items'
]);
Html
::
addCssClass
(
$options
,
'dropdown-submenu'
);
$url
=
array_key_exists
(
'url'
,
$item
)
?
$item
[
'url'
]
:
null
;
if
(
empty
(
$item
[
'items'
]))
{
if
(
$url
===
null
)
{
$content
=
$label
;
Html
::
addCssClass
(
$itemOptions
,
'dropdown-header'
);
}
else
{
$content
=
Html
::
a
(
$label
,
$url
,
$linkOptions
);
}
}
else
{
$submenuOptions
=
$options
;
unset
(
$submenuOptions
[
'id'
]);
$content
=
Html
::
a
(
$label
,
$url
===
null
?
'#'
:
$url
,
$linkOptions
)
.
$this
->
renderItems
(
$item
[
'items'
],
$submenuOptions
);
Html
::
addCssClass
(
$itemOptions
,
'dropdown-submenu'
);
}
$lines
[]
=
Html
::
tag
(
'li'
,
$content
,
$options
);
$lines
[]
=
Html
::
tag
(
'li'
,
$content
,
$itemOptions
);
}
return
Html
::
tag
(
'ul'
,
implode
(
"
\n
"
,
$lines
),
$
this
->
_containerO
ptions
);
return
Html
::
tag
(
'ul'
,
implode
(
"
\n
"
,
$lines
),
$
o
ptions
);
}
}
framework/CHANGELOG.md
View file @
ca5b8745
...
...
@@ -63,6 +63,7 @@ Yii Framework 2 Change Log
-
Enh #5223: Query builder now supports selecting sub-queries as columns (qiangxue)
-
Enh #5367: Added
`yii\grid\DataColumn::encodeLabel`
(SDKiller)
-
Enh #5480: Added defensive code to
`yii\web\User::getIdentity()`
to avoid potential infinite recursion (qiangxue)
-
Enh #5494: Added support for specifying a menu header as a configuration array in
`yii\bootstrap\Dropdown`
(hiltonjanfield, qiangxue)
-
Enh #5503: Added support for
`DateTimeImmutable`
to Formatter (olegtsvetkov, cebe)
-
Enh #5587:
`json_encode`
is now used with
`JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE`
where it makes sense, also
it is now default for
`Json::encode()`
(samdark)
...
...
tests/unit/framework/widgets/MenuTest.php
View file @
ca5b8745
...
...
@@ -3,7 +3,6 @@
namespace
yiiunit\framework\widgets
;
use
yii\widgets\Menu
;
use
yii\widgets\Spaceless
;
/**
* @group widgets
...
...
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