@@ -420,8 +420,9 @@ discard block |
||
| 420 | 420 | $element=$this->_prep_element($element); |
| 421 | 421 | $value=$this->_prep_value($value); |
| 422 | 422 | $str="$({$element}).after({$value});"; |
| 423 | - if ($immediatly) |
|
| 424 | - $this->jquery_code_for_compile[]=$str; |
|
| 423 | + if ($immediatly) { |
|
| 424 | + $this->jquery_code_for_compile[]=$str; |
|
| 425 | + } |
|
| 425 | 426 | return $str; |
| 426 | 427 | } |
| 427 | 428 | |
@@ -437,10 +438,12 @@ discard block |
||
| 437 | 438 | if (isset($value)) { |
| 438 | 439 | $value=$this->_prep_value($value); |
| 439 | 440 | $str="$({$element}).attr(\"$attributeName\",{$value});"; |
| 440 | - } else |
|
| 441 | - $str="$({$element}).attr(\"$attributeName\");"; |
|
| 442 | - if ($immediatly) |
|
| 443 | - $this->jquery_code_for_compile[]=$str; |
|
| 441 | + } else { |
|
| 442 | + $str="$({$element}).attr(\"$attributeName\");"; |
|
| 443 | + } |
|
| 444 | + if ($immediatly) { |
|
| 445 | + $this->jquery_code_for_compile[]=$str; |
|
| 446 | + } |
|
| 444 | 447 | return $str; |
| 445 | 448 | } |
| 446 | 449 | |
@@ -456,10 +459,12 @@ discard block |
||
| 456 | 459 | if (isset($param)) { |
| 457 | 460 | $param=$this->_prep_value($param); |
| 458 | 461 | $str="$({$element}).{$jQueryCall}({$param});"; |
| 459 | - } else |
|
| 460 | - $str="$({$element}).{$jQueryCall}();"; |
|
| 461 | - if ($immediatly) |
|
| 462 | - $this->jquery_code_for_compile[]=$str; |
|
| 462 | + } else { |
|
| 463 | + $str="$({$element}).{$jQueryCall}();"; |
|
| 464 | + } |
|
| 465 | + if ($immediatly) { |
|
| 466 | + $this->jquery_code_for_compile[]=$str; |
|
| 467 | + } |
|
| 463 | 468 | return $str; |
| 464 | 469 | } |
| 465 | 470 | /** |
@@ -474,8 +479,9 @@ discard block |
||
| 474 | 479 | $to=$this->_prep_element($to); |
| 475 | 480 | $element=$this->_prep_element($element); |
| 476 | 481 | $str="$({$to}).{$jQueryCall}({$element});"; |
| 477 | - if ($immediatly) |
|
| 478 | - $this->jquery_code_for_compile[]=$str; |
|
| 482 | + if ($immediatly) { |
|
| 483 | + $this->jquery_code_for_compile[]=$str; |
|
| 484 | + } |
|
| 479 | 485 | return $str; |
| 480 | 486 | } |
| 481 | 487 | // -------------------------------------------------------------------- |
@@ -512,8 +518,9 @@ discard block |
||
| 512 | 518 | |
| 513 | 519 | $str="$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");"; |
| 514 | 520 | |
| 515 | - if ($immediatly) |
|
| 516 | - $this->jquery_code_for_compile[]=$str; |
|
| 521 | + if ($immediatly) { |
|
| 522 | + $this->jquery_code_for_compile[]=$str; |
|
| 523 | + } |
|
| 517 | 524 | return $str; |
| 518 | 525 | } |
| 519 | 526 | |
@@ -538,8 +545,9 @@ discard block |
||
| 538 | 545 | |
| 539 | 546 | $str="$({$element}).fadeIn({$speed}{$callback});"; |
| 540 | 547 | |
| 541 | - if ($immediatly) |
|
| 542 | - $this->jquery_code_for_compile[]=$str; |
|
| 548 | + if ($immediatly) { |
|
| 549 | + $this->jquery_code_for_compile[]=$str; |
|
| 550 | + } |
|
| 543 | 551 | return $str; |
| 544 | 552 | } |
| 545 | 553 | |
@@ -564,8 +572,9 @@ discard block |
||
| 564 | 572 | |
| 565 | 573 | $str="$({$element}).fadeOut({$speed}{$callback});"; |
| 566 | 574 | |
| 567 | - if ($immediatly) |
|
| 568 | - $this->jquery_code_for_compile[]=$str; |
|
| 575 | + if ($immediatly) { |
|
| 576 | + $this->jquery_code_for_compile[]=$str; |
|
| 577 | + } |
|
| 569 | 578 | return $str; |
| 570 | 579 | } |
| 571 | 580 | |
@@ -590,8 +599,9 @@ discard block |
||
| 590 | 599 | |
| 591 | 600 | $str="$({$element}).hide({$speed}{$callback});"; |
| 592 | 601 | |
| 593 | - if ($immediatly) |
|
| 594 | - $this->jquery_code_for_compile[]=$str; |
|
| 602 | + if ($immediatly) { |
|
| 603 | + $this->jquery_code_for_compile[]=$str; |
|
| 604 | + } |
|
| 595 | 605 | return $str; |
| 596 | 606 | } |
| 597 | 607 | |
@@ -618,8 +628,9 @@ discard block |
||
| 618 | 628 | |
| 619 | 629 | $str="$({$element}).slideUp({$speed}{$callback});"; |
| 620 | 630 | |
| 621 | - if ($immediatly) |
|
| 622 | - $this->jquery_code_for_compile[]=$str; |
|
| 631 | + if ($immediatly) { |
|
| 632 | + $this->jquery_code_for_compile[]=$str; |
|
| 633 | + } |
|
| 623 | 634 | return $str; |
| 624 | 635 | } |
| 625 | 636 | |
@@ -644,8 +655,9 @@ discard block |
||
| 644 | 655 | |
| 645 | 656 | $str="$({$element}).slideDown({$speed}{$callback});"; |
| 646 | 657 | |
| 647 | - if ($immediatly) |
|
| 648 | - $this->jquery_code_for_compile[]=$str; |
|
| 658 | + if ($immediatly) { |
|
| 659 | + $this->jquery_code_for_compile[]=$str; |
|
| 660 | + } |
|
| 649 | 661 | return $str; |
| 650 | 662 | } |
| 651 | 663 | |
@@ -670,8 +682,9 @@ discard block |
||
| 670 | 682 | |
| 671 | 683 | $str="$({$element}).slideToggle({$speed}{$callback});"; |
| 672 | 684 | |
| 673 | - if ($immediatly) |
|
| 674 | - $this->jquery_code_for_compile[]=$str; |
|
| 685 | + if ($immediatly) { |
|
| 686 | + $this->jquery_code_for_compile[]=$str; |
|
| 687 | + } |
|
| 675 | 688 | return $str; |
| 676 | 689 | } |
| 677 | 690 | |
@@ -688,8 +701,9 @@ discard block |
||
| 688 | 701 | $element=$this->_prep_element($element); |
| 689 | 702 | $str="$({$element}).toggle();"; |
| 690 | 703 | |
| 691 | - if ($immediatly) |
|
| 692 | - $this->jquery_code_for_compile[]=$str; |
|
| 704 | + if ($immediatly) { |
|
| 705 | + $this->jquery_code_for_compile[]=$str; |
|
| 706 | + } |
|
| 693 | 707 | return $str; |
| 694 | 708 | } |
| 695 | 709 | |
@@ -705,8 +719,9 @@ discard block |
||
| 705 | 719 | $element=$this->_prep_element($element); |
| 706 | 720 | $str="$({$element}).trigger(\"$event\");"; |
| 707 | 721 | |
| 708 | - if ($immediatly) |
|
| 709 | - $this->jquery_code_for_compile[]=$str; |
|
| 722 | + if ($immediatly) { |
|
| 723 | + $this->jquery_code_for_compile[]=$str; |
|
| 724 | + } |
|
| 710 | 725 | return $str; |
| 711 | 726 | } |
| 712 | 727 | |
@@ -731,8 +746,9 @@ discard block |
||
| 731 | 746 | |
| 732 | 747 | $str="$({$element}).show({$speed}{$callback});"; |
| 733 | 748 | |
| 734 | - if ($immediatly) |
|
| 735 | - $this->jquery_code_for_compile[]=$str; |
|
| 749 | + if ($immediatly) { |
|
| 750 | + $this->jquery_code_for_compile[]=$str; |
|
| 751 | + } |
|
| 736 | 752 | return $str; |
| 737 | 753 | } |
| 738 | 754 | |
@@ -750,8 +766,9 @@ discard block |
||
| 750 | 766 | $str.="else{".$jsCodeIfFalse."}"; |
| 751 | 767 | } |
| 752 | 768 | |
| 753 | - if ($immediatly) |
|
| 754 | - $this->jquery_code_for_compile[]=$str; |
|
| 769 | + if ($immediatly) { |
|
| 770 | + $this->jquery_code_for_compile[]=$str; |
|
| 771 | + } |
|
| 755 | 772 | return $str; |
| 756 | 773 | } |
| 757 | 774 | |
@@ -817,12 +834,14 @@ discard block |
||
| 817 | 834 | if ($stopPropagation===true) { |
| 818 | 835 | $js="event.stopPropagation();\n".$js; |
| 819 | 836 | } |
| 820 | - if (array_search($event, $this->jquery_events)===false) |
|
| 821 | - $event="\n\t$(".$this->_prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
|
| 822 | - else |
|
| 823 | - $event="\n\t$(".$this->_prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
|
| 824 | - if($immediatly) |
|
| 825 | - $this->jquery_code_for_compile[]=$event; |
|
| 837 | + if (array_search($event, $this->jquery_events)===false) { |
|
| 838 | + $event="\n\t$(".$this->_prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
|
| 839 | + } else { |
|
| 840 | + $event="\n\t$(".$this->_prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
|
| 841 | + } |
|
| 842 | + if($immediatly) { |
|
| 843 | + $this->jquery_code_for_compile[]=$event; |
|
| 844 | + } |
|
| 826 | 845 | return $event; |
| 827 | 846 | } |
| 828 | 847 | |
@@ -871,8 +890,9 @@ discard block |
||
| 871 | 890 | |
| 872 | 891 | $output=($script_tags===FALSE) ? $script : $this->inline($script); |
| 873 | 892 | |
| 874 | - if ($view!=NULL) |
|
| 875 | - $view->setVar($view_var, $output); |
|
| 893 | + if ($view!=NULL) { |
|
| 894 | + $view->setVar($view_var, $output); |
|
| 895 | + } |
|
| 876 | 896 | return $output; |
| 877 | 897 | } |
| 878 | 898 | |
@@ -995,8 +1015,9 @@ discard block |
||
| 995 | 1015 | } |
| 996 | 1016 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
| 997 | 1017 | $retour.=$this->_getOnAjaxDone($responseElement, $jsCallback)."});\n"; |
| 998 | - if ($immediatly) |
|
| 999 | - $this->jquery_code_for_compile[]=$retour; |
|
| 1018 | + if ($immediatly) { |
|
| 1019 | + $this->jquery_code_for_compile[]=$retour; |
|
| 1020 | + } |
|
| 1000 | 1021 | return $retour; |
| 1001 | 1022 | } |
| 1002 | 1023 | |
@@ -1004,13 +1025,15 @@ discard block |
||
| 1004 | 1025 | $url=$this->_correctAjaxUrl($url); |
| 1005 | 1026 | $retour="url='".$url."';\n"; |
| 1006 | 1027 | $slash="/"; |
| 1007 | - if(PhalconUtils::endsWith($url, "/")) |
|
| 1008 | - $slash=""; |
|
| 1028 | + if(PhalconUtils::endsWith($url, "/")) { |
|
| 1029 | + $slash=""; |
|
| 1030 | + } |
|
| 1009 | 1031 | if(JString::isNotNull($attr)){ |
| 1010 | - if ($attr=="value") |
|
| 1011 | - $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
| 1012 | - else if($attr!=null && $attr!=="") |
|
| 1013 | - $retour.="url=url+'".$slash."'+$(this).attr('".$attr."');\n"; |
|
| 1032 | + if ($attr=="value") { |
|
| 1033 | + $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
| 1034 | + } else if($attr!=null && $attr!=="") { |
|
| 1035 | + $retour.="url=url+'".$slash."'+$(this).attr('".$attr."');\n"; |
|
| 1036 | + } |
|
| 1014 | 1037 | } |
| 1015 | 1038 | return $retour; |
| 1016 | 1039 | } |
@@ -1032,8 +1055,9 @@ discard block |
||
| 1032 | 1055 | } |
| 1033 | 1056 | |
| 1034 | 1057 | protected function _correctAjaxUrl($url) { |
| 1035 | - if (PhalconUtils::endsWith($url, "/")) |
|
| 1036 | - $url=substr($url, 0, strlen($url)-1); |
|
| 1058 | + if (PhalconUtils::endsWith($url, "/")) { |
|
| 1059 | + $url=substr($url, 0, strlen($url)-1); |
|
| 1060 | + } |
|
| 1037 | 1061 | if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
| 1038 | 1062 | $url=$this->_di->get("url")->get($url); |
| 1039 | 1063 | } |
@@ -1057,8 +1081,9 @@ discard block |
||
| 1057 | 1081 | $retour.="\t".$jsCallback."\n". |
| 1058 | 1082 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 1059 | 1083 | "});\n"; |
| 1060 | - if ($immediatly) |
|
| 1061 | - $this->jquery_code_for_compile[]=$retour; |
|
| 1084 | + if ($immediatly) { |
|
| 1085 | + $this->jquery_code_for_compile[]=$retour; |
|
| 1086 | + } |
|
| 1062 | 1087 | return $retour; |
| 1063 | 1088 | } |
| 1064 | 1089 | |
@@ -1097,7 +1122,7 @@ discard block |
||
| 1097 | 1122 | if($context===null){ |
| 1098 | 1123 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
| 1099 | 1124 | $newElm = "$('#'+newId)"; |
| 1100 | - }else{ |
|
| 1125 | + } else{ |
|
| 1101 | 1126 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
| 1102 | 1127 | $newElm = $context.".find('#'+newId)"; |
| 1103 | 1128 | } |
@@ -1107,8 +1132,9 @@ discard block |
||
| 1107 | 1132 | $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"; |
| 1108 | 1133 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 1109 | 1134 | $retour.="\t".$jsCallback."\n"."});\n"; |
| 1110 | - if ($immediatly) |
|
| 1111 | - $this->jquery_code_for_compile[]=$retour; |
|
| 1135 | + if ($immediatly) { |
|
| 1136 | + $this->jquery_code_for_compile[]=$retour; |
|
| 1137 | + } |
|
| 1112 | 1138 | return $retour; |
| 1113 | 1139 | } |
| 1114 | 1140 | /** |
@@ -1149,8 +1175,9 @@ discard block |
||
| 1149 | 1175 | }});\n"; |
| 1150 | 1176 | $retour.="$('#".$form."').submit();\n"; |
| 1151 | 1177 | } |
| 1152 | - if ($immediatly) |
|
| 1153 | - $this->jquery_code_for_compile[]=$retour; |
|
| 1178 | + if ($immediatly) { |
|
| 1179 | + $this->jquery_code_for_compile[]=$retour; |
|
| 1180 | + } |
|
| 1154 | 1181 | return $retour; |
| 1155 | 1182 | } |
| 1156 | 1183 | |
@@ -1230,11 +1257,13 @@ discard block |
||
| 1230 | 1257 | public function _doJQuery($element, $jqueryCall, $param="", $jsCallback="", $immediatly=false) { |
| 1231 | 1258 | $param=$this->_prep_value($param); |
| 1232 | 1259 | $callback=""; |
| 1233 | - if ($jsCallback!="") |
|
| 1234 | - $callback=", function(event){\n{$jsCallback}\n}"; |
|
| 1260 | + if ($jsCallback!="") { |
|
| 1261 | + $callback=", function(event){\n{$jsCallback}\n}"; |
|
| 1262 | + } |
|
| 1235 | 1263 | $script="$(".$this->_prep_element($element).").".$jqueryCall."(".$param.$callback.");\n"; |
| 1236 | - if ($immediatly) |
|
| 1237 | - $this->jquery_code_for_compile[]=$script; |
|
| 1264 | + if ($immediatly) { |
|
| 1265 | + $this->jquery_code_for_compile[]=$script; |
|
| 1266 | + } |
|
| 1238 | 1267 | return $script; |
| 1239 | 1268 | } |
| 1240 | 1269 | |
@@ -1263,8 +1292,9 @@ discard block |
||
| 1263 | 1292 | */ |
| 1264 | 1293 | public function _exec($js, $immediatly=false) { |
| 1265 | 1294 | $script=$js."\n"; |
| 1266 | - if ($immediatly) |
|
| 1267 | - $this->jquery_code_for_compile[]=$script; |
|
| 1295 | + if ($immediatly) { |
|
| 1296 | + $this->jquery_code_for_compile[]=$script; |
|
| 1297 | + } |
|
| 1268 | 1298 | return $script; |
| 1269 | 1299 | } |
| 1270 | 1300 | |