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
5333077b
Commit
5333077b
authored
Mar 19, 2012
by
Crisu83
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added yii related css and improved yii widgets
parent
420499f9
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
258 additions
and
22 deletions
+258
-22
yii-bootstrap.css
assets/css/yii-bootstrap.css
+125
-0
loading.gif
assets/img/loading.gif
+0
-0
Bootstrap.php
components/Bootstrap.php
+11
-0
SiteController.php
demo/protected/controllers/SiteController.php
+23
-7
Person.php
demo/protected/models/Person.php
+23
-0
index.php
demo/protected/views/site/index.php
+7
-7
BootDetailView.php
widgets/BootDetailView.php
+34
-6
BootGridView.php
widgets/BootGridView.php
+35
-2
No files found.
assets/css/yii-bootstrap.css
0 → 100644
View file @
5333077b
/*
Forms
*/
span
.required
{
color
:
#F00
;
}
/*
Grid view
*/
.grid-view
{
padding-top
:
20px
;
}
.grid-view-loading
{
background
:
url(../img/loading.gif)
no-repeat
;
}
.grid-view
table
.items
th
a
{
display
:
block
;
position
:
relative
;
}
.grid-view
table
.items
th
a
.caret
{
position
:
absolute
;
right
:
5px
;
top
:
7px
;
}
.grid-view
table
.items
th
a
.desc
.caret
{
border-bottom
:
4px
solid
#000
;
border-top
:
none
;
}
.grid-view
table
.items
tr
.selected
td
{
background
:
#EEE
;
}
.grid-view
.button-column
{
text-align
:
center
;
width
:
50px
;
}
.grid-view
.checkbox-column
{
width
:
15px
;
}
.grid-view
.summary
{
margin-bottom
:
5px
;
text-align
:
right
;
}
.grid-view
.pager
{
margin-top
:
5px
;
}
.grid-view
.empty
{
font-style
:
italic
;
}
.grid-view
.filters
input
,
.grid-view
.filters
select
{
border
:
none
;
margin-bottom
:
0
;
padding
:
0
;
width
:
100%
;
box-shadow
:
none
;
-o-box-shadow
:
none
;
-moz-box-shadow
:
none
;
-ms-box-shadow
:
none
;
-webkit-box-shadow
:
none
;
}
/*
List view
*/
.list-view-loading
{
background
:
url(../img/loading.gif)
no-repeat
;
}
.list-view
.summary
{
margin-bottom
:
5px
;
text-align
:
right
;
}
.list-view
.pager
{
margin-top
:
5px
;
}
.list-view
.sorter
ul
{
display
:
inline
;
list-style
:
none
outside
none
;
margin
:
0
;
padding
:
0
;
}
.list-view
.sorter
li
{
display
:
inline
;
margin
:
0
0
0
5px
;
padding
:
0
;
}
.list-view
.sorter
a
.caret
{
position
:
absolute
;
right
:
5px
;
top
:
7px
;
}
.list-view
.sorter
a
.desc
.caret
{
border-bottom
:
4px
solid
#000
;
border-top
:
none
;
}
/*
Detail view
*/
table
.detail-view
.null
{
color
:
#FFC0CB
;
}
table
.detail-view
th
{
text-align
:
right
;
width
:
160px
;
}
\ No newline at end of file
assets/img/loading.gif
0 → 100644
View file @
5333077b
6.65 KB
components/Bootstrap.php
View file @
5333077b
...
...
@@ -71,6 +71,8 @@ class Bootstrap extends CApplicationComponent
if
(
$this
->
responsiveCss
)
$this
->
registerResponsiveCss
();
$this
->
registerYiiCss
();
if
(
$this
->
enableJS
)
{
Yii
::
app
()
->
clientScript
->
registerCoreScript
(
'jquery'
);
...
...
@@ -96,6 +98,15 @@ class Bootstrap extends CApplicationComponent
}
/**
* Registers the Yii-specific CSS missing from Bootstrap.
* @since 1.0.0
*/
public
function
registerYiiCss
()
{
Yii
::
app
()
->
clientScript
->
registerCssFile
(
$this
->
getAssetsUrl
()
.
'/css/yii-bootstrap.css'
);
}
/**
* Registers the core JavaScript plugins.
* @since 0.9.8
*/
...
...
demo/protected/controllers/SiteController.php
View file @
5333077b
...
...
@@ -50,20 +50,35 @@ class SiteController extends Controller
array
(
'label'
=>
'Section 3'
,
'content'
=>
'<p>What up girl, this is Section 3.</p>'
),
);
$gridDataProvider
=
new
CArrayDataProvider
(
array
(
array
(
'id'
=>
1
,
'firstName'
=>
'Mark'
,
'lastName'
=>
'Otto'
,
'language'
=>
'CSS'
),
array
(
'id'
=>
2
,
'firstName'
=>
'Jacob'
,
'lastName'
=>
'Thornton'
,
'language'
=>
'JavaScript'
),
array
(
'id'
=>
3
,
'firstName'
=>
'Stu'
,
'lastName'
=>
'Dent'
,
'language'
=>
'HTML'
),
));
$mark
=
new
Person
();
$mark
->
id
=
1
;
$mark
->
firstName
=
'Mark'
;
$mark
->
lastName
=
'Otto'
;
$mark
->
language
=
'CSS'
;
$jacob
=
new
Person
();
$jacob
->
id
=
2
;
$jacob
->
firstName
=
'Jacob'
;
$jacob
->
lastName
=
'Thornton'
;
$jacob
->
language
=
'JavaScript'
;
$stu
=
new
Person
();
$stu
->
id
=
3
;
$stu
->
firstName
=
'Stu'
;
$stu
->
lastName
=
'Dent'
;
$stu
->
language
=
'HTML'
;
$persons
=
array
(
$mark
,
$jacob
,
$stu
);
$gridDataProvider
=
new
CArrayDataProvider
(
$persons
);
$gridColumns
=
array
(
array
(
'name'
=>
'id'
,
'header'
=>
'#'
),
array
(
'name'
=>
'id'
,
'header'
=>
'#'
,
'htmlOptions'
=>
array
(
'style'
=>
'width: 60px'
)
),
array
(
'name'
=>
'firstName'
,
'header'
=>
'First name'
),
array
(
'name'
=>
'lastName'
,
'header'
=>
'Last name'
),
array
(
'name'
=>
'language'
,
'header'
=>
'Language'
),
array
(
'class'
=>
'bootstrap.widgets.BootButtonColumn'
,
'htmlOptions'
=>
array
(
'style'
=>
'width: 50px'
),
'viewButtonUrl'
=>
null
,
'updateButtonUrl'
=>
null
,
'deleteButtonUrl'
=>
null
,
...
...
@@ -80,6 +95,7 @@ class SiteController extends Controller
$this
->
render
(
'index'
,
array
(
'model'
=>
$model
,
'person'
=>
new
Person
(),
'tabs'
=>
$tabs
,
'tabbable'
=>
$tabbable
,
'gridDataProvider'
=>
$gridDataProvider
,
...
...
demo/protected/models/Person.php
0 → 100644
View file @
5333077b
<?php
class
Person
extends
CModel
{
public
$id
;
public
$firstName
;
public
$lastName
;
public
$language
;
public
function
attributeNames
()
{
return
array
(
'id'
,
'firstName'
,
'lastName'
,
'language'
,
);
}
public
function
search
()
{
return
new
Person
();
}
}
demo/protected/views/site/index.php
View file @
5333077b
...
...
@@ -399,43 +399,43 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
<?php
$this
->
widget
(
'bootstrap.widgets.BootGridView'
,
array
(
'dataProvider'
=>
$gridDataProvider
,
'template'
=>
"
{
items
}
"
,
'itemsCssClass'
=>
'table'
,
'columns'
=>
$gridColumns
,
));
?>
<h3>
Striped
</h3>
<?php
$this
->
widget
(
'bootstrap.widgets.BootGridView'
,
array
(
'type'
=>
'striped'
,
'dataProvider'
=>
$gridDataProvider
,
'template'
=>
"
{
items
}
"
,
'itemsCssClass'
=>
'table table-striped'
,
'columns'
=>
$gridColumns
,
));
?>
<h3>
Bordered
</h3>
<?php
$this
->
widget
(
'bootstrap.widgets.BootGridView'
,
array
(
'type'
=>
'bordered'
,
'dataProvider'
=>
$gridDataProvider
,
'template'
=>
"
{
items
}
"
,
'itemsCssClass'
=>
'table table-bordered'
,
'columns'
=>
$gridColumns
,
));
?>
<h3>
Condensed
</h3>
<?php
$this
->
widget
(
'bootstrap.widgets.BootGridView'
,
array
(
'type'
=>
'condensed'
,
'dataProvider'
=>
$gridDataProvider
,
'template'
=>
"
{
items
}
"
,
'itemsCssClass'
=>
'table table-condensed'
,
'columns'
=>
$gridColumns
,
));
?>
<h3>
Striped, bordered and condensed
</h3>
<?php
$this
->
widget
(
'bootstrap.widgets.BootGridView'
,
array
(
'type'
=>
'striped bordered condensed'
,
'dataProvider'
=>
$gridDataProvider
,
'template'
=>
"
{
items
}
"
,
'
itemsCssClass'
=>
'table table-striped table-bordered table-condensed'
,
'template'
=>
"
{
summary}\n{items}\n{pager
}
"
,
'
filter'
=>
$person
->
search
()
,
'columns'
=>
$gridColumns
,
));
?>
...
...
@@ -452,9 +452,9 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
~~~
[php]
<?php
\$
this->widget('bootstrap.widgets.BootGridView', array(
'type'=>'striped bordered condensed',
'dataProvider'=>
\$
gridDataProvider,
'template'=>
\"
{
items
}
\"
,
'itemsCssClass'=>'table table-striped table-bordered table-condensed',
'columns'=>array(
array('name'=>'id', 'header'=>'#'),
array('name'=>'firstName', 'header'=>'First name'),
...
...
widgets/BootDetailView.php
View file @
5333077b
...
...
@@ -15,21 +15,49 @@ Yii::import('zii.widgets.CDetailView');
*/
class
BootDetailView
extends
CDetailView
{
// Table types.
const
TYPE_PLAIN
=
''
;
const
TYPE_STRIPED
=
'striped'
;
const
TYPE_BORDERED
=
'bordered'
;
const
TYPE_CONDENSED
=
'condensed'
;
/**
* @var string the template used to render a single attribute. Defaults to a table row.
* @var string|array the table type.
* Valid values are '', 'striped', 'bordered' and/or 'condensed'.
*/
public
$
itemTemplate
=
"<tr class=
\"
{
class
}
\"
><th style=
\"
width: 160px
\"
>
{
label}</th><td>{value
}
</td></tr>
\n
"
;
public
$
type
=
array
(
self
::
TYPE_STRIPED
,
self
::
TYPE_CONDENSED
)
;
/**
* @var array the CSS class names for the items displaying attribute values.
*/
public
$itemCssClass
=
array
();
/**
* @var array the HTML attributes for the container.
*/
public
$htmlOptions
=
array
(
'class'
=>
'table table-striped table-condensed detail-view'
);
/**
* @var string the URL of the CSS file used by this detail view.
* Defaults to false, meaning that no CSS will be included.
*/
public
$cssFile
=
false
;
/**
* Initializes the widget.
*/
public
function
init
()
{
parent
::
init
();
$class
=
array
(
'table'
);
if
(
is_string
(
$this
->
type
))
$this
->
type
=
explode
(
' '
,
$this
->
type
);
$validTypes
=
array
(
self
::
TYPE_STRIPED
,
self
::
TYPE_BORDERED
,
self
::
TYPE_CONDENSED
);
foreach
(
$this
->
type
as
$type
)
if
(
in_array
(
$type
,
$validTypes
))
$class
[]
=
'table-'
.
$type
;
$cssClass
=
implode
(
' '
,
$class
);
if
(
isset
(
$this
->
htmlOptions
[
'class'
]))
$this
->
htmlOptions
[
'class'
]
.=
' '
.
$cssClass
;
else
$this
->
htmlOptions
[
'class'
]
=
$cssClass
;
}
}
widgets/BootGridView.php
View file @
5333077b
...
...
@@ -15,10 +15,22 @@ Yii::import('zii.widgets.grid.CGridView');
*/
class
BootGridView
extends
CGridView
{
// Table types.
const
TYPE_PLAIN
=
''
;
const
TYPE_STRIPED
=
'striped'
;
const
TYPE_BORDERED
=
'bordered'
;
const
TYPE_CONDENSED
=
'condensed'
;
/**
* @var string|array the table type.
* Valid values are '', 'striped', 'bordered' and/or ' condensed'.
*/
public
$type
=
self
::
TYPE_PLAIN
;
/**
* @var string the CSS class name for the container table. Defaults to 'table'.
* @var array the CSS class names for the table body rows.
* Defaults to an empty array.
*/
public
$
itemsCssClass
=
'table table-striped'
;
public
$
rowCssClass
=
array
()
;
/**
* @var string the CSS class name for the pager container.
* Defaults to 'pagination'.
...
...
@@ -34,4 +46,25 @@ class BootGridView extends CGridView
* Defaults to false, meaning that no CSS will be included.
*/
public
$cssFile
=
false
;
/**
* Initializes the widget.
*/
public
function
init
()
{
parent
::
init
();
$class
=
array
(
'table'
);
if
(
is_string
(
$this
->
type
))
$this
->
type
=
explode
(
' '
,
$this
->
type
);
$validTypes
=
array
(
self
::
TYPE_STRIPED
,
self
::
TYPE_BORDERED
,
self
::
TYPE_CONDENSED
);
foreach
(
$this
->
type
as
$type
)
if
(
in_array
(
$type
,
$validTypes
))
$class
[]
=
'table-'
.
$type
;
$this
->
itemsCssClass
.=
' '
.
implode
(
' '
,
$class
);
}
}
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