Completed
Push — master ( c1fce6...6de931 )
by Alexey
02:42
created

ControlSidebar::init()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
namespace backend\widgets\control;
4
5
use yii\bootstrap\Widget;
6
use yii\web\JsExpression;
7
8
/**
9
 * Class ControlSidebar
10
 * @package backend\themes\AdminLTE\widgets
11
 */
12
class ControlSidebar extends Widget
13
{
14
    /**
15
     * @var bool
16
     */
17
    public $status = true;
18
19
    /**
20
     * @var bool
21
     */
22
    public $demo = false;
23
24
    /**
25
     * @inheritdoc
26
     */
27
    public function run()
28
    {
29
        if ($this->status === true) {
30
            $this->registerAssets();
31
            echo $this->render('controlSidebar');
32
        }
33
    }
34
35
    /**
36
     * @inheritdoc
37
     */
38
    public function registerAssets()
39
    {
40
        $view = $this->getView();
41
        $script = new JsExpression("
42
            $('a[href=\"#control-sidebar-home-tab\"]').parent().removeClass('active');
43
            $('#control-sidebar-home-tab').removeClass('active');
44
        ");
45
        if ($this->demo === true) {
46
            DemoAsset::register($view);
47
            $view->registerJs($script);
48
        }
49
    }
50
}
51