@@ -20,6 +20,9 @@ |
||
| 20 | 20 | protected $_tabsType="tabs"; |
| 21 | 21 | protected $stacked=""; |
| 22 | 22 | |
| 23 | + /** |
|
| 24 | + * @param string $identifier |
|
| 25 | + */ |
|
| 23 | 26 | public function __construct($identifier, $tagName="ul") { |
| 24 | 27 | parent::__construct($identifier, $tagName); |
| 25 | 28 | $this->_template="<%tagName% %properties%>%tabs%</%tagName%>%content%"; |
@@ -16,7 +16,7 @@ discard block |
||
| 16 | 16 | use Phalcon\Mvc\View; |
| 17 | 17 | |
| 18 | 18 | class HtmlTabs extends HtmlDoubleElement { |
| 19 | - protected $tabs=array (); |
|
| 19 | + protected $tabs=array(); |
|
| 20 | 20 | protected $_tabsType="tabs"; |
| 21 | 21 | protected $stacked=""; |
| 22 | 22 | |
@@ -27,25 +27,25 @@ discard block |
||
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | protected function addTab_($tab, $index=null) { |
| 30 | - if($tab instanceof HtmlDropdown){ |
|
| 30 | + if ($tab instanceof HtmlDropdown) { |
|
| 31 | 31 | $tab->setMTagName("li"); |
| 32 | 32 | } |
| 33 | 33 | if (isset($index)) { |
| 34 | - $inserted=array ( |
|
| 34 | + $inserted=array( |
|
| 35 | 35 | $tab |
| 36 | 36 | ); |
| 37 | 37 | array_splice($this->tabs, $index, 0, $inserted); |
| 38 | - } else |
|
| 38 | + }else |
|
| 39 | 39 | $this->tabs []=$tab; |
| 40 | 40 | } |
| 41 | 41 | |
| 42 | - public function setActive($index){ |
|
| 43 | - for ($i=0;$i<sizeof($this->tabs);$i++){ |
|
| 42 | + public function setActive($index) { |
|
| 43 | + for ($i=0; $i<sizeof($this->tabs); $i++) { |
|
| 44 | 44 | $this->tabs[$i]->setActive($i==$index); |
| 45 | 45 | } |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - public function disable($index){ |
|
| 48 | + public function disable($index) { |
|
| 49 | 49 | $this->tabs[$index]->disable(); |
| 50 | 50 | } |
| 51 | 51 | |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | $tab=new HtmlTabItem("tab-".$this->identifier."-".$iid); |
| 60 | 60 | $tab->fromArray($element); |
| 61 | 61 | $this->addTab_($tab, $index); |
| 62 | - } else { |
|
| 62 | + }else { |
|
| 63 | 63 | $this->addTab_($tab, $index); |
| 64 | 64 | } |
| 65 | 65 | return $tab; |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | public function addTabs($tabs) { |
| 79 | - foreach ( $tabs as $tab ) { |
|
| 79 | + foreach ($tabs as $tab) { |
|
| 80 | 80 | $this->addTab($tab); |
| 81 | 81 | } |
| 82 | 82 | return $this; |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | */ |
| 107 | 107 | public function run(JsUtils $js) { |
| 108 | 108 | $this->_bsComponent=new Tabs($js); |
| 109 | - foreach ( $this->tabs as $tab ) { |
|
| 109 | + foreach ($this->tabs as $tab) { |
|
| 110 | 110 | $this->_bsComponent->addTab($tab->run($js)); |
| 111 | 111 | } |
| 112 | 112 | $this->addEventsOnRun($js); |
@@ -115,11 +115,11 @@ discard block |
||
| 115 | 115 | |
| 116 | 116 | public function createTabContents() { |
| 117 | 117 | $tabContent=new HtmlTabContent("tabcontent-".$this->identifier); |
| 118 | - foreach ( $this->tabs as $tab ) { |
|
| 118 | + foreach ($this->tabs as $tab) { |
|
| 119 | 119 | if ($tab instanceof HtmlTabItem) |
| 120 | 120 | $tabContent->addTabItem($tab->getHref()); |
| 121 | 121 | elseif ($tab instanceof HtmlDropdown) { |
| 122 | - foreach ( $tab->getItems() as $dropdownItem ) { |
|
| 122 | + foreach ($tab->getItems() as $dropdownItem) { |
|
| 123 | 123 | $tabContent->addTabItem($dropdownItem->getHref()); |
| 124 | 124 | } |
| 125 | 125 | } |
@@ -154,21 +154,21 @@ discard block |
||
| 154 | 154 | if (sizeof($this->content->getTabItems())>0) { |
| 155 | 155 | $this->content->getTabItem(0)->addToProperty("class", "fade in"); |
| 156 | 156 | $size=sizeof($this->tabs); |
| 157 | - for($index=0; $index<$size; $index++) { |
|
| 157 | + for ($index=0; $index<$size; $index++) { |
|
| 158 | 158 | $this->content->getTabItem($index)->addToProperty("class", "fade"); |
| 159 | 159 | } |
| 160 | 160 | } |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - public function on($event, $jsCode,$stopPropagation=false,$preventDefault=false){ |
|
| 164 | - foreach ($this->tabs as $tab){ |
|
| 165 | - $tab->on($event,$jsCode,$stopPropagation,$preventDefault); |
|
| 163 | + public function on($event, $jsCode, $stopPropagation=false, $preventDefault=false) { |
|
| 164 | + foreach ($this->tabs as $tab) { |
|
| 165 | + $tab->on($event, $jsCode, $stopPropagation, $preventDefault); |
|
| 166 | 166 | } |
| 167 | 167 | return $this; |
| 168 | 168 | } |
| 169 | 169 | |
| 170 | - public function setStacked($stacked=true){ |
|
| 171 | - if($stacked) |
|
| 170 | + public function setStacked($stacked=true) { |
|
| 171 | + if ($stacked) |
|
| 172 | 172 | $this->stacked="nav-stacked"; |
| 173 | 173 | else $this->stacked=""; |
| 174 | 174 | } |
@@ -35,8 +35,9 @@ discard block |
||
| 35 | 35 | $tab |
| 36 | 36 | ); |
| 37 | 37 | array_splice($this->tabs, $index, 0, $inserted); |
| 38 | - } else |
|
| 39 | - $this->tabs []=$tab; |
|
| 38 | + } else { |
|
| 39 | + $this->tabs []=$tab; |
|
| 40 | + } |
|
| 40 | 41 | } |
| 41 | 42 | |
| 42 | 43 | public function setActive($index){ |
@@ -116,9 +117,9 @@ discard block |
||
| 116 | 117 | public function createTabContents() { |
| 117 | 118 | $tabContent=new HtmlTabContent("tabcontent-".$this->identifier); |
| 118 | 119 | foreach ( $this->tabs as $tab ) { |
| 119 | - if ($tab instanceof HtmlTabItem) |
|
| 120 | - $tabContent->addTabItem($tab->getHref()); |
|
| 121 | - elseif ($tab instanceof HtmlDropdown) { |
|
| 120 | + if ($tab instanceof HtmlTabItem) { |
|
| 121 | + $tabContent->addTabItem($tab->getHref()); |
|
| 122 | + } elseif ($tab instanceof HtmlDropdown) { |
|
| 122 | 123 | foreach ( $tab->getItems() as $dropdownItem ) { |
| 123 | 124 | $tabContent->addTabItem($dropdownItem->getHref()); |
| 124 | 125 | } |
@@ -137,8 +138,9 @@ discard block |
||
| 137 | 138 | |
| 138 | 139 | public function setContentToTab($index, $text) { |
| 139 | 140 | $tabContentItem=$this->content->getTabItem($index); |
| 140 | - if (isset($tabContentItem)) |
|
| 141 | - $tabContentItem->setContent($text); |
|
| 141 | + if (isset($tabContentItem)) { |
|
| 142 | + $tabContentItem->setContent($text); |
|
| 143 | + } |
|
| 142 | 144 | } |
| 143 | 145 | |
| 144 | 146 | public function countTabs() { |
@@ -146,8 +148,9 @@ discard block |
||
| 146 | 148 | } |
| 147 | 149 | |
| 148 | 150 | public function getTabItem($index) { |
| 149 | - if ($index<sizeof($this->content->get)) |
|
| 150 | - return $this->content; |
|
| 151 | + if ($index<sizeof($this->content->get)) { |
|
| 152 | + return $this->content; |
|
| 153 | + } |
|
| 151 | 154 | } |
| 152 | 155 | |
| 153 | 156 | public function fadeEffect() { |
@@ -168,9 +171,11 @@ discard block |
||
| 168 | 171 | } |
| 169 | 172 | |
| 170 | 173 | public function setStacked($stacked=true){ |
| 171 | - if($stacked) |
|
| 172 | - $this->stacked="nav-stacked"; |
|
| 173 | - else $this->stacked=""; |
|
| 174 | + if($stacked) { |
|
| 175 | + $this->stacked="nav-stacked"; |
|
| 176 | + } else { |
|
| 177 | + $this->stacked=""; |
|
| 178 | + } |
|
| 174 | 179 | } |
| 175 | 180 | |
| 176 | 181 | /* (non-PHPdoc) |
@@ -4,7 +4,6 @@ |
||
| 4 | 4 | |
| 5 | 5 | use Ajax\bootstrap\html\phalcon\PhBsElement; |
| 6 | 6 | use Phalcon\Forms\Element\Select; |
| 7 | -use Ajax\bootstrap\html\base\HtmlDoubleElement; |
|
| 8 | 7 | use Ajax\bootstrap\html\html5\HtmlSelect; |
| 9 | 8 | |
| 10 | 9 | class PhBsSelect extends PhBsElement { |
@@ -13,7 +13,7 @@ |
||
| 13 | 13 | parent::__construct($name, $attributes); |
| 14 | 14 | $list=new HtmlSelect($name); |
| 15 | 15 | $list->setTagName("select"); |
| 16 | - $this->renderer=new PhBsRenderer(new Select($name, array (), $attributes), $list); |
|
| 16 | + $this->renderer=new PhBsRenderer(new Select($name, array(), $attributes), $list); |
|
| 17 | 17 | $this->setOptions($options); |
| 18 | 18 | } |
| 19 | 19 | |
@@ -155,7 +155,7 @@ discard block |
||
| 155 | 155 | * Outputs a jQuery click event |
| 156 | 156 | * |
| 157 | 157 | * @param string $element The element to attach the event to |
| 158 | - * @param mixed $js The code to execute |
|
| 158 | + * @param string $js The code to execute |
|
| 159 | 159 | * @param boolean $ret_false whether or not to return false |
| 160 | 160 | * @return string |
| 161 | 161 | */ |
@@ -220,6 +220,8 @@ discard block |
||
| 220 | 220 | * @param string - element |
| 221 | 221 | * @param string - Javascript code for mouse over |
| 222 | 222 | * @param string - Javascript code for mouse out |
| 223 | + * @param string $over |
|
| 224 | + * @param string $out |
|
| 223 | 225 | * @return string |
| 224 | 226 | */ |
| 225 | 227 | public function _hover($element='this', $over, $out) { |
@@ -803,7 +805,7 @@ discard block |
||
| 803 | 805 | * |
| 804 | 806 | * @param string $element |
| 805 | 807 | * @param array $options |
| 806 | - * @return void |
|
| 808 | + * @return string |
|
| 807 | 809 | */ |
| 808 | 810 | public function sortable($element, $options=array()) { |
| 809 | 811 | if (count($options)>0) { |
@@ -934,6 +936,7 @@ discard block |
||
| 934 | 936 | /** |
| 935 | 937 | * A wrapper for writing document.ready() |
| 936 | 938 | * |
| 939 | + * @param string $js |
|
| 937 | 940 | * @return string |
| 938 | 941 | */ |
| 939 | 942 | public function _document_ready($js) { |
@@ -988,7 +991,7 @@ discard block |
||
| 988 | 991 | /** |
| 989 | 992 | * Ensures the speed parameter is valid for jQuery |
| 990 | 993 | * |
| 991 | - * @param string|int $speed |
|
| 994 | + * @param string $speed |
|
| 992 | 995 | * @return string |
| 993 | 996 | */ |
| 994 | 997 | private function _validate_speed($speed) { |
@@ -1003,6 +1006,10 @@ discard block |
||
| 1003 | 1006 | return $speed; |
| 1004 | 1007 | } |
| 1005 | 1008 | // ------------------------------------------------------------------------ |
| 1009 | + |
|
| 1010 | + /** |
|
| 1011 | + * @param string $retour |
|
| 1012 | + */ |
|
| 1006 | 1013 | protected function addLoading(&$retour, $responseElement) { |
| 1007 | 1014 | $loading_notifier='<div class="ajax-loader">'; |
| 1008 | 1015 | if ($this->ajaxLoader=='') { |
@@ -1015,13 +1022,25 @@ discard block |
||
| 1015 | 1022 | $retour.="\t\t$(\"{$responseElement}\").prepend('{$loading_notifier}');\n"; |
| 1016 | 1023 | } |
| 1017 | 1024 | |
| 1025 | + /** |
|
| 1026 | + * @param string $url |
|
| 1027 | + * @param string $jsCallback |
|
| 1028 | + */ |
|
| 1018 | 1029 | public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
| 1019 | 1030 | return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
| 1020 | 1031 | } |
| 1032 | + |
|
| 1033 | + /** |
|
| 1034 | + * @param string $url |
|
| 1035 | + * @param string $jsCallback |
|
| 1036 | + */ |
|
| 1021 | 1037 | public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
| 1022 | 1038 | return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
| 1023 | 1039 | } |
| 1024 | 1040 | |
| 1041 | + /** |
|
| 1042 | + * @param string $method |
|
| 1043 | + */ |
|
| 1025 | 1044 | protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
| 1026 | 1045 | if(JString::isNull($params)){$params="{}";} |
| 1027 | 1046 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
@@ -1036,6 +1055,9 @@ discard block |
||
| 1036 | 1055 | return $retour; |
| 1037 | 1056 | } |
| 1038 | 1057 | |
| 1058 | + /** |
|
| 1059 | + * @param string $attr |
|
| 1060 | + */ |
|
| 1039 | 1061 | protected function _getAjaxUrl($url,$attr){ |
| 1040 | 1062 | $url=$this->_correctAjaxUrl($url); |
| 1041 | 1063 | $retour="url='".$url."';\n"; |
@@ -1105,6 +1127,12 @@ discard block |
||
| 1105 | 1127 | return $retour; |
| 1106 | 1128 | } |
| 1107 | 1129 | |
| 1130 | + /** |
|
| 1131 | + * @param string $url |
|
| 1132 | + * @param string $form |
|
| 1133 | + * @param string $responseElement |
|
| 1134 | + * @param string $jsCallback |
|
| 1135 | + */ |
|
| 1108 | 1136 | public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
| 1109 | 1137 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 1110 | 1138 | $retour=$this->_getAjaxUrl($url, $attr); |
@@ -1212,7 +1240,7 @@ discard block |
||
| 1212 | 1240 | * @param string $element |
| 1213 | 1241 | * @param string $elementToModify |
| 1214 | 1242 | * @param string $jqueryCall |
| 1215 | - * @param string|array $param |
|
| 1243 | + * @param string $param |
|
| 1216 | 1244 | * @param boolean $preventDefault |
| 1217 | 1245 | * @param boolean $stopPropagation |
| 1218 | 1246 | * @param string $jsCallback javascript code to execute after the jquery call |
@@ -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,10 +834,11 @@ 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"; |
|
| 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 | + } |
|
| 824 | 842 | $this->jquery_code_for_compile[]=$event; |
| 825 | 843 | return $event; |
| 826 | 844 | } |
@@ -870,8 +888,9 @@ discard block |
||
| 870 | 888 | |
| 871 | 889 | $output=($script_tags===FALSE) ? $script : $this->inline($script); |
| 872 | 890 | |
| 873 | - if ($view!=NULL) |
|
| 874 | - $view->setVar($view_var, $output); |
|
| 891 | + if ($view!=NULL) { |
|
| 892 | + $view->setVar($view_var, $output); |
|
| 893 | + } |
|
| 875 | 894 | return $output; |
| 876 | 895 | } |
| 877 | 896 | |
@@ -994,8 +1013,9 @@ discard block |
||
| 994 | 1013 | } |
| 995 | 1014 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
| 996 | 1015 | $retour.=$this->_getOnAjaxDone($responseElement, $jsCallback)."});\n"; |
| 997 | - if ($immediatly) |
|
| 998 | - $this->jquery_code_for_compile[]=$retour; |
|
| 1016 | + if ($immediatly) { |
|
| 1017 | + $this->jquery_code_for_compile[]=$retour; |
|
| 1018 | + } |
|
| 999 | 1019 | return $retour; |
| 1000 | 1020 | } |
| 1001 | 1021 | |
@@ -1003,13 +1023,15 @@ discard block |
||
| 1003 | 1023 | $url=$this->_correctAjaxUrl($url); |
| 1004 | 1024 | $retour="url='".$url."';\n"; |
| 1005 | 1025 | $slash="/"; |
| 1006 | - if(PhalconUtils::endsWith($url, "/")) |
|
| 1007 | - $slash=""; |
|
| 1026 | + if(PhalconUtils::endsWith($url, "/")) { |
|
| 1027 | + $slash=""; |
|
| 1028 | + } |
|
| 1008 | 1029 | if(JString::isNotNull($attr)){ |
| 1009 | - if ($attr=="value") |
|
| 1010 | - $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
| 1011 | - else if($attr!=null && $attr!=="") |
|
| 1012 | - $retour.="url=url+'".$slash."'+$(this).attr('".$attr."');\n"; |
|
| 1030 | + if ($attr=="value") { |
|
| 1031 | + $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
| 1032 | + } else if($attr!=null && $attr!=="") { |
|
| 1033 | + $retour.="url=url+'".$slash."'+$(this).attr('".$attr."');\n"; |
|
| 1034 | + } |
|
| 1013 | 1035 | } |
| 1014 | 1036 | return $retour; |
| 1015 | 1037 | } |
@@ -1031,8 +1053,9 @@ discard block |
||
| 1031 | 1053 | } |
| 1032 | 1054 | |
| 1033 | 1055 | protected function _correctAjaxUrl($url) { |
| 1034 | - if (PhalconUtils::endsWith($url, "/")) |
|
| 1035 | - $url=substr($url, 0, strlen($url)-1); |
|
| 1056 | + if (PhalconUtils::endsWith($url, "/")) { |
|
| 1057 | + $url=substr($url, 0, strlen($url)-1); |
|
| 1058 | + } |
|
| 1036 | 1059 | if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
| 1037 | 1060 | $url=$this->_di->get("url")->get($url); |
| 1038 | 1061 | } |
@@ -1054,8 +1077,9 @@ discard block |
||
| 1054 | 1077 | ."if($('#'+key,".$context.").length){ if($('#'+key,".$context.").is('[value]')) { $('#'+key,".$context.").val(data[key]);} else { $('#'+key,".$context.").html(data[key]); }}};\n"; |
| 1055 | 1078 | $retour.="\t".$jsCallback."\n |
| 1056 | 1079 | });\n"; |
| 1057 | - if ($immediatly) |
|
| 1058 | - $this->jquery_code_for_compile[]=$retour; |
|
| 1080 | + if ($immediatly) { |
|
| 1081 | + $this->jquery_code_for_compile[]=$retour; |
|
| 1082 | + } |
|
| 1059 | 1083 | return $retour; |
| 1060 | 1084 | } |
| 1061 | 1085 | |
@@ -1092,7 +1116,7 @@ discard block |
||
| 1092 | 1116 | if($context==null){ |
| 1093 | 1117 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
| 1094 | 1118 | $newElm = "$('#'+newId)"; |
| 1095 | - }else{ |
|
| 1119 | + } else{ |
|
| 1096 | 1120 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
| 1097 | 1121 | $newElm = $context.".find('#'+newId)"; |
| 1098 | 1122 | } |
@@ -1102,8 +1126,9 @@ discard block |
||
| 1102 | 1126 | $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"; |
| 1103 | 1127 | |
| 1104 | 1128 | $retour.="\t".$jsCallback."\n"."});\n"; |
| 1105 | - if ($immediatly) |
|
| 1106 | - $this->jquery_code_for_compile[]=$retour; |
|
| 1129 | + if ($immediatly) { |
|
| 1130 | + $this->jquery_code_for_compile[]=$retour; |
|
| 1131 | + } |
|
| 1107 | 1132 | return $retour; |
| 1108 | 1133 | } |
| 1109 | 1134 | /** |
@@ -1143,8 +1168,9 @@ discard block |
||
| 1143 | 1168 | }});\n"; |
| 1144 | 1169 | $retour.="$('#".$form."').submit();\n"; |
| 1145 | 1170 | } |
| 1146 | - if ($immediatly) |
|
| 1147 | - $this->jquery_code_for_compile[]=$retour; |
|
| 1171 | + if ($immediatly) { |
|
| 1172 | + $this->jquery_code_for_compile[]=$retour; |
|
| 1173 | + } |
|
| 1148 | 1174 | return $retour; |
| 1149 | 1175 | } |
| 1150 | 1176 | |
@@ -1220,11 +1246,13 @@ discard block |
||
| 1220 | 1246 | public function _doJQuery($element, $jqueryCall, $param="", $jsCallback="", $immediatly=false) { |
| 1221 | 1247 | $param=$this->_prep_value($param); |
| 1222 | 1248 | $callback=""; |
| 1223 | - if ($jsCallback!="") |
|
| 1224 | - $callback=", function(event){\n{$jsCallback}\n}"; |
|
| 1249 | + if ($jsCallback!="") { |
|
| 1250 | + $callback=", function(event){\n{$jsCallback}\n}"; |
|
| 1251 | + } |
|
| 1225 | 1252 | $script="$(".$this->_prep_element($element).").".$jqueryCall."(".$param.$callback.");\n"; |
| 1226 | - if ($immediatly) |
|
| 1227 | - $this->jquery_code_for_compile[]=$script; |
|
| 1253 | + if ($immediatly) { |
|
| 1254 | + $this->jquery_code_for_compile[]=$script; |
|
| 1255 | + } |
|
| 1228 | 1256 | return $script; |
| 1229 | 1257 | } |
| 1230 | 1258 | |
@@ -1252,8 +1280,9 @@ discard block |
||
| 1252 | 1280 | */ |
| 1253 | 1281 | public function _exec($js, $immediatly=false) { |
| 1254 | 1282 | $script=$js."\n"; |
| 1255 | - if ($immediatly) |
|
| 1256 | - $this->jquery_code_for_compile[]=$script; |
|
| 1283 | + if ($immediatly) { |
|
| 1284 | + $this->jquery_code_for_compile[]=$script; |
|
| 1285 | + } |
|
| 1257 | 1286 | return $script; |
| 1258 | 1287 | } |
| 1259 | 1288 | |
@@ -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 | |
@@ -854,7 +854,7 @@ discard block |
||
| 854 | 854 | |
| 855 | 855 | // External references |
| 856 | 856 | $external_scripts=implode('', $this->jquery_code_for_load); |
| 857 | - extract(array ( |
|
| 857 | + extract(array( |
|
| 858 | 858 | 'library_src' => $external_scripts |
| 859 | 859 | )); |
| 860 | 860 | |
@@ -887,7 +887,7 @@ discard block |
||
| 887 | 887 | * @return void |
| 888 | 888 | */ |
| 889 | 889 | public function _clear_compile() { |
| 890 | - $this->jquery_code_for_compile=array (); |
|
| 890 | + $this->jquery_code_for_compile=array(); |
|
| 891 | 891 | } |
| 892 | 892 | |
| 893 | 893 | // -------------------------------------------------------------------- |
@@ -899,12 +899,12 @@ discard block |
||
| 899 | 899 | */ |
| 900 | 900 | public function _document_ready($js) { |
| 901 | 901 | if (!is_array($js)) { |
| 902 | - $js=array ( |
|
| 902 | + $js=array( |
|
| 903 | 903 | $js |
| 904 | 904 | ); |
| 905 | 905 | } |
| 906 | 906 | |
| 907 | - foreach ( $js as $script ) { |
|
| 907 | + foreach ($js as $script) { |
|
| 908 | 908 | $this->jquery_code_for_compile[]=$script; |
| 909 | 909 | } |
| 910 | 910 | } |
@@ -920,7 +920,7 @@ discard block |
||
| 920 | 920 | * @return string |
| 921 | 921 | */ |
| 922 | 922 | public function _prep_element($element) { |
| 923 | - if (strrpos($element, 'this')===false&&strrpos($element, 'event')===false&&strrpos($element, 'self')===false) { |
|
| 923 | + if (strrpos($element, 'this')===false && strrpos($element, 'event')===false && strrpos($element, 'self')===false) { |
|
| 924 | 924 | $element='"'.addslashes($element).'"'; |
| 925 | 925 | } |
| 926 | 926 | return $element; |
@@ -938,7 +938,7 @@ discard block |
||
| 938 | 938 | if (is_array($value)) { |
| 939 | 939 | $value=implode(",", $value); |
| 940 | 940 | } |
| 941 | - if (strrpos($value, 'this')===false&&strrpos($value, 'event')===false&&strrpos($value, 'self')===false) { |
|
| 941 | + if (strrpos($value, 'this')===false && strrpos($value, 'event')===false && strrpos($value, 'self')===false) { |
|
| 942 | 942 | $value='"'.$value.'"'; |
| 943 | 943 | } |
| 944 | 944 | return $value; |
@@ -953,8 +953,8 @@ discard block |
||
| 953 | 953 | * @return string |
| 954 | 954 | */ |
| 955 | 955 | private function _validate_speed($speed) { |
| 956 | - if (in_array($speed, array ( |
|
| 957 | - 'slow','normal','fast' |
|
| 956 | + if (in_array($speed, array( |
|
| 957 | + 'slow', 'normal', 'fast' |
|
| 958 | 958 | ))) { |
| 959 | 959 | $speed='"'.$speed.'"'; |
| 960 | 960 | } elseif (preg_match("/[^0-9]/", $speed)) { |
@@ -968,7 +968,7 @@ discard block |
||
| 968 | 968 | $loading_notifier='<div class="ajax-loader">'; |
| 969 | 969 | if ($this->ajaxLoader=='') { |
| 970 | 970 | $loading_notifier.="Loading..."; |
| 971 | - } else { |
|
| 971 | + }else { |
|
| 972 | 972 | $loading_notifier.=$this->ajaxLoader; |
| 973 | 973 | } |
| 974 | 974 | $loading_notifier.='</div>'; |
@@ -976,20 +976,20 @@ discard block |
||
| 976 | 976 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
| 977 | 977 | } |
| 978 | 978 | |
| 979 | - public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 980 | - return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
| 979 | + public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 980 | + return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
| 981 | 981 | } |
| 982 | - public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 983 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
| 982 | + public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 983 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
| 984 | 984 | } |
| 985 | 985 | |
| 986 | - protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 987 | - if(JString::isNull($params)){$params="{}";} |
|
| 986 | + protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 987 | + if (JString::isNull($params)) {$params="{}"; } |
|
| 988 | 988 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 989 | 989 | $retour=$this->_getAjaxUrl($url, $attr); |
| 990 | 990 | $responseElement=$this->_getResponseElement($responseElement); |
| 991 | 991 | $retour.="var self=this;\n"; |
| 992 | - if($hasLoader===true){ |
|
| 992 | + if ($hasLoader===true) { |
|
| 993 | 993 | $this->addLoading($retour, $responseElement); |
| 994 | 994 | } |
| 995 | 995 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
@@ -999,22 +999,22 @@ discard block |
||
| 999 | 999 | return $retour; |
| 1000 | 1000 | } |
| 1001 | 1001 | |
| 1002 | - protected function _getAjaxUrl($url,$attr){ |
|
| 1002 | + protected function _getAjaxUrl($url, $attr) { |
|
| 1003 | 1003 | $url=$this->_correctAjaxUrl($url); |
| 1004 | 1004 | $retour="url='".$url."';\n"; |
| 1005 | 1005 | $slash="/"; |
| 1006 | - if(PhalconUtils::endsWith($url, "/")) |
|
| 1006 | + if (PhalconUtils::endsWith($url, "/")) |
|
| 1007 | 1007 | $slash=""; |
| 1008 | - if(JString::isNotNull($attr)){ |
|
| 1008 | + if (JString::isNotNull($attr)) { |
|
| 1009 | 1009 | if ($attr=="value") |
| 1010 | 1010 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
| 1011 | - else if($attr!=null && $attr!=="") |
|
| 1011 | + else if ($attr!=null && $attr!=="") |
|
| 1012 | 1012 | $retour.="url=url+'".$slash."'+$(this).attr('".$attr."');\n"; |
| 1013 | 1013 | } |
| 1014 | 1014 | return $retour; |
| 1015 | 1015 | } |
| 1016 | 1016 | |
| 1017 | - protected function _getOnAjaxDone($responseElement,$jsCallback){ |
|
| 1017 | + protected function _getOnAjaxDone($responseElement, $jsCallback) { |
|
| 1018 | 1018 | $retour=""; |
| 1019 | 1019 | if ($responseElement!=="") { |
| 1020 | 1020 | $retour="\t$({$responseElement}).html( data );\n"; |
@@ -1023,7 +1023,7 @@ discard block |
||
| 1023 | 1023 | return $retour; |
| 1024 | 1024 | } |
| 1025 | 1025 | |
| 1026 | - protected function _getResponseElement($responseElement){ |
|
| 1026 | + protected function _getResponseElement($responseElement) { |
|
| 1027 | 1027 | if ($responseElement!=="") { |
| 1028 | 1028 | $responseElement=$this->_prep_value($responseElement); |
| 1029 | 1029 | } |
@@ -1033,7 +1033,7 @@ discard block |
||
| 1033 | 1033 | protected function _correctAjaxUrl($url) { |
| 1034 | 1034 | if (PhalconUtils::endsWith($url, "/")) |
| 1035 | 1035 | $url=substr($url, 0, strlen($url)-1); |
| 1036 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
| 1036 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
| 1037 | 1037 | $url=$this->_di->get("url")->get($url); |
| 1038 | 1038 | } |
| 1039 | 1039 | return $url; |
@@ -1046,7 +1046,7 @@ discard block |
||
| 1046 | 1046 | * @param string $method Method use |
| 1047 | 1047 | * @param string $jsCallback javascript code to execute after the request |
| 1048 | 1048 | */ |
| 1049 | - public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
| 1049 | + public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
| 1050 | 1050 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 1051 | 1051 | $retour=$this->_getAjaxUrl($url, $attr); |
| 1052 | 1052 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -1066,7 +1066,7 @@ discard block |
||
| 1066 | 1066 | * @param string $url the request address |
| 1067 | 1067 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get") |
| 1068 | 1068 | */ |
| 1069 | - public function _jsonOn($event,$element, $url,$parameters=array()) { |
|
| 1069 | + public function _jsonOn($event, $element, $url, $parameters=array()) { |
|
| 1070 | 1070 | $preventDefault=true; |
| 1071 | 1071 | $stopPropagation=true; |
| 1072 | 1072 | $jsCallback=null; |
@@ -1075,7 +1075,7 @@ discard block |
||
| 1075 | 1075 | $context="document"; |
| 1076 | 1076 | $params="{}"; |
| 1077 | 1077 | extract($parameters); |
| 1078 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation); |
|
| 1078 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation); |
|
| 1079 | 1079 | } |
| 1080 | 1080 | |
| 1081 | 1081 | /** |
@@ -1086,19 +1086,19 @@ discard block |
||
| 1086 | 1086 | * @param string $jsCallback javascript code to execute after the request |
| 1087 | 1087 | * @param string $context jquery DOM element, array container. |
| 1088 | 1088 | */ |
| 1089 | - public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null,$immediatly=false) { |
|
| 1089 | + public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null, $immediatly=false) { |
|
| 1090 | 1090 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 1091 | 1091 | $retour=$this->_getAjaxUrl($url, $attr); |
| 1092 | - if($context===null){ |
|
| 1092 | + if ($context===null) { |
|
| 1093 | 1093 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
| 1094 | - $newElm = "$('#'+newId)"; |
|
| 1095 | - }else{ |
|
| 1094 | + $newElm="$('#'+newId)"; |
|
| 1095 | + }else { |
|
| 1096 | 1096 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
| 1097 | - $newElm = $context.".find('#'+newId)"; |
|
| 1097 | + $newElm=$context.".find('#'+newId)"; |
|
| 1098 | 1098 | } |
| 1099 | 1099 | $retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n"; |
| 1100 | 1100 | $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"; |
| 1101 | - $retour.= $appendTo; |
|
| 1101 | + $retour.=$appendTo; |
|
| 1102 | 1102 | $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"; |
| 1103 | 1103 | |
| 1104 | 1104 | $retour.="\t".$jsCallback."\n"."});\n"; |
@@ -1113,25 +1113,25 @@ discard block |
||
| 1113 | 1113 | * @param string $url the request address |
| 1114 | 1114 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get", "context"=>null) |
| 1115 | 1115 | */ |
| 1116 | - public function _jsonArrayOn($event,$element, $maskSelector,$url,$parameters=array()) { |
|
| 1116 | + public function _jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
| 1117 | 1117 | $preventDefault=true; |
| 1118 | 1118 | $stopPropagation=true; |
| 1119 | 1119 | $jsCallback=null; |
| 1120 | 1120 | $attr="id"; |
| 1121 | 1121 | $method="get"; |
| 1122 | - $context = null; |
|
| 1122 | + $context=null; |
|
| 1123 | 1123 | $params="{}"; |
| 1124 | 1124 | extract($parameters); |
| 1125 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation); |
|
| 1125 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation); |
|
| 1126 | 1126 | } |
| 1127 | 1127 | |
| 1128 | - public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 1128 | + public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 1129 | 1129 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 1130 | 1130 | $retour=$this->_getAjaxUrl($url, $attr); |
| 1131 | 1131 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
| 1132 | 1132 | $responseElement=$this->_getResponseElement($responseElement); |
| 1133 | 1133 | $retour.="var self=this;\n"; |
| 1134 | - if($hasLoader===true){ |
|
| 1134 | + if ($hasLoader===true) { |
|
| 1135 | 1135 | $this->addLoading($retour, $responseElement); |
| 1136 | 1136 | } |
| 1137 | 1137 | $retour.="$.post(url,params).done(function( data ) {\n"; |
@@ -1158,14 +1158,14 @@ discard block |
||
| 1158 | 1158 | * @param string $responseElement |
| 1159 | 1159 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
| 1160 | 1160 | */ |
| 1161 | - public function _getOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 1161 | + public function _getOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 1162 | 1162 | $preventDefault=true; |
| 1163 | 1163 | $stopPropagation=true; |
| 1164 | 1164 | $jsCallback=null; |
| 1165 | 1165 | $attr="id"; |
| 1166 | 1166 | $hasLoader=true; |
| 1167 | 1167 | extract($parameters); |
| 1168 | - return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation); |
|
| 1168 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation); |
|
| 1169 | 1169 | } |
| 1170 | 1170 | |
| 1171 | 1171 | /** |
@@ -1178,14 +1178,14 @@ discard block |
||
| 1178 | 1178 | * @param string $responseElement |
| 1179 | 1179 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
| 1180 | 1180 | */ |
| 1181 | - public function _postOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 1181 | + public function _postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 1182 | 1182 | $preventDefault=true; |
| 1183 | 1183 | $stopPropagation=true; |
| 1184 | 1184 | $jsCallback=null; |
| 1185 | 1185 | $attr="id"; |
| 1186 | 1186 | $hasLoader=true; |
| 1187 | 1187 | extract($parameters); |
| 1188 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation); |
|
| 1188 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation); |
|
| 1189 | 1189 | } |
| 1190 | 1190 | |
| 1191 | 1191 | /** |
@@ -1198,7 +1198,7 @@ discard block |
||
| 1198 | 1198 | * @param string $responseElement |
| 1199 | 1199 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
| 1200 | 1200 | */ |
| 1201 | - public function _postFormOn($event,$element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 1201 | + public function _postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 1202 | 1202 | $preventDefault=true; |
| 1203 | 1203 | $stopPropagation=true; |
| 1204 | 1204 | $validation=false; |
@@ -1206,7 +1206,7 @@ discard block |
||
| 1206 | 1206 | $attr="id"; |
| 1207 | 1207 | $hasLoader=true; |
| 1208 | 1208 | extract($parameters); |
| 1209 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation); |
|
| 1209 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation); |
|
| 1210 | 1210 | } |
| 1211 | 1211 | |
| 1212 | 1212 | /** |
@@ -676,6 +676,9 @@ discard block |
||
| 676 | 676 | return $this->_create_json($json_result, $match_array_type); |
| 677 | 677 | } |
| 678 | 678 | |
| 679 | + /** |
|
| 680 | + * @param boolean $match_array_type |
|
| 681 | + */ |
|
| 679 | 682 | private function _create_json($json_result, $match_array_type) { |
| 680 | 683 | $json=array (); |
| 681 | 684 | $_is_assoc=TRUE; |
@@ -699,7 +702,7 @@ discard block |
||
| 699 | 702 | * Checks for an associative array |
| 700 | 703 | * |
| 701 | 704 | * @param type |
| 702 | - * @return type |
|
| 705 | + * @return boolean |
|
| 703 | 706 | */ |
| 704 | 707 | public function _is_associative_array($arr) { |
| 705 | 708 | foreach ( array_keys($arr) as $key => $val ) { |
@@ -939,7 +942,7 @@ discard block |
||
| 939 | 942 | * @param string $jqueryCall the JQuery callback |
| 940 | 943 | * @param mixed $param array or string parameters |
| 941 | 944 | * @param string $jsCallback javascript code to execute after the jquery call |
| 942 | - * @return mixed |
|
| 945 | + * @return string |
|
| 943 | 946 | */ |
| 944 | 947 | public function doJQuery($element, $jqueryCall, $param="", $jsCallback="") { |
| 945 | 948 | return $this->js->_doJQuery($element, $jqueryCall, $param, $jsCallback, true); |
@@ -951,7 +954,7 @@ discard block |
||
| 951 | 954 | * @param string $jqueryCall the JQuery callback |
| 952 | 955 | * @param mixed $param array or string parameters |
| 953 | 956 | * @param string $jsCallback javascript code to execute after the jquery call |
| 954 | - * @return mixed |
|
| 957 | + * @return string |
|
| 955 | 958 | */ |
| 956 | 959 | public function doJQueryDeferred($element, $jqueryCall, $param="", $jsCallback="") { |
| 957 | 960 | return $this->js->_doJQuery($element, $jqueryCall, $param, $jsCallback, false); |
@@ -45,8 +45,9 @@ |
||
| 45 | 45 | |
| 46 | 46 | protected function _setDi($di) { |
| 47 | 47 | $this->_di=$di; |
| 48 | - if ($this->js!=null&&$di!=null) |
|
| 49 | - $this->js->setDi($di); |
|
| 48 | + if ($this->js!=null&&$di!=null) { |
|
| 49 | + $this->js->setDi($di); |
|
| 50 | + } |
|
| 50 | 51 | } |
| 51 | 52 | |
| 52 | 53 | /** |
@@ -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 | /** |
@@ -794,8 +794,8 @@ discard block |
||
| 794 | 794 | * @param string $method Method used |
| 795 | 795 | * @param string $jsCallback javascript code to execute after the request |
| 796 | 796 | */ |
| 797 | - public function json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
| 798 | - return $this->js->_json($url, $method, $params, $jsCallback, $attr, $context,$immediatly); |
|
| 797 | + public function json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
| 798 | + return $this->js->_json($url, $method, $params, $jsCallback, $attr, $context, $immediatly); |
|
| 799 | 799 | } |
| 800 | 800 | |
| 801 | 801 | /** |
@@ -805,8 +805,8 @@ discard block |
||
| 805 | 805 | * @param string $url the request address |
| 806 | 806 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get") |
| 807 | 807 | */ |
| 808 | - public function jsonOn($event,$element, $url,$parameters=array()) { |
|
| 809 | - return $this->js->_jsonOn($event, $element, $url,$parameters); |
|
| 808 | + public function jsonOn($event, $element, $url, $parameters=array()) { |
|
| 809 | + return $this->js->_jsonOn($event, $element, $url, $parameters); |
|
| 810 | 810 | } |
| 811 | 811 | |
| 812 | 812 | /** |
@@ -850,8 +850,8 @@ discard block |
||
| 850 | 850 | * @param string $url the request url |
| 851 | 851 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get") |
| 852 | 852 | */ |
| 853 | - public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) { |
|
| 854 | - return $this->js->_jsonArrayOn($event,$element,$maskSelector, $url, $parameters); |
|
| 853 | + public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
| 854 | + return $this->js->_jsonArrayOn($event, $element, $maskSelector, $url, $parameters); |
|
| 855 | 855 | } |
| 856 | 856 | |
| 857 | 857 | /** |
@@ -863,7 +863,7 @@ discard block |
||
| 863 | 863 | * @param string $jsCallback javascript code to execute after the request |
| 864 | 864 | * @param string $attr the html attribute added to the request |
| 865 | 865 | */ |
| 866 | - public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id") { |
|
| 866 | + public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id") { |
|
| 867 | 867 | return $this->js->_get($url, $params, $responseElement, $jsCallback, $attr, false); |
| 868 | 868 | } |
| 869 | 869 | |
@@ -901,8 +901,8 @@ discard block |
||
| 901 | 901 | * @param string $jsCallback javascript code to execute after the request |
| 902 | 902 | * @param boolean $hasLoader true for showing ajax loader. default : true |
| 903 | 903 | */ |
| 904 | - public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true) { |
|
| 905 | - return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,true); |
|
| 904 | + public function post($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true) { |
|
| 905 | + return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, true); |
|
| 906 | 906 | } |
| 907 | 907 | |
| 908 | 908 | /** |
@@ -915,8 +915,8 @@ discard block |
||
| 915 | 915 | * @param string $jsCallback javascript code to execute after the request |
| 916 | 916 | * @param boolean $hasLoader true for showing ajax loader. default : true |
| 917 | 917 | */ |
| 918 | - public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true) { |
|
| 919 | - return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,false); |
|
| 918 | + public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $hasLoader=true) { |
|
| 919 | + return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, false); |
|
| 920 | 920 | } |
| 921 | 921 | |
| 922 | 922 | /** |
@@ -930,7 +930,7 @@ discard block |
||
| 930 | 930 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
| 931 | 931 | */ |
| 932 | 932 | public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
| 933 | - return $this->js->_postOn($event, $element, $url, $params, $responseElement, $parameters); |
|
| 933 | + return $this->js->_postOn($event, $element, $url, $params, $responseElement, $parameters); |
|
| 934 | 934 | } |
| 935 | 935 | |
| 936 | 936 | /** |
@@ -954,8 +954,8 @@ discard block |
||
| 954 | 954 | * @param string $jsCallback javascript code to execute after the request |
| 955 | 955 | * @param boolean $hasLoader true for showing ajax loader. default : true |
| 956 | 956 | */ |
| 957 | - public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$hasLoader=true) { |
|
| 958 | - return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader,true); |
|
| 957 | + public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $hasLoader=true) { |
|
| 958 | + return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader, true); |
|
| 959 | 959 | } |
| 960 | 960 | |
| 961 | 961 | /** |
@@ -968,8 +968,8 @@ discard block |
||
| 968 | 968 | * @param string $attr the html attribute added to the request |
| 969 | 969 | * @param boolean $hasLoader true for showing ajax loader. default : true |
| 970 | 970 | */ |
| 971 | - public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true) { |
|
| 972 | - return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader,false); |
|
| 971 | + public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true) { |
|
| 972 | + return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, false); |
|
| 973 | 973 | } |
| 974 | 974 | |
| 975 | 975 | /** |
@@ -983,7 +983,7 @@ discard block |
||
| 983 | 983 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
| 984 | 984 | */ |
| 985 | 985 | public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
| 986 | - return $this->js->_postFormOn($event,$element, $url, $form, $responseElement, $parameters); |
|
| 986 | + return $this->js->_postFormOn($event, $element, $url, $form, $responseElement, $parameters); |
|
| 987 | 987 | } |
| 988 | 988 | |
| 989 | 989 | /** |
@@ -1073,7 +1073,7 @@ discard block |
||
| 1073 | 1073 | |
| 1074 | 1074 | public function setCDNs($cdns) { |
| 1075 | 1075 | if (is_array($cdns)===false) { |
| 1076 | - $cdns=array ( |
|
| 1076 | + $cdns=array( |
|
| 1077 | 1077 | $cdns |
| 1078 | 1078 | ); |
| 1079 | 1079 | } |
@@ -1084,9 +1084,9 @@ discard block |
||
| 1084 | 1084 | $hasJQuery=false; |
| 1085 | 1085 | $hasJQueryUI=false; |
| 1086 | 1086 | $hasBootstrap=false; |
| 1087 | - $result=array (); |
|
| 1088 | - foreach ( $this->cdns as $cdn ) { |
|
| 1089 | - switch(get_class($cdn)) { |
|
| 1087 | + $result=array(); |
|
| 1088 | + foreach ($this->cdns as $cdn) { |
|
| 1089 | + switch (get_class($cdn)) { |
|
| 1090 | 1090 | case "Ajax\lib\CDNJQuery": |
| 1091 | 1091 | $hasJQuery=true; |
| 1092 | 1092 | $result[0]=$cdn; |
@@ -1104,10 +1104,10 @@ discard block |
||
| 1104 | 1104 | if ($hasJQuery===false) { |
| 1105 | 1105 | $result[0]=new CDNJQuery("x"); |
| 1106 | 1106 | } |
| 1107 | - if ($hasJQueryUI===false&&isset($this->_ui)) { |
|
| 1107 | + if ($hasJQueryUI===false && isset($this->_ui)) { |
|
| 1108 | 1108 | $result[1]=new CDNGuiGen("x", $template); |
| 1109 | 1109 | } |
| 1110 | - if ($hasBootstrap===false&&isset($this->_bootstrap)) { |
|
| 1110 | + if ($hasBootstrap===false && isset($this->_bootstrap)) { |
|
| 1111 | 1111 | $result[2]=new CDNBootstrap("x"); |
| 1112 | 1112 | } |
| 1113 | 1113 | ksort($result); |
@@ -1121,7 +1121,7 @@ discard block |
||
| 1121 | 1121 | $this->_setDi($di); |
| 1122 | 1122 | } |
| 1123 | 1123 | } |
| 1124 | -} else { |
|
| 1124 | +}else { |
|
| 1125 | 1125 | class JsUtils extends _JsUtils { |
| 1126 | 1126 | |
| 1127 | 1127 | public function setDi(DiInterface $di) { |
@@ -65,7 +65,7 @@ |
||
| 65 | 65 | } |
| 66 | 66 | |
| 67 | 67 | protected function compileEvents() { |
| 68 | - foreach ( $this->events as $event => $jsCode ) { |
|
| 68 | + foreach ($this->events as $event => $jsCode) { |
|
| 69 | 69 | $this->jquery_code_for_compile []="$( \"".$this->collapsed."\" ).on(\"".$event."\" , function (e) {".$jsCode."});"; |
| 70 | 70 | } |
| 71 | 71 | } |
@@ -9,9 +9,9 @@ |
||
| 9 | 9 | * @see \Ajax\bootstrap\components\SimpleBsComponent::getScript() |
| 10 | 10 | */ |
| 11 | 11 | public function getScript() { |
| 12 | - $this->jquery_code_for_compile=array (); |
|
| 13 | - foreach ( $this->jsCodes as $jsCode ) { |
|
| 14 | - $this->jquery_code_for_compile []=$jsCode->compile(array ( |
|
| 12 | + $this->jquery_code_for_compile=array(); |
|
| 13 | + foreach ($this->jsCodes as $jsCode) { |
|
| 14 | + $this->jquery_code_for_compile []=$jsCode->compile(array( |
|
| 15 | 15 | "identifier" => $this->attachTo |
| 16 | 16 | )); |
| 17 | 17 | } |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | if ($value) { |
| 58 | 58 | $this->jsCodes ["draggable"]=new Draggable(); |
| 59 | 59 | $this->setBackdrop(false); |
| 60 | - } else if (array_key_exists("draggable", $this->jsCodes)) { |
|
| 60 | + }else if (array_key_exists("draggable", $this->jsCodes)) { |
|
| 61 | 61 | unset($this->jsCodes ["draggable"]); |
| 62 | 62 | unset($this->params ["backdrop"]); |
| 63 | 63 | } |
@@ -6,8 +6,8 @@ discard block |
||
| 6 | 6 | use Ajax\common\JsCode; |
| 7 | 7 | |
| 8 | 8 | class SimpleBsComponent extends SimpleComponent { |
| 9 | - protected $events=array (); |
|
| 10 | - protected $jsCodes=array (); |
|
| 9 | + protected $events=array(); |
|
| 10 | + protected $jsCodes=array(); |
|
| 11 | 11 | |
| 12 | 12 | public function addEvent($event, $jsCode) { |
| 13 | 13 | $this->events [$event]=$jsCode; |
@@ -15,8 +15,8 @@ discard block |
||
| 15 | 15 | |
| 16 | 16 | public function getScript() { |
| 17 | 17 | parent::getScript(); |
| 18 | - foreach ( $this->jsCodes as $jsCode ) { |
|
| 19 | - $this->jquery_code_for_compile []=$jsCode->compile(array ( |
|
| 18 | + foreach ($this->jsCodes as $jsCode) { |
|
| 19 | + $this->jquery_code_for_compile []=$jsCode->compile(array( |
|
| 20 | 20 | "identifier" => $this->attachTo |
| 21 | 21 | )); |
| 22 | 22 | } |
@@ -9,10 +9,10 @@ |
||
| 9 | 9 | * @see \Ajax\common\SimpleComponent::compileEvents() |
| 10 | 10 | */ |
| 11 | 11 | protected function compileEvents() { |
| 12 | - foreach ( $this->events as $event => $jsCode ) { |
|
| 12 | + foreach ($this->events as $event => $jsCode) { |
|
| 13 | 13 | if ($event==="buttonClick") { |
| 14 | 14 | $this->jquery_code_for_compile []="$( \"#split-".preg_replace('/[^a-zA-Z0-9\-.]/s', '', $this->attachTo)."\" ).on(\"click\" , function( event, data ) {".$jsCode."});"; |
| 15 | - } else { |
|
| 15 | + }else { |
|
| 16 | 16 | $this->jquery_code_for_compile []="$( \"".$this->attachTo."\" ).on(\"".$event."\" , function( event, data ) {".$jsCode."});"; |
| 17 | 17 | } |
| 18 | 18 | } |