-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJQueryToolsOverlay.php
More file actions
62 lines (50 loc) · 1.86 KB
/
JQueryToolsOverlay.php
File metadata and controls
62 lines (50 loc) · 1.86 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
<?php
/**
* This file is part of the EcommitJavascriptBundle package.
*
* (c) E-commit <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Ecommit\JavascriptBundle\Overlay;
class JQueryToolsOverlay extends AbstractOverlay
{
/**
* @var bool
*/
protected $useBootstrap;
public function __construct($useBootstrap)
{
$this->useBootstrap = $useBootstrap;
}
public function declareJavascriptModal($modalId, $options = array())
{
$modalId = str_replace(' ', '', $modalId);
$apiVar = $this->getApiVariableName($modalId);
$options = $this->getDeclareJavascriptModalOptions($options);
$jsModal = \sprintf("var %s = $('#%s').overlay({oneInstance: false, api: true, fixed: false", $apiVar, $modalId);
$jsModal .= empty($options['js_on_open']) ? '' : sprintf(" ,onLoad: function() { %s }", $options['js_on_open']);
$jsModal .= empty($options['js_on_close']) ? '' : sprintf(" ,onClose: function() { %s }", $options['js_on_close']);
$jsModal .= empty($options['close_div_class']) ? '' : sprintf(" ,close: '.%s'", $options['close_div_class']);
$jsModal .= '}); ';
return $jsModal;
}
public function openModal($modalId)
{
$modalId = str_replace(' ', '', $modalId);
$apiVar = $this->getApiVariableName($modalId);
return \sprintf('%s.load();', $apiVar);
}
public function closeModal($modalId)
{
$modalId = str_replace(' ', '', $modalId);
$apiVar = $this->getApiVariableName($modalId);
return \sprintf('%s.close();', $apiVar);
}
protected function getApiVariableName($modalId)
{
$modalId = str_replace(' ', '', $modalId);
return \sprintf('api_crud_modal_%s', $modalId);
}
}