-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathEBootstrapWidget.php
62 lines (54 loc) · 1.36 KB
/
EBootstrapWidget.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* Base widget
*
* This is the parent widget of all bootstrap widgets.
* It provides some basic functionallity like the collapse option
*
*
* @author Tim Helfensdörfer <tim@visualappeal.de>
* @version 0.3.0
* @package widgets.bootstrap
*/
class EBootstrapWidget extends CWidget {
/**
* Collapse the widget
*/
public $collapse = false;
/**
* Show the widget per default
*
* If it's set to true the widget is per default open
*/
public $collapseShow = false;
/**
* Default HTML options
*/
public $htmlOptions = array();
/**
* Javascript file to include for the collapse plugin
*
* If its set to false, no file will be included
*/
public $collapseJsFile = null;
/**
* Init the widget
*/
public function init() {
parent::init();
if ($this->collapse) {
EBootstrap::mergeClass($this->htmlOptions, array('collapse'));
if ($this->collapseShow)
EBootstrap::mergeClass($this->htmlOptions, array('in'));
if (is_null($this->collapseJsFile)) {
$collapseJsFile = dirname(__FILE__).'/js/bootstrap.min.js';
$this->collapseJsFile = Yii::app()->getAssetManager()->publish($collapseJsFile);
Yii::app()->clientScript->registerScriptFile($this->collapseJsFile);
}
elseif ($this->collapseJsFile !== false) {
Yii::app()->clientScript->registerScriptFile($this->collapseJsFile);
}
}
}
}
?>