Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #410 from magefad/refactoring-components
Small refactoring bootstrap components
  • Loading branch information
hijarian committed Mar 26, 2013
2 parents d50ecf2 + 88cfc27 commit 8f1b790
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 67 deletions.
39 changes: 18 additions & 21 deletions components/Bootstrap.php
Expand Up @@ -8,7 +8,7 @@
*
* Modified for YiiBooster
* @author Antonio Ramirez <antonio@clevertech.biz>
* @version 1.0.5
* @version 1.0.6
*
* Added Bootstrap Modal Manager Plugin
* @author Thiago Otaviani Vidal <thiagovidal@gmail.com>
Expand Down Expand Up @@ -46,16 +46,19 @@ class Bootstrap extends CApplicationComponent
* Defaults to true.
*/
public $coreCss = true;

/**
* @var boolean whether to register the Bootstrap responsive CSS (bootstrap-responsive.min.css).
* Defaults to false.
*/
public $responsiveCss = false;

/**
* @var boolean whether to register the Font Awesome CSS (font-awesome.min.css).
* Defaults to false.
*/
public $fontAwesomeCss = false;

/**
* @var boolean whether to register the Yii-specific CSS missing from Bootstrap.
* @since 0.9.12
Expand All @@ -72,18 +75,21 @@ class Bootstrap extends CApplicationComponent
* @since 0.9.10
*/
public $enableJS = true;

/**
* @var array plugin initial options (name=>options).
* Each array key-value pair represents the initial options for a single plugin class,
* with the array key being the plugin name, and array value being the initial options array.
* @since 0.9.8
*/
public $plugins = array();

/**
* @var string default popover CSS selector.
* @since 0.10.0
*/
public $popoverSelector = 'body';

/**
* @var string default tooltip CSS selector.
* @since 0.10.0
Expand All @@ -109,7 +115,7 @@ class Bootstrap extends CApplicationComponent
* @since YiiBooster 1.0.6
*/
public $forceCopyAssets = false;

/**
* @var string handles the assets folder path.
*/
Expand Down Expand Up @@ -140,7 +146,7 @@ public function init()
if ($this->yiiCss !== false)
$this->registerYiiCss();

if($this->jqueryCss !== false)
if ($this->jqueryCss !== false)
$this->registerJQueryCss();

if ($this->enableJS !== false)
Expand Down Expand Up @@ -228,12 +234,11 @@ public function registerJS($position = CClientScript::POS_HEAD)
$cs->registerCoreScript('jquery');

/* enable bootboxJS? */
if($this->enableBootboxJS)
{
if ($this->enableBootboxJS)
$cs->registerScriptFile($this->getAssetsUrl() . '/js/bootstrap.bootbox.min.js', $position);
}

/* enable bootstrap notifier ? */
if($this->enableNotifierJS)
if ($this->enableNotifierJS)
{
// notifier requires a style
$cs->registerCssFile($this->getAssetsUrl() . '/css/bootstrap-notify.css');
Expand Down Expand Up @@ -362,10 +367,8 @@ public function registerPopover($selector = null, $options = array())
if (!isset($options['selector']))
{
$options['selector'] = '[rel=popover]';
if(null === $selector)
{
if (null === $selector)
$selector = 'body';
}
}
$this->registerPlugin(self::PLUGIN_POPOVER, $selector, $options, $this->popoverSelector);
}
Expand Down Expand Up @@ -394,10 +397,8 @@ public function registerTooltip($selector = null, $options = array())
if (!isset($options['selector']))
{
$options['selector'] = '[rel=tooltip]';
if(null === $selector)
{
if (null === $selector)
$selector = 'body';
}
}
$this->registerPlugin(self::PLUGIN_TOOLTIP, $selector, $options, $this->tooltipSelector);
}
Expand Down Expand Up @@ -430,7 +431,7 @@ public function registerDatePicker($selector = null, $options = array())
/**
* Registers the RedactorJS plugin.
* @param null $selector
* @param $options
* @param array $options
*/
public function registerRedactor($selector = null, $options = array())
{
Expand All @@ -440,7 +441,7 @@ public function registerRedactor($selector = null, $options = array())
/**
* Registers the Bootstrap-whysihtml5 plugin.
* @param null $selector
* @param $options
* @param array $options
*/
public function registerHtml5Editor($selector = null, $options = array())
{
Expand All @@ -450,7 +451,7 @@ public function registerHtml5Editor($selector = null, $options = array())
/**
* Registers the Bootstrap-colorpicker plugin.
* @param null $selector
* @param $options
* @param array $options
*/
public function registerColorPicker($selector = null, $options = array())
{
Expand All @@ -473,18 +474,14 @@ public function registerAffix($selector = null, $options = array())
* Registers the Bootstrap daterange plugin
* @param string $selector the CSS selector
* @param array $options the plugin options
* @param $callback the javascript callback function
* @param string $callback the javascript callback function
* @see http://www.dangrossman.info/2012/08/20/a-date-range-picker-for-twitter-bootstrap/
* @since 1.1.0
*/
public function registerDateRangePlugin($selector, $options = array(), $callback = null)
{

$key = __CLASS__ . '.' . md5(self::PLUGIN_DATERANGEPICKER . $selector . serialize($options) . $callback);

Yii::app()->clientScript->registerScript($key, '$("' . $selector . '").daterangepicker(' . CJavaScript::encode($options) . ($callback ? ', ' . CJavaScript::encode($callback) : '') . ');');


}


Expand Down

0 comments on commit 8f1b790

Please sign in to comment.