Commits

Christoffer Niska committed fd8559f

added yii related css and improved yii widgets

  • Participants
  • Parent commits 3c7458e
  • Branches 1.0.0-wip

Comments (0)

Files changed (8)

File assets/css/yii-bootstrap.css

+/*
+	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;
+}

File assets/img/loading.gif

Added
New image

File components/Bootstrap.php

 		if ($this->responsiveCss)
 			$this->registerResponsiveCss();
 
+		$this->registerYiiCss();
+
 		if ($this->enableJS)
 		{
 			Yii::app()->clientScript->registerCoreScript('jquery');
 	}
 
 	/**
+	 * 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
 	 */

File demo/protected/controllers/SiteController.php

 			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,
 
 		$this->render('index', array(
 			'model'=>$model,
+			'person'=>new Person(),
 			'tabs'=>$tabs,
 			'tabbable'=>$tabbable,
 			'gridDataProvider'=>$gridDataProvider,

File demo/protected/models/Person.php

+<?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();
+	}
+}

File demo/protected/views/site/index.php

 	<?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,
 	)); ?>
 
 ~~~
 [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'),

File widgets/BootDetailView.php

  */
 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;
+	}
 }

File widgets/BootGridView.php

  */
 class BootGridView extends CGridView
 {
+	// Table types.
+	const TYPE_PLAIN = '';
+	const TYPE_STRIPED = 'striped';
+	const TYPE_BORDERED = 'bordered';
+	const TYPE_CONDENSED = 'condensed';
+
 	/**
-	 * @var string the CSS class name for the container table. Defaults to 'table'.
+	 * @var string|array the table type.
+	 * Valid values are '', 'striped', 'bordered' and/or ' condensed'.
 	 */
-	public $itemsCssClass = 'table table-striped';
+	public $type = self::TYPE_PLAIN;
+	/**
+	 * @var array the CSS class names for the table body rows.
+	 * Defaults to an empty array.
+	 */
+	public $rowCssClass = array();
 	/**
 	 * @var string the CSS class name for the pager container.
 	 * Defaults to 'pagination'.
 	 * 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);
+	}
 }