Commit 4457b28f by niskac

added tab placement support to BootTabbable and updated the demo

parent 305bb2a5
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
* @author Christoffer Niska <ChristofferNiska@gmail.com> * @author Christoffer Niska <ChristofferNiska@gmail.com>
* @copyright Copyright &copy; Christoffer Niska 2011- * @copyright Copyright &copy; 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
* @version 0.9.10
*/ */
/** /**
......
...@@ -147,6 +147,9 @@ section a.top { ...@@ -147,6 +147,9 @@ section a.top {
#bootTabbable .tabbable { #bootTabbable .tabbable {
margin-bottom: 20px; margin-bottom: 20px;
} }
#bootTabbable .tabbable.tabbable-placed {
width: 340px;
}
#bootThumbs .list-view { #bootThumbs .list-view {
padding-top: 30px; padding-top: 30px;
} }
......
...@@ -125,6 +125,10 @@ section { ...@@ -125,6 +125,10 @@ section {
#bootTabbable .tabbable { #bootTabbable .tabbable {
margin-bottom: 20px; margin-bottom: 20px;
&.tabbable-placed {
width: 340px;
}
} }
#bootThumbs .list-view { #bootThumbs .list-view {
......
...@@ -34,6 +34,13 @@ $config = array( ...@@ -34,6 +34,13 @@ $config = array(
'errorHandler'=>array( 'errorHandler'=>array(
'errorAction'=>'site/error', 'errorAction'=>'site/error',
), ),
'clientScript'=>array(
'class'=>'ext.minify.EClientScript',
//'combineScriptFiles' => true,
//'combineCssFiles' => true,
//'optimizeCssFiles' => true,
//'optimizeScriptFiles' => true,
),
'fb'=>array( 'fb'=>array(
'class'=>'ext.facebook.components.FacebookConnect', 'class'=>'ext.facebook.components.FacebookConnect',
'appID'=>'106265262835735', 'appID'=>'106265262835735',
......
...@@ -35,6 +35,21 @@ class SiteController extends Controller ...@@ -35,6 +35,21 @@ class SiteController extends Controller
{ {
$model = new TestForm(); $model = new TestForm();
$tabs = array(
array('label'=>'Home', 'content'=>'<p>Raw denim you probably haven\'t heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.</p>'),
array('label'=>'Profile', 'content'=>'<p>Food truck fixie locavore, accusamus mcsweeney\'s marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.</p>'),
array('label'=>'Dropdown', 'items'=>array(
array('label'=>'@fat', 'content'=>'<p>Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney\'s organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven\'t heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.</p>'),
array('label'=>'@mdo', 'content'=>'<p>Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out master cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out farm-to-table VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh craft beer marfa ethical. Wolf salvia freegan, sartorial keffiyeh echo park vegan.</p>'),
)),
);
$tabbable = array(
array('label'=>'Section 1', 'content'=>'<p>I\'m in Section 1.</p>'),
array('label'=>'Section 2', 'content'=>'<p>Howdy, I\'m in Section 2.</p>'),
array('label'=>'Section 3', 'content'=>'<p>What up girl, this is Section 3.</p>'),
);
$gridDataProvider = new CArrayDataProvider(array( $gridDataProvider = new CArrayDataProvider(array(
array('id'=>1, 'firstName'=>'Mark', 'lastName'=>'Otto', 'language'=>'CSS'), array('id'=>1, 'firstName'=>'Mark', 'lastName'=>'Otto', 'language'=>'CSS'),
array('id'=>2, 'firstName'=>'Jacob', 'lastName'=>'Thornton', 'language'=>'JavaScript'), array('id'=>2, 'firstName'=>'Jacob', 'lastName'=>'Thornton', 'language'=>'JavaScript'),
...@@ -65,6 +80,8 @@ class SiteController extends Controller ...@@ -65,6 +80,8 @@ class SiteController extends Controller
$this->render('index', array( $this->render('index', array(
'model'=>$model, 'model'=>$model,
'tabs'=>$tabs,
'tabbable'=>$tabbable,
'gridDataProvider'=>$gridDataProvider, 'gridDataProvider'=>$gridDataProvider,
'gridColumns'=>$gridColumns, 'gridColumns'=>$gridColumns,
'listDataProvider'=>$listDataProvider, 'listDataProvider'=>$listDataProvider,
...@@ -101,4 +118,4 @@ class SiteController extends Controller ...@@ -101,4 +118,4 @@ class SiteController extends Controller
$this->render('error', $error); $this->render('error', $error);
} }
} }
} }
\ No newline at end of file
...@@ -7,12 +7,11 @@ ...@@ -7,12 +7,11 @@
'title'=>array('class'=>'ext.seo.widgets.SeoTitle', 'separator'=>' :: '), 'title'=>array('class'=>'ext.seo.widgets.SeoTitle', 'separator'=>' :: '),
)); ?> )); ?>
<link rel="shortcut icon" href="<?php echo Yii::app()->request->baseUrl; ?>/favicon.ico"> <link rel="shortcut icon" href="<?php echo Yii::app()->request->baseUrl; ?>/favicon.ico">
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/styles.css" /> <?php Yii::app()->clientScript->registerCssFile(Yii::app()->request->baseUrl.'/css/styles.css'); ?>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script type="text/javascript" src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> <script type="text/javascript" src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]--> <![endif]-->
<script type="text/javascript"> <?php Yii::app()->clientScript->registerScript('GA',"
var _gaq = _gaq || []; var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-29040179-1']); _gaq.push(['_setAccount', 'UA-29040179-1']);
_gaq.push(['_trackPageview']); _gaq.push(['_trackPageview']);
...@@ -22,8 +21,7 @@ ...@@ -22,8 +21,7 @@
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})(); })();
"); ?>
</script>
</head> </head>
<body id="top"> <body id="top">
......
...@@ -266,36 +266,17 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin ...@@ -266,36 +266,17 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
<section id="bootTabbable"> <section id="bootTabbable">
<h2>Tabs</h2> <h2>Tabbable</h2>
<?php $this->widget('bootstrap.widgets.BootTabbable', array( <?php $this->widget('bootstrap.widgets.BootTabbable', array(
'type'=>'tabs', // 'tabs' or 'pills'
'htmlOptions'=>array('class'=>'tabbable'), 'htmlOptions'=>array('class'=>'tabbable'),
'tabs'=>array( 'tabs'=>$tabs,
array('label'=>'Home', 'content'=>'Raw denim you probably haven\'t heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.'),
array('label'=>'Profile', 'content'=>'Food truck fixie locavore, accusamus mcsweeney\'s marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.'),
array('label'=>'Dropdown', 'items'=>array(
array('label'=>'@fat', 'content'=>'Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney\'s organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven\'t heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.'),
array('label'=>'@mdo', 'content'=>'Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out master cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out farm-to-table VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh craft beer marfa ethical. Wolf salvia freegan, sartorial keffiyeh echo park vegan.'),
)),
),
)); ?>
<?php $this->widget('bootstrap.widgets.BootTabbable', array(
'type'=>'pills',
'htmlOptions'=>array('class'=>'tabbable'),
'tabs'=>array(
array('label'=>'Home', 'content'=>'Raw denim you probably haven\'t heard of them jean shorts Austin. Nesciunt tofu stumptown aliqua, retro synth master cleanse. Mustache cliche tempor, williamsburg carles vegan helvetica. Reprehenderit butcher retro keffiyeh dreamcatcher synth. Cosby sweater eu banh mi, qui irure terry richardson ex squid. Aliquip placeat salvia cillum iphone. Seitan aliquip quis cardigan american apparel, butcher voluptate nisi qui.'),
array('label'=>'Profile', 'content'=>'Food truck fixie locavore, accusamus mcsweeney\'s marfa nulla single-origin coffee squid. Exercitation +1 labore velit, blog sartorial PBR leggings next level wes anderson artisan four loko farm-to-table craft beer twee. Qui photo booth letterpress, commodo enim craft beer mlkshk aliquip jean shorts ullamco ad vinyl cillum PBR. Homo nostrud organic, assumenda labore aesthetic magna delectus mollit. Keytar helvetica VHS salvia yr, vero magna velit sapiente labore stumptown. Vegan fanny pack odio cillum wes anderson 8-bit, sustainable jean shorts beard ut DIY ethical culpa terry richardson biodiesel. Art party scenester stumptown, tumblr butcher vero sint qui sapiente accusamus tattooed echo park.'),
array('label'=>'Dropdown', 'items'=>array(
array('label'=>'@fat', 'content'=>'Etsy mixtape wayfarers, ethical wes anderson tofu before they sold out mcsweeney\'s organic lomo retro fanny pack lo-fi farm-to-table readymade. Messenger bag gentrify pitchfork tattooed craft beer, iphone skateboard locavore carles etsy salvia banksy hoodie helvetica. DIY synth PBR banksy irony. Leggings gentrify squid 8-bit cred pitchfork. Williamsburg banh mi whatever gluten-free, carles pitchfork biodiesel fixie etsy retro mlkshk vice blog. Scenester cred you probably haven\'t heard of them, vinyl craft beer blog stumptown. Pitchfork sustainable tofu synth chambray yr.'),
array('label'=>'@mdo', 'content'=>'Trust fund seitan letterpress, keytar raw denim keffiyeh etsy art party before they sold out master cleanse gluten-free squid scenester freegan cosby sweater. Fanny pack portland seitan DIY, art party locavore wolf cliche high life echo park Austin. Cred vinyl keffiyeh DIY salvia PBR, banh mi before they sold out farm-to-table VHS viral locavore cosby sweater. Lomo wolf viral, mustache readymade thundercats keffiyeh craft beer marfa ethical. Wolf salvia freegan, sartorial keffiyeh echo park vegan.'),
)),
),
)); ?> )); ?>
<h4>Source code</h4> <h4>Source code</h4>
<?php echo $parser->safeTransform("~~~ <?php echo $parser->safeTransform("~~~
[php] [php]
<?php \$this->widget('bootstrap.widgets.BootTabbable', array( <?php \$this->widget('bootstrap.widgets.BootTabbable', array(
'type'=>'pills', // 'tabs' or 'pills' 'type'=>'pills', // 'tabs' or 'pills'
...@@ -310,6 +291,62 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin ...@@ -310,6 +291,62 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
)); ?> )); ?>
~~~"); ?> ~~~"); ?>
<div class="row">
<div class="span6">
<h3>Tabs on the top</h3>
<?php $this->widget('bootstrap.widgets.BootTabbable', array(
'htmlOptions'=>array('class'=>'tabbable tabbable-placed'),
'tabs'=>$tabbable,
)); ?>
<h3>Tabs on the left</h3>
<?php $this->widget('bootstrap.widgets.BootTabbable', array(
'placement'=>'left',
'htmlOptions'=>array('class'=>'tabbable tabbable-placed'),
'tabs'=>$tabbable,
)); ?>
</div>
<div class="span6">
<h3>Tabs on the bottom</h3>
<?php $this->widget('bootstrap.widgets.BootTabbable', array(
'placement'=>'below',
'htmlOptions'=>array('class'=>'tabbable tabbable-placed'),
'tabs'=>$tabbable,
)); ?>
<h3>Tabs on the right</h3>
<?php $this->widget('bootstrap.widgets.BootTabbable', array(
'placement'=>'right',
'htmlOptions'=>array('class'=>'tabbable tabbable-placed'),
'tabs'=>$tabbable,
)); ?>
</div>
</div>
<?php echo $parser->safeTransform("~~~
[php]
<?php \$this->widget('bootstrap.widgets.BootTabbable', array(
'type'=>'tabs',
'placement'=>'below', // 'top ', 'right', 'bottom' or 'left'
'tabs'=>array(
array('label'=>'Section 1', 'content'=>'<p>I\'m in Section 1.</p>'),
array('label'=>'Section 2', 'content'=>'<p>Howdy, I\'m in Section 2.</p>'),
array('label'=>'Section 3', 'content'=>'<p>What up girl, this is Section 3.</p>'),
),
)); ?>
~~~"); ?>
<a class="top" href="#top">Back to top &uarr;</a> <a class="top" href="#top">Back to top &uarr;</a>
</section> </section>
...@@ -1161,7 +1198,7 @@ $('#buttonStateful').click(function() { ...@@ -1161,7 +1198,7 @@ $('#buttonStateful').click(function() {
array('label'=>'Breadcrumb', 'url'=>'#bootCrumb'), array('label'=>'Breadcrumb', 'url'=>'#bootCrumb'),
array('label'=>'Navbar', 'url'=>'#bootNavbar'), array('label'=>'Navbar', 'url'=>'#bootNavbar'),
array('label'=>'Menu', 'url'=>'#bootMenu'), array('label'=>'Menu', 'url'=>'#bootMenu'),
array('label'=>'Tabs', 'url'=>'#bootTabbable'), array('label'=>'Tabbable', 'url'=>'#bootTabbable'),
array('label'=>'Detail view', 'url'=>'#bootDetailView'), array('label'=>'Detail view', 'url'=>'#bootDetailView'),
array('label'=>'Grid view', 'url'=>'#bootGridView'), array('label'=>'Grid view', 'url'=>'#bootGridView'),
array('label'=>'Thumbnails', 'url'=>'#bootThumbs'), array('label'=>'Thumbnails', 'url'=>'#bootThumbs'),
......
...@@ -23,4 +23,9 @@ class BootListView extends CListView ...@@ -23,4 +23,9 @@ class BootListView extends CListView
* @var array the configuration for the pager. * @var array the configuration for the pager.
*/ */
public $pager = array('class'=>'bootstrap.widgets.BootPager'); public $pager = array('class'=>'bootstrap.widgets.BootPager');
/**
* @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;
} }
...@@ -17,12 +17,24 @@ Yii::import('bootstrap.widgets.BootWidget'); ...@@ -17,12 +17,24 @@ Yii::import('bootstrap.widgets.BootWidget');
*/ */
class BootTabbable extends BootWidget class BootTabbable extends BootWidget
{ {
// The valid placements.
const PLACEMENT_ABOVE = 'above';
const PLACEMENT_BELOW = 'below';
const PLACEMENT_LEFT = 'left';
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!
*/ */
public $type = BootMenu::TYPE_TABS; public $type = BootMenu::TYPE_TABS;
/** /**
* @var string the placement of the tabs.
* Valid values are 'above', 'below', 'left' and 'right'.
*/
public $placement = self::PLACEMENT_ABOVE;
/**
* @var array the tab configuration. * @var array the tab configuration.
*/ */
public $tabs = array(); public $tabs = array();
...@@ -38,10 +50,23 @@ class BootTabbable extends BootWidget ...@@ -38,10 +50,23 @@ class BootTabbable extends BootWidget
{ {
parent::init(); parent::init();
Yii::app()->bootstrap->registerTabs();
if (!isset($this->htmlOptions['id'])) if (!isset($this->htmlOptions['id']))
$this->htmlOptions['id'] = $this->getId(); $this->htmlOptions['id'] = $this->getId();
if (isset($this->placement))
{
$validPlacements = array(self::PLACEMENT_ABOVE, self::PLACEMENT_BELOW, self::PLACEMENT_LEFT, self::PLACEMENT_RIGHT);
if (in_array($this->placement, $validPlacements))
{
$cssClass = 'tabs-'.$this->placement;
if (isset($this->htmlOptions['class']))
$this->htmlOptions['class'] .= ' '.$cssClass;
else
$this->htmlOptions['class'] = $cssClass;
}
}
Yii::app()->bootstrap->registerTabs();
} }
/** /**
...@@ -49,20 +74,26 @@ class BootTabbable extends BootWidget ...@@ -49,20 +74,26 @@ class BootTabbable extends BootWidget
*/ */
public function run() public function run()
{ {
$panes = array(); $content = array();
$items = $this->normalizeTabs($this->tabs, $panes); $items = $this->normalizeTabs($this->tabs, $content);
echo CHtml::openTag('div', $this->htmlOptions); ob_start();
$this->controller->widget('bootstrap.widgets.BootMenu', array(
$this->controller->widget('bootstrap.widgets.BootMenu', array(
'type'=>$this->type, 'type'=>$this->type,
'encodeLabel'=>$this->encodeLabel, 'encodeLabel'=>$this->encodeLabel,
'items'=>$items, 'items'=>$items,
)); ));
$tabs = ob_get_clean();
echo '<div class="tab-content">';
echo implode('', $panes); ob_start();
echo '</div></div>'; echo '<div class="tab-content">';
echo implode('', $content);
echo '</div>';
$content = ob_get_clean();
echo CHtml::openTag('div', $this->htmlOptions);
echo $this->placement === self::PLACEMENT_BELOW ? $content.$tabs : $tabs.$content;
echo '</div>';
Yii::app()->clientScript->registerScript(__CLASS__.'#'.$this->id, "jQuery('{$this->id}').tab('show');"); Yii::app()->clientScript->registerScript(__CLASS__.'#'.$this->id, "jQuery('{$this->id}').tab('show');");
......
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