Commits

Christoffer Niska  committed 0209b11

Added todos and support for events where necessary.

  • Participants
  • Parent commits 970385d
  • Branches nativejs

Comments (0)

Files changed (18)

File components/Bootstrap.php

  */
 
 /**
- * @todo Fix collapse. http://twitter.github.com/bootstrap/javascript.html#collapse
+ * @todo Add support for passing options to the global plugins.
+ * @todo Fix collapse integration. http://twitter.github.com/bootstrap/javascript.html#collapse
+ * @todo DocBlock
  */
 class Bootstrap extends CApplicationComponent
 {

File demo/protected/views/layouts/main.php

 	<div class="footer">
 
 		<p class="powered">
-			Powered by <?php echo CHtml::link('Yii 1.1.9', 'http://www.yiiframework.com'); ?> //
-			<?php echo CHtml::link('Yii-Bootstrap 0.9.8', 'http://www.yiiframework.com/extension/bootstrap'); ?> //
-			<?php echo CHtml::link('Bootstrap 2', 'http://twitter.github.com/bootstrap'); ?> //
-			<?php echo CHtml::link('LESS 1.2.1', 'http://www.lesscss.org'); ?>
+			Powered by <?php echo CHtml::link('Yii 1.1.9', 'http://www.yiiframework.com', array('target'=>'_blank')); ?> //
+			<?php echo CHtml::link('jQuery 1.7.1', 'http://www.jquery.com', array('target'=>'_blank')); ?> //
+			<?php echo CHtml::link('Yii-Bootstrap 0.9.8', 'http://www.yiiframework.com/extension/bootstrap', array('target'=>'_blank')); ?> //
+			<?php echo CHtml::link('Bootstrap 2', 'http://twitter.github.com/bootstrap', array('target'=>'_blank')); ?> //
+			<?php echo CHtml::link('LESS 1.2.1', 'http://www.lesscss.org', array('target'=>'_blank')); ?>
 		</p>
 
 	</div>

File demo/protected/views/site/index.php

 			<h2>BootCrumb</h2>
 
 			<?php $this->widget('bootstrap.widgets.BootCrumb', array(
-				'links'=>array(
-					'Library'=>'#',
-					'Data',
-				),
+				'links'=>array('Library'=>'#', 'Data'),
 			)); ?>
 
 			<h4>Source code</h4>
 <?php echo $parser->safeTransform("~~~
 [php]
 <?php \$this->widget('bootstrap.widgets.BootCrumb', array(
-	'links'=>array(
-		'Library'=>'#',
-		'Data',
-	),
+	'links'=>array('Library'=>'#', 'Data'),
 )); ?>
 ~~~"); ?>
 
 		jQuery('a[rel=tooltip]').tooltip();
 	}\",
 )); ?>
+~~~
+**\_thumb.php**
+~~~
+[html]
+<li class=\"span3\">
+	<a href=\"#\" class=\"thumbnail\" rel=\"tooltip\" data-title=\"Tooltip\">
+		<img src=\"http://placehold.it/280x180\" alt=\"\">
+	</a>
+</li>
 ~~~"); ?>
 
 			<a class="top" href="#top">Back to top &uarr;</a>
 
 			<?php $this->beginWidget('bootstrap.widgets.BootModal', array(
 				'id'=>'modal',
+				'events'=>array(
+					'show'=>"js:function() { console.log('modal show.'); }",
+					'shown'=>"js:function() { console.log('modal shown.'); }",
+					'hide'=>"js:function() { console.log('modal hide.'); }",
+					'hidden'=>"js:function() { console.log('modal hidden.'); }",
+				),
 				'htmlOptions'=>array('class'=>'modal hide fade'),
 			)); ?>
 
 [php]
 <?php \$this->beginWidget('bootstrap.widgets.BootModal', array(
 	'id'=>'modal',
+	'events'=>array(
+		'show'=>\"js:function() { console.log('modal show.'); }\",
+		'shown'=>\"js:function() { console.log('modal shown.'); }\",
+		'hide'=>\"js:function() { console.log('modal hide.'); }\",
+		'hidden'=>\"js:function() { console.log('modal hidden.'); }\",
+	),
 	'htmlOptions'=>array('class'=>'hide fade'),
 )); ?>
 ~~~

File widgets/BootActiveForm.php

 
 Yii::import('bootstrap.widgets.BootInput');
 
+/**
+ * @todo DocBlock
+ */
 class BootActiveForm extends CActiveForm
 {
 	// The different form types.

File widgets/BootAlert.php

 Yii::import('bootstrap.widgets.BootWidget');
 
 /**
- * @todo Add support for events. http://twitter.github.com/bootstrap/javascript.html#alerts
+ * @todo DocBlock
+ * @todo Fix event support. http://twitter.github.com/bootstrap/javascript.html#alerts
  */
 class BootAlert extends BootWidget
 {
 
 		echo '</div>';
 
-		Yii::app()->clientScript->registerScript(__CLASS__.'#'.$this->id,"jQuery('#{$this->id}').alert();");
+		$selector = "#{$this->id} .alert";
+		Yii::app()->clientScript->registerScript(__CLASS__.'#'.$this->id, "jQuery('{$selector}').alert();");
+
+		/*
+		// Register the "close" event-handler.
+		if (isset($this->events['close']))
+		{
+			$fn = CJavaScript::encode($this->events['close']);
+			Yii::app()->clientScript->registerScript(__CLASS__.'#'.$this->id.'.close', "jQuery('{$selector}').bind('close', {$fn});");
+		}
+
+		// Register the "closed" event-handler.
+		if (isset($this->events['closed']))
+		{
+			$fn = CJavaScript::encode($this->events['closed']);
+			Yii::app()->clientScript->registerScript(__CLASS__.'#'.$this->id.'.closed', "jQuery('{$selector}').bind('closed', {$fn});");
+		}
+		*/
 	}
 }

File widgets/BootButtonColumn.php

 <?php
+/**
+ * @todo DocBlock
+ */
 
 Yii::import('zii.widgets.grid.CButtonColumn');
 
+/**
+ * @todo DocBlock
+ */
 class BootButtonColumn extends CButtonColumn
 {
 	public $viewButtonIconCssClass = 'icon-search';

File widgets/BootCrumb.php

  */
 
 Yii::import('zii.widgets.CBreadcrumbs');
+
+/**
+ * @todo DocBlock
+ */
 class BootCrumb extends CBreadcrumbs
 {
 	/**

File widgets/BootDetailView.php

 
 Yii::import('zii.widgets.CDetailView');
 
+/**
+ * @todo DocBlock
+ */
 class BootDetailView extends CDetailView
 {
 	/**

File widgets/BootGridView.php

 
 Yii::import('zii.widgets.grid.CGridView');
 
+/**
+ * @todo DocBlock
+ */
 class BootGridView extends CGridView
 {
 	/**

File widgets/BootInput.php

  * @copyright Copyright &copy; Christoffer Niska 2011-
  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  */
- 
+
+/**
+ * @todo DocBlock
+ */
 class BootInput extends CInputWidget
 {
 	// The different input types.

File widgets/BootListView.php

 
 Yii::import('zii.widgets.CListView');
 
+/**
+ * @todo DocBlock
+ */
 class BootListView extends CListView
 {
 	/**

File widgets/BootMenu.php

 Yii::import('bootstrap.widgets.BootWidget');
 
 /**
- * Bootstrap menu widget with support for dropdown sub-menus.
+ * Bootstrap menu widget.
  * @since 0.9.8
- * @todo Add api and target support. http://twitter.github.com/bootstrap/javascript.html#dropdowns
  */
 class BootMenu extends BootWidget
 {

File widgets/BootModal.php

 Yii::import('bootstrap.widgets.BootWidget');
 
 /**
- * @todo Add support for events. http://twitter.github.com/bootstrap/javascript.html#modals
+ * @todo DocBlock
  */
 class BootModal extends BootWidget
 {
 	public function run()
 	{
 		echo CHtml::closeTag($this->tagName);
+
+		// Register the "show" event-handler.
+		if (isset($this->events['show']))
+		{
+			$fn = CJavaScript::encode($this->events['show']);
+			Yii::app()->clientScript->registerScript(__CLASS__.'#'.$this->id.'.show', "jQuery('#{$this->id}').on('show', {$fn});");
+		}
+
+		// Register the "shown" event-handler.
+		if (isset($this->events['shown']))
+		{
+			$fn = CJavaScript::encode($this->events['shown']);
+			Yii::app()->clientScript->registerScript(__CLASS__.'#'.$this->id.'.shown', "jQuery('#{$this->id}').on('shown', {$fn});");
+		}
+
+		// Register the "hide" event-handler.
+		if (isset($this->events['hide']))
+		{
+			$fn = CJavaScript::encode($this->events['hide']);
+			Yii::app()->clientScript->registerScript(__CLASS__.'#'.$this->id.'.hide', "jQuery('#{$this->id}').on('hide', {$fn});");
+		}
+
+		// Register the "hidden" event-handler.
+		if (isset($this->events['hidden']))
+		{
+			$fn = CJavaScript::encode($this->events['hidden']);
+			Yii::app()->clientScript->registerScript(__CLASS__.'#'.$this->id.'.hidden', "jQuery('#{$this->id}').on('hidden', {$fn});");
+		}
 	}
 }

File widgets/BootNavbar.php

 Yii::import('bootstrap.widgets.BootWidget');
 
 /**
- * Bootstrap navigation widget with support for dropdown menus.
+ * Bootstrap navigation bar widget.
  * @since 0.9.7
  * @todo Add collapse support. http://twitter.github.com/bootstrap/javascript.html#collapse
  */
 	 */
 	public function init()
 	{
-		if (!isset($this->brand))
+		if ($this->brand !== false)
+		{
 			$this->brand = CHtml::encode(Yii::app()->name);
 
-		if (!isset($this->brandUrl))
-			$this->brandUrl = Yii::app()->homeUrl;
+			if (!isset($this->brandUrl))
+				$this->brandUrl = Yii::app()->homeUrl;
+		}
 	}
 
 	/**
         if ($this->brand)
             echo CHtml::openTag('a', $this->brandOptions).$this->brand.'</a>';
         
-		echo '<div class="nav-collapse collapse">';
+		echo '<div class="nav-collapse">';
 
 		foreach ($this->items as $item)
 		{

File widgets/BootPager.php

  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  */
 
+/**
+ * @todo DocBlock
+ */
 class BootPager extends CLinkPager
 {
 	/**

File widgets/BootThumbs.php

 
 Yii::import('bootstrap.widgets.BootListView');
 
+/**
+ * @todo DocBlock
+ */
 class BootThumbs extends BootListView
 {
 	/**

File widgets/BootTooltip.php

 
 Yii::import('bootstrap.widgets.BootWidget');
 
+/**
+ * @todo DocBlock
+ */
 class BootTooltip extends BootWidget
 {
 	/**

File widgets/BootWidget.php

  * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
  */
 
+/**
+ * @todo DocBlock
+ */
 class BootWidget extends CWidget
 {
 	/**
-	 * @var array the initial JavaScript options that should be passed to the Bootstrap plugin.
+	 * @var array the options for the Bootstrap JavaScript plugin.
 	 */
 	public $options = array();
 	/**
+	 * @var string[] the JavaScript event handlers.
+	 */
+	public $events = array();
+	/**
 	 * @var array the HTML attributes for the widget container.
 	 */
 	public $htmlOptions = array();
 	{
 		Yii::app()->clientScript->registerCoreScript('jquery');
 		Yii::app()->clientScript->registerCoreScript('jquery.ui');
-		
-		$this->registerScriptFile('jquery.ui.boot-widget.js');
 	}
 
 	/**