@@ -54,8 +54,9 @@ discard block |
||
54 | 54 | $this->params[$key]=$params[$key]; |
55 | 55 | } |
56 | 56 | $this->jsUtils=$jsUtils; |
57 | - if(isset($params["ajaxTransition"])) |
|
58 | - $this->ajaxTransition=$this->setAjaxDataCall($params["ajaxTransition"]); |
|
57 | + if(isset($params["ajaxTransition"])) { |
|
58 | + $this->ajaxTransition=$this->setAjaxDataCall($params["ajaxTransition"]); |
|
59 | + } |
|
59 | 60 | } |
60 | 61 | |
61 | 62 | /** |
@@ -138,10 +139,12 @@ discard block |
||
138 | 139 | if (isset($param)) { |
139 | 140 | $param=Javascript::prep_value($param); |
140 | 141 | $str="$({$element}).{$jQueryCall}({$param});"; |
141 | - } else |
|
142 | - $str="$({$element}).{$jQueryCall}();"; |
|
143 | - if ($immediatly) |
|
144 | - $this->jquery_code_for_compile[]=$str; |
|
142 | + } else { |
|
143 | + $str="$({$element}).{$jQueryCall}();"; |
|
144 | + } |
|
145 | + if ($immediatly) { |
|
146 | + $this->jquery_code_for_compile[]=$str; |
|
147 | + } |
|
145 | 148 | return $str; |
146 | 149 | } |
147 | 150 | /** |
@@ -156,8 +159,9 @@ discard block |
||
156 | 159 | $to=Javascript::prep_element($to); |
157 | 160 | $element=Javascript::prep_element($element); |
158 | 161 | $str="$({$to}).{$jQueryCall}({$element});"; |
159 | - if ($immediatly) |
|
160 | - $this->jquery_code_for_compile[]=$str; |
|
162 | + if ($immediatly) { |
|
163 | + $this->jquery_code_for_compile[]=$str; |
|
164 | + } |
|
161 | 165 | return $str; |
162 | 166 | } |
163 | 167 | |
@@ -213,12 +217,14 @@ discard block |
||
213 | 217 | if ($stopPropagation===true) { |
214 | 218 | $js=Javascript::$stopPropagation.$js; |
215 | 219 | } |
216 | - if (array_search($event, $this->jquery_events)===false) |
|
217 | - $event="\n\t$(".Javascript::prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
|
218 | - else |
|
219 | - $event="\n\t$(".Javascript::prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
|
220 | - if($immediatly) |
|
221 | - $this->jquery_code_for_compile[]=$event; |
|
220 | + if (array_search($event, $this->jquery_events)===false) { |
|
221 | + $event="\n\t$(".Javascript::prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
|
222 | + } else { |
|
223 | + $event="\n\t$(".Javascript::prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
|
224 | + } |
|
225 | + if($immediatly) { |
|
226 | + $this->jquery_code_for_compile[]=$event; |
|
227 | + } |
|
222 | 228 | return $event; |
223 | 229 | } |
224 | 230 | |
@@ -303,7 +309,9 @@ discard block |
||
303 | 309 | } |
304 | 310 | |
305 | 311 | private function minify($input) { |
306 | - if(trim($input) === "") return $input; |
|
312 | + if(trim($input) === "") { |
|
313 | + return $input; |
|
314 | + } |
|
307 | 315 | return preg_replace( |
308 | 316 | array( |
309 | 317 | // Remove comment(s) |
@@ -49,10 +49,12 @@ discard block |
||
49 | 49 | $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
50 | 50 | $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
51 | 51 | } |
52 | - if(\is_array($this->_deleteBehavior)) |
|
53 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
54 | - if(\is_array($this->_editBehavior)) |
|
55 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
52 | + if(\is_array($this->_deleteBehavior)) { |
|
53 | + $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
54 | + } |
|
55 | + if(\is_array($this->_editBehavior)) { |
|
56 | + $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
57 | + } |
|
56 | 58 | return parent::run($js); |
57 | 59 | } |
58 | 60 | |
@@ -103,12 +105,14 @@ discard block |
||
103 | 105 | |
104 | 106 | $table->setRowCount(0, \sizeof($captions)); |
105 | 107 | $table->setHeaderValues($captions); |
106 | - if(isset($this->_compileParts)) |
|
107 | - $table->setCompileParts($this->_compileParts); |
|
108 | + if(isset($this->_compileParts)) { |
|
109 | + $table->setCompileParts($this->_compileParts); |
|
110 | + } |
|
108 | 111 | |
109 | 112 | if(isset($this->_searchField) && isset($js)){ |
110 | - if(isset($this->_urls["refresh"])) |
|
111 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
113 | + if(isset($this->_urls["refresh"])) { |
|
114 | + $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
115 | + } |
|
112 | 116 | } |
113 | 117 | |
114 | 118 | $this->_generateContent($table); |
@@ -133,8 +137,9 @@ discard block |
||
133 | 137 | private function _generateMainCheckbox(&$captions){ |
134 | 138 | $ck=new HtmlCheckbox("main-ck-".$this->identifier,""); |
135 | 139 | $checkedMessageCall=""; |
136 | - if($this->_hasCheckedMessage) |
|
137 | - $checkedMessageCall="updateChecked();"; |
|
140 | + if($this->_hasCheckedMessage) { |
|
141 | + $checkedMessageCall="updateChecked();"; |
|
142 | + } |
|
138 | 143 | $ck->setOnChecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',true);".$checkedMessageCall); |
139 | 144 | $ck->setOnUnchecked("$('#".$this->identifier." [name=%quote%selection[]%quote%]').prop('checked',false);".$checkedMessageCall); |
140 | 145 | \array_unshift($captions, $ck); |
@@ -171,8 +176,9 @@ discard block |
||
171 | 176 | $menu->floatRight(); |
172 | 177 | $menu->setActiveItem($this->_pagination->getPage()-1); |
173 | 178 | $footer->setValues($menu); |
174 | - if(isset($this->_urls["refresh"])) |
|
175 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
179 | + if(isset($this->_urls["refresh"])) { |
|
180 | + $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
181 | + } |
|
176 | 182 | } |
177 | 183 | |
178 | 184 | protected function _getFieldName($index){ |
@@ -215,7 +221,7 @@ discard block |
||
215 | 221 | $hasPart=$table->hasPart($part); |
216 | 222 | if($hasPart){ |
217 | 223 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
218 | - }else{ |
|
224 | + } else{ |
|
219 | 225 | $row=$table->getPart($part)->getRow(0); |
220 | 226 | } |
221 | 227 | $row->mergeCol(); |
@@ -240,7 +246,7 @@ discard block |
||
240 | 246 | $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
241 | 247 | $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
242 | 248 | $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
243 | - }else{ |
|
249 | + } else{ |
|
244 | 250 | $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
245 | 251 | } |
246 | 252 | return $this; |
@@ -296,8 +302,9 @@ discard block |
||
296 | 302 | |
297 | 303 | protected function getTargetSelector() { |
298 | 304 | $result=$this->_targetSelector; |
299 | - if(!isset($result)) |
|
300 | - $result="#".$this->identifier; |
|
305 | + if(!isset($result)) { |
|
306 | + $result="#".$this->identifier; |
|
307 | + } |
|
301 | 308 | return $result; |
302 | 309 | } |
303 | 310 | |
@@ -335,8 +342,9 @@ discard block |
||
335 | 342 | * @param callable $callback |
336 | 343 | */ |
337 | 344 | public function addCountCheckedInToolbar(array $checkedMessage=null,$callback=null){ |
338 | - if(isset($checkedMessage)) |
|
339 | - $this->_checkedMessage=$checkedMessage; |
|
345 | + if(isset($checkedMessage)) { |
|
346 | + $this->_checkedMessage=$checkedMessage; |
|
347 | + } |
|
340 | 348 | $checkedMessage=$this->getCheckedMessage(); |
341 | 349 | $this->_hasCheckboxes=true; |
342 | 350 | $this->_hasCheckedMessage=true; |
@@ -48,8 +48,9 @@ discard block |
||
48 | 48 | } |
49 | 49 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
50 | 50 | $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
51 | - if ($immediatly) |
|
52 | - $this->jquery_code_for_compile[]=$retour; |
|
51 | + if ($immediatly) { |
|
52 | + $this->jquery_code_for_compile[]=$retour; |
|
53 | + } |
|
53 | 54 | return $retour; |
54 | 55 | } |
55 | 56 | |
@@ -67,15 +68,17 @@ discard block |
||
67 | 68 | $url=$this->_correctAjaxUrl($url); |
68 | 69 | $retour="url='".$url."';"; |
69 | 70 | $slash="/"; |
70 | - if(JString::endswith($url, "/")===true) |
|
71 | - $slash=""; |
|
71 | + if(JString::endswith($url, "/")===true) { |
|
72 | + $slash=""; |
|
73 | + } |
|
72 | 74 | if(JString::isNotNull($attr)){ |
73 | - if ($attr==="value") |
|
74 | - $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
75 | - elseif ($attr==="html") |
|
76 | - $retour.="url=url+'".$slash."'+$(this).html();\n"; |
|
77 | - elseif($attr!=null && $attr!=="") |
|
78 | - $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
75 | + if ($attr==="value") { |
|
76 | + $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
77 | + } elseif ($attr==="html") { |
|
78 | + $retour.="url=url+'".$slash."'+$(this).html();\n"; |
|
79 | + } elseif($attr!=null && $attr!=="") { |
|
80 | + $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
81 | + } |
|
79 | 82 | } |
80 | 83 | return $retour; |
81 | 84 | } |
@@ -85,13 +88,14 @@ discard block |
||
85 | 88 | if ($responseElement!=="") { |
86 | 89 | if(isset($ajaxTransition)){ |
87 | 90 | $call=$this->setAjaxDataCall($ajaxTransition); |
88 | - }elseif(isset($this->ajaxTransition)){ |
|
91 | + } elseif(isset($this->ajaxTransition)){ |
|
89 | 92 | $call=$this->ajaxTransition; |
90 | 93 | } |
91 | - if(\is_callable($call)) |
|
92 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
93 | - else |
|
94 | - $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
|
94 | + if(\is_callable($call)) { |
|
95 | + $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
96 | + } else { |
|
97 | + $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
|
98 | + } |
|
95 | 99 | } |
96 | 100 | $retour.="\t".$jsCallback."\n"; |
97 | 101 | return $retour; |
@@ -105,8 +109,9 @@ discard block |
||
105 | 109 | } |
106 | 110 | |
107 | 111 | protected function _correctAjaxUrl($url) { |
108 | - if ($url!=="/" && JString::endsWith($url, "/")===true) |
|
109 | - $url=substr($url, 0, strlen($url)-1); |
|
112 | + if ($url!=="/" && JString::endsWith($url, "/")===true) { |
|
113 | + $url=substr($url, 0, strlen($url)-1); |
|
114 | + } |
|
110 | 115 | if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
111 | 116 | $url=$this->jsUtils->getUrl($url); |
112 | 117 | } |
@@ -130,8 +135,9 @@ discard block |
||
130 | 135 | $retour.="\t".$jsCallback."\n". |
131 | 136 | "\t$(document).trigger('jsonReady',[data]);\n". |
132 | 137 | "});\n"; |
133 | - if ($immediatly) |
|
134 | - $this->jquery_code_for_compile[]=$retour; |
|
138 | + if ($immediatly) { |
|
139 | + $this->jquery_code_for_compile[]=$retour; |
|
140 | + } |
|
135 | 141 | return $retour; |
136 | 142 | } |
137 | 143 | |
@@ -170,7 +176,7 @@ discard block |
||
170 | 176 | if($context===null){ |
171 | 177 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
172 | 178 | $newElm = "$('#'+newId)"; |
173 | - }else{ |
|
179 | + } else{ |
|
174 | 180 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
175 | 181 | $newElm = $context.".find('#'+newId)"; |
176 | 182 | } |
@@ -180,8 +186,9 @@ discard block |
||
180 | 186 | $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"; |
181 | 187 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
182 | 188 | $retour.="\t".$jsCallback."\n"."});\n"; |
183 | - if ($immediatly) |
|
184 | - $this->jquery_code_for_compile[]=$retour; |
|
189 | + if ($immediatly) { |
|
190 | + $this->jquery_code_for_compile[]=$retour; |
|
191 | + } |
|
185 | 192 | return $retour; |
186 | 193 | } |
187 | 194 | /** |
@@ -222,8 +229,9 @@ discard block |
||
222 | 229 | }});\n"; |
223 | 230 | $retour.="$('#".$form."').submit();\n"; |
224 | 231 | } |
225 | - if ($immediatly) |
|
226 | - $this->jquery_code_for_compile[]=$retour; |
|
232 | + if ($immediatly) { |
|
233 | + $this->jquery_code_for_compile[]=$retour; |
|
234 | + } |
|
227 | 235 | return $retour; |
228 | 236 | } |
229 | 237 |