@@ -23,22 +23,22 @@ discard block |
||
23 | 23 | class HtmlSemDoubleElement extends HtmlDoubleElement { |
24 | 24 | use BaseTrait; |
25 | 25 | |
26 | - protected $_popup = NULL; |
|
26 | + protected $_popup=NULL; |
|
27 | 27 | |
28 | - protected $_dimmer = NULL; |
|
28 | + protected $_dimmer=NULL; |
|
29 | 29 | |
30 | - protected $_toast = NULL; |
|
30 | + protected $_toast=NULL; |
|
31 | 31 | |
32 | - protected $_sidebar = NULL; |
|
32 | + protected $_sidebar=NULL; |
|
33 | 33 | |
34 | - protected $_params = array(); |
|
34 | + protected $_params=array(); |
|
35 | 35 | |
36 | - public function __construct($identifier, $tagName = "p", $baseClass = "ui", $content = NULL) { |
|
36 | + public function __construct($identifier, $tagName="p", $baseClass="ui", $content=NULL) { |
|
37 | 37 | parent::__construct($identifier, $tagName); |
38 | - $this->_baseClass = $baseClass; |
|
38 | + $this->_baseClass=$baseClass; |
|
39 | 39 | $this->setClass($baseClass); |
40 | 40 | if (isset($content)) { |
41 | - $this->content = $content; |
|
41 | + $this->content=$content; |
|
42 | 42 | } |
43 | 43 | } |
44 | 44 | |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | * @param string $variation |
49 | 49 | * @param string $popupEvent |
50 | 50 | */ |
51 | - public function setPopupAttributes($variation = NULL, $popupEvent = NULL) { |
|
51 | + public function setPopupAttributes($variation=NULL, $popupEvent=NULL) { |
|
52 | 52 | if (isset($this->_popup)) |
53 | 53 | $this->_popup->setAttributes($variation, $popupEvent); |
54 | 54 | } |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | * @param array $params |
63 | 63 | * @return HtmlSemDoubleElement |
64 | 64 | */ |
65 | - public function addPopup($title = "", $content = "", $variation = NULL, $params = array()) { |
|
66 | - $this->_popup = new InternalPopup($this, $title, $content, $variation, $params); |
|
65 | + public function addPopup($title="", $content="", $variation=NULL, $params=array()) { |
|
66 | + $this->_popup=new InternalPopup($this, $title, $content, $variation, $params); |
|
67 | 67 | return $this; |
68 | 68 | } |
69 | 69 | |
@@ -75,8 +75,8 @@ discard block |
||
75 | 75 | * @param array $params |
76 | 76 | * @return HtmlSemDoubleElement |
77 | 77 | */ |
78 | - public function addPopupHtml($html = "", $variation = NULL, $params = array()) { |
|
79 | - $this->_popup = new InternalPopup($this); |
|
78 | + public function addPopupHtml($html="", $variation=NULL, $params=array()) { |
|
79 | + $this->_popup=new InternalPopup($this); |
|
80 | 80 | $this->_popup->setHtml($html); |
81 | 81 | $this->_popup->setAttributes($variation, $params); |
82 | 82 | return $this; |
@@ -89,8 +89,8 @@ discard block |
||
89 | 89 | * @param mixed $content |
90 | 90 | * @return HtmlDimmer |
91 | 91 | */ |
92 | - public function addDimmer($params = array(), $content = NULL) { |
|
93 | - $dimmer = new HtmlDimmer("dimmer-" . $this->identifier, $content); |
|
92 | + public function addDimmer($params=array(), $content=NULL) { |
|
93 | + $dimmer=new HtmlDimmer("dimmer-".$this->identifier, $content); |
|
94 | 94 | $dimmer->setParams($params); |
95 | 95 | $dimmer->setContainer($this); |
96 | 96 | $this->addContent($dimmer); |
@@ -105,10 +105,10 @@ discard block |
||
105 | 105 | * @param string $icon |
106 | 106 | * @return mixed|HtmlLabel |
107 | 107 | */ |
108 | - public function addLabel($label, $before = false, $icon = NULL) { |
|
109 | - $labelO = $label; |
|
110 | - if (\is_object($label) === false) { |
|
111 | - $labelO = new HtmlLabel("label-" . $this->identifier, $label); |
|
108 | + public function addLabel($label, $before=false, $icon=NULL) { |
|
109 | + $labelO=$label; |
|
110 | + if (\is_object($label)===false) { |
|
111 | + $labelO=new HtmlLabel("label-".$this->identifier, $label); |
|
112 | 112 | if (isset($icon)) |
113 | 113 | $labelO->addIcon($icon); |
114 | 114 | } else { |
@@ -129,8 +129,8 @@ discard block |
||
129 | 129 | * @param string $icon |
130 | 130 | * @return HtmlSemDoubleElement |
131 | 131 | */ |
132 | - public function attachLabel($label, $side = Side::TOP, $direction = Direction::NONE, $icon = NULL) { |
|
133 | - $label = $this->addLabel($label, true, $icon); |
|
132 | + public function attachLabel($label, $side=Side::TOP, $direction=Direction::NONE, $icon=NULL) { |
|
133 | + $label=$this->addLabel($label, true, $icon); |
|
134 | 134 | $label->setAttached($side, $direction); |
135 | 135 | return $this; |
136 | 136 | } |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | * |
141 | 141 | * @return HtmlSemDoubleElement |
142 | 142 | */ |
143 | - public function asLink($href = NULL, $target = NULL) { |
|
143 | + public function asLink($href=NULL, $target=NULL) { |
|
144 | 144 | if (isset($href)) |
145 | 145 | $this->setProperty("href", $href); |
146 | 146 | if (isset($target)) |
@@ -154,11 +154,11 @@ discard block |
||
154 | 154 | * @param boolean $show |
155 | 155 | * @return string |
156 | 156 | */ |
157 | - public function jsShowDimmer($show = true) { |
|
158 | - $status = "hide"; |
|
159 | - if ($show === true) |
|
160 | - $status = "show"; |
|
161 | - return '$("#.' . $this->identifier . ').dimmer("' . $status . '");'; |
|
157 | + public function jsShowDimmer($show=true) { |
|
158 | + $status="hide"; |
|
159 | + if ($show===true) |
|
160 | + $status="show"; |
|
161 | + return '$("#.'.$this->identifier.').dimmer("'.$status.'");'; |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | * {@inheritdoc} |
167 | 167 | * @see BaseHtml::compile() |
168 | 168 | */ |
169 | - public function compile(JsUtils $js = NULL, &$view = NULL) { |
|
169 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
170 | 170 | if (isset($this->_popup)) { |
171 | 171 | $this->_popup->compile($js); |
172 | 172 | } |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | * @see HtmlDoubleElement::run() |
180 | 180 | */ |
181 | 181 | public function run(JsUtils $js) { |
182 | - $this->_bsComponent = $js->semantic()->generic("#" . $this->identifier); |
|
182 | + $this->_bsComponent=$js->semantic()->generic("#".$this->identifier); |
|
183 | 183 | parent::run($js); |
184 | 184 | $this->addEventsOnRun($js); |
185 | 185 | if (isset($this->_popup)) { |
@@ -197,8 +197,8 @@ discard block |
||
197 | 197 | * @param boolean $ordered |
198 | 198 | * @return \Ajax\common\html\html5\HtmlList |
199 | 199 | */ |
200 | - public function addList($items, $ordered = false) { |
|
201 | - $list = new HtmlList("list-" . $this->identifier, $items); |
|
200 | + public function addList($items, $ordered=false) { |
|
201 | + $list=new HtmlList("list-".$this->identifier, $items); |
|
202 | 202 | $list->setOrdered($ordered); |
203 | 203 | $list->setClass("ui list"); |
204 | 204 | $this->addContent($list); |
@@ -210,9 +210,9 @@ discard block |
||
210 | 210 | * @param ?array $params |
211 | 211 | * @return \Ajax\semantic\components\Toast |
212 | 212 | */ |
213 | - public function asToast($params = NULL) { |
|
214 | - $this->_toast = new Toast(); |
|
215 | - $this->_toast->attach('#' . $this->_identifier); |
|
213 | + public function asToast($params=NULL) { |
|
214 | + $this->_toast=new Toast(); |
|
215 | + $this->_toast->attach('#'.$this->_identifier); |
|
216 | 216 | $this->setProperty('style', 'display:none;'); |
217 | 217 | if (isset($params)) { |
218 | 218 | $this->_toast->setParams($params); |
@@ -226,8 +226,8 @@ discard block |
||
226 | 226 | * @param string $classes |
227 | 227 | * @return \Ajax\semantic\components\Sidebar |
228 | 228 | */ |
229 | - public function asSideBar($classes = '') { |
|
230 | - $this->_sidebar = new Sidebar(); |
|
229 | + public function asSideBar($classes='') { |
|
230 | + $this->_sidebar=new Sidebar(); |
|
231 | 231 | $this->addToProperty('class', 'sidebar'); |
232 | 232 | return $this->_sidebar; |
233 | 233 | } |
@@ -49,8 +49,9 @@ discard block |
||
49 | 49 | * @param string $popupEvent |
50 | 50 | */ |
51 | 51 | public function setPopupAttributes($variation = NULL, $popupEvent = NULL) { |
52 | - if (isset($this->_popup)) |
|
53 | - $this->_popup->setAttributes($variation, $popupEvent); |
|
52 | + if (isset($this->_popup)) { |
|
53 | + $this->_popup->setAttributes($variation, $popupEvent); |
|
54 | + } |
|
54 | 55 | } |
55 | 56 | |
56 | 57 | /** |
@@ -109,8 +110,9 @@ discard block |
||
109 | 110 | $labelO = $label; |
110 | 111 | if (\is_object($label) === false) { |
111 | 112 | $labelO = new HtmlLabel("label-" . $this->identifier, $label); |
112 | - if (isset($icon)) |
|
113 | - $labelO->addIcon($icon); |
|
113 | + if (isset($icon)) { |
|
114 | + $labelO->addIcon($icon); |
|
115 | + } |
|
114 | 116 | } else { |
115 | 117 | $labelO->addToPropertyCtrl("class", "label", array( |
116 | 118 | "label" |
@@ -141,10 +143,12 @@ discard block |
||
141 | 143 | * @return HtmlSemDoubleElement |
142 | 144 | */ |
143 | 145 | public function asLink($href = NULL, $target = NULL) { |
144 | - if (isset($href)) |
|
145 | - $this->setProperty("href", $href); |
|
146 | - if (isset($target)) |
|
147 | - $this->setProperty("target", $target); |
|
146 | + if (isset($href)) { |
|
147 | + $this->setProperty("href", $href); |
|
148 | + } |
|
149 | + if (isset($target)) { |
|
150 | + $this->setProperty("target", $target); |
|
151 | + } |
|
148 | 152 | return $this->setTagName("a"); |
149 | 153 | } |
150 | 154 | |
@@ -156,8 +160,9 @@ discard block |
||
156 | 160 | */ |
157 | 161 | public function jsShowDimmer($show = true) { |
158 | 162 | $status = "hide"; |
159 | - if ($show === true) |
|
160 | - $status = "show"; |
|
163 | + if ($show === true) { |
|
164 | + $status = "show"; |
|
165 | + } |
|
161 | 166 | return '$("#.' . $this->identifier . ').dimmer("' . $status . '");'; |
162 | 167 | } |
163 | 168 |
@@ -14,9 +14,9 @@ discard block |
||
14 | 14 | */ |
15 | 15 | class Sidebar extends SimpleSemExtComponent { |
16 | 16 | |
17 | - public function __construct(JsUtils $js = NULL) { |
|
17 | + public function __construct(JsUtils $js=NULL) { |
|
18 | 18 | parent::__construct($js); |
19 | - $this->uiName = 'sidebar'; |
|
19 | + $this->uiName='sidebar'; |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | public function show() { |
@@ -46,32 +46,32 @@ discard block |
||
46 | 46 | } |
47 | 47 | |
48 | 48 | public function setContext($value) { |
49 | - $this->params['context'] = $value; |
|
49 | + $this->params['context']=$value; |
|
50 | 50 | return $this; |
51 | 51 | } |
52 | 52 | |
53 | - public function setExclusive($value = true) { |
|
54 | - $this->params['exclusive'] = true; |
|
53 | + public function setExclusive($value=true) { |
|
54 | + $this->params['exclusive']=true; |
|
55 | 55 | return $this; |
56 | 56 | } |
57 | 57 | |
58 | - public function setClosable($value = true) { |
|
59 | - $this->params['closable'] = $value; |
|
58 | + public function setClosable($value=true) { |
|
59 | + $this->params['closable']=$value; |
|
60 | 60 | return $this; |
61 | 61 | } |
62 | 62 | |
63 | - public function setDimPage($value = true) { |
|
64 | - $this->params['dimPage'] = $value; |
|
63 | + public function setDimPage($value=true) { |
|
64 | + $this->params['dimPage']=$value; |
|
65 | 65 | return $this; |
66 | 66 | } |
67 | 67 | |
68 | - public function setScrollLock($value = false) { |
|
69 | - $this->params['scrollLock'] = $value; |
|
68 | + public function setScrollLock($value=false) { |
|
69 | + $this->params['scrollLock']=$value; |
|
70 | 70 | return $this; |
71 | 71 | } |
72 | 72 | |
73 | - public function setReturnScroll($value = false) { |
|
74 | - $this->params['returnScroll'] = $value; |
|
73 | + public function setReturnScroll($value=false) { |
|
74 | + $this->params['returnScroll']=$value; |
|
75 | 75 | return $this; |
76 | 76 | } |
77 | 77 |
@@ -10,50 +10,50 @@ discard block |
||
10 | 10 | private $parameters; |
11 | 11 | |
12 | 12 | public function __construct($method, $parameters) { |
13 | - $this->method = $method; |
|
14 | - $this->parameters = $parameters; |
|
13 | + $this->method=$method; |
|
14 | + $this->parameters=$parameters; |
|
15 | 15 | } |
16 | 16 | |
17 | - public function compile(JsUtils $js = null) { |
|
18 | - if ($js === null) |
|
17 | + public function compile(JsUtils $js=null) { |
|
18 | + if ($js===null) |
|
19 | 19 | return; |
20 | - $params = "{}"; |
|
21 | - $stopPropagation = true; |
|
22 | - $preventDefault = true; |
|
23 | - $method = "get"; |
|
24 | - $this->parameters["immediatly"] = false; |
|
20 | + $params="{}"; |
|
21 | + $stopPropagation=true; |
|
22 | + $preventDefault=true; |
|
23 | + $method="get"; |
|
24 | + $this->parameters["immediatly"]=false; |
|
25 | 25 | extract($this->parameters); |
26 | - $result = $this->_eventPreparing($preventDefault, $stopPropagation); |
|
26 | + $result=$this->_eventPreparing($preventDefault, $stopPropagation); |
|
27 | 27 | switch ($this->method) { |
28 | 28 | case "get": |
29 | - $result .= $js->getDeferred($url, $responseElement, $this->parameters); |
|
29 | + $result.=$js->getDeferred($url, $responseElement, $this->parameters); |
|
30 | 30 | break; |
31 | 31 | case "post": |
32 | - $result .= $js->postDeferred($url, $params, $responseElement, $this->parameters); |
|
32 | + $result.=$js->postDeferred($url, $params, $responseElement, $this->parameters); |
|
33 | 33 | break; |
34 | 34 | case "postForm": |
35 | - $result .= $js->postFormDeferred($url, $form, $responseElement, $this->parameters); |
|
35 | + $result.=$js->postFormDeferred($url, $form, $responseElement, $this->parameters); |
|
36 | 36 | break; |
37 | 37 | case "json": |
38 | - $result .= $js->jsonDeferred($url, $method, $this->parameters); |
|
38 | + $result.=$js->jsonDeferred($url, $method, $this->parameters); |
|
39 | 39 | break; |
40 | 40 | case "jsonArray": |
41 | - $result .= $js->jsonArrayDeferred($modelSelector, $url, $method, $this->parameters); |
|
41 | + $result.=$js->jsonArrayDeferred($modelSelector, $url, $method, $this->parameters); |
|
42 | 42 | break; |
43 | 43 | default: |
44 | - $result .= $js->ajaxDeferred($this->method, $url, $responseElement, $this->parameters); |
|
44 | + $result.=$js->ajaxDeferred($this->method, $url, $responseElement, $this->parameters); |
|
45 | 45 | break; |
46 | 46 | } |
47 | 47 | return $result; |
48 | 48 | } |
49 | 49 | |
50 | 50 | protected function _eventPreparing($preventDefault, $stopPropagation) { |
51 | - $result = ""; |
|
52 | - if ($preventDefault === true) { |
|
53 | - $result .= Javascript::$preventDefault; |
|
51 | + $result=""; |
|
52 | + if ($preventDefault===true) { |
|
53 | + $result.=Javascript::$preventDefault; |
|
54 | 54 | } |
55 | - if ($stopPropagation === true) { |
|
56 | - $result .= Javascript::$stopPropagation; |
|
55 | + if ($stopPropagation===true) { |
|
56 | + $result.=Javascript::$stopPropagation; |
|
57 | 57 | } |
58 | 58 | return $result; |
59 | 59 | } |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | } |
64 | 64 | |
65 | 65 | public function setMethod($method) { |
66 | - $this->method = $method; |
|
66 | + $this->method=$method; |
|
67 | 67 | return $this; |
68 | 68 | } |
69 | 69 | |
@@ -72,7 +72,7 @@ discard block |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | public function setParameters($parameters) { |
75 | - $this->parameters = $parameters; |
|
75 | + $this->parameters=$parameters; |
|
76 | 76 | return $this; |
77 | 77 | } |
78 | 78 | } |
@@ -15,8 +15,9 @@ |
||
15 | 15 | } |
16 | 16 | |
17 | 17 | public function compile(JsUtils $js = null) { |
18 | - if ($js === null) |
|
19 | - return; |
|
18 | + if ($js === null) { |
|
19 | + return; |
|
20 | + } |
|
20 | 21 | $params = "{}"; |
21 | 22 | $stopPropagation = true; |
22 | 23 | $preventDefault = true; |
@@ -126,8 +126,9 @@ discard block |
||
126 | 126 | public function fieldAsLabel($index, $icon = NULL, $attributes = NULL) { |
127 | 127 | return $this->_fieldAs(function ($id, $name, $value) use ($icon) { |
128 | 128 | $lbl = new HtmlLabel($id, $value); |
129 | - if (isset($icon)) |
|
130 | - $lbl->addIcon($icon); |
|
129 | + if (isset($icon)) { |
|
130 | + $lbl->addIcon($icon); |
|
131 | + } |
|
131 | 132 | return $lbl; |
132 | 133 | }, $index, $attributes, "label"); |
133 | 134 | } |
@@ -135,8 +136,9 @@ discard block |
||
135 | 136 | public function fieldAsHeader($index, $niveau = 1, $icon = NULL, $attributes = NULL) { |
136 | 137 | return $this->_fieldAs(function ($id, $name, $value) use ($niveau, $icon) { |
137 | 138 | $header = new HtmlHeader($id, $niveau, $value); |
138 | - if (isset($icon)) |
|
139 | - $header->asIcon($icon, $value); |
|
139 | + if (isset($icon)) { |
|
140 | + $header->asIcon($icon, $value); |
|
141 | + } |
|
140 | 142 | return $header; |
141 | 143 | }, $index, $attributes, "header"); |
142 | 144 | } |
@@ -145,8 +147,9 @@ discard block |
||
145 | 147 | $this->setValueFunction($index, function ($img) use ($size, $circular) { |
146 | 148 | $image = new HtmlImage($this->_getFieldIdentifier("image"), $img); |
147 | 149 | $image->setSize($size); |
148 | - if ($circular) |
|
149 | - $image->setCircular(); |
|
150 | + if ($circular) { |
|
151 | + $image->setCircular(); |
|
152 | + } |
|
150 | 153 | return $image; |
151 | 154 | }); |
152 | 155 | return $this; |
@@ -251,8 +254,9 @@ discard block |
||
251 | 254 | |
252 | 255 | public function fieldAsCheckbox($index, $attributes = NULL) { |
253 | 256 | return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
254 | - if ($caption === null || $caption === "") |
|
255 | - $caption = ""; |
|
257 | + if ($caption === null || $caption === "") { |
|
258 | + $caption = ""; |
|
259 | + } |
|
256 | 260 | $input = new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
257 | 261 | $input->setChecked(JString::isBooleanTrue($value)); |
258 | 262 | return $this->_prepareFormFields($input, $name, $attributes); |
@@ -292,9 +296,9 @@ discard block |
||
292 | 296 | $i = 0; |
293 | 297 | if (JArray::isAssociative($types)) { |
294 | 298 | foreach ($types as $type => $attributes) { |
295 | - if (\is_int($type)) |
|
296 | - $this->fieldAs($i ++, $attributes, []); |
|
297 | - else { |
|
299 | + if (\is_int($type)) { |
|
300 | + $this->fieldAs($i ++, $attributes, []); |
|
301 | + } else { |
|
298 | 302 | $type = preg_replace('/\d/', '', $type); |
299 | 303 | $this->fieldAs($i ++, $type, $attributes); |
300 | 304 | } |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | trait FieldAsTrait { |
39 | 39 | |
40 | - abstract protected function _getFieldIdentifier($prefix, $name = ""); |
|
40 | + abstract protected function _getFieldIdentifier($prefix, $name=""); |
|
41 | 41 | |
42 | 42 | abstract public function setValueFunction($index, $callback); |
43 | 43 | |
@@ -45,7 +45,7 @@ discard block |
||
45 | 45 | |
46 | 46 | abstract protected function _getFieldCaption($index); |
47 | 47 | |
48 | - abstract protected function _buttonAsSubmit(BaseHtml &$button, $event, $url, $responseElement = NULL, $parameters = NULL); |
|
48 | + abstract protected function _buttonAsSubmit(BaseHtml&$button, $event, $url, $responseElement=NULL, $parameters=NULL); |
|
49 | 49 | |
50 | 50 | private $_speProperties; |
51 | 51 | |
@@ -54,9 +54,9 @@ discard block |
||
54 | 54 | * @param HtmlFormField $element |
55 | 55 | * @param array $attributes |
56 | 56 | */ |
57 | - protected function _applyAttributes(BaseHtml $element, &$attributes, $index, $instance = null) { |
|
57 | + protected function _applyAttributes(BaseHtml $element, &$attributes, $index, $instance=null) { |
|
58 | 58 | if (isset($attributes["jsCallback"])) { |
59 | - $callback = $attributes["jsCallback"]; |
|
59 | + $callback=$attributes["jsCallback"]; |
|
60 | 60 | if (\is_callable($callback)) { |
61 | 61 | $callback($element, $instance, $index, InstanceViewer::$index); |
62 | 62 | } |
@@ -67,15 +67,15 @@ discard block |
||
67 | 67 | $element->fromArray($attributes); |
68 | 68 | } |
69 | 69 | |
70 | - private function _getLabelField($caption, $icon = NULL) { |
|
71 | - $label = new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
70 | + private function _getLabelField($caption, $icon=NULL) { |
|
71 | + $label=new HtmlLabel($this->_getFieldIdentifier("lbl"), $caption, $icon); |
|
72 | 72 | return $label; |
73 | 73 | } |
74 | 74 | |
75 | 75 | protected function _addRules(HtmlFormField $element, &$attributes) { |
76 | 76 | if (isset($attributes["rules"])) { |
77 | - $this->_hasRules = true; |
|
78 | - $rules = $attributes["rules"]; |
|
77 | + $this->_hasRules=true; |
|
78 | + $rules=$attributes["rules"]; |
|
79 | 79 | if (\is_array($rules)) { |
80 | 80 | $element->addRules($rules); |
81 | 81 | } else { |
@@ -85,30 +85,30 @@ discard block |
||
85 | 85 | } |
86 | 86 | } |
87 | 87 | |
88 | - protected function _prepareFormFields(HtmlFormField &$field, $name, &$attributes) { |
|
88 | + protected function _prepareFormFields(HtmlFormField&$field, $name, &$attributes) { |
|
89 | 89 | $field->setName($name); |
90 | 90 | $this->_addRules($field, $attributes); |
91 | 91 | return $field; |
92 | 92 | } |
93 | 93 | |
94 | - protected function _fieldAs($elementCallback, &$index, $attributes = NULL, $prefix = null) { |
|
95 | - $this->setValueFunction($index, function ($value, $instance, $index, $rowIndex) use (&$attributes, $elementCallback, $prefix) { |
|
96 | - $caption = $this->_getFieldCaption($index); |
|
97 | - $name = $this->_getFieldName($index); |
|
98 | - $id = $this->_getFieldIdentifier($prefix, $name); |
|
94 | + protected function _fieldAs($elementCallback, &$index, $attributes=NULL, $prefix=null) { |
|
95 | + $this->setValueFunction($index, function($value, $instance, $index, $rowIndex) use (&$attributes, $elementCallback, $prefix) { |
|
96 | + $caption=$this->_getFieldCaption($index); |
|
97 | + $name=$this->_getFieldName($index); |
|
98 | + $id=$this->_getFieldIdentifier($prefix, $name); |
|
99 | 99 | if (isset($attributes["name"])) { |
100 | - $name = $attributes["name"]; |
|
100 | + $name=$attributes["name"]; |
|
101 | 101 | unset($attributes["name"]); |
102 | 102 | } |
103 | - $element = $elementCallback($id, $name, $value, $caption); |
|
103 | + $element=$elementCallback($id, $name, $value, $caption); |
|
104 | 104 | if (isset($this->_speProperties[$index])) { |
105 | - $attributes ??= []; |
|
106 | - $attributes += $this->_speProperties[$index]; |
|
105 | + $attributes??=[]; |
|
106 | + $attributes+=$this->_speProperties[$index]; |
|
107 | 107 | } |
108 | 108 | if (\is_array($attributes)) { |
109 | 109 | $this->_applyAttributes($element, $attributes, $index, $instance); |
110 | 110 | } |
111 | - $element->setDisabled(! $this->_edition); |
|
111 | + $element->setDisabled(!$this->_edition); |
|
112 | 112 | return $element; |
113 | 113 | }); |
114 | 114 | return $this; |
@@ -124,48 +124,48 @@ discard block |
||
124 | 124 | */ |
125 | 125 | public function setPropertyValues($property, $indexValues) { |
126 | 126 | foreach ($indexValues as $index => $value) { |
127 | - $ind = $this->_getIndex($index); |
|
128 | - $this->_speProperties[$ind][$property] = $value; |
|
127 | + $ind=$this->_getIndex($index); |
|
128 | + $this->_speProperties[$ind][$property]=$value; |
|
129 | 129 | } |
130 | 130 | } |
131 | 131 | |
132 | - public function fieldAsProgress($index, $label = NULL, $attributes = array()) { |
|
133 | - $this->setValueFunction($index, function ($value) use ($label, $attributes) { |
|
134 | - $pb = new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
132 | + public function fieldAsProgress($index, $label=NULL, $attributes=array()) { |
|
133 | + $this->setValueFunction($index, function($value) use ($label, $attributes) { |
|
134 | + $pb=new HtmlProgress($this->_getFieldIdentifier("pb"), $value, $label, $attributes); |
|
135 | 135 | return $pb; |
136 | 136 | }); |
137 | 137 | return $this; |
138 | 138 | } |
139 | 139 | |
140 | - public function fieldAsRating($index, $max = 5, $icon = "") { |
|
141 | - $this->setValueFunction($index, function ($value) use ($max, $icon) { |
|
142 | - $rating = new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
140 | + public function fieldAsRating($index, $max=5, $icon="") { |
|
141 | + $this->setValueFunction($index, function($value) use ($max, $icon) { |
|
142 | + $rating=new HtmlRating($this->_getFieldIdentifier("rat"), $value, $max, $icon); |
|
143 | 143 | return $rating; |
144 | 144 | }); |
145 | 145 | return $this; |
146 | 146 | } |
147 | 147 | |
148 | - public function fieldAsLabel($index, $icon = NULL, $attributes = NULL) { |
|
149 | - return $this->_fieldAs(function ($id, $name, $value) use ($icon) { |
|
150 | - $lbl = new HtmlLabel($id, $value); |
|
148 | + public function fieldAsLabel($index, $icon=NULL, $attributes=NULL) { |
|
149 | + return $this->_fieldAs(function($id, $name, $value) use ($icon) { |
|
150 | + $lbl=new HtmlLabel($id, $value); |
|
151 | 151 | if (isset($icon)) |
152 | 152 | $lbl->addIcon($icon); |
153 | 153 | return $lbl; |
154 | 154 | }, $index, $attributes, "label"); |
155 | 155 | } |
156 | 156 | |
157 | - public function fieldAsHeader($index, $niveau = 1, $icon = NULL, $attributes = NULL) { |
|
158 | - return $this->_fieldAs(function ($id, $name, $value) use ($niveau, $icon) { |
|
159 | - $header = new HtmlHeader($id, $niveau, $value); |
|
157 | + public function fieldAsHeader($index, $niveau=1, $icon=NULL, $attributes=NULL) { |
|
158 | + return $this->_fieldAs(function($id, $name, $value) use ($niveau, $icon) { |
|
159 | + $header=new HtmlHeader($id, $niveau, $value); |
|
160 | 160 | if (isset($icon)) |
161 | 161 | $header->asIcon($icon, $value); |
162 | 162 | return $header; |
163 | 163 | }, $index, $attributes, "header"); |
164 | 164 | } |
165 | 165 | |
166 | - public function fieldAsImage($index, $size = Size::MINI, $circular = false) { |
|
167 | - $this->setValueFunction($index, function ($img) use ($size, $circular) { |
|
168 | - $image = new HtmlImage($this->_getFieldIdentifier("image"), $img); |
|
166 | + public function fieldAsImage($index, $size=Size::MINI, $circular=false) { |
|
167 | + $this->setValueFunction($index, function($img) use ($size, $circular) { |
|
168 | + $image=new HtmlImage($this->_getFieldIdentifier("image"), $img); |
|
169 | 169 | $image->setSize($size); |
170 | 170 | if ($circular) |
171 | 171 | $image->setCircular(); |
@@ -175,65 +175,65 @@ discard block |
||
175 | 175 | } |
176 | 176 | |
177 | 177 | public function fieldAsFlag($index) { |
178 | - $this->setValueFunction($index, function ($flag) { |
|
179 | - $flag = new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
178 | + $this->setValueFunction($index, function($flag) { |
|
179 | + $flag=new HtmlFlag($this->_getFieldIdentifier("flag"), $flag); |
|
180 | 180 | return $flag; |
181 | 181 | }); |
182 | 182 | return $this; |
183 | 183 | } |
184 | 184 | |
185 | 185 | public function fieldAsIcon($index) { |
186 | - $this->setValueFunction($index, function ($icon) { |
|
187 | - $icon = new HtmlIcon($this->_getFieldIdentifier("icon"), $icon); |
|
186 | + $this->setValueFunction($index, function($icon) { |
|
187 | + $icon=new HtmlIcon($this->_getFieldIdentifier("icon"), $icon); |
|
188 | 188 | return $icon; |
189 | 189 | }); |
190 | 190 | return $this; |
191 | 191 | } |
192 | 192 | |
193 | - public function fieldAsAvatar($index, $attributes = NULL) { |
|
194 | - return $this->_fieldAs(function ($id, $name, $value) { |
|
195 | - $img = new HtmlImage($id, $value); |
|
193 | + public function fieldAsAvatar($index, $attributes=NULL) { |
|
194 | + return $this->_fieldAs(function($id, $name, $value) { |
|
195 | + $img=new HtmlImage($id, $value); |
|
196 | 196 | $img->asAvatar(); |
197 | 197 | return $img; |
198 | 198 | }, $index, $attributes, "avatar"); |
199 | 199 | } |
200 | 200 | |
201 | - public function fieldAsRadio($index, $attributes = NULL) { |
|
202 | - return $this->_fieldAs(function ($id, $name, $value) use ($attributes) { |
|
203 | - $input = new HtmlFormRadio($id, $name, $value, $value); |
|
201 | + public function fieldAsRadio($index, $attributes=NULL) { |
|
202 | + return $this->_fieldAs(function($id, $name, $value) use ($attributes) { |
|
203 | + $input=new HtmlFormRadio($id, $name, $value, $value); |
|
204 | 204 | return $this->_prepareFormFields($input, $name, $attributes); |
205 | 205 | }, $index, $attributes, "radio"); |
206 | 206 | } |
207 | 207 | |
208 | - public function fieldAsRadios($index, $elements = [], $attributes = NULL) { |
|
209 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($elements) { |
|
208 | + public function fieldAsRadios($index, $elements=[], $attributes=NULL) { |
|
209 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements) { |
|
210 | 210 | return HtmlFormFields::radios($name, $elements, $caption, $value); |
211 | 211 | }, $index, $attributes, "radios"); |
212 | 212 | } |
213 | 213 | |
214 | - public function fieldAsList($index, $classNames = "", $attributes = NULL) { |
|
215 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($classNames) { |
|
216 | - $result = new HtmlList($name, $value); |
|
214 | + public function fieldAsList($index, $classNames="", $attributes=NULL) { |
|
215 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($classNames) { |
|
216 | + $result=new HtmlList($name, $value); |
|
217 | 217 | $result->addClass($classNames); |
218 | 218 | return $result; |
219 | 219 | }, $index, $attributes, "list"); |
220 | 220 | } |
221 | 221 | |
222 | - public function fieldAsInput($index, $attributes = NULL) { |
|
223 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
224 | - $input = new HtmlFormInput($id, $caption, "text", $value); |
|
222 | + public function fieldAsInput($index, $attributes=NULL) { |
|
223 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
224 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
225 | 225 | return $this->_prepareFormFields($input, $name, $attributes); |
226 | 226 | }, $index, $attributes, "input"); |
227 | 227 | } |
228 | 228 | |
229 | - public function fieldAsLabeledInput($index, $attributes = NULL) { |
|
230 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
231 | - $input = new HtmlFormInput($id, '', 'text', $value, $caption); |
|
232 | - $required = ''; |
|
229 | + public function fieldAsLabeledInput($index, $attributes=NULL) { |
|
230 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
231 | + $input=new HtmlFormInput($id, '', 'text', $value, $caption); |
|
232 | + $required=''; |
|
233 | 233 | if (isset($attributes['rules'])) { |
234 | - $rules = json_encode($attributes['rules']); |
|
235 | - if (strpos($rules, 'empty') !== false) { |
|
236 | - $required = 'required'; |
|
234 | + $rules=json_encode($attributes['rules']); |
|
235 | + if (strpos($rules, 'empty')!==false) { |
|
236 | + $required='required'; |
|
237 | 237 | } |
238 | 238 | } |
239 | 239 | $input->getField() |
@@ -244,80 +244,80 @@ discard block |
||
244 | 244 | }, $index, $attributes, 'input'); |
245 | 245 | } |
246 | 246 | |
247 | - public function fieldAsDataList($index, ?array $items = [], $attributes = NULL) { |
|
248 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes, $items) { |
|
249 | - $input = new HtmlFormInput($id, $caption, "text", $value); |
|
247 | + public function fieldAsDataList($index, ?array $items=[], $attributes=NULL) { |
|
248 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes, $items) { |
|
249 | + $input=new HtmlFormInput($id, $caption, "text", $value); |
|
250 | 250 | $input->getField() |
251 | 251 | ->addDataList($items); |
252 | 252 | return $this->_prepareFormFields($input, $name, $attributes); |
253 | 253 | }, $index, $attributes, "input"); |
254 | 254 | } |
255 | 255 | |
256 | - public function fieldAsFile($index, $attributes = NULL) { |
|
256 | + public function fieldAsFile($index, $attributes=NULL) { |
|
257 | 257 | if (isset($this->_form)) { |
258 | 258 | $this->_form->setProperty('enctype', 'multipart/form-data'); |
259 | 259 | } |
260 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
261 | - $input = new HtmlFormInput($id, $caption); |
|
260 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
261 | + $input=new HtmlFormInput($id, $caption); |
|
262 | 262 | $input->asFile(); |
263 | 263 | return $this->_prepareFormFields($input, $name, $attributes); |
264 | 264 | }, $index, $attributes, "input"); |
265 | 265 | } |
266 | 266 | |
267 | - public function fieldAsTextarea($index, $attributes = NULL) { |
|
268 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
269 | - $textarea = new HtmlFormTextarea($id, $caption, $value); |
|
267 | + public function fieldAsTextarea($index, $attributes=NULL) { |
|
268 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
269 | + $textarea=new HtmlFormTextarea($id, $caption, $value); |
|
270 | 270 | return $this->_prepareFormFields($textarea, $name, $attributes); |
271 | 271 | }, $index, $attributes, "textarea"); |
272 | 272 | } |
273 | 273 | |
274 | - public function fieldAsElement($index, $tagName = "div", $baseClass = "", $attributes = NULL) { |
|
275 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes, $tagName, $baseClass) { |
|
276 | - $div = new HtmlSemDoubleElement($id, $tagName, $baseClass); |
|
274 | + public function fieldAsElement($index, $tagName="div", $baseClass="", $attributes=NULL) { |
|
275 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes, $tagName, $baseClass) { |
|
276 | + $div=new HtmlSemDoubleElement($id, $tagName, $baseClass); |
|
277 | 277 | $div->setContent(\htmlentities($value)); |
278 | - $textarea = new HtmlFormField("field-" . $id, $div, $caption); |
|
278 | + $textarea=new HtmlFormField("field-".$id, $div, $caption); |
|
279 | 279 | return $this->_prepareFormFields($textarea, $name, $attributes); |
280 | 280 | }, $index, $attributes, "element"); |
281 | 281 | } |
282 | 282 | |
283 | - public function fieldAsHidden($index, $attributes = NULL) { |
|
284 | - if (! \is_array($attributes)) { |
|
285 | - $attributes = []; |
|
283 | + public function fieldAsHidden($index, $attributes=NULL) { |
|
284 | + if (!\is_array($attributes)) { |
|
285 | + $attributes=[]; |
|
286 | 286 | } |
287 | - $attributes["inputType"] = "hidden"; |
|
288 | - $attributes["style"] = "display:none;"; |
|
287 | + $attributes["inputType"]="hidden"; |
|
288 | + $attributes["style"]="display:none;"; |
|
289 | 289 | return $this->fieldAsInput($index, $attributes); |
290 | 290 | } |
291 | 291 | |
292 | - public function fieldAsCheckbox($index, $attributes = NULL) { |
|
293 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($attributes) { |
|
294 | - if ($caption === null || $caption === "") |
|
295 | - $caption = ""; |
|
296 | - $input = new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
292 | + public function fieldAsCheckbox($index, $attributes=NULL) { |
|
293 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($attributes) { |
|
294 | + if ($caption===null || $caption==="") |
|
295 | + $caption=""; |
|
296 | + $input=new HtmlFormCheckbox($id, $caption, $this->_instanceViewer->getIdentifier()); |
|
297 | 297 | $input->setChecked(JString::isBooleanTrue($value)); |
298 | 298 | return $this->_prepareFormFields($input, $name, $attributes); |
299 | 299 | }, $index, $attributes, "ck"); |
300 | 300 | } |
301 | 301 | |
302 | - public function fieldAsDropDown($index, $elements = [], $multiple = false, $attributes = NULL) { |
|
303 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($elements, $multiple, $attributes) { |
|
304 | - $dd = new HtmlFormDropdown($id, $elements, $caption, $value ?? ''); |
|
302 | + public function fieldAsDropDown($index, $elements=[], $multiple=false, $attributes=NULL) { |
|
303 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($elements, $multiple, $attributes) { |
|
304 | + $dd=new HtmlFormDropdown($id, $elements, $caption, $value ?? ''); |
|
305 | 305 | $dd->asSelect($name, $multiple); |
306 | 306 | return $this->_prepareFormFields($dd, $name, $attributes); |
307 | 307 | }, $index, $attributes, "dd"); |
308 | 308 | } |
309 | 309 | |
310 | - public function fieldAsMessage($index, $attributes = NULL) { |
|
311 | - return $this->_fieldAs(function ($id, $name, $value, $caption) { |
|
312 | - $mess = new HtmlMessage("message-" . $id, $caption); |
|
310 | + public function fieldAsMessage($index, $attributes=NULL) { |
|
311 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
312 | + $mess=new HtmlMessage("message-".$id, $caption); |
|
313 | 313 | $mess->addHeader($value); |
314 | 314 | return $mess; |
315 | 315 | }, $index, $attributes, "message"); |
316 | 316 | } |
317 | 317 | |
318 | - public function fieldAsLink($index, $attributes = NULL) { |
|
319 | - return $this->_fieldAs(function ($id, $name, $value, $caption) { |
|
320 | - $lnk = new HtmlLink("message-" . $id, "#", $caption); |
|
318 | + public function fieldAsLink($index, $attributes=NULL) { |
|
319 | + return $this->_fieldAs(function($id, $name, $value, $caption) { |
|
320 | + $lnk=new HtmlLink("message-".$id, "#", $caption); |
|
321 | 321 | return $lnk; |
322 | 322 | }, $index, $attributes, "link"); |
323 | 323 | } |
@@ -329,28 +329,28 @@ discard block |
||
329 | 329 | * an array or associative array $type=>$attributes |
330 | 330 | */ |
331 | 331 | public function fieldsAs(array $types) { |
332 | - $i = 0; |
|
332 | + $i=0; |
|
333 | 333 | if (JArray::isAssociative($types)) { |
334 | 334 | foreach ($types as $type => $attributes) { |
335 | 335 | if (\is_int($type)) |
336 | - $this->fieldAs($i ++, $attributes, []); |
|
336 | + $this->fieldAs($i++, $attributes, []); |
|
337 | 337 | else { |
338 | - $type = preg_replace('/\d/', '', $type); |
|
339 | - $this->fieldAs($i ++, $type, $attributes); |
|
338 | + $type=preg_replace('/\d/', '', $type); |
|
339 | + $this->fieldAs($i++, $type, $attributes); |
|
340 | 340 | } |
341 | 341 | } |
342 | 342 | } else { |
343 | 343 | foreach ($types as $type) { |
344 | - $this->fieldAs($i ++, $type); |
|
344 | + $this->fieldAs($i++, $type); |
|
345 | 345 | } |
346 | 346 | } |
347 | 347 | } |
348 | 348 | |
349 | - public function fieldAs($index, $type, $attributes = NULL) { |
|
350 | - $method = "fieldAs" . \ucfirst($type); |
|
349 | + public function fieldAs($index, $type, $attributes=NULL) { |
|
350 | + $method="fieldAs".\ucfirst($type); |
|
351 | 351 | if (\method_exists($this, $method)) { |
352 | - if (! \is_array($attributes)) { |
|
353 | - $attributes = [ |
|
352 | + if (!\is_array($attributes)) { |
|
353 | + $attributes=[ |
|
354 | 354 | $index |
355 | 355 | ]; |
356 | 356 | } else { |
@@ -363,39 +363,39 @@ discard block |
||
363 | 363 | } |
364 | 364 | } |
365 | 365 | |
366 | - public function fieldAsSubmit($index, $cssStyle = NULL, $url = NULL, $responseElement = NULL, $attributes = NULL) { |
|
367 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes) { |
|
368 | - $button = new HtmlButton($id, $caption, $cssStyle); |
|
366 | + public function fieldAsSubmit($index, $cssStyle=NULL, $url=NULL, $responseElement=NULL, $attributes=NULL) { |
|
367 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($url, $responseElement, $cssStyle, $attributes) { |
|
368 | + $button=new HtmlButton($id, $caption, $cssStyle); |
|
369 | 369 | $this->_buttonAsSubmit($button, "click", $url, $responseElement, $attributes["ajax"] ?? []); |
370 | 370 | return $button; |
371 | 371 | }, $index, $attributes, "submit"); |
372 | 372 | } |
373 | 373 | |
374 | - public function fieldAsButton($index, $cssStyle = NULL, $attributes = NULL) { |
|
375 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($cssStyle) { |
|
376 | - $button = new HtmlButton($id, $value, $cssStyle); |
|
374 | + public function fieldAsButton($index, $cssStyle=NULL, $attributes=NULL) { |
|
375 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($cssStyle) { |
|
376 | + $button=new HtmlButton($id, $value, $cssStyle); |
|
377 | 377 | return $button; |
378 | 378 | }, $index, $attributes, "button"); |
379 | 379 | } |
380 | 380 | |
381 | - public function fieldAsDataTable($index, $model, $instances = null, $fields = [], $attributes = NULL) { |
|
382 | - return $this->_fieldAs(function ($id, $name, $value, $caption) use ($model, $instances, $fields, $index) { |
|
383 | - $dt = new DataTable($id, $model, $instances); |
|
381 | + public function fieldAsDataTable($index, $model, $instances=null, $fields=[], $attributes=NULL) { |
|
382 | + return $this->_fieldAs(function($id, $name, $value, $caption) use ($model, $instances, $fields, $index) { |
|
383 | + $dt=new DataTable($id, $model, $instances); |
|
384 | 384 | $dt->setNamePrefix($index); |
385 | 385 | $dt->setFields($fields); |
386 | 386 | $dt->setEdition(true); |
387 | - $dt->addDeleteButton(false, [], function ($bt) use ($index) { |
|
387 | + $dt->addDeleteButton(false, [], function($bt) use ($index) { |
|
388 | 388 | $bt->addClass('mini circular') |
389 | - ->wrap('<input value="" class="_status" type="hidden" name="' . $index . '._status[]">'); |
|
389 | + ->wrap('<input value="" class="_status" type="hidden" name="'.$index.'._status[]">'); |
|
390 | 390 | }); |
391 | - if ($caption != null) { |
|
391 | + if ($caption!=null) { |
|
392 | 392 | $dt->setFormCaption($caption); |
393 | 393 | } |
394 | - $dt->onPreCompile(function () use (&$dt) { |
|
394 | + $dt->onPreCompile(function() use (&$dt) { |
|
395 | 395 | $dt->getHtmlComponent() |
396 | 396 | ->colRightFromRight(0); |
397 | 397 | }); |
398 | - $dt->wrap('<input type="hidden" name="' . $index . '">'); |
|
398 | + $dt->wrap('<input type="hidden" name="'.$index.'">'); |
|
399 | 399 | return $dt; |
400 | 400 | }, $index, $attributes, "dataTable"); |
401 | 401 | } |
@@ -34,8 +34,9 @@ discard block |
||
34 | 34 | $callback = ", function(){\n{$callback}\n}"; |
35 | 35 | } |
36 | 36 | $str = "$({$element}).{$action}({$speed}{$callback});"; |
37 | - if ($immediatly) |
|
38 | - $this->jquery_code_for_compile [] = $str; |
|
37 | + if ($immediatly) { |
|
38 | + $this->jquery_code_for_compile [] = $str; |
|
39 | + } |
|
39 | 40 | return $str; |
40 | 41 | } |
41 | 42 | |
@@ -73,10 +74,12 @@ discard block |
||
73 | 74 | if (isset ( $param )) { |
74 | 75 | $param = Javascript::prep_value ( $param ); |
75 | 76 | $str = "$({$element}).{$jQueryCall}({$param});"; |
76 | - } else |
|
77 | - $str = "$({$element}).{$jQueryCall}();"; |
|
78 | - if ($immediatly) |
|
79 | - $this->jquery_code_for_compile [] = $str; |
|
77 | + } else { |
|
78 | + $str = "$({$element}).{$jQueryCall}();"; |
|
79 | + } |
|
80 | + if ($immediatly) { |
|
81 | + $this->jquery_code_for_compile [] = $str; |
|
82 | + } |
|
80 | 83 | return $str; |
81 | 84 | } |
82 | 85 | |
@@ -94,8 +97,9 @@ discard block |
||
94 | 97 | $to = Javascript::prep_element ( $to ); |
95 | 98 | $element = Javascript::prep_element ( $element ); |
96 | 99 | $str = "$({$to}).{$jQueryCall}({$element});"; |
97 | - if ($immediatly) |
|
98 | - $this->jquery_code_for_compile [] = $str; |
|
100 | + if ($immediatly) { |
|
101 | + $this->jquery_code_for_compile [] = $str; |
|
102 | + } |
|
99 | 103 | return $str; |
100 | 104 | } |
101 | 105 | |
@@ -153,10 +157,12 @@ discard block |
||
153 | 157 | if (isset ( $value )) { |
154 | 158 | $value = Javascript::prep_value ( $value ); |
155 | 159 | $str = "$({$element}).attr(\"$attributeName\",{$value});"; |
156 | - } else |
|
157 | - $str = "$({$element}).attr(\"$attributeName\");"; |
|
158 | - if ($immediatly) |
|
159 | - $this->jquery_code_for_compile [] = $str; |
|
160 | + } else { |
|
161 | + $str = "$({$element}).attr(\"$attributeName\");"; |
|
162 | + } |
|
163 | + if ($immediatly) { |
|
164 | + $this->jquery_code_for_compile [] = $str; |
|
165 | + } |
|
160 | 166 | return $str; |
161 | 167 | } |
162 | 168 | |
@@ -219,8 +225,9 @@ discard block |
||
219 | 225 | |
220 | 226 | $str = "$({$element}).animate({\n$animations\n\t\t}" . $speed . $extra . ");"; |
221 | 227 | |
222 | - if ($immediatly) |
|
223 | - $this->jquery_code_for_compile [] = $str; |
|
228 | + if ($immediatly) { |
|
229 | + $this->jquery_code_for_compile [] = $str; |
|
230 | + } |
|
224 | 231 | return $str; |
225 | 232 | } |
226 | 233 | |
@@ -410,8 +417,9 @@ discard block |
||
410 | 417 | $element = Javascript::prep_element ( $element ); |
411 | 418 | $str = "$({$element}).trigger(\"$event\");"; |
412 | 419 | |
413 | - if ($immediatly) |
|
414 | - $this->jquery_code_for_compile [] = $str; |
|
420 | + if ($immediatly) { |
|
421 | + $this->jquery_code_for_compile [] = $str; |
|
422 | + } |
|
415 | 423 | return $str; |
416 | 424 | } |
417 | 425 | |
@@ -481,8 +489,9 @@ discard block |
||
481 | 489 | $str .= "else{" . $jsCodeIfFalse . "}"; |
482 | 490 | } |
483 | 491 | |
484 | - if ($immediatly) |
|
485 | - $this->jquery_code_for_compile [] = $str; |
|
492 | + if ($immediatly) { |
|
493 | + $this->jquery_code_for_compile [] = $str; |
|
494 | + } |
|
486 | 495 | return $str; |
487 | 496 | } |
488 | 497 | |
@@ -500,11 +509,13 @@ discard block |
||
500 | 509 | private function _doJQuery($element, $jqueryCall, $param = "", $jsCallback = "", $immediatly = false) { |
501 | 510 | $param = Javascript::prep_value ( $param ); |
502 | 511 | $callback = ""; |
503 | - if ($jsCallback != "") |
|
504 | - $callback = ", function(event){\n{$jsCallback}\n}"; |
|
512 | + if ($jsCallback != "") { |
|
513 | + $callback = ", function(event){\n{$jsCallback}\n}"; |
|
514 | + } |
|
505 | 515 | $script = "$(" . Javascript::prep_element ( $element ) . ")." . $jqueryCall . "(" . $param . $callback . ");\n"; |
506 | - if ($immediatly) |
|
507 | - $this->jquery_code_for_compile [] = $script; |
|
516 | + if ($immediatly) { |
|
517 | + $this->jquery_code_for_compile [] = $script; |
|
518 | + } |
|
508 | 519 | return $script; |
509 | 520 | } |
510 | 521 | |
@@ -591,8 +602,9 @@ discard block |
||
591 | 602 | */ |
592 | 603 | public function exec($js, $immediatly = false) { |
593 | 604 | $script = $js . "\n"; |
594 | - if ($immediatly) |
|
595 | - $this->jquery_code_for_compile [] = $script; |
|
605 | + if ($immediatly) { |
|
606 | + $this->jquery_code_for_compile [] = $script; |
|
607 | + } |
|
596 | 608 | return $script; |
597 | 609 | } |
598 | 610 |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | */ |
13 | 13 | trait JsUtilsActionsTrait { |
14 | 14 | |
15 | - abstract public function _add_event($element, $js, $event, $preventDefault = false, $stopPropagation = false, $immediatly = true, $listenerOn=false); |
|
15 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true, $listenerOn=false); |
|
16 | 16 | |
17 | 17 | /** |
18 | 18 | * show or hide with effect |
@@ -28,15 +28,15 @@ discard block |
||
28 | 28 | * defers the execution if set to false |
29 | 29 | * @return string |
30 | 30 | */ |
31 | - protected function _showHideWithEffect($action, $element = 'this', $speed = '', $callback = '', $immediatly = false) { |
|
32 | - $element = Javascript::prep_element ( $element ); |
|
33 | - $speed = $this->_validate_speed ( $speed ); |
|
34 | - if ($callback != '') { |
|
35 | - $callback = ", function(){\n{$callback}\n}"; |
|
31 | + protected function _showHideWithEffect($action, $element='this', $speed='', $callback='', $immediatly=false) { |
|
32 | + $element=Javascript::prep_element($element); |
|
33 | + $speed=$this->_validate_speed($speed); |
|
34 | + if ($callback!='') { |
|
35 | + $callback=", function(){\n{$callback}\n}"; |
|
36 | 36 | } |
37 | - $str = "$({$element}).{$action}({$speed}{$callback});"; |
|
37 | + $str="$({$element}).{$action}({$speed}{$callback});"; |
|
38 | 38 | if ($immediatly) |
39 | - $this->jquery_code_for_compile [] = $str; |
|
39 | + $this->jquery_code_for_compile []=$str; |
|
40 | 40 | return $str; |
41 | 41 | } |
42 | 42 | |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | * @return string |
48 | 48 | */ |
49 | 49 | private function _validate_speed($speed) { |
50 | - if (in_array ( $speed, array ( |
|
50 | + if (in_array($speed, array( |
|
51 | 51 | 'slow', |
52 | 52 | 'normal', |
53 | 53 | 'fast' |
54 | - ) )) { |
|
55 | - $speed = '"' . $speed . '"'; |
|
56 | - } elseif (preg_match ( "/[^0-9]/", $speed )) { |
|
57 | - $speed = ''; |
|
54 | + ))) { |
|
55 | + $speed='"'.$speed.'"'; |
|
56 | + } elseif (preg_match("/[^0-9]/", $speed)) { |
|
57 | + $speed=''; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | return $speed; |
@@ -69,15 +69,15 @@ discard block |
||
69 | 69 | * @param boolean $immediatly |
70 | 70 | * delayed if false |
71 | 71 | */ |
72 | - public function _genericCallValue($jQueryCall, $element = 'this', $param = "", $immediatly = false) { |
|
73 | - $element = Javascript::prep_element ( $element ); |
|
74 | - if (isset ( $param )) { |
|
75 | - $param = Javascript::prep_value ( $param ); |
|
76 | - $str = "$({$element}).{$jQueryCall}({$param});"; |
|
72 | + public function _genericCallValue($jQueryCall, $element='this', $param="", $immediatly=false) { |
|
73 | + $element=Javascript::prep_element($element); |
|
74 | + if (isset ($param)) { |
|
75 | + $param=Javascript::prep_value($param); |
|
76 | + $str="$({$element}).{$jQueryCall}({$param});"; |
|
77 | 77 | } else |
78 | - $str = "$({$element}).{$jQueryCall}();"; |
|
78 | + $str="$({$element}).{$jQueryCall}();"; |
|
79 | 79 | if ($immediatly) |
80 | - $this->jquery_code_for_compile [] = $str; |
|
80 | + $this->jquery_code_for_compile []=$str; |
|
81 | 81 | return $str; |
82 | 82 | } |
83 | 83 | |
@@ -91,12 +91,12 @@ discard block |
||
91 | 91 | * delayed if false |
92 | 92 | * @return string |
93 | 93 | */ |
94 | - public function _genericCallElement($jQueryCall, $to = 'this', $element = '', $immediatly = false) { |
|
95 | - $to = Javascript::prep_element ( $to ); |
|
96 | - $element = Javascript::prep_element ( $element ); |
|
97 | - $str = "$({$to}).{$jQueryCall}({$element});"; |
|
94 | + public function _genericCallElement($jQueryCall, $to='this', $element='', $immediatly=false) { |
|
95 | + $to=Javascript::prep_element($to); |
|
96 | + $element=Javascript::prep_element($element); |
|
97 | + $str="$({$to}).{$jQueryCall}({$element});"; |
|
98 | 98 | if ($immediatly) |
99 | - $this->jquery_code_for_compile [] = $str; |
|
99 | + $this->jquery_code_for_compile []=$str; |
|
100 | 100 | return $str; |
101 | 101 | } |
102 | 102 | |
@@ -110,8 +110,8 @@ discard block |
||
110 | 110 | * defers the execution if set to false |
111 | 111 | * @return string |
112 | 112 | */ |
113 | - public function addClass($element = 'this', $class = '', $immediatly = false) { |
|
114 | - return $this->_genericCallValue ( 'addClass', $element, $class, $immediatly ); |
|
113 | + public function addClass($element='this', $class='', $immediatly=false) { |
|
114 | + return $this->_genericCallValue('addClass', $element, $class, $immediatly); |
|
115 | 115 | } |
116 | 116 | |
117 | 117 | /** |
@@ -123,8 +123,8 @@ discard block |
||
123 | 123 | * defers the execution if set to false |
124 | 124 | * @return string |
125 | 125 | */ |
126 | - public function after($to, $element, $immediatly = false) { |
|
127 | - return $this->_genericCallElement ( 'after', $to, $element, $immediatly ); |
|
126 | + public function after($to, $element, $immediatly=false) { |
|
127 | + return $this->_genericCallElement('after', $to, $element, $immediatly); |
|
128 | 128 | } |
129 | 129 | |
130 | 130 | /** |
@@ -136,8 +136,8 @@ discard block |
||
136 | 136 | * defers the execution if set to false |
137 | 137 | * @return string |
138 | 138 | */ |
139 | - public function before($to, $element, $immediatly = false) { |
|
140 | - return $this->_genericCallElement ( 'before', $to, $element, $immediatly ); |
|
139 | + public function before($to, $element, $immediatly=false) { |
|
140 | + return $this->_genericCallElement('before', $to, $element, $immediatly); |
|
141 | 141 | } |
142 | 142 | |
143 | 143 | /** |
@@ -149,15 +149,15 @@ discard block |
||
149 | 149 | * @param boolean $immediatly |
150 | 150 | * delayed if false |
151 | 151 | */ |
152 | - public function attr($element = 'this', $attributeName = 'id', $value = "", $immediatly = false) { |
|
153 | - $element = Javascript::prep_element ( $element ); |
|
154 | - if (isset ( $value )) { |
|
155 | - $value = Javascript::prep_value ( $value ); |
|
156 | - $str = "$({$element}).attr(\"$attributeName\",{$value});"; |
|
152 | + public function attr($element='this', $attributeName='id', $value="", $immediatly=false) { |
|
153 | + $element=Javascript::prep_element($element); |
|
154 | + if (isset ($value)) { |
|
155 | + $value=Javascript::prep_value($value); |
|
156 | + $str="$({$element}).attr(\"$attributeName\",{$value});"; |
|
157 | 157 | } else |
158 | - $str = "$({$element}).attr(\"$attributeName\");"; |
|
158 | + $str="$({$element}).attr(\"$attributeName\");"; |
|
159 | 159 | if ($immediatly) |
160 | - $this->jquery_code_for_compile [] = $str; |
|
160 | + $this->jquery_code_for_compile []=$str; |
|
161 | 161 | return $str; |
162 | 162 | } |
163 | 163 | |
@@ -169,8 +169,8 @@ discard block |
||
169 | 169 | * @param boolean $immediatly |
170 | 170 | * defers the execution if set to false |
171 | 171 | */ |
172 | - public function val($element = 'this', $value = '', $immediatly = false) { |
|
173 | - return $this->_genericCallValue ( 'val', $element, $value, $immediatly ); |
|
172 | + public function val($element='this', $value='', $immediatly=false) { |
|
173 | + return $this->_genericCallValue('val', $element, $value, $immediatly); |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | /** |
@@ -181,8 +181,8 @@ discard block |
||
181 | 181 | * @param boolean $immediatly |
182 | 182 | * defers the execution if set to false |
183 | 183 | */ |
184 | - public function html($element = 'this', $value = '', $immediatly = false) { |
|
185 | - return $this->_genericCallValue ( 'html', $element, $value, $immediatly ); |
|
184 | + public function html($element='this', $value='', $immediatly=false) { |
|
185 | + return $this->_genericCallValue('html', $element, $value, $immediatly); |
|
186 | 186 | } |
187 | 187 | |
188 | 188 | /** |
@@ -198,30 +198,30 @@ discard block |
||
198 | 198 | * defers the execution if set to false |
199 | 199 | * @return string |
200 | 200 | */ |
201 | - public function animate($element = 'this', $params = array (), $speed = '', $extra = '', $immediatly = false) { |
|
202 | - $element = Javascript::prep_element ( $element ); |
|
203 | - $speed = $this->_validate_speed ( $speed ); |
|
201 | + public function animate($element='this', $params=array(), $speed='', $extra='', $immediatly=false) { |
|
202 | + $element=Javascript::prep_element($element); |
|
203 | + $speed=$this->_validate_speed($speed); |
|
204 | 204 | |
205 | - $animations = "\t\t\t"; |
|
206 | - if (\is_array ( $params )) { |
|
207 | - foreach ( $params as $param => $value ) { |
|
208 | - $animations .= $param . ': \'' . $value . '\', '; |
|
205 | + $animations="\t\t\t"; |
|
206 | + if (\is_array ($params)) { |
|
207 | + foreach ($params as $param => $value) { |
|
208 | + $animations.=$param.': \''.$value.'\', '; |
|
209 | 209 | } |
210 | 210 | } |
211 | - $animations = substr ( $animations, 0, - 2 ); // remove the last ", " |
|
211 | + $animations=substr($animations, 0, - 2); // remove the last ", " |
|
212 | 212 | |
213 | - if ($speed != '') { |
|
214 | - $speed = ', ' . $speed; |
|
213 | + if ($speed!='') { |
|
214 | + $speed=', '.$speed; |
|
215 | 215 | } |
216 | 216 | |
217 | - if ($extra != '') { |
|
218 | - $extra = ', ' . $extra; |
|
217 | + if ($extra!='') { |
|
218 | + $extra=', '.$extra; |
|
219 | 219 | } |
220 | 220 | |
221 | - $str = "$({$element}).animate({\n$animations\n\t\t}" . $speed . $extra . ");"; |
|
221 | + $str="$({$element}).animate({\n$animations\n\t\t}".$speed.$extra.");"; |
|
222 | 222 | |
223 | 223 | if ($immediatly) |
224 | - $this->jquery_code_for_compile [] = $str; |
|
224 | + $this->jquery_code_for_compile []=$str; |
|
225 | 225 | return $str; |
226 | 226 | } |
227 | 227 | |
@@ -234,8 +234,8 @@ discard block |
||
234 | 234 | * defers the execution if set to false |
235 | 235 | * @return string |
236 | 236 | */ |
237 | - public function append($to, $element, $immediatly = false) { |
|
238 | - return $this->_genericCallElement ( 'append', $to, $element, $immediatly ); |
|
237 | + public function append($to, $element, $immediatly=false) { |
|
238 | + return $this->_genericCallElement('append', $to, $element, $immediatly); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | /** |
@@ -247,8 +247,8 @@ discard block |
||
247 | 247 | * defers the execution if set to false |
248 | 248 | * @return string |
249 | 249 | */ |
250 | - public function prepend($to, $element, $immediatly = false) { |
|
251 | - return $this->_genericCallElement ( 'prepend', $to, $element, $immediatly ); |
|
250 | + public function prepend($to, $element, $immediatly=false) { |
|
251 | + return $this->_genericCallElement('prepend', $to, $element, $immediatly); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -264,8 +264,8 @@ discard block |
||
264 | 264 | * defers the execution if set to false |
265 | 265 | * @return string |
266 | 266 | */ |
267 | - public function fadeIn($element = 'this', $speed = '', $callback = '', $immediatly = false) { |
|
268 | - return $this->_showHideWithEffect ( "fadeIn", $element, $speed, $callback, $immediatly ); |
|
267 | + public function fadeIn($element='this', $speed='', $callback='', $immediatly=false) { |
|
268 | + return $this->_showHideWithEffect("fadeIn", $element, $speed, $callback, $immediatly); |
|
269 | 269 | } |
270 | 270 | |
271 | 271 | /** |
@@ -281,8 +281,8 @@ discard block |
||
281 | 281 | * defers the execution if set to false |
282 | 282 | * @return string |
283 | 283 | */ |
284 | - public function fadeOut($element = 'this', $speed = '', $callback = '', $immediatly = false) { |
|
285 | - return $this->_showHideWithEffect ( "fadeOut", $element, $speed, $callback, $immediatly ); |
|
284 | + public function fadeOut($element='this', $speed='', $callback='', $immediatly=false) { |
|
285 | + return $this->_showHideWithEffect("fadeOut", $element, $speed, $callback, $immediatly); |
|
286 | 286 | } |
287 | 287 | |
288 | 288 | /** |
@@ -298,8 +298,8 @@ discard block |
||
298 | 298 | * defers the execution if set to false |
299 | 299 | * @return string |
300 | 300 | */ |
301 | - public function slideUp($element = 'this', $speed = '', $callback = '', $immediatly = false) { |
|
302 | - return $this->_showHideWithEffect ( "slideUp", $element, $speed, $callback, $immediatly ); |
|
301 | + public function slideUp($element='this', $speed='', $callback='', $immediatly=false) { |
|
302 | + return $this->_showHideWithEffect("slideUp", $element, $speed, $callback, $immediatly); |
|
303 | 303 | } |
304 | 304 | |
305 | 305 | /** |
@@ -313,8 +313,8 @@ discard block |
||
313 | 313 | * defers the execution if set to false |
314 | 314 | * @return string |
315 | 315 | */ |
316 | - public function removeClass($element = 'this', $class = '', $immediatly = false) { |
|
317 | - return $this->_genericCallValue ( 'removeClass', $element, $class, $immediatly ); |
|
316 | + public function removeClass($element='this', $class='', $immediatly=false) { |
|
317 | + return $this->_genericCallValue('removeClass', $element, $class, $immediatly); |
|
318 | 318 | } |
319 | 319 | |
320 | 320 | /** |
@@ -330,8 +330,8 @@ discard block |
||
330 | 330 | * defers the execution if set to false |
331 | 331 | * @return string |
332 | 332 | */ |
333 | - public function slideDown($element = 'this', $speed = '', $callback = '', $immediatly = false) { |
|
334 | - return $this->_showHideWithEffect ( "slideDown", $element, $speed, $callback, $immediatly ); |
|
333 | + public function slideDown($element='this', $speed='', $callback='', $immediatly=false) { |
|
334 | + return $this->_showHideWithEffect("slideDown", $element, $speed, $callback, $immediatly); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | /** |
@@ -347,8 +347,8 @@ discard block |
||
347 | 347 | * defers the execution if set to false |
348 | 348 | * @return string |
349 | 349 | */ |
350 | - public function slideToggle($element = 'this', $speed = '', $callback = '', $immediatly = false) { |
|
351 | - return $this->_showHideWithEffect ( "slideToggle", $element, $speed, $callback, $immediatly ); |
|
350 | + public function slideToggle($element='this', $speed='', $callback='', $immediatly=false) { |
|
351 | + return $this->_showHideWithEffect("slideToggle", $element, $speed, $callback, $immediatly); |
|
352 | 352 | } |
353 | 353 | |
354 | 354 | /** |
@@ -364,8 +364,8 @@ discard block |
||
364 | 364 | * defers the execution if set to false |
365 | 365 | * @return string |
366 | 366 | */ |
367 | - public function hide($element = 'this', $speed = '', $callback = '', $immediatly = false) { |
|
368 | - return $this->_showHideWithEffect ( "hide", $element, $speed, $callback, $immediatly ); |
|
367 | + public function hide($element='this', $speed='', $callback='', $immediatly=false) { |
|
368 | + return $this->_showHideWithEffect("hide", $element, $speed, $callback, $immediatly); |
|
369 | 369 | } |
370 | 370 | |
371 | 371 | /** |
@@ -381,8 +381,8 @@ discard block |
||
381 | 381 | * defers the execution if set to false |
382 | 382 | * @return string |
383 | 383 | */ |
384 | - public function toggle($element = 'this', $speed = '', $callback = '', $immediatly = false) { |
|
385 | - return $this->_showHideWithEffect ( "toggle", $element, $speed, $callback, $immediatly ); |
|
384 | + public function toggle($element='this', $speed='', $callback='', $immediatly=false) { |
|
385 | + return $this->_showHideWithEffect("toggle", $element, $speed, $callback, $immediatly); |
|
386 | 386 | } |
387 | 387 | |
388 | 388 | /** |
@@ -395,8 +395,8 @@ discard block |
||
395 | 395 | * defers the execution if set to false |
396 | 396 | * @return string |
397 | 397 | */ |
398 | - public function toggleClass($element = 'this', $class = '', $immediatly = false) { |
|
399 | - return $this->_genericCallValue ( 'toggleClass', $element, $class, $immediatly ); |
|
398 | + public function toggleClass($element='this', $class='', $immediatly=false) { |
|
399 | + return $this->_genericCallValue('toggleClass', $element, $class, $immediatly); |
|
400 | 400 | } |
401 | 401 | |
402 | 402 | /** |
@@ -407,12 +407,12 @@ discard block |
||
407 | 407 | * @param boolean $immediatly |
408 | 408 | * defers the execution if set to false |
409 | 409 | */ |
410 | - public function trigger($element = 'this', $event = 'click', $immediatly = false) { |
|
411 | - $element = Javascript::prep_element ( $element ); |
|
412 | - $str = "$({$element}).trigger(\"$event\");"; |
|
410 | + public function trigger($element='this', $event='click', $immediatly=false) { |
|
411 | + $element=Javascript::prep_element($element); |
|
412 | + $str="$({$element}).trigger(\"$event\");"; |
|
413 | 413 | |
414 | 414 | if ($immediatly) |
415 | - $this->jquery_code_for_compile [] = $str; |
|
415 | + $this->jquery_code_for_compile []=$str; |
|
416 | 416 | return $str; |
417 | 417 | } |
418 | 418 | |
@@ -429,8 +429,8 @@ discard block |
||
429 | 429 | * defers the execution if set to false |
430 | 430 | * @return string |
431 | 431 | */ |
432 | - public function show($element = 'this', $speed = '', $callback = '', $immediatly = false) { |
|
433 | - return $this->_showHideWithEffect ( "show", $element, $speed, $callback, $immediatly ); |
|
432 | + public function show($element='this', $speed='', $callback='', $immediatly=false) { |
|
433 | + return $this->_showHideWithEffect("show", $element, $speed, $callback, $immediatly); |
|
434 | 434 | } |
435 | 435 | |
436 | 436 | /** |
@@ -440,18 +440,18 @@ discard block |
||
440 | 440 | * @param array $options |
441 | 441 | * @return string |
442 | 442 | */ |
443 | - public function sortable($element, $options = array ()) { |
|
444 | - if (count ( $options ) > 0) { |
|
445 | - $sort_options = array (); |
|
446 | - foreach ( $options as $k => $v ) { |
|
447 | - $sort_options [] = "\n\t\t" . $k . ': ' . $v . ""; |
|
443 | + public function sortable($element, $options=array()) { |
|
444 | + if (count($options)>0) { |
|
445 | + $sort_options=array(); |
|
446 | + foreach ($options as $k => $v) { |
|
447 | + $sort_options []="\n\t\t".$k.': '.$v.""; |
|
448 | 448 | } |
449 | - $sort_options = implode ( ",", $sort_options ); |
|
449 | + $sort_options=implode(",", $sort_options); |
|
450 | 450 | } else { |
451 | - $sort_options = ''; |
|
451 | + $sort_options=''; |
|
452 | 452 | } |
453 | 453 | |
454 | - return "$(" . Javascript::prep_element ( $element ) . ").sortable({" . $sort_options . "\n\t});"; |
|
454 | + return "$(".Javascript::prep_element($element).").sortable({".$sort_options."\n\t});"; |
|
455 | 455 | } |
456 | 456 | |
457 | 457 | /** |
@@ -463,8 +463,8 @@ discard block |
||
463 | 463 | * plugin location |
464 | 464 | * @return string |
465 | 465 | */ |
466 | - public function tablesorter($table = '', $options = '') { |
|
467 | - $this->jquery_code_for_compile [] = "\t$(" . Javascript::prep_element ( $table ) . ").tablesorter($options);\n"; |
|
466 | + public function tablesorter($table='', $options='') { |
|
467 | + $this->jquery_code_for_compile []="\t$(".Javascript::prep_element($table).").tablesorter($options);\n"; |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | /** |
@@ -476,14 +476,14 @@ discard block |
||
476 | 476 | * @param boolean $immediatly |
477 | 477 | * defers the execution if set to false |
478 | 478 | */ |
479 | - public function condition($condition, $jsCodeIfTrue, $jsCodeIfFalse = null, $immediatly = false) { |
|
480 | - $str = "if(" . $condition . "){" . $jsCodeIfTrue . "}"; |
|
481 | - if (isset ( $jsCodeIfFalse )) { |
|
482 | - $str .= "else{" . $jsCodeIfFalse . "}"; |
|
479 | + public function condition($condition, $jsCodeIfTrue, $jsCodeIfFalse=null, $immediatly=false) { |
|
480 | + $str="if(".$condition."){".$jsCodeIfTrue."}"; |
|
481 | + if (isset ($jsCodeIfFalse)) { |
|
482 | + $str.="else{".$jsCodeIfFalse."}"; |
|
483 | 483 | } |
484 | 484 | |
485 | 485 | if ($immediatly) |
486 | - $this->jquery_code_for_compile [] = $str; |
|
486 | + $this->jquery_code_for_compile []=$str; |
|
487 | 487 | return $str; |
488 | 488 | } |
489 | 489 | |
@@ -498,14 +498,14 @@ discard block |
||
498 | 498 | * @param boolean $immediatly |
499 | 499 | * @return string |
500 | 500 | */ |
501 | - private function _doJQuery($element, $jqueryCall, $param = "", $jsCallback = "", $immediatly = false) { |
|
502 | - $param = Javascript::prep_value ( $param ); |
|
503 | - $callback = ""; |
|
504 | - if ($jsCallback != "") |
|
505 | - $callback = ", function(event){\n{$jsCallback}\n}"; |
|
506 | - $script = "$(" . Javascript::prep_element ( $element ) . ")." . $jqueryCall . "(" . $param . $callback . ");\n"; |
|
501 | + private function _doJQuery($element, $jqueryCall, $param="", $jsCallback="", $immediatly=false) { |
|
502 | + $param=Javascript::prep_value($param); |
|
503 | + $callback=""; |
|
504 | + if ($jsCallback!="") |
|
505 | + $callback=", function(event){\n{$jsCallback}\n}"; |
|
506 | + $script="$(".Javascript::prep_element($element).").".$jqueryCall."(".$param.$callback.");\n"; |
|
507 | 507 | if ($immediatly) |
508 | - $this->jquery_code_for_compile [] = $script; |
|
508 | + $this->jquery_code_for_compile []=$script; |
|
509 | 509 | return $script; |
510 | 510 | } |
511 | 511 | |
@@ -522,8 +522,8 @@ discard block |
||
522 | 522 | * javascript code to execute after the jquery call |
523 | 523 | * @return mixed |
524 | 524 | */ |
525 | - public function doJQuery($element, $jqueryCall, $param = "", $jsCallback = "") { |
|
526 | - return $this->_doJQuery ( $element, $jqueryCall, $param, $jsCallback, true ); |
|
525 | + public function doJQuery($element, $jqueryCall, $param="", $jsCallback="") { |
|
526 | + return $this->_doJQuery($element, $jqueryCall, $param, $jsCallback, true); |
|
527 | 527 | } |
528 | 528 | |
529 | 529 | /** |
@@ -539,8 +539,8 @@ discard block |
||
539 | 539 | * javascript code to execute after the jquery call |
540 | 540 | * @return mixed |
541 | 541 | */ |
542 | - public function doJQueryDeferred($element, $jqueryCall, $param = "", $jsCallback = "") { |
|
543 | - return $this->_doJQuery ( $element, $jqueryCall, $param, $jsCallback, false ); |
|
542 | + public function doJQueryDeferred($element, $jqueryCall, $param="", $jsCallback="") { |
|
543 | + return $this->_doJQuery($element, $jqueryCall, $param, $jsCallback, false); |
|
544 | 544 | } |
545 | 545 | |
546 | 546 | /** |
@@ -557,8 +557,8 @@ discard block |
||
557 | 557 | * @param boolean $immediatly |
558 | 558 | * @return string |
559 | 559 | */ |
560 | - private function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param = "", $preventDefault = false, $stopPropagation = false, $jsCallback = "", $immediatly = true) { |
|
561 | - return $this->_add_event ( $element, $this->_doJQuery ( $elementToModify, $jqueryCall, $param, $jsCallback ), $event, $preventDefault, $stopPropagation, $immediatly ); |
|
560 | + private function _doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $preventDefault=false, $stopPropagation=false, $jsCallback="", $immediatly=true) { |
|
561 | + return $this->_add_event($element, $this->_doJQuery($elementToModify, $jqueryCall, $param, $jsCallback), $event, $preventDefault, $stopPropagation, $immediatly); |
|
562 | 562 | } |
563 | 563 | |
564 | 564 | /** |
@@ -572,13 +572,13 @@ discard block |
||
572 | 572 | * @param array $parameters |
573 | 573 | * default : array("preventDefault"=>false,"stopPropagation"=>false,"jsCallback"=>'',"immediatly"=>true) |
574 | 574 | */ |
575 | - public function doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param = "", $parameters = array ()) { |
|
576 | - $jsCallback = ""; |
|
577 | - $stopPropagation = false; |
|
578 | - $preventDefault = false; |
|
579 | - $immediatly = true; |
|
580 | - extract ( $parameters ); |
|
581 | - return $this->_doJQueryOn ( $event, $element, $elementToModify, $jqueryCall, $param, $preventDefault, $stopPropagation, $jsCallback, $immediatly ); |
|
575 | + public function doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param="", $parameters=array()) { |
|
576 | + $jsCallback=""; |
|
577 | + $stopPropagation=false; |
|
578 | + $preventDefault=false; |
|
579 | + $immediatly=true; |
|
580 | + extract($parameters); |
|
581 | + return $this->_doJQueryOn($event, $element, $elementToModify, $jqueryCall, $param, $preventDefault, $stopPropagation, $jsCallback, $immediatly); |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | /** |
@@ -590,10 +590,10 @@ discard block |
||
590 | 590 | * delayed if false |
591 | 591 | * @return String |
592 | 592 | */ |
593 | - public function exec($js, $immediatly = false) { |
|
594 | - $script = $js . "\n"; |
|
593 | + public function exec($js, $immediatly=false) { |
|
594 | + $script=$js."\n"; |
|
595 | 595 | if ($immediatly) |
596 | - $this->jquery_code_for_compile [] = $script; |
|
596 | + $this->jquery_code_for_compile []=$script; |
|
597 | 597 | return $script; |
598 | 598 | } |
599 | 599 | |
@@ -607,8 +607,8 @@ discard block |
||
607 | 607 | * @return String |
608 | 608 | */ |
609 | 609 | public function execAtLast($js) { |
610 | - $script = $js . "\n"; |
|
611 | - $this->jquery_code_for_compile_at_last [] = $script; |
|
610 | + $script=$js."\n"; |
|
611 | + $this->jquery_code_for_compile_at_last []=$script; |
|
612 | 612 | return $script; |
613 | 613 | } |
614 | 614 | |
@@ -623,18 +623,18 @@ discard block |
||
623 | 623 | * default : array("preventDefault"=>false,"stopPropagation"=>false,"immediatly"=>true) |
624 | 624 | * @return String |
625 | 625 | */ |
626 | - public function execOn($event, $element, $js, $parameters = array ()) { |
|
627 | - $stopPropagation = false; |
|
628 | - $preventDefault = false; |
|
629 | - $immediatly = true; |
|
630 | - extract ( $parameters ); |
|
631 | - $script = $this->_add_event ( $element, $this->exec ( $js ), $event, $preventDefault, $stopPropagation, $immediatly ); |
|
626 | + public function execOn($event, $element, $js, $parameters=array()) { |
|
627 | + $stopPropagation=false; |
|
628 | + $preventDefault=false; |
|
629 | + $immediatly=true; |
|
630 | + extract($parameters); |
|
631 | + $script=$this->_add_event($element, $this->exec($js), $event, $preventDefault, $stopPropagation, $immediatly); |
|
632 | 632 | return $script; |
633 | 633 | } |
634 | - public function setJsonToElement($json, $elementClass = "_element", $immediatly = true) { |
|
635 | - $retour = "var data={$json};" . "\n\tdata=($.isPlainObject(data))?data:JSON.parse(data);" . "\n\tvar pk=data['pk'];var object=data['object'];" . "\n\tfor(var field in object){" . "\n\tif($('[data-field='+field+']',$('._element[data-ajax='+pk+']')).length){" . "\n\t\t$('[data-field='+field+']',$('._element[data-ajax='+pk+']')).each(function(){" . "\n\t\t\tif($(this).is('[value]')) { $(this).val(object[field]);} else { $(this).html(object[field]); }" . "\n\t});" . "\n}};\n"; |
|
636 | - $retour .= "\t$(document).trigger('jsonReady',[data]);\n"; |
|
637 | - return $this->exec ( $retour, $immediatly ); |
|
634 | + public function setJsonToElement($json, $elementClass="_element", $immediatly=true) { |
|
635 | + $retour="var data={$json};"."\n\tdata=($.isPlainObject(data))?data:JSON.parse(data);"."\n\tvar pk=data['pk'];var object=data['object'];"."\n\tfor(var field in object){"."\n\tif($('[data-field='+field+']',$('._element[data-ajax='+pk+']')).length){"."\n\t\t$('[data-field='+field+']',$('._element[data-ajax='+pk+']')).each(function(){"."\n\t\t\tif($(this).is('[value]')) { $(this).val(object[field]);} else { $(this).html(object[field]); }"."\n\t});"."\n}};\n"; |
|
636 | + $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
|
637 | + return $this->exec($retour, $immediatly); |
|
638 | 638 | } |
639 | 639 | |
640 | 640 | /** |
@@ -645,13 +645,13 @@ discard block |
||
645 | 645 | * @param array $parameters |
646 | 646 | * default : array("attr"=>"id","preventDefault"=>false,"stopPropagation"=>false,"immediatly"=>true) |
647 | 647 | */ |
648 | - public function setDraggable($element, $parameters = [ ]) { |
|
649 | - $attr = "id"; |
|
650 | - $preventDefault = false; |
|
651 | - $stopPropagation = false; |
|
652 | - $immediatly = true; |
|
653 | - extract ( $parameters ); |
|
654 | - $script = $this->_add_event ( $element, Javascript::draggable ( $attr ), "dragstart", $preventDefault, $stopPropagation, $immediatly ); |
|
648 | + public function setDraggable($element, $parameters=[]) { |
|
649 | + $attr="id"; |
|
650 | + $preventDefault=false; |
|
651 | + $stopPropagation=false; |
|
652 | + $immediatly=true; |
|
653 | + extract($parameters); |
|
654 | + $script=$this->_add_event($element, Javascript::draggable($attr), "dragstart", $preventDefault, $stopPropagation, $immediatly); |
|
655 | 655 | return $script; |
656 | 656 | } |
657 | 657 | |
@@ -665,13 +665,13 @@ discard block |
||
665 | 665 | * @param string $jsCallback |
666 | 666 | * the js script to call when element is dropped |
667 | 667 | */ |
668 | - public function asDropZone($element, $jsCallback = "", $parameters = [ ]) { |
|
669 | - $stopPropagation = false; |
|
670 | - $immediatly = true; |
|
671 | - $jqueryDone = "append"; |
|
672 | - $script = $this->_add_event ( $element, '', "dragover", true, $stopPropagation, $immediatly ); |
|
673 | - extract ( $parameters ); |
|
674 | - $script .= $this->_add_event ( $element, Javascript::dropZone ( $jqueryDone, $jsCallback ), "drop", true, $stopPropagation, $immediatly ); |
|
668 | + public function asDropZone($element, $jsCallback="", $parameters=[]) { |
|
669 | + $stopPropagation=false; |
|
670 | + $immediatly=true; |
|
671 | + $jqueryDone="append"; |
|
672 | + $script=$this->_add_event($element, '', "dragover", true, $stopPropagation, $immediatly); |
|
673 | + extract($parameters); |
|
674 | + $script.=$this->_add_event($element, Javascript::dropZone($jqueryDone, $jsCallback), "drop", true, $stopPropagation, $immediatly); |
|
675 | 675 | return $script; |
676 | 676 | } |
677 | 677 | |
@@ -688,16 +688,16 @@ discard block |
||
688 | 688 | * delayed if false |
689 | 689 | * @return string |
690 | 690 | */ |
691 | - public function interval($jsCode, $time, $globalName = null, $immediatly = true) { |
|
692 | - if (! Javascript::isFunction ( $jsCode )) { |
|
693 | - $jsCode = "function(){\n" . $jsCode . "\n}"; |
|
691 | + public function interval($jsCode, $time, $globalName=null, $immediatly=true) { |
|
692 | + if (!Javascript::isFunction($jsCode)) { |
|
693 | + $jsCode="function(){\n".$jsCode."\n}"; |
|
694 | 694 | } |
695 | - if (isset ( $globalName )) { |
|
696 | - $script = "if(window.{$globalName}){clearInterval(window.{$globalName});}\nwindow.{$globalName}=setInterval({$jsCode},{$time});"; |
|
695 | + if (isset ($globalName)) { |
|
696 | + $script="if(window.{$globalName}){clearInterval(window.{$globalName});}\nwindow.{$globalName}=setInterval({$jsCode},{$time});"; |
|
697 | 697 | } else { |
698 | - $script = "setInterval({$jsCode},{$time});"; |
|
698 | + $script="setInterval({$jsCode},{$time});"; |
|
699 | 699 | } |
700 | - return $this->exec ( $script, $immediatly ); |
|
700 | + return $this->exec($script, $immediatly); |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | /** |
@@ -709,8 +709,8 @@ discard block |
||
709 | 709 | * delayed if false |
710 | 710 | * @return string |
711 | 711 | */ |
712 | - public function clearInterval($globalName, $immediatly = true) { |
|
713 | - return $this->exec ( "if(window.{$globalName}){clearInterval(window.{$globalName});}", $immediatly ); |
|
712 | + public function clearInterval($globalName, $immediatly=true) { |
|
713 | + return $this->exec("if(window.{$globalName}){clearInterval(window.{$globalName});}", $immediatly); |
|
714 | 714 | } |
715 | 715 | |
716 | 716 | /** |
@@ -731,20 +731,20 @@ discard block |
||
731 | 731 | * delayed if false |
732 | 732 | * @return string |
733 | 733 | */ |
734 | - public function counter($counterSelector, $value = 0, $limit = 0, $globalName = null, $countDown = true, $immediatly = true) { |
|
735 | - $stop = ""; |
|
734 | + public function counter($counterSelector, $value=0, $limit=0, $globalName=null, $countDown=true, $immediatly=true) { |
|
735 | + $stop=""; |
|
736 | 736 | if ($countDown) { |
737 | - $stop = "if (--timer < " . $limit . ") {clearInterval(interval);display.trigger({type:'counter-end',value: timer,limit:" . $limit . "});}"; |
|
737 | + $stop="if (--timer < ".$limit.") {clearInterval(interval);display.trigger({type:'counter-end',value: timer,limit:".$limit."});}"; |
|
738 | 738 | } else { |
739 | - if ($limit != 0) { |
|
740 | - $stop = "if (++timer > " . $limit . ") {clearInterval(interval);display.trigger({type:'counter-end',value: timer,limit:" . $limit . "});}"; |
|
739 | + if ($limit!=0) { |
|
740 | + $stop="if (++timer > ".$limit.") {clearInterval(interval);display.trigger({type:'counter-end',value: timer,limit:".$limit."});}"; |
|
741 | 741 | } |
742 | 742 | } |
743 | - $global = ""; |
|
744 | - if (isset ( $globalName )) { |
|
745 | - $global = "\nwindow.{$globalName}=interval;"; |
|
743 | + $global=""; |
|
744 | + if (isset ($globalName)) { |
|
745 | + $global="\nwindow.{$globalName}=interval;"; |
|
746 | 746 | } |
747 | - $timer = "var startTimer=function(duration, display) {var timer = duration, days, hours, minutes, seconds; |
|
747 | + $timer="var startTimer=function(duration, display) {var timer = duration, days, hours, minutes, seconds; |
|
748 | 748 | var sh=function(disp,v){if(disp.is('[value]')){disp.val(v);} else {disp.html(v);};}; |
749 | 749 | var shHide=function(v,k,kBefore){if(v==0 && display.find(k).closest('.timer').is(':visible') && (!kBefore || !display.find(kBefore).closest('.timer').is(':visible'))){display.find(k).closest('.timer').hide();}else{sh(display.find(k),v);}}; |
750 | 750 | var pl=function(v,text){return (v>1)?v+' '+text+'s':(v>0)?v+' '+text:'';}; |
@@ -760,12 +760,12 @@ discard block |
||
760 | 760 | minutes = d0(parseInt((timer%3600) / 60, 10)); |
761 | 761 | seconds = d0(parseInt(timer%60, 10)); |
762 | 762 | mainSh(days,hours,minutes,seconds); |
763 | - " . $stop . " |
|
763 | + " . $stop." |
|
764 | 764 | }, 1000); |
765 | - " . $global . " |
|
765 | + " . $global." |
|
766 | 766 | }"; |
767 | - $element = '$("' . $counterSelector . '")'; |
|
768 | - return $this->exec ( $timer . "\nstartTimer(" . $value . "," . $element . ");", $immediatly ); |
|
767 | + $element='$("'.$counterSelector.'")'; |
|
768 | + return $this->exec($timer."\nstartTimer(".$value.",".$element.");", $immediatly); |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | /** |
@@ -787,8 +787,8 @@ discard block |
||
787 | 787 | * count down if true or elapse if false |
788 | 788 | * @return string |
789 | 789 | */ |
790 | - public function counterOn($element, $event, $counterSelector, $value = 0, $limit = 0, $globalName = null, $countDown = true) { |
|
791 | - return $this->execOn ( $event, $element, $this->counter ( $counterSelector, $value, $limit, $globalName, $countDown, false ) ); |
|
790 | + public function counterOn($element, $event, $counterSelector, $value=0, $limit=0, $globalName=null, $countDown=true) { |
|
791 | + return $this->execOn($event, $element, $this->counter($counterSelector, $value, $limit, $globalName, $countDown, false)); |
|
792 | 792 | } |
793 | 793 | |
794 | 794 | /** |
@@ -802,8 +802,8 @@ discard block |
||
802 | 802 | * the active href (if null, window.location.href is used) |
803 | 803 | * @return string |
804 | 804 | */ |
805 | - public function activateLink($target, $property = 'href', $href = null) { |
|
806 | - return $this->execAtLast ( $this->_activateLink ( $target, $property, $href ) ); |
|
805 | + public function activateLink($target, $property='href', $href=null) { |
|
806 | + return $this->execAtLast($this->_activateLink($target, $property, $href)); |
|
807 | 807 | } |
808 | 808 | |
809 | 809 | /** |
@@ -817,14 +817,14 @@ discard block |
||
817 | 817 | * the active href (if null, window.location.href is used) |
818 | 818 | * @return string |
819 | 819 | */ |
820 | - public function _activateLink($target, $property = 'href', $href = null) { |
|
821 | - $js = '$("' . $target . ' [' . $property . ']").removeClass("active");'; |
|
822 | - if (isset ( $href )) { |
|
823 | - $js .= 'var href="' . $href . '";'; |
|
820 | + public function _activateLink($target, $property='href', $href=null) { |
|
821 | + $js='$("'.$target.' ['.$property.']").removeClass("active");'; |
|
822 | + if (isset ($href)) { |
|
823 | + $js.='var href="'.$href.'";'; |
|
824 | 824 | } else { |
825 | - $js .= 'var href=window.location.href;'; |
|
825 | + $js.='var href=window.location.href;'; |
|
826 | 826 | } |
827 | - $js .= '$("' . $target . ' [' . $property . ']").each(function(){if(href.includes($(this).attr("' . $property . '"))) $(this).addClass("active");});'; |
|
827 | + $js.='$("'.$target.' ['.$property.']").each(function(){if(href.includes($(this).attr("'.$property.'"))) $(this).addClass("active");});'; |
|
828 | 828 | return $js; |
829 | 829 | } |
830 | 830 | } |
@@ -10,7 +10,7 @@ discard block |
||
10 | 10 | * @property array $jquery_code_for_compile |
11 | 11 | */ |
12 | 12 | trait JsUtilsEventsTrait { |
13 | - protected $jquery_events = [ |
|
13 | + protected $jquery_events=[ |
|
14 | 14 | 'bind', |
15 | 15 | 'blur', |
16 | 16 | 'change', |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | 'unload' |
52 | 52 | ]; |
53 | 53 | |
54 | - abstract public function _add_event($element, $js, $event, $preventDefault = false, $stopPropagation = false, $immediatly = true, $listenerOn=false); |
|
54 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true, $listenerOn=false); |
|
55 | 55 | |
56 | 56 | /** |
57 | 57 | * Outputs a javascript library blur event |
@@ -62,8 +62,8 @@ discard block |
||
62 | 62 | * code to execute |
63 | 63 | * @return string |
64 | 64 | */ |
65 | - public function blur($element = 'this', $js = '', $preventDefault = false, $stopPropagation = false, $listenerOn=false) { |
|
66 | - return $this->_add_event ( $element, $js, 'blur', $preventDefault, $stopPropagation, true, $listenerOn ); |
|
65 | + public function blur($element='this', $js='', $preventDefault=false, $stopPropagation=false, $listenerOn=false) { |
|
66 | + return $this->_add_event($element, $js, 'blur', $preventDefault, $stopPropagation, true, $listenerOn); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | /** |
@@ -78,8 +78,8 @@ discard block |
||
78 | 78 | * @param boolean|string $listenerOn use a selector for a delegated event handler |
79 | 79 | * @return string |
80 | 80 | */ |
81 | - public function change($element = 'this', $js = '', $preventDefault = false, $stopPropagation = false, $listenerOn=false) { |
|
82 | - return $this->_add_event ( $element, $js, 'change', $preventDefault, $stopPropagation, true, $listenerOn ); |
|
81 | + public function change($element='this', $js='', $preventDefault=false, $stopPropagation=false, $listenerOn=false) { |
|
82 | + return $this->_add_event($element, $js, 'change', $preventDefault, $stopPropagation, true, $listenerOn); |
|
83 | 83 | } |
84 | 84 | |
85 | 85 | /** |
@@ -96,18 +96,18 @@ discard block |
||
96 | 96 | * @param boolean|string $listenerOn use a selector for a delegated event handler |
97 | 97 | * @return string |
98 | 98 | */ |
99 | - public function click($element = 'this', $js = '', $ret_false = TRUE, $preventDefault = false, $stopPropagation = false, $listenerOn=false) { |
|
100 | - if (! is_array ( $js )) { |
|
101 | - $js = array ( |
|
99 | + public function click($element='this', $js='', $ret_false=TRUE, $preventDefault=false, $stopPropagation=false, $listenerOn=false) { |
|
100 | + if (!is_array($js)) { |
|
101 | + $js=array( |
|
102 | 102 | $js |
103 | 103 | ); |
104 | 104 | } |
105 | 105 | |
106 | 106 | if ($ret_false) { |
107 | - $js [] = "return false;"; |
|
107 | + $js []="return false;"; |
|
108 | 108 | } |
109 | 109 | |
110 | - return $this->_add_event ( $element, $js, 'click', $preventDefault, $stopPropagation, true, $listenerOn ); |
|
110 | + return $this->_add_event($element, $js, 'click', $preventDefault, $stopPropagation, true, $listenerOn); |
|
111 | 111 | } |
112 | 112 | |
113 | 113 | /** |
@@ -122,8 +122,8 @@ discard block |
||
122 | 122 | * @param boolean|string $listenerOn use a selector for a delegated event handler |
123 | 123 | * @return string |
124 | 124 | */ |
125 | - public function contextmenu($element = 'this', $js = '', $preventDefault = false, $stopPropagation = false, $listenerOn=false) { |
|
126 | - return $this->_add_event ( $element, $js, 'contextmenu', $preventDefault, $stopPropagation, true, $listenerOn ); |
|
125 | + public function contextmenu($element='this', $js='', $preventDefault=false, $stopPropagation=false, $listenerOn=false) { |
|
126 | + return $this->_add_event($element, $js, 'contextmenu', $preventDefault, $stopPropagation, true, $listenerOn); |
|
127 | 127 | } |
128 | 128 | |
129 | 129 | /** |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | * @param boolean|string $listenerOn use a selector for a delegated event handler |
139 | 139 | * @return string |
140 | 140 | */ |
141 | - public function dblclick($element = 'this', $js = '', $preventDefault = false, $stopPropagation = false, $listenerOn=false) { |
|
142 | - return $this->_add_event ( $element, $js, 'dblclick', $preventDefault, $stopPropagation, true, $listenerOn ); |
|
141 | + public function dblclick($element='this', $js='', $preventDefault=false, $stopPropagation=false, $listenerOn=false) { |
|
142 | + return $this->_add_event($element, $js, 'dblclick', $preventDefault, $stopPropagation, true, $listenerOn); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -151,8 +151,8 @@ discard block |
||
151 | 151 | * code to execute |
152 | 152 | * @return string |
153 | 153 | */ |
154 | - public function error($element = 'this', $js = '') { |
|
155 | - return $this->_add_event ( $element, $js, 'error' ); |
|
154 | + public function error($element='this', $js='') { |
|
155 | + return $this->_add_event($element, $js, 'error'); |
|
156 | 156 | } |
157 | 157 | |
158 | 158 | /** |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @param boolean|string $listenerOn use a selector for a delegated event handler |
168 | 168 | * @return string |
169 | 169 | */ |
170 | - public function focus($element = 'this', $js = '', $preventDefault = false, $stopPropagation = false, $listenerOn=false) { |
|
171 | - return $this->_add_event ( $element, $js, 'focus', $preventDefault, $stopPropagation, true, $listenerOn ); |
|
170 | + public function focus($element='this', $js='', $preventDefault=false, $stopPropagation=false, $listenerOn=false) { |
|
171 | + return $this->_add_event($element, $js, 'focus', $preventDefault, $stopPropagation, true, $listenerOn); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | /** |
@@ -181,9 +181,9 @@ discard block |
||
181 | 181 | * code for mouse out |
182 | 182 | * @return string |
183 | 183 | */ |
184 | - public function hover($element = 'this', $over = '', $out = '') { |
|
185 | - $event = "\n\t$(" . Javascript::prep_element ( $element ) . ").hover(\n\t\tfunction()\n\t\t{\n\t\t\t{$over}\n\t\t}, \n\t\tfunction()\n\t\t{\n\t\t\t{$out}\n\t\t});\n"; |
|
186 | - $this->jquery_code_for_compile [] = $event; |
|
184 | + public function hover($element='this', $over='', $out='') { |
|
185 | + $event="\n\t$(".Javascript::prep_element($element).").hover(\n\t\tfunction()\n\t\t{\n\t\t\t{$over}\n\t\t}, \n\t\tfunction()\n\t\t{\n\t\t\t{$out}\n\t\t});\n"; |
|
186 | + $this->jquery_code_for_compile []=$event; |
|
187 | 187 | return $event; |
188 | 188 | } |
189 | 189 | |
@@ -199,8 +199,8 @@ discard block |
||
199 | 199 | * @param boolean|string $listenerOn use a selector for a delegated event handler |
200 | 200 | * @return string |
201 | 201 | */ |
202 | - public function keydown($element = 'this', $js = '', $preventDefault = false, $stopPropagation = false, $listenerOn=false) { |
|
203 | - return $this->_add_event ( $element, $js, 'keydown', $preventDefault, $stopPropagation, true, $listenerOn ); |
|
202 | + public function keydown($element='this', $js='', $preventDefault=false, $stopPropagation=false, $listenerOn=false) { |
|
203 | + return $this->_add_event($element, $js, 'keydown', $preventDefault, $stopPropagation, true, $listenerOn); |
|
204 | 204 | } |
205 | 205 | |
206 | 206 | /** |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | * @param boolean|string $listenerOn use a selector for a delegated event handler |
216 | 216 | * @return string |
217 | 217 | */ |
218 | - public function keypress($element = 'this', $js = '', $preventDefault = false, $stopPropagation = false, $listenerOn=false) { |
|
219 | - return $this->_add_event ( $element, $js, 'keypress', $preventDefault, $stopPropagation, true, $listenerOn ); |
|
218 | + public function keypress($element='this', $js='', $preventDefault=false, $stopPropagation=false, $listenerOn=false) { |
|
219 | + return $this->_add_event($element, $js, 'keypress', $preventDefault, $stopPropagation, true, $listenerOn); |
|
220 | 220 | } |
221 | 221 | |
222 | 222 | /** |
@@ -231,8 +231,8 @@ discard block |
||
231 | 231 | * @param boolean|string $listenerOn use a selector for a delegated event handler |
232 | 232 | * @return string |
233 | 233 | */ |
234 | - public function keyup($element = 'this', $js = '', $preventDefault = false, $stopPropagation = false, $listenerOn=false) { |
|
235 | - return $this->_add_event ( $element, $js, 'keyup', $preventDefault, $stopPropagation, true, $listenerOn ); |
|
234 | + public function keyup($element='this', $js='', $preventDefault=false, $stopPropagation=false, $listenerOn=false) { |
|
235 | + return $this->_add_event($element, $js, 'keyup', $preventDefault, $stopPropagation, true, $listenerOn); |
|
236 | 236 | } |
237 | 237 | |
238 | 238 | /** |
@@ -247,8 +247,8 @@ discard block |
||
247 | 247 | * @param boolean|string $listenerOn use a selector for a delegated event handler |
248 | 248 | * @return string |
249 | 249 | */ |
250 | - public function load($element = 'this', $js = '', $preventDefault = false, $stopPropagation = false, $listenerOn=false) { |
|
251 | - return $this->_add_event ( $element, $js, 'load', $preventDefault, $stopPropagation, true, $listenerOn ); |
|
250 | + public function load($element='this', $js='', $preventDefault=false, $stopPropagation=false, $listenerOn=false) { |
|
251 | + return $this->_add_event($element, $js, 'load', $preventDefault, $stopPropagation, true, $listenerOn); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | /** |
@@ -263,8 +263,8 @@ discard block |
||
263 | 263 | * @param boolean|string $listenerOn use a selector for a delegated event handler |
264 | 264 | * @return string |
265 | 265 | */ |
266 | - public function mousedown($element = 'this', $js = '', $preventDefault = false, $stopPropagation = false, $listenerOn=false) { |
|
267 | - return $this->_add_event ( $element, $js, 'mousedown', $preventDefault, $stopPropagation, true, $listenerOn ); |
|
266 | + public function mousedown($element='this', $js='', $preventDefault=false, $stopPropagation=false, $listenerOn=false) { |
|
267 | + return $this->_add_event($element, $js, 'mousedown', $preventDefault, $stopPropagation, true, $listenerOn); |
|
268 | 268 | } |
269 | 269 | |
270 | 270 | /** |
@@ -279,8 +279,8 @@ discard block |
||
279 | 279 | * @param boolean|string $listenerOn use a selector for a delegated event handler |
280 | 280 | * @return string |
281 | 281 | */ |
282 | - public function mouseout($element = 'this', $js = '', $preventDefault = false, $stopPropagation = false, $listenerOn=false) { |
|
283 | - return $this->_add_event ( $element, $js, 'mouseout', $preventDefault, $stopPropagation, true, $listenerOn ); |
|
282 | + public function mouseout($element='this', $js='', $preventDefault=false, $stopPropagation=false, $listenerOn=false) { |
|
283 | + return $this->_add_event($element, $js, 'mouseout', $preventDefault, $stopPropagation, true, $listenerOn); |
|
284 | 284 | } |
285 | 285 | |
286 | 286 | /** |
@@ -295,8 +295,8 @@ discard block |
||
295 | 295 | * @param boolean|string $listenerOn use a selector for a delegated event handler |
296 | 296 | * @return string |
297 | 297 | */ |
298 | - public function mouseleave($element = 'this', $js = '', $preventDefault = false, $stopPropagation = false, $listenerOn=false) { |
|
299 | - return $this->_add_event ( $element, $js, 'mouseleave', $preventDefault, $stopPropagation, true, $listenerOn ); |
|
298 | + public function mouseleave($element='this', $js='', $preventDefault=false, $stopPropagation=false, $listenerOn=false) { |
|
299 | + return $this->_add_event($element, $js, 'mouseleave', $preventDefault, $stopPropagation, true, $listenerOn); |
|
300 | 300 | } |
301 | 301 | |
302 | 302 | /** |
@@ -311,8 +311,8 @@ discard block |
||
311 | 311 | * @param boolean|string $listenerOn use a selector for a delegated event handler |
312 | 312 | * @return string |
313 | 313 | */ |
314 | - public function mouseenter($element = 'this', $js = '', $preventDefault = false, $stopPropagation = false, $listenerOn=false) { |
|
315 | - return $this->_add_event ( $element, $js, 'mouseenter', $preventDefault, $stopPropagation, true, $listenerOn ); |
|
314 | + public function mouseenter($element='this', $js='', $preventDefault=false, $stopPropagation=false, $listenerOn=false) { |
|
315 | + return $this->_add_event($element, $js, 'mouseenter', $preventDefault, $stopPropagation, true, $listenerOn); |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | /** |
@@ -327,8 +327,8 @@ discard block |
||
327 | 327 | * @param boolean|string $listenerOn use a selector for a delegated event handler |
328 | 328 | * @return string |
329 | 329 | */ |
330 | - public function mouseover($element = 'this', $js = '', $preventDefault = false, $stopPropagation = false, $listenerOn=false) { |
|
331 | - return $this->_add_event ( $element, $js, 'mouseover', $preventDefault, $stopPropagation, true, $listenerOn ); |
|
330 | + public function mouseover($element='this', $js='', $preventDefault=false, $stopPropagation=false, $listenerOn=false) { |
|
331 | + return $this->_add_event($element, $js, 'mouseover', $preventDefault, $stopPropagation, true, $listenerOn); |
|
332 | 332 | } |
333 | 333 | |
334 | 334 | /** |
@@ -343,8 +343,8 @@ discard block |
||
343 | 343 | * @param boolean|string $listenerOn use a selector for a delegated event handler |
344 | 344 | * @return string |
345 | 345 | */ |
346 | - public function mouseup($element = 'this', $js = '', $preventDefault = false, $stopPropagation = false, $listenerOn=false) { |
|
347 | - return $this->_add_event ( $element, $js, 'mouseup', $preventDefault, $stopPropagation, true, $listenerOn ); |
|
346 | + public function mouseup($element='this', $js='', $preventDefault=false, $stopPropagation=false, $listenerOn=false) { |
|
347 | + return $this->_add_event($element, $js, 'mouseup', $preventDefault, $stopPropagation, true, $listenerOn); |
|
348 | 348 | } |
349 | 349 | |
350 | 350 | /** |
@@ -359,8 +359,8 @@ discard block |
||
359 | 359 | * @param boolean|string $listenerOn use a selector for a delegated event handler |
360 | 360 | * @return string |
361 | 361 | */ |
362 | - public function unload($element = 'this', $js = '', $preventDefault = false, $stopPropagation = false, $listenerOn=false) { |
|
363 | - return $this->_add_event ( $element, $js, 'unload', $preventDefault, $stopPropagation, true, $listenerOn ); |
|
362 | + public function unload($element='this', $js='', $preventDefault=false, $stopPropagation=false, $listenerOn=false) { |
|
363 | + return $this->_add_event($element, $js, 'unload', $preventDefault, $stopPropagation, true, $listenerOn); |
|
364 | 364 | } |
365 | 365 | |
366 | 366 | // -------------------------------------------------------------------- |
@@ -376,8 +376,8 @@ discard block |
||
376 | 376 | * @param boolean|string $listenerOn use a selector for a delegated event handler |
377 | 377 | * @return string |
378 | 378 | */ |
379 | - public function resize($element = 'this', $js = '', $preventDefault = false, $stopPropagation = false, $listenerOn=false) { |
|
380 | - return $this->_add_event ( $element, $js, 'resize', $preventDefault, $stopPropagation, true, $listenerOn ); |
|
379 | + public function resize($element='this', $js='', $preventDefault=false, $stopPropagation=false, $listenerOn=false) { |
|
380 | + return $this->_add_event($element, $js, 'resize', $preventDefault, $stopPropagation, true, $listenerOn); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | // -------------------------------------------------------------------- |
@@ -393,7 +393,7 @@ discard block |
||
393 | 393 | * @param boolean|string $listenerOn use a selector for a delegated event handler |
394 | 394 | * @return string |
395 | 395 | */ |
396 | - public function scroll($element = 'this', $js = '', $preventDefault = false, $stopPropagation = false, $listenerOn=false) { |
|
397 | - return $this->_add_event ( $element, $js, 'scroll', $preventDefault, $stopPropagation, true, $listenerOn ); |
|
396 | + public function scroll($element='this', $js='', $preventDefault=false, $stopPropagation=false, $listenerOn=false) { |
|
397 | + return $this->_add_event($element, $js, 'scroll', $preventDefault, $stopPropagation, true, $listenerOn); |
|
398 | 398 | } |
399 | 399 | } |
@@ -18,19 +18,19 @@ discard block |
||
18 | 18 | */ |
19 | 19 | class HtmlTab extends HtmlSemCollection { |
20 | 20 | |
21 | - protected $params = []; |
|
21 | + protected $params=[]; |
|
22 | 22 | |
23 | - protected $_activated = false; |
|
23 | + protected $_activated=false; |
|
24 | 24 | |
25 | - public function __construct($identifier, $tabs = array()) { |
|
25 | + public function __construct($identifier, $tabs=array()) { |
|
26 | 26 | parent::__construct($identifier, "div", ""); |
27 | - $menu = new HtmlMenu("menu" . $this->identifier); |
|
27 | + $menu=new HtmlMenu("menu".$this->identifier); |
|
28 | 28 | $menu->asTab(false)->setAttachment(NULL, Side::TOP); |
29 | - $this->content["menu"] = $menu; |
|
29 | + $this->content["menu"]=$menu; |
|
30 | 30 | $this->addItems($tabs); |
31 | 31 | } |
32 | 32 | |
33 | - public function getMenu(){ |
|
33 | + public function getMenu() { |
|
34 | 34 | return $this->content['menu']; |
35 | 35 | } |
36 | 36 | |
@@ -41,18 +41,18 @@ discard block |
||
41 | 41 | * @return HtmlSegment |
42 | 42 | */ |
43 | 43 | protected function createItem($value) { |
44 | - $count = $this->count(); |
|
45 | - $title = $value; |
|
46 | - $content = NULL; |
|
44 | + $count=$this->count(); |
|
45 | + $title=$value; |
|
46 | + $content=NULL; |
|
47 | 47 | if (\is_array($value)) { |
48 | - $title = @$value[0]; |
|
49 | - $content = @$value[1]; |
|
48 | + $title=@$value[0]; |
|
49 | + $content=@$value[1]; |
|
50 | 50 | } |
51 | - $menuItem = $this->content["menu"]->addItem($title); |
|
51 | + $menuItem=$this->content["menu"]->addItem($title); |
|
52 | 52 | $menuItem->addToProperty("data-tab", $menuItem->getIdentifier()); |
53 | 53 | $menuItem->removeProperty("href"); |
54 | - $result = $this->createSegment($count, $content, $menuItem->getIdentifier()); |
|
55 | - $result->menuTab = $menuItem; |
|
54 | + $result=$this->createSegment($count, $content, $menuItem->getIdentifier()); |
|
55 | + $result->menuTab=$menuItem; |
|
56 | 56 | return $result; |
57 | 57 | } |
58 | 58 | |
@@ -64,7 +64,7 @@ discard block |
||
64 | 64 | * @return \Ajax\semantic\html\elements\HtmlSegment |
65 | 65 | */ |
66 | 66 | private function createSegment($count, $content, $datatab) { |
67 | - $segment = new HtmlSegment("item-" . $this->identifier . "-" . $count, $content); |
|
67 | + $segment=new HtmlSegment("item-".$this->identifier."-".$count, $content); |
|
68 | 68 | $segment->setAttachment(NULL, Side::BOTTOM) |
69 | 69 | ->addToProperty("class", "tab") |
70 | 70 | ->addToProperty("data-tab", $datatab); |
@@ -81,10 +81,10 @@ discard block |
||
81 | 81 | * @return \Ajax\semantic\html\modules\HtmlTab |
82 | 82 | */ |
83 | 83 | public function setTabContent($index, $content) { |
84 | - $menu = $this->content["menu"]; |
|
85 | - if ($index < $menu->count()) { |
|
86 | - if (isset($this->content[$index]) === false) { |
|
87 | - $this->content[$index] = $this->createSegment($index, $content, $menu->getItem($index) |
|
84 | + $menu=$this->content["menu"]; |
|
85 | + if ($index<$menu->count()) { |
|
86 | + if (isset($this->content[$index])===false) { |
|
87 | + $this->content[$index]=$this->createSegment($index, $content, $menu->getItem($index) |
|
88 | 88 | ->getIdentifier()); |
89 | 89 | } else |
90 | 90 | $this->content[$index]->setContent($content); |
@@ -99,8 +99,8 @@ discard block |
||
99 | 99 | * @return \Ajax\semantic\html\modules\HtmlTab |
100 | 100 | */ |
101 | 101 | public function setTabsContent($contents) { |
102 | - $size = \sizeof($contents); |
|
103 | - for ($i = 0; $i < $size; $i ++) { |
|
102 | + $size=\sizeof($contents); |
|
103 | + for ($i=0; $i<$size; $i++) { |
|
104 | 104 | $this->setTabContent($i, $contents[$i]); |
105 | 105 | } |
106 | 106 | return $this; |
@@ -113,11 +113,11 @@ discard block |
||
113 | 113 | * @return \Ajax\semantic\html\modules\HtmlTab |
114 | 114 | */ |
115 | 115 | public function activate($index) { |
116 | - $item = $this->content["menu"]->getItem($index); |
|
117 | - if ($item != null) { |
|
116 | + $item=$this->content["menu"]->getItem($index); |
|
117 | + if ($item!=null) { |
|
118 | 118 | $item->setActive(true); |
119 | 119 | $this->content[$index]->setActive(true); |
120 | - $this->_activated = true; |
|
120 | + $this->_activated=true; |
|
121 | 121 | } |
122 | 122 | return $this; |
123 | 123 | } |
@@ -151,9 +151,9 @@ discard block |
||
151 | 151 | * @param array $params |
152 | 152 | * @return \Ajax\semantic\html\elements\HtmlSegment |
153 | 153 | */ |
154 | - public function forwardTab($index, JsUtils $js, $title, $initialController, $controller, $action, $params = array()) { |
|
154 | + public function forwardTab($index, JsUtils $js, $title, $initialController, $controller, $action, $params=array()) { |
|
155 | 155 | if (\array_key_exists($index, $this->content)) { |
156 | - $this->content[$index] = $js->forward($initialController, $controller, $action, $params); |
|
156 | + $this->content[$index]=$js->forward($initialController, $controller, $action, $params); |
|
157 | 157 | return $this->content[$index]; |
158 | 158 | } |
159 | 159 | |
@@ -174,9 +174,9 @@ discard block |
||
174 | 174 | * The parameters to pass to the view |
175 | 175 | * @return \Ajax\semantic\html\elements\HtmlSegment |
176 | 176 | */ |
177 | - public function renderViewTab($index, JsUtils $js, $title, $initialController, $viewName, $params = array()) { |
|
177 | + public function renderViewTab($index, JsUtils $js, $title, $initialController, $viewName, $params=array()) { |
|
178 | 178 | if (\array_key_exists($index, $this->content)) { |
179 | - $this->content[$index] = $js->renderContent($initialController, $viewName, $params); |
|
179 | + $this->content[$index]=$js->renderContent($initialController, $viewName, $params); |
|
180 | 180 | return $this->content[$index]; |
181 | 181 | } |
182 | 182 | return $this->addAndRenderViewTab($js, $title, $initialController, $viewName, $params); |
@@ -196,10 +196,10 @@ discard block |
||
196 | 196 | * @param array $params |
197 | 197 | * @return \Ajax\semantic\html\elements\HtmlSegment |
198 | 198 | */ |
199 | - public function addAndForwardTab(JsUtils $js, $title, $initialController, $controller, $action, $params = array()) { |
|
199 | + public function addAndForwardTab(JsUtils $js, $title, $initialController, $controller, $action, $params=array()) { |
|
200 | 200 | \ob_start(); |
201 | 201 | $js->forward($initialController, $controller, $action, $params); |
202 | - $content = \ob_get_clean(); |
|
202 | + $content=\ob_get_clean(); |
|
203 | 203 | return $this->addTab($title, $content); |
204 | 204 | } |
205 | 205 | |
@@ -215,11 +215,11 @@ discard block |
||
215 | 215 | * The parameters to pass to the view |
216 | 216 | * @return \Ajax\semantic\html\elements\HtmlSegment |
217 | 217 | */ |
218 | - public function addAndRenderViewTab(JsUtils $js, $title, $initialController, $viewName, $params = array()) { |
|
218 | + public function addAndRenderViewTab(JsUtils $js, $title, $initialController, $viewName, $params=array()) { |
|
219 | 219 | return $this->addTab($title, $js->renderContent($initialController, $viewName, $params)); |
220 | 220 | } |
221 | 221 | |
222 | - public function setPointing($value = Direction::NONE) { |
|
222 | + public function setPointing($value=Direction::NONE) { |
|
223 | 223 | return $this->content["menu"]->setPointing($value); |
224 | 224 | } |
225 | 225 | |
@@ -254,25 +254,25 @@ discard block |
||
254 | 254 | * @return \Ajax\semantic\html\modules\HtmlTab |
255 | 255 | */ |
256 | 256 | public function setMenu($menu) { |
257 | - $contentSize = \sizeof($this->content); |
|
258 | - for ($i = 0; $i < $contentSize; $i ++) { |
|
259 | - if ($menu->getItem($i) !== NULL) { |
|
257 | + $contentSize=\sizeof($this->content); |
|
258 | + for ($i=0; $i<$contentSize; $i++) { |
|
259 | + if ($menu->getItem($i)!==NULL) { |
|
260 | 260 | if (isset($this->content[$i])) { |
261 | 261 | $menu->getItem($i)->addToProperty("data-tab", $this->content[$i]->getProperty("data-tab")); |
262 | 262 | } |
263 | 263 | } |
264 | 264 | } |
265 | - $menuSize = $menu->count(); |
|
266 | - for ($i = 0; $i < $menuSize; $i ++) { |
|
265 | + $menuSize=$menu->count(); |
|
266 | + for ($i=0; $i<$menuSize; $i++) { |
|
267 | 267 | $menu->getItem($i)->removeProperty("href"); |
268 | - if (isset($this->content[$i]) === false) { |
|
269 | - $this->content[$i] = $this->createSegment($i, "New content", $menu->getItem($i) |
|
268 | + if (isset($this->content[$i])===false) { |
|
269 | + $this->content[$i]=$this->createSegment($i, "New content", $menu->getItem($i) |
|
270 | 270 | ->getIdentifier()); |
271 | 271 | } |
272 | 272 | $menu->getItem($i)->addToProperty("data-tab", $this->content[$i]->getProperty("data-tab")); |
273 | 273 | } |
274 | 274 | |
275 | - $this->content["menu"] = $menu; |
|
275 | + $this->content["menu"]=$menu; |
|
276 | 276 | return $this; |
277 | 277 | } |
278 | 278 | |
@@ -281,19 +281,19 @@ discard block |
||
281 | 281 | * @see BaseHtml::run() |
282 | 282 | */ |
283 | 283 | public function run(JsUtils $js) { |
284 | - if (isset($this->_bsComponent) === false) |
|
285 | - $this->_bsComponent = $js->semantic()->tab("#" . $this->identifier . " .item", $this->params); |
|
284 | + if (isset($this->_bsComponent)===false) |
|
285 | + $this->_bsComponent=$js->semantic()->tab("#".$this->identifier." .item", $this->params); |
|
286 | 286 | $this->addEventsOnRun($js); |
287 | 287 | return $this->_bsComponent; |
288 | 288 | } |
289 | 289 | |
290 | - public function compile(JsUtils $js = NULL, &$view = NULL) { |
|
291 | - if (! $this->_activated && $this->content["menu"]->count() > 0 && \sizeof($this->content) > 1) |
|
290 | + public function compile(JsUtils $js=NULL, &$view=NULL) { |
|
291 | + if (!$this->_activated && $this->content["menu"]->count()>0 && \sizeof($this->content)>1) |
|
292 | 292 | $this->activate(0); |
293 | 293 | return parent::compile($js, $view); |
294 | 294 | } |
295 | 295 | |
296 | - public function setInverted($recursive=true){ |
|
296 | + public function setInverted($recursive=true) { |
|
297 | 297 | parent::setInverted($recursive); |
298 | 298 | $this->content['menu']->addClass('inverted'); |
299 | 299 | } |
@@ -86,8 +86,9 @@ discard block |
||
86 | 86 | if (isset($this->content[$index]) === false) { |
87 | 87 | $this->content[$index] = $this->createSegment($index, $content, $menu->getItem($index) |
88 | 88 | ->getIdentifier()); |
89 | - } else |
|
90 | - $this->content[$index]->setContent($content); |
|
89 | + } else { |
|
90 | + $this->content[$index]->setContent($content); |
|
91 | + } |
|
91 | 92 | } |
92 | 93 | return $this; |
93 | 94 | } |
@@ -281,15 +282,17 @@ discard block |
||
281 | 282 | * @see BaseHtml::run() |
282 | 283 | */ |
283 | 284 | public function run(JsUtils $js) { |
284 | - if (isset($this->_bsComponent) === false) |
|
285 | - $this->_bsComponent = $js->semantic()->tab("#" . $this->identifier . " .item", $this->params); |
|
285 | + if (isset($this->_bsComponent) === false) { |
|
286 | + $this->_bsComponent = $js->semantic()->tab("#" . $this->identifier . " .item", $this->params); |
|
287 | + } |
|
286 | 288 | $this->addEventsOnRun($js); |
287 | 289 | return $this->_bsComponent; |
288 | 290 | } |
289 | 291 | |
290 | 292 | public function compile(JsUtils $js = NULL, &$view = NULL) { |
291 | - if (! $this->_activated && $this->content["menu"]->count() > 0 && \sizeof($this->content) > 1) |
|
292 | - $this->activate(0); |
|
293 | + if (! $this->_activated && $this->content["menu"]->count() > 0 && \sizeof($this->content) > 1) { |
|
294 | + $this->activate(0); |
|
295 | + } |
|
293 | 296 | return parent::compile($js, $view); |
294 | 297 | } |
295 | 298 |
@@ -16,9 +16,9 @@ discard block |
||
16 | 16 | |
17 | 17 | private $ajaxCall; |
18 | 18 | |
19 | - public function __construct($type, $url, $params, $jsCallback = null, $method = 'post', $parameters = [], $prompt = NULL, $value = NULL) { |
|
19 | + public function __construct($type, $url, $params, $jsCallback=null, $method='post', $parameters=[], $prompt=NULL, $value=NULL) { |
|
20 | 20 | parent::__construct($type, $prompt, $value); |
21 | - $parameters = \array_merge([ |
|
21 | + $parameters=\array_merge([ |
|
22 | 22 | 'async' => false, |
23 | 23 | 'url' => $url, |
24 | 24 | 'params' => $params, |
@@ -29,10 +29,10 @@ discard block |
||
29 | 29 | 'preventDefault' => false, |
30 | 30 | 'responseElement' => null |
31 | 31 | ], $parameters); |
32 | - $this->ajaxCall = new AjaxCall($method, $parameters); |
|
32 | + $this->ajaxCall=new AjaxCall($method, $parameters); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | public function compile(JsUtils $js) { |
36 | - $js->exec(Rule::custom($this->getType(), "function(value,ruleValue){var result=true;" . $this->ajaxCall->compile($js) . "return result;}"), true); |
|
36 | + $js->exec(Rule::custom($this->getType(), "function(value,ruleValue){var result=true;".$this->ajaxCall->compile($js)."return result;}"), true); |
|
37 | 37 | } |
38 | 38 | } |
39 | 39 | \ No newline at end of file |
@@ -15,9 +15,9 @@ |
||
15 | 15 | |
16 | 16 | protected $jsFunction; |
17 | 17 | |
18 | - public function __construct($type, $jsFunction, $prompt = NULL, $value = NULL) { |
|
18 | + public function __construct($type, $jsFunction, $prompt=NULL, $value=NULL) { |
|
19 | 19 | parent::__construct($type, $prompt, $value); |
20 | - $this->jsFunction = $jsFunction; |
|
20 | + $this->jsFunction=$jsFunction; |
|
21 | 21 | } |
22 | 22 | |
23 | 23 | public function compile(JsUtils $js) { |