Skip to content

Commit 55f351d

Browse files
committed
ajaxEffect option
1 parent 9fed17e commit 55f351d

File tree

13 files changed

+63
-32
lines changed

13 files changed

+63
-32
lines changed

Ajax/Jquery.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public function __construct($params,$jsUtils) {
5454
$this->params[$key]=$params[$key];
5555
}
5656
$this->jsUtils=$jsUtils;
57+
$this->setAjaxDataCall();
5758
}
5859

5960
/**

Ajax/JsUtils.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ public function __construct($params=array(),$injected=NULL) {
167167
$defaults=array (
168168
'driver' => 'Jquery',
169169
'debug' => true,
170-
'defer' => false
170+
'defer' => false,
171+
'ajaxEffect'=>'fade'
171172
);
172173
foreach ( $defaults as $key => $val ) {
173174
if (isset($params[$key])===false || $params[$key]==="") {

Ajax/bootstrap/html/HtmlButtongroups.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public function addElement($element) {
8181
return $result;
8282
}
8383

84-
private function _addArrayElement(array $element,int $iid){
84+
private function _addArrayElement(array $element,$iid){
8585
if (array_key_exists("glyph", $element))
8686
$bt=new HtmlGlyphButton($this->identifier."-button-".$iid);
8787
elseif (array_key_exists("btnCaption", $element)) {
@@ -91,9 +91,10 @@ private function _addArrayElement(array $element,int $iid){
9191
$bt=new HtmlDropdown($this->identifier."-dropdown-".$iid);
9292
$this->dropdownAsButton($bt);
9393
}
94-
} else
94+
} else{
9595
$bt=new HtmlButton($this->identifier."-button-".$iid);
96-
$bt->fromArray($element);
96+
$bt->fromArray($element);
97+
}
9798
return $bt;
9899
}
99100

Ajax/common/html/BaseHtml.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ abstract class BaseHtml extends BaseWidget {
2222
protected $_wrapAfter=array ();
2323
protected $_bsComponent;
2424

25+
/**
26+
*
27+
* @param JsUtils $js
28+
* @return SimpleExtComponent
29+
*/
30+
abstract public function run(JsUtils $js);
31+
2532
private function _callSetter($setter,$key,$value,&$array){
2633
$result=false;
2734
if (method_exists($this, $setter) && !JString::startswith($key, "_")) {
@@ -122,13 +129,6 @@ protected function setWrapAfter($wrapAfter) {
122129
return $this;
123130
}
124131

125-
/**
126-
*
127-
* @param JsUtils $js
128-
* @return SimpleExtComponent
129-
*/
130-
abstract public function run(JsUtils $js);
131-
132132
public function getTagName() {
133133
return $this->tagName;
134134
}

Ajax/common/traits/JqueryAjaxTrait.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,17 @@
44

55
use Ajax\service\JString;
66
use Ajax\service\Javascript;
7+
use Ajax\service\JQueryAjaxEffect;
78

89

910
/**
1011
* @author jc
1112
* @property array $jquery_code_for_compile
1213
* @property Ajax\JsUtils $jsUtils
14+
* @property array $params
1315
*/
1416
trait JqueryAjaxTrait {
15-
17+
protected $ajaxDataCall;
1618
protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>';
1719

1820
abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true);
@@ -51,9 +53,15 @@ protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCal
5153
return $retour;
5254
}
5355

56+
protected function setAjaxDataCall(){
57+
$this->ajaxDataCall=function ($responseElement,$jqueryDone="html"){
58+
return JQueryAjaxEffect::{$this->params["ajaxEffect"]}($responseElement,$jqueryDone);
59+
};
60+
}
61+
5462
protected function _getAjaxUrl($url,$attr){
5563
$url=$this->_correctAjaxUrl($url);
56-
$retour="url='".$url."';\n";
64+
$retour="url='".$url."';";
5765
$slash="/";
5866
if(JString::endswith($url, "/")===true)
5967
$slash="";
@@ -69,9 +77,9 @@ protected function _getAjaxUrl($url,$attr){
6977
}
7078

7179
protected function _getOnAjaxDone($responseElement,$jqueryDone,$jsCallback){
72-
$retour="";
80+
$retour="";$call=$this->ajaxDataCall;
7381
if ($responseElement!=="") {
74-
$retour="\t$({$responseElement}).{$jqueryDone}( data );\n";
82+
$retour=$call($responseElement,$jqueryDone);
7583
}
7684
$retour.="\t".$jsCallback."\n";
7785
return $retour;

Ajax/semantic/html/collections/HtmlMessage.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
use Ajax\JsUtils;
99
use Ajax\semantic\html\base\constants\Style;
1010
use Ajax\semantic\html\base\traits\AttachedTrait;
11-
use Ajax\common\html\HtmlDoubleElement;
1211
/**
1312
* Semantic Message component
1413
* @see http://semantic-ui.com/collections/message.html

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ protected function _buttonAsSubmit(&$button,$event,$url,$responseElement=NULL,$p
8484
$form=$this->getForm();
8585
if(isset($url) && isset($responseElement)){
8686
$button->addEvent($event, "$('#".$form->getIdentifier()."').form('validate form');");
87-
$params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url];
87+
$params=["form"=>$form->getIdentifier(),"responseElement"=>$responseElement,"url"=>$url,"stopPropagation"=>true];
8888
if(\is_array($parameters))
8989
$params=\array_merge($params,$parameters);
9090
$form->addValidationParam("_ajaxSubmit", new AjaxCall("postForm", $params));

Ajax/semantic/widgets/base/FieldAsTrait.php

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,8 @@ public function fieldAsInput($index,$attributes=NULL){
164164
}
165165

166166
public function fieldAsTextarea($index,$attributes=NULL){
167-
return $this->_fieldAs(function($id,$name,$value){
168-
$textarea=new HtmlFormTextarea($id,null,$value);
167+
return $this->_fieldAs(function($id,$name,$value,$caption){
168+
$textarea=new HtmlFormTextarea($id,$caption,$value);
169169
$textarea->setName($name);
170170
return $textarea;
171171
}, $index,$attributes,"textarea");
@@ -180,17 +180,17 @@ public function fieldAsHidden($index,$attributes=NULL){
180180
}
181181

182182
public function fieldAsCheckbox($index,$attributes=NULL){
183-
return $this->_fieldAs(function($id,$name,$value){
184-
$input=new HtmlFormCheckbox($id,NULL,$this->_instanceViewer->getIdentifier());
183+
return $this->_fieldAs(function($id,$name,$value,$caption){
184+
$input=new HtmlFormCheckbox($id,$caption,$this->_instanceViewer->getIdentifier());
185185
$input->setChecked(JString::isBooleanTrue($value));
186186
$input->setName($name);
187187
return $input;
188188
}, $index,$attributes,"ck");
189189
}
190190

191191
public function fieldAsDropDown($index,$elements=[],$multiple=false,$attributes=NULL){
192-
return $this->_fieldAs(function($id,$name,$value) use($elements,$multiple){
193-
$dd=new HtmlFormDropdown($id,$elements,NULL,$value);
192+
return $this->_fieldAs(function($id,$name,$value,$caption) use($elements,$multiple){
193+
$dd=new HtmlFormDropdown($id,$elements,$caption,$value);
194194
$dd->asSelect($name,$multiple);
195195
return $dd;
196196
}, $index,$attributes,"dd");
@@ -238,8 +238,15 @@ public function fieldAs($index,$type,$attributes=NULL){
238238
public function fieldAsSubmit($index,$cssStyle=NULL,$url=NULL,$responseElement=NULL,$attributes=NULL){
239239
return $this->_fieldAs(function($id,$name,$value,$caption) use ($url,$responseElement,$cssStyle,$attributes){
240240
$button=new HtmlButton($id,$value,$cssStyle);
241-
$this->_buttonAsSubmit($button,"click",$url,$responseElement,$attributes["ajax"]);
241+
$this->_buttonAsSubmit($button,"click",$url,$responseElement,@$attributes["ajax"]);
242242
return $button;
243243
}, $index,$attributes,"submit");
244244
}
245+
246+
public function fieldAsButton($index,$cssStyle=NULL,$attributes=NULL){
247+
return $this->_fieldAs(function($id,$name,$value,$caption) use ($cssStyle){
248+
$button=new HtmlButton($id,$value,$cssStyle);
249+
return $button;
250+
}, $index,$attributes,"button");
251+
}
245252
}

Ajax/semantic/widgets/dataform/DataForm.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ protected function _generateContent($form){
6363
$form->addField($fields[0]);
6464
}elseif(\sizeof($fields)>1){
6565
$form->addFields($fields);
66-
$i+=\sizeof($fields)-1;
6766
}
6867
}
6968
}

Ajax/semantic/widgets/dataform/FormInstanceViewer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected function _beforeAddProperty($index,&$field){
3535
public function addSeparatorAfter($fieldNum){
3636
if(\array_search($fieldNum, $this->separators)===false)
3737
$this->separators[]=$fieldNum;
38-
return $this;
38+
return $this;
3939
}
4040

4141
public function getSeparators() {

0 commit comments

Comments
 (0)