Commit 5333077b by Crisu83

added yii related css and improved yii widgets

parent 420499f9
/*
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
...@@ -71,6 +71,8 @@ class Bootstrap extends CApplicationComponent ...@@ -71,6 +71,8 @@ class Bootstrap extends CApplicationComponent
if ($this->responsiveCss) if ($this->responsiveCss)
$this->registerResponsiveCss(); $this->registerResponsiveCss();
$this->registerYiiCss();
if ($this->enableJS) if ($this->enableJS)
{ {
Yii::app()->clientScript->registerCoreScript('jquery'); Yii::app()->clientScript->registerCoreScript('jquery');
...@@ -96,6 +98,15 @@ class Bootstrap extends CApplicationComponent ...@@ -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. * Registers the core JavaScript plugins.
* @since 0.9.8 * @since 0.9.8
*/ */
......
...@@ -50,20 +50,35 @@ class SiteController extends Controller ...@@ -50,20 +50,35 @@ class SiteController extends Controller
array('label'=>'Section 3', 'content'=>'<p>What up girl, this is Section 3.</p>'), array('label'=>'Section 3', 'content'=>'<p>What up girl, this is Section 3.</p>'),
); );
$gridDataProvider = new CArrayDataProvider(array( $mark = new Person();
array('id'=>1, 'firstName'=>'Mark', 'lastName'=>'Otto', 'language'=>'CSS'), $mark->id = 1;
array('id'=>2, 'firstName'=>'Jacob', 'lastName'=>'Thornton', 'language'=>'JavaScript'), $mark->firstName = 'Mark';
array('id'=>3, 'firstName'=>'Stu', 'lastName'=>'Dent', 'language'=>'HTML'), $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( $gridColumns = array(
array('name'=>'id', 'header'=>'#'), array('name'=>'id', 'header'=>'#', 'htmlOptions'=>array('style'=>'width: 60px')),
array('name'=>'firstName', 'header'=>'First name'), array('name'=>'firstName', 'header'=>'First name'),
array('name'=>'lastName', 'header'=>'Last name'), array('name'=>'lastName', 'header'=>'Last name'),
array('name'=>'language', 'header'=>'Language'), array('name'=>'language', 'header'=>'Language'),
array( array(
'class'=>'bootstrap.widgets.BootButtonColumn', 'class'=>'bootstrap.widgets.BootButtonColumn',
'htmlOptions'=>array('style'=>'width: 50px'),
'viewButtonUrl'=>null, 'viewButtonUrl'=>null,
'updateButtonUrl'=>null, 'updateButtonUrl'=>null,
'deleteButtonUrl'=>null, 'deleteButtonUrl'=>null,
...@@ -80,6 +95,7 @@ class SiteController extends Controller ...@@ -80,6 +95,7 @@ class SiteController extends Controller
$this->render('index', array( $this->render('index', array(
'model'=>$model, 'model'=>$model,
'person'=>new Person(),
'tabs'=>$tabs, 'tabs'=>$tabs,
'tabbable'=>$tabbable, 'tabbable'=>$tabbable,
'gridDataProvider'=>$gridDataProvider, 'gridDataProvider'=>$gridDataProvider,
......
<?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();
}
}
...@@ -399,43 +399,43 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin ...@@ -399,43 +399,43 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
<?php $this->widget('bootstrap.widgets.BootGridView', array( <?php $this->widget('bootstrap.widgets.BootGridView', array(
'dataProvider'=>$gridDataProvider, 'dataProvider'=>$gridDataProvider,
'template'=>"{items}", 'template'=>"{items}",
'itemsCssClass'=>'table',
'columns'=>$gridColumns, 'columns'=>$gridColumns,
)); ?> )); ?>
<h3>Striped</h3> <h3>Striped</h3>
<?php $this->widget('bootstrap.widgets.BootGridView', array( <?php $this->widget('bootstrap.widgets.BootGridView', array(
'type'=>'striped',
'dataProvider'=>$gridDataProvider, 'dataProvider'=>$gridDataProvider,
'template'=>"{items}", 'template'=>"{items}",
'itemsCssClass'=>'table table-striped',
'columns'=>$gridColumns, 'columns'=>$gridColumns,
)); ?> )); ?>
<h3>Bordered</h3> <h3>Bordered</h3>
<?php $this->widget('bootstrap.widgets.BootGridView', array( <?php $this->widget('bootstrap.widgets.BootGridView', array(
'type'=>'bordered',
'dataProvider'=>$gridDataProvider, 'dataProvider'=>$gridDataProvider,
'template'=>"{items}", 'template'=>"{items}",
'itemsCssClass'=>'table table-bordered',
'columns'=>$gridColumns, 'columns'=>$gridColumns,
)); ?> )); ?>
<h3>Condensed</h3> <h3>Condensed</h3>
<?php $this->widget('bootstrap.widgets.BootGridView', array( <?php $this->widget('bootstrap.widgets.BootGridView', array(
'type'=>'condensed',
'dataProvider'=>$gridDataProvider, 'dataProvider'=>$gridDataProvider,
'template'=>"{items}", 'template'=>"{items}",
'itemsCssClass'=>'table table-condensed',
'columns'=>$gridColumns, 'columns'=>$gridColumns,
)); ?> )); ?>
<h3>Striped, bordered and condensed</h3> <h3>Striped, bordered and condensed</h3>
<?php $this->widget('bootstrap.widgets.BootGridView', array( <?php $this->widget('bootstrap.widgets.BootGridView', array(
'type'=>'striped bordered condensed',
'dataProvider'=>$gridDataProvider, 'dataProvider'=>$gridDataProvider,
'template'=>"{items}", 'template'=>"{summary}\n{items}\n{pager}",
'itemsCssClass'=>'table table-striped table-bordered table-condensed', 'filter'=>$person->search(),
'columns'=>$gridColumns, 'columns'=>$gridColumns,
)); ?> )); ?>
...@@ -452,9 +452,9 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin ...@@ -452,9 +452,9 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
~~~ ~~~
[php] [php]
<?php \$this->widget('bootstrap.widgets.BootGridView', array( <?php \$this->widget('bootstrap.widgets.BootGridView', array(
'type'=>'striped bordered condensed',
'dataProvider'=>\$gridDataProvider, 'dataProvider'=>\$gridDataProvider,
'template'=>\"{items}\", 'template'=>\"{items}\",
'itemsCssClass'=>'table table-striped table-bordered table-condensed',
'columns'=>array( 'columns'=>array(
array('name'=>'id', 'header'=>'#'), array('name'=>'id', 'header'=>'#'),
array('name'=>'firstName', 'header'=>'First name'), array('name'=>'firstName', 'header'=>'First name'),
......
...@@ -15,21 +15,49 @@ Yii::import('zii.widgets.CDetailView'); ...@@ -15,21 +15,49 @@ Yii::import('zii.widgets.CDetailView');
*/ */
class BootDetailView extends 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. * @var array the CSS class names for the items displaying attribute values.
*/ */
public $itemCssClass = array(); 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. * @var string the URL of the CSS file used by this detail view.
* Defaults to false, meaning that no CSS will be included. * Defaults to false, meaning that no CSS will be included.
*/ */
public $cssFile = false; 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;
}
} }
...@@ -15,10 +15,22 @@ Yii::import('zii.widgets.grid.CGridView'); ...@@ -15,10 +15,22 @@ Yii::import('zii.widgets.grid.CGridView');
*/ */
class BootGridView extends 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. * @var string the CSS class name for the pager container.
* Defaults to 'pagination'. * Defaults to 'pagination'.
...@@ -34,4 +46,25 @@ class BootGridView extends CGridView ...@@ -34,4 +46,25 @@ class BootGridView extends CGridView
* Defaults to false, meaning that no CSS will be included. * Defaults to false, meaning that no CSS will be included.
*/ */
public $cssFile = false; 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);
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment