Skip to content

Commit 5a9be24

Browse files
committed
Add sidebar
+ visibleHover getter
1 parent a7d880c commit 5a9be24

File tree

3 files changed

+181
-42
lines changed

3 files changed

+181
-42
lines changed

Ajax/semantic/components/Sidebar.php

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
<?php
2+
namespace Ajax\semantic\components;
3+
4+
use Ajax\JsUtils;
5+
6+
/**
7+
* Ajax\semantic\components$Sidebar
8+
* This class is part of phpMv-ui
9+
*
10+
* @author jcheron <myaddressmail@gmail.com>
11+
* @version 1.0.0
12+
* @since 2.3.6
13+
* @see https://fomantic-ui.com/modules/sidebar.html
14+
*/
15+
class Sidebar extends SimpleSemExtComponent {
16+
17+
public function __construct(JsUtils $js = NULL) {
18+
parent::__construct($js);
19+
$this->uiName = 'sidebar';
20+
}
21+
22+
public function show() {
23+
return $this->addBehavior('show');
24+
}
25+
26+
public function hide() {
27+
return $this->addBehavior('hide');
28+
}
29+
30+
public function toogle() {
31+
return $this->addBehavior('toggle');
32+
}
33+
34+
/**
35+
* Pushes page content to be visible alongside sidebar.
36+
*/
37+
public function pushPage() {
38+
return $this->addBehavior('push page');
39+
}
40+
41+
/**
42+
* Returns page content to original position.
43+
*/
44+
public function pullPage() {
45+
return $this->addBehavior('pull page');
46+
}
47+
48+
public function setContext($value) {
49+
$this->params['context'] = $value;
50+
return $this;
51+
}
52+
53+
public function setExclusive($value = true) {
54+
$this->params['exclusive'] = true;
55+
return $this;
56+
}
57+
58+
public function setClosable($value = true) {
59+
$this->params['closable'] = $value;
60+
return $this;
61+
}
62+
63+
public function setDimPage($value = true) {
64+
$this->params['dimPage'] = $value;
65+
return $this;
66+
}
67+
68+
public function setScrollLock($value = false) {
69+
$this->params['scrollLock'] = $value;
70+
return $this;
71+
}
72+
73+
public function setReturnScroll($value = false) {
74+
$this->params['returnScroll'] = $value;
75+
return $this;
76+
}
77+
78+
public function setOnVisible($jsCode) {
79+
$this->addComponentEvent('onVisible', $jsCode);
80+
}
81+
82+
public function setOnShow($jsCode) {
83+
$this->addComponentEvent('onShow', $jsCode);
84+
return $this;
85+
}
86+
87+
public function setOnChange($jsCode) {
88+
$this->addComponentEvent('onChange', $jsCode);
89+
return $this;
90+
}
91+
92+
public function setOnHide($jsCode) {
93+
$this->addComponentEvent('onHide', $jsCode);
94+
return $this;
95+
}
96+
97+
public function setOnHidden($jsCode) {
98+
$this->addComponentEvent('onHidden', $jsCode);
99+
return $this;
100+
}
101+
}

Ajax/semantic/html/base/HtmlSemDoubleElement.php

Lines changed: 72 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
<?php
2-
32
namespace Ajax\semantic\html\base;
43

54
use Ajax\common\html\HtmlDoubleElement;
65
use Ajax\semantic\html\content\InternalPopup;
7-
86
use Ajax\semantic\html\base\traits\BaseTrait;
97
use Ajax\semantic\html\modules\HtmlDimmer;
108
use Ajax\semantic\html\elements\HtmlLabel;
@@ -14,74 +12,85 @@
1412
use Ajax\common\html\html5\HtmlList;
1513
use Ajax\common\html\BaseHtml;
1614
use Ajax\semantic\components\Toast;
15+
use Ajax\semantic\components\Sidebar;
1716

1817
/**
1918
* Base class for Semantic double elements
19+
*
2020
* @author jc
2121
* @version 1.0.2
2222
*/
2323
class HtmlSemDoubleElement extends HtmlDoubleElement {
2424
use BaseTrait;
25-
protected $_popup=NULL;
26-
protected $_dimmer=NULL;
27-
protected $_toast=NULL;
28-
protected $_params=array ();
2925

26+
protected $_popup = NULL;
27+
28+
protected $_dimmer = NULL;
29+
30+
protected $_toast = NULL;
31+
32+
protected $_sidebar = NULL;
33+
34+
protected $_params = array();
3035

31-
public function __construct($identifier, $tagName="p", $baseClass="ui", $content=NULL) {
36+
public function __construct($identifier, $tagName = "p", $baseClass = "ui", $content = NULL) {
3237
parent::__construct($identifier, $tagName);
33-
$this->_baseClass=$baseClass;
38+
$this->_baseClass = $baseClass;
3439
$this->setClass($baseClass);
3540
if (isset($content)) {
36-
$this->content=$content;
41+
$this->content = $content;
3742
}
3843
}
3944

4045
/**
4146
* Defines the popup attributes
47+
*
4248
* @param string $variation
4349
* @param string $popupEvent
4450
*/
45-
public function setPopupAttributes($variation=NULL, $popupEvent=NULL) {
51+
public function setPopupAttributes($variation = NULL, $popupEvent = NULL) {
4652
if (isset($this->_popup))
4753
$this->_popup->setAttributes($variation, $popupEvent);
4854
}
4955

5056
/**
5157
* Adds a popup to the element
58+
*
5259
* @param string $title
5360
* @param string $content
5461
* @param string $variation
5562
* @param array $params
5663
* @return HtmlSemDoubleElement
5764
*/
58-
public function addPopup($title="", $content="", $variation=NULL, $params=array()) {
59-
$this->_popup=new InternalPopup($this, $title, $content, $variation, $params);
65+
public function addPopup($title = "", $content = "", $variation = NULL, $params = array()) {
66+
$this->_popup = new InternalPopup($this, $title, $content, $variation, $params);
6067
return $this;
6168
}
6269

6370
/**
6471
* Adds an html popup to the element
72+
*
6573
* @param string $html
6674
* @param string $variation
6775
* @param array $params
6876
* @return HtmlSemDoubleElement
6977
*/
70-
public function addPopupHtml($html="", $variation=NULL, $params=array()) {
71-
$this->_popup=new InternalPopup($this);
78+
public function addPopupHtml($html = "", $variation = NULL, $params = array()) {
79+
$this->_popup = new InternalPopup($this);
7280
$this->_popup->setHtml($html);
7381
$this->_popup->setAttributes($variation, $params);
7482
return $this;
7583
}
7684

7785
/**
7886
* Adds a Dimmer to the element
87+
*
7988
* @param array $params
8089
* @param mixed $content
8190
* @return HtmlDimmer
8291
*/
83-
public function addDimmer($params=array(), $content=NULL) {
84-
$dimmer=new HtmlDimmer("dimmer-" . $this->identifier, $content);
92+
public function addDimmer($params = array(), $content = NULL) {
93+
$dimmer = new HtmlDimmer("dimmer-" . $this->identifier, $content);
8594
$dimmer->setParams($params);
8695
$dimmer->setContainer($this);
8796
$this->addContent($dimmer);
@@ -90,79 +99,87 @@ public function addDimmer($params=array(), $content=NULL) {
9099

91100
/**
92101
* Adds a label to the element
102+
*
93103
* @param mixed $label
94104
* @param boolean $before
95105
* @param string $icon
96106
* @return mixed|HtmlLabel
97107
*/
98-
public function addLabel($label, $before=false, $icon=NULL) {
99-
$labelO=$label;
108+
public function addLabel($label, $before = false, $icon = NULL) {
109+
$labelO = $label;
100110
if (\is_object($label) === false) {
101-
$labelO=new HtmlLabel("label-" . $this->identifier, $label);
111+
$labelO = new HtmlLabel("label-" . $this->identifier, $label);
102112
if (isset($icon))
103113
$labelO->addIcon($icon);
104114
} else {
105-
$labelO->addToPropertyCtrl("class", "label", array ("label" ));
115+
$labelO->addToPropertyCtrl("class", "label", array(
116+
"label"
117+
));
106118
}
107119
$this->addContent($labelO, $before);
108120
return $labelO;
109121
}
110122

111123
/**
112124
* Adds an attached label to the element
125+
*
113126
* @param mixed $label
114127
* @param string $side
115128
* @param string $direction
116129
* @param string $icon
117130
* @return HtmlSemDoubleElement
118131
*/
119-
public function attachLabel($label,$side=Side::TOP,$direction=Direction::NONE,$icon=NULL){
120-
$label=$this->addLabel($label,true,$icon);
121-
$label->setAttached($side,$direction);
132+
public function attachLabel($label, $side = Side::TOP, $direction = Direction::NONE, $icon = NULL) {
133+
$label = $this->addLabel($label, true, $icon);
134+
$label->setAttached($side, $direction);
122135
return $this;
123136
}
124137

125138
/**
126139
* Transforms the element into a link
140+
*
127141
* @return HtmlSemDoubleElement
128142
*/
129-
public function asLink($href=NULL,$target=NULL) {
143+
public function asLink($href = NULL, $target = NULL) {
130144
if (isset($href))
131145
$this->setProperty("href", $href);
132-
if(isset($target))
146+
if (isset($target))
133147
$this->setProperty("target", $target);
134148
return $this->setTagName("a");
135149
}
136150

137151
/**
138152
* Returns the script displaying the dimmer
153+
*
139154
* @param boolean $show
140155
* @return string
141156
*/
142-
public function jsShowDimmer($show=true) {
143-
$status="hide";
157+
public function jsShowDimmer($show = true) {
158+
$status = "hide";
144159
if ($show === true)
145-
$status="show";
160+
$status = "show";
146161
return '$("#.' . $this->identifier . ').dimmer("' . $status . '");';
147162
}
148163

149164
/**
150-
* {@inheritDoc}
165+
*
166+
* {@inheritdoc}
151167
* @see BaseHtml::compile()
152168
*/
153-
public function compile(JsUtils $js=NULL, &$view=NULL) {
154-
if (isset($this->_popup)){
169+
public function compile(JsUtils $js = NULL, &$view = NULL) {
170+
if (isset($this->_popup)) {
155171
$this->_popup->compile($js);
156172
}
157173
return parent::compile($js, $view);
158174
}
159175

160176
/**
161-
* {@inheritDoc}
177+
*
178+
* {@inheritdoc}
162179
* @see HtmlDoubleElement::run()
163180
*/
164181
public function run(JsUtils $js) {
165-
$this->_bsComponent=$js->semantic()->generic("#" . $this->identifier);
182+
$this->_bsComponent = $js->semantic()->generic("#" . $this->identifier);
166183
parent::run($js);
167184
$this->addEventsOnRun($js);
168185
if (isset($this->_popup)) {
@@ -175,33 +192,46 @@ public function run(JsUtils $js) {
175192
}
176193

177194
/**
195+
*
178196
* @param array $items
179197
* @param boolean $ordered
180198
* @return \Ajax\common\html\html5\HtmlList
181199
*/
182-
public function addList($items,$ordered=false){
183-
$list=new HtmlList("list-".$this->identifier,$items);
200+
public function addList($items, $ordered = false) {
201+
$list = new HtmlList("list-" . $this->identifier, $items);
184202
$list->setOrdered($ordered);
185203
$list->setClass("ui list");
186204
$this->addContent($list);
187205
return $list;
188206
}
189-
207+
190208
/**
209+
*
191210
* @param ?array $params
192211
* @return \Ajax\semantic\components\Toast
193212
*/
194-
public function asToast($params=NULL){
195-
$this->_toast=new Toast();
196-
$this->_toast->attach('#'.$this->_identifier);
197-
$this->setProperty('style','display:none;');
198-
if(isset($params)){
213+
public function asToast($params = NULL) {
214+
$this->_toast = new Toast();
215+
$this->_toast->attach('#' . $this->_identifier);
216+
$this->setProperty('style', 'display:none;');
217+
if (isset($params)) {
199218
$this->_toast->setParams($params);
200219
}
201-
$this->_toast->setParam('onShow','$(".toast-box *").show();');
220+
$this->_toast->setParam('onShow', '$(".toast-box *").show();');
202221
return $this->_toast;
203222
}
204223

224+
/**
225+
*
226+
* @param string $classes
227+
* @return \Ajax\semantic\components\Sidebar
228+
*/
229+
public function asSideBar($classes = '') {
230+
$this->_sidebar = new Sidebar();
231+
$this->addToProperty('class', 'sidebar');
232+
return $this->_sidebar;
233+
}
234+
205235
/*
206236
* public function __call($name, $arguments){
207237
* $type=\substr($name, 0,3);

Ajax/semantic/widgets/datatable/DataTable.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,4 +690,12 @@ public function getGroupByFields() {
690690
public function setGroupByFields($_groupByFields) {
691691
$this->_instanceViewer->setGroupByFields($_groupByFields);
692692
}
693+
694+
/**
695+
*
696+
* @param boolean $_visibleHover
697+
*/
698+
public function setVisibleHover($_visibleHover) {
699+
$this->_visibleHover = $_visibleHover;
700+
}
693701
}

0 commit comments

Comments
 (0)