Skip to content

Commit acbd35d

Browse files
committed
Semantic Sticky !!!!
1 parent 3ad5ef1 commit acbd35d

File tree

11 files changed

+148
-21
lines changed

11 files changed

+148
-21
lines changed

Ajax/common/components/BaseComponent.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,12 @@ public function addParams($params){
8989
}
9090

9191
abstract public function getScript();
92+
93+
public function setDebug($value){
94+
return $this->setParam("debug", $value);
95+
}
96+
97+
public function setVerbose($value){
98+
return $this->setParam("verbose", $value);
99+
}
92100
}

Ajax/common/components/SimpleExtComponent.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,5 @@ public function getScript() {
2626
public function addCode($jsCode) {
2727
$this->jsCodes []=new JsCode($jsCode);
2828
}
29+
2930
}

Ajax/semantic/components/Sticky.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,10 @@ public function __construct(JsUtils $js) {
2020
public function setContext($value="") {
2121
return $this->setParam("context", $value);
2222
}
23+
24+
public function setOffset($offset=0){
25+
return $this->setParam("offset", $offset);
26+
}
27+
2328
//TODO other events implementation
2429
}

Ajax/semantic/html/collections/form/HtmlForm.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
use Ajax\JsUtils;
1212
use Ajax\semantic\html\collections\form\traits\FormTrait;
1313
use Ajax\semantic\components\Form;
14-
use Ajax\service\JString;
1514

1615
/**
1716
* Semantic Form component
@@ -59,13 +58,20 @@ public function addHeader($title, $niveau=1, $dividing=true) {
5958
}
6059

6160
/**
61+
* Adds a divider
6262
* @param string $caption
63-
* @return \Ajax\semantic\html\collections\form\HtmlForm
63+
* @return HtmlForm
6464
*/
6565
public function addDivider($caption=NULL){
6666
return $this->addContent(new HtmlDivider("",$caption));
6767
}
6868

69+
/**
70+
* Adds a group of fields
71+
* @param array $fields
72+
* @param string $label
73+
* @return string|\Ajax\semantic\html\collections\form\HtmlFormFields
74+
*/
6975
public function addFields($fields=NULL, $label=NULL) {
7076
if (isset($fields)) {
7177
if (!$fields instanceof HtmlFormFields) {
@@ -98,6 +104,10 @@ public function addItem($item) {
98104
return $item;
99105
}
100106

107+
/**
108+
* @param int $index
109+
* @return mixed|NULL|BaseHtml
110+
*/
101111
public function getField($index) {
102112
if (\is_string($index)) {
103113
$field=$this->getElementById($index, $this->_fields);
@@ -109,7 +119,7 @@ public function getField($index) {
109119

110120
/**
111121
* automatically divide fields to be equal width
112-
* @return \Ajax\semantic\html\collections\form\HtmlForm
122+
* @return HtmlForm
113123
*/
114124
public function setEqualWidth() {
115125
return $this->addToProperty("class", "equal width");
@@ -118,7 +128,7 @@ public function setEqualWidth() {
118128
/**
119129
* Adds a field (alias for addItem)
120130
* @param HtmlFormField $field
121-
* @return \Ajax\common\html\HtmlDoubleElement
131+
* @return HtmlDoubleElement
122132
*/
123133
public function addField($field) {
124134
return $this->addItem($field);
@@ -131,7 +141,7 @@ public function addField($field) {
131141
* @param string $header
132142
* @param string $icon
133143
* @param string $type
134-
* @return \Ajax\semantic\html\collections\HtmlMessage
144+
* @return HtmlMessage
135145
*/
136146
public function addMessage($identifier, $content, $header=NULL, $icon=NULL, $type=NULL) {
137147
$message=new HtmlMessage($identifier, $content);

Ajax/semantic/html/collections/form/traits/FormTrait.php

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Ajax\service\AjaxCall;
77
use Ajax\JsUtils;
88
use Ajax\semantic\html\elements\HtmlButton;
9+
use Ajax\common\html\BaseHtml;
910

1011
/**
1112
* trait used in Widget and HtmlForm
@@ -68,30 +69,34 @@ public function jsState($state) {
6869

6970
/**
7071
* @param string $event
71-
* @param string $identifier
72+
* @param string|BaseHtml $identifierOrElement
7273
* @param string $url
7374
* @param string $responseElement
74-
* @return \Ajax\semantic\html\collections\form\HtmlForm
75+
* @param array $parameters
76+
* @return HtmlForm
7577
*/
76-
public function submitOn($event,$identifier,$url,$responseElement){
78+
public function submitOn($event,$identifierOrElement,$url,$responseElement,$parameters=NULL){
7779
$form=$this->getForm();
78-
$elem=$form->getElementById($identifier, $form->getContent());
80+
if($identifierOrElement instanceof BaseHtml)
81+
$elem=$identifierOrElement;
82+
else
83+
$elem=$form->getElementById($identifierOrElement, $form->getContent());
7984
if(isset($elem)){
80-
$this->_buttonAsSubmit($elem, $event,$url,$responseElement);
85+
$this->_buttonAsSubmit($elem, $event,$url,$responseElement,$parameters);
8186
}
8287
return $form;
8388
}
8489

85-
public function submitOnClick($identifier,$url,$responseElement){
86-
return $this->submitOn("click", $identifier, $url, $responseElement);
90+
public function submitOnClick($identifier,$url,$responseElement,$parameters=NULL){
91+
return $this->submitOn("click", $identifier, $url, $responseElement,$parameters);
8792
}
8893

89-
public function addSubmit($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL){
94+
public function addSubmit($identifier,$value,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$parameters=NULL){
9095
$bt=$this->getForm()->addButton($identifier, $value,$cssStyle);
91-
return $this->_buttonAsSubmit($bt, "click",$url,$responseElement);
96+
return $this->_buttonAsSubmit($bt, "click",$url,$responseElement,$parameters);
9297
}
9398

94-
protected function _buttonAsSubmit(HtmlButton &$button,$event,$url,$responseElement=NULL,$parameters=NULL){
99+
protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElement=NULL,$parameters=NULL){
95100
$form=$this->getForm();
96101
if(isset($url) && isset($responseElement)){
97102
$button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');",true,true);

Ajax/semantic/html/collections/menus/HtmlMenu.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,10 @@ public function getItemHeader() {
235235
return $this->_itemHeader;
236236
}
237237

238+
public function setHasContainer(){
239+
return $this->wrapContent("<div class='ui container'>","</div>");
240+
}
241+
238242
public function run(JsUtils $js){
239243
$this->onClick('if(!$(this).hasClass("dropdown")&&!$(this).hasClass("no-active")){$(this).addClass("active").siblings().removeClass("active");}',false,false);
240244
$result= parent::run($js);

Ajax/semantic/html/collections/table/HtmlTable.php

Lines changed: 64 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct($identifier, $rowCount, $colCount) {
3636

3737
/**
3838
* {@inheritDoc}
39-
* @see \Ajax\semantic\html\collections\table\TableTrait::getTable()
39+
* @see TableTrait::getTable()
4040
*/
4141
protected function getTable() {
4242
return $this;
@@ -147,15 +147,30 @@ public function newRow() {
147147
return $this->getBody()->newRow($this->_colCount);
148148
}
149149

150+
/**
151+
* Sets the tbody values
152+
* @param array $values values in an array of array
153+
* @return HtmlTable
154+
*/
150155
public function setValues($values=array()) {
151156
$this->getBody()->setValues($values);
152157
return $this;
153158
}
154159

160+
/**
161+
* Sets the header values
162+
* @param array $values
163+
* @return HtmlTableContent
164+
*/
155165
public function setHeaderValues($values=array()) {
156166
return $this->getHeader()->setValues($values);
157167
}
158168

169+
/**
170+
* Sets the footer values
171+
* @param array $values
172+
* @return HtmlTableContent
173+
*/
159174
public function setFooterValues($values=array()) {
160175
return $this->getFooter()->setValues($values);
161176
}
@@ -186,14 +201,29 @@ public function addColVariations($colIndex, $variations=array()) {
186201
return $this->getBody()->addColVariations($colIndex, $variations);
187202
}
188203

204+
/**
205+
* Sets the col alignment to center
206+
* @param int $colIndex
207+
* @return HtmlTable
208+
*/
189209
public function colCenter($colIndex) {
190210
return $this->colAlign($colIndex, "colCenter");
191211
}
192212

213+
/**
214+
* Sets the col alignment to right
215+
* @param int $colIndex
216+
* @return HtmlTable
217+
*/
193218
public function colRight($colIndex) {
194219
return $this->colAlign($colIndex, "colRight");
195220
}
196221

222+
/**
223+
* Sets col alignment to left
224+
* @param int $colIndex
225+
* @return HtmlTable
226+
*/
197227
public function colLeft($colIndex) {
198228
return $this->colAlign($colIndex, "colLeft");
199229
}
@@ -212,21 +242,43 @@ private function colAlign($colIndex, $function) {
212242
return $this;
213243
}
214244

245+
/**
246+
* Applies a format on each cell when $callback returns true
247+
* @param callable $callback function with the cell as parameter, must return a boolean
248+
* @param string $format css class to apply
249+
* @return HtmlTable
250+
*/
215251
public function conditionalCellFormat($callback, $format) {
216252
$this->getBody()->conditionalCellFormat($callback, $format);
217253
return $this;
218254
}
219255

256+
/**
257+
* Applies a format on each row when $callback returns true
258+
* @param callable $callback function with the row as parameter, must return a boolean
259+
* @param string $format css class to apply
260+
* @return HtmlTable
261+
*/
220262
public function conditionalRowFormat($callback, $format) {
221263
$this->getBody()->conditionalRowFormat($callback, $format);
222264
return $this;
223265
}
224266

267+
/**
268+
* Applies a callback function on each cell
269+
* @param callable $callback
270+
* @return HtmlTable
271+
*/
225272
public function applyCells($callback) {
226273
$this->getBody()->applyCells($callback);
227274
return $this;
228275
}
229276

277+
/**
278+
* Applies a callback function on each row
279+
* @param callable $callback
280+
* @return HtmlTable
281+
*/
230282
public function applyRows($callback) {
231283
$this->getBody()->applyRows($callback);
232284
return $this;
@@ -236,7 +288,7 @@ public function applyRows($callback) {
236288
*
237289
* {@inheritDoc}
238290
*
239-
* @see \Ajax\semantic\html\base\HtmlSemDoubleElement::compile()
291+
* @see HtmlSemDoubleElement::compile()
240292
*/
241293
public function compile(JsUtils $js=NULL, &$view=NULL) {
242294
if(\sizeof($this->_compileParts)<3){
@@ -260,7 +312,7 @@ protected function compile_once(JsUtils $js=NULL, &$view=NULL) {
260312
*
261313
* {@inheritDoc}
262314
*
263-
* @see \Ajax\common\html\BaseHtml::fromDatabaseObject()
315+
* @see BaseHtml::fromDatabaseObject()
264316
*/
265317
public function fromDatabaseObject($object, $function) {
266318
$result=$function($object);
@@ -277,7 +329,8 @@ public function fromDatabaseObject($object, $function) {
277329
}
278330

279331
/**
280-
* @param array $parts
332+
* Sets the parts of the Table to compile
333+
* @param array $parts array of thead,tbody,tfoot
281334
* @return HtmlTable
282335
*/
283336
public function setCompileParts($parts=["tbody"]) {
@@ -308,6 +361,13 @@ public function onNewRow($callback) {
308361
return $this;
309362
}
310363

364+
/**
365+
* Defines how a row is selectable
366+
* @param string $class
367+
* @param string $event
368+
* @param boolean $multiple
369+
* @return HtmlTable
370+
*/
311371
public function setActiveRowSelector($class="active",$event="click",$multiple=false){
312372
$this->_activeRowSelector=new ActiveRow($this,$class,$event,$multiple);
313373
return $this;

Ajax/semantic/html/modules/HtmlSticky.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,20 @@ public function setContext($context){
1818
return $this;
1919
}
2020

21+
public function setFixed($value=NULL){
22+
$fixed="fixed";
23+
if(isset($value))
24+
$fixed.=" ".$value;
25+
return $this->addToProperty("class",$fixed);
26+
}
27+
28+
public function setBound($value=NULL){
29+
$bound="bound";
30+
if(isset($value))
31+
$bound.=" ".$value;
32+
return $this->addToProperty("class",$bound);
33+
}
34+
2135
/**
2236
* {@inheritDoc}
2337
* @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run()
@@ -26,4 +40,18 @@ public function run(JsUtils $js){
2640
parent::run($js);
2741
return $js->semantic()->sticky("#".$this->identifier,$this->_params);
2842
}
43+
44+
public function setOffset($offset=0){
45+
$this->_params["offset"]=$offset;
46+
return $this;
47+
}
48+
49+
50+
51+
public function setDebug($verbose=NULL){
52+
$this->_params["debug"]=true;
53+
if(isset($verbose))
54+
$this->_params["verbose"]=true;
55+
return $this;
56+
}
2957
}

Ajax/semantic/html/modules/checkbox/AbstractCheckbox.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ public function setOnChange($jsCode){
127127
}
128128

129129
public function run(JsUtils $js) {
130+
if(!isset($this->_bsComponent))
130131
$this->_bsComponent=$js->semantic()->checkbox("#" . $this->identifier, $this->_params);
131-
return parent::run($js);
132+
return parent::run($js);
132133
}
133134
}

Ajax/semantic/widgets/base/FieldAsTrait.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
use Ajax\service\JArray;
1919
use Ajax\semantic\html\elements\html5\HtmlLink;
2020
use Ajax\semantic\html\elements\HtmlFlag;
21+
use Ajax\common\html\BaseHtml;
2122

2223
/**
2324
* trait used in Widget
@@ -32,7 +33,7 @@ abstract protected function _getFieldIdentifier($prefix,$name="");
3233
abstract public function setValueFunction($index,$callback);
3334
abstract protected function _getFieldName($index);
3435
abstract protected function _getFieldCaption($index);
35-
abstract protected function _buttonAsSubmit(HtmlButton &$button,$event,$url,$responseElement=NULL,$parameters=NULL);
36+
abstract protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElement=NULL,$parameters=NULL);
3637

3738
/**
3839
* @param HtmlFormField $element

0 commit comments

Comments
 (0)