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
cc7c6c7a
Commit
cc7c6c7a
authored
May 20, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactored Modal.
parent
7a1e4e62
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
40 deletions
+55
-40
Modal.php
yii/bootstrap/Modal.php
+55
-40
No files found.
yii/bootstrap/Modal.php
View file @
cc7c6c7a
...
@@ -102,34 +102,12 @@ class Modal extends Widget
...
@@ -102,34 +102,12 @@ class Modal extends Widget
{
{
parent
::
init
();
parent
::
init
();
$this
->
options
=
array_merge
(
array
(
$this
->
initOptions
();
'class'
=>
'modal hide'
,
),
$this
->
options
);
$this
->
addCssClass
(
$this
->
options
,
'modal'
);
$this
->
pluginOptions
=
array_merge
(
array
(
'show'
=>
false
,
),
$this
->
pluginOptions
);
if
(
$this
->
closeButton
!==
null
)
{
$this
->
closeButton
=
array_merge
(
array
(
'data-dismiss'
=>
'modal'
,
'aria-hidden'
=>
'true'
,
'class'
=>
'close'
,
),
$this
->
closeButton
);
}
if
(
$this
->
toggleButton
!==
null
)
{
echo
$this
->
renderToggleButton
()
.
"
\n
"
;
$this
->
toggleButton
=
array_merge
(
array
(
echo
Html
::
beginTag
(
'div'
,
$this
->
options
)
.
"
\n
"
;
'data-toggle'
=>
'modal'
,
echo
$this
->
renderHeader
()
.
"
\n
"
;
),
$this
->
toggleButton
);
echo
$this
->
renderBodyBegin
()
.
"
\n
"
;
if
(
!
isset
(
$this
->
toggleButton
[
'data-target'
])
&&
!
isset
(
$this
->
toggleButton
[
'href'
]))
{
$this
->
toggleButton
[
'data-target'
]
=
'#'
.
$this
->
options
[
'id'
];
}
}
ob_start
();
ob_implicit_flush
(
false
);
}
}
/**
/**
...
@@ -137,14 +115,9 @@ class Modal extends Widget
...
@@ -137,14 +115,9 @@ class Modal extends Widget
*/
*/
public
function
run
()
public
function
run
()
{
{
$this
->
body
=
ob_get_clean
()
.
$this
->
body
;
echo
"
\n
"
.
$this
->
renderBodyEnd
();
echo
"
\n
"
.
$this
->
renderFooter
();
echo
$this
->
renderToggleButton
();
echo
"
\n
"
.
Html
::
endTag
(
'div'
);
$html
=
$this
->
renderHeader
()
.
"
\n
"
.
$this
->
renderBody
()
.
"
\n
"
.
$this
->
renderFooter
();
echo
Html
::
tag
(
'div'
,
"
\n
"
.
$html
.
"
\n
"
,
$this
->
options
);
$this
->
registerPlugin
(
'modal'
);
$this
->
registerPlugin
(
'modal'
);
}
}
...
@@ -167,12 +140,21 @@ class Modal extends Widget
...
@@ -167,12 +140,21 @@ class Modal extends Widget
}
}
/**
/**
* Renders the
HTML markup for the body of the modal
* Renders the
opening tag of the modal body.
* @return string the rendering result
* @return string the rendering result
*/
*/
protected
function
renderBody
()
protected
function
renderBody
Begin
()
{
{
return
Html
::
tag
(
'div'
,
$this
->
body
,
array
(
'class'
=>
'modal-body'
));
return
Html
::
beginTag
(
'div'
,
array
(
'class'
=>
'modal-body'
));
}
/**
* Renders the closing tag of the modal body.
* @return string the rendering result
*/
protected
function
renderBodyEnd
()
{
return
$this
->
body
.
"
\n
"
.
Html
::
endTag
(
'div'
);
}
}
/**
/**
...
@@ -182,7 +164,7 @@ class Modal extends Widget
...
@@ -182,7 +164,7 @@ class Modal extends Widget
protected
function
renderFooter
()
protected
function
renderFooter
()
{
{
if
(
$this
->
footer
!==
null
)
{
if
(
$this
->
footer
!==
null
)
{
return
Html
::
tag
(
'div'
,
$this
->
footer
,
array
(
'class'
=>
'modal-footer'
));
return
Html
::
tag
(
'div'
,
"
\n
"
.
$this
->
footer
.
"
\n
"
,
array
(
'class'
=>
'modal-footer'
));
}
else
{
}
else
{
return
null
;
return
null
;
}
}
...
@@ -200,7 +182,7 @@ class Modal extends Widget
...
@@ -200,7 +182,7 @@ class Modal extends Widget
if
(
$tag
===
'button'
&&
!
isset
(
$this
->
toggleButton
[
'type'
]))
{
if
(
$tag
===
'button'
&&
!
isset
(
$this
->
toggleButton
[
'type'
]))
{
$this
->
toggleButton
[
'type'
]
=
'button'
;
$this
->
toggleButton
[
'type'
]
=
'button'
;
}
}
return
Html
::
tag
(
$tag
,
$label
,
$this
->
toggleButton
)
.
"
\n
"
;
return
Html
::
tag
(
$tag
,
$label
,
$this
->
toggleButton
);
}
else
{
}
else
{
return
null
;
return
null
;
}
}
...
@@ -223,4 +205,37 @@ class Modal extends Widget
...
@@ -223,4 +205,37 @@ class Modal extends Widget
return
null
;
return
null
;
}
}
}
}
/**
* Initializes the widget options.
* This method sets the default values for various options.
*/
protected
function
initOptions
()
{
$this
->
options
=
array_merge
(
array
(
'class'
=>
'modal hide'
,
),
$this
->
options
);
$this
->
addCssClass
(
$this
->
options
,
'modal'
);
$this
->
pluginOptions
=
array_merge
(
array
(
'show'
=>
false
,
),
$this
->
pluginOptions
);
if
(
$this
->
closeButton
!==
null
)
{
$this
->
closeButton
=
array_merge
(
array
(
'data-dismiss'
=>
'modal'
,
'aria-hidden'
=>
'true'
,
'class'
=>
'close'
,
),
$this
->
closeButton
);
}
if
(
$this
->
toggleButton
!==
null
)
{
$this
->
toggleButton
=
array_merge
(
array
(
'data-toggle'
=>
'modal'
,
),
$this
->
toggleButton
);
if
(
!
isset
(
$this
->
toggleButton
[
'data-target'
])
&&
!
isset
(
$this
->
toggleButton
[
'href'
]))
{
$this
->
toggleButton
[
'data-target'
]
=
'#'
.
$this
->
options
[
'id'
];
}
}
}
}
}
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