-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBootstrapModal.class.php
executable file
·90 lines (74 loc) · 1.99 KB
/
BootstrapModal.class.php
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
79
80
81
82
83
84
85
86
87
88
89
90
<?php
namespace fwk\ui;
class BootstrapModal{
const SIZE_SMALL = 'modal-sm';
const SIZE_NORMAL = null;
const SIZE_LARGE = 'modal-lg';
protected static $validSize = array(self::SIZE_SMALL, self::SIZE_NORMAL, self::SIZE_LARGE);
public $id;
public $title;
public $body;
public $footerButtons = array();
public $isAnimationOn = true;
protected $size;
public function __construct($newId = null, $newTitle = null, $newBody = null){
$this->id = $newId;
$this->title = $newTitle;
$this->body = $newBody;
}
public function animationOff(){
$this->isAnimationOn = false;
}
public function animationOn(){
$this->isAnimationOn = true;
}
public function sizeGet(){
return $this->size;
}
public function sizeReset(){
$this->size = self::SIZE_NORMAL;
}
public function sizeSet($newSize = self::SIZE_NORMAL){
if( !in_array($newSize, self::$validSize) ){
$newSize = self::SIZE_NORMAL;
}
$this->size = $newSize;
}
public function view(){
$str = "";
$str .= "<div class='modal ";
// Animation
if( $this->isAnimationOn ){
$str .= "fade";
}
$str .= "' ";
// Modal ID
if( !is_null($this->id) ){
$str .= "id='" . $this->id . "' ";
}
$str .= "tabindex='-1' role='dialog' ";
if( !is_null($this->id) ){
$str .= "aria-labelledby='" . $this->id . "Label' ";
}
$str .= ">\n";
$str .= "<div class='modal-dialog " . $this->size . "' role='document'>
<div class='modal-content'>
<div class='modal-header'>
<button type='button' class='close' data-dismiss='modal' aria-label='Close'><span aria-hidden='true'>×<span></button>";
$str .= "<h4 class='modal-title' ";
if( !is_null($this->id) ){
$str .= "id='" . $this->id . "Label' ";
}
$str .= ">" . $this->title . "</h4>\n";
$str .= "</div>
<div class='modal-body'>
" . $this->body . "
</div>
<div class='modal-footer'>
<button type='button' class='btn btn-default' data-dismiss='modal'>Close</button>
</div>
</div>
</div>";
return $str;
}
}