@@ -21,14 +21,14 @@ discard block |
||
| 21 | 21 | protected $_bootstrap; |
| 22 | 22 | protected $libraryFile; |
| 23 | 23 | protected $_javascript_folder='js'; |
| 24 | - protected $jquery_code_for_load=array (); |
|
| 25 | - protected $jquery_code_for_compile=array (); |
|
| 24 | + protected $jquery_code_for_load=array(); |
|
| 25 | + protected $jquery_code_for_compile=array(); |
|
| 26 | 26 | protected $jquery_corner_active=FALSE; |
| 27 | 27 | protected $jquery_table_sorter_active=FALSE; |
| 28 | 28 | protected $jquery_table_sorter_pager_active=FALSE; |
| 29 | 29 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
| 30 | - protected $jquery_events=array ( |
|
| 31 | - "bind","blur","change","click","dblclick","delegate","die","error","focus","focusin","focusout","hover","keydown","keypress","keyup","live","load","mousedown","mousseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","off","on","one","ready","resize","scroll","select","submit","toggle","trigger","triggerHandler","undind","undelegate","unload" |
|
| 30 | + protected $jquery_events=array( |
|
| 31 | + "bind", "blur", "change", "click", "dblclick", "delegate", "die", "error", "focus", "focusin", "focusout", "hover", "keydown", "keypress", "keyup", "live", "load", "mousedown", "mousseenter", "mouseleave", "mousemove", "mouseout", "mouseover", "mouseup", "off", "on", "one", "ready", "resize", "scroll", "select", "submit", "toggle", "trigger", "triggerHandler", "undind", "undelegate", "unload" |
|
| 32 | 32 | ); |
| 33 | 33 | |
| 34 | 34 | public function setDi($di) { |
@@ -161,7 +161,7 @@ discard block |
||
| 161 | 161 | */ |
| 162 | 162 | public function _click($element='this', $js=array(), $ret_false=TRUE) { |
| 163 | 163 | if (!is_array($js)) { |
| 164 | - $js=array ( |
|
| 164 | + $js=array( |
|
| 165 | 165 | $js |
| 166 | 166 | ); |
| 167 | 167 | } |
@@ -356,12 +356,12 @@ discard block |
||
| 356 | 356 | */ |
| 357 | 357 | public function _output($array_js='') { |
| 358 | 358 | if (!is_array($array_js)) { |
| 359 | - $array_js=array ( |
|
| 359 | + $array_js=array( |
|
| 360 | 360 | $array_js |
| 361 | 361 | ); |
| 362 | 362 | } |
| 363 | 363 | |
| 364 | - foreach ( $array_js as $js ) { |
|
| 364 | + foreach ($array_js as $js) { |
|
| 365 | 365 | $this->jquery_code_for_compile[]="\t$js\n"; |
| 366 | 366 | } |
| 367 | 367 | } |
@@ -416,7 +416,7 @@ discard block |
||
| 416 | 416 | * @param boolean $immediatly defers the execution if set to false |
| 417 | 417 | * @return string |
| 418 | 418 | */ |
| 419 | - public function after($element='this', $value='', $immediatly=false){ |
|
| 419 | + public function after($element='this', $value='', $immediatly=false) { |
|
| 420 | 420 | $element=$this->_prep_element($element); |
| 421 | 421 | $value=$this->_prep_value($value); |
| 422 | 422 | $str="$({$element}).after({$value});"; |
@@ -437,7 +437,7 @@ discard block |
||
| 437 | 437 | if (isset($value)) { |
| 438 | 438 | $value=$this->_prep_value($value); |
| 439 | 439 | $str="$({$element}).attr(\"$attributeName\",{$value});"; |
| 440 | - } else |
|
| 440 | + }else |
|
| 441 | 441 | $str="$({$element}).attr(\"$attributeName\");"; |
| 442 | 442 | if ($immediatly) |
| 443 | 443 | $this->jquery_code_for_compile[]=$str; |
@@ -451,12 +451,12 @@ discard block |
||
| 451 | 451 | * @param string $param |
| 452 | 452 | * @param boolean $immediatly delayed if false |
| 453 | 453 | */ |
| 454 | - public function _genericCallValue($jQueryCall,$element='this', $param="", $immediatly=false) { |
|
| 454 | + public function _genericCallValue($jQueryCall, $element='this', $param="", $immediatly=false) { |
|
| 455 | 455 | $element=$this->_prep_element($element); |
| 456 | 456 | if (isset($param)) { |
| 457 | 457 | $param=$this->_prep_value($param); |
| 458 | 458 | $str="$({$element}).{$jQueryCall}({$param});"; |
| 459 | - } else |
|
| 459 | + }else |
|
| 460 | 460 | $str="$({$element}).{$jQueryCall}();"; |
| 461 | 461 | if ($immediatly) |
| 462 | 462 | $this->jquery_code_for_compile[]=$str; |
@@ -470,7 +470,7 @@ discard block |
||
| 470 | 470 | * @param boolean $immediatly delayed if false |
| 471 | 471 | * @return string |
| 472 | 472 | */ |
| 473 | - public function _genericCallElement($jQueryCall,$to='this', $element, $immediatly=false) { |
|
| 473 | + public function _genericCallElement($jQueryCall, $to='this', $element, $immediatly=false) { |
|
| 474 | 474 | $to=$this->_prep_element($to); |
| 475 | 475 | $element=$this->_prep_element($element); |
| 476 | 476 | $str="$({$to}).{$jQueryCall}({$element});"; |
@@ -496,7 +496,7 @@ discard block |
||
| 496 | 496 | |
| 497 | 497 | $animations="\t\t\t"; |
| 498 | 498 | if (is_array($params)) { |
| 499 | - foreach ( $params as $param => $value ) { |
|
| 499 | + foreach ($params as $param => $value) { |
|
| 500 | 500 | $animations.=$param.': \''.$value.'\', '; |
| 501 | 501 | } |
| 502 | 502 | } |
@@ -768,12 +768,12 @@ discard block |
||
| 768 | 768 | */ |
| 769 | 769 | public function sortable($element, $options=array()) { |
| 770 | 770 | if (count($options)>0) { |
| 771 | - $sort_options=array (); |
|
| 772 | - foreach ( $options as $k => $v ) { |
|
| 771 | + $sort_options=array(); |
|
| 772 | + foreach ($options as $k => $v) { |
|
| 773 | 773 | $sort_options[]="\n\t\t".$k.': '.$v.""; |
| 774 | 774 | } |
| 775 | 775 | $sort_options=implode(",", $sort_options); |
| 776 | - } else { |
|
| 776 | + }else { |
|
| 777 | 777 | $sort_options=''; |
| 778 | 778 | } |
| 779 | 779 | |
@@ -807,7 +807,7 @@ discard block |
||
| 807 | 807 | * @param boolean $stopPropagation Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. |
| 808 | 808 | * @return string |
| 809 | 809 | */ |
| 810 | - public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true) { |
|
| 810 | + public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true) { |
|
| 811 | 811 | if (is_array($js)) { |
| 812 | 812 | $js=implode("\n\t\t", $js); |
| 813 | 813 | } |
@@ -821,7 +821,7 @@ discard block |
||
| 821 | 821 | $event="\n\t$(".$this->_prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
| 822 | 822 | else |
| 823 | 823 | $event="\n\t$(".$this->_prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
| 824 | - if($immediatly) |
|
| 824 | + if ($immediatly) |
|
| 825 | 825 | $this->jquery_code_for_compile[]=$event; |
| 826 | 826 | return $event; |
| 827 | 827 | } |
@@ -855,7 +855,7 @@ discard block |
||
| 855 | 855 | |
| 856 | 856 | // External references |
| 857 | 857 | $external_scripts=implode('', $this->jquery_code_for_load); |
| 858 | - extract(array ( |
|
| 858 | + extract(array( |
|
| 859 | 859 | 'library_src' => $external_scripts |
| 860 | 860 | )); |
| 861 | 861 | |
@@ -888,7 +888,7 @@ discard block |
||
| 888 | 888 | * @return void |
| 889 | 889 | */ |
| 890 | 890 | public function _clear_compile() { |
| 891 | - $this->jquery_code_for_compile=array (); |
|
| 891 | + $this->jquery_code_for_compile=array(); |
|
| 892 | 892 | } |
| 893 | 893 | |
| 894 | 894 | // -------------------------------------------------------------------- |
@@ -900,12 +900,12 @@ discard block |
||
| 900 | 900 | */ |
| 901 | 901 | public function _document_ready($js) { |
| 902 | 902 | if (!is_array($js)) { |
| 903 | - $js=array ( |
|
| 903 | + $js=array( |
|
| 904 | 904 | $js |
| 905 | 905 | ); |
| 906 | 906 | } |
| 907 | 907 | |
| 908 | - foreach ( $js as $script ) { |
|
| 908 | + foreach ($js as $script) { |
|
| 909 | 909 | $this->jquery_code_for_compile[]=$script; |
| 910 | 910 | } |
| 911 | 911 | } |
@@ -921,7 +921,7 @@ discard block |
||
| 921 | 921 | * @return string |
| 922 | 922 | */ |
| 923 | 923 | public function _prep_element($element) { |
| 924 | - if (strrpos($element, 'this')===false&&strrpos($element, 'event')===false&&strrpos($element, 'self')===false) { |
|
| 924 | + if (strrpos($element, 'this')===false && strrpos($element, 'event')===false && strrpos($element, 'self')===false) { |
|
| 925 | 925 | $element='"'.addslashes($element).'"'; |
| 926 | 926 | } |
| 927 | 927 | return $element; |
@@ -939,7 +939,7 @@ discard block |
||
| 939 | 939 | if (is_array($value)) { |
| 940 | 940 | $value=implode(",", $value); |
| 941 | 941 | } |
| 942 | - if (strrpos($value, 'this')===false&&strrpos($value, 'event')===false&&strrpos($value, 'self')===false) { |
|
| 942 | + if (strrpos($value, 'this')===false && strrpos($value, 'event')===false && strrpos($value, 'self')===false) { |
|
| 943 | 943 | $value='"'.$value.'"'; |
| 944 | 944 | } |
| 945 | 945 | return $value; |
@@ -954,8 +954,8 @@ discard block |
||
| 954 | 954 | * @return string |
| 955 | 955 | */ |
| 956 | 956 | private function _validate_speed($speed) { |
| 957 | - if (in_array($speed, array ( |
|
| 958 | - 'slow','normal','fast' |
|
| 957 | + if (in_array($speed, array( |
|
| 958 | + 'slow', 'normal', 'fast' |
|
| 959 | 959 | ))) { |
| 960 | 960 | $speed='"'.$speed.'"'; |
| 961 | 961 | } elseif (preg_match("/[^0-9]/", $speed)) { |
@@ -969,7 +969,7 @@ discard block |
||
| 969 | 969 | $loading_notifier='<div class="ajax-loader">'; |
| 970 | 970 | if ($this->ajaxLoader=='') { |
| 971 | 971 | $loading_notifier.="Loading..."; |
| 972 | - } else { |
|
| 972 | + }else { |
|
| 973 | 973 | $loading_notifier.=$this->ajaxLoader; |
| 974 | 974 | } |
| 975 | 975 | $loading_notifier.='</div>'; |
@@ -977,20 +977,20 @@ discard block |
||
| 977 | 977 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
| 978 | 978 | } |
| 979 | 979 | |
| 980 | - public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 981 | - return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
| 980 | + public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 981 | + return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
| 982 | 982 | } |
| 983 | - public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 984 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
| 983 | + public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 984 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
| 985 | 985 | } |
| 986 | 986 | |
| 987 | - protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 988 | - if(JString::isNull($params)){$params="{}";} |
|
| 987 | + protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 988 | + if (JString::isNull($params)) {$params="{}"; } |
|
| 989 | 989 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 990 | 990 | $retour=$this->_getAjaxUrl($url, $attr); |
| 991 | 991 | $responseElement=$this->_getResponseElement($responseElement); |
| 992 | 992 | $retour.="var self=this;\n"; |
| 993 | - if($hasLoader===true){ |
|
| 993 | + if ($hasLoader===true) { |
|
| 994 | 994 | $this->addLoading($retour, $responseElement); |
| 995 | 995 | } |
| 996 | 996 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
@@ -1000,22 +1000,22 @@ discard block |
||
| 1000 | 1000 | return $retour; |
| 1001 | 1001 | } |
| 1002 | 1002 | |
| 1003 | - protected function _getAjaxUrl($url,$attr){ |
|
| 1003 | + protected function _getAjaxUrl($url, $attr) { |
|
| 1004 | 1004 | $url=$this->_correctAjaxUrl($url); |
| 1005 | 1005 | $retour="url='".$url."';\n"; |
| 1006 | 1006 | $slash="/"; |
| 1007 | - if(PhalconUtils::endsWith($url, "/")) |
|
| 1007 | + if (PhalconUtils::endsWith($url, "/")) |
|
| 1008 | 1008 | $slash=""; |
| 1009 | - if(JString::isNotNull($attr)){ |
|
| 1009 | + if (JString::isNotNull($attr)) { |
|
| 1010 | 1010 | if ($attr=="value") |
| 1011 | 1011 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
| 1012 | - else if($attr!=null && $attr!=="") |
|
| 1012 | + else if ($attr!=null && $attr!=="") |
|
| 1013 | 1013 | $retour.="url=url+'".$slash."'+$(this).attr('".$attr."');\n"; |
| 1014 | 1014 | } |
| 1015 | 1015 | return $retour; |
| 1016 | 1016 | } |
| 1017 | 1017 | |
| 1018 | - protected function _getOnAjaxDone($responseElement,$jsCallback){ |
|
| 1018 | + protected function _getOnAjaxDone($responseElement, $jsCallback) { |
|
| 1019 | 1019 | $retour=""; |
| 1020 | 1020 | if ($responseElement!=="") { |
| 1021 | 1021 | $retour="\t$({$responseElement}).html( data );\n"; |
@@ -1024,7 +1024,7 @@ discard block |
||
| 1024 | 1024 | return $retour; |
| 1025 | 1025 | } |
| 1026 | 1026 | |
| 1027 | - protected function _getResponseElement($responseElement){ |
|
| 1027 | + protected function _getResponseElement($responseElement) { |
|
| 1028 | 1028 | if ($responseElement!=="") { |
| 1029 | 1029 | $responseElement=$this->_prep_value($responseElement); |
| 1030 | 1030 | } |
@@ -1034,7 +1034,7 @@ discard block |
||
| 1034 | 1034 | protected function _correctAjaxUrl($url) { |
| 1035 | 1035 | if (PhalconUtils::endsWith($url, "/")) |
| 1036 | 1036 | $url=substr($url, 0, strlen($url)-1); |
| 1037 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
| 1037 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
| 1038 | 1038 | $url=$this->_di->get("url")->get($url); |
| 1039 | 1039 | } |
| 1040 | 1040 | return $url; |
@@ -1048,7 +1048,7 @@ discard block |
||
| 1048 | 1048 | * @param string $jsCallback javascript code to execute after the request |
| 1049 | 1049 | * @param boolean $immediatly |
| 1050 | 1050 | */ |
| 1051 | - public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
| 1051 | + public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
| 1052 | 1052 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 1053 | 1053 | $retour=$this->_getAjaxUrl($url, $attr); |
| 1054 | 1054 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -1069,7 +1069,7 @@ discard block |
||
| 1069 | 1069 | * @param string $url the request address |
| 1070 | 1070 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
| 1071 | 1071 | */ |
| 1072 | - public function _jsonOn($event,$element, $url,$parameters=array()) { |
|
| 1072 | + public function _jsonOn($event, $element, $url, $parameters=array()) { |
|
| 1073 | 1073 | $preventDefault=true; |
| 1074 | 1074 | $stopPropagation=true; |
| 1075 | 1075 | $jsCallback=null; |
@@ -1079,7 +1079,7 @@ discard block |
||
| 1079 | 1079 | $params="{}"; |
| 1080 | 1080 | $immediatly=true; |
| 1081 | 1081 | extract($parameters); |
| 1082 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 1082 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 1083 | 1083 | } |
| 1084 | 1084 | |
| 1085 | 1085 | /** |
@@ -1091,19 +1091,19 @@ discard block |
||
| 1091 | 1091 | * @param string $context jquery DOM element, array container. |
| 1092 | 1092 | * @param boolean $immediatly |
| 1093 | 1093 | */ |
| 1094 | - public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null,$immediatly=false) { |
|
| 1094 | + public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null, $immediatly=false) { |
|
| 1095 | 1095 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 1096 | 1096 | $retour=$this->_getAjaxUrl($url, $attr); |
| 1097 | - if($context===null){ |
|
| 1097 | + if ($context===null) { |
|
| 1098 | 1098 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
| 1099 | - $newElm = "$('#'+newId)"; |
|
| 1100 | - }else{ |
|
| 1099 | + $newElm="$('#'+newId)"; |
|
| 1100 | + }else { |
|
| 1101 | 1101 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
| 1102 | - $newElm = $context.".find('#'+newId)"; |
|
| 1102 | + $newElm=$context.".find('#'+newId)"; |
|
| 1103 | 1103 | } |
| 1104 | 1104 | $retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n"; |
| 1105 | 1105 | $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();newElm.attr('id',newId);\n"; |
| 1106 | - $retour.= $appendTo; |
|
| 1106 | + $retour.=$appendTo; |
|
| 1107 | 1107 | $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 | 1108 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 1109 | 1109 | $retour.="\t".$jsCallback."\n"."});\n"; |
@@ -1118,26 +1118,26 @@ discard block |
||
| 1118 | 1118 | * @param string $url the request address |
| 1119 | 1119 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get", "context"=>null) |
| 1120 | 1120 | */ |
| 1121 | - public function _jsonArrayOn($event,$element, $maskSelector,$url,$parameters=array()) { |
|
| 1121 | + public function _jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
| 1122 | 1122 | $preventDefault=true; |
| 1123 | 1123 | $stopPropagation=true; |
| 1124 | 1124 | $jsCallback=null; |
| 1125 | 1125 | $attr="id"; |
| 1126 | 1126 | $method="get"; |
| 1127 | - $context = null; |
|
| 1127 | + $context=null; |
|
| 1128 | 1128 | $params="{}"; |
| 1129 | 1129 | $immediatly=true; |
| 1130 | 1130 | extract($parameters); |
| 1131 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 1131 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 1132 | 1132 | } |
| 1133 | 1133 | |
| 1134 | - public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 1134 | + public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 1135 | 1135 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 1136 | 1136 | $retour=$this->_getAjaxUrl($url, $attr); |
| 1137 | 1137 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
| 1138 | 1138 | $responseElement=$this->_getResponseElement($responseElement); |
| 1139 | 1139 | $retour.="var self=this;\n"; |
| 1140 | - if($hasLoader===true){ |
|
| 1140 | + if ($hasLoader===true) { |
|
| 1141 | 1141 | $this->addLoading($retour, $responseElement); |
| 1142 | 1142 | } |
| 1143 | 1143 | $retour.="$.post(url,params).done(function( data ) {\n"; |
@@ -1164,7 +1164,7 @@ discard block |
||
| 1164 | 1164 | * @param string $responseElement |
| 1165 | 1165 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
| 1166 | 1166 | */ |
| 1167 | - public function _getOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 1167 | + public function _getOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 1168 | 1168 | $preventDefault=true; |
| 1169 | 1169 | $stopPropagation=true; |
| 1170 | 1170 | $jsCallback=null; |
@@ -1172,7 +1172,7 @@ discard block |
||
| 1172 | 1172 | $hasLoader=true; |
| 1173 | 1173 | $immediatly=true; |
| 1174 | 1174 | extract($parameters); |
| 1175 | - return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 1175 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 1176 | 1176 | } |
| 1177 | 1177 | |
| 1178 | 1178 | /** |
@@ -1185,7 +1185,7 @@ discard block |
||
| 1185 | 1185 | * @param string $responseElement |
| 1186 | 1186 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
| 1187 | 1187 | */ |
| 1188 | - public function _postOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 1188 | + public function _postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 1189 | 1189 | $preventDefault=true; |
| 1190 | 1190 | $stopPropagation=true; |
| 1191 | 1191 | $jsCallback=null; |
@@ -1193,7 +1193,7 @@ discard block |
||
| 1193 | 1193 | $hasLoader=true; |
| 1194 | 1194 | $immediatly=true; |
| 1195 | 1195 | extract($parameters); |
| 1196 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 1196 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 1197 | 1197 | } |
| 1198 | 1198 | |
| 1199 | 1199 | /** |
@@ -1206,7 +1206,7 @@ discard block |
||
| 1206 | 1206 | * @param string $responseElement |
| 1207 | 1207 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true) |
| 1208 | 1208 | */ |
| 1209 | - public function _postFormOn($event,$element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 1209 | + public function _postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 1210 | 1210 | $preventDefault=true; |
| 1211 | 1211 | $stopPropagation=true; |
| 1212 | 1212 | $validation=false; |
@@ -1215,7 +1215,7 @@ discard block |
||
| 1215 | 1215 | $hasLoader=true; |
| 1216 | 1216 | $immediatly=true; |
| 1217 | 1217 | extract($parameters); |
| 1218 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 1218 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 1219 | 1219 | } |
| 1220 | 1220 | |
| 1221 | 1221 | /** |
@@ -1251,8 +1251,8 @@ discard block |
||
| 1251 | 1251 | * @param boolean $immediatly |
| 1252 | 1252 | * @return string |
| 1253 | 1253 | */ |
| 1254 | - public function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="",$immediatly=true) { |
|
| 1255 | - return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 1254 | + public function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="", $immediatly=true) { |
|
| 1255 | + return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 1256 | 1256 | } |
| 1257 | 1257 | |
| 1258 | 1258 | /** |
@@ -1278,8 +1278,8 @@ discard block |
||
| 1278 | 1278 | * @param boolean $immediatly |
| 1279 | 1279 | * @return String |
| 1280 | 1280 | */ |
| 1281 | - public function _execOn($element, $event, $js, $preventDefault=false, $stopPropagation=false,$immediatly=true) { |
|
| 1282 | - return $this->_add_event($element, $this->_exec($js), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 1281 | + public function _execOn($element, $event, $js, $preventDefault=false, $stopPropagation=false, $immediatly=true) { |
|
| 1282 | + return $this->_add_event($element, $this->_exec($js), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 1283 | 1283 | } |
| 1284 | 1284 | } |
| 1285 | 1285 | /* End of file Jquery.php */ |
@@ -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 | |
@@ -45,7 +45,7 @@ discard block |
||
| 45 | 45 | |
| 46 | 46 | protected function _setDi($di) { |
| 47 | 47 | $this->_di=$di; |
| 48 | - if ($this->js!=null&&$di!=null) |
|
| 48 | + if ($this->js!=null && $di!=null) |
|
| 49 | 49 | $this->js->setDi($di); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -120,17 +120,17 @@ discard block |
||
| 120 | 120 | } |
| 121 | 121 | |
| 122 | 122 | public function __construct($params=array()) { |
| 123 | - $defaults=array ( |
|
| 123 | + $defaults=array( |
|
| 124 | 124 | 'driver' => 'Jquery' |
| 125 | 125 | ); |
| 126 | - foreach ( $defaults as $key => $val ) { |
|
| 127 | - if (isset($params[$key])&&$params[$key]!=="") { |
|
| 126 | + foreach ($defaults as $key => $val) { |
|
| 127 | + if (isset($params[$key]) && $params[$key]!=="") { |
|
| 128 | 128 | $defaults[$key]=$params[$key]; |
| 129 | 129 | } |
| 130 | 130 | } |
| 131 | 131 | extract($defaults); |
| 132 | 132 | $this->js=new Jquery(); |
| 133 | - $this->cdns=array (); |
|
| 133 | + $this->cdns=array(); |
|
| 134 | 134 | } |
| 135 | 135 | |
| 136 | 136 | public function addToCompile($jsScript) { |
@@ -382,7 +382,7 @@ discard block |
||
| 382 | 382 | * @return string |
| 383 | 383 | */ |
| 384 | 384 | public function addClass($element='this', $class='', $immediatly=false) { |
| 385 | - return $this->js->_genericCallValue('addClass',$element, $class, $immediatly); |
|
| 385 | + return $this->js->_genericCallValue('addClass', $element, $class, $immediatly); |
|
| 386 | 386 | } |
| 387 | 387 | |
| 388 | 388 | /** |
@@ -392,8 +392,8 @@ discard block |
||
| 392 | 392 | * @param boolean $immediatly defers the execution if set to false |
| 393 | 393 | * @return string |
| 394 | 394 | */ |
| 395 | - public function after($to, $element, $immediatly=false){ |
|
| 396 | - return $this->js->_genericCallElement('after',$to, $element, $immediatly); |
|
| 395 | + public function after($to, $element, $immediatly=false) { |
|
| 396 | + return $this->js->_genericCallElement('after', $to, $element, $immediatly); |
|
| 397 | 397 | } |
| 398 | 398 | |
| 399 | 399 | /** |
@@ -403,8 +403,8 @@ discard block |
||
| 403 | 403 | * @param boolean $immediatly defers the execution if set to false |
| 404 | 404 | * @return string |
| 405 | 405 | */ |
| 406 | - public function before($to, $element, $immediatly=false){ |
|
| 407 | - return $this->js->_genericCallElement('before',$to, $element, $immediatly); |
|
| 406 | + public function before($to, $element, $immediatly=false) { |
|
| 407 | + return $this->js->_genericCallElement('before', $to, $element, $immediatly); |
|
| 408 | 408 | } |
| 409 | 409 | |
| 410 | 410 | /** |
@@ -424,8 +424,8 @@ discard block |
||
| 424 | 424 | * @param string $value |
| 425 | 425 | * @param boolean $immediatly defers the execution if set to false |
| 426 | 426 | */ |
| 427 | - public function val($element='this',$value='',$immediatly=false){ |
|
| 428 | - return $this->js->_genericCallValue('val',$element,$value,$immediatly); |
|
| 427 | + public function val($element='this', $value='', $immediatly=false) { |
|
| 428 | + return $this->js->_genericCallValue('val', $element, $value, $immediatly); |
|
| 429 | 429 | } |
| 430 | 430 | |
| 431 | 431 | /** |
@@ -435,7 +435,7 @@ discard block |
||
| 435 | 435 | * @param boolean $immediatly defers the execution if set to false |
| 436 | 436 | */ |
| 437 | 437 | public function html($element='this', $value='', $immediatly=false) { |
| 438 | - return $this->js->_genericCallValue('html',$element, $value, $immediatly); |
|
| 438 | + return $this->js->_genericCallValue('html', $element, $value, $immediatly); |
|
| 439 | 439 | } |
| 440 | 440 | // -------------------------------------------------------------------- |
| 441 | 441 | /** |
@@ -460,7 +460,7 @@ discard block |
||
| 460 | 460 | * @return string |
| 461 | 461 | */ |
| 462 | 462 | public function append($to, $element, $immediatly=false) { |
| 463 | - return $this->js->_genericCallElement('append',$to, $element, $immediatly); |
|
| 463 | + return $this->js->_genericCallElement('append', $to, $element, $immediatly); |
|
| 464 | 464 | } |
| 465 | 465 | |
| 466 | 466 | /** |
@@ -471,7 +471,7 @@ discard block |
||
| 471 | 471 | * @return string |
| 472 | 472 | */ |
| 473 | 473 | public function prepend($to, $element, $immediatly=false) { |
| 474 | - return $this->js->_genericCallElement('prepend',$to, $element, $immediatly); |
|
| 474 | + return $this->js->_genericCallElement('prepend', $to, $element, $immediatly); |
|
| 475 | 475 | } |
| 476 | 476 | // -------------------------------------------------------------------- |
| 477 | 477 | /** |
@@ -522,7 +522,7 @@ discard block |
||
| 522 | 522 | * @return string |
| 523 | 523 | */ |
| 524 | 524 | public function removeClass($element='this', $class='', $immediatly=false) { |
| 525 | - return $this->js->_genericCall('removeClass',$element, $class, $immediatly); |
|
| 525 | + return $this->js->_genericCall('removeClass', $element, $class, $immediatly); |
|
| 526 | 526 | } |
| 527 | 527 | // -------------------------------------------------------------------- |
| 528 | 528 | /** |
@@ -583,7 +583,7 @@ discard block |
||
| 583 | 583 | * @return string |
| 584 | 584 | */ |
| 585 | 585 | public function toggleClass($element='this', $class='', $immediatly=false) { |
| 586 | - return $this->js->_genericCallValue('toggleClass',$element, $class, $immediatly); |
|
| 586 | + return $this->js->_genericCallValue('toggleClass', $element, $class, $immediatly); |
|
| 587 | 587 | } |
| 588 | 588 | |
| 589 | 589 | /** |
@@ -630,7 +630,7 @@ discard block |
||
| 630 | 630 | */ |
| 631 | 631 | public function compile($view=NULL, $view_var='script_foot', $script_tags=TRUE) { |
| 632 | 632 | $bs=$this->_bootstrap; |
| 633 | - if (isset($bs)&&isset($view)) { |
|
| 633 | + if (isset($bs) && isset($view)) { |
|
| 634 | 634 | $bs->compileHtml($this, $view); |
| 635 | 635 | } |
| 636 | 636 | return $this->js->_compile($view, $view_var, $script_tags); |
@@ -710,27 +710,27 @@ discard block |
||
| 710 | 710 | $json_result=$result->result_array(); |
| 711 | 711 | } elseif (is_array($result)) { |
| 712 | 712 | $json_result=$result; |
| 713 | - } else { |
|
| 713 | + }else { |
|
| 714 | 714 | return $this->_prep_args($result); |
| 715 | 715 | } |
| 716 | - } else { |
|
| 716 | + }else { |
|
| 717 | 717 | return 'null'; |
| 718 | 718 | } |
| 719 | 719 | return $this->_create_json($json_result, $match_array_type); |
| 720 | 720 | } |
| 721 | 721 | |
| 722 | 722 | private function _create_json($json_result, $match_array_type) { |
| 723 | - $json=array (); |
|
| 723 | + $json=array(); |
|
| 724 | 724 | $_is_assoc=TRUE; |
| 725 | - if (!is_array($json_result)&&empty($json_result)) { |
|
| 725 | + if (!is_array($json_result) && empty($json_result)) { |
|
| 726 | 726 | show_error("Generate JSON Failed - Illegal key, value pair."); |
| 727 | 727 | } elseif ($match_array_type) { |
| 728 | 728 | $_is_assoc=$this->_is_associative_array($json_result); |
| 729 | 729 | } |
| 730 | - foreach ( $json_result as $k => $v ) { |
|
| 730 | + foreach ($json_result as $k => $v) { |
|
| 731 | 731 | if ($_is_assoc) { |
| 732 | 732 | $json[]=$this->_prep_args($k, TRUE).':'.$this->generate_json($v, $match_array_type); |
| 733 | - } else { |
|
| 733 | + }else { |
|
| 734 | 734 | $json[]=$this->generate_json($v, $match_array_type); |
| 735 | 735 | } |
| 736 | 736 | } |
@@ -745,7 +745,7 @@ discard block |
||
| 745 | 745 | * @return type |
| 746 | 746 | */ |
| 747 | 747 | public function _is_associative_array($arr) { |
| 748 | - foreach ( array_keys($arr) as $key => $val ) { |
|
| 748 | + foreach (array_keys($arr) as $key => $val) { |
|
| 749 | 749 | if ($key!==$val) { |
| 750 | 750 | return TRUE; |
| 751 | 751 | } |
@@ -764,11 +764,11 @@ discard block |
||
| 764 | 764 | return 'null'; |
| 765 | 765 | } elseif (is_bool($result)) { |
| 766 | 766 | return ($result===TRUE) ? 'true' : 'false'; |
| 767 | - } elseif (is_string($result)||$is_key) { |
|
| 768 | - return '"'.str_replace(array ( |
|
| 769 | - '\\',"\t","\n","\r",'"','/' |
|
| 770 | - ), array ( |
|
| 771 | - '\\\\','\\t','\\n',"\\r",'\"','\/' |
|
| 767 | + } elseif (is_string($result) || $is_key) { |
|
| 768 | + return '"'.str_replace(array( |
|
| 769 | + '\\', "\t", "\n", "\r", '"', '/' |
|
| 770 | + ), array( |
|
| 771 | + '\\\\', '\\t', '\\n', "\\r", '\"', '\/' |
|
| 772 | 772 | ), $result).'"'; |
| 773 | 773 | } elseif (is_scalar($result)) { |
| 774 | 774 | return $result; |
@@ -783,8 +783,8 @@ discard block |
||
| 783 | 783 | * @param string $jsCallback javascript code to execute after the request |
| 784 | 784 | * @param boolean $hasLoader true for showing ajax loader. default : true |
| 785 | 785 | */ |
| 786 | - public function get($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true) { |
|
| 787 | - return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,true); |
|
| 786 | + public function get($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true) { |
|
| 787 | + return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, true); |
|
| 788 | 788 | } |
| 789 | 789 | |
| 790 | 790 | /** |
@@ -795,8 +795,8 @@ discard block |
||
| 795 | 795 | * @param string $jsCallback javascript code to execute after the request |
| 796 | 796 | * @param boolean $immediatly |
| 797 | 797 | */ |
| 798 | - public function json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
| 799 | - return $this->js->_json($url, $method, $params, $jsCallback, $attr, $context,$immediatly); |
|
| 798 | + public function json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
| 799 | + return $this->js->_json($url, $method, $params, $jsCallback, $attr, $context, $immediatly); |
|
| 800 | 800 | } |
| 801 | 801 | |
| 802 | 802 | /** |
@@ -806,8 +806,8 @@ discard block |
||
| 806 | 806 | * @param string $url the request address |
| 807 | 807 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
| 808 | 808 | */ |
| 809 | - public function jsonOn($event,$element, $url,$parameters=array()) { |
|
| 810 | - return $this->js->_jsonOn($event, $element, $url,$parameters); |
|
| 809 | + public function jsonOn($event, $element, $url, $parameters=array()) { |
|
| 810 | + return $this->js->_jsonOn($event, $element, $url, $parameters); |
|
| 811 | 811 | } |
| 812 | 812 | |
| 813 | 813 | /** |
@@ -851,8 +851,8 @@ discard block |
||
| 851 | 851 | * @param string $url the request url |
| 852 | 852 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
| 853 | 853 | */ |
| 854 | - public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) { |
|
| 855 | - return $this->js->_jsonArrayOn($event,$element,$maskSelector, $url, $parameters); |
|
| 854 | + public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
| 855 | + return $this->js->_jsonArrayOn($event, $element, $maskSelector, $url, $parameters); |
|
| 856 | 856 | } |
| 857 | 857 | |
| 858 | 858 | /** |
@@ -864,7 +864,7 @@ discard block |
||
| 864 | 864 | * @param string $jsCallback javascript code to execute after the request |
| 865 | 865 | * @param string $attr the html attribute added to the request |
| 866 | 866 | */ |
| 867 | - public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id") { |
|
| 867 | + public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id") { |
|
| 868 | 868 | return $this->js->_get($url, $params, $responseElement, $jsCallback, $attr, false); |
| 869 | 869 | } |
| 870 | 870 | |
@@ -902,8 +902,8 @@ discard block |
||
| 902 | 902 | * @param string $jsCallback javascript code to execute after the request |
| 903 | 903 | * @param boolean $hasLoader true for showing ajax loader. default : true |
| 904 | 904 | */ |
| 905 | - public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true) { |
|
| 906 | - return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,true); |
|
| 905 | + public function post($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true) { |
|
| 906 | + return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, true); |
|
| 907 | 907 | } |
| 908 | 908 | |
| 909 | 909 | /** |
@@ -916,8 +916,8 @@ discard block |
||
| 916 | 916 | * @param string $jsCallback javascript code to execute after the request |
| 917 | 917 | * @param boolean $hasLoader true for showing ajax loader. default : true |
| 918 | 918 | */ |
| 919 | - public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true) { |
|
| 920 | - return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,false); |
|
| 919 | + public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $hasLoader=true) { |
|
| 920 | + return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, false); |
|
| 921 | 921 | } |
| 922 | 922 | |
| 923 | 923 | /** |
@@ -931,7 +931,7 @@ discard block |
||
| 931 | 931 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true) |
| 932 | 932 | */ |
| 933 | 933 | public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
| 934 | - return $this->js->_postOn($event, $element, $url, $params, $responseElement, $parameters); |
|
| 934 | + return $this->js->_postOn($event, $element, $url, $params, $responseElement, $parameters); |
|
| 935 | 935 | } |
| 936 | 936 | |
| 937 | 937 | /** |
@@ -955,8 +955,8 @@ discard block |
||
| 955 | 955 | * @param string $jsCallback javascript code to execute after the request |
| 956 | 956 | * @param boolean $hasLoader true for showing ajax loader. default : true |
| 957 | 957 | */ |
| 958 | - public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$hasLoader=true) { |
|
| 959 | - return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader,true); |
|
| 958 | + public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $hasLoader=true) { |
|
| 959 | + return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader, true); |
|
| 960 | 960 | } |
| 961 | 961 | |
| 962 | 962 | /** |
@@ -969,8 +969,8 @@ discard block |
||
| 969 | 969 | * @param string $attr the html attribute added to the request |
| 970 | 970 | * @param boolean $hasLoader true for showing ajax loader. default : true |
| 971 | 971 | */ |
| 972 | - public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true) { |
|
| 973 | - return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader,false); |
|
| 972 | + public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true) { |
|
| 973 | + return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, false); |
|
| 974 | 974 | } |
| 975 | 975 | |
| 976 | 976 | /** |
@@ -984,7 +984,7 @@ discard block |
||
| 984 | 984 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true) |
| 985 | 985 | */ |
| 986 | 986 | public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
| 987 | - return $this->js->_postFormOn($event,$element, $url, $form, $responseElement, $parameters); |
|
| 987 | + return $this->js->_postFormOn($event, $element, $url, $form, $responseElement, $parameters); |
|
| 988 | 988 | } |
| 989 | 989 | |
| 990 | 990 | /** |
@@ -1039,7 +1039,7 @@ discard block |
||
| 1039 | 1039 | $preventDefault=false; |
| 1040 | 1040 | $immediatly=true; |
| 1041 | 1041 | extract($parameters); |
| 1042 | - return $this->js->_doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param, $preventDefault, $stopPropagation, $jsCallback,$immediatly); |
|
| 1042 | + return $this->js->_doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param, $preventDefault, $stopPropagation, $jsCallback, $immediatly); |
|
| 1043 | 1043 | } |
| 1044 | 1044 | |
| 1045 | 1045 | /** |
@@ -1066,7 +1066,7 @@ discard block |
||
| 1066 | 1066 | $preventDefault=false; |
| 1067 | 1067 | $immediatly=true; |
| 1068 | 1068 | extract($parameters); |
| 1069 | - $script=$this->js->_execOn($element, $event, $js, $preventDefault, $stopPropagation,$immediatly); |
|
| 1069 | + $script=$this->js->_execOn($element, $event, $js, $preventDefault, $stopPropagation, $immediatly); |
|
| 1070 | 1070 | return $script; |
| 1071 | 1071 | } |
| 1072 | 1072 | |
@@ -1076,7 +1076,7 @@ discard block |
||
| 1076 | 1076 | |
| 1077 | 1077 | public function setCDNs($cdns) { |
| 1078 | 1078 | if (is_array($cdns)===false) { |
| 1079 | - $cdns=array ( |
|
| 1079 | + $cdns=array( |
|
| 1080 | 1080 | $cdns |
| 1081 | 1081 | ); |
| 1082 | 1082 | } |
@@ -1087,9 +1087,9 @@ discard block |
||
| 1087 | 1087 | $hasJQuery=false; |
| 1088 | 1088 | $hasJQueryUI=false; |
| 1089 | 1089 | $hasBootstrap=false; |
| 1090 | - $result=array (); |
|
| 1091 | - foreach ( $this->cdns as $cdn ) { |
|
| 1092 | - switch(get_class($cdn)) { |
|
| 1090 | + $result=array(); |
|
| 1091 | + foreach ($this->cdns as $cdn) { |
|
| 1092 | + switch (get_class($cdn)) { |
|
| 1093 | 1093 | case "Ajax\lib\CDNJQuery": |
| 1094 | 1094 | $hasJQuery=true; |
| 1095 | 1095 | $result[0]=$cdn; |
@@ -1107,10 +1107,10 @@ discard block |
||
| 1107 | 1107 | if ($hasJQuery===false) { |
| 1108 | 1108 | $result[0]=new CDNJQuery("x"); |
| 1109 | 1109 | } |
| 1110 | - if ($hasJQueryUI===false&&isset($this->_ui)) { |
|
| 1110 | + if ($hasJQueryUI===false && isset($this->_ui)) { |
|
| 1111 | 1111 | $result[1]=new CDNGuiGen("x", $template); |
| 1112 | 1112 | } |
| 1113 | - if ($hasBootstrap===false&&isset($this->_bootstrap)) { |
|
| 1113 | + if ($hasBootstrap===false && isset($this->_bootstrap)) { |
|
| 1114 | 1114 | $result[2]=new CDNBootstrap("x"); |
| 1115 | 1115 | } |
| 1116 | 1116 | ksort($result); |
@@ -1124,7 +1124,7 @@ discard block |
||
| 1124 | 1124 | $this->_setDi($di); |
| 1125 | 1125 | } |
| 1126 | 1126 | } |
| 1127 | -} else { |
|
| 1127 | +}else { |
|
| 1128 | 1128 | class JsUtils extends _JsUtils { |
| 1129 | 1129 | |
| 1130 | 1130 | public function setDi(DiInterface $di) { |