Commit dad11791 by niskac

added option to disable js, refactored code and updated the demo

parent 9db95b04
......@@ -38,6 +38,10 @@ class Bootstrap extends CApplicationComponent
*/
public $responsiveCss = false;
/**
* @var boolean whether to register jQuery and the Bootstrap JavaScript.
*/
public $enableJS = true;
/**
* @var array the plugin options (name=>options).
* @since 0.9.8
*/
......@@ -60,9 +64,12 @@ class Bootstrap extends CApplicationComponent
if ($this->responsiveCss)
$this->registerResponsiveCss();
if ($this->enableJS)
{
Yii::app()->clientScript->registerCoreScript('jquery');
$this->registerCorePlugins();
}
}
/**
* Returns whether a plugin is registered.
......
......@@ -101,7 +101,7 @@
)); ?>
<?php if (!empty($this->breadcrumbs)):?>
<?php $this->widget('bootstrap.widgets.BootCrumb', array(
<?php $this->widget('bootstrap.widgets.BootBreadcrumbs', array(
'links'=>$this->breadcrumbs,
)); ?>
<?php endif?>
......
......@@ -42,11 +42,11 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
</section>
<section id="bootCrumb">
<section id="bootBreadcrumbs">
<h2>Breadcrumbs</h2>
<?php $this->widget('bootstrap.widgets.BootCrumb', array(
<?php $this->widget('bootstrap.widgets.BootBreadcrumbs', array(
'links'=>array('Library'=>'#', 'Data'),
)); ?>
......@@ -54,7 +54,7 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
<?php echo $parser->safeTransform("~~~
[php]
<?php \$this->widget('bootstrap.widgets.BootCrumb', array(
<?php \$this->widget('bootstrap.widgets.BootBreadcrumbs', array(
'links'=>array('Library'=>'#', 'Data'),
)); ?>
~~~"); ?>
......@@ -81,7 +81,7 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
array('label'=>'Link', 'url'=>'#'),
array('label'=>'Link', 'url'=>'#'),
array('label'=>'Dropdown', 'url'=>'#', 'items'=>array(
array('label'=>'DROPDOWN HEADER', 'header'=>true),
array('label'=>'DROPDOWN HEADER'),
array('label'=>'Action', 'url'=>'#'),
array('label'=>'Another action', 'url'=>'#'),
array('label'=>'Something else here', 'url'=>'#'),
......@@ -97,6 +97,7 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
'items'=>array(
array('label'=>'Link', 'url'=>'#'),
array('label'=>'Dropdown', 'url'=>'#', 'items'=>array(
array('label'=>'DROPDOWN HEADER'),
array('label'=>'Action', 'url'=>'#'),
array('label'=>'Another action', 'url'=>'#'),
array('label'=>'Something else here', 'url'=>'#'),
......@@ -124,7 +125,7 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
array('label'=>'Home', 'url'=>'#', 'active'=>true),
array('label'=>'Link', 'url'=>'#'),
array('label'=>'Dropdown', 'url'=>'#', 'items'=>array(
array('label'=>'DROPDOWN HEADER', 'itemOptions'=>array('class'=>'nav-header')),
array('label'=>'DROPDOWN HEADER'),
array('label'=>'Action', 'url'=>'#'),
array('label'=>'Another action', 'url'=>'#'),
array('label'=>'Something else here', 'url'=>'#'),
......@@ -140,6 +141,7 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
'items'=>array(
array('label'=>'Link', 'url'=>'#'),
array('label'=>'Dropdown', 'url'=>'#', 'items'=>array(
array('label'=>'DROPDOWN HEADER'),
array('label'=>'Action', 'url'=>'#'),
array('label'=>'Another action', 'url'=>'#'),
array('label'=>'Something else here', 'url'=>'#'),
......@@ -470,11 +472,11 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
</section>
<section id="bootThumbs">
<section id="bootThumbnails">
<h2>Thumbnails</h2>
<?php $this->widget('bootstrap.widgets.BootThumbs', array(
<?php $this->widget('bootstrap.widgets.BootThumbnails', array(
'dataProvider'=>$listDataProvider,
'template'=>"{items}\n{pager}",
'itemView'=>'_thumb',
......@@ -489,7 +491,7 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
<?php echo $parser->safeTransform("~~~
[php]
<?php \$this->widget('bootstrap.widgets.BootThumbs', array(
<?php \$this->widget('bootstrap.widgets.BootThumbnails', array(
'dataProvider'=>\$listDataProvider,
'template'=>\"{items}\\n{pager}\",
'itemView'=>'_thumb',
......@@ -701,10 +703,6 @@ Yii::app()->user->setFlash('error', '<strong>Oh snap!</strong> Change a few thin
<?php $this->endWidget(); ?>
<div class="alert alert-block alert-warning">
</div>
<h3>Horizontal</h3>
<?php /** @var BootActiveForm $form */
......@@ -1367,13 +1365,13 @@ $('#buttonStateful').click(function() {
'scrollspy'=>array('spy'=>'.subnav', 'offset'=>50),
'items'=>array(
array('label'=>'Alert', 'url'=>'#bootAlert'),
array('label'=>'Breadcrumb', 'url'=>'#bootCrumb'),
array('label'=>'Breadcrumb', 'url'=>'#bootBreadcrumbs'),
array('label'=>'Navbar', 'url'=>'#bootNavbar'),
array('label'=>'Menu', 'url'=>'#bootMenu'),
array('label'=>'Tabbable', 'url'=>'#bootTabbable'),
array('label'=>'Detail view', 'url'=>'#bootDetailView'),
array('label'=>'Grid view', 'url'=>'#bootGridView'),
array('label'=>'Thumbnail', 'url'=>'#bootThumbs'),
array('label'=>'Thumbnail', 'url'=>'#bootThumbnails'),
array('label'=>'Tooltip', 'url'=>'#bootTooltip'),
array('label'=>'Popover', 'url'=>'#bootPopover'),
array('label'=>'Modal', 'url'=>'#bootModal'),
......
......@@ -14,12 +14,13 @@ Yii::import('bootstrap.widgets.input.BootInput');
*/
class BootActiveForm extends CActiveForm
{
// The different form types.
// Form types.
const TYPE_VERTICAL = 'vertical';
const TYPE_INLINE = 'inline';
const TYPE_HORIZONTAL = 'horizontal';
const TYPE_SEARCH = 'search';
// Input classes.
const INPUT_HORIZONTAL = 'bootstrap.widgets.input.BootInputHorizontal';
const INPUT_INLINE = 'bootstrap.widgets.input.BootInputInline';
const INPUT_SEARCH = 'bootstrap.widgets.input.BootInputSearch';
......
......@@ -55,9 +55,6 @@ abstract class BootBaseMenu extends BootWidget
$item['label'] = '<i class="'.$item['icon'].'"></i> '.$item['label'];
}
if (!isset($item['header']) && !isset($item['url']))
$item['url'] = '#';
if (isset($item['url']))
return CHtml::link($item['label'], $item['url'], $item['linkOptions']);
else
......
......@@ -12,14 +12,14 @@ Yii::import('zii.widgets.CBreadcrumbs');
/**
* Bootstrap breadcrumb widget.
*/
class BootCrumb extends CBreadcrumbs
class BootBreadcrumbs extends CBreadcrumbs
{
/**
* @var array the HTML attributes for the breadcrumbs container tag.
*/
public $htmlOptions=array('class'=>'breadcrumb');
public $htmlOptions = array('class'=>'breadcrumb');
/**
* @var string the separator between links in the breadcrumbs. Defaults to ' / '.
* @var string the separator between links in the breadcrumbs (defaults to ' / ').
*/
public $separator = '/';
......
......@@ -10,13 +10,18 @@
Yii::import('bootstrap.widgets.BootWidget');
/**
* Bootstrap button widget.
*/
class BootButton extends BootWidget
{
// Button methods.
const METHOD_LINK = 'link';
const METHOD_BUTTON = 'button';
const METHOD_AJAXLINK = 'ajaxLink';
const METHOD_AJAXBUTTON = 'ajaxButton';
// Button types.
const TYPE_NORMAL = '';
const TYPE_PRIMARY = 'primary';
const TYPE_INFO = 'info';
......@@ -25,22 +30,65 @@ class BootButton extends BootWidget
const TYPE_DANGER = 'danger';
const TYPE_INVERSE = 'inverse';
// Button sizes.
const SIZE_SMALL = 'small';
const SIZE_NORMAL = '';
const SIZE_LARGE = 'large';
/**
* @var string the method to use for rendering the button.
* Valid values are 'link', 'button', 'ajaxLink' and 'ajaxButton'.
*/
public $method = self::METHOD_LINK;
/**
* @var string the button type.
* Valid values are '', 'primary', 'info', 'success', 'warning', 'danger' and 'inverse'.
*/
public $type = self::TYPE_NORMAL;
/**
* @var string the button size.
* Valid values are '', 'small' and 'large'.
*/
public $size = self::SIZE_NORMAL;
/**
* @var string the button icon, e.g. 'ok' or 'remove white'.
*/
public $icon;
/**
* @var string the button label.
*/
public $label;
/**
* @var string the button URL.
*/
public $url;
/**
* @var boolean indicates whether the button is active.
*/
public $active = false;
/**
* @var array the dropdown button items.
*/
public $items;
/**
* @var boolean indicates whether to enable toggle.
*/
public $toggle;
/**
* @var string the loading text.
*/
public $loadingText;
/**
* @var string the complete text.
*/
public $completeText;
/**
* @var boolean indicates whether to encode the label.
*/
public $encodeLabel = true;
/**
* @var array the button ajax options (used by 'ajaxLink' and 'ajaxButton').
*/
public $ajaxOptions = array();
/**
......@@ -70,6 +118,9 @@ class BootButton extends BootWidget
if ($this->hasDropdown())
{
if (!isset($this->url))
$this->url = '#';
$class[] = 'dropdown-toggle';
$this->label .= ' <span class="caret"></span>';
$this->htmlOptions['data-toggle'] = 'dropdown';
......
......@@ -5,19 +5,28 @@
* @copyright Copyright &copy; Christoffer Niska 2011-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package bootstrap.widgets
* @since 0.9.8
*/
Yii::import('zii.widgets.grid.CButtonColumn');
/**
* Bootstrap button column widget.
* Used to set zbuttons to use Glyphicons instead of the defaults.
* @since 0.9.8
* Used to set buttons to use Glyphicons instead of the defaults images.
*/
class BootButtonColumn extends CButtonColumn
{
/**
* @var string the view button icon (defaults to 'eye-open').
*/
public $viewButtonIcon = 'eye-open';
/**
* @var string the update button icon (defaults to 'pencil').
*/
public $updateButtonIcon = 'pencil';
/**
* @var string the delete button icon (defaults to 'trash').
*/
public $deleteButtonIcon = 'trash';
/**
......
......@@ -11,18 +11,46 @@
Yii::import('bootstrap.widgets.BootButton');
Yii::import('bootstrap.widgets.BootWidget');
/**
* Bootstrap button group widget.
*/
class BootButtonGroup extends BootWidget
{
// Toggle options.
const TOGGLE_CHECKBOX = 'checkbox';
const TOGGLE_RADIO = 'radio';
/**
* @var string the button method.
* @see BootButton::method
*/
public $method = BootButton::METHOD_LINK;
/**
* @var string the button type.
* @see BootButton::type
*/
public $type = BootButton::TYPE_NORMAL;
/**
* @var string the button size.
* @see BootButton::size
*/
public $size = BootButton::SIZE_NORMAL;
/**
* @var boolean indicates whether to encode the button labels.
*/
public $encodeLabel = true;
/**
* @var array the button configuration.
*/
public $buttons = array();
/**
* @var boolean indicates whether to enable button toggling.
*/
public $toggle;
/**
* Initializes the widget.
*/
public function init()
{
$cssClass = 'btn-group';
......@@ -40,6 +68,9 @@ class BootButtonGroup extends BootWidget
}
}
/**
* Runs the widget.
*/
public function run()
{
echo CHtml::openTag('div', $this->htmlOptions);
......
......@@ -18,7 +18,7 @@ class BootDetailView extends CDetailView
/**
* @var string the template used to render a single attribute. Defaults to a table row.
*/
public $itemTemplate="<tr class=\"{class}\"><th style=\"width: 160px\">{label}</th><td>{value}</td></tr>\n";
public $itemTemplate = "<tr class=\"{class}\"><th style=\"width: 160px\">{label}</th><td>{value}</td></tr>\n";
/**
* @var array the CSS class names for the items displaying attribute values.
*/
......
......@@ -10,6 +10,9 @@
Yii::import('bootstrap.widgets.BootBaseMenu');
/**
* Bootstrap dropdown menu widget.
*/
class BootDropdown extends BootBaseMenu
{
/**
......@@ -45,7 +48,7 @@ class BootDropdown extends BootBaseMenu
$item['itemOptions'] = array();
$class = array();
if (isset($item['header']))
if (!isset($item['url']))
$class[] = 'nav-header';
if ($item['active'])
......
......@@ -16,7 +16,7 @@ Yii::import('bootstrap.widgets.BootBaseMenu');
*/
class BootMenu extends BootBaseMenu
{
// The different menu types.
// Menu types.
const TYPE_UNSTYLED = '';
const TYPE_TABS = 'tabs';
const TYPE_PILLS = 'pills';
......@@ -151,6 +151,9 @@ class BootMenu extends BootBaseMenu
$item['label'] .= ' <span class="caret"></span>';
}
if (!isset($item['url']))
$item['url'] = '#';
return parent::renderItem($item);
}
......
......@@ -5,13 +5,13 @@
* @copyright Copyright &copy; Christoffer Niska 2011-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package bootstrap.widgets
* @since 0.9.3
*/
Yii::import('bootstrap.widgets.BootWidget');
/**
* Bootstrap modal widget.
* @since 0.9.3
*/
class BootModal extends BootWidget
{
......
......@@ -5,13 +5,13 @@
* @copyright Copyright &copy; Christoffer Niska 2011-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @package bootstrap.widgets
* @since 0.9.7
*/
Yii::import('bootstrap.widgets.BootWidget');
/**
* Bootstrap navigation bar widget.
* @since 0.9.7
*/
class BootNavbar extends BootWidget
{
......
......@@ -15,7 +15,7 @@ Yii::import('bootstrap.widgets.BootWidget');
*/
class BootProgress extends BootWidget
{
// The different progress bar types.
// Progress bar types.
const TYPE_DEFAULT = '';
const TYPE_INFO = 'info';
const TYPE_SUCCESS = 'success';
......
......@@ -17,7 +17,7 @@ Yii::import('bootstrap.widgets.BootWidget');
*/
class BootTabbable extends BootWidget
{
// The valid placements.
// Tab placements.
const PLACEMENT_ABOVE = 'above';
const PLACEMENT_BELOW = 'below';
const PLACEMENT_LEFT = 'left';
......
......@@ -12,7 +12,7 @@ Yii::import('bootstrap.widgets.BootListView');
/**
* Bootstrap thumbnails widget.
*/
class BootThumbs extends BootListView
class BootThumbnails extends BootListView
{
/**
* Renders the data items for the view.
......
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