Completed
Push — master ( ef9455...966ba4 )
by Jean-Christophe
02:39
created
Ajax/semantic/html/modules/HtmlPopup.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 
12 12
 class HtmlPopup extends HtmlSemDoubleElement {
13 13
 	private $_container;
14
-	public function __construct(BaseHtml $container,$identifier, $content="") {
14
+	public function __construct(BaseHtml $container, $identifier, $content="") {
15 15
 		parent::__construct($identifier, "div");
16 16
 		$this->_container=$container;
17 17
 		$this->setClass("ui popup");
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
 	 * {@inheritDoc}
24 24
 	 * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::addList()
25 25
 	 */
26
-	public function addList($items=array(),$header=NULL){
27
-		if(!$this->content instanceof HtmlGrid){
28
-			$this->content=new HtmlGrid("Grid-".$this->identifier,0);
26
+	public function addList($items=array(), $header=NULL) {
27
+		if (!$this->content instanceof HtmlGrid) {
28
+			$this->content=new HtmlGrid("Grid-".$this->identifier, 0);
29 29
 		}
30 30
 		$grid=$this->content;
31 31
 
@@ -33,12 +33,12 @@  discard block
 block discarded – undo
33 33
 		$colCount++;
34 34
 		$grid->setColsCount($colCount);
35 35
 
36
-		$list=new HtmlList("",$items);
36
+		$list=new HtmlList("", $items);
37 37
 		$list->asLink();
38
-		if(isset($header)){
39
-			$list->addHeader(4,$header);
38
+		if (isset($header)) {
39
+			$list->addHeader(4, $header);
40 40
 		}
41
-		$grid->getCell(0,$colCount-1)->setContent($list);
41
+		$grid->getCell(0, $colCount-1)->setContent($list);
42 42
 		$grid->setDivided()->setRelaxed(true);
43 43
 		return $list;
44 44
 	}
@@ -46,14 +46,14 @@  discard block
 block discarded – undo
46 46
 	/**
47 47
 	 * A popup can have no maximum width and continue to flow to fit its content
48 48
 	 */
49
-	public function setFlowing(){
49
+	public function setFlowing() {
50 50
 		return $this->addToProperty("class", "flowing");
51 51
 	}
52 52
 
53 53
 	/**
54 54
 	 * A popup can provide more basic formatting
55 55
 	 */
56
-	public function setBasic(){
56
+	public function setBasic() {
57 57
 		return $this->addToProperty("class", "basic");
58 58
 	}
59 59
 
@@ -61,23 +61,23 @@  discard block
 block discarded – undo
61 61
 	 * {@inheritDoc}
62 62
 	 * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run()
63 63
 	 */
64
-	public function run(JsUtils $js){
64
+	public function run(JsUtils $js) {
65 65
 		parent::run($js);
66 66
 		$this->_params["popup"]="#".$this->identifier;
67
-		$js->semantic()->popup("#".$this->_container->getIdentifier(),$this->_params);
67
+		$js->semantic()->popup("#".$this->_container->getIdentifier(), $this->_params);
68 68
 	}
69 69
 
70
-	public function setOn($event="click"){
70
+	public function setOn($event="click") {
71 71
 		$this->_params["on"]=$event;
72 72
 		return $this;
73 73
 	}
74 74
 
75
-	public function setInline($value=true){
75
+	public function setInline($value=true) {
76 76
 		$this->_params["inline"]=$value;
77 77
 		return $this;
78 78
 	}
79 79
 
80
-	public function setPosition($position){
80
+	public function setPosition($position) {
81 81
 		$this->_params["position"]=$position;
82 82
 		return $this;
83 83
 	}
Please login to merge, or discard this patch.
Ajax/service/AjaxCall.php 2 patches
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -25,27 +25,27 @@
 block discarded – undo
25 25
 		$this->parameters["immediatly"]=false;
26 26
 		extract($this->parameters);
27 27
 		$result=$this->_eventPreparing($preventDefault, $stopPropagation);
28
-		switch($this->method) {
28
+		switch ($this->method) {
29 29
 			case "get":
30 30
 				$result.=$js->getDeferred($url, $responseElement, $this->parameters);
31 31
 				break;
32 32
 			case "post":
33
-				$result.=$js->postDeferred($url, $params,$responseElement, $this->parameters);
33
+				$result.=$js->postDeferred($url, $params, $responseElement, $this->parameters);
34 34
 				break;
35 35
 			case "postForm":
36 36
 				$result.=$js->postFormDeferred($url, $form, $responseElement, $this->parameters);
37 37
 				break;
38 38
 			case "json":
39
-				$result.=$js->jsonDeferred($url,$method,$params,$jsCallback);
39
+				$result.=$js->jsonDeferred($url, $method, $params, $jsCallback);
40 40
 				break;
41 41
 			case "jsonArray":
42
-				$result.=$js->jsonArrayDeferred($modelSelector, $url,$method,$params,$jsCallback,$rowClass);
42
+				$result.=$js->jsonArrayDeferred($modelSelector, $url, $method, $params, $jsCallback, $rowClass);
43 43
 				break;
44 44
 		}
45 45
 		return $result;
46 46
 	}
47 47
 
48
-	protected function _eventPreparing($preventDefault,$stopPropagation){
48
+	protected function _eventPreparing($preventDefault, $stopPropagation) {
49 49
 		$result="";
50 50
 		if ($preventDefault===true) {
51 51
 			$result.=Javascript::$preventDefault;
Please login to merge, or discard this patch.
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -14,8 +14,9 @@
 block discarded – undo
14 14
 	}
15 15
 
16 16
 	public function compile(JsUtils $js=null) {
17
-		if ($js===null)
18
-			return;
17
+		if ($js===null) {
18
+					return;
19
+		}
19 20
 		$params="{}";
20 21
 		$jsCallback=NULL;
21 22
 		$stopPropagation=true;
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/form/HtmlFormDropdown.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -7,29 +7,29 @@  discard block
 block discarded – undo
7 7
 
8 8
 class HtmlFormDropdown extends HtmlFormField {
9 9
 
10
-	public function __construct($identifier,$items=array(), $label=NULL,$value="",$multiple=false,$associative=true) {
11
-		parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items,$associative))->asSelect($identifier,$multiple), $label);
10
+	public function __construct($identifier, $items=array(), $label=NULL, $value="", $multiple=false, $associative=true) {
11
+		parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items, $associative))->asSelect($identifier, $multiple), $label);
12 12
 		$this->_identifier=$identifier;
13 13
 	}
14 14
 
15
-	public function setItems($items){
15
+	public function setItems($items) {
16 16
 		return $this->getField()->setItems($items);
17 17
 	}
18
-	public function addItem($item,$value=NULL,$image=NULL){
19
-		return $this->getField()->addItem($item,$value,$image);
18
+	public function addItem($item, $value=NULL, $image=NULL) {
19
+		return $this->getField()->addItem($item, $value, $image);
20 20
 	}
21
-	public static function multipleDropdown($identifier,$items=array(), $label=NULL,$value="",$associative=true){
22
-		return new HtmlFormDropdown($identifier,$items,$label,$value,true,$associative);
21
+	public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value="", $associative=true) {
22
+		return new HtmlFormDropdown($identifier, $items, $label, $value, true, $associative);
23 23
 	}
24 24
 
25 25
 	/**
26 26
 	 * @return HtmlDropdown
27 27
 	 */
28
-	public function getDataField(){
28
+	public function getDataField() {
29 29
 		return $this->getField()->getInput();
30 30
 	}
31
-	public function asSelect($name=NULL,$multiple=false,$selection=true){
32
-		$this->getField()->asSelect($name,$multiple,$selection);
31
+	public function asSelect($name=NULL, $multiple=false, $selection=true) {
32
+		$this->getField()->asSelect($name, $multiple, $selection);
33 33
 		return $this;
34 34
 	}
35 35
 
@@ -37,7 +37,7 @@  discard block
 block discarded – undo
37 37
 	 * @param boolean $floating
38 38
 	 * @return HtmlDropdown
39 39
 	 */
40
-	public function asButton($floating=false){
40
+	public function asButton($floating=false) {
41 41
 		$field=$this->content["field"];
42 42
 		$label=$this->content["label"];
43 43
 		$field->addContent($label);
Please login to merge, or discard this patch.
Ajax/semantic/html/collections/HtmlMessage.php 2 patches
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
  * @version 1.001
16 16
  */
17 17
 class HtmlMessage extends HtmlSemDoubleElement {
18
-	use AttachedTrait,HasTimeoutTrait;
18
+	use AttachedTrait, HasTimeoutTrait;
19 19
 	protected $icon;
20 20
 	protected $close;
21 21
 
@@ -32,39 +32,39 @@  discard block
 block discarded – undo
32 32
 	 * @param string|HtmlSemDoubleElement $header
33 33
 	 * @return \Ajax\semantic\html\collections\HtmlMessage
34 34
 	 */
35
-	public function addHeader($header){
35
+	public function addHeader($header) {
36 36
 		$headerO=$header;
37
-		if(\is_string($header)){
38
-			$headerO=new HtmlSemDoubleElement("header-".$this->identifier,"div");
37
+		if (\is_string($header)) {
38
+			$headerO=new HtmlSemDoubleElement("header-".$this->identifier, "div");
39 39
 			$headerO->setClass("header");
40 40
 			$headerO->setContent($header);
41 41
 		}
42
-		return $this->addContent($headerO,true);
42
+		return $this->addContent($headerO, true);
43 43
 	}
44 44
 
45
-	public function setHeader($header){
45
+	public function setHeader($header) {
46 46
 		return $this->addHeader($header);
47 47
 	}
48 48
 
49
-	public function setIcon($icon){
49
+	public function setIcon($icon) {
50 50
 		$this->addToProperty("class", "icon");
51
-		$this->wrapContent("<div class='content'>","</div>");
52
-		if(\is_string($icon)){
51
+		$this->wrapContent("<div class='content'>", "</div>");
52
+		if (\is_string($icon)) {
53 53
 			$this->icon=new HtmlIcon("icon-".$this->identifier, $icon);
54
-		}else{
54
+		} else {
55 55
 			$this->icon=$icon;
56 56
 		}
57 57
 		return $this;
58 58
 	}
59 59
 
60
-	public function addLoader($loaderIcon="notched circle"){
60
+	public function addLoader($loaderIcon="notched circle") {
61 61
 		$this->setIcon($loaderIcon);
62 62
 		$this->icon->addToIcon("loading");
63 63
 		return $this;
64 64
 	}
65 65
 
66
-	public function setDismissable($dismiss=true){
67
-		if($dismiss===true)
66
+	public function setDismissable($dismiss=true) {
67
+		if ($dismiss===true)
68 68
 			$this->close=new HtmlIcon("close-".$this->identifier, "close");
69 69
 		else
70 70
 			$this->close=NULL;
@@ -75,43 +75,43 @@  discard block
 block discarded – undo
75 75
 	 * {@inheritDoc}
76 76
 	 * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run()
77 77
 	 */
78
-	public function run(JsUtils $js){
79
-		if(!isset($this->_bsComponent)){
80
-			if(isset($this->close)){
78
+	public function run(JsUtils $js) {
79
+		if (!isset($this->_bsComponent)) {
80
+			if (isset($this->close)) {
81 81
 				$js->execOn("click", "#".$this->identifier." .close", "$(this).closest('.message').transition({$this->_closeTransition})");
82 82
 			}
83
-			if(isset($this->_timeout)){
84
-				$js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}); }, {$this->_timeout});",true);
83
+			if (isset($this->_timeout)) {
84
+				$js->exec("setTimeout(function() { $('#{$this->identifier}').transition({$this->_closeTransition}); }, {$this->_timeout});", true);
85 85
 			}
86 86
 		}
87 87
 		return parent::run($js);
88 88
 	}
89 89
 
90
-	public function setState($visible=true){
91
-		$visible=($visible===true)?"visible":"hidden";
92
-		return $this->addToPropertyCtrl("class", $visible, array("visible","hidden"));
90
+	public function setState($visible=true) {
91
+		$visible=($visible===true) ? "visible" : "hidden";
92
+		return $this->addToPropertyCtrl("class", $visible, array("visible", "hidden"));
93 93
 	}
94 94
 
95
-	public function setVariation($value="floating"){
96
-		return $this->addToPropertyCtrl("class", $value, array("floating","compact"));
95
+	public function setVariation($value="floating") {
96
+		return $this->addToPropertyCtrl("class", $value, array("floating", "compact"));
97 97
 	}
98 98
 
99
-	public function setStyle($style){
99
+	public function setStyle($style) {
100 100
 		return $this->addToPropertyCtrl("class", $style, Style::getConstants());
101 101
 	}
102 102
 
103
-	public function setError(){
103
+	public function setError() {
104 104
 		return $this->setStyle("error");
105 105
 	}
106 106
 
107
-	public function setWarning(){
107
+	public function setWarning() {
108 108
 		return $this->setStyle("warning");
109 109
 	}
110 110
 
111
-	public function setMessage($message){
112
-		if(\is_array($this->content)){
111
+	public function setMessage($message) {
112
+		if (\is_array($this->content)) {
113 113
 			$this->content[\sizeof($this->content)-1]=$message;
114
-		}else
114
+		} else
115 115
 			$this->setContent($message);
116 116
 	}
117 117
 
Please login to merge, or discard this patch.
Braces   +9 added lines, -7 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 		$this->wrapContent("<div class='content'>","</div>");
52 52
 		if(\is_string($icon)){
53 53
 			$this->icon=new HtmlIcon("icon-".$this->identifier, $icon);
54
-		}else{
54
+		} else{
55 55
 			$this->icon=$icon;
56 56
 		}
57 57
 		return $this;
@@ -64,10 +64,11 @@  discard block
 block discarded – undo
64 64
 	}
65 65
 
66 66
 	public function setDismissable($dismiss=true){
67
-		if($dismiss===true)
68
-			$this->close=new HtmlIcon("close-".$this->identifier, "close");
69
-		else
70
-			$this->close=NULL;
67
+		if($dismiss===true) {
68
+					$this->close=new HtmlIcon("close-".$this->identifier, "close");
69
+		} else {
70
+					$this->close=NULL;
71
+		}
71 72
 		return $this;
72 73
 	}
73 74
 
@@ -111,8 +112,9 @@  discard block
 block discarded – undo
111 112
 	public function setMessage($message){
112 113
 		if(\is_array($this->content)){
113 114
 			$this->content[\sizeof($this->content)-1]=$message;
114
-		}else
115
-			$this->setContent($message);
115
+		} else {
116
+					$this->setContent($message);
117
+		}
116 118
 	}
117 119
 
118 120
 }
Please login to merge, or discard this patch.
Ajax/service/Javascript.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@  discard block
 block discarded – undo
6 6
 	public static $preventDefault="\nif(event && event.preventDefault) event.preventDefault();\n";
7 7
 	public static $stopPropagation="\nif(event && event.stopPropagation) event.stopPropagation();\n";
8 8
 
9
-	public static function containsCode($expression){
10
-		return strrpos($expression, 'this')!==false||strrpos($expression, 'event')!==false||strrpos($expression, 'self')!==false;
9
+	public static function containsCode($expression) {
10
+		return strrpos($expression, 'this')!==false || strrpos($expression, 'event')!==false || strrpos($expression, 'self')!==false;
11 11
 	}
12 12
 
13 13
 	/**
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 		return $value;
44 44
 	}
45 45
 
46
-	public static function prep_jquery_selector($value){
47
-		if(JString::startswith($value, '$(')===false){
46
+	public static function prep_jquery_selector($value) {
47
+		if (JString::startswith($value, '$(')===false) {
48 48
 			return '$('.$value.')';
49 49
 		}
50 50
 		return $value;
Please login to merge, or discard this patch.
Ajax/service/AjaxTransition.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -3,26 +3,26 @@
 block discarded – undo
3 3
 use Ajax\semantic\html\base\constants\Transition;
4 4
 
5 5
 class AjaxTransition {
6
-	public static function none($responseElement,$jqueryDone="html"){
6
+	public static function none($responseElement, $jqueryDone="html") {
7 7
 		return $responseElement.".".$jqueryDone."( data )";
8 8
 	}
9 9
 
10
-	public static function jqFade($responseElement,$jqueryDone="html"){
10
+	public static function jqFade($responseElement, $jqueryDone="html") {
11 11
 		return $responseElement.".hide().{$jqueryDone}( data ).fadeIn()";
12 12
 	}
13 13
 
14
-	public static function jqSlide($responseElement,$jqueryDone="html"){
14
+	public static function jqSlide($responseElement, $jqueryDone="html") {
15 15
 		return $responseElement.".hide().{$jqueryDone}( data ).slideDown()";
16 16
 	}
17 17
 
18
-	public static function random($responseElement,$jqueryDone="html"){
18
+	public static function random($responseElement, $jqueryDone="html") {
19 19
 		$transitions=Transition::getConstantValues();
20
-		$transition=$transitions[\rand(0,\sizeof($transitions)-1)];
21
-		return self::__callStatic($transition, [$responseElement,$jqueryDone]);
20
+		$transition=$transitions[\rand(0, \sizeof($transitions)-1)];
21
+		return self::__callStatic($transition, [$responseElement, $jqueryDone]);
22 22
 	}
23 23
 
24
-	public static function __callStatic($name, $arguments){
25
-		if(\sizeof($arguments)==2){
24
+	public static function __callStatic($name, $arguments) {
25
+		if (\sizeof($arguments)==2) {
26 26
 			$responseElement=$arguments[0];
27 27
 			$jqueryDone=$arguments[1];
28 28
 			$name=JString::camelCaseToSeparated($name);
Please login to merge, or discard this patch.
Ajax/common/traits/JsUtilsAjaxTrait.php 2 patches
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -16,9 +16,9 @@  discard block
 block discarded – undo
16 16
 	protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>';
17 17
 
18 18
 	abstract public function getUrl($url);
19
-	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true);
19
+	abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true);
20 20
 
21
-	protected function _ajax($method,$url,$responseElement="",$parameters=[]) {
21
+	protected function _ajax($method, $url, $responseElement="", $parameters=[]) {
22 22
 		$jsCallback=null;
23 23
 		$attr="id";
24 24
 		$hasLoader=true;
@@ -34,78 +34,78 @@  discard block
 block discarded – undo
34 34
 		$retour=$this->_getAjaxUrl($url, $attr);
35 35
 		$responseElement=$this->_getResponseElement($responseElement);
36 36
 		$retour.="var self=this;\n";
37
-		if($hasLoader===true && JString::isNotNull($responseElement)){
37
+		if ($hasLoader===true && JString::isNotNull($responseElement)) {
38 38
 			$this->addLoading($retour, $responseElement);
39 39
 		}
40 40
 
41
-		$ajaxParameters=["url"=>"url","method"=>"'".\strtoupper($method)."'"];
42
-		if(isset($params)){
41
+		$ajaxParameters=["url"=>"url", "method"=>"'".\strtoupper($method)."'"];
42
+		if (isset($params)) {
43 43
 			$ajaxParameters["data"]=self::_correctParams($params);
44 44
 		}
45
-		if(isset($headers)){
45
+		if (isset($headers)) {
46 46
 			$ajaxParameters["headers"]=$headers;
47 47
 		}
48 48
 		$this->createAjaxParameters($ajaxParameters, $parameters);
49 49
 		$retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n";
50
-		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
51
-		$retour=$this->_addJsCondition($jsCondition,$retour);
50
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n";
51
+		$retour=$this->_addJsCondition($jsCondition, $retour);
52 52
 		if ($immediatly)
53 53
 			$this->jquery_code_for_compile[]=$retour;
54 54
 		return $retour;
55 55
 	}
56 56
 
57
-	protected function createAjaxParameters(&$original,$parameters){
58
-		$validParameters=["dataType"=>"'%value%'","beforeSend"=>"function(jqXHR,settings){%value%}","complete"=>"function(jqXHR){%value%}"];
59
-		foreach ($validParameters as $param=>$mask){
60
-			if(isset($parameters[$param])){
57
+	protected function createAjaxParameters(&$original, $parameters) {
58
+		$validParameters=["dataType"=>"'%value%'", "beforeSend"=>"function(jqXHR,settings){%value%}", "complete"=>"function(jqXHR){%value%}"];
59
+		foreach ($validParameters as $param=>$mask) {
60
+			if (isset($parameters[$param])) {
61 61
 				$original[$param]=\str_replace("%value%", $parameters[$param], $mask);
62 62
 			}
63 63
 		}
64 64
 	}
65 65
 
66
-	protected function implodeAjaxParameters($ajaxParameters){
67
-		$s = ''; foreach ($ajaxParameters as $k=>$v) { if ($s !== '') { $s .= ','; } $s .= "'{$k}':{$v}"; }
66
+	protected function implodeAjaxParameters($ajaxParameters) {
67
+		$s=''; foreach ($ajaxParameters as $k=>$v) { if ($s!=='') { $s.=','; } $s.="'{$k}':{$v}"; }
68 68
 		return $s;
69 69
 	}
70 70
 
71
-	protected function _addJsCondition($jsCondition,$jsSource){
72
-		if(isset($jsCondition)){
71
+	protected function _addJsCondition($jsCondition, $jsSource) {
72
+		if (isset($jsCondition)) {
73 73
 			return "if(".$jsCondition."){\n".$jsSource."\n}";
74 74
 		}
75 75
 		return $jsSource;
76 76
 	}
77 77
 
78 78
 
79
-	protected function _getAjaxUrl($url,$attr){
79
+	protected function _getAjaxUrl($url, $attr) {
80 80
 		$url=$this->_correctAjaxUrl($url);
81 81
 		$retour="url='".$url."';";
82 82
 		$slash="/";
83
-		if(JString::endswith($url, "/")===true){
83
+		if (JString::endswith($url, "/")===true) {
84 84
 			$slash="";
85 85
 		}
86
-		if(JString::isNotNull($attr)){
87
-			if ($attr==="value"){
86
+		if (JString::isNotNull($attr)) {
87
+			if ($attr==="value") {
88 88
 				$retour.="url=url+'".$slash."'+$(this).val();\n";
89
-			}elseif ($attr==="html"){
89
+			}elseif ($attr==="html") {
90 90
 				$retour.="url=url+'".$slash."'+$(this).html();\n";
91
-			}elseif(\substr($attr, 0,3)==="js:"){
91
+			}elseif (\substr($attr, 0, 3)==="js:") {
92 92
 				$retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n";
93
-			}elseif($attr!==null && $attr!=="")
93
+			}elseif ($attr!==null && $attr!=="")
94 94
 				$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
95 95
 		}
96 96
 		return $retour;
97 97
 	}
98 98
 
99
-	protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$jsCallback){
100
-		$retour="";$call=null;
99
+	protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback) {
100
+		$retour=""; $call=null;
101 101
 		if ($responseElement!=="") {
102
-			if(isset($ajaxTransition)){
102
+			if (isset($ajaxTransition)) {
103 103
 				$call=$this->setAjaxDataCall($ajaxTransition);
104
-			}elseif(isset($this->ajaxTransition)){
104
+			}elseif (isset($this->ajaxTransition)) {
105 105
 				$call=$this->ajaxTransition;
106 106
 			}
107
-			if(\is_callable($call))
108
-				$retour="\t".$call($responseElement,$jqueryDone).";\n";
107
+			if (\is_callable($call))
108
+				$retour="\t".$call($responseElement, $jqueryDone).";\n";
109 109
 			else
110 110
 				$retour="\t{$responseElement}.{$jqueryDone}( data );\n";
111 111
 		}
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
 		return $retour;
114 114
 	}
115 115
 
116
-	protected function _getResponseElement($responseElement){
116
+	protected function _getResponseElement($responseElement) {
117 117
 		if ($responseElement!=="") {
118 118
 			$responseElement=Javascript::prep_value($responseElement);
119 119
 			$responseElement=Javascript::prep_jquery_selector($responseElement);
@@ -124,26 +124,26 @@  discard block
 block discarded – undo
124 124
 	protected function _correctAjaxUrl($url) {
125 125
 		if ($url!=="/" && JString::endsWith($url, "/")===true)
126 126
 			$url=substr($url, 0, strlen($url)-1);
127
-			if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) {
127
+			if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) {
128 128
 				$url=$this->getUrl($url);
129 129
 			}
130 130
 			return $url;
131 131
 	}
132 132
 
133
-	public static function _correctParams($params){
134
-		if(JString::isNull($params)){
133
+	public static function _correctParams($params) {
134
+		if (JString::isNull($params)) {
135 135
 			return "";
136 136
 		}
137
-		if(\preg_match("@^\{.*?\}$@", $params)){
137
+		if (\preg_match("@^\{.*?\}$@", $params)) {
138 138
 			return '$.param('.$params.')';
139 139
 		}
140 140
 		return $params;
141 141
 	}
142 142
 
143
-	public static function _implodeParams($parameters){
143
+	public static function _implodeParams($parameters) {
144 144
 		$allParameters=[];
145
-		foreach ($parameters as $params){
146
-			if(isset($params))
145
+		foreach ($parameters as $params) {
146
+			if (isset($params))
147 147
 				$allParameters[]=self::_correctParams($params);
148 148
 		}
149 149
 		return \implode("+'&'+", $allParameters);
@@ -161,19 +161,19 @@  discard block
 block discarded – undo
161 161
 		$retour.="\t\t{$responseElement}.prepend('{$loading_notifier}');\n";
162 162
 	}
163 163
 
164
-	protected function setAjaxDataCall($params){
164
+	protected function setAjaxDataCall($params) {
165 165
 		$result=null;
166
-		if(!\is_callable($params)){
167
-			$result=function ($responseElement,$jqueryDone="html") use($params){
168
-				return AjaxTransition::{$params}($responseElement,$jqueryDone);
166
+		if (!\is_callable($params)) {
167
+			$result=function($responseElement, $jqueryDone="html") use($params){
168
+				return AjaxTransition::{$params}($responseElement, $jqueryDone);
169 169
 			};
170 170
 		}
171 171
 		return $result;
172 172
 	}
173 173
 
174
-	protected function setDefaultParameters(&$parameters,$default){
175
-		foreach ($default as $k=>$v){
176
-			if(!isset($parameters[$k]))
174
+	protected function setDefaultParameters(&$parameters, $default) {
175
+		foreach ($default as $k=>$v) {
176
+			if (!isset($parameters[$k]))
177 177
 				$parameters[$k]=$v;
178 178
 		}
179 179
 	}
@@ -187,8 +187,8 @@  discard block
 block discarded – undo
187 187
 	 * @param string $url The url of the request
188 188
 	 * @param string $responseElement selector of the HTML element displaying the answer
189 189
 	 */
190
-	private function _get($url, $responseElement="",$parameters=[]) {
191
-		return $this->_ajax("get", $url,$responseElement,$parameters);
190
+	private function _get($url, $responseElement="", $parameters=[]) {
191
+		return $this->_ajax("get", $url, $responseElement, $parameters);
192 192
 	}
193 193
 
194 194
 	/**
@@ -197,9 +197,9 @@  discard block
 block discarded – undo
197 197
 	 * @param string $responseElement selector of the HTML element displaying the answer
198 198
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null)
199 199
 	 */
200
-	public function get($url, $responseElement="",$parameters=[]) {
200
+	public function get($url, $responseElement="", $parameters=[]) {
201 201
 		$parameters["immediatly"]=true;
202
-		return $this->_get($url,$responseElement,$parameters);
202
+		return $this->_get($url, $responseElement, $parameters);
203 203
 	}
204 204
 
205 205
 	/**
@@ -209,9 +209,9 @@  discard block
 block discarded – undo
209 209
 	 * @param string $responseElement selector of the HTML element displaying the answer
210 210
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null)
211 211
 	 */
212
-	public function ajax($method,$url, $responseElement="", $parameters=[]) {
212
+	public function ajax($method, $url, $responseElement="", $parameters=[]) {
213 213
 		$parameters["immediatly"]=true;
214
-		return $this->_ajax($method,$url,$responseElement,$parameters);
214
+		return $this->_ajax($method, $url, $responseElement, $parameters);
215 215
 	}
216 216
 
217 217
 	/**
@@ -221,9 +221,9 @@  discard block
 block discarded – undo
221 221
 	 * @param string $responseElement selector of the HTML element displaying the answer
222 222
 	 * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null)
223 223
 	 */
224
-	public function ajaxDeferred($method,$url, $responseElement="", $parameters=[]) {
224
+	public function ajaxDeferred($method, $url, $responseElement="", $parameters=[]) {
225 225
 		$parameters["immediatly"]=false;
226
-		return $this->_ajax($method,$url,$responseElement,$parameters);
226
+		return $this->_ajax($method, $url, $responseElement, $parameters);
227 227
 	}
228 228
 
229 229
 	/**
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	 * @param string $context
237 237
 	 * @param boolean $immediatly
238 238
 	 */
239
-	private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) {
239
+	private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) {
240 240
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
241 241
 		$retour=$this->_getAjaxUrl($url, $attr);
242 242
 		$retour.="$.{$method}(url,".$params.").done(function( data ) {\n";
@@ -259,8 +259,8 @@  discard block
 block discarded – undo
259 259
 	 * @param string $context
260 260
 	 * @param boolean $immediatly
261 261
 	 */
262
-	public function json($url, $method="get", $params="{}", $jsCallback=NULL,$context="document",$immediatly=false) {
263
-		return $this->_json($url,$method,$params,$jsCallback,NULL,$context,$immediatly);
262
+	public function json($url, $method="get", $params="{}", $jsCallback=NULL, $context="document", $immediatly=false) {
263
+		return $this->_json($url, $method, $params, $jsCallback, NULL, $context, $immediatly);
264 264
 	}
265 265
 
266 266
 	/**
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 * @param string $url the request address
271 271
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true)
272 272
 	 */
273
-	public function jsonOn($event,$element, $url,$parameters=array()) {
273
+	public function jsonOn($event, $element, $url, $parameters=array()) {
274 274
 		$preventDefault=true;
275 275
 		$stopPropagation=true;
276 276
 		$jsCallback=null;
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 		$params="{}";
281 281
 		$immediatly=true;
282 282
 		extract($parameters);
283
-		return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly);
283
+		return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly);
284 284
 	}
285 285
 
286 286
 	/**
@@ -291,8 +291,8 @@  discard block
 block discarded – undo
291 291
 	 * @param string $jsCallback javascript code to execute after the request
292 292
 	 * @param string $context jquery DOM element, array container.
293 293
 	 */
294
-	public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL,$context=NULL) {
295
-		return $this->json($url, $method, $params, $jsCallback, $context,false);
294
+	public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL, $context=NULL) {
295
+		return $this->json($url, $method, $params, $jsCallback, $context, false);
296 296
 	}
297 297
 
298 298
 	/**
@@ -305,22 +305,22 @@  discard block
 block discarded – undo
305 305
 	 * @param string $rowClass the css class for the new element
306 306
 	 * @param boolean $immediatly
307 307
 	 */
308
-	private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$attr="id",$immediatly=false) {
308
+	private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $attr="id", $immediatly=false) {
309 309
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
310 310
 		$retour=$this->_getAjaxUrl($url, $attr);
311
-		if($context===null){
311
+		if ($context===null) {
312 312
 			$parent="$('".$maskSelector."').parent()";
313
-			$newElm = "$('#'+newId)";
314
-		}else{
313
+			$newElm="$('#'+newId)";
314
+		} else {
315 315
 			$parent=$context;
316
-			$newElm = $context.".find('#'+newId)";
316
+			$newElm=$context.".find('#'+newId)";
317 317
 		}
318 318
 		$appendTo="\t\tnewElm.appendTo(".$parent.");\n";
319 319
 		$retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n";
320 320
 		$retour.=$parent.".find('._json').remove();";
321 321
 		$retour.="\tdata=$.parseJSON(data);$.each(data, function(index, value) {\n"."\tvar created=false;var maskElm=$('".$maskSelector."').first();maskElm.hide();"."\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;"."\tvar newElm=".$newElm.";\n"."\tif(!newElm.length){\n"."\t\tnewElm=maskElm.clone();
322 322
 		newElm.attr('id',newId);\n;newElm.addClass('{$rowClass}').removeClass('_jsonArrayModel');\nnewElm.find('[id]').each(function(){ var newId=$(this).attr('id')+'-'+index;$(this).attr('id',newId).removeClass('_jsonArrayChecked');});\n";
323
-		$retour.= $appendTo;
323
+		$retour.=$appendTo;
324 324
 		$retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('__'+key+'__')>-1){\n"."\t\t\t\tcontent=$(html.split('__'+key+'__').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n";
325 325
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
326 326
 		$retour.="\t".$jsCallback."\n"."});\n";
@@ -339,8 +339,8 @@  discard block
 block discarded – undo
339 339
 	 * @param string $context jquery DOM element, array container.
340 340
 	 * @param boolean $immediatly
341 341
 	 */
342
-	public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$immediatly=false) {
343
-		return $this->_jsonArray($maskSelector, $url,$method,$params,$jsCallback,$rowClass,$context,NULL,$immediatly);
342
+	public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $immediatly=false) {
343
+		return $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, NULL, $immediatly);
344 344
 	}
345 345
 
346 346
 	/**
@@ -353,8 +353,8 @@  discard block
 block discarded – undo
353 353
 	 * @param string $rowClass the css class for the new element
354 354
 	 * @param string $context jquery DOM element, array container.
355 355
 	 */
356
-	public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL) {
357
-		return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback,$rowClass,$context,false);
356
+	public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL) {
357
+		return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, false);
358 358
 	}
359 359
 
360 360
 	/**
@@ -364,18 +364,18 @@  discard block
 block discarded – undo
364 364
 	 * @param string $url the request url
365 365
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true)
366 366
 	 */
367
-	public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) {
367
+	public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) {
368 368
 		$preventDefault=true;
369 369
 		$stopPropagation=true;
370 370
 		$jsCallback=null;
371 371
 		$attr="id";
372 372
 		$method="get";
373
-		$context = null;
373
+		$context=null;
374 374
 		$params="{}";
375 375
 		$immediatly=true;
376 376
 		$rowClass="_json";
377 377
 		extract($parameters);
378
-		return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $rowClass, $context,$attr), $event, $preventDefault, $stopPropagation,$immediatly);
378
+		return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, $attr), $event, $preventDefault, $stopPropagation, $immediatly);
379 379
 	}
380 380
 
381 381
 	/**
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	 */
388 388
 	public function getDeferred($url, $responseElement="", $parameters=[]) {
389 389
 		$parameters["immediatly"]=false;
390
-		return $this->_get($url, $responseElement,$parameters);
390
+		return $this->_get($url, $responseElement, $parameters);
391 391
 	}
392 392
 
393 393
 	/**
@@ -400,8 +400,8 @@  discard block
 block discarded – undo
400 400
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null)
401 401
 	 */
402 402
 	public function getOn($event, $element, $url, $responseElement="", $parameters=array()) {
403
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]);
404
-		return $this->_add_event($element, $this->getDeferred($url,$responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
403
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]);
404
+		return $this->_add_event($element, $this->getDeferred($url, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
405 405
 	}
406 406
 
407 407
 	/**
@@ -414,8 +414,8 @@  discard block
 block discarded – undo
414 414
 	 * @param array $parameters default : array("method"=>"get","preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null)
415 415
 	 */
416 416
 	public function ajaxOn($event, $element, $url, $responseElement="", $parameters=array()) {
417
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true,"method"=>"get"]);
418
-		return $this->_add_event($element, $this->ajaxDeferred($parameters["method"],$url,$responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
417
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true, "method"=>"get"]);
418
+		return $this->_add_event($element, $this->ajaxDeferred($parameters["method"], $url, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
419 419
 	}
420 420
 
421 421
 	/**
@@ -442,9 +442,9 @@  discard block
 block discarded – undo
442 442
 		return $this->getOn("click", $element, $url, $responseElement, $parameters);
443 443
 	}
444 444
 
445
-	private function _post($url, $params="{}",$responseElement="", $parameters=[]) {
445
+	private function _post($url, $params="{}", $responseElement="", $parameters=[]) {
446 446
 		$parameters["params"]=$params;
447
-		return $this->_ajax("POST", $url,$responseElement,$parameters);
447
+		return $this->_ajax("POST", $url, $responseElement, $parameters);
448 448
 	}
449 449
 
450 450
 	/**
@@ -454,8 +454,8 @@  discard block
 block discarded – undo
454 454
 	 * @param string $params JSON parameters
455 455
 	 * @param array $parameters default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null)
456 456
 	 */
457
-	public function post($url, $params="{}",$responseElement="", $parameters=[]) {
458
-		return $this->_post($url, $params,$responseElement, $parameters);
457
+	public function post($url, $params="{}", $responseElement="", $parameters=[]) {
458
+		return $this->_post($url, $params, $responseElement, $parameters);
459 459
 	}
460 460
 
461 461
 	/**
@@ -466,7 +466,7 @@  discard block
 block discarded – undo
466 466
 	 * @param string $responseElement selector of the HTML element displaying the answer
467 467
 	 * @param array $parameters default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null)
468 468
 	 */
469
-	public function postDeferred($url, $params="{}",$responseElement="", $parameters=[]) {
469
+	public function postDeferred($url, $params="{}", $responseElement="", $parameters=[]) {
470 470
 		$parameters["immediatly"]=false;
471 471
 		return $this->_post($url, $params, $responseElement, $parameters);
472 472
 	}
@@ -482,8 +482,8 @@  discard block
 block discarded – undo
482 482
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null)
483 483
 	 */
484 484
 	public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) {
485
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]);
486
-		return $this->_add_event($element, $this->postDeferred($url, $params, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
485
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]);
486
+		return $this->_add_event($element, $this->postDeferred($url, $params, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
487 487
 	}
488 488
 
489 489
 	/**
@@ -500,26 +500,26 @@  discard block
 block discarded – undo
500 500
 	}
501 501
 
502 502
 	private function _postForm($url, $form, $responseElement, $parameters=[]) {
503
-		$params="{}";$validation=false;$jsCallback=NULL;$attr="id";$hasLoader=true;$jqueryDone="html";$ajaxTransition=null;$immediatly=false;$jsCondition=NULL;$headers=NULL;
503
+		$params="{}"; $validation=false; $jsCallback=NULL; $attr="id"; $hasLoader=true; $jqueryDone="html"; $ajaxTransition=null; $immediatly=false; $jsCondition=NULL; $headers=NULL;
504 504
 		\extract($parameters);
505 505
 		$jsCallback=isset($jsCallback) ? $jsCallback : "";
506 506
 		$retour=$this->_getAjaxUrl($url, $attr);
507 507
 		$retour.="\nvar params=$('#".$form."').serialize();\n";
508
-		if(isset($params)){
508
+		if (isset($params)) {
509 509
 			$retour.="params+='&'+".self::_correctParams($params).";\n";
510 510
 		}
511 511
 		$responseElement=$this->_getResponseElement($responseElement);
512 512
 		$retour.="var self=this;\n";
513
-		if($hasLoader===true){
513
+		if ($hasLoader===true) {
514 514
 			$this->addLoading($retour, $responseElement);
515 515
 		}
516
-		$ajaxParameters=["url"=>"url","method"=>"'POST'","data"=>"params"];
517
-		if(isset($headers)){
516
+		$ajaxParameters=["url"=>"url", "method"=>"'POST'", "data"=>"params"];
517
+		if (isset($headers)) {
518 518
 			$ajaxParameters["headers"]=$headers;
519 519
 		}
520 520
 		$this->createAjaxParameters($ajaxParameters, $parameters);
521 521
 		$retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data ) {\n";
522
-		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
522
+		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n";
523 523
 
524 524
 		if ($validation) {
525 525
 			$retour="$('#".$form."').validate({submitHandler: function(form) {
@@ -569,8 +569,8 @@  discard block
 block discarded – undo
569 569
 	 * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null)
570 570
 	 */
571 571
 	public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) {
572
-		$this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]);
573
-		return $this->_add_event($element, $this->postFormDeferred($url, $form, $responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]);
572
+		$this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]);
573
+		return $this->_add_event($element, $this->postFormDeferred($url, $form, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]);
574 574
 	}
575 575
 
576 576
 	/**
Please login to merge, or discard this patch.
Braces   +33 added lines, -24 removed lines patch added patch discarded remove patch
@@ -49,8 +49,9 @@  discard block
 block discarded – undo
49 49
 		$retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n";
50 50
 		$retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n";
51 51
 		$retour=$this->_addJsCondition($jsCondition,$retour);
52
-		if ($immediatly)
53
-			$this->jquery_code_for_compile[]=$retour;
52
+		if ($immediatly) {
53
+					$this->jquery_code_for_compile[]=$retour;
54
+		}
54 55
 		return $retour;
55 56
 	}
56 57
 
@@ -86,12 +87,13 @@  discard block
 block discarded – undo
86 87
 		if(JString::isNotNull($attr)){
87 88
 			if ($attr==="value"){
88 89
 				$retour.="url=url+'".$slash."'+$(this).val();\n";
89
-			}elseif ($attr==="html"){
90
+			} elseif ($attr==="html"){
90 91
 				$retour.="url=url+'".$slash."'+$(this).html();\n";
91
-			}elseif(\substr($attr, 0,3)==="js:"){
92
+			} elseif(\substr($attr, 0,3)==="js:"){
92 93
 				$retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n";
93
-			}elseif($attr!==null && $attr!=="")
94
-				$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
94
+			} elseif($attr!==null && $attr!=="") {
95
+							$retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n";
96
+			}
95 97
 		}
96 98
 		return $retour;
97 99
 	}
@@ -101,13 +103,14 @@  discard block
 block discarded – undo
101 103
 		if ($responseElement!=="") {
102 104
 			if(isset($ajaxTransition)){
103 105
 				$call=$this->setAjaxDataCall($ajaxTransition);
104
-			}elseif(isset($this->ajaxTransition)){
106
+			} elseif(isset($this->ajaxTransition)){
105 107
 				$call=$this->ajaxTransition;
106 108
 			}
107
-			if(\is_callable($call))
108
-				$retour="\t".$call($responseElement,$jqueryDone).";\n";
109
-			else
110
-				$retour="\t{$responseElement}.{$jqueryDone}( data );\n";
109
+			if(\is_callable($call)) {
110
+							$retour="\t".$call($responseElement,$jqueryDone).";\n";
111
+			} else {
112
+							$retour="\t{$responseElement}.{$jqueryDone}( data );\n";
113
+			}
111 114
 		}
112 115
 		$retour.="\t".$jsCallback."\n";
113 116
 		return $retour;
@@ -122,8 +125,9 @@  discard block
 block discarded – undo
122 125
 	}
123 126
 
124 127
 	protected function _correctAjaxUrl($url) {
125
-		if ($url!=="/" && JString::endsWith($url, "/")===true)
126
-			$url=substr($url, 0, strlen($url)-1);
128
+		if ($url!=="/" && JString::endsWith($url, "/")===true) {
129
+					$url=substr($url, 0, strlen($url)-1);
130
+		}
127 131
 			if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) {
128 132
 				$url=$this->getUrl($url);
129 133
 			}
@@ -143,8 +147,9 @@  discard block
 block discarded – undo
143 147
 	public static function _implodeParams($parameters){
144 148
 		$allParameters=[];
145 149
 		foreach ($parameters as $params){
146
-			if(isset($params))
147
-				$allParameters[]=self::_correctParams($params);
150
+			if(isset($params)) {
151
+							$allParameters[]=self::_correctParams($params);
152
+			}
148 153
 		}
149 154
 		return \implode("+'&'+", $allParameters);
150 155
 	}
@@ -173,8 +178,9 @@  discard block
 block discarded – undo
173 178
 
174 179
 	protected function setDefaultParameters(&$parameters,$default){
175 180
 		foreach ($default as $k=>$v){
176
-			if(!isset($parameters[$k]))
177
-				$parameters[$k]=$v;
181
+			if(!isset($parameters[$k])) {
182
+							$parameters[$k]=$v;
183
+			}
178 184
 		}
179 185
 	}
180 186
 
@@ -245,8 +251,9 @@  discard block
 block discarded – undo
245 251
 				$retour.="\t".$jsCallback."\n".
246 252
 						"\t$(document).trigger('jsonReady',[data]);\n".
247 253
 						"});\n";
248
-				if ($immediatly)
249
-					$this->jquery_code_for_compile[]=$retour;
254
+				if ($immediatly) {
255
+									$this->jquery_code_for_compile[]=$retour;
256
+				}
250 257
 		return $retour;
251 258
 	}
252 259
 
@@ -311,7 +318,7 @@  discard block
 block discarded – undo
311 318
 		if($context===null){
312 319
 			$parent="$('".$maskSelector."').parent()";
313 320
 			$newElm = "$('#'+newId)";
314
-		}else{
321
+		} else{
315 322
 			$parent=$context;
316 323
 			$newElm = $context.".find('#'+newId)";
317 324
 		}
@@ -324,8 +331,9 @@  discard block
 block discarded – undo
324 331
 		$retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('__'+key+'__')>-1){\n"."\t\t\t\tcontent=$(html.split('__'+key+'__').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n";
325 332
 		$retour.="\t$(document).trigger('jsonReady',[data]);\n";
326 333
 		$retour.="\t".$jsCallback."\n"."});\n";
327
-		if ($immediatly)
328
-			$this->jquery_code_for_compile[]=$retour;
334
+		if ($immediatly) {
335
+					$this->jquery_code_for_compile[]=$retour;
336
+		}
329 337
 		return $retour;
330 338
 	}
331 339
 
@@ -528,8 +536,9 @@  discard block
 block discarded – undo
528 536
 			$retour.="$('#".$form."').submit();\n";
529 537
 		}
530 538
 		$retour=$this->_addJsCondition($jsCondition, $retour);
531
-		if ($immediatly)
532
-			$this->jquery_code_for_compile[]=$retour;
539
+		if ($immediatly) {
540
+					$this->jquery_code_for_compile[]=$retour;
541
+		}
533 542
 		return $retour;
534 543
 	}
535 544
 
Please login to merge, or discard this patch.