Commit f0d6adc5 by Crisu83

changed BootButton::fn to buttonType and updated the demo

parent 1a464dbc
......@@ -4,7 +4,7 @@
* @author Christoffer Niska <ChristofferNiska@gmail.com>
* @copyright Copyright &copy; Christoffer Niska 2011-
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @version 1.0.0
* @version 0.9.11
*/
/**
......@@ -99,7 +99,7 @@ class Bootstrap extends CApplicationComponent
/**
* Registers the Yii-specific CSS missing from Bootstrap.
* @since 1.0.0
* @since 0.9.11
*/
public function registerYiiCss()
{
......
......@@ -7,6 +7,7 @@
.input-block-level{display:block;width:100%;min-height:28px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box;}
.php-hl-default{color:Black;}
.php-hl-code{color:Gray;}
.php-hl-brackets{color:Olive;}
......@@ -150,7 +151,7 @@ section{padding-top:40px;}section a.top{display:block;text-align:right;}
#bootCarousel .carousel{width:770px;}#bootCarousel .carousel .carousel-caption p{margin-bottom:9px;}
#bootTypeahead input{margin-bottom:0;}
.hl-code{margin-bottom:20px;}.hl-code pre{background:#FCFCFC;border-color:#EEE transparent #EEE;font-family:"Menlo","Consolas","Courier New",Courier,mono;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;}
.php-hl-main,.html-hl-main,.javascript-hl-main{margin-bottom:20px;}.php-hl-main pre,.html-hl-main pre,.javascript-hl-main pre{background:#FCFCFC;border-color:#EEE transparent #EEE;font-family:"Menlo","Consolas","Courier New",Courier,mono;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;}
.maintenance .hero-unit{text-align:center;}.maintenance .hero-unit p{text-align:inherit;}
......
......@@ -138,7 +138,9 @@ section {
margin-bottom: 0;
}
.hl-code {
.php-hl-main,
.html-hl-main,
.javascript-hl-main {
margin-bottom: 20px;
pre {
......
......@@ -45,7 +45,7 @@ class SiteController extends Controller
);
$tabbable = array(
array('label'=>'Section 1', 'content'=>'<p>I\'m in Section 1.</p>'),
array('label'=>'Section 1', 'content'=>'<p>I\'m in Section 1.</p>', 'active'=>true),
array('label'=>'Section 2', 'content'=>'<p>Howdy, I\'m in Section 2.</p>'),
array('label'=>'Section 3', 'content'=>'<p>What up girl, this is Section 3.</p>'),
);
......@@ -93,6 +93,15 @@ class SiteController extends Controller
'pagination'=>array('pageSize'=>8),
));
$phpLighter = new CTextHighlighter();
$phpLighter->language = 'PHP';
$jsLighter = new CTextHighlighter();
$jsLighter->language = 'JAVASCRIPT';
$htmlLighter = new CTextHighlighter();
$htmlLighter->language = 'HTML';
$this->render('index', array(
'model'=>$model,
'person'=>new Person(),
......@@ -101,7 +110,9 @@ class SiteController extends Controller
'gridDataProvider'=>$gridDataProvider,
'gridColumns'=>$gridColumns,
'listDataProvider'=>$listDataProvider,
'parser'=>new CMarkdownParser(),
'phpLighter'=>$phpLighter,
'jsLighter'=>$jsLighter,
'htmlLighter'=>$htmlLighter,
));
}
......
......@@ -15,15 +15,15 @@ Yii::import('bootstrap.widgets.BootWidget');
*/
class BootButton extends BootWidget
{
// Button callback functions.
const FN_LINK = 'link';
const FN_BUTTON = 'button';
const FN_SUBMIT = 'submit';
const FN_SUBMITLINK = 'submitLink';
const FN_RESET = 'reset';
const FN_AJAXLINK = 'ajaxLink';
const FN_AJAXBUTTON = 'ajaxButton';
const FN_AJAXSUBMIT = 'ajaxSubmit';
// Button callback types.
const BUTTON_LINK = 'link';
const BUTTON_BUTTON = 'button';
const BUTTON_SUBMIT = 'submit';
const BUTTON_SUBMITLINK = 'submitLink';
const BUTTON_RESET = 'reset';
const BUTTON_AJAXLINK = 'ajaxLink';
const BUTTON_AJAXBUTTON = 'ajaxButton';
const BUTTON_AJAXSUBMIT = 'ajaxSubmit';
// Button types.
const TYPE_NORMAL = '';
......@@ -41,10 +41,10 @@ class BootButton extends BootWidget
const SIZE_LARGE = 'large';
/**
* @var string the callback function for rendering the button.
* @var string the button callback types.
* Valid values are 'link', 'button', 'submit', 'submitLink', 'reset', 'ajaxLink', 'ajaxButton' and 'ajaxSubmit'.
*/
public $fn = self::FN_LINK;
public $buttonType = self::BUTTON_LINK;
/**
* @var string the button type.
* Valid values are '', 'primary', 'info', 'success', 'warning', 'danger' and 'inverse'.
......@@ -97,7 +97,7 @@ class BootButton extends BootWidget
public $ajaxOptions = array();
/**
* @var array the HTML options for the dropdown menu.
* @since 1.0.0
* @since 0.9.11
*/
public $dropdownOptions = array();
......@@ -181,11 +181,13 @@ class BootButton extends BootWidget
echo $this->createButton();
if ($this->hasDropdown())
{
$this->controller->widget('bootstrap.widgets.BootDropdown', array(
'encodeLabel'=>$this->encodeLabel,
'items'=>$this->items,
'htmlOptions'=>$this->dropdownOptions,
));
}
}
/**
......@@ -194,31 +196,31 @@ class BootButton extends BootWidget
*/
protected function createButton()
{
switch ($this->fn)
switch ($this->buttonType)
{
case self::FN_BUTTON:
case self::BUTTON_BUTTON:
return CHtml::htmlButton($this->label, $this->htmlOptions);
case self::FN_SUBMIT:
case self::BUTTON_SUBMIT:
$this->htmlOptions['type'] = 'submit';
return CHtml::htmlButton($this->label, $this->htmlOptions);
case self::FN_RESET:
case self::BUTTON_RESET:
$this->htmlOptions['type'] = 'reset';
return CHtml::htmlButton($this->label, $this->htmlOptions);
case self::FN_SUBMITLINK:
case self::BUTTON_SUBMITLINK:
return CHtml::linkButton($this->label, $this->htmlOptions);
case self::FN_AJAXLINK:
case self::BUTTON_AJAXLINK:
return CHtml::ajaxLink($this->label, $this->url, $this->ajaxOptions, $this->htmlOptions);
case self::FN_AJAXBUTTON:
case self::BUTTON_AJAXBUTTON:
$this->ajaxOptions['url'] = $this->url;
$this->htmlOptions['ajax'] = $this->ajaxOptions;
return CHtml::htmlButton($this->label, $this->htmlOptions);
case self::FN_AJAXSUBMIT:
case self::BUTTON_AJAXSUBMIT:
$this->ajaxOptions['type'] = 'POST';
$this->ajaxOptions['url'] = $this->url;
$this->htmlOptions['type'] = 'submit';
......@@ -226,7 +228,7 @@ class BootButton extends BootWidget
return CHtml::htmlButton($this->label, $this->htmlOptions);
default:
case self::FN_LINK:
case self::BUTTON_LINK:
return CHtml::link($this->label, $this->url, $this->htmlOptions);
}
}
......
......@@ -21,10 +21,10 @@ class BootButtonGroup extends BootWidget
const TOGGLE_RADIO = 'radio';
/**
* @var string the button function.
* @see BootButton::fn
* @var string the button callback type.
* @see BootButton::buttonType
*/
public $fn = BootButton::FN_LINK;
public $buttonType = BootButton::BUTTON_LINK;
/**
* @var string the button type.
* @see BootButton::type
......@@ -78,7 +78,7 @@ class BootButtonGroup extends BootWidget
foreach ($this->buttons as $button)
{
$this->controller->widget('bootstrap.widgets.BootButton', array(
'fn'=>isset($button['fn']) ? $button['fn'] : $this->fn,
'buttonType'=>isset($button['buttonType']) ? $button['buttonType'] : $this->buttonType,
'type'=>isset($button['type']) ? $button['type'] : $this->type,
'size'=>$this->size,
'icon'=>isset($button['icon']) ? $button['icon'] : null,
......
......@@ -27,13 +27,18 @@ class BootModal extends BootWidget
if (!isset($this->htmlOptions['id']))
$this->htmlOptions['id'] = $this->getId();
$class = array('modal');
if (Yii::app()->bootstrap->isPluginRegistered(Bootstrap::PLUGIN_TRANSITION))
$class[] = 'fade';
$cssClass = implode(' ', $class);
if (isset($this->htmlOptions['class']))
$this->htmlOptions['class'] .= ' modal';
$this->htmlOptions['class'] .= ' '.$cssClass;
else
$this->htmlOptions['class'] = 'modal';
$this->htmlOptions['class'] = $cssClass;
if (Yii::app()->bootstrap->isPluginRegistered(Bootstrap::PLUGIN_TRANSITION))
$this->htmlOptions['class'] .= ' fade';
echo CHtml::openTag('div', $this->htmlOptions).PHP_EOL;
}
......
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