Repository navigation
Expand file tree
/
Copy pathJsModal.php
More file actions
78 lines (69 loc) · 2.18 KB
/
Copy pathJsModal.php
File metadata and controls
78 lines (69 loc) · 2.18 KB
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
<?php
declare(strict_types=1);
namespace Atk4\Ui;
/**
* This class generates action, that will be able to loop-back to the callback method.
*/
class JsModal extends JsExpression
{
/**
* @param string $title when empty, header will be remove in modal
*/
public function __construct($title, $url, array $args = [], string $dataType = 'json')
{
if ($url instanceof VirtualPage) {
$url = $url->getJsUrl('cut');
}
parent::__construct('$(this).atkCreateModal([arg])', ['arg' => ['uri' => $url, 'title' => $title, 'data_type' => $dataType, 'uri_options' => $args]]);
if (empty($title)) {
$this->removeHeader();
}
}
/**
* Set additionnal option for this JsModal.
*
* Valuable option are headerCss and label:
* 'headerCss' -> customize css class name for the header.
* ex: changing color text for header
* $jsModal->setOption('headerCss', 'ui blue header');
*
* 'label' -> set the text loader value.
* ex: changing default 'Loading...' for no text
* $jsModal->setOption('label', '');
*
* 'modalCss' -> customize css class name for the entire modal.
* ex: making modal fullscreen
* $jsModal->setOption('modalCss', 'fullscreen');
*
* 'contentCss' -> customize css class name for Modal content.
* ex: making content scrollable
* $jsModal->setOption('contentCss', 'scrolling');
* Note: Default to 'image' for backward compatibility.
*
* You can set option individually or supply an array.
*
* @return $this
*/
public function setOption($options, $value = null)
{
if (is_array($options)) {
foreach ($options as $key => $value) {
$this->args['arg'][$key] = $value;
}
} else {
$this->args['arg'][$options] = $value;
}
return $this;
}
/**
* Clear header class and title.
*
* @return $this
*/
public function removeHeader()
{
$this->args['arg']['headerCss'] = '';
$this->args['arg']['title'] = '';
return $this;
}
}