Completed
Pull Request — master (#37)
by Klochok
04:53
created

ApplyPtrChange::run()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 22

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 0
cts 20
cp 0
rs 9.568
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace hipanel\modules\hosting\widgets\ip;
4
5
use Yii;
6
use yii\base\Widget;
7
use yii\helpers\Html;
8
use yii\web\View;
9
10
class ApplyPtrChange extends Widget
11
{
12
    public function init()
13
    {
14
        $this->view->registerJs(
15
            <<<'JS'
16
                $('.apply-ptr-change').popover({html: true});
17
                $(document).on('click', function (e) {
18
                    $('[data-toggle="popover"], [data-original-title]').each(function () {
19
                        if (!$(this).is(e.target) && $(this).has(e.target).length === 0 && $('.popover').has(e.target).length === 0) {
20
                            (($(this).popover('hide').data('bs.popover')||{}).inState||{}).click = false
21
                        }
22
                    });
23
                });
24
JS
25
            ,
26
            View::POS_READY
27
        );
28
        $this->view->registerCss(
29
            <<<'CSS'
30
            .apply-ptr-change {
31
                border-bottom: 1px #72afd2 dashed;
32
                font-style: italic;
33
            }
34
            
35
            .apply-ptr-change:hover {
36
                text-decoration: none;
37
            }
38
39
CSS
40
        );
41
    }
42
43
    public function run(): string
44
    {
45
        return Html::tag(
46
            'a',
47
            Yii::t('hipanel', 'Empty'),
48
            [
49
                'class' => 'apply-ptr-change',
50
                'href' => '#',
51
                'data' => [
52
                    'container' => 'body',
53
                    'toggle' => 'popover',
54
                    'title' => 'PTR',
55
                    'content' => Html::a(
56
                        Yii::t('hipanel:hosting', 'Apply for change of PTR records'),
57
                        ['@ticket/create'],
58
                        ['target' => '_blank']
59
                    ),
60
                    'placement' => 'top',
61
                ],
62
            ]
63
        );
64
    }
65
}
66