Commit dc9870ca by niskac

Fixed ScrollSpy, fixed a few bugs with BootNavbar and BootTabbed and updated the demo.

parent 1d913faf
...@@ -251,7 +251,7 @@ class Bootstrap extends CApplicationComponent ...@@ -251,7 +251,7 @@ class Bootstrap extends CApplicationComponent
if (isset($offset)) if (isset($offset))
$script .= "jQuery('{$selector}').attr('data-offset', '{$offset}');"; $script .= "jQuery('{$selector}').attr('data-offset', '{$offset}');";
Yii::app()->clientScript->registerScript(__CLASS__.'.spyOn.'.$selector, $script); Yii::app()->clientScript->registerScript(__CLASS__.'.spyOn.'.$selector, $script, CClientScript::POS_BEGIN);
} }
/** /**
......
// PRE-IMPORTS // PRE-IMPORTS
@import "../../lib/bootstrap/less/bootstrap.less"; @import "../../lib/bootstrap/less/mixins.less";
//@import "../yii/vendors/TextHighlighter/highlight.css"; //@import "../yii/vendors/TextHighlighter/highlight.css";
// VARIABLES // VARIABLES
@imageUrl: "../../../demo/images/";
body { body {
padding-top: 100px; padding-top: 60px;
padding-bottom: 40px; padding-bottom: 60px;
} }
h1, h2, h3, h4, h5, h6 { h1, h2, h3, h4, h5, h6 {
...@@ -17,51 +15,51 @@ h1, h2, h3, h4, h5, h6 { ...@@ -17,51 +15,51 @@ h1, h2, h3, h4, h5, h6 {
} }
.subnav { .subnav {
border: 1px solid #E5E5E5; border: 1px solid #E5E5E5;
.border-radius(4px); font-size: 12px;
.size(36px, 100%); .border-radius(4px);
#gradient > .vertical(#F5F5F5, #EEE); .size(36px, 100%);
#gradient > .vertical(#F5F5F5, #EEE);
&.subnav-fixed {
border-color: #D5D5D5; &.subnav-fixed {
border-width: 0 0 1px; border-color: #D5D5D5;
left: 0; border-width: 1px 0 0;
position: fixed; bottom: 0;
right: 0; left: 0;
top: 40px; position: fixed;
z-index: 1030; right: 0;
z-index: 1030;
.border-radius(0); .border-radius(0);
.box-shadow(inset 0 1px 0 #FFF, 0 1px 5px rgba(0, 0, 0, .1)); .box-shadow(inset 0 1px 0 #FFF, 0 1px 5px rgba(0, 0, 0, .1));
} }
.nav { .nav {
margin: 0 auto; margin: 0 auto;
width: 1170px; max-width: 1170px;
& > li > a { & > li > a {
margin: 0; margin: 0;
padding-top: 11px; padding: 11px;
padding-bottom: 11px; border-left: 1px solid whiteSmoke;
border-left: 1px solid whiteSmoke; border-right: 1px solid #E5E5E5;
border-right: 1px solid #E5E5E5; .border-radius(0);
.border-radius(0); }
}
& > li:first-child > a {
& > li:first-child > a { border-left: 0;
border-left: 0; }
}
& > li:last-child > a {
& > li:last-child > a { border-right: 0;
border-right: 0; }
}
& > .active >a, & .action > a:hover {
& > .active >a, & .action > a:hover { background-color: #E9E9E9;
background-color: #E9E9E9; border-right-color: #DDD;
border-right-color: #DDD; color: #777;
color: #777; .box-shadow(inset 0 3px 5px rgba(0, 0, 0, .05));
.box-shadow(inset 0 3px 5px rgba(0, 0, 0, .05)); }
} }
}
} }
footer { footer {
...@@ -97,7 +95,7 @@ span.required { ...@@ -97,7 +95,7 @@ span.required {
} }
section { section {
padding-top: 80px; padding-top: 40px;
a.top { a.top {
display: block; display: block;
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
<!--[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]-->
<?php Yii::app()->bootstrap->registerCss(); ?>
<link rel="stylesheet/less" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/less/styles.less" /> <link rel="stylesheet/less" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/less/styles.less" />
<script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/less-1.2.1.min.js"></script> <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/less-1.2.1.min.js"></script>
<script type="text/javascript"> <script type="text/javascript">
...@@ -31,7 +32,7 @@ ...@@ -31,7 +32,7 @@
'collapse'=>true, 'collapse'=>true,
'items'=>array( 'items'=>array(
array( array(
'class'=>'bootstrap.widgets.BootMenu', 'class'=>'BootMenu',
'items'=>array( 'items'=>array(
array('label'=>'Home', 'url'=>'#'), array('label'=>'Home', 'url'=>'#'),
array('label'=>'About', 'url'=>'#'), array('label'=>'About', 'url'=>'#'),
...@@ -42,30 +43,6 @@ ...@@ -42,30 +43,6 @@
), ),
)); ?> )); ?>
<div class="subnav subnav-fixed">
<?php $this->widget('bootstrap.widgets.BootMenu', array(
'type'=>'pills',
//'scrollspy'=>array('offset'=>50),
'items'=>array(
array('label'=>'BootAlert', 'url'=>'#bootAlert'),
array('label'=>'BootCrumb', 'url'=>'#bootCrumb'),
array('label'=>'BootNavbar', 'url'=>'#bootNavbar'),
array('label'=>'BootMenu', 'url'=>'#bootMenu'),
array('label'=>'BootTabbed', 'url'=>'#bootTabbed'),
array('label'=>'BootDetailView', 'url'=>'#bootDetailView'),
array('label'=>'BootGridView', 'url'=>'#bootGridView'),
array('label'=>'BootThumbs', 'url'=>'#bootThumbs'),
array('label'=>'BootTooltip', 'url'=>'#bootTooltip'),
array('label'=>'BootPopover', 'url'=>'#bootPopover'),
array('label'=>'BootModal', 'url'=>'#bootModal'),
array('label'=>'BootActiveForm', 'url'=>'#bootActiveForm'),
),
)); ?>
</div>
<div class="container"> <div class="container">
<div class="hero-unit"> <div class="hero-unit">
......
...@@ -89,26 +89,20 @@ class BootMenu extends BootWidget ...@@ -89,26 +89,20 @@ class BootMenu extends BootWidget
$this->renderItems($this->items); $this->renderItems($this->items);
echo '</ul>'; echo '</ul>';
/** @var Bootstrap $bootstrap */ Yii::app()->bootstrap->registerDropdown();
$bootstrap = Yii::app()->bootstrap;
$bootstrap->registerDropdown();
/* if (isset($this->scrollspy) && is_array($this->scrollspy) && isset($this->scrollspy['spy']))
if (isset($this->scrollspy))
{ {
if (!is_array($this->scrollspy)) Yii::app()->bootstrap->registerScrollSpy();
$this->scrollspy = array();
if (!isset($this->scrollspy['target'])) if (!isset($this->scrollspy['subject']))
$this->scrollspy['target'] = 'body'; $this->scrollspy['subject'] = 'body';
if (!isset($this->scrollspy['offset'])) if (!isset($this->scrollspy['offset']))
$this->scrollspy['offset'] = null; $this->scrollspy['offset'] = null;
$bootstrap->registerScrollSpy(); Yii::app()->bootstrap->spyOn($this->scrollspy['subject'], $this->scrollspy['spy'], $this->scrollspy['offset']);
$bootstrap->spyOn($this->scrollspy['target'], '#'.$this->id, $this->scrollspy['offset']);
} }
*/
} }
} }
...@@ -178,6 +172,13 @@ class BootMenu extends BootWidget ...@@ -178,6 +172,13 @@ class BootMenu extends BootWidget
*/ */
protected function renderItem($item) protected function renderItem($item)
{ {
if (isset($item['icon'])) {
if (strpos($item['icon'], 'icon') === false)
$item['icon'] = 'icon-'.$item['icon'];
$item['label'] = '<i class="'.$item['icon'].'"></i> '.$item['label'];
}
if (isset($item['items'])) if (isset($item['items']))
{ {
if (!isset($item['url'])) if (!isset($item['url']))
...@@ -193,16 +194,7 @@ class BootMenu extends BootWidget ...@@ -193,16 +194,7 @@ class BootMenu extends BootWidget
} }
if (isset($item['url'])) if (isset($item['url']))
{
if (isset($item['icon'])) {
if (strpos($item['icon'], 'icon') === false)
$item['icon'] = 'icon-'.$item['icon'];
$item['label'] = '<i class="'.$item['icon'].'"></i> '.$item['label'];
}
return CHtml::link($item['label'], $item['url'], isset($item['linkOptions']) ? $item['linkOptions'] : array()); return CHtml::link($item['label'], $item['url'], isset($item['linkOptions']) ? $item['linkOptions'] : array());
}
else else
return $item['label']; return $item['label'];
} }
......
...@@ -52,7 +52,7 @@ class BootNavbar extends BootWidget ...@@ -52,7 +52,7 @@ class BootNavbar extends BootWidget
*/ */
public function init() public function init()
{ {
if (!$this->brand) if ($this->brand !== false)
{ {
$this->brand = CHtml::encode(Yii::app()->name); $this->brand = CHtml::encode(Yii::app()->name);
......
...@@ -101,21 +101,12 @@ class BootTabbed extends BootWidget ...@@ -101,21 +101,12 @@ class BootTabbed extends BootWidget
foreach ($tabs as $tab) foreach ($tabs as $tab)
{ {
$i++;
$item = $tab; $item = $tab;
if (!isset($item['id']))
$item['id'] = $id.'_tab_'.$i;
if (!isset($item['label']))
$item['label'] = '';
$item['url'] = '#'.$item['id'];
if (!isset($item['itemOptions'])) if (!isset($item['itemOptions']))
$item['itemOptions'] = array(); $item['itemOptions'] = array();
if ($i === 1) if ($i === 0)
{ {
if (isset($item['itemOptions']['class'])) if (isset($item['itemOptions']['class']))
$item['itemOptions']['class'] .= ' active'; $item['itemOptions']['class'] .= ' active';
...@@ -126,42 +117,47 @@ class BootTabbed extends BootWidget ...@@ -126,42 +117,47 @@ class BootTabbed extends BootWidget
$item['linkOptions']['data-toggle'] = 'tab'; $item['linkOptions']['data-toggle'] = 'tab';
if (isset($tab['items'])) if (isset($tab['items']))
{
$item['items'] = $this->normalizeTabs($item['items'], $panes, $i); $item['items'] = $this->normalizeTabs($item['items'], $panes, $i);
unset($item['url']); else
} {
if (!isset($item['id']))
$item['id'] = $id.'_tab_'.++$i;
if (!isset($item['content'])) $item['url'] = '#'.$item['id'];
$item['content'] = '';
$content = $item['content']; if (!isset($item['content']))
unset($item['content']); $item['content'] = '';
if (!isset($item['paneOptions'])) $content = $item['content'];
$item['paneOptions'] = array(); unset($item['content']);
$paneOptions = $item['paneOptions']; if (!isset($item['paneOptions']))
unset($item['paneOptions']); $item['paneOptions'] = array();
$paneOptions['id'] = $item['id']; $paneOptions = $item['paneOptions'];
unset($item['paneOptions']);
if (isset($tab['paneOptions']['class'])) $paneOptions['id'] = $item['id'];
$paneOptions['class'] .= ' tab-pane';
else
$paneOptions['class'] = 'tab-pane';
if ($transitions) if (isset($tab['paneOptions']['class']))
$paneOptions['class'] .= ' fade'; $paneOptions['class'] .= ' tab-pane';
else
$paneOptions['class'] = 'tab-pane';
if ($i === 1) if ($transitions)
{ $paneOptions['class'] .= ' fade';
if ($transitions)
$paneOptions['class'] .= ' in';
$paneOptions['class'] .= ' active'; if ($i === 1)
} {
if ($transitions)
$paneOptions['class'] .= ' in';
$paneOptions['class'] .= ' active';
}
$panes[] = CHtml::tag('div', $paneOptions, $content);
}
$panes[] = CHtml::tag('div', $paneOptions, $content);
$items[] = $item; $items[] = $item;
} }
......
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