Completed
Push — master ( 4b5e24...bb73d0 )
by Song
02:30
created

Secret::addScript()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
namespace Encore\Admin\Grid\Displayers;
4
5
use Encore\Admin\Facades\Admin;
6
7
class Secret extends AbstractDisplayer
8
{
9
    public function display($dotCount = 6)
10
    {
11
        $this->addScript();
12
13
        $dots = str_repeat('*', $dotCount);
14
15
        return <<<HTML
16
<span class="secret-wrapper">
17
    <i class="fa fa-eye" style="cursor: pointer;"></i>
18
    &nbsp;
19
    <span class="secret-placeholder" style="vertical-align: middle;">{$dots}</span>
20
    <span class="secret-content" style="display: none;">{$this->getValue()}</span>
21
</span>
22
HTML;
23
    }
24
25
    protected function addScript()
26
    {
27
        $script = <<<SCRIPT
28
$('.secret-wrapper i').click(function () {
29
    $(this).toggleClass('fa-eye fa-eye-slash').parent().find('.secret-placeholder,.secret-content').toggle();
30
});
31
SCRIPT;
32
33
        Admin::script($script);
34
35
    }
36
}