1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* DialogLibraryInterface.php - Adapter for the PgwJs ModalInterface 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\PgwJs; |
14
|
|
|
|
15
|
|
|
use Jaxon\App\Dialog\Library\DialogLibraryTrait; |
16
|
|
|
use Jaxon\App\Dialog\LibraryInterface; |
17
|
|
|
use Jaxon\App\Dialog\ModalInterface; |
18
|
|
|
|
19
|
|
|
class PgwJsLibrary implements LibraryInterface, ModalInterface |
20
|
|
|
{ |
21
|
|
|
use DialogLibraryTrait; |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* @const The library name |
25
|
|
|
*/ |
26
|
|
|
const NAME = 'pgwjs'; |
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 'pgwjs/modal'; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* @inheritDoc |
46
|
|
|
*/ |
47
|
|
|
public function getVersion(): string |
48
|
|
|
{ |
49
|
|
|
return '2.0.0'; |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* @inheritDoc |
54
|
|
|
*/ |
55
|
|
|
public function getJs(): string |
56
|
|
|
{ |
57
|
|
|
return $this->helper()->getJsCode('pgwmodal.min.js'); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** |
61
|
|
|
* @inheritDoc |
62
|
|
|
*/ |
63
|
|
|
public function getCss(): string |
64
|
|
|
{ |
65
|
|
|
return $this->helper()->getCssCode('pgwmodal.min.css'); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* @inheritDoc |
70
|
|
|
*/ |
71
|
|
|
public function getScript(): string |
72
|
|
|
{ |
73
|
|
|
return $this->helper()->render('pgwjs/alert.js'); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* @inheritDoc |
78
|
|
|
*/ |
79
|
|
|
public function getReadyScript(): string |
80
|
|
|
{ |
81
|
|
|
$sVarPrefix = 'jaxon.dialogs.pgwjs.options.'; |
82
|
|
|
return $this->helper()->render('pgwjs/ready.js.php', [ |
83
|
|
|
'options' => $this->helper()->getOptionScript($sVarPrefix, 'options.modal.'), |
84
|
|
|
]); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
/** |
88
|
|
|
* @inheritDoc |
89
|
|
|
*/ |
90
|
|
|
public function show(string $sTitle, string $sContent, array $aButtons, array $aOptions = []) |
91
|
|
|
{ |
92
|
|
|
// Set the value of the max width, if there is no value defined |
93
|
|
|
$aOptions['title'] = $sTitle; |
94
|
|
|
$aOptions['content'] = $this->helper()->render('pgwjs/dialog.html', |
95
|
|
|
['content' => $sContent, 'buttons' => $aButtons]); |
96
|
|
|
// Affectations du contenu de la fenêtre |
97
|
|
|
$this->addCommand(array('cmd'=>'pgw.modal'), $aOptions); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @inheritDoc |
102
|
|
|
*/ |
103
|
|
|
public function hide() |
104
|
|
|
{ |
105
|
|
|
$this->response()->script('$.pgwModal("close")'); |
106
|
|
|
} |
107
|
|
|
} |
108
|
|
|
|