Completed
Push — master ( 6de3cf...c386e0 )
by Song
03:18
created

Fieldset   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 49
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A start() 0 22 1
A end() 0 4 1
A collapsed() 0 11 1
1
<?php
2
3
namespace Encore\Admin\Form\Field;
4
5
use Encore\Admin\Admin;
6
7
class Fieldset
8
{
9
    protected $name = '';
10
11
    public function __construct()
12
    {
13
        $this->name = uniqid('fieldset-');
14
    }
15
16
    public function start($title)
17
    {
18
        $script = <<<SCRIPT
19
$('.{$this->name}-title').click(function () {
20
    $("i", this).toggleClass("fa-angle-double-down fa-angle-double-up");
21
});
22
SCRIPT;
23
24
        Admin::script($script);
25
26
        return <<<HTML
27
<div>
28
    <div style="height: 20px; border-bottom: 1px solid #eee; text-align: center;margin-top: 20px;margin-bottom: 20px;">
29
      <span style="font-size: 16px; background-color: #ffffff; padding: 0 10px;">
30
        <a data-toggle="collapse" href="#{$this->name}" class="{$this->name}-title">
31
          <i class="fa fa-angle-double-up"></i>&nbsp;&nbsp;{$title}
32
        </a>
33
      </span>
34
    </div>
35
    <div class="collapse in" id="{$this->name}">
36
HTML;
37
    }
38
39
    public function end()
40
    {
41
        return '</div></div>';
42
    }
43
44
    public function collapsed()
45
    {
46
        $script = <<<SCRIPT
47
$("#{$this->name}").removeClass("in");
48
$(".{$this->name}-title i").toggleClass("fa-angle-double-down fa-angle-double-up");
49
SCRIPT;
50
51
        Admin::script($script);
52
53
        return $this;
54
    }
55
}