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
489633b3
Commit
489633b3
authored
May 26, 2013
by
Alexander Kochetov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introducing items
parent
d2403ebf
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
6 deletions
+39
-6
Sortable.php
framework/yii/jui/Sortable.php
+39
-6
No files found.
framework/yii/jui/Sortable.php
View file @
489633b3
...
...
@@ -15,18 +15,34 @@ use yii\helpers\Html;
* For example:
*
* ```php
* echo Sortable::widget(array(
* 'items' => array(
* '<li>Item 1</li>',
* '<li>Item 2</li>',
* '<li>Item 3</li>',
* ),
* 'clientOptions' => array(
* 'cursor' => 'move',
* ),
* ));
* ```
*
* The following example will show the content enclosed between the [[begin()]]
* and [[end()]] calls within the sortable widget:
*
* ```php
* Sortable::begin(array(
* 'clientOptions' => array(
* 'cursor' => 'move',
* ),
* 'options' => array(
* 'tag' => '
ul
',
* 'tag' => '
div
',
* ),
* ));
*
* echo '<
li>Item 1</li
>';
* echo '<
li>Item 2</li
>';
* echo '<
li>Item 3</li
>';
* echo '<
div>Item 1</div
>';
* echo '<
div>Item 2</div
>';
* echo '<
div>Item 3</div
>';
*
* Sortable::end();
* ```
...
...
@@ -38,13 +54,20 @@ use yii\helpers\Html;
class
Sortable
extends
Widget
{
/**
* @var array list of sortable containers. Each array element represents a single
* sortable container.
*/
public
$items
=
array
();
/**
* Initializes the widget.
*/
public
function
init
()
{
parent
::
init
();
$options
=
$this
->
options
;
$tag
=
isset
(
$options
[
'tag'
])
?
$options
[
'tag'
]
:
'
div
'
;
$tag
=
isset
(
$options
[
'tag'
])
?
$options
[
'tag'
]
:
'
ul
'
;
unset
(
$options
[
'tag'
]);
echo
Html
::
beginTag
(
$tag
,
$options
)
.
"
\n
"
;
}
...
...
@@ -54,7 +77,17 @@ class Sortable extends Widget
*/
public
function
run
()
{
echo
Html
::
endTag
(
isset
(
$this
->
options
[
'tag'
])
?
$this
->
options
[
'tag'
]
:
'div'
)
.
"
\n
"
;
echo
$this
->
renderItems
()
.
"
\n
"
;
echo
Html
::
endTag
(
isset
(
$this
->
options
[
'tag'
])
?
$this
->
options
[
'tag'
]
:
'ul'
)
.
"
\n
"
;
$this
->
registerWidget
(
'sortable'
,
false
);
}
/**
* Renders sortable items as specified on [[items]].
* @return string the rendering result
*/
public
function
renderItems
()
{
return
implode
(
"
\n
"
,
$this
->
items
);
}
}
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