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
2e203f17
Commit
2e203f17
authored
Mar 08, 2012
by
niskac
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added support for additional button callbacks
parent
f4f92f23
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
21 deletions
+37
-21
index.php
demo/protected/views/site/index.php
+4
-4
BootButton.php
widgets/BootButton.php
+29
-13
BootButtonGroup.php
widgets/BootButtonGroup.php
+4
-4
No files found.
demo/protected/views/site/index.php
View file @
2e203f17
...
@@ -1113,7 +1113,7 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
...
@@ -1113,7 +1113,7 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
<p>
<p>
<?php
$this
->
widget
(
'bootstrap.widgets.BootButton'
,
array
(
<?php
$this
->
widget
(
'bootstrap.widgets.BootButton'
,
array
(
'
method
'
=>
'button'
,
'
fn
'
=>
'button'
,
'type'
=>
'primary'
,
'type'
=>
'primary'
,
'label'
=>
'Click me'
,
'label'
=>
'Click me'
,
'loadingText'
=>
'loading...'
,
'loadingText'
=>
'loading...'
,
...
@@ -1136,7 +1136,7 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
...
@@ -1136,7 +1136,7 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
<?php
echo
$parser
->
safeTransform
(
"~~~
<?php
echo
$parser
->
safeTransform
(
"~~~
[php]
[php]
<?php
\$
this->widget('bootstrap.widgets.BootButton', array(
<?php
\$
this->widget('bootstrap.widgets.BootButton', array(
'
method
'=>'button',
'
fn
'=>'button',
'type'=>'primary',
'type'=>'primary',
'label'=>'Click me',
'label'=>'Click me',
'loadingText'=>'loading...',
'loadingText'=>'loading...',
...
@@ -1159,7 +1159,7 @@ $('#buttonStateful').click(function() {
...
@@ -1159,7 +1159,7 @@ $('#buttonStateful').click(function() {
<p>
<p>
<?php
$this
->
widget
(
'bootstrap.widgets.BootButton'
,
array
(
<?php
$this
->
widget
(
'bootstrap.widgets.BootButton'
,
array
(
'
method
'
=>
'button'
,
'
fn
'
=>
'button'
,
'type'
=>
'primary'
,
'type'
=>
'primary'
,
'label'
=>
'Toggle me'
,
'label'
=>
'Toggle me'
,
'toggle'
=>
true
,
'toggle'
=>
true
,
...
@@ -1171,7 +1171,7 @@ $('#buttonStateful').click(function() {
...
@@ -1171,7 +1171,7 @@ $('#buttonStateful').click(function() {
<?php
echo
$parser
->
safeTransform
(
"~~~
<?php
echo
$parser
->
safeTransform
(
"~~~
[php]
[php]
<?php
\$
this->widget('bootstrap.widgets.BootButton', array(
<?php
\$
this->widget('bootstrap.widgets.BootButton', array(
'
method
'=>'button',
'
fn
'=>'button',
'type'=>'primary',
'type'=>'primary',
'label'=>'Toggle me',
'label'=>'Toggle me',
'toggle'=>true,
'toggle'=>true,
...
...
widgets/BootButton.php
View file @
2e203f17
...
@@ -15,11 +15,15 @@ Yii::import('bootstrap.widgets.BootWidget');
...
@@ -15,11 +15,15 @@ Yii::import('bootstrap.widgets.BootWidget');
*/
*/
class
BootButton
extends
BootWidget
class
BootButton
extends
BootWidget
{
{
// Button methods.
// Button callback functions.
const
METHOD_LINK
=
'link'
;
const
FN_LINK
=
'link'
;
const
METHOD_BUTTON
=
'button'
;
const
FN_BUTTON
=
'button'
;
const
METHOD_AJAXLINK
=
'ajaxLink'
;
const
FN_SUBMIT
=
'submit'
;
const
METHOD_AJAXBUTTON
=
'ajaxButton'
;
const
FN_SUBMITLINK
=
'submitLink'
;
const
FN_RESET
=
'reset'
;
const
FN_AJAXLINK
=
'ajaxLink'
;
const
FN_AJAXBUTTON
=
'ajaxButton'
;
const
FN_AJAXSUBMIT
=
'ajaxSubmit'
;
// Button types.
// Button types.
const
TYPE_NORMAL
=
''
;
const
TYPE_NORMAL
=
''
;
...
@@ -36,10 +40,10 @@ class BootButton extends BootWidget
...
@@ -36,10 +40,10 @@ class BootButton extends BootWidget
const
SIZE_LARGE
=
'large'
;
const
SIZE_LARGE
=
'large'
;
/**
/**
* @var string the
method to use
for rendering the button.
* @var string the
callback function
for rendering the button.
* Valid values are 'link', 'button', '
ajaxLink' and 'ajaxButton
'.
* Valid values are 'link', 'button', '
submit', 'submitLink', 'reset', 'ajaxLink', 'ajaxButton' and 'ajaxSubmit
'.
*/
*/
public
$
method
=
self
::
METHOD
_LINK
;
public
$
fn
=
self
::
FN
_LINK
;
/**
/**
* @var string the button type.
* @var string the button type.
* Valid values are '', 'primary', 'info', 'success', 'warning', 'danger' and 'inverse'.
* Valid values are '', 'primary', 'info', 'success', 'warning', 'danger' and 'inverse'.
...
@@ -182,19 +186,31 @@ class BootButton extends BootWidget
...
@@ -182,19 +186,31 @@ class BootButton extends BootWidget
*/
*/
protected
function
createButton
()
protected
function
createButton
()
{
{
switch
(
$this
->
method
)
switch
(
$this
->
fn
)
{
{
case
self
::
METHOD
_BUTTON
:
case
self
::
FN
_BUTTON
:
return
CHtml
::
htmlButton
(
$this
->
label
,
$this
->
htmlOptions
);
return
CHtml
::
htmlButton
(
$this
->
label
,
$this
->
htmlOptions
);
case
self
::
METHOD_AJAXLINK
:
case
self
::
FN_SUBMIT
:
return
CHtml
::
submitButton
(
$this
->
label
,
$this
->
htmlOptions
);
case
self
::
FN_RESET
:
return
CHtml
::
resetButton
(
$this
->
label
,
$this
->
htmlOptions
);
case
self
::
FN_SUBMITLINK
:
return
CHtml
::
linkButton
(
$this
->
label
,
$this
->
htmlOptions
);
case
self
::
FN_AJAXLINK
:
return
CHtml
::
ajaxLink
(
$this
->
label
,
$this
->
url
,
$this
->
ajaxOptions
,
$this
->
htmlOptions
);
return
CHtml
::
ajaxLink
(
$this
->
label
,
$this
->
url
,
$this
->
ajaxOptions
,
$this
->
htmlOptions
);
case
self
::
METHOD
_AJAXBUTTON
:
case
self
::
FN
_AJAXBUTTON
:
return
CHtml
::
ajaxButton
(
$this
->
label
,
$this
->
url
,
$this
->
ajaxOptions
,
$this
->
htmlOptions
);
return
CHtml
::
ajaxButton
(
$this
->
label
,
$this
->
url
,
$this
->
ajaxOptions
,
$this
->
htmlOptions
);
case
self
::
FN_AJAXSUBMIT
:
return
CHtml
::
ajaxSubmitButton
(
$this
->
label
,
$this
->
ajaxOptions
,
$this
->
htmlOptions
);
default
:
default
:
case
self
::
METHOD
_LINK
:
case
self
::
FN
_LINK
:
return
CHtml
::
link
(
$this
->
label
,
$this
->
url
,
$this
->
htmlOptions
);
return
CHtml
::
link
(
$this
->
label
,
$this
->
url
,
$this
->
htmlOptions
);
}
}
}
}
...
...
widgets/BootButtonGroup.php
View file @
2e203f17
...
@@ -21,10 +21,10 @@ class BootButtonGroup extends BootWidget
...
@@ -21,10 +21,10 @@ class BootButtonGroup extends BootWidget
const
TOGGLE_RADIO
=
'radio'
;
const
TOGGLE_RADIO
=
'radio'
;
/**
/**
* @var string the button
method
.
* @var string the button
function
.
* @see BootButton::
method
* @see BootButton::
fn
*/
*/
public
$
method
=
BootButton
::
METHOD
_LINK
;
public
$
fn
=
BootButton
::
FN
_LINK
;
/**
/**
* @var string the button type.
* @var string the button type.
* @see BootButton::type
* @see BootButton::type
...
@@ -78,7 +78,7 @@ class BootButtonGroup extends BootWidget
...
@@ -78,7 +78,7 @@ class BootButtonGroup extends BootWidget
foreach
(
$this
->
buttons
as
$button
)
foreach
(
$this
->
buttons
as
$button
)
{
{
$this
->
controller
->
widget
(
'bootstrap.widgets.BootButton'
,
array
(
$this
->
controller
->
widget
(
'bootstrap.widgets.BootButton'
,
array
(
'
method'
=>
isset
(
$button
[
'method'
])
?
$button
[
'method'
]
:
$this
->
method
,
'
fn'
=>
isset
(
$button
[
'fn'
])
?
$button
[
'fn'
]
:
$this
->
fn
,
'type'
=>
isset
(
$button
[
'type'
])
?
$button
[
'type'
]
:
$this
->
type
,
'type'
=>
isset
(
$button
[
'type'
])
?
$button
[
'type'
]
:
$this
->
type
,
'size'
=>
$this
->
size
,
'size'
=>
$this
->
size
,
'icon'
=>
isset
(
$button
[
'icon'
])
?
$button
[
'icon'
]
:
null
,
'icon'
=>
isset
(
$button
[
'icon'
])
?
$button
[
'icon'
]
:
null
,
...
...
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