1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* TingleLibrary.php |
5
|
|
|
* |
6
|
|
|
* Adapter for the Tingle library. |
7
|
|
|
* |
8
|
|
|
* @package jaxon-dialogs |
9
|
|
|
* @author Thierry Feuzeu <[email protected]> |
10
|
|
|
* @copyright 2016 Thierry Feuzeu <[email protected]> |
11
|
|
|
* @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License |
12
|
|
|
* @link https://github.com/jaxon-php/jaxon-dialogs |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace Jaxon\Dialogs\Tingle; |
16
|
|
|
|
17
|
|
|
use Jaxon\App\Dialog\Library\DialogLibraryTrait; |
18
|
|
|
use Jaxon\App\Dialog\ModalInterface; |
19
|
|
|
|
20
|
|
|
class TingleLibrary implements ModalInterface |
21
|
|
|
{ |
22
|
|
|
use DialogLibraryTrait; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* @const The library name |
26
|
|
|
*/ |
27
|
|
|
const NAME = 'tingle'; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @inheritDoc |
31
|
|
|
*/ |
32
|
|
|
public function getName(): string |
33
|
|
|
{ |
34
|
|
|
return self::NAME; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @inheritDoc |
39
|
|
|
*/ |
40
|
|
|
public function getSubdir(): string |
41
|
|
|
{ |
42
|
|
|
return 'tingle'; |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
/** |
46
|
|
|
* @inheritDoc |
47
|
|
|
*/ |
48
|
|
|
public function getVersion(): string |
49
|
|
|
{ |
50
|
|
|
return '0.8.4'; |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* @inheritDoc |
55
|
|
|
*/ |
56
|
|
|
public function getJs(): string |
57
|
|
|
{ |
58
|
|
|
return $this->helper()->getJsCode('tingle.min.js'); |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
/** |
62
|
|
|
* @inheritDoc |
63
|
|
|
*/ |
64
|
|
|
public function getCss(): string |
65
|
|
|
{ |
66
|
|
|
return $this->helper()->getCssCode('tingle.min.css'); |
67
|
|
|
} |
68
|
|
|
|
69
|
|
|
/** |
70
|
|
|
* @inheritDoc |
71
|
|
|
*/ |
72
|
|
|
public function getScript(): string |
73
|
|
|
{ |
74
|
|
|
return $this->helper()->render('tingle/alert.js'); |
75
|
|
|
} |
76
|
|
|
|
77
|
|
|
/** |
78
|
|
|
* @inheritDoc |
79
|
|
|
*/ |
80
|
|
|
public function getReadyScript(): string |
81
|
|
|
{ |
82
|
|
|
return $this->helper()->render('tingle/ready.js'); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* @inheritDoc |
87
|
|
|
*/ |
88
|
|
|
public function show(string $sTitle, string $sContent, array $aButtons, array $aOptions = []) |
89
|
|
|
{ |
90
|
|
|
// Show the footer only if there is a button to display. |
91
|
|
|
$aOptions['footer'] = (count($aButtons) > 0); |
92
|
|
|
// Show the modal dialog |
93
|
|
|
$this->addCommand(['cmd' => 'tingle.show'], |
94
|
|
|
['content' => '<h2>' . $sTitle . '</h2>' . $sContent, 'buttons' => $aButtons, 'options' => $aOptions]); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
/** |
98
|
|
|
* @inheritDoc |
99
|
|
|
*/ |
100
|
|
|
public function hide() |
101
|
|
|
{ |
102
|
|
|
// Hide the modal dialog |
103
|
|
|
$this->addCommand(['cmd' => 'tingle.hide'], []); |
104
|
|
|
} |
105
|
|
|
} |
106
|
|
|
|