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">
<div class="row">
<div class="span8">
<?php echo $content; ?>
</div>
</div>
<div class="span4">
<div class="span4">
<?php
$this->beginWidget('zii.widgets.CPortlet', array(
'title'=>'Operations',
......@@ -15,6 +17,8 @@
));
$this->endWidget();
?>
</div>
</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>
<hr />
......
<?php $this->pageTitle=Yii::app()->name; ?>
<div class="row">
<div class="span9">
<h1>Widgets</h1>
<div class="site-index">
<section id="bootAlert">
......@@ -84,9 +80,7 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
)),
),
),
'<form class="navbar-search pull-left" action="">
<input type="text" class="search-query span2" placeholder="Search">
</form>',
'<form class="navbar-search pull-left" action=""><input type="text" class="search-query span2" placeholder="Search"></form>',
array(
'class'=>'bootstrap.widgets.BootMenu',
'htmlOptions'=>array('class'=>'pull-right'),
......@@ -128,9 +122,7 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
)),
),
),
'<form class=\"navbar-search pull-left\" action=\"\">
<input type=\"text\" class=\"search-query span2\" placeholder=\"Search\">
</form>',
'<form class=\"navbar-search pull-left\" action=\"\"><input type=\"text\" class=\"search-query span2\" placeholder=\"Search\"></form>',
array(
'class'=>'bootstrap.widgets.BootMenu',
'htmlOptions'=>array('class'=>'pull-right'),
......@@ -224,7 +216,6 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
<?php $this->widget('bootstrap.widgets.BootMenu', array(
'type'=>'list',
'encodeLabel'=>false,
'items'=>array(
array('label'=>'LIST HEADER', 'itemOptions'=>array('class'=>'nav-header')),
array('label'=>'Home', 'icon'=>'home', 'url'=>'#', 'active'=>true),
......@@ -245,7 +236,6 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
[php]
<?php \$this->widget('bootstrap.widgets.BootMenu', array(
'type'=>'list',
'encodeLabel'=>false,
'items'=>array(
array('label'=>'LIST HEADER', 'itemOptions'=>array('class'=>'nav-header')),
array('label'=>'Home', 'icon'=>'home', 'url'=>'#', 'active'=>true),
......@@ -319,7 +309,11 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
<?php $this->widget('bootstrap.widgets.BootDetailView', array(
'data'=>array('id'=>1, 'firstName'=>'Mark', 'lastName'=>'Otto', 'language'=>'CSS'),
'attributes'=>array('firstName', 'lastName', 'language'),
'attributes'=>array(
array('name'=>'firstName', 'label'=>'First name'),
array('name'=>'lastName', 'label'=>'Last name'),
array('name'=>'language', 'label'=>'Language'),
),
)); ?>
<h4>Source code</h4>
......@@ -328,7 +322,11 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
[php]
<?php \$this->widget('bootstrap.widgets.BootDetailView', array(
'data'=>array('id'=>1, 'firstName'=>'Mark', 'lastName'=>'Otto', 'language'=>'CSS'),
'attributes'=>array('firstName', 'lastName', 'language'),
'attributes'=>array(
array('name'=>'firstName', 'label'=>'First name'),
array('name'=>'lastName', 'label'=>'Last name'),
array('name'=>'language', 'label'=>'Language'),
),
)); ?>
~~~"); ?>
......@@ -518,12 +516,7 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
<?php echo $parser->safeTransform("~~~
[php]
<?php echo CHtml::link('Hover me', '#', array(
'class'=>'btn btn-primary btn-danger',
'data-title'=>'Heading',
'data-content'=>'Content ...',
'rel'=>'popover'
)); ?>
<?php echo CHtml::link('Hover me', '#', array('class'=>'btn btn-primary btn-danger', 'data-title'=>'Heading', 'data-content'=>'Content ...', 'rel'=>'popover')); ?>
~~~"); ?>
<a class="top" href="#top">Back to top &uarr;</a>
......@@ -601,10 +594,7 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
~~~
~~~
[php]
<?php echo CHtml::link('Click me','#modal', array(
'class'=>'btn btn-primary',
'data-toggle'=>'modal',
)); ?>
<?php echo CHtml::link('Click me','#modal', array('class'=>'btn btn-primary', 'data-toggle'=>'modal')); ?>
~~~"); ?>
<a class="top" href="#top">Back to top &uarr;</a>
......@@ -620,8 +610,6 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
<?php /** @var BootActiveForm $form */
$form = $this->beginWidget('bootstrap.widgets.BootActiveForm', array(
'id'=>'verticalForm',
'enableClientValidation'=>true,
'clientOptions'=>array('validateOnSubmit'=>true),
'htmlOptions'=>array('class'=>'well'),
)); ?>
......@@ -638,8 +626,6 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
$form = $this->beginWidget('bootstrap.widgets.BootActiveForm', array(
'id'=>'searchForm',
'type'=>'search',
'enableClientValidation'=>true,
'clientOptions'=>array('validateOnSubmit'=>true),
'htmlOptions'=>array('class'=>'well'),
)); ?>
......@@ -654,8 +640,6 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
$form = $this->beginWidget('bootstrap.widgets.BootActiveForm', array(
'id'=>'inlineForm',
'type'=>'inline',
'enableClientValidation'=>true,
'clientOptions'=>array('validateOnSubmit'=>true),
'htmlOptions'=>array('class'=>'well'),
)); ?>
......@@ -671,8 +655,6 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
$form = $this->beginWidget('bootstrap.widgets.BootActiveForm', array(
'id'=>'horizontalForm',
'type'=>'horizontal',
'enableClientValidation'=>true,
'clientOptions'=>array('validateOnSubmit'=>true),
)); ?>
<fieldset>
......@@ -718,8 +700,6 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
<?php /** @var BootActiveForm \$form */
\$form = \$this->beginWidget('bootstrap.widgets.BootActiveForm', array(
'id'=>'verticalForm',
'enableClientValidation'=>true,
'clientOptions'=>array('validateOnSubmit'=>true),
'htmlOptions'=>array('class'=>'well'),
)); ?>
......@@ -736,8 +716,6 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
\$form = \$this->beginWidget('bootstrap.widgets.BootActiveForm', array(
'id'=>'searchForm',
'type'=>'search',
'enableClientValidation'=>true,
'clientOptions'=>array('validateOnSubmit'=>true),
'htmlOptions'=>array('class'=>'well'),
)); ?>
......@@ -752,8 +730,6 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
\$form = \$this->beginWidget('bootstrap.widgets.BootActiveForm', array(
'id'=>'inlineForm',
'type'=>'inline',
'enableClientValidation'=>true,
'clientOptions'=>array('validateOnSubmit'=>true),
'htmlOptions'=>array('class'=>'well'),
)); ?>
......@@ -769,16 +745,13 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
\$form = \$this->beginWidget('bootstrap.widgets.BootActiveForm', array(
'id'=>'horizontalForm',
'type'=>'horizontal',
'enableClientValidation'=>true,
'clientOptions'=>array('validateOnSubmit'=>true),
)); ?>
<fieldset>
<legend>Legend</legend>
<?php echo \$form->textFieldRow(\$model, 'textField',
array('hint'=>'In addition to freeform text, any HTML5 text-based input appears like so.')); ?>
<?php echo \$form->textFieldRow(\$model, 'textField', array('hint'=>'In addition to freeform text, any HTML5 text-based input appears like so.')); ?>
<?php echo \$form->dropDownListRow(\$model, 'dropdown', array('Something ...', '1', '2', '3', '4', '5')); ?>
<?php echo \$form->dropDownListRow(\$model, 'multiDropdown', array('1', '2', '3', '4', '5'), array('multiple'=>true)); ?>
<?php echo \$form->fileFieldRow(\$model, 'fileField'); ?>
......@@ -813,34 +786,28 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
</section>
</div>
<div class="span3">
</div>
<aside class="well" style="padding: 8px 0;">
<aside id="subnav" class="well" style="padding: 8px 0;">
<?php $this->widget('bootstrap.widgets.BootMenu', array(
'type'=>'list',
//'scrollspy'=>true,
//'scrollspy'=>array('offset'=>50),
'items'=>array(
array('label'=>'WIDGETS','itemOptions'=>array('class'=>'nav-header')),
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'),
array('label'=>'WIDGETS', 'itemOptions'=>array('class'=>'nav-header')),
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'),
),
)); ?>
</aside>
</div>
</div>
\ No newline at end of file
</aside>
\ No newline at end of file
......@@ -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