|
1
|
|
|
<?php |
|
2
|
|
|
namespace Ajax\ui\properties; |
|
3
|
|
|
|
|
4
|
|
|
use Ajax\common\components\BaseComponent; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Composant JQuery UI Position property |
|
8
|
|
|
* |
|
9
|
|
|
* @author jc |
|
10
|
|
|
* @version 1.001 |
|
11
|
|
|
*/ |
|
12
|
|
|
class Position extends BaseComponent { |
|
13
|
|
|
|
|
14
|
|
|
public function __construct($my = "left top", $at = "left bottom", $collision = "none", $within = "window") { |
|
15
|
|
|
$this->setParam("my", $my); |
|
16
|
|
|
$this->setParam("at", $at); |
|
17
|
|
|
$this->setParam("collision", $collision); |
|
18
|
|
|
$this->setParam("within", $within); |
|
19
|
|
|
} |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* Defines which position on the element being positioned to align with |
|
23
|
|
|
* the target element: "horizontal vertical" alignment. |
|
24
|
|
|
* A single value such as "right" will be normalized to "right center", |
|
25
|
|
|
* "top" will be normalized to "center top" (following CSS convention). |
|
26
|
|
|
* Acceptable horizontal values: "left", "center", "right". |
|
27
|
|
|
* Acceptable vertical values: "top", "center", "bottom". |
|
28
|
|
|
* Example: "left top" or "center center". Each dimension can also contain offsets, |
|
29
|
|
|
* in pixels or percent, e.g., "right+10 top-25%". Percentage offsets are relative to the element being positioned. |
|
30
|
|
|
* |
|
31
|
|
|
* @param string $value |
|
32
|
|
|
* default : left top |
|
33
|
|
|
*/ |
|
34
|
|
|
public function setMy($value) { |
|
35
|
|
|
$this->setParamCtrl("my", $value, "is_string"); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* Defines which position on the target element to align the positioned element against: "horizontal vertical" alignment. |
|
40
|
|
|
* See the my option for full details on possible values. |
|
41
|
|
|
* Percentage offsets are relative to the target element |
|
42
|
|
|
* |
|
43
|
|
|
* @param string $value |
|
44
|
|
|
* default : left bottom |
|
45
|
|
|
*/ |
|
46
|
|
|
public function setAt($value) { |
|
47
|
|
|
$this->setParamCtrl("at", $value, "is_string"); |
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
/** |
|
51
|
|
|
* Which element to position against. |
|
52
|
|
|
* If you provide a selector or jQuery object, the first matching element will be used. |
|
53
|
|
|
* If you provide an event object, the pageX and pageY properties will be used. Example: "#top-menu" |
|
54
|
|
|
* |
|
55
|
|
|
* @param string $value |
|
56
|
|
|
* default : null |
|
57
|
|
|
*/ |
|
58
|
|
|
public function setOf($value) { |
|
59
|
|
|
$this->setParamCtrl("of", $value, "is_string"); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* When the positioned element overflows the window in some direction, move it to an alternative position. |
|
64
|
|
|
* Similar to my and at, this accepts a single value or a pair for horizontal/vertical, e.g., "flip", "fit", "fit flip", "fit none" |
|
65
|
|
|
* |
|
66
|
|
|
* @param string $value |
|
67
|
|
|
* default : none |
|
68
|
|
|
*/ |
|
69
|
|
|
public function setCollision($value) { |
|
70
|
|
|
$this->setParamCtrl("collision", $value, "is_string"); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* Element to position within, affecting collision detection. |
|
75
|
|
|
* If you provide a selector or jQuery object, the first matching element will be used. |
|
76
|
|
|
* |
|
77
|
|
|
* @param string $value |
|
78
|
|
|
* default : window |
|
79
|
|
|
*/ |
|
80
|
|
|
public function setWithin($value) { |
|
81
|
|
|
$this->setParamCtrl("within", $value, "is_string"); |
|
82
|
|
|
} |
|
83
|
|
|
|
|
84
|
|
|
protected function setParamCtrl($key, $value, $typeCtrl) { |
|
85
|
|
|
if (! $typeCtrl($value)) { |
|
86
|
|
|
throw new \Exception("La fonction " . $typeCtrl . " a retourné faux pour l'affectation de la propriété " . $key . " à la position"); |
|
87
|
|
|
} else |
|
88
|
|
|
$this->setParam($key, $value); |
|
89
|
|
|
} |
|
90
|
|
|
|
|
91
|
|
|
/* |
|
92
|
|
|
* (non-PHPdoc) |
|
93
|
|
|
* @see \Ajax\common\BaseComponent::getScript() |
|
94
|
|
|
*/ |
|
95
|
|
|
public function getScript() {} |
|
96
|
|
|
} |
|
97
|
|
|
|