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