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
80d276db
Commit
80d276db
authored
Jul 31, 2012
by
Crisu83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added collapse and scrollspy widgets and renamed tabbable to tabs
parent
1cc2899a
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
148 additions
and
10 deletions
+148
-10
TbCollapse.php
widgets/TbCollapse.php
+80
-0
TbScrollSpy.php
widgets/TbScrollSpy.php
+58
-0
TbTabs.php
widgets/TbTabs.php
+10
-10
No files found.
widgets/TbCollapse.php
0 → 100644
View file @
80d276db
<?php
/**
* TbCollapse class file.
* @author Christoffer Niska <ChristofferNiska@gmail.com>
* @copyright Copyright © Christoffer Niska 2012-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package bootstrap.widgets
* @since 1.0.0
*/
/**
* Bootstrap collapse widget.
* @see http://twitter.github.com/bootstrap/javascript.html#collapse
*/
class
TbCollapse
extends
CWidget
{
/**
* @var string the name of the collapse element. Defaults to 'a'.
*/
public
$tagName
=
'div'
;
/**
* @var boolean the CSS selector for element to collapse. Default to 'false'.
*/
public
$parent
=
false
;
/**
* @var boolean indicates whether to toggle the collapsible element on invocation.
*/
public
$toggle
=
true
;
/**
* @var array the options for the Bootstrap Javascript plugin.
*/
public
$options
=
array
();
/**
* @var string[] the Javascript event handlers.
*/
public
$events
=
array
();
/**
* @var array the HTML attributes for the widget container.
*/
public
$htmlOptions
=
array
();
/**
* Initializes the widget.
*/
public
function
init
()
{
if
(
!
isset
(
$this
->
htmlOptions
[
'id'
]))
$this
->
htmlOptions
[
'id'
]
=
$this
->
getId
();
if
(
isset
(
$this
->
parent
)
&&
!
isset
(
$this
->
options
[
'parent'
]))
$this
->
options
[
'parent'
]
=
$this
->
parent
;
if
(
isset
(
$this
->
toggle
)
&&
!
isset
(
$this
->
options
[
'toggle'
]))
$this
->
options
[
'toggle'
]
=
$this
->
toggle
;
echo
CHtml
::
tag
(
$this
->
tagName
,
$this
->
htmlOptions
);
}
/**
* Runs the widget.
*/
public
function
run
()
{
$id
=
$this
->
htmlOptions
[
'id'
];
echo
CHtml
::
closeTag
(
$this
->
tagName
);
/** @var CClientScript $cs */
$cs
=
Yii
::
app
()
->
getClientScript
();
$options
=
!
empty
(
$this
->
options
)
?
CJavaScript
::
encode
(
$this
->
options
)
:
''
;
$cs
->
registerScript
(
__CLASS__
.
'#'
.
$id
,
"jQuery('#
{
$id
}
').collapse(
{
$options
}
);"
);
foreach
(
$this
->
events
as
$name
=>
$handler
)
{
$handler
=
CJavaScript
::
encode
(
$handler
);
$cs
->
registerScript
(
__CLASS__
.
'#'
.
$id
.
'_'
.
$name
,
"jQuery('#
{
$id
}
').on('
{
$name
}
',
{
$handler
}
);"
);
}
}
}
widgets/TbScrollSpy.php
0 → 100644
View file @
80d276db
<?php
/**
* TbScrollSpy class file.
* @author Christoffer Niska <ChristofferNiska@gmail.com>
* @copyright Copyright © Christoffer Niska 2012-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package bootstrap.widgets
* @since 1.0.0
*/
/**
* Bootstrap scrollspy widget.
* @see http://twitter.github.com/bootstrap/javascript.html#scrollspy
*/
class
TbScrollSpy
extends
CWidget
{
/**
* @var string the CSS selector for the scrollspy element. Defaults to 'body'.
*/
public
$selector
=
'body'
;
/**
* @var string the CSS selector for the spying element.
*/
public
$target
;
/**
* @var integer the scroll offset (in pixels).
*/
public
$offset
;
/**
* @var array string[] the Javascript event handlers.
*/
public
$events
=
array
();
/**
* Runs the widget.
*/
public
function
run
()
{
$script
=
"jQuery('
{
$this
->
selector
}
').attr('data-spy', 'scroll');"
;
if
(
isset
(
$this
->
target
))
$script
.=
"jQuery('
{
$this
->
selector
}
').attr('data-target', '
{
$this
->
target
}
');"
;
if
(
isset
(
$this
->
offset
))
$script
.=
"jQuery('
{
$this
->
selector
}
').attr('data-offset', '
{
$this
->
offset
}
');"
;
/** @var CClientScript $cs */
$cs
=
Yii
::
app
()
->
getClientScript
();
$cs
->
registerScript
(
__CLASS__
.
'#'
.
$this
->
selector
,
$script
,
CClientScript
::
POS_BEGIN
);
foreach
(
$this
->
events
as
$name
=>
$handler
)
{
$handler
=
CJavaScript
::
encode
(
$handler
);
$cs
->
registerScript
(
__CLASS__
.
'#'
.
$this
->
selector
.
'_'
.
$name
,
"jQuery('
{
$this
->
selector
}
').on('
{
$name
}
',
{
$handler
}
);"
);
}
}
}
widgets/TbTab
bable
.php
→
widgets/TbTab
s
.php
View file @
80d276db
<?php
<?php
/**
/**
*
BootTabbable
class file.
*
TbTabs
class file.
* @author Christoffer Niska <ChristofferNiska@gmail.com>
* @author Christoffer Niska <ChristofferNiska@gmail.com>
* @copyright Copyright © Christoffer Niska 2011-
* @copyright Copyright © Christoffer Niska 2011-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
...
@@ -10,10 +10,10 @@
...
@@ -10,10 +10,10 @@
Yii
::
import
(
'bootstrap.widgets.TbMenu'
);
Yii
::
import
(
'bootstrap.widgets.TbMenu'
);
/**
/**
* Bootstrap Java
S
cript tabs widget.
* Bootstrap Java
s
cript tabs widget.
* @s
ince 0.9.8
* @s
ee http://twitter.github.com/bootstrap/javascript.html#tabs
*/
*/
class
TbTab
bable
extends
CWidget
class
TbTab
s
extends
CWidget
{
{
// Tab placements.
// Tab placements.
const
PLACEMENT_ABOVE
=
'above'
;
const
PLACEMENT_ABOVE
=
'above'
;
...
@@ -22,9 +22,9 @@ class TbTabbable extends CWidget
...
@@ -22,9 +22,9 @@ class TbTabbable extends CWidget
const
PLACEMENT_RIGHT
=
'right'
;
const
PLACEMENT_RIGHT
=
'right'
;
/**
/**
* @var string the type of tabs to display. Defaults to 'tabs'.
* @var string the type of tabs to display. Defaults to 'tabs'.
Valid values are 'tabs' and 'pills'.
*
Valid values are 'tabs' and 'pills'.
*
Please not that Javascript pills are not fully supported in Bootstrap yet!
* Please not that JavaScript pills are not fully supported in Bootstrap!
* @see TbMenu::$type
*/
*/
public
$type
=
TbMenu
::
TYPE_TABS
;
public
$type
=
TbMenu
::
TYPE_TABS
;
/**
/**
...
@@ -41,7 +41,7 @@ class TbTabbable extends CWidget
...
@@ -41,7 +41,7 @@ class TbTabbable extends CWidget
*/
*/
public
$encodeLabel
=
true
;
public
$encodeLabel
=
true
;
/**
/**
* @var string[] the Java
S
cript event handlers.
* @var string[] the Java
s
cript event handlers.
*/
*/
public
$events
=
array
();
public
$events
=
array
();
/**
/**
...
@@ -108,7 +108,7 @@ class TbTabbable extends CWidget
...
@@ -108,7 +108,7 @@ class TbTabbable extends CWidget
foreach
(
$this
->
events
as
$name
=>
$handler
)
foreach
(
$this
->
events
as
$name
=>
$handler
)
{
{
$handler
=
CJavaScript
::
encode
(
$handler
);
$handler
=
CJavaScript
::
encode
(
$handler
);
$cs
->
registerScript
(
__CLASS__
.
'#'
.
$id
.
'_'
.
$name
,
"jQuery('#
{
$id
}
').on('
"
.
$name
.
"
',
{
$handler
}
);"
);
$cs
->
registerScript
(
__CLASS__
.
'#'
.
$id
.
'_'
.
$name
,
"jQuery('#
{
$id
}
').on('
{
$name
}
',
{
$handler
}
);"
);
}
}
}
}
...
@@ -128,7 +128,7 @@ class TbTabbable extends CWidget
...
@@ -128,7 +128,7 @@ class TbTabbable extends CWidget
{
{
$item
=
$tab
;
$item
=
$tab
;
if
(
isset
(
$item
[
'visible'
])
&&
!
$item
[
'visible'
]
)
if
(
isset
(
$item
[
'visible'
])
&&
$item
[
'visible'
]
===
false
)
continue
;
continue
;
if
(
!
isset
(
$item
[
'itemOptions'
]))
if
(
!
isset
(
$item
[
'itemOptions'
]))
...
...
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