@@ -9,10 +9,10 @@ discard block |
||
| 9 | 9 | class HtmlFormTextarea extends HtmlFormField { |
| 10 | 10 | use TextFieldsTrait; |
| 11 | 11 | |
| 12 | - public function __construct($identifier, $label=NULL,$value=NULL,$placeholder=NULL,$rows=NULL) { |
|
| 13 | - if(!isset($placeholder)) |
|
| 12 | + public function __construct($identifier, $label=NULL, $value=NULL, $placeholder=NULL, $rows=NULL) { |
|
| 13 | + if (!isset($placeholder)) |
|
| 14 | 14 | $placeholder=$label; |
| 15 | - parent::__construct("field-".$identifier, new HtmlTextarea($identifier,$value,$placeholder,$rows), $label); |
|
| 15 | + parent::__construct("field-".$identifier, new HtmlTextarea($identifier, $value, $placeholder, $rows), $label); |
|
| 16 | 16 | $this->_identifier=$identifier; |
| 17 | 17 | } |
| 18 | 18 | |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | * Defines the textarea row count |
| 21 | 21 | * @param int $count |
| 22 | 22 | */ |
| 23 | - public function setRows($count){ |
|
| 23 | + public function setRows($count) { |
|
| 24 | 24 | $this->getField()->setRows($count); |
| 25 | 25 | } |
| 26 | 26 | |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | return $this->content["field"]; |
| 29 | 29 | } |
| 30 | 30 | |
| 31 | - public function setName($name){ |
|
| 32 | - $this->getDataField()->setProperty("name",$name); |
|
| 31 | + public function setName($name) { |
|
| 32 | + $this->getDataField()->setProperty("name", $name); |
|
| 33 | 33 | } |
| 34 | 34 | } |
| 35 | 35 | \ No newline at end of file |
@@ -10,8 +10,9 @@ |
||
| 10 | 10 | use TextFieldsTrait; |
| 11 | 11 | |
| 12 | 12 | public function __construct($identifier, $label=NULL,$value=NULL,$placeholder=NULL,$rows=NULL) { |
| 13 | - if(!isset($placeholder)) |
|
| 14 | - $placeholder=$label; |
|
| 13 | + if(!isset($placeholder)) { |
|
| 14 | + $placeholder=$label; |
|
| 15 | + } |
|
| 15 | 16 | parent::__construct("field-".$identifier, new HtmlTextarea($identifier,$value,$placeholder,$rows), $label); |
| 16 | 17 | $this->_identifier=$identifier; |
| 17 | 18 | } |
@@ -7,26 +7,26 @@ |
||
| 7 | 7 | |
| 8 | 8 | class HtmlFormDropdown extends HtmlFormField { |
| 9 | 9 | |
| 10 | - public function __construct($identifier,$items=array(), $label=NULL,$value=NULL,$multiple=false,$associative=true) { |
|
| 11 | - parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier,$value,$items,$associative))->asSelect($identifier,$multiple), $label); |
|
| 10 | + public function __construct($identifier, $items=array(), $label=NULL, $value=NULL, $multiple=false, $associative=true) { |
|
| 11 | + parent::__construct("field-".$identifier, (new HtmlDropdown("dropdown-".$identifier, $value, $items, $associative))->asSelect($identifier, $multiple), $label); |
|
| 12 | 12 | $this->_identifier=$identifier; |
| 13 | 13 | } |
| 14 | 14 | |
| 15 | - public function setItems($items){ |
|
| 15 | + public function setItems($items) { |
|
| 16 | 16 | return $this->getField()->setItems($items); |
| 17 | 17 | } |
| 18 | - public function addItem($item,$value=NULL,$image=NULL){ |
|
| 19 | - return $this->getField()->addItem($item,$value,$image); |
|
| 18 | + public function addItem($item, $value=NULL, $image=NULL) { |
|
| 19 | + return $this->getField()->addItem($item, $value, $image); |
|
| 20 | 20 | } |
| 21 | - public static function multipleDropdown($identifier,$items=array(), $label=NULL,$value=NULL,$associative=true){ |
|
| 22 | - return new HtmlFormDropdown($identifier,$items,$label,$value,true,$associative); |
|
| 21 | + public static function multipleDropdown($identifier, $items=array(), $label=NULL, $value=NULL, $associative=true) { |
|
| 22 | + return new HtmlFormDropdown($identifier, $items, $label, $value, true, $associative); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | - public function getDataField(){ |
|
| 25 | + public function getDataField() { |
|
| 26 | 26 | return $this->getField()->getInput(); |
| 27 | 27 | } |
| 28 | - public function asSelect($name=NULL,$multiple=false,$selection=true){ |
|
| 29 | - $this->getField()->asSelect($name,$multiple,$selection); |
|
| 28 | + public function asSelect($name=NULL, $multiple=false, $selection=true) { |
|
| 29 | + $this->getField()->asSelect($name, $multiple, $selection); |
|
| 30 | 30 | return $this; |
| 31 | 31 | } |
| 32 | 32 | } |
| 33 | 33 | \ No newline at end of file |
@@ -10,14 +10,14 @@ discard block |
||
| 10 | 10 | use Ajax\JsUtils; |
| 11 | 11 | |
| 12 | 12 | class HtmlInput extends HtmlSemDoubleElement { |
| 13 | - use IconTrait,TextFieldsTrait,FieldTrait; |
|
| 13 | + use IconTrait, TextFieldsTrait, FieldTrait; |
|
| 14 | 14 | |
| 15 | 15 | public function __construct($identifier, $type="text", $value="", $placeholder="") { |
| 16 | - parent::__construct("div-" . $identifier, "div", "ui input"); |
|
| 16 | + parent::__construct("div-".$identifier, "div", "ui input"); |
|
| 17 | 17 | $this->_identifier=$identifier; |
| 18 | - $this->content=[ "field" => new \Ajax\common\html\html5\HtmlInput($identifier, $type, $value, $placeholder) ]; |
|
| 19 | - $this->_states=[ State::DISABLED,State::FOCUS,State::ERROR ]; |
|
| 20 | - $this->_variations=[ Variation::TRANSPARENT ]; |
|
| 18 | + $this->content=["field" => new \Ajax\common\html\html5\HtmlInput($identifier, $type, $value, $placeholder)]; |
|
| 19 | + $this->_states=[State::DISABLED, State::FOCUS, State::ERROR]; |
|
| 20 | + $this->_variations=[Variation::TRANSPARENT]; |
|
| 21 | 21 | } |
| 22 | 22 | |
| 23 | 23 | public function getField() { |
@@ -37,11 +37,11 @@ discard block |
||
| 37 | 37 | |
| 38 | 38 | public function run(JsUtils $js) { |
| 39 | 39 | $result=parent::run($js); |
| 40 | - $result->attach("#" . $this->getDataField()->getIdentifier()); |
|
| 40 | + $result->attach("#".$this->getDataField()->getIdentifier()); |
|
| 41 | 41 | return $result; |
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public function setTransparent(){ |
|
| 44 | + public function setTransparent() { |
|
| 45 | 45 | return $this->addToProperty("class", "transparent"); |
| 46 | 46 | } |
| 47 | 47 | } |
| 48 | 48 | \ No newline at end of file |
@@ -7,22 +7,22 @@ |
||
| 7 | 7 | */ |
| 8 | 8 | |
| 9 | 9 | // Get the input |
| 10 | -$source = file_get_contents($argv[1]); |
|
| 10 | +$source=file_get_contents($argv[1]); |
|
| 11 | 11 | |
| 12 | 12 | // make traits to classes |
| 13 | -$regexp = '#trait([\s]+[\S]+[\s]*){#'; |
|
| 14 | -$replace = 'class$1{'; |
|
| 15 | -$source = preg_replace($regexp, $replace, $source); |
|
| 13 | +$regexp='#trait([\s]+[\S]+[\s]*){#'; |
|
| 14 | +$replace='class$1{'; |
|
| 15 | +$source=preg_replace($regexp, $replace, $source); |
|
| 16 | 16 | |
| 17 | 17 | // use traits by extending them (classes that not extending a class) |
| 18 | -$regexp = '#class([\s]+[\S]+[\s]*)(implements[\s]+[\S]+[\s]*)?{[\s]+use([^;]+);#'; |
|
| 19 | -$replace = 'class$1 extends $3 $2 {'; |
|
| 20 | -$source = preg_replace($regexp, $replace, $source); |
|
| 18 | +$regexp='#class([\s]+[\S]+[\s]*)(implements[\s]+[\S]+[\s]*)?{[\s]+use([^;]+);#'; |
|
| 19 | +$replace='class$1 extends $3 $2 {'; |
|
| 20 | +$source=preg_replace($regexp, $replace, $source); |
|
| 21 | 21 | |
| 22 | 22 | // use traits by extending them (classes that already extending a class) |
| 23 | -$regexp = '#class([\s]+[\S]+[\s]+extends[\s]+[\S]+[\s]*)(implements[\s]+[\S]+[\s]*)?{[\s]+use([^;]+);#'; |
|
| 24 | -$replace = 'class$1, $3 $2{'; |
|
| 25 | -$source = preg_replace($regexp, $replace, $source); |
|
| 23 | +$regexp='#class([\s]+[\S]+[\s]+extends[\s]+[\S]+[\s]*)(implements[\s]+[\S]+[\s]*)?{[\s]+use([^;]+);#'; |
|
| 24 | +$replace='class$1, $3 $2{'; |
|
| 25 | +$source=preg_replace($regexp, $replace, $source); |
|
| 26 | 26 | |
| 27 | 27 | // Output |
| 28 | 28 | echo $source; |
@@ -14,8 +14,8 @@ discard block |
||
| 14 | 14 | * @property string $identifier |
| 15 | 15 | */ |
| 16 | 16 | trait BaseTrait { |
| 17 | - protected $_variations=[ ]; |
|
| 18 | - protected $_states=[ ]; |
|
| 17 | + protected $_variations=[]; |
|
| 18 | + protected $_states=[]; |
|
| 19 | 19 | protected $_baseClass; |
| 20 | 20 | |
| 21 | 21 | abstract protected function setPropertyCtrl($name, $value, $typeCtrl); |
@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | |
| 29 | 29 | abstract public function setProperty($name, $value); |
| 30 | 30 | |
| 31 | - abstract public function addContent($content,$before=false); |
|
| 31 | + abstract public function addContent($content, $before=false); |
|
| 32 | 32 | |
| 33 | 33 | abstract public function onCreate($jsCode); |
| 34 | 34 | |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | $this->setProperty("class", $this->_baseClass); |
| 50 | 50 | if (\is_string($variations)) |
| 51 | 51 | $variations=\explode(" ", $variations); |
| 52 | - foreach ( $variations as $variation ) { |
|
| 52 | + foreach ($variations as $variation) { |
|
| 53 | 53 | $this->addVariation($variation); |
| 54 | 54 | } |
| 55 | 55 | return $this; |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | public function addVariations($variations=array()) { |
| 64 | 64 | if (\is_string($variations)) |
| 65 | 65 | $variations=\explode(" ", $variations); |
| 66 | - foreach ( $variations as $variation ) { |
|
| 66 | + foreach ($variations as $variation) { |
|
| 67 | 67 | $this->addVariation($variation); |
| 68 | 68 | } |
| 69 | 69 | return $this; |
@@ -72,7 +72,7 @@ discard block |
||
| 72 | 72 | public function addStates($states=array()) { |
| 73 | 73 | if (\is_string($states)) |
| 74 | 74 | $states=\explode(" ", $states); |
| 75 | - foreach ( $states as $state ) { |
|
| 75 | + foreach ($states as $state) { |
|
| 76 | 76 | $this->addState($state); |
| 77 | 77 | } |
| 78 | 78 | return $this; |
@@ -82,17 +82,17 @@ discard block |
||
| 82 | 82 | $this->setProperty("class", $this->_baseClass); |
| 83 | 83 | if (\is_string($states)) |
| 84 | 84 | $states=\explode(" ", $states); |
| 85 | - foreach ( $states as $state ) { |
|
| 85 | + foreach ($states as $state) { |
|
| 86 | 86 | $this->addState($state); |
| 87 | 87 | } |
| 88 | 88 | return $this; |
| 89 | 89 | } |
| 90 | 90 | |
| 91 | 91 | public function addIcon($icon, $before=true) { |
| 92 | - return $this->addContent(new HtmlIcon("icon-" . $this->identifier, $icon), $before); |
|
| 92 | + return $this->addContent(new HtmlIcon("icon-".$this->identifier, $icon), $before); |
|
| 93 | 93 | } |
| 94 | 94 | |
| 95 | - public function addSticky($context="body"){ |
|
| 95 | + public function addSticky($context="body") { |
|
| 96 | 96 | $this->onCreate("$('#".$this->identifier."').sticky({ context: '".$context."'});"); |
| 97 | 97 | return $this; |
| 98 | 98 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | * @return HtmlSemDoubleElement |
| 114 | 114 | */ |
| 115 | 115 | public function setDisabled($disable=true) { |
| 116 | - if($disable) |
|
| 116 | + if ($disable) |
|
| 117 | 117 | $this->addToProperty("class", "disabled"); |
| 118 | 118 | return $this; |
| 119 | 119 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | * |
| 140 | 140 | * @return HtmlSemDoubleElement |
| 141 | 141 | */ |
| 142 | - public function asHeader(){ |
|
| 142 | + public function asHeader() { |
|
| 143 | 143 | return $this->addToProperty("class", "header"); |
| 144 | 144 | } |
| 145 | 145 | |
@@ -147,15 +147,15 @@ discard block |
||
| 147 | 147 | * show it is currently the active user selection |
| 148 | 148 | * @return HtmlSemDoubleElement |
| 149 | 149 | */ |
| 150 | - public function setActive($value=true){ |
|
| 151 | - if($value) |
|
| 150 | + public function setActive($value=true) { |
|
| 151 | + if ($value) |
|
| 152 | 152 | $this->addToProperty("class", "active"); |
| 153 | 153 | return $this; |
| 154 | 154 | } |
| 155 | 155 | |
| 156 | - public function setAttached($value=true){ |
|
| 157 | - if($value) |
|
| 158 | - $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
| 156 | + public function setAttached($value=true) { |
|
| 157 | + if ($value) |
|
| 158 | + $this->addToPropertyCtrl("class", "attached", array("attached")); |
|
| 159 | 159 | return $this; |
| 160 | 160 | } |
| 161 | 161 | |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | } |
| 172 | 172 | |
| 173 | 173 | public function setFloated($direction="right") { |
| 174 | - return $this->addToPropertyCtrl("class", $direction . " floated", Direction::getConstantValues("floated")); |
|
| 174 | + return $this->addToPropertyCtrl("class", $direction." floated", Direction::getConstantValues("floated")); |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | public function floatRight() { |
@@ -186,14 +186,14 @@ discard block |
||
| 186 | 186 | return $this->_baseClass; |
| 187 | 187 | } |
| 188 | 188 | |
| 189 | - protected function addBehavior(&$array,$key,$value,$before="",$after=""){ |
|
| 190 | - if(\is_string($value)){ |
|
| 191 | - if(isset($array[$key])){ |
|
| 189 | + protected function addBehavior(&$array, $key, $value, $before="", $after="") { |
|
| 190 | + if (\is_string($value)) { |
|
| 191 | + if (isset($array[$key])) { |
|
| 192 | 192 | $p=JString::replaceAtFirstAndLast($array[$key], $before, "", $after, ""); |
| 193 | 193 | $array[$key]=$before.$p.$value.$after; |
| 194 | - }else |
|
| 194 | + } else |
|
| 195 | 195 | $array[$key]=$before.$value.$after; |
| 196 | - }else |
|
| 196 | + } else |
|
| 197 | 197 | $array[$key]=$value; |
| 198 | 198 | return $this; |
| 199 | 199 | } |
@@ -47,8 +47,9 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | public function setVariations($variations) { |
| 49 | 49 | $this->setProperty("class", $this->_baseClass); |
| 50 | - if (\is_string($variations)) |
|
| 51 | - $variations=\explode(" ", $variations); |
|
| 50 | + if (\is_string($variations)) { |
|
| 51 | + $variations=\explode(" ", $variations); |
|
| 52 | + } |
|
| 52 | 53 | foreach ( $variations as $variation ) { |
| 53 | 54 | $this->addVariation($variation); |
| 54 | 55 | } |
@@ -61,8 +62,9 @@ discard block |
||
| 61 | 62 | } |
| 62 | 63 | |
| 63 | 64 | public function addVariations($variations=array()) { |
| 64 | - if (\is_string($variations)) |
|
| 65 | - $variations=\explode(" ", $variations); |
|
| 65 | + if (\is_string($variations)) { |
|
| 66 | + $variations=\explode(" ", $variations); |
|
| 67 | + } |
|
| 66 | 68 | foreach ( $variations as $variation ) { |
| 67 | 69 | $this->addVariation($variation); |
| 68 | 70 | } |
@@ -70,8 +72,9 @@ discard block |
||
| 70 | 72 | } |
| 71 | 73 | |
| 72 | 74 | public function addStates($states=array()) { |
| 73 | - if (\is_string($states)) |
|
| 74 | - $states=\explode(" ", $states); |
|
| 75 | + if (\is_string($states)) { |
|
| 76 | + $states=\explode(" ", $states); |
|
| 77 | + } |
|
| 75 | 78 | foreach ( $states as $state ) { |
| 76 | 79 | $this->addState($state); |
| 77 | 80 | } |
@@ -80,8 +83,9 @@ discard block |
||
| 80 | 83 | |
| 81 | 84 | public function setStates($states) { |
| 82 | 85 | $this->setProperty("class", $this->_baseClass); |
| 83 | - if (\is_string($states)) |
|
| 84 | - $states=\explode(" ", $states); |
|
| 86 | + if (\is_string($states)) { |
|
| 87 | + $states=\explode(" ", $states); |
|
| 88 | + } |
|
| 85 | 89 | foreach ( $states as $state ) { |
| 86 | 90 | $this->addState($state); |
| 87 | 91 | } |
@@ -113,8 +117,9 @@ discard block |
||
| 113 | 117 | * @return HtmlSemDoubleElement |
| 114 | 118 | */ |
| 115 | 119 | public function setDisabled($disable=true) { |
| 116 | - if($disable) |
|
| 117 | - $this->addToProperty("class", "disabled"); |
|
| 120 | + if($disable) { |
|
| 121 | + $this->addToProperty("class", "disabled"); |
|
| 122 | + } |
|
| 118 | 123 | return $this; |
| 119 | 124 | } |
| 120 | 125 | |
@@ -148,14 +153,16 @@ discard block |
||
| 148 | 153 | * @return HtmlSemDoubleElement |
| 149 | 154 | */ |
| 150 | 155 | public function setActive($value=true){ |
| 151 | - if($value) |
|
| 152 | - $this->addToProperty("class", "active"); |
|
| 156 | + if($value) { |
|
| 157 | + $this->addToProperty("class", "active"); |
|
| 158 | + } |
|
| 153 | 159 | return $this; |
| 154 | 160 | } |
| 155 | 161 | |
| 156 | 162 | public function setAttached($value=true){ |
| 157 | - if($value) |
|
| 158 | - $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
| 163 | + if($value) { |
|
| 164 | + $this->addToPropertyCtrl("class", "attached", array ("attached" )); |
|
| 165 | + } |
|
| 159 | 166 | return $this; |
| 160 | 167 | } |
| 161 | 168 | |
@@ -191,10 +198,12 @@ discard block |
||
| 191 | 198 | if(isset($array[$key])){ |
| 192 | 199 | $p=JString::replaceAtFirstAndLast($array[$key], $before, "", $after, ""); |
| 193 | 200 | $array[$key]=$before.$p.$value.$after; |
| 194 | - }else |
|
| 195 | - $array[$key]=$before.$value.$after; |
|
| 196 | - }else |
|
| 197 | - $array[$key]=$value; |
|
| 201 | + } else { |
|
| 202 | + $array[$key]=$before.$value.$after; |
|
| 203 | + } |
|
| 204 | + } else { |
|
| 205 | + $array[$key]=$value; |
|
| 206 | + } |
|
| 198 | 207 | return $this; |
| 199 | 208 | } |
| 200 | 209 | } |
| 201 | 210 | \ No newline at end of file |
@@ -63,6 +63,9 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | |
| 65 | 65 | |
| 66 | + /** |
|
| 67 | + * @param string $op |
|
| 68 | + */ |
|
| 66 | 69 | protected function _generateBehavior($op,$params,JsUtils $js){ |
| 67 | 70 | if(isset($this->_urls[$op])){ |
| 68 | 71 | $params=\array_merge($params,["attr"=>"data-ajax"]); |
@@ -139,6 +142,9 @@ discard block |
||
| 139 | 142 | } |
| 140 | 143 | } |
| 141 | 144 | |
| 145 | + /** |
|
| 146 | + * @param string $checkedClass |
|
| 147 | + */ |
|
| 142 | 148 | protected function _generateRow($instance,&$table,$checkedClass=null){ |
| 143 | 149 | $this->_instanceViewer->setInstance($instance); |
| 144 | 150 | InstanceViewer::$index++; |
@@ -215,6 +221,9 @@ discard block |
||
| 215 | 221 | return $this; |
| 216 | 222 | } |
| 217 | 223 | |
| 224 | + /** |
|
| 225 | + * @param PositionInTable $part |
|
| 226 | + */ |
|
| 218 | 227 | private function addToolbarRow($part,$table,$captions){ |
| 219 | 228 | $hasPart=$table->hasPart($part); |
| 220 | 229 | if($hasPart){ |
@@ -254,7 +263,7 @@ discard block |
||
| 254 | 263 | * Paginates the DataTable element with a Semantic HtmlPaginationMenu component |
| 255 | 264 | * @param number $page the active page number |
| 256 | 265 | * @param number $total_rowcount the total number of items |
| 257 | - * @param number $items_per_page The number of items per page |
|
| 266 | + * @param integer $items_per_page The number of items per page |
|
| 258 | 267 | * @param number $pages_visibles The number of visible pages in the Pagination component |
| 259 | 268 | * @return DataTable |
| 260 | 269 | */ |
@@ -265,9 +274,9 @@ discard block |
||
| 265 | 274 | |
| 266 | 275 | /** |
| 267 | 276 | * Auto Paginates the DataTable element with a Semantic HtmlPaginationMenu component |
| 268 | - * @param number $page the active page number |
|
| 269 | - * @param number $items_per_page The number of items per page |
|
| 270 | - * @param number $pages_visibles The number of visible pages in the Pagination component |
|
| 277 | + * @param integer $page the active page number |
|
| 278 | + * @param integer $items_per_page The number of items per page |
|
| 279 | + * @param integer $pages_visibles The number of visible pages in the Pagination component |
|
| 271 | 280 | * @return DataTable |
| 272 | 281 | */ |
| 273 | 282 | public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){ |
@@ -333,6 +342,9 @@ discard block |
||
| 333 | 342 | return $this; |
| 334 | 343 | } |
| 335 | 344 | |
| 345 | + /** |
|
| 346 | + * @return string |
|
| 347 | + */ |
|
| 336 | 348 | public function getRefreshSelector() { |
| 337 | 349 | if(isset($this->_refreshSelector)) |
| 338 | 350 | return $this->_refreshSelector; |
@@ -23,7 +23,7 @@ discard block |
||
| 23 | 23 | * |
| 24 | 24 | */ |
| 25 | 25 | class DataTable extends Widget { |
| 26 | - use TableTrait,DataTableFieldAsTrait,HasCheckboxesTrait; |
|
| 26 | + use TableTrait, DataTableFieldAsTrait, HasCheckboxesTrait; |
|
| 27 | 27 | protected $_searchField; |
| 28 | 28 | protected $_urls; |
| 29 | 29 | protected $_pagination; |
@@ -40,35 +40,35 @@ discard block |
||
| 40 | 40 | protected $_hiddenColumns; |
| 41 | 41 | |
| 42 | 42 | |
| 43 | - public function __construct($identifier,$model,$modelInstance=NULL) { |
|
| 44 | - parent::__construct($identifier, $model,$modelInstance); |
|
| 45 | - $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0,0), false); |
|
| 43 | + public function __construct($identifier, $model, $modelInstance=NULL) { |
|
| 44 | + parent::__construct($identifier, $model, $modelInstance); |
|
| 45 | + $this->_init(new InstanceViewer($identifier), "table", new HtmlTable($identifier, 0, 0), false); |
|
| 46 | 46 | $this->_urls=[]; |
| 47 | - $this->_emptyMessage=new HtmlMessage("","nothing to display"); |
|
| 47 | + $this->_emptyMessage=new HtmlMessage("", "nothing to display"); |
|
| 48 | 48 | $this->_emptyMessage->setIcon("info circle"); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function run(JsUtils $js){ |
|
| 52 | - if($this->_hasCheckboxes && isset($js)){ |
|
| 51 | + public function run(JsUtils $js) { |
|
| 52 | + if ($this->_hasCheckboxes && isset($js)) { |
|
| 53 | 53 | $this->_runCheckboxes($js); |
| 54 | 54 | } |
| 55 | - if($this->_visibleHover){ |
|
| 56 | - $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
| 57 | - $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
|
| 55 | + if ($this->_visibleHover) { |
|
| 56 | + $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
| 57 | + $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');", ["preventDefault"=>false, "stopPropagation"=>true]); |
|
| 58 | 58 | } |
| 59 | - if(\is_array($this->_deleteBehavior)) |
|
| 60 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
| 61 | - if(\is_array($this->_editBehavior)) |
|
| 62 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
| 59 | + if (\is_array($this->_deleteBehavior)) |
|
| 60 | + $this->_generateBehavior("delete", $this->_deleteBehavior, $js); |
|
| 61 | + if (\is_array($this->_editBehavior)) |
|
| 62 | + $this->_generateBehavior("edit", $this->_editBehavior, $js); |
|
| 63 | 63 | return parent::run($js); |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | |
| 67 | 67 | |
| 68 | - protected function _generateBehavior($op,$params,JsUtils $js){ |
|
| 69 | - if(isset($this->_urls[$op])){ |
|
| 70 | - $params=\array_merge($params,["attr"=>"data-ajax"]); |
|
| 71 | - $js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op],$this->getTargetSelector(),$params); |
|
| 68 | + protected function _generateBehavior($op, $params, JsUtils $js) { |
|
| 69 | + if (isset($this->_urls[$op])) { |
|
| 70 | + $params=\array_merge($params, ["attr"=>"data-ajax"]); |
|
| 71 | + $js->getOnClick("#".$this->identifier." ._".$op, $this->_urls[$op], $this->getTargetSelector(), $params); |
|
| 72 | 72 | } |
| 73 | 73 | } |
| 74 | 74 | |
@@ -81,146 +81,146 @@ discard block |
||
| 81 | 81 | } |
| 82 | 82 | |
| 83 | 83 | |
| 84 | - public function compile(JsUtils $js=NULL,&$view=NULL){ |
|
| 85 | - if(!$this->_generated){ |
|
| 84 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
| 85 | + if (!$this->_generated) { |
|
| 86 | 86 | $this->_instanceViewer->setInstance($this->_model); |
| 87 | 87 | $captions=$this->_instanceViewer->getCaptions(); |
| 88 | 88 | |
| 89 | 89 | $table=$this->content["table"]; |
| 90 | 90 | |
| 91 | - if($this->_hasCheckboxes){ |
|
| 91 | + if ($this->_hasCheckboxes) { |
|
| 92 | 92 | $this->_generateMainCheckbox($captions); |
| 93 | 93 | } |
| 94 | 94 | |
| 95 | 95 | $table->setRowCount(0, \sizeof($captions)); |
| 96 | - $this->_generateHeader($table,$captions); |
|
| 96 | + $this->_generateHeader($table, $captions); |
|
| 97 | 97 | |
| 98 | - if(isset($this->_compileParts)) |
|
| 98 | + if (isset($this->_compileParts)) |
|
| 99 | 99 | $table->setCompileParts($this->_compileParts); |
| 100 | 100 | |
| 101 | - if(isset($this->_searchField) && isset($js)){ |
|
| 102 | - if(isset($this->_urls["refresh"])) |
|
| 103 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
| 101 | + if (isset($this->_searchField) && isset($js)) { |
|
| 102 | + if (isset($this->_urls["refresh"])) |
|
| 103 | + $this->_searchField->postOn("change", $this->_urls["refresh"], "{'s':$(this).val()}", "#".$this->identifier." tbody", ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | $this->_generateContent($table); |
| 107 | 107 | |
| 108 | - if($this->_hasCheckboxes && $table->hasPart("thead")){ |
|
| 108 | + if ($this->_hasCheckboxes && $table->hasPart("thead")) { |
|
| 109 | 109 | $table->getHeader()->getCell(0, 0)->addClass("no-sort"); |
| 110 | 110 | } |
| 111 | 111 | |
| 112 | - if(isset($this->_toolbar)){ |
|
| 112 | + if (isset($this->_toolbar)) { |
|
| 113 | 113 | $this->_setToolbarPosition($table, $captions); |
| 114 | 114 | } |
| 115 | - if(isset($this->_pagination) && $this->_pagination->getVisible()){ |
|
| 116 | - $this->_generatePagination($table,$js); |
|
| 115 | + if (isset($this->_pagination) && $this->_pagination->getVisible()) { |
|
| 116 | + $this->_generatePagination($table, $js); |
|
| 117 | 117 | } |
| 118 | 118 | |
| 119 | - $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
|
| 119 | + $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE, "table", PositionInTable::AFTERTABLE]); |
|
| 120 | 120 | $this->_compileForm(); |
| 121 | - if(isset($this->_hiddenColumns)) |
|
| 121 | + if (isset($this->_hiddenColumns)) |
|
| 122 | 122 | $this->_hideColumns(); |
| 123 | 123 | $this->_generated=true; |
| 124 | 124 | } |
| 125 | - return parent::compile($js,$view); |
|
| 125 | + return parent::compile($js, $view); |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | - protected function _hideColumns(){ |
|
| 128 | + protected function _hideColumns() { |
|
| 129 | 129 | $table=$this->getTable(); |
| 130 | - foreach ($this->_hiddenColumns as $colIndex){ |
|
| 130 | + foreach ($this->_hiddenColumns as $colIndex) { |
|
| 131 | 131 | $table->hideColumn($colIndex); |
| 132 | 132 | } |
| 133 | 133 | return $this; |
| 134 | 134 | } |
| 135 | 135 | |
| 136 | - protected function _generateHeader(HtmlTable $table,$captions){ |
|
| 136 | + protected function _generateHeader(HtmlTable $table, $captions) { |
|
| 137 | 137 | $table->setHeaderValues($captions); |
| 138 | - if(isset($this->_sortable)){ |
|
| 138 | + if (isset($this->_sortable)) { |
|
| 139 | 139 | $table->setSortable($this->_sortable); |
| 140 | 140 | } |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | 143 | |
| 144 | 144 | |
| 145 | - protected function _generateContent($table){ |
|
| 145 | + protected function _generateContent($table) { |
|
| 146 | 146 | $objects=$this->_modelInstance; |
| 147 | - if(isset($this->_pagination)){ |
|
| 147 | + if (isset($this->_pagination)) { |
|
| 148 | 148 | $objects=$this->_pagination->getObjects($this->_modelInstance); |
| 149 | 149 | } |
| 150 | 150 | InstanceViewer::setIndex(0); |
| 151 | 151 | $table->fromDatabaseObjects($objects, function($instance) use($table){ |
| 152 | 152 | return $this->_generateRow($instance, $table); |
| 153 | 153 | }); |
| 154 | - if($table->getRowCount()==0){ |
|
| 154 | + if ($table->getRowCount()==0) { |
|
| 155 | 155 | $result=$table->addRow(); |
| 156 | 156 | $result->mergeRow(); |
| 157 | 157 | $result->setValues([$this->_emptyMessage]); |
| 158 | 158 | } |
| 159 | 159 | } |
| 160 | 160 | |
| 161 | - protected function _generateRow($instance,&$table,$checkedClass=null){ |
|
| 161 | + protected function _generateRow($instance, &$table, $checkedClass=null) { |
|
| 162 | 162 | $this->_instanceViewer->setInstance($instance); |
| 163 | 163 | InstanceViewer::$index++; |
| 164 | - $values= $this->_instanceViewer->getValues(); |
|
| 164 | + $values=$this->_instanceViewer->getValues(); |
|
| 165 | 165 | $id=$this->_instanceViewer->getIdentifier(); |
| 166 | - if($this->_hasCheckboxes){ |
|
| 167 | - $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id,""); |
|
| 166 | + if ($this->_hasCheckboxes) { |
|
| 167 | + $ck=new HtmlCheckbox("ck-".$this->identifier."-".$id, ""); |
|
| 168 | 168 | $ck->setOnChange("event.stopPropagation();"); |
| 169 | 169 | $field=$ck->getField(); |
| 170 | - $field->setProperty("value",$id); |
|
| 170 | + $field->setProperty("value", $id); |
|
| 171 | 171 | $field->setProperty("name", "selection[]"); |
| 172 | - if(isset($checkedClass)) |
|
| 172 | + if (isset($checkedClass)) |
|
| 173 | 173 | $field->setClass($checkedClass); |
| 174 | 174 | \array_unshift($values, $ck); |
| 175 | 175 | } |
| 176 | 176 | $result=$table->newRow(); |
| 177 | 177 | $result->setIdentifier($this->identifier."-tr-".$id); |
| 178 | - $result->setProperty("data-ajax",$id); |
|
| 178 | + $result->setProperty("data-ajax", $id); |
|
| 179 | 179 | $result->setValues($values); |
| 180 | - $result->addToProperty("class",$this->_rowClass); |
|
| 180 | + $result->addToProperty("class", $this->_rowClass); |
|
| 181 | 181 | return $result; |
| 182 | 182 | } |
| 183 | 183 | |
| 184 | - protected function _generatePagination($table,$js=NULL){ |
|
| 185 | - if(isset($this->_toolbar)){ |
|
| 186 | - if($this->_toolbarPosition==PositionInTable::FOOTER) |
|
| 184 | + protected function _generatePagination($table, $js=NULL) { |
|
| 185 | + if (isset($this->_toolbar)) { |
|
| 186 | + if ($this->_toolbarPosition==PositionInTable::FOOTER) |
|
| 187 | 187 | $this->_toolbar->setFloated("left"); |
| 188 | 188 | } |
| 189 | 189 | $footer=$table->getFooter(); |
| 190 | 190 | $footer->mergeCol(); |
| 191 | - $menu=new HtmlPaginationMenu("pagination-".$this->identifier,$this->_pagination->getPagesNumbers()); |
|
| 191 | + $menu=new HtmlPaginationMenu("pagination-".$this->identifier, $this->_pagination->getPagesNumbers()); |
|
| 192 | 192 | $menu->floatRight(); |
| 193 | 193 | $menu->setActiveItem($this->_pagination->getPage()-1); |
| 194 | 194 | $footer->addValues($menu); |
| 195 | - $this->_associatePaginationBehavior($menu,$js); |
|
| 195 | + $this->_associatePaginationBehavior($menu, $js); |
|
| 196 | 196 | } |
| 197 | 197 | |
| 198 | - protected function _associatePaginationBehavior(HtmlMenu $menu,JsUtils $js=NULL){ |
|
| 199 | - if(isset($this->_urls["refresh"])){ |
|
| 200 | - $menu->postOnClick($this->_urls["refresh"],"{'p':$(this).attr('data-page')}",$this->getRefreshSelector(),["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
| 198 | + protected function _associatePaginationBehavior(HtmlMenu $menu, JsUtils $js=NULL) { |
|
| 199 | + if (isset($this->_urls["refresh"])) { |
|
| 200 | + $menu->postOnClick($this->_urls["refresh"], "{'p':$(this).attr('data-page')}", $this->getRefreshSelector(), ["preventDefault"=>false, "jqueryDone"=>"replaceWith"]); |
|
| 201 | 201 | } |
| 202 | 202 | } |
| 203 | 203 | |
| 204 | - protected function _getFieldName($index){ |
|
| 204 | + protected function _getFieldName($index) { |
|
| 205 | 205 | return parent::_getFieldName($index)."[]"; |
| 206 | 206 | } |
| 207 | 207 | |
| 208 | - protected function _getFieldCaption($index){ |
|
| 208 | + protected function _getFieldCaption($index) { |
|
| 209 | 209 | return null; |
| 210 | 210 | } |
| 211 | 211 | |
| 212 | - protected function _setToolbarPosition($table,$captions=NULL){ |
|
| 213 | - switch ($this->_toolbarPosition){ |
|
| 212 | + protected function _setToolbarPosition($table, $captions=NULL) { |
|
| 213 | + switch ($this->_toolbarPosition) { |
|
| 214 | 214 | case PositionInTable::BEFORETABLE: |
| 215 | 215 | case PositionInTable::AFTERTABLE: |
| 216 | - if(isset($this->_compileParts)===false){ |
|
| 216 | + if (isset($this->_compileParts)===false) { |
|
| 217 | 217 | $this->content[$this->_toolbarPosition]=$this->_toolbar; |
| 218 | 218 | } |
| 219 | 219 | break; |
| 220 | 220 | case PositionInTable::HEADER: |
| 221 | 221 | case PositionInTable::FOOTER: |
| 222 | 222 | case PositionInTable::BODY: |
| 223 | - $this->addToolbarRow($this->_toolbarPosition,$table, $captions); |
|
| 223 | + $this->addToolbarRow($this->_toolbarPosition, $table, $captions); |
|
| 224 | 224 | break; |
| 225 | 225 | } |
| 226 | 226 | } |
@@ -232,23 +232,23 @@ discard block |
||
| 232 | 232 | * @param callable $callback function called after the field compilation |
| 233 | 233 | * @return DataTable |
| 234 | 234 | */ |
| 235 | - public function afterCompile($index,$callback){ |
|
| 236 | - $this->_instanceViewer->afterCompile($index,$callback); |
|
| 235 | + public function afterCompile($index, $callback) { |
|
| 236 | + $this->_instanceViewer->afterCompile($index, $callback); |
|
| 237 | 237 | return $this; |
| 238 | 238 | } |
| 239 | 239 | |
| 240 | - private function addToolbarRow($part,$table,$captions){ |
|
| 240 | + private function addToolbarRow($part, $table, $captions) { |
|
| 241 | 241 | $hasPart=$table->hasPart($part); |
| 242 | - if($hasPart){ |
|
| 242 | + if ($hasPart) { |
|
| 243 | 243 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
| 244 | - }else{ |
|
| 244 | + } else { |
|
| 245 | 245 | $row=$table->getPart($part)->getRow(0); |
| 246 | 246 | } |
| 247 | 247 | $row->mergeCol(); |
| 248 | 248 | $row->setValues([$this->_toolbar]); |
| 249 | 249 | } |
| 250 | 250 | |
| 251 | - public function getHtmlComponent(){ |
|
| 251 | + public function getHtmlComponent() { |
|
| 252 | 252 | return $this->content["table"]; |
| 253 | 253 | } |
| 254 | 254 | |
@@ -262,12 +262,12 @@ discard block |
||
| 262 | 262 | * @return DataTable |
| 263 | 263 | */ |
| 264 | 264 | public function setUrls($urls) { |
| 265 | - if(\is_array($urls)){ |
|
| 266 | - $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
|
| 267 | - $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
|
| 268 | - $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
|
| 269 | - }else{ |
|
| 270 | - $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
|
| 265 | + if (\is_array($urls)) { |
|
| 266 | + $this->_urls["refresh"]=JArray::getValue($urls, "refresh", 0); |
|
| 267 | + $this->_urls["edit"]=JArray::getValue($urls, "edit", 1); |
|
| 268 | + $this->_urls["delete"]=JArray::getValue($urls, "delete", 2); |
|
| 269 | + } else { |
|
| 270 | + $this->_urls=["refresh"=>$urls, "edit"=>$urls, "delete"=>$urls]; |
|
| 271 | 271 | } |
| 272 | 272 | return $this; |
| 273 | 273 | } |
@@ -280,8 +280,8 @@ discard block |
||
| 280 | 280 | * @param number $pages_visibles The number of visible pages in the Pagination component |
| 281 | 281 | * @return DataTable |
| 282 | 282 | */ |
| 283 | - public function paginate($page,$total_rowcount,$items_per_page=10,$pages_visibles=null){ |
|
| 284 | - $this->_pagination=new Pagination($items_per_page,$pages_visibles,$page,$total_rowcount); |
|
| 283 | + public function paginate($page, $total_rowcount, $items_per_page=10, $pages_visibles=null) { |
|
| 284 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page, $total_rowcount); |
|
| 285 | 285 | return $this; |
| 286 | 286 | } |
| 287 | 287 | |
@@ -292,8 +292,8 @@ discard block |
||
| 292 | 292 | * @param number $pages_visibles The number of visible pages in the Pagination component |
| 293 | 293 | * @return DataTable |
| 294 | 294 | */ |
| 295 | - public function autoPaginate($page=1,$items_per_page=10,$pages_visibles=4){ |
|
| 296 | - $this->_pagination=new Pagination($items_per_page,$pages_visibles,$page); |
|
| 295 | + public function autoPaginate($page=1, $items_per_page=10, $pages_visibles=4) { |
|
| 296 | + $this->_pagination=new Pagination($items_per_page, $pages_visibles, $page); |
|
| 297 | 297 | return $this; |
| 298 | 298 | } |
| 299 | 299 | |
@@ -303,20 +303,20 @@ discard block |
||
| 303 | 303 | * @param array $compileParts |
| 304 | 304 | * @return DataTable |
| 305 | 305 | */ |
| 306 | - public function refresh($compileParts=["tbody"]){ |
|
| 306 | + public function refresh($compileParts=["tbody"]) { |
|
| 307 | 307 | $this->_compileParts=$compileParts; |
| 308 | 308 | return $this; |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | 311 | |
| 312 | - public function addSearchInToolbar($position=Direction::RIGHT){ |
|
| 312 | + public function addSearchInToolbar($position=Direction::RIGHT) { |
|
| 313 | 313 | return $this->addInToolbar($this->getSearchField())->setPosition($position); |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | - public function getSearchField(){ |
|
| 317 | - if(isset($this->_searchField)===false){ |
|
| 318 | - $this->_searchField=new HtmlInput("search-".$this->identifier,"search","","Search..."); |
|
| 319 | - $this->_searchField->addIcon("search",Direction::RIGHT); |
|
| 316 | + public function getSearchField() { |
|
| 317 | + if (isset($this->_searchField)===false) { |
|
| 318 | + $this->_searchField=new HtmlInput("search-".$this->identifier, "search", "", "Search..."); |
|
| 319 | + $this->_searchField->addIcon("search", Direction::RIGHT); |
|
| 320 | 320 | } |
| 321 | 321 | return $this->_searchField; |
| 322 | 322 | } |
@@ -332,7 +332,7 @@ discard block |
||
| 332 | 332 | return $this; |
| 333 | 333 | } |
| 334 | 334 | |
| 335 | - public function asForm(){ |
|
| 335 | + public function asForm() { |
|
| 336 | 336 | return $this->getForm(); |
| 337 | 337 | } |
| 338 | 338 | |
@@ -340,7 +340,7 @@ discard block |
||
| 340 | 340 | |
| 341 | 341 | protected function getTargetSelector() { |
| 342 | 342 | $result=$this->_targetSelector; |
| 343 | - if(!isset($result)) |
|
| 343 | + if (!isset($result)) |
|
| 344 | 344 | $result="#".$this->identifier; |
| 345 | 345 | return $result; |
| 346 | 346 | } |
@@ -356,7 +356,7 @@ discard block |
||
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | public function getRefreshSelector() { |
| 359 | - if(isset($this->_refreshSelector)) |
|
| 359 | + if (isset($this->_refreshSelector)) |
|
| 360 | 360 | return $this->_refreshSelector; |
| 361 | 361 | return "#".$this->identifier." tbody"; |
| 362 | 362 | } |
@@ -374,9 +374,9 @@ discard block |
||
| 374 | 374 | * {@inheritDoc} |
| 375 | 375 | * @see \Ajax\common\Widget::show() |
| 376 | 376 | */ |
| 377 | - public function show($modelInstance){ |
|
| 378 | - if(\is_array($modelInstance)){ |
|
| 379 | - if(\is_array(array_values($modelInstance)[0])) |
|
| 377 | + public function show($modelInstance) { |
|
| 378 | + if (\is_array($modelInstance)) { |
|
| 379 | + if (\is_array(array_values($modelInstance)[0])) |
|
| 380 | 380 | $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
| 381 | 381 | } |
| 382 | 382 | $this->_modelInstance=$modelInstance; |
@@ -411,13 +411,13 @@ discard block |
||
| 411 | 411 | return $this; |
| 412 | 412 | } |
| 413 | 413 | |
| 414 | - public function setActiveRowSelector($class="active",$event="click",$multiple=false){ |
|
| 415 | - $this->getTable()->setActiveRowSelector($class,$event,$multiple); |
|
| 414 | + public function setActiveRowSelector($class="active", $event="click", $multiple=false) { |
|
| 415 | + $this->getTable()->setActiveRowSelector($class, $event, $multiple); |
|
| 416 | 416 | return $this; |
| 417 | 417 | } |
| 418 | 418 | |
| 419 | - public function hideColumn($colIndex){ |
|
| 420 | - if(!\is_array($this->_hiddenColumns)) |
|
| 419 | + public function hideColumn($colIndex) { |
|
| 420 | + if (!\is_array($this->_hiddenColumns)) |
|
| 421 | 421 | $this->_hiddenColumns=[]; |
| 422 | 422 | $this->_hiddenColumns[]=$colIndex; |
| 423 | 423 | return $this; |
@@ -56,10 +56,12 @@ discard block |
||
| 56 | 56 | $js->execOn("mouseover", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'visible');",["preventDefault"=>false,"stopPropagation"=>true]); |
| 57 | 57 | $js->execOn("mouseout", "#".$this->identifier." tr", "$(event.target).closest('tr').find('.visibleover').css('visibility', 'hidden');",["preventDefault"=>false,"stopPropagation"=>true]); |
| 58 | 58 | } |
| 59 | - if(\is_array($this->_deleteBehavior)) |
|
| 60 | - $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
| 61 | - if(\is_array($this->_editBehavior)) |
|
| 62 | - $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
| 59 | + if(\is_array($this->_deleteBehavior)) { |
|
| 60 | + $this->_generateBehavior("delete",$this->_deleteBehavior, $js); |
|
| 61 | + } |
|
| 62 | + if(\is_array($this->_editBehavior)) { |
|
| 63 | + $this->_generateBehavior("edit",$this->_editBehavior,$js); |
|
| 64 | + } |
|
| 63 | 65 | return parent::run($js); |
| 64 | 66 | } |
| 65 | 67 | |
@@ -95,12 +97,14 @@ discard block |
||
| 95 | 97 | $table->setRowCount(0, \sizeof($captions)); |
| 96 | 98 | $this->_generateHeader($table,$captions); |
| 97 | 99 | |
| 98 | - if(isset($this->_compileParts)) |
|
| 99 | - $table->setCompileParts($this->_compileParts); |
|
| 100 | + if(isset($this->_compileParts)) { |
|
| 101 | + $table->setCompileParts($this->_compileParts); |
|
| 102 | + } |
|
| 100 | 103 | |
| 101 | 104 | if(isset($this->_searchField) && isset($js)){ |
| 102 | - if(isset($this->_urls["refresh"])) |
|
| 103 | - $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
| 105 | + if(isset($this->_urls["refresh"])) { |
|
| 106 | + $this->_searchField->postOn("change", $this->_urls["refresh"],"{'s':$(this).val()}","#".$this->identifier." tbody",["preventDefault"=>false,"jqueryDone"=>"replaceWith"]); |
|
| 107 | + } |
|
| 104 | 108 | } |
| 105 | 109 | |
| 106 | 110 | $this->_generateContent($table); |
@@ -118,8 +122,9 @@ discard block |
||
| 118 | 122 | |
| 119 | 123 | $this->content=JArray::sortAssociative($this->content, [PositionInTable::BEFORETABLE,"table",PositionInTable::AFTERTABLE]); |
| 120 | 124 | $this->_compileForm(); |
| 121 | - if(isset($this->_hiddenColumns)) |
|
| 122 | - $this->_hideColumns(); |
|
| 125 | + if(isset($this->_hiddenColumns)) { |
|
| 126 | + $this->_hideColumns(); |
|
| 127 | + } |
|
| 123 | 128 | $this->_generated=true; |
| 124 | 129 | } |
| 125 | 130 | return parent::compile($js,$view); |
@@ -169,8 +174,9 @@ discard block |
||
| 169 | 174 | $field=$ck->getField(); |
| 170 | 175 | $field->setProperty("value",$id); |
| 171 | 176 | $field->setProperty("name", "selection[]"); |
| 172 | - if(isset($checkedClass)) |
|
| 173 | - $field->setClass($checkedClass); |
|
| 177 | + if(isset($checkedClass)) { |
|
| 178 | + $field->setClass($checkedClass); |
|
| 179 | + } |
|
| 174 | 180 | \array_unshift($values, $ck); |
| 175 | 181 | } |
| 176 | 182 | $result=$table->newRow(); |
@@ -183,8 +189,9 @@ discard block |
||
| 183 | 189 | |
| 184 | 190 | protected function _generatePagination($table,$js=NULL){ |
| 185 | 191 | if(isset($this->_toolbar)){ |
| 186 | - if($this->_toolbarPosition==PositionInTable::FOOTER) |
|
| 187 | - $this->_toolbar->setFloated("left"); |
|
| 192 | + if($this->_toolbarPosition==PositionInTable::FOOTER) { |
|
| 193 | + $this->_toolbar->setFloated("left"); |
|
| 194 | + } |
|
| 188 | 195 | } |
| 189 | 196 | $footer=$table->getFooter(); |
| 190 | 197 | $footer->mergeCol(); |
@@ -241,7 +248,7 @@ discard block |
||
| 241 | 248 | $hasPart=$table->hasPart($part); |
| 242 | 249 | if($hasPart){ |
| 243 | 250 | $row=$table->getPart($part)->addRow(\sizeof($captions)); |
| 244 | - }else{ |
|
| 251 | + } else{ |
|
| 245 | 252 | $row=$table->getPart($part)->getRow(0); |
| 246 | 253 | } |
| 247 | 254 | $row->mergeCol(); |
@@ -266,7 +273,7 @@ discard block |
||
| 266 | 273 | $this->_urls["refresh"]=JArray::getValue($urls, "refresh",0); |
| 267 | 274 | $this->_urls["edit"]=JArray::getValue($urls, "edit",1); |
| 268 | 275 | $this->_urls["delete"]=JArray::getValue($urls, "delete",2); |
| 269 | - }else{ |
|
| 276 | + } else{ |
|
| 270 | 277 | $this->_urls=["refresh"=>$urls,"edit"=>$urls,"delete"=>$urls]; |
| 271 | 278 | } |
| 272 | 279 | return $this; |
@@ -340,8 +347,9 @@ discard block |
||
| 340 | 347 | |
| 341 | 348 | protected function getTargetSelector() { |
| 342 | 349 | $result=$this->_targetSelector; |
| 343 | - if(!isset($result)) |
|
| 344 | - $result="#".$this->identifier; |
|
| 350 | + if(!isset($result)) { |
|
| 351 | + $result="#".$this->identifier; |
|
| 352 | + } |
|
| 345 | 353 | return $result; |
| 346 | 354 | } |
| 347 | 355 | |
@@ -356,8 +364,9 @@ discard block |
||
| 356 | 364 | } |
| 357 | 365 | |
| 358 | 366 | public function getRefreshSelector() { |
| 359 | - if(isset($this->_refreshSelector)) |
|
| 360 | - return $this->_refreshSelector; |
|
| 367 | + if(isset($this->_refreshSelector)) { |
|
| 368 | + return $this->_refreshSelector; |
|
| 369 | + } |
|
| 361 | 370 | return "#".$this->identifier." tbody"; |
| 362 | 371 | } |
| 363 | 372 | |
@@ -376,8 +385,9 @@ discard block |
||
| 376 | 385 | */ |
| 377 | 386 | public function show($modelInstance){ |
| 378 | 387 | if(\is_array($modelInstance)){ |
| 379 | - if(\is_array(array_values($modelInstance)[0])) |
|
| 380 | - $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
|
| 388 | + if(\is_array(array_values($modelInstance)[0])) { |
|
| 389 | + $modelInstance=\json_decode(\json_encode($modelInstance), FALSE); |
|
| 390 | + } |
|
| 381 | 391 | } |
| 382 | 392 | $this->_modelInstance=$modelInstance; |
| 383 | 393 | } |
@@ -417,8 +427,9 @@ discard block |
||
| 417 | 427 | } |
| 418 | 428 | |
| 419 | 429 | public function hideColumn($colIndex){ |
| 420 | - if(!\is_array($this->_hiddenColumns)) |
|
| 421 | - $this->_hiddenColumns=[]; |
|
| 430 | + if(!\is_array($this->_hiddenColumns)) { |
|
| 431 | + $this->_hiddenColumns=[]; |
|
| 432 | + } |
|
| 422 | 433 | $this->_hiddenColumns[]=$colIndex; |
| 423 | 434 | return $this; |
| 424 | 435 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | protected $ajaxTransition; |
| 18 | 18 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
| 19 | 19 | |
| 20 | - abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
| 20 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
| 21 | 21 | protected function addLoading(&$retour, $responseElement) { |
| 22 | 22 | $loading_notifier='<div class="ajax-loader">'; |
| 23 | 23 | if ($this->ajaxLoader=='') { |
@@ -30,66 +30,66 @@ discard block |
||
| 30 | 30 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
| 34 | - return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly); |
|
| 33 | + public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
| 34 | + return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly); |
|
| 35 | 35 | } |
| 36 | - public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
| 37 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$jqueryDone,$ajaxTransition,$immediatly); |
|
| 36 | + public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
| 37 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, $immediatly); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | - protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
| 41 | - if(JString::isNull($params)){$params="{}";} |
|
| 40 | + protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
| 41 | + if (JString::isNull($params)) {$params="{}"; } |
|
| 42 | 42 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 43 | 43 | $retour=$this->_getAjaxUrl($url, $attr); |
| 44 | 44 | $responseElement=$this->_getResponseElement($responseElement); |
| 45 | 45 | $retour.="var self=this;\n"; |
| 46 | - if($hasLoader===true){ |
|
| 46 | + if ($hasLoader===true) { |
|
| 47 | 47 | $this->addLoading($retour, $responseElement); |
| 48 | 48 | } |
| 49 | 49 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
| 50 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
|
| 50 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n"; |
|
| 51 | 51 | if ($immediatly) |
| 52 | 52 | $this->jquery_code_for_compile[]=$retour; |
| 53 | 53 | return $retour; |
| 54 | 54 | } |
| 55 | 55 | |
| 56 | - protected function setAjaxDataCall($params){ |
|
| 56 | + protected function setAjaxDataCall($params) { |
|
| 57 | 57 | $result=null; |
| 58 | - if(!\is_callable($params)){ |
|
| 59 | - $result=function ($responseElement,$jqueryDone="html") use($params){ |
|
| 60 | - return AjaxTransition::{$params}($responseElement,$jqueryDone); |
|
| 58 | + if (!\is_callable($params)) { |
|
| 59 | + $result=function($responseElement, $jqueryDone="html") use($params){ |
|
| 60 | + return AjaxTransition::{$params}($responseElement, $jqueryDone); |
|
| 61 | 61 | }; |
| 62 | 62 | } |
| 63 | 63 | return $result; |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - protected function _getAjaxUrl($url,$attr){ |
|
| 66 | + protected function _getAjaxUrl($url, $attr) { |
|
| 67 | 67 | $url=$this->_correctAjaxUrl($url); |
| 68 | 68 | $retour="url='".$url."';"; |
| 69 | 69 | $slash="/"; |
| 70 | - if(JString::endswith($url, "/")===true) |
|
| 70 | + if (JString::endswith($url, "/")===true) |
|
| 71 | 71 | $slash=""; |
| 72 | - if(JString::isNotNull($attr)){ |
|
| 72 | + if (JString::isNotNull($attr)) { |
|
| 73 | 73 | if ($attr==="value") |
| 74 | 74 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
| 75 | 75 | elseif ($attr==="html") |
| 76 | 76 | $retour.="url=url+'".$slash."'+$(this).html();\n"; |
| 77 | - elseif($attr!=null && $attr!=="") |
|
| 77 | + elseif ($attr!=null && $attr!=="") |
|
| 78 | 78 | $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
| 79 | 79 | } |
| 80 | 80 | return $retour; |
| 81 | 81 | } |
| 82 | 82 | |
| 83 | - protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$jsCallback){ |
|
| 84 | - $retour="";$call=null; |
|
| 83 | + protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback) { |
|
| 84 | + $retour=""; $call=null; |
|
| 85 | 85 | if ($responseElement!=="") { |
| 86 | - if(isset($ajaxTransition)){ |
|
| 86 | + if (isset($ajaxTransition)) { |
|
| 87 | 87 | $call=$this->setAjaxDataCall($ajaxTransition); |
| 88 | - }elseif(isset($this->ajaxTransition)){ |
|
| 88 | + }elseif (isset($this->ajaxTransition)) { |
|
| 89 | 89 | $call=$this->ajaxTransition; |
| 90 | 90 | } |
| 91 | - if(\is_callable($call)) |
|
| 92 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
| 91 | + if (\is_callable($call)) |
|
| 92 | + $retour="\t".$call($responseElement, $jqueryDone).";\n"; |
|
| 93 | 93 | else |
| 94 | 94 | $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
| 95 | 95 | } |
@@ -97,7 +97,7 @@ discard block |
||
| 97 | 97 | return $retour; |
| 98 | 98 | } |
| 99 | 99 | |
| 100 | - protected function _getResponseElement($responseElement){ |
|
| 100 | + protected function _getResponseElement($responseElement) { |
|
| 101 | 101 | if ($responseElement!=="") { |
| 102 | 102 | $responseElement=Javascript::prep_value($responseElement); |
| 103 | 103 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | protected function _correctAjaxUrl($url) { |
| 108 | 108 | if ($url!=="/" && JString::endsWith($url, "/")===true) |
| 109 | 109 | $url=substr($url, 0, strlen($url)-1); |
| 110 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
| 110 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
| 111 | 111 | $url=$this->jsUtils->getUrl($url); |
| 112 | 112 | } |
| 113 | 113 | return $url; |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | * @param string $jsCallback javascript code to execute after the request |
| 122 | 122 | * @param boolean $immediatly |
| 123 | 123 | */ |
| 124 | - public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
| 124 | + public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
| 125 | 125 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 126 | 126 | $retour=$this->_getAjaxUrl($url, $attr); |
| 127 | 127 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -142,7 +142,7 @@ discard block |
||
| 142 | 142 | * @param string $url the request address |
| 143 | 143 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
| 144 | 144 | */ |
| 145 | - public function _jsonOn($event,$element, $url,$parameters=array()) { |
|
| 145 | + public function _jsonOn($event, $element, $url, $parameters=array()) { |
|
| 146 | 146 | $preventDefault=true; |
| 147 | 147 | $stopPropagation=true; |
| 148 | 148 | $jsCallback=null; |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | $params="{}"; |
| 153 | 153 | $immediatly=true; |
| 154 | 154 | extract($parameters); |
| 155 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 155 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 156 | 156 | } |
| 157 | 157 | |
| 158 | 158 | /** |
@@ -164,22 +164,22 @@ discard block |
||
| 164 | 164 | * @param string $context jquery DOM element, array container. |
| 165 | 165 | * @param boolean $immediatly |
| 166 | 166 | */ |
| 167 | - public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null,$immediatly=false) { |
|
| 167 | + public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null, $immediatly=false) { |
|
| 168 | 168 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 169 | 169 | $retour=$this->_getAjaxUrl($url, $attr); |
| 170 | - if($context===null){ |
|
| 170 | + if ($context===null) { |
|
| 171 | 171 | $parent="$('".$maskSelector."').parent()"; |
| 172 | - $newElm = "$('#'+newId)"; |
|
| 173 | - }else{ |
|
| 172 | + $newElm="$('#'+newId)"; |
|
| 173 | + } else { |
|
| 174 | 174 | $parent=$context; |
| 175 | - $newElm = $context.".find('#'+newId)"; |
|
| 175 | + $newElm=$context.".find('#'+newId)"; |
|
| 176 | 176 | } |
| 177 | 177 | $appendTo="\t\tnewElm.appendTo(".$parent.");\n"; |
| 178 | 178 | $retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n"; |
| 179 | 179 | $retour.=$parent.".find('._json').remove();"; |
| 180 | 180 | $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(); |
| 181 | 181 | newElm.attr('id',newId);\n;newElm.addClass('_json').removeClass('_jsonArrayModel');\nnewElm.find('[id]').each(function(){ var newId=$(this).attr('id')+'-'+index;$(this).attr('id',newId).removeClass('_jsonArrayChecked');});\n"; |
| 182 | - $retour.= $appendTo; |
|
| 182 | + $retour.=$appendTo; |
|
| 183 | 183 | $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"; |
| 184 | 184 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 185 | 185 | $retour.="\t".$jsCallback."\n"."});\n"; |
@@ -194,30 +194,30 @@ discard block |
||
| 194 | 194 | * @param string $url the request address |
| 195 | 195 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get", "context"=>null) |
| 196 | 196 | */ |
| 197 | - public function _jsonArrayOn($event,$element, $maskSelector,$url,$parameters=array()) { |
|
| 197 | + public function _jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
| 198 | 198 | $preventDefault=true; |
| 199 | 199 | $stopPropagation=true; |
| 200 | 200 | $jsCallback=null; |
| 201 | 201 | $attr="id"; |
| 202 | 202 | $method="get"; |
| 203 | - $context = null; |
|
| 203 | + $context=null; |
|
| 204 | 204 | $params="{}"; |
| 205 | 205 | $immediatly=true; |
| 206 | 206 | extract($parameters); |
| 207 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 207 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 208 | 208 | } |
| 209 | 209 | |
| 210 | - public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$jqueryDone="html",$ajaxTransition=null,$immediatly=false) { |
|
| 210 | + public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null, $immediatly=false) { |
|
| 211 | 211 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 212 | 212 | $retour=$this->_getAjaxUrl($url, $attr); |
| 213 | 213 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
| 214 | 214 | $responseElement=$this->_getResponseElement($responseElement); |
| 215 | 215 | $retour.="var self=this;\n"; |
| 216 | - if($hasLoader===true){ |
|
| 216 | + if ($hasLoader===true) { |
|
| 217 | 217 | $this->addLoading($retour, $responseElement); |
| 218 | 218 | } |
| 219 | 219 | $retour.="$.post(url,params).done(function( data ) {\n"; |
| 220 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
|
| 220 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n"; |
|
| 221 | 221 | |
| 222 | 222 | if ($validation) { |
| 223 | 223 | $retour="$('#".$form."').validate({submitHandler: function(form) { |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | * @param string $responseElement |
| 241 | 241 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxTransition"=>null,"jqueryDone"=>"html") |
| 242 | 242 | */ |
| 243 | - public function _getOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 243 | + public function _getOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 244 | 244 | $preventDefault=true; |
| 245 | 245 | $stopPropagation=true; |
| 246 | 246 | $jsCallback=null; |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | $jqueryDone="html"; |
| 251 | 251 | $ajaxTransition=null; |
| 252 | 252 | extract($parameters); |
| 253 | - return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 253 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 254 | 254 | } |
| 255 | 255 | |
| 256 | 256 | /** |
@@ -263,7 +263,7 @@ discard block |
||
| 263 | 263 | * @param string $responseElement |
| 264 | 264 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxTransition"=>null) |
| 265 | 265 | */ |
| 266 | - public function _postOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 266 | + public function _postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 267 | 267 | $preventDefault=true; |
| 268 | 268 | $stopPropagation=true; |
| 269 | 269 | $jsCallback=null; |
@@ -273,7 +273,7 @@ discard block |
||
| 273 | 273 | $jqueryDone="html"; |
| 274 | 274 | $ajaxTransition=null; |
| 275 | 275 | extract($parameters); |
| 276 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 276 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 277 | 277 | } |
| 278 | 278 | |
| 279 | 279 | /** |
@@ -286,7 +286,7 @@ discard block |
||
| 286 | 286 | * @param string $responseElement |
| 287 | 287 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"ajaxTransition"=>null,"immediatly"=>true) |
| 288 | 288 | */ |
| 289 | - public function _postFormOn($event,$element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 289 | + public function _postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 290 | 290 | $preventDefault=true; |
| 291 | 291 | $stopPropagation=true; |
| 292 | 292 | $validation=false; |
@@ -297,6 +297,6 @@ discard block |
||
| 297 | 297 | $jqueryDone="html"; |
| 298 | 298 | $ajaxTransition=null; |
| 299 | 299 | extract($parameters); |
| 300 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader,$jqueryDone,$ajaxTransition), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 300 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 301 | 301 | } |
| 302 | 302 | } |
| 303 | 303 | \ No newline at end of file |
@@ -48,8 +48,9 @@ discard block |
||
| 48 | 48 | } |
| 49 | 49 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
| 50 | 50 | $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
| 51 | - if ($immediatly) |
|
| 52 | - $this->jquery_code_for_compile[]=$retour; |
|
| 51 | + if ($immediatly) { |
|
| 52 | + $this->jquery_code_for_compile[]=$retour; |
|
| 53 | + } |
|
| 53 | 54 | return $retour; |
| 54 | 55 | } |
| 55 | 56 | |
@@ -67,15 +68,17 @@ discard block |
||
| 67 | 68 | $url=$this->_correctAjaxUrl($url); |
| 68 | 69 | $retour="url='".$url."';"; |
| 69 | 70 | $slash="/"; |
| 70 | - if(JString::endswith($url, "/")===true) |
|
| 71 | - $slash=""; |
|
| 71 | + if(JString::endswith($url, "/")===true) { |
|
| 72 | + $slash=""; |
|
| 73 | + } |
|
| 72 | 74 | if(JString::isNotNull($attr)){ |
| 73 | - if ($attr==="value") |
|
| 74 | - $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
| 75 | - elseif ($attr==="html") |
|
| 76 | - $retour.="url=url+'".$slash."'+$(this).html();\n"; |
|
| 77 | - elseif($attr!=null && $attr!=="") |
|
| 78 | - $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
| 75 | + if ($attr==="value") { |
|
| 76 | + $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
| 77 | + } elseif ($attr==="html") { |
|
| 78 | + $retour.="url=url+'".$slash."'+$(this).html();\n"; |
|
| 79 | + } elseif($attr!=null && $attr!=="") { |
|
| 80 | + $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
| 81 | + } |
|
| 79 | 82 | } |
| 80 | 83 | return $retour; |
| 81 | 84 | } |
@@ -85,13 +88,14 @@ discard block |
||
| 85 | 88 | if ($responseElement!=="") { |
| 86 | 89 | if(isset($ajaxTransition)){ |
| 87 | 90 | $call=$this->setAjaxDataCall($ajaxTransition); |
| 88 | - }elseif(isset($this->ajaxTransition)){ |
|
| 91 | + } elseif(isset($this->ajaxTransition)){ |
|
| 89 | 92 | $call=$this->ajaxTransition; |
| 90 | 93 | } |
| 91 | - if(\is_callable($call)) |
|
| 92 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
| 93 | - else |
|
| 94 | - $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
|
| 94 | + if(\is_callable($call)) { |
|
| 95 | + $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
| 96 | + } else { |
|
| 97 | + $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
|
| 98 | + } |
|
| 95 | 99 | } |
| 96 | 100 | $retour.="\t".$jsCallback."\n"; |
| 97 | 101 | return $retour; |
@@ -105,8 +109,9 @@ discard block |
||
| 105 | 109 | } |
| 106 | 110 | |
| 107 | 111 | protected function _correctAjaxUrl($url) { |
| 108 | - if ($url!=="/" && JString::endsWith($url, "/")===true) |
|
| 109 | - $url=substr($url, 0, strlen($url)-1); |
|
| 112 | + if ($url!=="/" && JString::endsWith($url, "/")===true) { |
|
| 113 | + $url=substr($url, 0, strlen($url)-1); |
|
| 114 | + } |
|
| 110 | 115 | if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
| 111 | 116 | $url=$this->jsUtils->getUrl($url); |
| 112 | 117 | } |
@@ -130,8 +135,9 @@ discard block |
||
| 130 | 135 | $retour.="\t".$jsCallback."\n". |
| 131 | 136 | "\t$(document).trigger('jsonReady',[data]);\n". |
| 132 | 137 | "});\n"; |
| 133 | - if ($immediatly) |
|
| 134 | - $this->jquery_code_for_compile[]=$retour; |
|
| 138 | + if ($immediatly) { |
|
| 139 | + $this->jquery_code_for_compile[]=$retour; |
|
| 140 | + } |
|
| 135 | 141 | return $retour; |
| 136 | 142 | } |
| 137 | 143 | |
@@ -170,7 +176,7 @@ discard block |
||
| 170 | 176 | if($context===null){ |
| 171 | 177 | $parent="$('".$maskSelector."').parent()"; |
| 172 | 178 | $newElm = "$('#'+newId)"; |
| 173 | - }else{ |
|
| 179 | + } else{ |
|
| 174 | 180 | $parent=$context; |
| 175 | 181 | $newElm = $context.".find('#'+newId)"; |
| 176 | 182 | } |
@@ -183,8 +189,9 @@ discard block |
||
| 183 | 189 | $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"; |
| 184 | 190 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 185 | 191 | $retour.="\t".$jsCallback."\n"."});\n"; |
| 186 | - if ($immediatly) |
|
| 187 | - $this->jquery_code_for_compile[]=$retour; |
|
| 192 | + if ($immediatly) { |
|
| 193 | + $this->jquery_code_for_compile[]=$retour; |
|
| 194 | + } |
|
| 188 | 195 | return $retour; |
| 189 | 196 | } |
| 190 | 197 | /** |
@@ -225,8 +232,9 @@ discard block |
||
| 225 | 232 | }});\n"; |
| 226 | 233 | $retour.="$('#".$form."').submit();\n"; |
| 227 | 234 | } |
| 228 | - if ($immediatly) |
|
| 229 | - $this->jquery_code_for_compile[]=$retour; |
|
| 235 | + if ($immediatly) { |
|
| 236 | + $this->jquery_code_for_compile[]=$retour; |
|
| 237 | + } |
|
| 230 | 238 | return $retour; |
| 231 | 239 | } |
| 232 | 240 | |
@@ -25,8 +25,8 @@ discard block |
||
| 25 | 25 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 26 | 26 | * @param string|callable $ajaxTransition |
| 27 | 27 | */ |
| 28 | - public function get($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
| 29 | - return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
| 28 | + public function get($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
| 29 | + return $this->js->_get($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
| 30 | 30 | } |
| 31 | 31 | |
| 32 | 32 | /** |
@@ -37,8 +37,8 @@ discard block |
||
| 37 | 37 | * @param string $jsCallback javascript code to execute after the request |
| 38 | 38 | * @param boolean $immediatly |
| 39 | 39 | */ |
| 40 | - public function json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
| 41 | - return $this->js->_json($url, $method, $params, $jsCallback, $attr, $context,$immediatly); |
|
| 40 | + public function json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
| 41 | + return $this->js->_json($url, $method, $params, $jsCallback, $attr, $context, $immediatly); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | 44 | /** |
@@ -48,8 +48,8 @@ discard block |
||
| 48 | 48 | * @param string $url the request address |
| 49 | 49 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
| 50 | 50 | */ |
| 51 | - public function jsonOn($event,$element, $url,$parameters=array()) { |
|
| 52 | - return $this->js->_jsonOn($event, $element, $url,$parameters); |
|
| 51 | + public function jsonOn($event, $element, $url, $parameters=array()) { |
|
| 52 | + return $this->js->_jsonOn($event, $element, $url, $parameters); |
|
| 53 | 53 | } |
| 54 | 54 | |
| 55 | 55 | /** |
@@ -71,7 +71,7 @@ discard block |
||
| 71 | 71 | * @param string $jsCallback javascript code to execute after the request |
| 72 | 72 | */ |
| 73 | 73 | public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL) { |
| 74 | - return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback,"id", NULL,true); |
|
| 74 | + return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, "id", NULL, true); |
|
| 75 | 75 | } |
| 76 | 76 | |
| 77 | 77 | /** |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | * @param string $jsCallback javascript code to execute after the request |
| 84 | 84 | */ |
| 85 | 85 | public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL) { |
| 86 | - return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback,"id", NULL, false); |
|
| 86 | + return $this->js->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, "id", NULL, false); |
|
| 87 | 87 | } |
| 88 | 88 | |
| 89 | 89 | /** |
@@ -93,8 +93,8 @@ discard block |
||
| 93 | 93 | * @param string $url the request url |
| 94 | 94 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
| 95 | 95 | */ |
| 96 | - public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) { |
|
| 97 | - return $this->js->_jsonArrayOn($event,$element,$maskSelector, $url, $parameters); |
|
| 96 | + public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
| 97 | + return $this->js->_jsonArrayOn($event, $element, $maskSelector, $url, $parameters); |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -108,8 +108,8 @@ discard block |
||
| 108 | 108 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 109 | 109 | * @param string|callable $ajaxTransition |
| 110 | 110 | */ |
| 111 | - public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL,$attr="id",$jqueryDone="html",$ajaxTransition=null) { |
|
| 112 | - return $this->js->_get($url, $params, $responseElement, $jsCallback, $attr, false,$jqueryDone,$ajaxTransition); |
|
| 111 | + public function getDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $jqueryDone="html", $ajaxTransition=null) { |
|
| 112 | + return $this->js->_get($url, $params, $responseElement, $jsCallback, $attr, false, $jqueryDone, $ajaxTransition); |
|
| 113 | 113 | } |
| 114 | 114 | |
| 115 | 115 | /** |
@@ -148,8 +148,8 @@ discard block |
||
| 148 | 148 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 149 | 149 | * @param string|callable $ajaxTransition |
| 150 | 150 | */ |
| 151 | - public function post($url, $responseElement="", $params="{}", $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
| 152 | - return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
| 151 | + public function post($url, $responseElement="", $params="{}", $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
| 152 | + return $this->js->_post($url, $params, $responseElement, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
| 153 | 153 | } |
| 154 | 154 | |
| 155 | 155 | /** |
@@ -164,8 +164,8 @@ discard block |
||
| 164 | 164 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 165 | 165 | * @param string|callable $ajaxTransition |
| 166 | 166 | */ |
| 167 | - public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
| 168 | - return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false); |
|
| 167 | + public function postDeferred($url, $responseElement="", $params="{}", $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
| 168 | + return $this->js->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false); |
|
| 169 | 169 | } |
| 170 | 170 | |
| 171 | 171 | /** |
@@ -179,7 +179,7 @@ discard block |
||
| 179 | 179 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null) |
| 180 | 180 | */ |
| 181 | 181 | public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
| 182 | - return $this->js->_postOn($event, $element, $url, $params, $responseElement, $parameters); |
|
| 182 | + return $this->js->_postOn($event, $element, $url, $params, $responseElement, $parameters); |
|
| 183 | 183 | } |
| 184 | 184 | |
| 185 | 185 | /** |
@@ -205,8 +205,8 @@ discard block |
||
| 205 | 205 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 206 | 206 | * @param string|callable $ajaxTransition |
| 207 | 207 | */ |
| 208 | - public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
| 209 | - return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader,$jqueryDone,$ajaxTransition,true); |
|
| 208 | + public function postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
| 209 | + return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, NULL, $hasLoader, $jqueryDone, $ajaxTransition, true); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | /** |
@@ -221,8 +221,8 @@ discard block |
||
| 221 | 221 | * @param string $jqueryDone the jquery function call on ajax data. default:html |
| 222 | 222 | * @param string|callable $ajaxTransition |
| 223 | 223 | */ |
| 224 | - public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL,$attr="id",$hasLoader=true,$jqueryDone="html",$ajaxTransition=null) { |
|
| 225 | - return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader,$jqueryDone,$ajaxTransition,false); |
|
| 224 | + public function postFormDeferred($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $jqueryDone="html", $ajaxTransition=null) { |
|
| 225 | + return $this->js->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader, $jqueryDone, $ajaxTransition, false); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
@@ -236,7 +236,7 @@ discard block |
||
| 236 | 236 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null) |
| 237 | 237 | */ |
| 238 | 238 | public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
| 239 | - return $this->js->_postFormOn($event,$element, $url, $form, $responseElement, $parameters); |
|
| 239 | + return $this->js->_postFormOn($event, $element, $url, $form, $responseElement, $parameters); |
|
| 240 | 240 | } |
| 241 | 241 | |
| 242 | 242 | /** |
@@ -15,16 +15,16 @@ discard block |
||
| 15 | 15 | * @license Apache 2 http://www.apache.org/licenses/ |
| 16 | 16 | **/ |
| 17 | 17 | class Jquery { |
| 18 | - use JqueryEventsTrait,JqueryAjaxTrait,JqueryActionsTrait; |
|
| 18 | + use JqueryEventsTrait, JqueryAjaxTrait, JqueryActionsTrait; |
|
| 19 | 19 | protected $_ui; |
| 20 | 20 | protected $_bootstrap; |
| 21 | 21 | protected $_semantic; |
| 22 | - protected $jquery_code_for_compile=array (); |
|
| 22 | + protected $jquery_code_for_compile=array(); |
|
| 23 | 23 | protected $jsUtils; |
| 24 | 24 | protected $params; |
| 25 | 25 | |
| 26 | - protected $jquery_events=array ( |
|
| 27 | - "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" |
|
| 26 | + protected $jquery_events=array( |
|
| 27 | + "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" |
|
| 28 | 28 | ); |
| 29 | 29 | |
| 30 | 30 | public function ui($ui=NULL) { |
@@ -48,13 +48,13 @@ discard block |
||
| 48 | 48 | return $this->_semantic; |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - public function __construct($params,$jsUtils) { |
|
| 51 | + public function __construct($params, $jsUtils) { |
|
| 52 | 52 | $this->params=array(); |
| 53 | - foreach ( $params as $key => $val ) { |
|
| 53 | + foreach ($params as $key => $val) { |
|
| 54 | 54 | $this->params[$key]=$params[$key]; |
| 55 | 55 | } |
| 56 | 56 | $this->jsUtils=$jsUtils; |
| 57 | - if(isset($params["ajaxTransition"])) |
|
| 57 | + if (isset($params["ajaxTransition"])) |
|
| 58 | 58 | $this->ajaxTransition=$this->setAjaxDataCall($params["ajaxTransition"]); |
| 59 | 59 | } |
| 60 | 60 | |
@@ -116,12 +116,12 @@ discard block |
||
| 116 | 116 | */ |
| 117 | 117 | public function _output($array_js='') { |
| 118 | 118 | if (!is_array($array_js)) { |
| 119 | - $array_js=array ( |
|
| 119 | + $array_js=array( |
|
| 120 | 120 | $array_js |
| 121 | 121 | ); |
| 122 | 122 | } |
| 123 | 123 | |
| 124 | - foreach ( $array_js as $js ) { |
|
| 124 | + foreach ($array_js as $js) { |
|
| 125 | 125 | $this->jquery_code_for_compile[]="\t$js\n"; |
| 126 | 126 | } |
| 127 | 127 | } |
@@ -133,7 +133,7 @@ discard block |
||
| 133 | 133 | * @param string $param |
| 134 | 134 | * @param boolean $immediatly delayed if false |
| 135 | 135 | */ |
| 136 | - public function _genericCallValue($jQueryCall,$element='this', $param="", $immediatly=false) { |
|
| 136 | + public function _genericCallValue($jQueryCall, $element='this', $param="", $immediatly=false) { |
|
| 137 | 137 | $element=Javascript::prep_element($element); |
| 138 | 138 | if (isset($param)) { |
| 139 | 139 | $param=Javascript::prep_value($param); |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | * @param boolean $immediatly delayed if false |
| 153 | 153 | * @return string |
| 154 | 154 | */ |
| 155 | - public function _genericCallElement($jQueryCall,$to='this', $element, $immediatly=false) { |
|
| 155 | + public function _genericCallElement($jQueryCall, $to='this', $element, $immediatly=false) { |
|
| 156 | 156 | $to=Javascript::prep_element($to); |
| 157 | 157 | $element=Javascript::prep_element($element); |
| 158 | 158 | $str="$({$to}).{$jQueryCall}({$element});"; |
@@ -170,8 +170,8 @@ discard block |
||
| 170 | 170 | */ |
| 171 | 171 | public function sortable($element, $options=array()) { |
| 172 | 172 | if (count($options)>0) { |
| 173 | - $sort_options=array (); |
|
| 174 | - foreach ( $options as $k => $v ) { |
|
| 173 | + $sort_options=array(); |
|
| 174 | + foreach ($options as $k => $v) { |
|
| 175 | 175 | $sort_options[]="\n\t\t".$k.': '.$v.""; |
| 176 | 176 | } |
| 177 | 177 | $sort_options=implode(",", $sort_options); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | * @param boolean $stopPropagation Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. |
| 204 | 204 | * @return string |
| 205 | 205 | */ |
| 206 | - public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true) { |
|
| 206 | + public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true) { |
|
| 207 | 207 | if (\is_array($js)) { |
| 208 | 208 | $js=implode("\n\t\t", $js); |
| 209 | 209 | } |
@@ -217,7 +217,7 @@ discard block |
||
| 217 | 217 | $event="\n\t$(".Javascript::prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
| 218 | 218 | else |
| 219 | 219 | $event="\n\t$(".Javascript::prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
| 220 | - if($immediatly) |
|
| 220 | + if ($immediatly) |
|
| 221 | 221 | $this->jquery_code_for_compile[]=$event; |
| 222 | 222 | return $event; |
| 223 | 223 | } |
@@ -243,40 +243,40 @@ discard block |
||
| 243 | 243 | $script='$(document).ready(function() {'."\n"; |
| 244 | 244 | $script.=implode('', $this->jquery_code_for_compile); |
| 245 | 245 | $script.='})'; |
| 246 | - if($this->params["defer"]){ |
|
| 246 | + if ($this->params["defer"]) { |
|
| 247 | 247 | $script=$this->defer($script); |
| 248 | 248 | } |
| 249 | 249 | $script.=";"; |
| 250 | 250 | $this->jquery_code_for_compile=array(); |
| 251 | - if($this->params["debug"]===false){ |
|
| 251 | + if ($this->params["debug"]===false) { |
|
| 252 | 252 | $script=$this->minify($script); |
| 253 | 253 | } |
| 254 | 254 | $output=($script_tags===FALSE) ? $script : $this->inline($script); |
| 255 | 255 | |
| 256 | - if ($view!==NULL){ |
|
| 257 | - $this->jsUtils->createScriptVariable($view,$view_var, $output); |
|
| 256 | + if ($view!==NULL) { |
|
| 257 | + $this->jsUtils->createScriptVariable($view, $view_var, $output); |
|
| 258 | 258 | } |
| 259 | 259 | return $output; |
| 260 | 260 | } |
| 261 | 261 | |
| 262 | - public function getScript($offset=0){ |
|
| 262 | + public function getScript($offset=0) { |
|
| 263 | 263 | $code=$this->jquery_code_for_compile; |
| 264 | - if($offset>0) |
|
| 264 | + if ($offset>0) |
|
| 265 | 265 | $code=\array_slice($code, $offset); |
| 266 | 266 | return implode('', $code); |
| 267 | 267 | } |
| 268 | 268 | |
| 269 | - public function scriptCount(){ |
|
| 269 | + public function scriptCount() { |
|
| 270 | 270 | return \sizeof($this->jquery_code_for_compile); |
| 271 | 271 | } |
| 272 | 272 | |
| 273 | - private function defer($script){ |
|
| 273 | + private function defer($script) { |
|
| 274 | 274 | $result="window.defer=function (method) {if (window.jQuery) method(); else setTimeout(function() { defer(method) }, 50);};"; |
| 275 | 275 | $result.="window.defer(function(){".$script."})"; |
| 276 | 276 | return $result; |
| 277 | 277 | } |
| 278 | 278 | |
| 279 | - private function _compileLibrary($library){ |
|
| 279 | + private function _compileLibrary($library) { |
|
| 280 | 280 | if ($library!=NULL) { |
| 281 | 281 | if ($library->isAutoCompile()) { |
| 282 | 282 | $library->compile(true); |
@@ -294,7 +294,7 @@ discard block |
||
| 294 | 294 | * @return void |
| 295 | 295 | */ |
| 296 | 296 | public function _clear_compile() { |
| 297 | - $this->jquery_code_for_compile=array (); |
|
| 297 | + $this->jquery_code_for_compile=array(); |
|
| 298 | 298 | } |
| 299 | 299 | |
| 300 | 300 | /** |
@@ -303,18 +303,18 @@ discard block |
||
| 303 | 303 | */ |
| 304 | 304 | public function _document_ready($js) { |
| 305 | 305 | if (!is_array($js)) { |
| 306 | - $js=array ( |
|
| 306 | + $js=array( |
|
| 307 | 307 | $js |
| 308 | 308 | ); |
| 309 | 309 | } |
| 310 | 310 | |
| 311 | - foreach ( $js as $script ) { |
|
| 311 | + foreach ($js as $script) { |
|
| 312 | 312 | $this->jquery_code_for_compile[]=$script; |
| 313 | 313 | } |
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | private function minify($input) { |
| 317 | - if(trim($input) === "") return $input; |
|
| 317 | + if (trim($input)==="") return $input; |
|
| 318 | 318 | return preg_replace( |
| 319 | 319 | array( |
| 320 | 320 | // Remove comment(s) |
@@ -54,8 +54,9 @@ discard block |
||
| 54 | 54 | $this->params[$key]=$params[$key]; |
| 55 | 55 | } |
| 56 | 56 | $this->jsUtils=$jsUtils; |
| 57 | - if(isset($params["ajaxTransition"])) |
|
| 58 | - $this->ajaxTransition=$this->setAjaxDataCall($params["ajaxTransition"]); |
|
| 57 | + if(isset($params["ajaxTransition"])) { |
|
| 58 | + $this->ajaxTransition=$this->setAjaxDataCall($params["ajaxTransition"]); |
|
| 59 | + } |
|
| 59 | 60 | } |
| 60 | 61 | |
| 61 | 62 | /** |
@@ -138,10 +139,12 @@ discard block |
||
| 138 | 139 | if (isset($param)) { |
| 139 | 140 | $param=Javascript::prep_value($param); |
| 140 | 141 | $str="$({$element}).{$jQueryCall}({$param});"; |
| 141 | - } else |
|
| 142 | - $str="$({$element}).{$jQueryCall}();"; |
|
| 143 | - if ($immediatly) |
|
| 144 | - $this->jquery_code_for_compile[]=$str; |
|
| 142 | + } else { |
|
| 143 | + $str="$({$element}).{$jQueryCall}();"; |
|
| 144 | + } |
|
| 145 | + if ($immediatly) { |
|
| 146 | + $this->jquery_code_for_compile[]=$str; |
|
| 147 | + } |
|
| 145 | 148 | return $str; |
| 146 | 149 | } |
| 147 | 150 | /** |
@@ -156,8 +159,9 @@ discard block |
||
| 156 | 159 | $to=Javascript::prep_element($to); |
| 157 | 160 | $element=Javascript::prep_element($element); |
| 158 | 161 | $str="$({$to}).{$jQueryCall}({$element});"; |
| 159 | - if ($immediatly) |
|
| 160 | - $this->jquery_code_for_compile[]=$str; |
|
| 162 | + if ($immediatly) { |
|
| 163 | + $this->jquery_code_for_compile[]=$str; |
|
| 164 | + } |
|
| 161 | 165 | return $str; |
| 162 | 166 | } |
| 163 | 167 | |
@@ -213,12 +217,14 @@ discard block |
||
| 213 | 217 | if ($stopPropagation===true) { |
| 214 | 218 | $js=Javascript::$stopPropagation.$js; |
| 215 | 219 | } |
| 216 | - if (array_search($event, $this->jquery_events)===false) |
|
| 217 | - $event="\n\t$(".Javascript::prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
|
| 218 | - else |
|
| 219 | - $event="\n\t$(".Javascript::prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
|
| 220 | - if($immediatly) |
|
| 221 | - $this->jquery_code_for_compile[]=$event; |
|
| 220 | + if (array_search($event, $this->jquery_events)===false) { |
|
| 221 | + $event="\n\t$(".Javascript::prep_element($element).").bind('{$event}',function(event){\n\t\t{$js}\n\t});\n"; |
|
| 222 | + } else { |
|
| 223 | + $event="\n\t$(".Javascript::prep_element($element).").{$event}(function(event){\n\t\t{$js}\n\t});\n"; |
|
| 224 | + } |
|
| 225 | + if($immediatly) { |
|
| 226 | + $this->jquery_code_for_compile[]=$event; |
|
| 227 | + } |
|
| 222 | 228 | return $event; |
| 223 | 229 | } |
| 224 | 230 | |
@@ -261,8 +267,9 @@ discard block |
||
| 261 | 267 | |
| 262 | 268 | public function getScript($offset=0){ |
| 263 | 269 | $code=$this->jquery_code_for_compile; |
| 264 | - if($offset>0) |
|
| 265 | - $code=\array_slice($code, $offset); |
|
| 270 | + if($offset>0) { |
|
| 271 | + $code=\array_slice($code, $offset); |
|
| 272 | + } |
|
| 266 | 273 | return implode('', $code); |
| 267 | 274 | } |
| 268 | 275 | |
@@ -314,7 +321,9 @@ discard block |
||
| 314 | 321 | } |
| 315 | 322 | |
| 316 | 323 | private function minify($input) { |
| 317 | - if(trim($input) === "") return $input; |
|
| 324 | + if(trim($input) === "") { |
|
| 325 | + return $input; |
|
| 326 | + } |
|
| 318 | 327 | return preg_replace( |
| 319 | 328 | array( |
| 320 | 329 | // Remove comment(s) |