|
@@ -14,215 +14,215 @@ discard block |
|
|
block discarded – undo |
|
14
|
14
|
*/ |
|
15
|
15
|
trait JsUtilsAjaxTrait { |
|
16
|
16
|
protected $ajaxTransition; |
|
17
|
|
- protected $ajaxLoader = "<div class=\"ui active centered inline text loader\">Loading</div>"; |
|
|
17
|
+ protected $ajaxLoader="<div class=\"ui active centered inline text loader\">Loading</div>"; |
|
18
|
18
|
abstract public function getUrl($url); |
|
19
|
|
- abstract public function _add_event($element, $js, $event, $preventDefault = false, $stopPropagation = false, $immediatly = true, $listenerOn=false); |
|
20
|
|
- abstract public function interval($jsCode, $time, $globalName = null, $immediatly = true); |
|
21
|
|
- |
|
22
|
|
- protected function _ajax($method, $url, $responseElement = '', $parameters = [ ]) { |
|
23
|
|
- if (isset ( $this->params ['ajax'] )) { |
|
24
|
|
- extract ( $this->params ['ajax'] ); |
|
25
|
|
- } |
|
26
|
|
- extract ( $parameters ); |
|
27
|
|
- |
|
28
|
|
- $jsCallback = isset ( $jsCallback ) ? $jsCallback : ''; |
|
29
|
|
- $retour = $this->_getAjaxUrl ( $url, $attr ); |
|
30
|
|
- $originalSelector = $responseElement; |
|
31
|
|
- $responseElement = $this->_getResponseElement ( $responseElement ); |
|
32
|
|
- $retour .= "var self=this;\n"; |
|
33
|
|
- $before = isset ( $before ) ? $before : ""; |
|
34
|
|
- $retour .= $before; |
|
35
|
|
- if ($hasLoader === true && JString::isNotNull ( $responseElement )) { |
|
36
|
|
- $this->addLoading ( $retour, $responseElement, $ajaxLoader ); |
|
37
|
|
- } elseif ($hasLoader === 'response') { |
|
38
|
|
- $this->addResponseLoading ( $retour, $responseElement, $ajaxLoader ); |
|
39
|
|
- } elseif ($hasLoader === 'internal') { |
|
40
|
|
- $retour .= "\n$(this).addClass('loading');"; |
|
41
|
|
- } |
|
42
|
|
- $ajaxParameters = [ |
|
|
19
|
+ abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true, $listenerOn=false); |
|
|
20
|
+ abstract public function interval($jsCode, $time, $globalName=null, $immediatly=true); |
|
|
21
|
+ |
|
|
22
|
+ protected function _ajax($method, $url, $responseElement='', $parameters=[]) { |
|
|
23
|
+ if (isset ($this->params ['ajax'])) { |
|
|
24
|
+ extract($this->params ['ajax']); |
|
|
25
|
+ } |
|
|
26
|
+ extract($parameters); |
|
|
27
|
+ |
|
|
28
|
+ $jsCallback=isset ($jsCallback) ? $jsCallback : ''; |
|
|
29
|
+ $retour=$this->_getAjaxUrl($url, $attr); |
|
|
30
|
+ $originalSelector=$responseElement; |
|
|
31
|
+ $responseElement=$this->_getResponseElement($responseElement); |
|
|
32
|
+ $retour.="var self=this;\n"; |
|
|
33
|
+ $before=isset ($before) ? $before : ""; |
|
|
34
|
+ $retour.=$before; |
|
|
35
|
+ if ($hasLoader===true && JString::isNotNull($responseElement)) { |
|
|
36
|
+ $this->addLoading($retour, $responseElement, $ajaxLoader); |
|
|
37
|
+ } elseif ($hasLoader==='response') { |
|
|
38
|
+ $this->addResponseLoading($retour, $responseElement, $ajaxLoader); |
|
|
39
|
+ } elseif ($hasLoader==='internal') { |
|
|
40
|
+ $retour.="\n$(this).addClass('loading');"; |
|
|
41
|
+ } |
|
|
42
|
+ $ajaxParameters=[ |
|
43
|
43
|
"url" => "url", |
|
44
|
|
- "method" => "'" . \strtoupper ( $method ) . "'" |
|
|
44
|
+ "method" => "'".\strtoupper($method)."'" |
|
45
|
45
|
]; |
|
46
|
46
|
|
|
47
|
|
- $ajaxParameters ["async"] = ($async ? "true" : "false"); |
|
|
47
|
+ $ajaxParameters ["async"]=($async ? "true" : "false"); |
|
48
|
48
|
|
|
49
|
|
- if (isset ( $params )) { |
|
50
|
|
- $ajaxParameters ["data"] = self::_correctParams ( $params, $parameters ); |
|
|
49
|
+ if (isset ($params)) { |
|
|
50
|
+ $ajaxParameters ["data"]=self::_correctParams($params, $parameters); |
|
51
|
51
|
} |
|
52
|
|
- if (isset ( $headers )) { |
|
53
|
|
- $ajaxParameters ["headers"] = $headers; |
|
|
52
|
+ if (isset ($headers)) { |
|
|
53
|
+ $ajaxParameters ["headers"]=$headers; |
|
54
|
54
|
} |
|
55
|
55
|
if ($csrf) { |
|
56
|
|
- $csrf=(is_string($csrf))?$csrf:'csrf-token'; |
|
57
|
|
- $parameters ["beforeSend"] = "jqXHR.setRequestHeader('{$csrf}', $('meta[name=\"{$csrf}\"]').attr('content'));"; |
|
|
56
|
+ $csrf=(is_string($csrf)) ? $csrf : 'csrf-token'; |
|
|
57
|
+ $parameters ["beforeSend"]="jqXHR.setRequestHeader('{$csrf}', $('meta[name=\"{$csrf}\"]').attr('content'));"; |
|
58
|
58
|
} |
|
59
|
|
- if (isset ( $partial )) { |
|
60
|
|
- $ajaxParameters ["xhr"] = "xhrProvider"; |
|
61
|
|
- $retour .= "var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;" . $partial . ";}; };"; |
|
|
59
|
+ if (isset ($partial)) { |
|
|
60
|
+ $ajaxParameters ["xhr"]="xhrProvider"; |
|
|
61
|
+ $retour.="var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;".$partial.";}; };"; |
|
62
|
62
|
} |
|
63
|
|
- $this->createAjaxParameters ( $ajaxParameters, $parameters ); |
|
64
|
|
- $retour .= "$.ajax({" . $this->implodeAjaxParameters ( $ajaxParameters ) . "}).done(function( data, textStatus, jqXHR ) {\n"; |
|
65
|
|
- $retour .= $this->_getOnAjaxDone ( $responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader, ($historize ? $originalSelector : null) ) . "});\n"; |
|
|
63
|
+ $this->createAjaxParameters($ajaxParameters, $parameters); |
|
|
64
|
+ $retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n"; |
|
|
65
|
+ $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader, ($historize ? $originalSelector : null))."});\n"; |
|
66
|
66
|
|
|
67
|
|
- $retour = $this->_addJsCondition ( $jsCondition, $retour ); |
|
|
67
|
+ $retour=$this->_addJsCondition($jsCondition, $retour); |
|
68
|
68
|
if ($immediatly) |
|
69
|
|
- $this->jquery_code_for_compile [] = $retour; |
|
|
69
|
+ $this->jquery_code_for_compile []=$retour; |
|
70
|
70
|
return $retour; |
|
71
|
71
|
} |
|
72
|
72
|
protected function createAjaxParameters(&$original, $parameters) { |
|
73
|
|
- $validParameters = [ |
|
|
73
|
+ $validParameters=[ |
|
74
|
74
|
"contentType" => "%value%", |
|
75
|
75
|
"dataType" => "'%value%'", |
|
76
|
76
|
"beforeSend" => "function(jqXHR,settings){%value%}", |
|
77
|
77
|
"complete" => "function(jqXHR){%value%}", |
|
78
|
78
|
"processData" => "%value%" |
|
79
|
79
|
]; |
|
80
|
|
- foreach ( $validParameters as $param => $mask ) { |
|
81
|
|
- if (isset ( $parameters [$param] )) { |
|
82
|
|
- $original [$param] = \str_replace ( "%value%", $parameters [$param], $mask ); |
|
|
80
|
+ foreach ($validParameters as $param => $mask) { |
|
|
81
|
+ if (isset ($parameters [$param])) { |
|
|
82
|
+ $original [$param]=\str_replace("%value%", $parameters [$param], $mask); |
|
83
|
83
|
} |
|
84
|
84
|
} |
|
85
|
85
|
} |
|
86
|
86
|
protected function implodeAjaxParameters($ajaxParameters) { |
|
87
|
|
- $s = ''; |
|
88
|
|
- foreach ( $ajaxParameters as $k => $v ) { |
|
89
|
|
- if ($s !== '') { |
|
90
|
|
- $s .= ','; |
|
|
87
|
+ $s=''; |
|
|
88
|
+ foreach ($ajaxParameters as $k => $v) { |
|
|
89
|
+ if ($s!=='') { |
|
|
90
|
+ $s.=','; |
|
91
|
91
|
} |
|
92
|
|
- if (is_array ( $v )) { |
|
93
|
|
- $s .= "'{$k}':{" . self::implodeAjaxParameters ( $v ) . "}"; |
|
|
92
|
+ if (is_array($v)) { |
|
|
93
|
+ $s.="'{$k}':{".self::implodeAjaxParameters($v)."}"; |
|
94
|
94
|
} else { |
|
95
|
|
- $s .= "'{$k}':{$v}"; |
|
|
95
|
+ $s.="'{$k}':{$v}"; |
|
96
|
96
|
} |
|
97
|
97
|
} |
|
98
|
98
|
return $s; |
|
99
|
99
|
} |
|
100
|
100
|
protected function _addJsCondition($jsCondition, $jsSource) { |
|
101
|
|
- if (isset ( $jsCondition )) { |
|
102
|
|
- return "if(" . $jsCondition . "){\n" . $jsSource . "\n}"; |
|
|
101
|
+ if (isset ($jsCondition)) { |
|
|
102
|
+ return "if(".$jsCondition."){\n".$jsSource."\n}"; |
|
103
|
103
|
} |
|
104
|
104
|
return $jsSource; |
|
105
|
105
|
} |
|
106
|
106
|
protected function _getAjaxUrl($url, $attr) { |
|
107
|
|
- $url = $this->_correctAjaxUrl ( $url ); |
|
108
|
|
- $retour = "url='" . $url . "';"; |
|
109
|
|
- $slash = "/"; |
|
110
|
|
- if (JString::endswith ( $url, "/" ) === true) { |
|
111
|
|
- $slash = ""; |
|
112
|
|
- } |
|
113
|
|
- if (JString::isNotNull ( $attr )) { |
|
114
|
|
- if ($attr === "value") { |
|
115
|
|
- $retour .= "url=url+'" . $slash . "'+$(this).val();\n"; |
|
116
|
|
- } elseif ($attr === "html") { |
|
117
|
|
- $retour .= "url=url+'" . $slash . "'+$(this).html();\n"; |
|
118
|
|
- } elseif (\substr ( $attr, 0, 3 ) === "js:") { |
|
119
|
|
- $retour .= "url=url+'" . $slash . "'+" . \substr ( $attr, 3 ) . ";\n"; |
|
120
|
|
- } elseif ($attr !== null && $attr !== "") |
|
121
|
|
- $retour .= "url=url+'" . $slash . "'+($(this).attr('" . $attr . "')||'');\n"; |
|
|
107
|
+ $url=$this->_correctAjaxUrl($url); |
|
|
108
|
+ $retour="url='".$url."';"; |
|
|
109
|
+ $slash="/"; |
|
|
110
|
+ if (JString::endswith($url, "/")===true) { |
|
|
111
|
+ $slash=""; |
|
|
112
|
+ } |
|
|
113
|
+ if (JString::isNotNull($attr)) { |
|
|
114
|
+ if ($attr==="value") { |
|
|
115
|
+ $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
|
116
|
+ } elseif ($attr==="html") { |
|
|
117
|
+ $retour.="url=url+'".$slash."'+$(this).html();\n"; |
|
|
118
|
+ } elseif (\substr($attr, 0, 3)==="js:") { |
|
|
119
|
+ $retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n"; |
|
|
120
|
+ } elseif ($attr!==null && $attr!=="") |
|
|
121
|
+ $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
122
|
122
|
} |
|
123
|
123
|
return $retour; |
|
124
|
124
|
} |
|
125
|
125
|
protected function onPopstate() { |
|
126
|
126
|
return "window.onpopstate = function(e){if(e.state){var target=e.state.jqueryDone;$(e.state.selector)[target](e.state.html);}};"; |
|
127
|
127
|
} |
|
128
|
|
- protected function autoActiveLinks($previousURL = "window.location.href") { |
|
129
|
|
- $result = "\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}"; |
|
130
|
|
- $result .= "\nvar myurl={$previousURL};if(window._previousURL) getHref(window._previousURL).removeClass('active');getHref(myurl).addClass('active');window._previousURL=myurl;"; |
|
|
128
|
+ protected function autoActiveLinks($previousURL="window.location.href") { |
|
|
129
|
+ $result="\nfunction getHref(url) { return \$('a').filter(function(){return \$(this).prop('href') == url; });}"; |
|
|
130
|
+ $result.="\nvar myurl={$previousURL};if(window._previousURL) getHref(window._previousURL).removeClass('active');getHref(myurl).addClass('active');window._previousURL=myurl;"; |
|
131
|
131
|
return $result; |
|
132
|
132
|
} |
|
133
|
|
- protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader = false, $history = null) { |
|
134
|
|
- $retour = ""; |
|
135
|
|
- $call = null; |
|
136
|
|
- if (JString::isNotNull ( $responseElement )) { |
|
137
|
|
- if (isset ( $ajaxTransition )) { |
|
138
|
|
- $call = $this->setAjaxDataCall ( $ajaxTransition ); |
|
139
|
|
- } elseif (isset ( $this->ajaxTransition )) { |
|
140
|
|
- $call = $this->ajaxTransition; |
|
|
133
|
+ protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader=false, $history=null) { |
|
|
134
|
+ $retour=""; |
|
|
135
|
+ $call=null; |
|
|
136
|
+ if (JString::isNotNull($responseElement)) { |
|
|
137
|
+ if (isset ($ajaxTransition)) { |
|
|
138
|
+ $call=$this->setAjaxDataCall($ajaxTransition); |
|
|
139
|
+ } elseif (isset ($this->ajaxTransition)) { |
|
|
140
|
+ $call=$this->ajaxTransition; |
|
141
|
141
|
} |
|
142
|
|
- if (\is_callable ( $call )) |
|
143
|
|
- $retour = "\t" . $call ( $responseElement, $jqueryDone ) . ";\n"; |
|
|
142
|
+ if (\is_callable($call)) |
|
|
143
|
+ $retour="\t".$call($responseElement, $jqueryDone).";\n"; |
|
144
|
144
|
else |
|
145
|
|
- $retour = "\t{$responseElement}.{$jqueryDone}( data );\n"; |
|
|
145
|
+ $retour="\t{$responseElement}.{$jqueryDone}( data );\n"; |
|
146
|
146
|
} |
|
147
|
|
- if (isset ( $history )) { |
|
|
147
|
+ if (isset ($history)) { |
|
148
|
148
|
if ($this->params ["autoActiveLinks"]) { |
|
149
|
|
- $retour .= $this->autoActiveLinks ( "url" ); |
|
|
149
|
+ $retour.=$this->autoActiveLinks("url"); |
|
150
|
150
|
} |
|
151
|
|
- $retour .= "\nwindow.history.pushState({'html':data,'selector':" . Javascript::prep_value ( $history ) . ",'jqueryDone':'{$jqueryDone}'},'', url);"; |
|
|
151
|
+ $retour.="\nwindow.history.pushState({'html':data,'selector':".Javascript::prep_value($history).",'jqueryDone':'{$jqueryDone}'},'', url);"; |
|
152
|
152
|
} |
|
153
|
|
- if ($hasLoader === 'internal') { |
|
154
|
|
- $retour .= "\n$(self).removeClass('loading');"; |
|
|
153
|
+ if ($hasLoader==='internal') { |
|
|
154
|
+ $retour.="\n$(self).removeClass('loading');"; |
|
155
|
155
|
} |
|
156
|
|
- $retour .= "\t" . $jsCallback . "\n"; |
|
|
156
|
+ $retour.="\t".$jsCallback."\n"; |
|
157
|
157
|
return $retour; |
|
158
|
158
|
} |
|
159
|
159
|
protected function _getResponseElement($responseElement) { |
|
160
|
|
- if (JString::isNotNull ( $responseElement )) { |
|
161
|
|
- $responseElement = Javascript::prep_jquery_selector ( $responseElement ); |
|
|
160
|
+ if (JString::isNotNull($responseElement)) { |
|
|
161
|
+ $responseElement=Javascript::prep_jquery_selector($responseElement); |
|
162
|
162
|
} |
|
163
|
163
|
return $responseElement; |
|
164
|
164
|
} |
|
165
|
165
|
protected function _correctAjaxUrl($url) { |
|
166
|
|
- if ($url !== "/" && JString::endsWith ( $url, "/" ) === true) |
|
167
|
|
- $url = substr ( $url, 0, strlen ( $url ) - 1 ); |
|
168
|
|
- if (strncmp ( $url, 'http://', 7 ) != 0 && strncmp ( $url, 'https://', 8 ) != 0) { |
|
169
|
|
- $url = $this->getUrl ( $url ); |
|
|
166
|
+ if ($url!=="/" && JString::endsWith($url, "/")===true) |
|
|
167
|
+ $url=substr($url, 0, strlen($url)-1); |
|
|
168
|
+ if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
|
169
|
+ $url=$this->getUrl($url); |
|
170
|
170
|
} |
|
171
|
171
|
return $url; |
|
172
|
172
|
} |
|
173
|
|
- public static function _correctParams($params, $ajaxParameters = [ ]) { |
|
174
|
|
- if (JString::isNull ( $params )) { |
|
|
173
|
+ public static function _correctParams($params, $ajaxParameters=[]) { |
|
|
174
|
+ if (JString::isNull($params)) { |
|
175
|
175
|
return ""; |
|
176
|
176
|
} |
|
177
|
|
- if (\preg_match ( "@^\{.*?\}$@", $params )) { |
|
178
|
|
- if (! isset ( $ajaxParameters ['contentType'] ) || ! JString::contains ( $ajaxParameters ['contentType'], 'json' )) { |
|
179
|
|
- return '$.param(' . $params . ')'; |
|
|
177
|
+ if (\preg_match("@^\{.*?\}$@", $params)) { |
|
|
178
|
+ if (!isset ($ajaxParameters ['contentType']) || !JString::contains($ajaxParameters ['contentType'], 'json')) { |
|
|
179
|
+ return '$.param('.$params.')'; |
|
180
|
180
|
} else { |
|
181
|
|
- return 'JSON.stringify(' . $params . ')'; |
|
|
181
|
+ return 'JSON.stringify('.$params.')'; |
|
182
|
182
|
} |
|
183
|
183
|
} |
|
184
|
184
|
return $params; |
|
185
|
185
|
} |
|
186
|
186
|
public static function _implodeParams($parameters) { |
|
187
|
|
- $allParameters = [ ]; |
|
188
|
|
- foreach ( $parameters as $params ) { |
|
189
|
|
- if (isset ( $params )) |
|
190
|
|
- $allParameters [] = self::_correctParams ( $params ); |
|
|
187
|
+ $allParameters=[]; |
|
|
188
|
+ foreach ($parameters as $params) { |
|
|
189
|
+ if (isset ($params)) |
|
|
190
|
+ $allParameters []=self::_correctParams($params); |
|
191
|
191
|
} |
|
192
|
|
- return \implode ( "+'&'+", $allParameters ); |
|
|
192
|
+ return \implode("+'&'+", $allParameters); |
|
193
|
193
|
} |
|
194
|
|
- protected function addLoading(&$retour, $responseElement, $ajaxLoader = null) { |
|
195
|
|
- if (! isset ( $ajaxLoader )) { |
|
196
|
|
- $ajaxLoader = $this->ajaxLoader; |
|
|
194
|
+ protected function addLoading(&$retour, $responseElement, $ajaxLoader=null) { |
|
|
195
|
+ if (!isset ($ajaxLoader)) { |
|
|
196
|
+ $ajaxLoader=$this->ajaxLoader; |
|
197
|
197
|
} |
|
198
|
|
- $loading_notifier = '<div class="ajax-loader ui active inverted dimmer">' . $ajaxLoader . '</div>'; |
|
199
|
|
- $retour .= "\t\t{$responseElement}.append('{$loading_notifier}');\n"; |
|
|
198
|
+ $loading_notifier='<div class="ajax-loader ui active inverted dimmer">'.$ajaxLoader.'</div>'; |
|
|
199
|
+ $retour.="\t\t{$responseElement}.append('{$loading_notifier}');\n"; |
|
200
|
200
|
} |
|
201
|
|
- protected function addResponseLoading(&$retour, $responseElement, $ajaxLoader = null) { |
|
202
|
|
- if (! isset ( $ajaxLoader )) { |
|
203
|
|
- $ajaxLoader = $this->ajaxLoader; |
|
|
201
|
+ protected function addResponseLoading(&$retour, $responseElement, $ajaxLoader=null) { |
|
|
202
|
+ if (!isset ($ajaxLoader)) { |
|
|
203
|
+ $ajaxLoader=$this->ajaxLoader; |
|
204
|
204
|
} |
|
205
|
|
- $loading_notifier = '<div class="ajax-loader">' . $ajaxLoader . '</div>'; |
|
206
|
|
- $retour .= "{$responseElement}.empty();\n"; |
|
207
|
|
- $retour .= "\t\t{$responseElement}.prepend('{$loading_notifier}');\n"; |
|
|
205
|
+ $loading_notifier='<div class="ajax-loader">'.$ajaxLoader.'</div>'; |
|
|
206
|
+ $retour.="{$responseElement}.empty();\n"; |
|
|
207
|
+ $retour.="\t\t{$responseElement}.prepend('{$loading_notifier}');\n"; |
|
208
|
208
|
} |
|
209
|
209
|
protected function setAjaxDataCall($params) { |
|
210
|
|
- $result = null; |
|
211
|
|
- if (! \is_callable ( $params )) { |
|
212
|
|
- $result = function ($responseElement, $jqueryDone = 'html') use ($params) { |
|
213
|
|
- return AjaxTransition::{$params} ( $responseElement, $jqueryDone ); |
|
|
210
|
+ $result=null; |
|
|
211
|
+ if (!\is_callable($params)) { |
|
|
212
|
+ $result=function($responseElement, $jqueryDone='html') use ($params) { |
|
|
213
|
+ return AjaxTransition::{$params} ($responseElement, $jqueryDone); |
|
214
|
214
|
}; |
|
215
|
215
|
} |
|
216
|
216
|
return $result; |
|
217
|
217
|
} |
|
218
|
218
|
protected function setDefaultParameters(&$parameters, $default) { |
|
219
|
|
- foreach ( $default as $k => $v ) { |
|
220
|
|
- if (! isset ( $parameters [$k] )) |
|
221
|
|
- $parameters [$k] = $v; |
|
|
219
|
+ foreach ($default as $k => $v) { |
|
|
220
|
+ if (!isset ($parameters [$k])) |
|
|
221
|
+ $parameters [$k]=$v; |
|
222
|
222
|
} |
|
223
|
223
|
} |
|
224
|
224
|
public function setAjaxLoader($loader) { |
|
225
|
|
- $this->ajaxLoader = $loader; |
|
|
225
|
+ $this->ajaxLoader=$loader; |
|
226
|
226
|
} |
|
227
|
227
|
|
|
228
|
228
|
/** |
|
@@ -233,8 +233,8 @@ discard block |
|
|
block discarded – undo |
|
233
|
233
|
* @param string $responseElement |
|
234
|
234
|
* selector of the HTML element displaying the answer |
|
235
|
235
|
*/ |
|
236
|
|
- private function _get($url, $responseElement = '', $parameters = [ ]) { |
|
237
|
|
- return $this->_ajax ( 'get', $url, $responseElement, $parameters ); |
|
|
236
|
+ private function _get($url, $responseElement='', $parameters=[]) { |
|
|
237
|
+ return $this->_ajax('get', $url, $responseElement, $parameters); |
|
238
|
238
|
} |
|
239
|
239
|
|
|
240
|
240
|
/** |
|
@@ -247,9 +247,9 @@ discard block |
|
|
block discarded – undo |
|
247
|
247
|
* @param array $parameters |
|
248
|
248
|
* default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
|
249
|
249
|
*/ |
|
250
|
|
- public function get($url, $responseElement = '', $parameters = [ ]) { |
|
251
|
|
- $parameters ['immediatly'] = true; |
|
252
|
|
- return $this->_get ( $url, $responseElement, $parameters ); |
|
|
250
|
+ public function get($url, $responseElement='', $parameters=[]) { |
|
|
251
|
+ $parameters ['immediatly']=true; |
|
|
252
|
+ return $this->_get($url, $responseElement, $parameters); |
|
253
|
253
|
} |
|
254
|
254
|
|
|
255
|
255
|
/** |
|
@@ -264,9 +264,9 @@ discard block |
|
|
block discarded – undo |
|
264
|
264
|
* @param array $parameters |
|
265
|
265
|
* default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
|
266
|
266
|
*/ |
|
267
|
|
- public function ajax($method, $url, $responseElement = '', $parameters = [ ]) { |
|
268
|
|
- $parameters ['immediatly'] = true; |
|
269
|
|
- return $this->_ajax ( $method, $url, $responseElement, $parameters ); |
|
|
267
|
+ public function ajax($method, $url, $responseElement='', $parameters=[]) { |
|
|
268
|
+ $parameters ['immediatly']=true; |
|
|
269
|
+ return $this->_ajax($method, $url, $responseElement, $parameters); |
|
270
|
270
|
} |
|
271
|
271
|
|
|
272
|
272
|
/** |
|
@@ -287,8 +287,8 @@ discard block |
|
|
block discarded – undo |
|
287
|
287
|
* $immediatly |
|
288
|
288
|
* @return string |
|
289
|
289
|
*/ |
|
290
|
|
- public function ajaxInterval($method, $url, $interval, $globalName = null, $responseElement = '', $parameters = [ ], $immediatly = true) { |
|
291
|
|
- return $this->interval ( $this->ajaxDeferred ( $method, $url, $responseElement, $parameters ), $interval, $globalName, $immediatly ); |
|
|
290
|
+ public function ajaxInterval($method, $url, $interval, $globalName=null, $responseElement='', $parameters=[], $immediatly=true) { |
|
|
291
|
+ return $this->interval($this->ajaxDeferred($method, $url, $responseElement, $parameters), $interval, $globalName, $immediatly); |
|
292
|
292
|
} |
|
293
|
293
|
|
|
294
|
294
|
/** |
|
@@ -303,9 +303,9 @@ discard block |
|
|
block discarded – undo |
|
303
|
303
|
* @param array $parameters |
|
304
|
304
|
* default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
|
305
|
305
|
*/ |
|
306
|
|
- public function ajaxDeferred($method, $url, $responseElement = '', $parameters = [ ]) { |
|
307
|
|
- $parameters ['immediatly'] = false; |
|
308
|
|
- return $this->_ajax ( $method, $url, $responseElement, $parameters ); |
|
|
306
|
+ public function ajaxDeferred($method, $url, $responseElement='', $parameters=[]) { |
|
|
307
|
+ $parameters ['immediatly']=false; |
|
|
308
|
+ return $this->_ajax($method, $url, $responseElement, $parameters); |
|
309
|
309
|
} |
|
310
|
310
|
|
|
311
|
311
|
/** |
|
@@ -318,16 +318,16 @@ discard block |
|
|
block discarded – undo |
|
318
|
318
|
* @param array $parameters |
|
319
|
319
|
* default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null) |
|
320
|
320
|
*/ |
|
321
|
|
- private function _json($url, $method = "get", $parameters = [ ]) { |
|
322
|
|
- $parameters = \array_merge ( $parameters, [ |
|
|
321
|
+ private function _json($url, $method="get", $parameters=[]) { |
|
|
322
|
+ $parameters=\array_merge($parameters, [ |
|
323
|
323
|
"hasLoader" => false |
|
324
|
|
- ] ); |
|
325
|
|
- $jsCallback = isset ( $parameters ['jsCallback'] ) ? $parameters ['jsCallback'] : ""; |
|
326
|
|
- $context = isset ( $parameters ['context'] ) ? $parameters ['context'] : "document"; |
|
327
|
|
- $retour = "\tdata=($.isPlainObject(data))?data:JSON.parse(data);\t" . $jsCallback . ";" . "\n\tfor(var key in data){" . "if($('#'+key," . $context . ").length){ if($('#'+key," . $context . ").is('[value]')) { $('#'+key," . $context . ").val(data[key]);} else { $('#'+key," . $context . ").html(data[key]); }}};\n"; |
|
328
|
|
- $retour .= "\t$(document).trigger('jsonReady',[data]);\n"; |
|
329
|
|
- $parameters ["jsCallback"] = $retour; |
|
330
|
|
- return $this->_ajax ( $method, $url, null, $parameters ); |
|
|
324
|
+ ]); |
|
|
325
|
+ $jsCallback=isset ($parameters ['jsCallback']) ? $parameters ['jsCallback'] : ""; |
|
|
326
|
+ $context=isset ($parameters ['context']) ? $parameters ['context'] : "document"; |
|
|
327
|
+ $retour="\tdata=($.isPlainObject(data))?data:JSON.parse(data);\t".$jsCallback.";"."\n\tfor(var key in data){"."if($('#'+key,".$context.").length){ if($('#'+key,".$context.").is('[value]')) { $('#'+key,".$context.").val(data[key]);} else { $('#'+key,".$context.").html(data[key]); }}};\n"; |
|
|
328
|
+ $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
|
|
329
|
+ $parameters ["jsCallback"]=$retour; |
|
|
330
|
+ return $this->_ajax($method, $url, null, $parameters); |
|
331
|
331
|
} |
|
332
|
332
|
|
|
333
|
333
|
/** |
|
@@ -340,8 +340,8 @@ discard block |
|
|
block discarded – undo |
|
340
|
340
|
* @param array $parameters |
|
341
|
341
|
* default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null) |
|
342
|
342
|
*/ |
|
343
|
|
- public function json($url, $method = "get", $parameters = [ ]) { |
|
344
|
|
- return $this->_json ( $url, $method, $parameters ); |
|
|
343
|
+ public function json($url, $method="get", $parameters=[]) { |
|
|
344
|
+ return $this->_json($url, $method, $parameters); |
|
345
|
345
|
} |
|
346
|
346
|
|
|
347
|
347
|
/** |
|
@@ -356,14 +356,14 @@ discard block |
|
|
block discarded – undo |
|
356
|
356
|
* @param array $parameters |
|
357
|
357
|
* default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true,"before"=>null,"listenerOn"=>false) |
|
358
|
358
|
*/ |
|
359
|
|
- public function jsonOn($event, $element, $url, $method = 'get', $parameters = array ()) { |
|
360
|
|
- $this->setDefaultParameters ( $parameters, [ |
|
|
359
|
+ public function jsonOn($event, $element, $url, $method='get', $parameters=array()) { |
|
|
360
|
+ $this->setDefaultParameters($parameters, [ |
|
361
|
361
|
'preventDefault' => true, |
|
362
|
362
|
'stopPropagation' => true, |
|
363
|
363
|
'immediatly' => true, |
|
364
|
364
|
'listenerOn'=>false |
|
365
|
|
- ] ); |
|
366
|
|
- return $this->_add_event ( $element, $this->jsonDeferred ( $url, $method, $parameters ), $event, $parameters ["preventDefault"], $parameters ["stopPropagation"], $parameters ["immediatly"] ,$parameters['listenerOn']); |
|
|
365
|
+ ]); |
|
|
366
|
+ return $this->_add_event($element, $this->jsonDeferred($url, $method, $parameters), $event, $parameters ["preventDefault"], $parameters ["stopPropagation"], $parameters ["immediatly"], $parameters['listenerOn']); |
|
367
|
367
|
} |
|
368
|
368
|
|
|
369
|
369
|
/** |
|
@@ -376,9 +376,9 @@ discard block |
|
|
block discarded – undo |
|
376
|
376
|
* @param array $parameters |
|
377
|
377
|
* default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>"document","jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"before"=>null) |
|
378
|
378
|
*/ |
|
379
|
|
- public function jsonDeferred($url, $method = 'get', $parameters = [ ]) { |
|
380
|
|
- $parameters ['immediatly'] = false; |
|
381
|
|
- return $this->_json ( $url, $method, $parameters ); |
|
|
379
|
+ public function jsonDeferred($url, $method='get', $parameters=[]) { |
|
|
380
|
+ $parameters ['immediatly']=false; |
|
|
381
|
+ return $this->_json($url, $method, $parameters); |
|
382
|
382
|
} |
|
383
|
383
|
|
|
384
|
384
|
/** |
|
@@ -392,30 +392,30 @@ discard block |
|
|
block discarded – undo |
|
392
|
392
|
* @param array $parameters |
|
393
|
393
|
* default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json","before"=>null) |
|
394
|
394
|
*/ |
|
395
|
|
- private function _jsonArray($maskSelector, $url, $method = 'get', $parameters = [ ]) { |
|
396
|
|
- $parameters = \array_merge ( $parameters, [ |
|
|
395
|
+ private function _jsonArray($maskSelector, $url, $method='get', $parameters=[]) { |
|
|
396
|
+ $parameters=\array_merge($parameters, [ |
|
397
|
397
|
"hasLoader" => false |
|
398
|
|
- ] ); |
|
399
|
|
- $rowClass = isset ( $parameters ['rowClass'] ) ? $parameters ['rowClass'] : "_json"; |
|
400
|
|
- $jsCallback = isset ( $parameters ['jsCallback'] ) ? $parameters ['jsCallback'] : ""; |
|
401
|
|
- $context = isset ( $parameters ['context'] ) ? $parameters ['context'] : null; |
|
402
|
|
- if ($context === null) { |
|
403
|
|
- $parent = "$('" . $maskSelector . "').parent()"; |
|
404
|
|
- $newElm = "$('#'+newId)"; |
|
|
398
|
+ ]); |
|
|
399
|
+ $rowClass=isset ($parameters ['rowClass']) ? $parameters ['rowClass'] : "_json"; |
|
|
400
|
+ $jsCallback=isset ($parameters ['jsCallback']) ? $parameters ['jsCallback'] : ""; |
|
|
401
|
+ $context=isset ($parameters ['context']) ? $parameters ['context'] : null; |
|
|
402
|
+ if ($context===null) { |
|
|
403
|
+ $parent="$('".$maskSelector."').parent()"; |
|
|
404
|
+ $newElm="$('#'+newId)"; |
|
405
|
405
|
} else { |
|
406
|
|
- $parent = $context; |
|
407
|
|
- $newElm = $context . ".find('#'+newId)"; |
|
|
406
|
+ $parent=$context; |
|
|
407
|
+ $newElm=$context.".find('#'+newId)"; |
|
408
|
408
|
} |
|
409
|
|
- $appendTo = "\t\tnewElm.appendTo(" . $parent . ");\n"; |
|
410
|
|
- $retour = $parent . ".find('.{$rowClass}').remove();"; |
|
411
|
|
- $retour .= "\tdata=($.isPlainObject(data)||$.isArray(data))?data:JSON.parse(data);\n$.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(); |
|
|
409
|
+ $appendTo="\t\tnewElm.appendTo(".$parent.");\n"; |
|
|
410
|
+ $retour=$parent.".find('.{$rowClass}').remove();"; |
|
|
411
|
+ $retour.="\tdata=($.isPlainObject(data)||$.isArray(data))?data:JSON.parse(data);\n$.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(); |
|
412
|
412
|
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"; |
|
413
|
|
- $retour .= $appendTo; |
|
414
|
|
- $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"; |
|
415
|
|
- $retour .= "\t$(document).trigger('jsonReady',[data]);\n"; |
|
416
|
|
- $retour .= "\t" . $jsCallback; |
|
417
|
|
- $parameters ["jsCallback"] = $retour; |
|
418
|
|
- return $this->_ajax ( $method, $url, null, $parameters ); |
|
|
413
|
+ $retour.=$appendTo; |
|
|
414
|
+ $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"; |
|
|
415
|
+ $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
|
|
416
|
+ $retour.="\t".$jsCallback; |
|
|
417
|
+ $parameters ["jsCallback"]=$retour; |
|
|
418
|
+ return $this->_ajax($method, $url, null, $parameters); |
|
419
|
419
|
} |
|
420
|
420
|
|
|
421
|
421
|
/** |
|
@@ -429,8 +429,8 @@ discard block |
|
|
block discarded – undo |
|
429
|
429
|
* @param array $parameters |
|
430
|
430
|
* default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"immediatly"=>false,"rowClass"=>"_json","before"=>null) |
|
431
|
431
|
*/ |
|
432
|
|
- public function jsonArray($maskSelector, $url, $method = 'get', $parameters = [ ]) { |
|
433
|
|
- return $this->_jsonArray ( $maskSelector, $url, $method, $parameters ); |
|
|
432
|
+ public function jsonArray($maskSelector, $url, $method='get', $parameters=[]) { |
|
|
433
|
+ return $this->_jsonArray($maskSelector, $url, $method, $parameters); |
|
434
|
434
|
} |
|
435
|
435
|
|
|
436
|
436
|
/** |
|
@@ -444,9 +444,9 @@ discard block |
|
|
block discarded – undo |
|
444
|
444
|
* @param array $parameters |
|
445
|
445
|
* default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","context"=>null,"jsCondition"=>NULL,"headers"=>null,"rowClass"=>"_json","before"=>null) |
|
446
|
446
|
*/ |
|
447
|
|
- public function jsonArrayDeferred($maskSelector, $url, $method = 'get', $parameters = [ ]) { |
|
448
|
|
- $parameters ['immediatly'] = false; |
|
449
|
|
- return $this->jsonArray ( $maskSelector, $url, $method, $parameters ); |
|
|
447
|
+ public function jsonArrayDeferred($maskSelector, $url, $method='get', $parameters=[]) { |
|
|
448
|
+ $parameters ['immediatly']=false; |
|
|
449
|
+ return $this->jsonArray($maskSelector, $url, $method, $parameters); |
|
450
|
450
|
} |
|
451
|
451
|
|
|
452
|
452
|
/** |
|
@@ -461,14 +461,14 @@ discard block |
|
|
block discarded – undo |
|
461
|
461
|
* @param array $parameters |
|
462
|
462
|
* default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true,"before"=>null,"listenerOn"=>false) |
|
463
|
463
|
*/ |
|
464
|
|
- public function jsonArrayOn($event, $element, $maskSelector, $url, $method = 'get', $parameters = array ()) { |
|
465
|
|
- $this->setDefaultParameters ( $parameters, [ |
|
|
464
|
+ public function jsonArrayOn($event, $element, $maskSelector, $url, $method='get', $parameters=array()) { |
|
|
465
|
+ $this->setDefaultParameters($parameters, [ |
|
466
|
466
|
'preventDefault' => true, |
|
467
|
467
|
'stopPropagation' => true, |
|
468
|
468
|
'immediatly' => true, |
|
469
|
469
|
'listenerOn'=>false |
|
470
|
|
- ] ); |
|
471
|
|
- return $this->_add_event ( $element, $this->jsonArrayDeferred ( $maskSelector, $url, $method, $parameters ), $event, $parameters ["preventDefault"], $parameters ["stopPropagation"], $parameters ["immediatly"] ,$parameters['listenerOn']); |
|
|
470
|
+ ]); |
|
|
471
|
+ return $this->_add_event($element, $this->jsonArrayDeferred($maskSelector, $url, $method, $parameters), $event, $parameters ["preventDefault"], $parameters ["stopPropagation"], $parameters ["immediatly"], $parameters['listenerOn']); |
|
472
|
472
|
} |
|
473
|
473
|
|
|
474
|
474
|
/** |
|
@@ -482,9 +482,9 @@ discard block |
|
|
block discarded – undo |
|
482
|
482
|
* @param array $parameters |
|
483
|
483
|
* default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
|
484
|
484
|
*/ |
|
485
|
|
- public function getDeferred($url, $responseElement = "", $parameters = [ ]) { |
|
486
|
|
- $parameters ['immediatly'] = false; |
|
487
|
|
- return $this->_get ( $url, $responseElement, $parameters ); |
|
|
485
|
+ public function getDeferred($url, $responseElement="", $parameters=[]) { |
|
|
486
|
+ $parameters ['immediatly']=false; |
|
|
487
|
+ return $this->_get($url, $responseElement, $parameters); |
|
488
|
488
|
} |
|
489
|
489
|
|
|
490
|
490
|
/** |
|
@@ -502,9 +502,9 @@ discard block |
|
|
block discarded – undo |
|
502
|
502
|
* @param array $parameters |
|
503
|
503
|
* default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
|
504
|
504
|
*/ |
|
505
|
|
- public function getOn($event, $element, $url, $responseElement = "", $parameters = array ()) { |
|
|
505
|
+ public function getOn($event, $element, $url, $responseElement="", $parameters=array()) { |
|
506
|
506
|
$parameters['method']='get'; |
|
507
|
|
- return $this->ajaxOn($event, $element, $url,$responseElement,$parameters); |
|
|
507
|
+ return $this->ajaxOn($event, $element, $url, $responseElement, $parameters); |
|
508
|
508
|
} |
|
509
|
509
|
|
|
510
|
510
|
/** |
|
@@ -522,15 +522,15 @@ discard block |
|
|
block discarded – undo |
|
522
|
522
|
* @param array $parameters |
|
523
|
523
|
* default : array("method"=>"get","preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
|
524
|
524
|
*/ |
|
525
|
|
- public function ajaxOn($event, $element, $url, $responseElement = '', $parameters = array ()) { |
|
526
|
|
- $this->setDefaultParameters ( $parameters, [ |
|
|
525
|
+ public function ajaxOn($event, $element, $url, $responseElement='', $parameters=array()) { |
|
|
526
|
+ $this->setDefaultParameters($parameters, [ |
|
527
|
527
|
'preventDefault' => true, |
|
528
|
528
|
'stopPropagation' => true, |
|
529
|
529
|
'immediatly' => true, |
|
530
|
530
|
'method' => 'get', |
|
531
|
531
|
'listenerOn'=>false |
|
532
|
|
- ] ); |
|
533
|
|
- return $this->_add_event ( $element, $this->ajaxDeferred ( $parameters ['method'], $url, $responseElement, $parameters ), $event, $parameters ["preventDefault"], $parameters ["stopPropagation"], $parameters ["immediatly"],$parameters['listenerOn'] ); |
|
|
532
|
+ ]); |
|
|
533
|
+ return $this->_add_event($element, $this->ajaxDeferred($parameters ['method'], $url, $responseElement, $parameters), $event, $parameters ["preventDefault"], $parameters ["stopPropagation"], $parameters ["immediatly"], $parameters['listenerOn']); |
|
534
|
534
|
} |
|
535
|
535
|
|
|
536
|
536
|
/** |
|
@@ -546,8 +546,8 @@ discard block |
|
|
block discarded – undo |
|
546
|
546
|
* @param array $parameters |
|
547
|
547
|
* default : array("method"=>"get","preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
|
548
|
548
|
*/ |
|
549
|
|
- public function ajaxOnClick($element, $url, $responseElement = '', $parameters = array ()) { |
|
550
|
|
- return $this->ajaxOn ( 'click', $element, $url, $responseElement, $parameters ); |
|
|
549
|
+ public function ajaxOnClick($element, $url, $responseElement='', $parameters=array()) { |
|
|
550
|
+ return $this->ajaxOn('click', $element, $url, $responseElement, $parameters); |
|
551
|
551
|
} |
|
552
|
552
|
|
|
553
|
553
|
/** |
|
@@ -563,8 +563,8 @@ discard block |
|
|
block discarded – undo |
|
563
|
563
|
* @param array $parameters |
|
564
|
564
|
* default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
|
565
|
565
|
*/ |
|
566
|
|
- public function getOnClick($element, $url, $responseElement = '', $parameters = array ()) { |
|
567
|
|
- return $this->getOn ( 'click', $element, $url, $responseElement, $parameters ); |
|
|
566
|
+ public function getOnClick($element, $url, $responseElement='', $parameters=array()) { |
|
|
567
|
+ return $this->getOn('click', $element, $url, $responseElement, $parameters); |
|
568
|
568
|
} |
|
569
|
569
|
|
|
570
|
570
|
/** |
|
@@ -578,17 +578,17 @@ discard block |
|
|
block discarded – undo |
|
578
|
578
|
* default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true,"before"=>null) |
|
579
|
579
|
* @return $this |
|
580
|
580
|
*/ |
|
581
|
|
- public function getHref($element, $responseElement = "", $parameters = array ()) { |
|
582
|
|
- $parameters ['attr'] = 'href'; |
|
583
|
|
- if (JString::isNull ( $responseElement )) { |
|
584
|
|
- $responseElement = '%$(self).attr("data-target")%'; |
|
|
581
|
+ public function getHref($element, $responseElement="", $parameters=array()) { |
|
|
582
|
+ $parameters ['attr']='href'; |
|
|
583
|
+ if (JString::isNull($responseElement)) { |
|
|
584
|
+ $responseElement='%$(self).attr("data-target")%'; |
|
585
|
585
|
} else { |
|
586
|
|
- $responseElement = '%$(self).attr("data-target") || "' . $responseElement . '"%'; |
|
|
586
|
+ $responseElement='%$(self).attr("data-target") || "'.$responseElement.'"%'; |
|
587
|
587
|
} |
|
588
|
|
- if (! isset ( $parameters ['historize'] )) { |
|
589
|
|
- $parameters ['historize'] = true; |
|
|
588
|
+ if (!isset ($parameters ['historize'])) { |
|
|
589
|
+ $parameters ['historize']=true; |
|
590
|
590
|
} |
|
591
|
|
- return $this->getOnClick ( $element, "", $responseElement, $parameters ); |
|
|
591
|
+ return $this->getOnClick($element, "", $responseElement, $parameters); |
|
592
|
592
|
} |
|
593
|
593
|
|
|
594
|
594
|
/** |
|
@@ -602,21 +602,21 @@ discard block |
|
|
block discarded – undo |
|
602
|
602
|
* default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"href","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null,"historize"=>true,"before"=>null) |
|
603
|
603
|
* @return $this |
|
604
|
604
|
*/ |
|
605
|
|
- public function postHref($element, $responseElement = "", $parameters = array ()) { |
|
606
|
|
- $parameters ['attr'] = 'href'; |
|
607
|
|
- if (JString::isNull ( $responseElement )) { |
|
608
|
|
- $responseElement = '%$(this).attr("data-target")%'; |
|
|
605
|
+ public function postHref($element, $responseElement="", $parameters=array()) { |
|
|
606
|
+ $parameters ['attr']='href'; |
|
|
607
|
+ if (JString::isNull($responseElement)) { |
|
|
608
|
+ $responseElement='%$(this).attr("data-target")%'; |
|
609
|
609
|
} else { |
|
610
|
|
- $responseElement = '%$(self).attr("data-target") || "' . $responseElement . '"%'; |
|
|
610
|
+ $responseElement='%$(self).attr("data-target") || "'.$responseElement.'"%'; |
|
611
|
611
|
} |
|
612
|
|
- if (! isset ( $parameters ['historize'] )) { |
|
613
|
|
- $parameters ['historize'] = true; |
|
|
612
|
+ if (!isset ($parameters ['historize'])) { |
|
|
613
|
+ $parameters ['historize']=true; |
|
614
|
614
|
} |
|
615
|
|
- return $this->postOnClick ( $element, '', '{}', $responseElement, $parameters ); |
|
|
615
|
+ return $this->postOnClick($element, '', '{}', $responseElement, $parameters); |
|
616
|
616
|
} |
|
617
|
|
- private function _post($url, $params = '{}', $responseElement = '', $parameters = [ ]) { |
|
618
|
|
- $parameters ['params'] = $params; |
|
619
|
|
- return $this->_ajax ( 'POST', $url, $responseElement, $parameters ); |
|
|
617
|
+ private function _post($url, $params='{}', $responseElement='', $parameters=[]) { |
|
|
618
|
+ $parameters ['params']=$params; |
|
|
619
|
+ return $this->_ajax('POST', $url, $responseElement, $parameters); |
|
620
|
620
|
} |
|
621
|
621
|
|
|
622
|
622
|
/** |
|
@@ -631,9 +631,9 @@ discard block |
|
|
block discarded – undo |
|
631
|
631
|
* @param array $parameters |
|
632
|
632
|
* default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
|
633
|
633
|
*/ |
|
634
|
|
- public function post($url, $params = "{}", $responseElement = "", $parameters = [ ]) { |
|
635
|
|
- $parameters ['immediatly'] = true; |
|
636
|
|
- return $this->_post ( $url, $params, $responseElement, $parameters ); |
|
|
634
|
+ public function post($url, $params="{}", $responseElement="", $parameters=[]) { |
|
|
635
|
+ $parameters ['immediatly']=true; |
|
|
636
|
+ return $this->_post($url, $params, $responseElement, $parameters); |
|
637
|
637
|
} |
|
638
|
638
|
|
|
639
|
639
|
/** |
|
@@ -649,9 +649,9 @@ discard block |
|
|
block discarded – undo |
|
649
|
649
|
* @param array $parameters |
|
650
|
650
|
* default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
|
651
|
651
|
*/ |
|
652
|
|
- public function postDeferred($url, $params = "{}", $responseElement = "", $parameters = [ ]) { |
|
653
|
|
- $parameters ['immediatly'] = false; |
|
654
|
|
- return $this->_post ( $url, $params, $responseElement, $parameters ); |
|
|
652
|
+ public function postDeferred($url, $params="{}", $responseElement="", $parameters=[]) { |
|
|
653
|
+ $parameters ['immediatly']=false; |
|
|
654
|
+ return $this->_post($url, $params, $responseElement, $parameters); |
|
655
|
655
|
} |
|
656
|
656
|
|
|
657
|
657
|
/** |
|
@@ -669,10 +669,10 @@ discard block |
|
|
block discarded – undo |
|
669
|
669
|
* @param array $parameters |
|
670
|
670
|
* default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
|
671
|
671
|
*/ |
|
672
|
|
- public function postOn($event, $element, $url, $params = "{}", $responseElement = "", $parameters = array ()) { |
|
|
672
|
+ public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
673
|
673
|
$parameters['method']='post'; |
|
674
|
|
- $parameters ['params'] = $params; |
|
675
|
|
- return $this->ajaxOn($event, $element, $url,$responseElement,$parameters); |
|
|
674
|
+ $parameters ['params']=$params; |
|
|
675
|
+ return $this->ajaxOn($event, $element, $url, $responseElement, $parameters); |
|
676
|
676
|
} |
|
677
|
677
|
|
|
678
|
678
|
/** |
|
@@ -689,65 +689,65 @@ discard block |
|
|
block discarded – undo |
|
689
|
689
|
* @param array $parameters |
|
690
|
690
|
* default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null,"before"=>null,"listenerOn"=>false) |
|
691
|
691
|
*/ |
|
692
|
|
- public function postOnClick($element, $url, $params = '{}', $responseElement = '', $parameters = array ()) { |
|
693
|
|
- return $this->postOn ( 'click', $element, $url, $params, $responseElement, $parameters ); |
|
694
|
|
- } |
|
695
|
|
- private function _postForm($url, $form, $responseElement, $parameters = [ ]) { |
|
696
|
|
- if (isset ( $this->params ['ajax'] )) { |
|
697
|
|
- extract ( $this->params ['ajax'] ); |
|
698
|
|
- } |
|
699
|
|
- $params = '{}'; |
|
700
|
|
- $validation = false; |
|
701
|
|
- \extract ( $parameters ); |
|
702
|
|
- $async = ($async) ? 'true' : 'false'; |
|
703
|
|
- $jsCallback = isset ( $jsCallback ) ? $jsCallback : ""; |
|
704
|
|
- $retour = $this->_getAjaxUrl ( $url, $attr ); |
|
705
|
|
- $retour .= "\n$('#" . $form . "').trigger('ajaxSubmit');"; |
|
706
|
|
- if (! isset ( $contentType ) || $contentType != 'false') { |
|
707
|
|
- $retour .= "\nvar params=$('#" . $form . "').serialize();\n"; |
|
708
|
|
- if (isset ( $params )) { |
|
709
|
|
- $retour .= "params+='&'+" . self::_correctParams ( $params ) . ";\n"; |
|
|
692
|
+ public function postOnClick($element, $url, $params='{}', $responseElement='', $parameters=array()) { |
|
|
693
|
+ return $this->postOn('click', $element, $url, $params, $responseElement, $parameters); |
|
|
694
|
+ } |
|
|
695
|
+ private function _postForm($url, $form, $responseElement, $parameters=[]) { |
|
|
696
|
+ if (isset ($this->params ['ajax'])) { |
|
|
697
|
+ extract($this->params ['ajax']); |
|
|
698
|
+ } |
|
|
699
|
+ $params='{}'; |
|
|
700
|
+ $validation=false; |
|
|
701
|
+ \extract($parameters); |
|
|
702
|
+ $async=($async) ? 'true' : 'false'; |
|
|
703
|
+ $jsCallback=isset ($jsCallback) ? $jsCallback : ""; |
|
|
704
|
+ $retour=$this->_getAjaxUrl($url, $attr); |
|
|
705
|
+ $retour.="\n$('#".$form."').trigger('ajaxSubmit');"; |
|
|
706
|
+ if (!isset ($contentType) || $contentType!='false') { |
|
|
707
|
+ $retour.="\nvar params=$('#".$form."').serialize();\n"; |
|
|
708
|
+ if (isset ($params)) { |
|
|
709
|
+ $retour.="params+='&'+".self::_correctParams($params).";\n"; |
|
710
|
710
|
} |
|
711
|
711
|
} else { |
|
712
|
|
- $retour .= "\nvar params=new FormData($('#" . $form . "')[0]);\n"; |
|
713
|
|
- } |
|
714
|
|
- $responseElement = $this->_getResponseElement ( $responseElement ); |
|
715
|
|
- $retour .= "var self=this;\n"; |
|
716
|
|
- $before = isset ( $before ) ? $before : ""; |
|
717
|
|
- $retour .= $before; |
|
718
|
|
- if ($hasLoader === true) { |
|
719
|
|
- $this->addLoading ( $retour, $responseElement, $ajaxLoader ); |
|
720
|
|
- } elseif ($hasLoader === 'response') { |
|
721
|
|
- $this->addResponseLoading ( $retour, $responseElement, $ajaxLoader ); |
|
722
|
|
- } elseif ($hasLoader === 'internal') { |
|
723
|
|
- $retour .= "\n$(this).addClass('loading');"; |
|
724
|
|
- } |
|
725
|
|
- $ajaxParameters = [ |
|
|
712
|
+ $retour.="\nvar params=new FormData($('#".$form."')[0]);\n"; |
|
|
713
|
+ } |
|
|
714
|
+ $responseElement=$this->_getResponseElement($responseElement); |
|
|
715
|
+ $retour.="var self=this;\n"; |
|
|
716
|
+ $before=isset ($before) ? $before : ""; |
|
|
717
|
+ $retour.=$before; |
|
|
718
|
+ if ($hasLoader===true) { |
|
|
719
|
+ $this->addLoading($retour, $responseElement, $ajaxLoader); |
|
|
720
|
+ } elseif ($hasLoader==='response') { |
|
|
721
|
+ $this->addResponseLoading($retour, $responseElement, $ajaxLoader); |
|
|
722
|
+ } elseif ($hasLoader==='internal') { |
|
|
723
|
+ $retour.="\n$(this).addClass('loading');"; |
|
|
724
|
+ } |
|
|
725
|
+ $ajaxParameters=[ |
|
726
|
726
|
"url" => "url", |
|
727
|
727
|
"method" => "'POST'", |
|
728
|
728
|
"data" => "params", |
|
729
|
729
|
"async" => $async |
|
730
|
730
|
]; |
|
731
|
|
- if (isset ( $headers )) { |
|
732
|
|
- $ajaxParameters ["headers"] = $headers; |
|
|
731
|
+ if (isset ($headers)) { |
|
|
732
|
+ $ajaxParameters ["headers"]=$headers; |
|
733
|
733
|
} |
|
734
|
|
- if (isset ( $partial )) { |
|
735
|
|
- $ajaxParameters ["xhr"] = "xhrProvider"; |
|
736
|
|
- $retour .= "var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;" . $partial . ";}; };"; |
|
|
734
|
+ if (isset ($partial)) { |
|
|
735
|
+ $ajaxParameters ["xhr"]="xhrProvider"; |
|
|
736
|
+ $retour.="var xhr = $.ajaxSettings.xhr();function xhrProvider() {return xhr;};xhr.onreadystatechange = function (e) { if (3==e.target.readyState){let response=e.target.responseText;".$partial.";}; };"; |
|
737
|
737
|
} |
|
738
|
|
- $this->createAjaxParameters ( $ajaxParameters, $parameters ); |
|
739
|
|
- $retour .= "$.ajax({" . $this->implodeAjaxParameters ( $ajaxParameters ) . "}).done(function( data ) {\n"; |
|
740
|
|
- $retour .= $this->_getOnAjaxDone ( $responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader ) . "});\n"; |
|
|
738
|
+ $this->createAjaxParameters($ajaxParameters, $parameters); |
|
|
739
|
+ $retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data ) {\n"; |
|
|
740
|
+ $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback, $hasLoader)."});\n"; |
|
741
|
741
|
|
|
742
|
742
|
if ($validation) { |
|
743
|
|
- $retour = "$('#" . $form . "').validate({submitHandler: function(form) { |
|
744
|
|
- " . $retour . " |
|
|
743
|
+ $retour="$('#".$form."').validate({submitHandler: function(form) { |
|
|
744
|
+ " . $retour." |
|
745
|
745
|
}});\n"; |
|
746
|
|
- $retour .= "$('#" . $form . "').submit();\n"; |
|
|
746
|
+ $retour.="$('#".$form."').submit();\n"; |
|
747
|
747
|
} |
|
748
|
|
- $retour = $this->_addJsCondition ( $jsCondition, $retour ); |
|
|
748
|
+ $retour=$this->_addJsCondition($jsCondition, $retour); |
|
749
|
749
|
if ($immediatly) |
|
750
|
|
- $this->jquery_code_for_compile [] = $retour; |
|
|
750
|
+ $this->jquery_code_for_compile []=$retour; |
|
751
|
751
|
return $retour; |
|
752
|
752
|
} |
|
753
|
753
|
|
|
@@ -763,9 +763,9 @@ discard block |
|
|
block discarded – undo |
|
763
|
763
|
* @param array $parameters |
|
764
|
764
|
* default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
|
765
|
765
|
*/ |
|
766
|
|
- public function postForm($url, $form, $responseElement, $parameters = [ ]) { |
|
767
|
|
- $parameters ['immediatly'] = true; |
|
768
|
|
- return $this->_postForm ( $url, $form, $responseElement, $parameters ); |
|
|
766
|
+ public function postForm($url, $form, $responseElement, $parameters=[]) { |
|
|
767
|
+ $parameters ['immediatly']=true; |
|
|
768
|
+ return $this->_postForm($url, $form, $responseElement, $parameters); |
|
769
|
769
|
} |
|
770
|
770
|
|
|
771
|
771
|
/** |
|
@@ -781,9 +781,9 @@ discard block |
|
|
block discarded – undo |
|
781
|
781
|
* @param array $parameters |
|
782
|
782
|
* default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null,"historize"=>false,"before"=>null) |
|
783
|
783
|
*/ |
|
784
|
|
- public function postFormDeferred($url, $form, $responseElement, $parameters = [ ]) { |
|
785
|
|
- $parameters ['immediatly'] = false; |
|
786
|
|
- return $this->_postForm ( $url, $form, $responseElement, $parameters ); |
|
|
784
|
+ public function postFormDeferred($url, $form, $responseElement, $parameters=[]) { |
|
|
785
|
+ $parameters ['immediatly']=false; |
|
|
786
|
+ return $this->_postForm($url, $form, $responseElement, $parameters); |
|
787
|
787
|
} |
|
788
|
788
|
|
|
789
|
789
|
/** |
|
@@ -799,14 +799,14 @@ discard block |
|
|
block discarded – undo |
|
799
|
799
|
* @param array $parameters |
|
800
|
800
|
* default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
|
801
|
801
|
*/ |
|
802
|
|
- public function postFormOn($event, $element, $url, $form, $responseElement = "", $parameters = array ()) { |
|
803
|
|
- $this->setDefaultParameters ( $parameters, [ |
|
|
802
|
+ public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
|
803
|
+ $this->setDefaultParameters($parameters, [ |
|
804
|
804
|
'preventDefault' => true, |
|
805
|
805
|
'stopPropagation' => true, |
|
806
|
806
|
'immediatly' => true, |
|
807
|
807
|
'listenerOn'=>false |
|
808
|
|
- ] ); |
|
809
|
|
- return $this->_add_event ( $element, $this->postFormDeferred ( $url, $form, $responseElement, $parameters ), $event, $parameters ["preventDefault"], $parameters ["stopPropagation"], $parameters ["immediatly"] ,$parameters['listenerOn']); |
|
|
808
|
+ ]); |
|
|
809
|
+ return $this->_add_event($element, $this->postFormDeferred($url, $form, $responseElement, $parameters), $event, $parameters ["preventDefault"], $parameters ["stopPropagation"], $parameters ["immediatly"], $parameters['listenerOn']); |
|
810
|
810
|
} |
|
811
|
811
|
|
|
812
|
812
|
/** |
|
@@ -821,11 +821,11 @@ discard block |
|
|
block discarded – undo |
|
821
|
821
|
* @param array $parameters |
|
822
|
822
|
* default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxLoader"=>null,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null,"historize"=>false,"before"=>null,"listenerOn"=>false) |
|
823
|
823
|
*/ |
|
824
|
|
- public function postFormOnClick($element, $url, $form, $responseElement = "", $parameters = array ()) { |
|
825
|
|
- return $this->postFormOn ( "click", $element, $url, $form, $responseElement, $parameters ); |
|
|
824
|
+ public function postFormOnClick($element, $url, $form, $responseElement="", $parameters=array()) { |
|
|
825
|
+ return $this->postFormOn("click", $element, $url, $form, $responseElement, $parameters); |
|
826
|
826
|
} |
|
827
|
827
|
|
|
828
|
|
- public function addCsrf($name='csrf-token'){ |
|
|
828
|
+ public function addCsrf($name='csrf-token') { |
|
829
|
829
|
return " |
|
830
|
830
|
$.ajaxSetup({ |
|
831
|
831
|
beforeSend: function(xhr, settings) { |