forked from php-flasher/flasher-toastr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ToastrBuilder.php
452 lines (382 loc) · 8.43 KB
/
ToastrBuilder.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
<?php
/*
* This file is part of the PHPFlasher package.
* (c) Younes KHOUBZA <younes.khoubza@gmail.com>
*/
namespace Flasher\Toastr\Prime;
use Flasher\Prime\Notification\NotificationBuilder;
/**
* @SuppressWarnings(PHPMD.TooManyMethods)
* @SuppressWarnings(PHPMD.TooManyPublicMethods)
*/
final class ToastrBuilder extends NotificationBuilder
{
/**
* Enable a close button.
*
* @param bool $closeButton
*
* @return static
*/
public function closeButton($closeButton = true)
{
$this->option('closeButton', $closeButton);
return $this;
}
/**
* @param string $closeClass
*
* @return static
*/
public function closeClass($closeClass)
{
$this->option('closeClass', $closeClass);
return $this;
}
/**
* @param int $closeDuration
*
* @return static
*/
public function closeDuration($closeDuration)
{
$this->option('closeDuration', $closeDuration);
return $this;
}
/**
* @param string $closeEasing
*
* @return static
*/
public function closeEasing($closeEasing)
{
$this->option('closeEasing', $closeEasing);
return $this;
}
/**
* Override the close button's HTML.
*
* @param string $closeHtml
*
* @return static
*/
public function closeHtml($closeHtml)
{
$this->option('closeHtml', $closeHtml);
return $this;
}
/**
* @param string $closeMethod
*
* @return static
*/
public function closeMethod($closeMethod)
{
$this->option('closeMethod', $closeMethod);
return $this;
}
/**
* @param bool $closeOnHover
*
* @return static
*/
public function closeOnHover($closeOnHover = true)
{
$this->option('closeOnHover', $closeOnHover);
return $this;
}
/**
* @param string $containerId
*
* @return static
*/
public function containerId($containerId)
{
$this->option('containerId', $containerId);
return $this;
}
/**
* @param bool $debug
*
* @return static
*/
public function debug($debug = true)
{
$this->option('debug', $debug);
return $this;
}
/**
* In case you want to escape HTML characters in title and message.
*
* @param bool $escapeHtml
*
* @return static
*/
public function escapeHtml($escapeHtml = true)
{
$this->option('escapeHtml', $escapeHtml);
return $this;
}
/**
* How long the toast will display after a user hovers over it.
*
* @param int $extendedTimeOut
*
* @return static
*/
public function extendedTimeOut($extendedTimeOut)
{
$this->option('extendedTimeOut', $extendedTimeOut);
return $this;
}
/**
* Specifies the time during which the pop-up closes in ms.
*
* @param int $hideDuration
*
* @return static
*/
public function hideDuration($hideDuration)
{
$this->option('hideDuration', $hideDuration);
return $this;
}
/**
* Indicates the entry transition of the pop-up.
*
* @param string $hideEasing
*
* @return static
*/
public function hideEasing($hideEasing)
{
$this->option('hideEasing', $hideEasing);
return $this;
}
/**
* Indicates the opening animation of the pop-up.
*
* @param string $hideMethod
*
* @return static
*/
public function hideMethod($hideMethod)
{
$this->option('hideMethod', $hideMethod);
return $this;
}
/**
* @param string $iconClass
*
* @return static
*/
public function iconClass($iconClass)
{
$this->option('iconClass', $iconClass);
return $this;
}
/**
* @param string $messageClass
*
* @return static
*/
public function messageClass($messageClass)
{
$this->option('messageClass', $messageClass);
return $this;
}
/**
* Show newest toast at bottom (top is default).
*
* @param bool $newestOnTop
*
* @return static
*/
public function newestOnTop($newestOnTop = true)
{
$this->option('newestOnTop', $newestOnTop);
return $this;
}
/**
* @param string $onHidden
*
* @return static
*/
public function onHidden($onHidden)
{
$this->option('onHidden', $onHidden);
return $this;
}
/**
* @param string $onShown
*
* @return static
*/
public function onShown($onShown)
{
$this->option('onShown', $onShown);
return $this;
}
/**
* @param string $positionClass
*
* @return static
*/
public function positionClass($positionClass)
{
$this->option('positionClass', $positionClass);
return $this;
}
/**
* Rather than having identical toasts stack, set the preventDuplicates property to true. Duplicates are matched to
* the previous toast based on their message content.
*
* @param bool $preventDuplicates
*
* @return static
*/
public function preventDuplicates($preventDuplicates = true)
{
$this->option('preventDuplicates', $preventDuplicates);
return $this;
}
/**
* Visually indicate how long before a toast expires.
*
* @param bool $progressBar
*
* @return static
*/
public function progressBar($progressBar = true)
{
$this->option('progressBar', $progressBar);
return $this;
}
/**
* @param string $progressClass
*
* @return static
*/
public function progressClass($progressClass)
{
$this->option('progressClass', $progressClass);
return $this;
}
/**
* Flip the toastr to be displayed properly for right-to-left languages.
*
* @param bool $rtl
*
* @return static
*/
public function rtl($rtl = true)
{
$this->option('rtl', $rtl);
return $this;
}
/**
* Specifies the time during which the pop-up opens in ms.
*
* @param int $showDuration
*
* @return static
*/
public function showDuration($showDuration)
{
$this->option('showDuration', $showDuration);
return $this;
}
/**
* Indicates the entry transition of the pop-up.
*
* @param string $showEasing
*
* @return static
*/
public function showEasing($showEasing)
{
$this->option('showEasing', $showEasing);
return $this;
}
/**
* Indicates the opening animation of the pop-up.
*
* @param string $showMethod
*
* @return static
*/
public function showMethod($showMethod)
{
$this->option('showMethod', $showMethod);
return $this;
}
/**
* Forces the user to validate the pop-up before closing.
*
* @param bool $tapToDismiss
*
* @return static
*/
public function tapToDismiss($tapToDismiss = true)
{
$this->option('tapToDismiss', $tapToDismiss);
return $this;
}
/**
* @param string $target
*
* @return static
*/
public function target($target)
{
$this->option('target', $target);
return $this;
}
/**
* How long the toast will display without user interaction.
*
* @param int $timeOut
* @param int $extendedTimeOut
*
* @return static
*/
public function timeOut($timeOut, $extendedTimeOut = null)
{
$this->option('timeOut', $timeOut);
if (null !== $extendedTimeOut) {
$this->extendedTimeOut($extendedTimeOut);
}
return $this;
}
/**
* @param string $titleClass
*
* @return static
*/
public function titleClass($titleClass)
{
$this->option('titleClass', $titleClass);
return $this;
}
/**
* @param string $toastClass
*
* @return static
*/
public function toastClass($toastClass)
{
$this->option('toastClass', $toastClass);
return $this;
}
/**
* Prevent from Auto Hiding.
*
* @return static
*/
public function persistent()
{
$this->timeOut(0);
$this->extendedTimeOut(0);
return $this;
}
}