1 | <?php |
||
17 | class Alert extends Widget |
||
18 | { |
||
19 | // Modal Type |
||
20 | const TYPE_INFO = 'info'; |
||
21 | const TYPE_ERROR = 'error'; |
||
22 | const TYPE_SUCCESS = 'success'; |
||
23 | const TYPE_WARNING = 'warning'; |
||
24 | const TYPE_QUESTION = 'question'; |
||
25 | |||
26 | // Input Type |
||
27 | const INPUT_TYPE_TEXT = 'text'; |
||
28 | const INPUT_TYPE_EMAIL = 'email'; |
||
29 | const INPUT_TYPE_PASSWORD = 'password'; |
||
30 | const INPUT_TYPE_NUMBER = 'number'; |
||
31 | const INPUT_TYPE_RANGE = 'range'; |
||
32 | const INPUT_TYPE_TEXTAREA = 'textarea'; |
||
33 | const INPUT_TYPE_SELECT = 'select'; |
||
34 | const INPUT_TYPE_RADIO = 'radio'; |
||
35 | const INPUT_TYPE_CHECKBOX = 'checkbox'; |
||
36 | const INPUT_TYPE_FILE = 'file'; |
||
37 | |||
38 | /** |
||
39 | * All the flash messages stored for the session are displayed and removed from the session |
||
40 | * Defaults to false. |
||
41 | * @var bool |
||
42 | */ |
||
43 | public $useSessionFlash = false; |
||
44 | |||
45 | /** |
||
46 | * @var string alert callback |
||
47 | */ |
||
48 | public $callback = 'function() {}'; |
||
49 | |||
50 | /** |
||
51 | 4 | * @inheritdoc |
|
52 | */ |
||
53 | 4 | public function init() |
|
54 | 4 | { |
|
55 | 4 | parent::init(); |
|
56 | SweetAlert2Asset::register($this->view); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | 3 | * @param array $steps |
|
61 | */ |
||
62 | 3 | public function initFlashWidget($steps = []) |
|
63 | 2 | { |
|
64 | 2 | if (!empty($steps)) { |
|
65 | 2 | if (isset($steps[0]['text']) && !is_array($steps[0]['text'])) { |
|
66 | 2 | $this->initSwalQueue($steps); |
|
67 | 2 | } else { |
|
68 | 2 | $this->processFlashWidget($steps); |
|
69 | } |
||
70 | 2 | } |
|
71 | } |
||
72 | 2 | ||
73 | 2 | /** |
|
74 | 1 | * @param array $steps |
|
75 | */ |
||
76 | 1 | public function initSwalQueue($steps = []) |
|
82 | 1 | ||
83 | 1 | /** |
|
84 | 2 | * @param string $options |
|
85 | * @param string $callback |
||
86 | */ |
||
87 | public function initSwal($options = '', $callback = '') |
||
93 | |||
94 | /** |
||
95 | * @inheritdoc |
||
96 | */ |
||
97 | 3 | public function run() |
|
105 | 1 | ||
106 | /** |
||
107 | 1 | * @param $session bool|mixed|\yii\web\Session |
|
108 | * @return array |
||
109 | 2 | */ |
|
110 | public function processFlashSession($session) |
||
123 | |||
124 | /** |
||
125 | * @param array $steps |
||
126 | 2 | */ |
|
127 | public function processFlashWidget($steps = []) |
||
138 | 2 | ||
139 | 2 | /** |
|
140 | * Get widget options |
||
141 | * |
||
142 | * @return string |
||
143 | */ |
||
144 | 4 | public function getOptions() |
|
160 | |||
161 | /** |
||
162 | * Add support Animate.css |
||
163 | * @see https://daneden.github.io/animate.css/ |
||
164 | */ |
||
165 | public function registerAnimateCss() |
||
173 | |||
174 | /** |
||
175 | * @return bool|mixed|\yii\web\Session |
||
176 | */ |
||
177 | private function getSession() |
||
181 | } |
||
182 |