Commit 72854898 by Crisu83

Disabled scrollspy and updated the demo.

parent 31aaada1
......@@ -184,15 +184,6 @@ class Bootstrap extends CApplicationComponent
public function registerScrollSpy($selector = null, $options = array())
{
$this->registerPlugin(self::PLUGIN_SCROLLSPY, $selector, $options);
if (!isset($selector))
{
$selector = isset($this->plugins[self::PLUGIN_SCROLLSPY], $this->plugins[self::PLUGIN_SCROLLSPY]['selector'])
? $this->plugins[self::PLUGIN_SCROLLSPY]['selector']
: 'body';
}
Yii::app()->clientScript->registerScript(__CLASS__.'.scrollspy', "jQuery({$selector}).attr('data-spy', 'scroll');");
}
/**
......@@ -245,6 +236,25 @@ class Bootstrap extends CApplicationComponent
}
/**
* Sets the target element for the scrollspy.
* @param string $selector the CSS selector
* @param string $target the target CSS selector
* @param string $offset the offset
*/
public function spyOn($selector, $target = null, $offset = null)
{
$script = "jQuery('{$selector}').attr('data-spy', 'scroll');";
if (isset($target))
$script .= "jQuery('{$selector}').attr('data-target', '{$target}');";
if (isset($offset))
$script .= "jQuery('{$selector}').attr('data-offset', '{$offset}');";
Yii::app()->clientScript->registerScript(__CLASS__.'.spyOn.'.$selector, $script);
}
/**
* Returns whether a plugin is disabled in the plugin configuration.
* @param string $name the name of the plugin
* @return boolean the result
......@@ -260,7 +270,7 @@ class Bootstrap extends CApplicationComponent
* @param string $name the name of the plugin
* @param string $selector the CSS selector
* @param array $options the plugin options
* @param string $defaultSelector the default selector to use
* @param string $defaultSelector the default CSS selector
* @since 0.9.8
*/
protected function registerPlugin($name, $selector = null, $options = array(), $defaultSelector = null)
......
......@@ -77,6 +77,13 @@ section {
font-weight: bold;
}
#subnav {
left: 20px;
position: fixed;
top: 60px;
width: 270px;
}
// POST-IMPORTS
// Responsive style must be included after the body padding has been set.
......
......@@ -48,7 +48,7 @@ class SiteController extends Controller
$rawData[] = array('id'=>$i + 1);
$listDataProvider = new CArrayDataProvider($rawData, array(
'pagination'=>array('pageSize'=>9),
'pagination'=>array('pageSize'=>12),
));
$parser = new CMarkdownParser();
......
<?php $this->beginContent('//layouts/main'); ?>
<div class="span12">
<?php echo $content; ?>
</div>
<?php echo $content; ?>
<?php $this->endContent(); ?>
\ No newline at end of file
<?php $this->beginContent('//layouts/main'); ?>
<div class="span8">
<?php echo $content; ?>
</div>
<div class="row">
<div class="span8">
<?php echo $content; ?>
</div>
<div class="span4">
<?php
$this->beginWidget('zii.widgets.CPortlet', array(
'title'=>'Operations',
));
$this->widget('zii.widgets.CMenu', array(
'items'=>$this->menu,
'htmlOptions'=>array('class'=>'operations'),
));
$this->endWidget();
?>
</div>
<div class="span4">
<?php
$this->beginWidget('zii.widgets.CPortlet', array(
'title'=>'Operations',
));
$this->widget('zii.widgets.CMenu', array(
'items'=>$this->menu,
'htmlOptions'=>array('class'=>'operations'),
));
$this->endWidget();
?>
</div>
<?php $this->endContent(); ?>
\ No newline at end of file
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<!doctype html>
<html>
<head>
<title><?php echo CHtml::encode($this->pageTitle); ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
......@@ -54,9 +54,7 @@
)); ?>
<?php endif?>
<div class="row">
<?php echo $content; ?>
</div>
<?php echo $content; ?>
<hr />
......
......@@ -13,6 +13,7 @@ Yii::import('bootstrap.widgets.BootWidget');
* Bootstrap menu widget.
* Used for rendering of bootstrap menus with support dropdown sub-menus and scroll-spying.
* @since 0.9.8
* @todo Fix scrollspy.
*/
class BootMenu extends BootWidget
{
......@@ -32,9 +33,9 @@ class BootMenu extends BootWidget
*/
public $stacked = false;
/**
* @var boolean whether to enable the scroll-spy.
* @var array the scroll-spy configuration.
*/
public $scrollspy = false;
public $scrollspy;
/**
* @var array the menu items.
*/
......@@ -88,10 +89,26 @@ class BootMenu extends BootWidget
$this->renderItems($this->items);
echo '</ul>';
Yii::app()->bootstrap->registerDropdown();
/** @var Bootstrap $bootstrap */
$bootstrap = Yii::app()->bootstrap;
$bootstrap->registerDropdown();
if ($this->scrollspy)
Yii::app()->bootstrap->registerScrollSpy('#'.$this->id);
/*
if (isset($this->scrollspy))
{
if (!is_array($this->scrollspy))
$this->scrollspy = array();
if (!isset($this->scrollspy['target']))
$this->scrollspy['target'] = 'body';
if (!isset($this->scrollspy['offset']))
$this->scrollspy['offset'] = null;
$bootstrap->registerScrollSpy();
$bootstrap->spyOn($this->scrollspy['target'], '#'.$this->id, $this->scrollspy['offset']);
}
*/
}
}
......
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