Skip to content

Commit 8a6a85b

Browse files
committed
_json add + timeout trait
1 parent 4bf1722 commit 8a6a85b

File tree

14 files changed

+160
-48
lines changed

14 files changed

+160
-48
lines changed

.codedocs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Doxyfile 1.8.12
1+
# Doxyfile 1.8.13
22

33
# This file describes the settings to be used by the documentation system
44
# doxygen (www.doxygen.org) for a project.
@@ -32,13 +32,13 @@ DOXYFILE_ENCODING = UTF-8
3232
# title of most generated pages and in a few other places.
3333
# The default value is: My Project.
3434

35-
PROJECT_NAME = "phpMv"
35+
PROJECT_NAME = phpMv
3636

3737
# The PROJECT_NUMBER tag can be used to enter a project or revision number. This
3838
# could be handy for archiving the generated documentation or if some version
3939
# control system is used.
4040

41-
PROJECT_NUMBER = "-UI toolkit 2.2"
41+
PROJECT_NUMBER = "-UI toolkit 2.2.2"
4242

4343
# Using the PROJECT_BRIEF tag one can provide an optional one line description
4444
# for a project that appears at the top of each page and should give viewer a
@@ -58,7 +58,7 @@ PROJECT_LOGO =
5858
# entered, it will be relative to the location where doxygen was started. If
5959
# left blank the current directory will be used.
6060

61-
#OUTPUT_DIRECTORY = doc
61+
OUTPUT_DIRECTORY = doc
6262

6363
# If the CREATE_SUBDIRS tag is set to YES then doxygen will create 4096 sub-
6464
# directories (in 2 levels) under the output directory of each output format and
@@ -945,7 +945,7 @@ IMAGE_PATH =
945945
# need to set EXTENSION_MAPPING for the extension otherwise the files are not
946946
# properly processed by doxygen.
947947

948-
INPUT_FILTER = php documentation/filters/traits.php
948+
INPUT_FILTER = "php documentation/filters/traits.php"
949949

950950
# The FILTER_PATTERNS tag can be used to specify filters on a per file pattern
951951
# basis. Doxygen will compare the file name with each pattern and apply the
@@ -2419,6 +2419,11 @@ DIAFILE_DIRS =
24192419

24202420
PLANTUML_JAR_PATH =
24212421

2422+
# When using plantuml, the PLANTUML_CFG_FILE tag can be used to specify a
2423+
# configuration file for plantuml.
2424+
2425+
PLANTUML_CFG_FILE =
2426+
24222427
# When using plantuml, the specified paths are searched for files specified by
24232428
# the !include statement in a plantuml block.
24242429

Ajax/common/Widget.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ public function removeField($index){
432432
return $this;
433433
}
434434

435-
public function asModal($header){
435+
public function asModal($header=null){
436436
$modal=new HtmlModal("modal-".$this->identifier,$header);
437437
$modal->setContent($this);
438438
if(isset($this->_form)){

Ajax/common/components/SimpleComponent.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
use Ajax\JsUtils;
77
use Ajax\service\JString;
8-
use Ajax\bootstrap\components\Splitbutton;
98
/**
109
* Base component for JQuery UI visuals components
1110
* @author jc

Ajax/common/html/HtmlCollection.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,4 +183,8 @@ public function compile(JsUtils $js=NULL, &$view=NULL) {
183183
}
184184
return parent::compile($js,$view);
185185
}
186+
187+
public function getItemById($identifier){
188+
return $this->getElementById($identifier, $this->content);
189+
}
186190
}

Ajax/common/traits/JsUtilsAjaxTrait.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,10 @@ public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL
6969
* @param string $params The JSON parameters
7070
* @param string $method Method used
7171
* @param string $jsCallback javascript code to execute after the request
72+
* @param string $rowClass the css class for the new element
7273
*/
73-
public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL) {
74-
return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback,"id", NULL,true);
74+
public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json") {
75+
return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback,"id", NULL,$rowClass,true);
7576
}
7677

7778
/**
@@ -81,17 +82,18 @@ public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsC
8182
* @param string $params JSON parameters
8283
* @param string $method Method used
8384
* @param string $jsCallback javascript code to execute after the request
85+
* @param string $rowClass the css class for the new element
8486
*/
85-
public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL) {
86-
return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback,"id", NULL, false);
87+
public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json") {
88+
return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback,"id", NULL, $rowClass,false);
8789
}
8890

8991
/**
9092
* Performs an ajax request and receives the JSON array data types by assigning DOM elements with the same name when $event fired on $element
9193
* @param string $element
9294
* @param string $event
9395
* @param string $url the request url
94-
* @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true)
96+
* @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true)
9597
*/
9698
public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) {
9799
return $this->js->_jsonArrayOn($event,$element,$maskSelector, $url, $parameters);

Ajax/semantic/html/base/traits/BaseTrait.php

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,31 @@ protected function addBehavior(&$array,$key,$value,$before="",$after=""){
193193
$array[$key]=$before.$p.$value.$after;
194194
}else
195195
$array[$key]=$before.$value.$after;
196-
}else
196+
}else{
197197
$array[$key]=$value;
198+
}
198199
return $this;
199200
}
201+
/*
202+
protected function addBehavior(&$array,$key,$value,$before="",$after=""){
203+
echo $key.":".$this->identifier."<br>";
204+
205+
if(\is_string($value)){
206+
if(isset($array[$key])){
207+
$p=JString::replaceAtFirstAndLast($array[$key], $before, "", $after, "");
208+
$array[$key]=$before.$p.$value.$after;
209+
}else
210+
$array[$key]=$before.$value.$after;
211+
}else{
212+
if(isset($array[$key])){
213+
if(!\is_array($array[$key])){
214+
$array[$key]=[$array[$key]];
215+
}
216+
$array[$key][]=$value;
217+
}else{
218+
$array[$key]=$value;
219+
}
220+
}
221+
return $this;
222+
}*/
200223
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
3+
namespace Ajax\semantic\html\base\traits;
4+
5+
use Ajax\JsUtils;
6+
7+
/**
8+
* @author jc
9+
* @property string $identifier
10+
* @property BaseComponent $_bsComponent
11+
*/
12+
trait HasTimeoutTrait {
13+
protected $_timeout;
14+
protected $_closeTransition="{animation : 'scale',duration : '2s'}";
15+
16+
/**
17+
* {@inheritDoc}
18+
* @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run()
19+
*/
20+
public function run(JsUtils $js){
21+
if(!isset($this->_bsComponent)){
22+
if(isset($this->_timeout)){
23+
$js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}); }, {$this->_timeout});",true);
24+
}
25+
}
26+
return parent::run($js);
27+
}
28+
29+
public function setTimeout($_timeout) {
30+
$this->_timeout=$_timeout;
31+
return $this;
32+
}
33+
34+
public function setCloseTransition($_closeTransition) {
35+
$this->_closeTransition=$_closeTransition;
36+
return $this;
37+
}
38+
}

Ajax/semantic/html/collections/HtmlMessage.php

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,18 @@
88
use Ajax\JsUtils;
99
use Ajax\semantic\html\base\constants\Style;
1010
use Ajax\semantic\html\base\traits\AttachedTrait;
11+
use Ajax\semantic\html\base\traits\HasTimeoutTrait;
1112
/**
1213
* Semantic Message component
1314
* @see http://semantic-ui.com/collections/message.html
1415
* @author jc
1516
* @version 1.001
1617
*/
1718
class HtmlMessage extends HtmlSemDoubleElement {
18-
use AttachedTrait;
19+
use AttachedTrait,HasTimeoutTrait;
1920
protected $icon;
2021
protected $close;
21-
protected $_timeout;
22-
protected $_closeTransition="{animation : 'scale',duration : '2s'}";
22+
2323

2424
public function __construct($identifier, $content="") {
2525
parent::__construct($identifier, "div");
@@ -80,13 +80,15 @@ public function setDismissable($dismiss=true){
8080
* @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run()
8181
*/
8282
public function run(JsUtils $js){
83-
parent::run($js);
84-
if(isset($this->close)){
85-
$js->execOn("click", "#".$this->identifier." .close", "$(this).closest('.message').transition({$this->_closeTransition})");
86-
}
87-
if(isset($this->_timeout)){
88-
$js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}); }, {$this->_timeout});",true);
83+
if(!isset($this->_bsComponent)){
84+
if(isset($this->close)){
85+
$js->execOn("click", "#".$this->identifier." .close", "$(this).closest('.message').transition({$this->_closeTransition})");
86+
}
87+
if(isset($this->_timeout)){
88+
$js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}); }, {$this->_timeout});",true);
89+
}
8990
}
91+
return parent::run($js);
9092
}
9193

9294
public function setState($visible=true){
@@ -117,14 +119,4 @@ public function setMessage($message){
117119
$this->setContent($message);
118120
}
119121

120-
public function setTimeout($_timeout) {
121-
$this->_timeout=$_timeout;
122-
return $this;
123-
}
124-
125-
public function setCloseTransition($_closeTransition) {
126-
$this->_closeTransition=$_closeTransition;
127-
return $this;
128-
}
129-
130122
}

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

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,8 @@ protected function addCompoValidation($compo,$field){
3232
protected function _runValidationParams(&$compo,JsUtils $js=NULL){
3333
$form=$this->getForm();
3434
$params=$form->getValidationParams();
35-
if(isset($params["_ajaxSubmit"]) && $params["_ajaxSubmit"] instanceof AjaxCall){
36-
$compilation=$params["_ajaxSubmit"]->compile($js);
37-
$compilation=str_ireplace("\"","%quote%", $compilation);
35+
if(isset($params["_ajaxSubmit"])){
36+
$compilation=$this->_compileAjaxSubmit($params["_ajaxSubmit"],$js);
3837
$this->onSuccess($compilation);
3938
$form->removeValidationParam("_ajaxSubmit");
4039
}
@@ -43,6 +42,19 @@ protected function _runValidationParams(&$compo,JsUtils $js=NULL){
4342
$form->addEventsOnRun($js);
4443
}
4544

45+
protected function _compileAjaxSubmit($ajaxSubmit,JsUtils $js=null){
46+
$compilation="";
47+
if(\is_array($ajaxSubmit)){
48+
foreach ($ajaxSubmit as $ajaxSubmitItem){
49+
$compilation.=$ajaxSubmitItem->compile($js);
50+
}
51+
}elseif($ajaxSubmit instanceof AjaxCall){
52+
$compilation=$ajaxSubmit->compile($js);
53+
}
54+
$compilation=str_ireplace("\"","%quote%", $compilation);
55+
return $compilation;
56+
}
57+
4658
public function setLoading() {
4759
return $this->getForm()->addToProperty("class", "loading");
4860
}
@@ -100,14 +112,20 @@ protected function _buttonAsSubmit(BaseHtml &$button,$event,$url,$responseElemen
100112
$form=$this->getForm();
101113
if(isset($url) && isset($responseElement)){
102114
$button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');",true,true);
103-
$params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true];
104-
if(\is_array($parameters))
105-
$params=\array_merge($params,$parameters);
106-
$form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params));
115+
$this->setSubmitParams($url,$responseElement,$parameters);
107116
}
108117
return $button;
109118
}
110119

120+
public function setSubmitParams($url,$responseElement=NULL,$parameters=NULL){
121+
$form=$this->getForm();
122+
$params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true];
123+
if(\is_array($parameters))
124+
$params=\array_merge($params,$parameters);
125+
$form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params));
126+
return $this;
127+
}
128+
111129
public function addReset($identifier,$value,$cssStyle=NULL){
112130
$bt=$this->getForm()->addButton($identifier, $value,$cssStyle);
113131
$bt->setProperty("type", "reset");

Ajax/semantic/html/elements/HtmlButtonGroups.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @version 1.001
1515
*/
1616
class HtmlButtonGroups extends HtmlSemCollection {
17-
17+
protected $_dropdown;
1818
public function __construct($identifier, $elements=array(), $asIcons=false) {
1919
parent::__construct($identifier, "div", "ui buttons");
2020
if ($asIcons === true)
@@ -32,6 +32,7 @@ public function addDropdown($items,$asCombo=false){
3232
$dd->setAction("combo");
3333
$dd->addToProperty("class", "combo");
3434
}
35+
$this->_dropdown=$dd;
3536
return $this->addElement($dd);
3637
}
3738

@@ -133,4 +134,9 @@ public function run(JsUtils $js){
133134
$result= parent::run($js);
134135
return $result->setItemSelector(".ui.button");
135136
}
137+
138+
public function getDropdown() {
139+
return $this->_dropdown;
140+
}
141+
136142
}

0 commit comments

Comments
 (0)