|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace JeroenNoten\LaravelAdminLte\Components; |
|
4
|
|
|
|
|
5
|
|
|
use Illuminate\View\Component; |
|
6
|
|
|
|
|
7
|
|
|
class Modal extends Component |
|
8
|
|
|
{ |
|
9
|
|
|
/** |
|
10
|
|
|
* The available modal sizes. |
|
11
|
|
|
* |
|
12
|
|
|
* @var array |
|
13
|
|
|
*/ |
|
14
|
|
|
protected $mSizes = ['sm', 'lg', 'xl']; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* The modal ID attribute, used to target the modal and show it. |
|
18
|
|
|
* |
|
19
|
|
|
* @var string |
|
20
|
|
|
*/ |
|
21
|
|
|
public $id; |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* The title for the modal header. |
|
25
|
|
|
* |
|
26
|
|
|
* @var string |
|
27
|
|
|
*/ |
|
28
|
|
|
public $title; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* A Font Awesome icon for the modal header. |
|
32
|
|
|
* |
|
33
|
|
|
* @var string |
|
34
|
|
|
*/ |
|
35
|
|
|
public $icon; |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* The modal size (sm, lg or xl). |
|
39
|
|
|
* |
|
40
|
|
|
* @var string |
|
41
|
|
|
*/ |
|
42
|
|
|
public $size; |
|
43
|
|
|
|
|
44
|
|
|
/** |
|
45
|
|
|
* The modal theme (light, dark, primary, secondary, info, success, |
|
46
|
|
|
* warning, danger or any other AdminLTE color like lighblue or teal). |
|
47
|
|
|
* |
|
48
|
|
|
* @var string |
|
49
|
|
|
*/ |
|
50
|
|
|
public $theme; |
|
51
|
|
|
|
|
52
|
|
|
/** |
|
53
|
|
|
* Indicates if the modal is vertically centered. |
|
54
|
|
|
* |
|
55
|
|
|
* @var bool|mixed |
|
56
|
|
|
*/ |
|
57
|
|
|
public $vCentered; |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Indicates if the modal is scrollable. Enable this if the modal content |
|
61
|
|
|
* is large. |
|
62
|
|
|
* |
|
63
|
|
|
* @var bool|mixed |
|
64
|
|
|
*/ |
|
65
|
|
|
public $scrollable; |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Indicates if the backdrop is static. When enabled, the modal will not |
|
69
|
|
|
* close when clicking outside it. |
|
70
|
|
|
* |
|
71
|
|
|
* @var bool|mixed |
|
72
|
|
|
*/ |
|
73
|
|
|
public $staticBackdrop; |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* Indicates if the show/hide fade animations are disabled. |
|
77
|
|
|
* |
|
78
|
|
|
* @var bool|mixed |
|
79
|
|
|
*/ |
|
80
|
|
|
public $disableAnimations; |
|
81
|
|
|
|
|
82
|
|
|
/** |
|
83
|
|
|
* Create a new component instance. |
|
84
|
|
|
* |
|
85
|
|
|
* @return void |
|
86
|
|
|
*/ |
|
87
|
2 |
|
public function __construct( |
|
88
|
|
|
$id, $title = null, $icon = null, $size = null, $theme = null, |
|
89
|
|
|
$vCentered = null, $scrollable = null, $staticBackdrop = null, |
|
90
|
|
|
$disableAnimations = null |
|
91
|
|
|
) { |
|
92
|
2 |
|
$this->id = $id; |
|
93
|
2 |
|
$this->title = $title; |
|
94
|
2 |
|
$this->icon = $icon; |
|
95
|
2 |
|
$this->size = $size; |
|
96
|
2 |
|
$this->theme = $theme; |
|
97
|
2 |
|
$this->vCentered = $vCentered; |
|
98
|
2 |
|
$this->scrollable = $scrollable; |
|
99
|
2 |
|
$this->staticBackdrop = $staticBackdrop; |
|
100
|
2 |
|
$this->disableAnimations = $disableAnimations; |
|
101
|
2 |
|
} |
|
102
|
|
|
|
|
103
|
|
|
/** |
|
104
|
|
|
* Make the class attribute for the modal. |
|
105
|
|
|
* |
|
106
|
|
|
* @return string |
|
107
|
|
|
*/ |
|
108
|
1 |
|
public function makeModalClass() |
|
109
|
|
|
{ |
|
110
|
1 |
|
$classes = ['modal']; |
|
111
|
|
|
|
|
112
|
1 |
|
if (! isset($this->disableAnimations)) { |
|
113
|
1 |
|
$classes[] = 'fade'; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
1 |
|
return implode(' ', $classes); |
|
117
|
|
|
} |
|
118
|
|
|
|
|
119
|
|
|
/** |
|
120
|
|
|
* Make the class attribute for the modal dialog. |
|
121
|
|
|
* |
|
122
|
|
|
* @return string |
|
123
|
|
|
*/ |
|
124
|
1 |
|
public function makeModalDialogClass() |
|
125
|
|
|
{ |
|
126
|
1 |
|
$classes = ['modal-dialog']; |
|
127
|
|
|
|
|
128
|
1 |
|
if (isset($this->vCentered)) { |
|
129
|
1 |
|
$classes[] = 'modal-dialog-centered'; |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
1 |
|
if (isset($this->scrollable)) { |
|
133
|
1 |
|
$classes[] = 'modal-dialog-scrollable'; |
|
134
|
|
|
} |
|
135
|
|
|
|
|
136
|
1 |
|
if (isset($this->size) && in_array($this->size, $this->mSizes)) { |
|
137
|
1 |
|
$classes[] = "modal-{$this->size}"; |
|
138
|
|
|
} |
|
139
|
|
|
|
|
140
|
1 |
|
return implode(' ', $classes); |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
/** |
|
144
|
|
|
* Make the class attribute for the modal header. |
|
145
|
|
|
* |
|
146
|
|
|
* @return string |
|
147
|
|
|
*/ |
|
148
|
1 |
|
public function makeModalHeaderClass() |
|
149
|
|
|
{ |
|
150
|
1 |
|
$classes = ['modal-header']; |
|
151
|
|
|
|
|
152
|
1 |
|
if (isset($this->theme)) { |
|
153
|
1 |
|
$classes[] = "bg-{$this->theme}"; |
|
154
|
|
|
} |
|
155
|
|
|
|
|
156
|
1 |
|
return implode(' ', $classes); |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
/** |
|
160
|
|
|
* Make the class attribute for the close button. |
|
161
|
|
|
* |
|
162
|
|
|
* @return string |
|
163
|
|
|
*/ |
|
164
|
1 |
|
public function makeCloseButtonClass() |
|
165
|
|
|
{ |
|
166
|
1 |
|
$classes = ['bg-secondary']; |
|
167
|
|
|
|
|
168
|
1 |
|
if (isset($this->theme)) { |
|
169
|
1 |
|
$classes = ["bg-{$this->theme}"]; |
|
170
|
|
|
} |
|
171
|
|
|
|
|
172
|
1 |
|
return implode(' ', $classes); |
|
173
|
|
|
} |
|
174
|
|
|
|
|
175
|
|
|
/** |
|
176
|
|
|
* Get the view / contents that represent the component. |
|
177
|
|
|
* |
|
178
|
|
|
* @return \Illuminate\View\View|string |
|
179
|
|
|
*/ |
|
180
|
1 |
|
public function render() |
|
181
|
|
|
{ |
|
182
|
1 |
|
return view('adminlte::components.modal'); |
|
183
|
|
|
} |
|
184
|
|
|
} |
|
185
|
|
|
|