@@ -47,7 +47,7 @@ |
||
| 47 | 47 | |
| 48 | 48 | /** |
| 49 | 49 | * define the button style |
| 50 | - * @param string|int $cssStyle |
|
| 50 | + * @param string $cssStyle |
|
| 51 | 51 | * @return HtmlButton default : "" |
| 52 | 52 | */ |
| 53 | 53 | public function setStyle($cssStyle) { |
@@ -55,7 +55,7 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | public function setFocusable($value=true) { |
| 58 | - if ($value === true) |
|
| 58 | + if ($value===true) |
|
| 59 | 59 | $this->setProperty("tabindex", "0"); |
| 60 | 60 | else { |
| 61 | 61 | $this->removeProperty("tabindex"); |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | public function setAnimated($content, $animation="") { |
| 67 | 67 | $this->setTagName("div"); |
| 68 | - $this->addToProperty("class", "animated " . $animation); |
|
| 69 | - $visible=new HtmlSemDoubleElement("visible-" . $this->identifier, "div"); |
|
| 68 | + $this->addToProperty("class", "animated ".$animation); |
|
| 69 | + $visible=new HtmlSemDoubleElement("visible-".$this->identifier, "div"); |
|
| 70 | 70 | $visible->setClass("visible content"); |
| 71 | 71 | $visible->setContent($this->content); |
| 72 | - $hidden=new HtmlSemDoubleElement("hidden-" . $this->identifier, "div"); |
|
| 72 | + $hidden=new HtmlSemDoubleElement("hidden-".$this->identifier, "div"); |
|
| 73 | 73 | $hidden->setClass("hidden content"); |
| 74 | 74 | $hidden->setContent($content); |
| 75 | - $this->content=array ($visible,$hidden ); |
|
| 75 | + $this->content=array($visible, $hidden); |
|
| 76 | 76 | return $hidden; |
| 77 | 77 | } |
| 78 | 78 | |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | public function asIcon($icon) { |
| 85 | 85 | $iconO=$icon; |
| 86 | 86 | if (\is_string($icon)) { |
| 87 | - $iconO=new HtmlIcon("icon-" . $this->identifier, $icon); |
|
| 87 | + $iconO=new HtmlIcon("icon-".$this->identifier, $icon); |
|
| 88 | 88 | } |
| 89 | 89 | $this->addToProperty("class", "icon"); |
| 90 | 90 | $this->content=$iconO; |
@@ -104,17 +104,17 @@ discard block |
||
| 104 | 104 | * @return HtmlLabel |
| 105 | 105 | */ |
| 106 | 106 | public function addLabel($label, $before=false, $icon=NULL) { |
| 107 | - $this->tagName="div";$prefix=""; |
|
| 108 | - if($before) |
|
| 107 | + $this->tagName="div"; $prefix=""; |
|
| 108 | + if ($before) |
|
| 109 | 109 | $prefix="left "; |
| 110 | 110 | $this->addToProperty("class", $prefix."labeled"); |
| 111 | 111 | $isIcon=(isset($this->content[0]) && $this->content[0] instanceof HtmlIcon); |
| 112 | - $this->content=new HtmlButton("button-" . $this->identifier, $this->content); |
|
| 113 | - if($isIcon){ |
|
| 112 | + $this->content=new HtmlButton("button-".$this->identifier, $this->content); |
|
| 113 | + if ($isIcon) { |
|
| 114 | 114 | $this->content->addClass("icon"); |
| 115 | 115 | } |
| 116 | 116 | $this->content->setTagName("div"); |
| 117 | - $label=new HtmlLabel("label-" . $this->identifier, $label, $icon,"a"); |
|
| 117 | + $label=new HtmlLabel("label-".$this->identifier, $label, $icon, "a"); |
|
| 118 | 118 | $label->setBasic(); |
| 119 | 119 | $this->addContent($label, $before); |
| 120 | 120 | return $label; |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | */ |
| 127 | 127 | public function fromArray($array) { |
| 128 | 128 | $array=parent::fromArray($array); |
| 129 | - foreach ( $array as $key => $value ) { |
|
| 129 | + foreach ($array as $key => $value) { |
|
| 130 | 130 | $this->setProperty($key, $value); |
| 131 | 131 | } |
| 132 | 132 | return $array; |
@@ -140,10 +140,10 @@ discard block |
||
| 140 | 140 | return $this->addToProperty("class", "positive"); |
| 141 | 141 | } |
| 142 | 142 | |
| 143 | - public function setColor($color){ |
|
| 144 | - if(\is_array($this->content)){ |
|
| 145 | - foreach ($this->content as $content){ |
|
| 146 | - if($content instanceof HtmlButton) |
|
| 143 | + public function setColor($color) { |
|
| 144 | + if (\is_array($this->content)) { |
|
| 145 | + foreach ($this->content as $content) { |
|
| 146 | + if ($content instanceof HtmlButton) |
|
| 147 | 147 | $content->setColor($color); |
| 148 | 148 | } |
| 149 | 149 | } |
@@ -201,7 +201,7 @@ discard block |
||
| 201 | 201 | * @return HtmlButton |
| 202 | 202 | */ |
| 203 | 203 | public static function social($identifier, $social, $value=NULL) { |
| 204 | - if ($value === NULL) |
|
| 204 | + if ($value===NULL) |
|
| 205 | 205 | $value=\ucfirst($social); |
| 206 | 206 | $return=new HtmlButton($identifier, $value); |
| 207 | 207 | $return->addIcon($social); |
@@ -238,8 +238,8 @@ discard block |
||
| 238 | 238 | * {@inheritDoc} |
| 239 | 239 | * @see HtmlSemDoubleElement::asLink() |
| 240 | 240 | */ |
| 241 | - public function asLink($href=NULL,$target=NULL) { |
|
| 242 | - parent::asLink($href,$target); |
|
| 241 | + public function asLink($href=NULL, $target=NULL) { |
|
| 242 | + parent::asLink($href, $target); |
|
| 243 | 243 | return $this; |
| 244 | 244 | } |
| 245 | 245 | |
@@ -252,10 +252,10 @@ discard block |
||
| 252 | 252 | * @param string $icon |
| 253 | 253 | * @return HtmlButtonGroups |
| 254 | 254 | */ |
| 255 | - public static function dropdown($identifier,$value,$items=[],$asCombo=false,$icon=null){ |
|
| 256 | - $result=new HtmlButtonGroups($identifier,[$value]); |
|
| 257 | - $result->addDropdown($items,$asCombo); |
|
| 258 | - if(isset($icon)) |
|
| 255 | + public static function dropdown($identifier, $value, $items=[], $asCombo=false, $icon=null) { |
|
| 256 | + $result=new HtmlButtonGroups($identifier, [$value]); |
|
| 257 | + $result->addDropdown($items, $asCombo); |
|
| 258 | + if (isset($icon)) |
|
| 259 | 259 | $result->setIcon($icon); |
| 260 | 260 | return $result; |
| 261 | 261 | } |
@@ -55,9 +55,9 @@ discard block |
||
| 55 | 55 | } |
| 56 | 56 | |
| 57 | 57 | public function setFocusable($value=true) { |
| 58 | - if ($value === true) |
|
| 59 | - $this->setProperty("tabindex", "0"); |
|
| 60 | - else { |
|
| 58 | + if ($value === true) { |
|
| 59 | + $this->setProperty("tabindex", "0"); |
|
| 60 | + } else { |
|
| 61 | 61 | $this->removeProperty("tabindex"); |
| 62 | 62 | } |
| 63 | 63 | return $this; |
@@ -105,8 +105,9 @@ discard block |
||
| 105 | 105 | */ |
| 106 | 106 | public function addLabel($label, $before=false, $icon=NULL) { |
| 107 | 107 | $this->tagName="div";$prefix=""; |
| 108 | - if($before) |
|
| 109 | - $prefix="left "; |
|
| 108 | + if($before) { |
|
| 109 | + $prefix="left "; |
|
| 110 | + } |
|
| 110 | 111 | $this->addToProperty("class", $prefix."labeled"); |
| 111 | 112 | $isIcon=(isset($this->content[0]) && $this->content[0] instanceof HtmlIcon); |
| 112 | 113 | $this->content=new HtmlButton("button-" . $this->identifier, $this->content); |
@@ -143,12 +144,13 @@ discard block |
||
| 143 | 144 | public function setColor($color){ |
| 144 | 145 | if(\is_array($this->content)){ |
| 145 | 146 | foreach ($this->content as $content){ |
| 146 | - if($content instanceof HtmlButton) |
|
| 147 | - $content->setColor($color); |
|
| 147 | + if($content instanceof HtmlButton) { |
|
| 148 | + $content->setColor($color); |
|
| 149 | + } |
|
| 148 | 150 | } |
| 151 | + } else { |
|
| 152 | + parent::setColor($color); |
|
| 149 | 153 | } |
| 150 | - else |
|
| 151 | - parent::setColor($color); |
|
| 152 | 154 | return $this; |
| 153 | 155 | } |
| 154 | 156 | |
@@ -201,8 +203,9 @@ discard block |
||
| 201 | 203 | * @return HtmlButton |
| 202 | 204 | */ |
| 203 | 205 | public static function social($identifier, $social, $value=NULL) { |
| 204 | - if ($value === NULL) |
|
| 205 | - $value=\ucfirst($social); |
|
| 206 | + if ($value === NULL) { |
|
| 207 | + $value=\ucfirst($social); |
|
| 208 | + } |
|
| 206 | 209 | $return=new HtmlButton($identifier, $value); |
| 207 | 210 | $return->addIcon($social); |
| 208 | 211 | return $return->addToPropertyCtrl("class", $social, Social::getConstants()); |
@@ -255,8 +258,9 @@ discard block |
||
| 255 | 258 | public static function dropdown($identifier,$value,$items=[],$asCombo=false,$icon=null){ |
| 256 | 259 | $result=new HtmlButtonGroups($identifier,[$value]); |
| 257 | 260 | $result->addDropdown($items,$asCombo); |
| 258 | - if(isset($icon)) |
|
| 259 | - $result->setIcon($icon); |
|
| 261 | + if(isset($icon)) { |
|
| 262 | + $result->setIcon($icon); |
|
| 263 | + } |
|
| 260 | 264 | return $result; |
| 261 | 265 | } |
| 262 | 266 | } |
@@ -11,11 +11,11 @@ discard block |
||
| 11 | 11 | trait JsUtilsEventsTrait { |
| 12 | 12 | |
| 13 | 13 | |
| 14 | - protected $jquery_events=array ( |
|
| 15 | - "bind","blur","change","click","dblclick","delegate","die","error","focus","focusin","focusout","hover","keydown","keypress","keyup","live","load","mousedown","mousseenter","mouseleave","mousemove","mouseout","mouseover","mouseup","off","on","one","ready","resize","scroll","select","submit","toggle","trigger","triggerHandler","undind","undelegate","unload" |
|
| 14 | + protected $jquery_events=array( |
|
| 15 | + "bind", "blur", "change", "click", "dblclick", "delegate", "die", "error", "focus", "focusin", "focusout", "hover", "keydown", "keypress", "keyup", "live", "load", "mousedown", "mousseenter", "mouseleave", "mousemove", "mouseout", "mouseover", "mouseup", "off", "on", "one", "ready", "resize", "scroll", "select", "submit", "toggle", "trigger", "triggerHandler", "undind", "undelegate", "unload" |
|
| 16 | 16 | ); |
| 17 | 17 | |
| 18 | - abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
| 18 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
| 19 | 19 | |
| 20 | 20 | /** |
| 21 | 21 | * Outputs a javascript library blur event |
@@ -49,9 +49,9 @@ discard block |
||
| 49 | 49 | * @param boolean $stopPropagation |
| 50 | 50 | * @return string |
| 51 | 51 | */ |
| 52 | - public function click($element='this', $js='', $ret_false=TRUE,$preventDefault=false,$stopPropagation=false) { |
|
| 52 | + public function click($element='this', $js='', $ret_false=TRUE, $preventDefault=false, $stopPropagation=false) { |
|
| 53 | 53 | if (!is_array($js)) { |
| 54 | - $js=array ( |
|
| 54 | + $js=array( |
|
| 55 | 55 | $js |
| 56 | 56 | ); |
| 57 | 57 | } |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | $js[]="return false;"; |
| 61 | 61 | } |
| 62 | 62 | |
| 63 | - return $this->_add_event($element, $js, 'click',$preventDefault,$stopPropagation); |
|
| 63 | + return $this->_add_event($element, $js, 'click', $preventDefault, $stopPropagation); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | /** |
@@ -9,12 +9,12 @@ discard block |
||
| 9 | 9 | use Ajax\common\html\HtmlDoubleElement; |
| 10 | 10 | use Ajax\semantic\html\base\constants\Side; |
| 11 | 11 | |
| 12 | -class HtmlStep extends HtmlSemCollection{ |
|
| 12 | +class HtmlStep extends HtmlSemCollection { |
|
| 13 | 13 | protected $_activeStep; |
| 14 | 14 | protected $_startStep; |
| 15 | 15 | |
| 16 | - public function __construct( $identifier,$steps=array()){ |
|
| 17 | - parent::__construct( $identifier,"div", "ui steps"); |
|
| 16 | + public function __construct($identifier, $steps=array()) { |
|
| 17 | + parent::__construct($identifier, "div", "ui steps"); |
|
| 18 | 18 | $this->addItems($steps); |
| 19 | 19 | } |
| 20 | 20 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | * @see \Ajax\common\html\html5\HtmlCollection::createItem() |
| 25 | 25 | */ |
| 26 | 26 | protected function createItem($value) { |
| 27 | - $itemO=new HtmlStepItem("item-".\sizeof($this->content),$value); |
|
| 27 | + $itemO=new HtmlStepItem("item-".\sizeof($this->content), $value); |
|
| 28 | 28 | return $itemO; |
| 29 | 29 | } |
| 30 | 30 | |
@@ -32,50 +32,50 @@ discard block |
||
| 32 | 32 | * @param string|array $step |
| 33 | 33 | * @return HtmlStepItem |
| 34 | 34 | */ |
| 35 | - public function addStep($step){ |
|
| 35 | + public function addStep($step) { |
|
| 36 | 36 | return $this->addItem($step); |
| 37 | 37 | } |
| 38 | 38 | |
| 39 | - public function setOrdered(){ |
|
| 39 | + public function setOrdered() { |
|
| 40 | 40 | return $this->addToProperty("class", "ordered"); |
| 41 | 41 | } |
| 42 | 42 | |
| 43 | - public function isOrdered(){ |
|
| 43 | + public function isOrdered() { |
|
| 44 | 44 | return $this->propertyContains("class", "ordered"); |
| 45 | 45 | } |
| 46 | 46 | |
| 47 | - public function setVertical(){ |
|
| 47 | + public function setVertical() { |
|
| 48 | 48 | return $this->addToProperty("class", "vertical"); |
| 49 | 49 | } |
| 50 | 50 | |
| 51 | - protected function defineActiveStep(){ |
|
| 51 | + protected function defineActiveStep() { |
|
| 52 | 52 | $activestep=$this->_activeStep; |
| 53 | 53 | $count=$this->count(); |
| 54 | - if(!$this->isOrdered()){ |
|
| 55 | - for($i=$this->_startStep;$i<$count;$i++){ |
|
| 54 | + if (!$this->isOrdered()) { |
|
| 55 | + for ($i=$this->_startStep; $i<$count; $i++) { |
|
| 56 | 56 | $step=$this->content[$i]; |
| 57 | 57 | $step->removeStatus(); |
| 58 | - if($i<$activestep) |
|
| 58 | + if ($i<$activestep) |
|
| 59 | 59 | $step->setCompleted(); |
| 60 | 60 | elseif ($i===$activestep) |
| 61 | 61 | $step->setActive(); |
| 62 | 62 | else |
| 63 | 63 | $step->setDisabled(); |
| 64 | 64 | } |
| 65 | - }else{ |
|
| 66 | - foreach ($this->content as $step){ |
|
| 65 | + } else { |
|
| 66 | + foreach ($this->content as $step) { |
|
| 67 | 67 | $step->removeStatus(); |
| 68 | 68 | } |
| 69 | - if($activestep<$count) |
|
| 69 | + if ($activestep<$count) |
|
| 70 | 70 | $this->content[$activestep]->setActive(); |
| 71 | 71 | } |
| 72 | 72 | return $this; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | 75 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 76 | - if(isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
| 76 | + if (isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
| 77 | 77 | $this->defineActiveStep(); |
| 78 | - return parent::compile($js,$view); |
|
| 78 | + return parent::compile($js, $view); |
|
| 79 | 79 | } |
| 80 | 80 | |
| 81 | 81 | public function setActiveStep($_activeStep) { |
@@ -83,15 +83,15 @@ discard block |
||
| 83 | 83 | return $this; |
| 84 | 84 | } |
| 85 | 85 | |
| 86 | - public function setAttached($side="",HtmlDoubleElement $toElement=NULL){ |
|
| 87 | - if(isset($toElement)){ |
|
| 88 | - $toElement->addToPropertyCtrl("class", "attached",array("attached")); |
|
| 86 | + public function setAttached($side="", HtmlDoubleElement $toElement=NULL) { |
|
| 87 | + if (isset($toElement)) { |
|
| 88 | + $toElement->addToPropertyCtrl("class", "attached", array("attached")); |
|
| 89 | 89 | } |
| 90 | - return $this->addToPropertyCtrl("class", $side." attached",Side::getConstantValues("attached")); |
|
| 90 | + return $this->addToPropertyCtrl("class", $side." attached", Side::getConstantValues("attached")); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | - public function asLink(){ |
|
| 94 | - foreach ($this->content as $step){ |
|
| 93 | + public function asLink() { |
|
| 94 | + foreach ($this->content as $step) { |
|
| 95 | 95 | $step->asLink(); |
| 96 | 96 | } |
| 97 | 97 | return $this; |
@@ -55,26 +55,29 @@ |
||
| 55 | 55 | for($i=$this->_startStep;$i<$count;$i++){ |
| 56 | 56 | $step=$this->content[$i]; |
| 57 | 57 | $step->removeStatus(); |
| 58 | - if($i<$activestep) |
|
| 59 | - $step->setCompleted(); |
|
| 60 | - elseif ($i===$activestep) |
|
| 61 | - $step->setActive(); |
|
| 62 | - else |
|
| 63 | - $step->setDisabled(); |
|
| 58 | + if($i<$activestep) { |
|
| 59 | + $step->setCompleted(); |
|
| 60 | + } elseif ($i===$activestep) { |
|
| 61 | + $step->setActive(); |
|
| 62 | + } else { |
|
| 63 | + $step->setDisabled(); |
|
| 64 | + } |
|
| 64 | 65 | } |
| 65 | - }else{ |
|
| 66 | + } else{ |
|
| 66 | 67 | foreach ($this->content as $step){ |
| 67 | 68 | $step->removeStatus(); |
| 68 | 69 | } |
| 69 | - if($activestep<$count) |
|
| 70 | - $this->content[$activestep]->setActive(); |
|
| 70 | + if($activestep<$count) { |
|
| 71 | + $this->content[$activestep]->setActive(); |
|
| 72 | + } |
|
| 71 | 73 | } |
| 72 | 74 | return $this; |
| 73 | 75 | } |
| 74 | 76 | |
| 75 | 77 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 76 | - if(isset($this->_activeStep) && \is_numeric($this->_activeStep)) |
|
| 77 | - $this->defineActiveStep(); |
|
| 78 | + if(isset($this->_activeStep) && \is_numeric($this->_activeStep)) { |
|
| 79 | + $this->defineActiveStep(); |
|
| 80 | + } |
|
| 78 | 81 | return parent::compile($js,$view); |
| 79 | 82 | } |
| 80 | 83 | |
@@ -9,15 +9,15 @@ discard block |
||
| 9 | 9 | protected $image; |
| 10 | 10 | |
| 11 | 11 | public function __construct($identifier, $content=NULL) { |
| 12 | - parent::__construct($identifier,"item",$content); |
|
| 12 | + parent::__construct($identifier, "item", $content); |
|
| 13 | 13 | } |
| 14 | - protected function initContent($content){ |
|
| 15 | - if(\is_array($content)){ |
|
| 16 | - if(JArray::isAssociative($content)===false){ |
|
| 14 | + protected function initContent($content) { |
|
| 15 | + if (\is_array($content)) { |
|
| 16 | + if (JArray::isAssociative($content)===false) { |
|
| 17 | 17 | $icon=@$content[0]; |
| 18 | 18 | $title=@$content[1]; |
| 19 | 19 | $desc=@$content[2]; |
| 20 | - }else{ |
|
| 20 | + } else { |
|
| 21 | 21 | $icon=@$content["icon"]; |
| 22 | 22 | $image=@$content["image"]; |
| 23 | 23 | $title=@$content["title"]; |
@@ -25,38 +25,38 @@ discard block |
||
| 25 | 25 | $desc=@$content["description"]; |
| 26 | 26 | $items=@$content["items"]; |
| 27 | 27 | } |
| 28 | - if(isset($icon)){ |
|
| 28 | + if (isset($icon)) { |
|
| 29 | 29 | $this->setIcon($icon); |
| 30 | 30 | } |
| 31 | - if(isset($image)){ |
|
| 31 | + if (isset($image)) { |
|
| 32 | 32 | $this->setImage($image); |
| 33 | 33 | } |
| 34 | - if(isset($title)){ |
|
| 35 | - $this->setTitle($title,$desc); |
|
| 36 | - }elseif (isset($header)){ |
|
| 37 | - $this->setTitle($header,$desc,"header"); |
|
| 34 | + if (isset($title)) { |
|
| 35 | + $this->setTitle($title, $desc); |
|
| 36 | + }elseif (isset($header)) { |
|
| 37 | + $this->setTitle($header, $desc, "header"); |
|
| 38 | 38 | } |
| 39 | - if(isset($items)){ |
|
| 39 | + if (isset($items)) { |
|
| 40 | 40 | $this->addList($items); |
| 41 | 41 | } |
| 42 | - }else{ |
|
| 42 | + } else { |
|
| 43 | 43 | $this->setContent($content); |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | - public function addList($items=array(),$ordered=false) { |
|
| 46 | + public function addList($items=array(), $ordered=false) { |
|
| 47 | 47 | $list=new HtmlList("", $items); |
| 48 | - if($ordered) |
|
| 48 | + if ($ordered) |
|
| 49 | 49 | $list->setOrdered(); |
| 50 | 50 | $list->setClass("list"); |
| 51 | 51 | $this->content["list"]=$list; |
| 52 | 52 | return $list; |
| 53 | 53 | } |
| 54 | 54 | |
| 55 | - public function getList(){ |
|
| 55 | + public function getList() { |
|
| 56 | 56 | return $this->content["list"]; |
| 57 | 57 | } |
| 58 | 58 | |
| 59 | - public function getItem($index){ |
|
| 59 | + public function getItem($index) { |
|
| 60 | 60 | return $this->getList()->getItem($index); |
| 61 | 61 | } |
| 62 | 62 | } |
@@ -17,7 +17,7 @@ discard block |
||
| 17 | 17 | $icon=@$content[0]; |
| 18 | 18 | $title=@$content[1]; |
| 19 | 19 | $desc=@$content[2]; |
| 20 | - }else{ |
|
| 20 | + } else{ |
|
| 21 | 21 | $icon=@$content["icon"]; |
| 22 | 22 | $image=@$content["image"]; |
| 23 | 23 | $title=@$content["title"]; |
@@ -33,20 +33,21 @@ discard block |
||
| 33 | 33 | } |
| 34 | 34 | if(isset($title)){ |
| 35 | 35 | $this->setTitle($title,$desc); |
| 36 | - }elseif (isset($header)){ |
|
| 36 | + } elseif (isset($header)){ |
|
| 37 | 37 | $this->setTitle($header,$desc,"header"); |
| 38 | 38 | } |
| 39 | 39 | if(isset($items)){ |
| 40 | 40 | $this->addList($items); |
| 41 | 41 | } |
| 42 | - }else{ |
|
| 42 | + } else{ |
|
| 43 | 43 | $this->setContent($content); |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | public function addList($items=array(),$ordered=false) { |
| 47 | 47 | $list=new HtmlList("", $items); |
| 48 | - if($ordered) |
|
| 49 | - $list->setOrdered(); |
|
| 48 | + if($ordered) { |
|
| 49 | + $list->setOrdered(); |
|
| 50 | + } |
|
| 50 | 51 | $list->setClass("list"); |
| 51 | 52 | $this->content["list"]=$list; |
| 52 | 53 | return $list; |
@@ -11,7 +11,7 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | class HtmlPopup extends HtmlSemDoubleElement { |
| 13 | 13 | private $_container; |
| 14 | - public function __construct(BaseHtml $container,$identifier, $content="") { |
|
| 14 | + public function __construct(BaseHtml $container, $identifier, $content="") { |
|
| 15 | 15 | parent::__construct($identifier, "div"); |
| 16 | 16 | $this->_container=$container; |
| 17 | 17 | $this->setClass("ui popup"); |
@@ -23,9 +23,9 @@ discard block |
||
| 23 | 23 | * {@inheritDoc} |
| 24 | 24 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::addList() |
| 25 | 25 | */ |
| 26 | - public function addList($items=array(),$header=NULL){ |
|
| 27 | - if(!$this->content instanceof HtmlGrid){ |
|
| 28 | - $this->content=new HtmlGrid("Grid-".$this->identifier,0); |
|
| 26 | + public function addList($items=array(), $header=NULL) { |
|
| 27 | + if (!$this->content instanceof HtmlGrid) { |
|
| 28 | + $this->content=new HtmlGrid("Grid-".$this->identifier, 0); |
|
| 29 | 29 | } |
| 30 | 30 | $grid=$this->content; |
| 31 | 31 | |
@@ -33,12 +33,12 @@ discard block |
||
| 33 | 33 | $colCount++; |
| 34 | 34 | $grid->setColsCount($colCount); |
| 35 | 35 | |
| 36 | - $list=new HtmlList("",$items); |
|
| 36 | + $list=new HtmlList("", $items); |
|
| 37 | 37 | $list->asLink(); |
| 38 | - if(isset($header)){ |
|
| 39 | - $list->addHeader(4,$header); |
|
| 38 | + if (isset($header)) { |
|
| 39 | + $list->addHeader(4, $header); |
|
| 40 | 40 | } |
| 41 | - $grid->getCell(0,$colCount-1)->setContent($list); |
|
| 41 | + $grid->getCell(0, $colCount-1)->setContent($list); |
|
| 42 | 42 | $grid->setDivided()->setRelaxed(true); |
| 43 | 43 | return $list; |
| 44 | 44 | } |
@@ -46,14 +46,14 @@ discard block |
||
| 46 | 46 | /** |
| 47 | 47 | * A popup can have no maximum width and continue to flow to fit its content |
| 48 | 48 | */ |
| 49 | - public function setFlowing(){ |
|
| 49 | + public function setFlowing() { |
|
| 50 | 50 | return $this->addToProperty("class", "flowing"); |
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | /** |
| 54 | 54 | * A popup can provide more basic formatting |
| 55 | 55 | */ |
| 56 | - public function setBasic(){ |
|
| 56 | + public function setBasic() { |
|
| 57 | 57 | return $this->addToProperty("class", "basic"); |
| 58 | 58 | } |
| 59 | 59 | |
@@ -61,23 +61,23 @@ discard block |
||
| 61 | 61 | * {@inheritDoc} |
| 62 | 62 | * @see \Ajax\semantic\html\base\HtmlSemDoubleElement::run() |
| 63 | 63 | */ |
| 64 | - public function run(JsUtils $js){ |
|
| 64 | + public function run(JsUtils $js) { |
|
| 65 | 65 | parent::run($js); |
| 66 | 66 | $this->_params["popup"]="#".$this->identifier; |
| 67 | - $js->semantic()->popup("#".$this->_container->getIdentifier(),$this->_params); |
|
| 67 | + $js->semantic()->popup("#".$this->_container->getIdentifier(), $this->_params); |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function setOn($event="click"){ |
|
| 70 | + public function setOn($event="click") { |
|
| 71 | 71 | $this->_params["on"]=$event; |
| 72 | 72 | return $this; |
| 73 | 73 | } |
| 74 | 74 | |
| 75 | - public function setInline($value=true){ |
|
| 75 | + public function setInline($value=true) { |
|
| 76 | 76 | $this->_params["inline"]=$value; |
| 77 | 77 | return $this; |
| 78 | 78 | } |
| 79 | 79 | |
| 80 | - public function setPosition($position){ |
|
| 80 | + public function setPosition($position) { |
|
| 81 | 81 | $this->_params["position"]=$position; |
| 82 | 82 | return $this; |
| 83 | 83 | } |
@@ -25,27 +25,27 @@ |
||
| 25 | 25 | $this->parameters["immediatly"]=false; |
| 26 | 26 | extract($this->parameters); |
| 27 | 27 | $result=$this->_eventPreparing($preventDefault, $stopPropagation); |
| 28 | - switch($this->method) { |
|
| 28 | + switch ($this->method) { |
|
| 29 | 29 | case "get": |
| 30 | 30 | $result.=$js->getDeferred($url, $responseElement, $this->parameters); |
| 31 | 31 | break; |
| 32 | 32 | case "post": |
| 33 | - $result.=$js->postDeferred($url, $params,$responseElement, $this->parameters); |
|
| 33 | + $result.=$js->postDeferred($url, $params, $responseElement, $this->parameters); |
|
| 34 | 34 | break; |
| 35 | 35 | case "postForm": |
| 36 | 36 | $result.=$js->postFormDeferred($url, $form, $responseElement, $this->parameters); |
| 37 | 37 | break; |
| 38 | 38 | case "json": |
| 39 | - $result.=$js->jsonDeferred($url,$method,$params,$jsCallback); |
|
| 39 | + $result.=$js->jsonDeferred($url, $method, $params, $jsCallback); |
|
| 40 | 40 | break; |
| 41 | 41 | case "jsonArray": |
| 42 | - $result.=$js->jsonArrayDeferred($modelSelector, $url,$method,$params,$jsCallback,$rowClass); |
|
| 42 | + $result.=$js->jsonArrayDeferred($modelSelector, $url, $method, $params, $jsCallback, $rowClass); |
|
| 43 | 43 | break; |
| 44 | 44 | } |
| 45 | 45 | return $result; |
| 46 | 46 | } |
| 47 | 47 | |
| 48 | - protected function _eventPreparing($preventDefault,$stopPropagation){ |
|
| 48 | + protected function _eventPreparing($preventDefault, $stopPropagation) { |
|
| 49 | 49 | $result=""; |
| 50 | 50 | if ($preventDefault===true) { |
| 51 | 51 | $result.=Javascript::$preventDefault; |
@@ -14,8 +14,9 @@ |
||
| 14 | 14 | } |
| 15 | 15 | |
| 16 | 16 | public function compile(JsUtils $js=null) { |
| 17 | - if ($js===null) |
|
| 18 | - return; |
|
| 17 | + if ($js===null) { |
|
| 18 | + return; |
|
| 19 | + } |
|
| 19 | 20 | $params="{}"; |
| 20 | 21 | $jsCallback=NULL; |
| 21 | 22 | $stopPropagation=true; |
@@ -16,9 +16,9 @@ discard block |
||
| 16 | 16 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
| 17 | 17 | |
| 18 | 18 | abstract public function getUrl($url); |
| 19 | - abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
| 19 | + abstract public function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
| 20 | 20 | |
| 21 | - protected function _ajax($method,$url,$responseElement="",$parameters=[]) { |
|
| 21 | + protected function _ajax($method, $url, $responseElement="", $parameters=[]) { |
|
| 22 | 22 | $jsCallback=null; |
| 23 | 23 | $attr="id"; |
| 24 | 24 | $hasLoader=true; |
@@ -34,78 +34,78 @@ discard block |
||
| 34 | 34 | $retour=$this->_getAjaxUrl($url, $attr); |
| 35 | 35 | $responseElement=$this->_getResponseElement($responseElement); |
| 36 | 36 | $retour.="var self=this;\n"; |
| 37 | - if($hasLoader===true){ |
|
| 37 | + if ($hasLoader===true) { |
|
| 38 | 38 | $this->addLoading($retour, $responseElement); |
| 39 | 39 | } |
| 40 | 40 | |
| 41 | - $ajaxParameters=["url"=>"url","method"=>"'".\strtoupper($method)."'"]; |
|
| 42 | - if(isset($params)){ |
|
| 41 | + $ajaxParameters=["url"=>"url", "method"=>"'".\strtoupper($method)."'"]; |
|
| 42 | + if (isset($params)) { |
|
| 43 | 43 | $ajaxParameters["data"]=self::_correctParams($params); |
| 44 | 44 | } |
| 45 | - if(isset($headers)){ |
|
| 45 | + if (isset($headers)) { |
|
| 46 | 46 | $ajaxParameters["headers"]=$this->_correctParams($headers); |
| 47 | 47 | } |
| 48 | 48 | $this->createAjaxParameters($ajaxParameters, $parameters); |
| 49 | 49 | $retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n"; |
| 50 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
|
| 51 | - $retour=$this->_addJsCondition($jsCondition,$retour); |
|
| 50 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n"; |
|
| 51 | + $retour=$this->_addJsCondition($jsCondition, $retour); |
|
| 52 | 52 | if ($immediatly) |
| 53 | 53 | $this->jquery_code_for_compile[]=$retour; |
| 54 | 54 | return $retour; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - protected function createAjaxParameters(&$original,$parameters){ |
|
| 58 | - $validParameters=["dataType"=>"'%value%'","beforeSend"=>"function(jqXHR,settings){%value%}","complete"=>"function(jqXHR){%value%}"]; |
|
| 59 | - foreach ($validParameters as $param=>$mask){ |
|
| 60 | - if(isset($parameters[$param])){ |
|
| 57 | + protected function createAjaxParameters(&$original, $parameters) { |
|
| 58 | + $validParameters=["dataType"=>"'%value%'", "beforeSend"=>"function(jqXHR,settings){%value%}", "complete"=>"function(jqXHR){%value%}"]; |
|
| 59 | + foreach ($validParameters as $param=>$mask) { |
|
| 60 | + if (isset($parameters[$param])) { |
|
| 61 | 61 | $original[$param]=\str_replace("%value%", $parameters[$param], $mask); |
| 62 | 62 | } |
| 63 | 63 | } |
| 64 | 64 | } |
| 65 | 65 | |
| 66 | - protected function implodeAjaxParameters($ajaxParameters){ |
|
| 67 | - $s = ''; foreach ($ajaxParameters as $k=>$v) { if ($s !== '') { $s .= ','; } $s .= "'{$k}':{$v}"; } |
|
| 66 | + protected function implodeAjaxParameters($ajaxParameters) { |
|
| 67 | + $s=''; foreach ($ajaxParameters as $k=>$v) { if ($s!=='') { $s.=','; } $s.="'{$k}':{$v}"; } |
|
| 68 | 68 | return $s; |
| 69 | 69 | } |
| 70 | 70 | |
| 71 | - protected function _addJsCondition($jsCondition,$jsSource){ |
|
| 72 | - if(isset($jsCondition)){ |
|
| 71 | + protected function _addJsCondition($jsCondition, $jsSource) { |
|
| 72 | + if (isset($jsCondition)) { |
|
| 73 | 73 | return "if(".$jsCondition."){\n".$jsSource."\n}"; |
| 74 | 74 | } |
| 75 | 75 | return $jsSource; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | |
| 79 | - protected function _getAjaxUrl($url,$attr){ |
|
| 79 | + protected function _getAjaxUrl($url, $attr) { |
|
| 80 | 80 | $url=$this->_correctAjaxUrl($url); |
| 81 | 81 | $retour="url='".$url."';"; |
| 82 | 82 | $slash="/"; |
| 83 | - if(JString::endswith($url, "/")===true){ |
|
| 83 | + if (JString::endswith($url, "/")===true) { |
|
| 84 | 84 | $slash=""; |
| 85 | 85 | } |
| 86 | - if(JString::isNotNull($attr)){ |
|
| 87 | - if ($attr==="value"){ |
|
| 86 | + if (JString::isNotNull($attr)) { |
|
| 87 | + if ($attr==="value") { |
|
| 88 | 88 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
| 89 | - }elseif ($attr==="html"){ |
|
| 89 | + }elseif ($attr==="html") { |
|
| 90 | 90 | $retour.="url=url+'".$slash."'+$(this).html();\n"; |
| 91 | - }elseif(\substr($attr, 0,3)==="js:"){ |
|
| 91 | + }elseif (\substr($attr, 0, 3)==="js:") { |
|
| 92 | 92 | $retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n"; |
| 93 | - }elseif($attr!==null && $attr!=="") |
|
| 93 | + }elseif ($attr!==null && $attr!=="") |
|
| 94 | 94 | $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
| 95 | 95 | } |
| 96 | 96 | return $retour; |
| 97 | 97 | } |
| 98 | 98 | |
| 99 | - protected function _getOnAjaxDone($responseElement,$jqueryDone,$ajaxTransition,$jsCallback){ |
|
| 100 | - $retour="";$call=null; |
|
| 99 | + protected function _getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback) { |
|
| 100 | + $retour=""; $call=null; |
|
| 101 | 101 | if ($responseElement!=="") { |
| 102 | - if(isset($ajaxTransition)){ |
|
| 102 | + if (isset($ajaxTransition)) { |
|
| 103 | 103 | $call=$this->setAjaxDataCall($ajaxTransition); |
| 104 | - }elseif(isset($this->ajaxTransition)){ |
|
| 104 | + }elseif (isset($this->ajaxTransition)) { |
|
| 105 | 105 | $call=$this->ajaxTransition; |
| 106 | 106 | } |
| 107 | - if(\is_callable($call)) |
|
| 108 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
| 107 | + if (\is_callable($call)) |
|
| 108 | + $retour="\t".$call($responseElement, $jqueryDone).";\n"; |
|
| 109 | 109 | else |
| 110 | 110 | $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
| 111 | 111 | } |
@@ -113,7 +113,7 @@ discard block |
||
| 113 | 113 | return $retour; |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - protected function _getResponseElement($responseElement){ |
|
| 116 | + protected function _getResponseElement($responseElement) { |
|
| 117 | 117 | if ($responseElement!=="") { |
| 118 | 118 | $responseElement=Javascript::prep_value($responseElement); |
| 119 | 119 | } |
@@ -123,26 +123,26 @@ discard block |
||
| 123 | 123 | protected function _correctAjaxUrl($url) { |
| 124 | 124 | if ($url!=="/" && JString::endsWith($url, "/")===true) |
| 125 | 125 | $url=substr($url, 0, strlen($url)-1); |
| 126 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
| 126 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
| 127 | 127 | $url=$this->getUrl($url); |
| 128 | 128 | } |
| 129 | 129 | return $url; |
| 130 | 130 | } |
| 131 | 131 | |
| 132 | - public static function _correctParams($params){ |
|
| 133 | - if(JString::isNull($params)){ |
|
| 132 | + public static function _correctParams($params) { |
|
| 133 | + if (JString::isNull($params)) { |
|
| 134 | 134 | return ""; |
| 135 | 135 | } |
| 136 | - if(\preg_match("@^\{.*?\}$@", $params)){ |
|
| 136 | + if (\preg_match("@^\{.*?\}$@", $params)) { |
|
| 137 | 137 | return '$.param('.$params.')'; |
| 138 | 138 | } |
| 139 | 139 | return $params; |
| 140 | 140 | } |
| 141 | 141 | |
| 142 | - public static function _implodeParams($parameters){ |
|
| 142 | + public static function _implodeParams($parameters) { |
|
| 143 | 143 | $allParameters=[]; |
| 144 | - foreach ($parameters as $params){ |
|
| 145 | - if(isset($params)) |
|
| 144 | + foreach ($parameters as $params) { |
|
| 145 | + if (isset($params)) |
|
| 146 | 146 | $allParameters[]=self::_correctParams($params); |
| 147 | 147 | } |
| 148 | 148 | return \implode("+'&'+", $allParameters); |
@@ -160,19 +160,19 @@ discard block |
||
| 160 | 160 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
| 161 | 161 | } |
| 162 | 162 | |
| 163 | - protected function setAjaxDataCall($params){ |
|
| 163 | + protected function setAjaxDataCall($params) { |
|
| 164 | 164 | $result=null; |
| 165 | - if(!\is_callable($params)){ |
|
| 166 | - $result=function ($responseElement,$jqueryDone="html") use($params){ |
|
| 167 | - return AjaxTransition::{$params}($responseElement,$jqueryDone); |
|
| 165 | + if (!\is_callable($params)) { |
|
| 166 | + $result=function($responseElement, $jqueryDone="html") use($params){ |
|
| 167 | + return AjaxTransition::{$params}($responseElement, $jqueryDone); |
|
| 168 | 168 | }; |
| 169 | 169 | } |
| 170 | 170 | return $result; |
| 171 | 171 | } |
| 172 | 172 | |
| 173 | - protected function setDefaultParameters(&$parameters,$default){ |
|
| 174 | - foreach ($default as $k=>$v){ |
|
| 175 | - if(!isset($parameters[$k])) |
|
| 173 | + protected function setDefaultParameters(&$parameters, $default) { |
|
| 174 | + foreach ($default as $k=>$v) { |
|
| 175 | + if (!isset($parameters[$k])) |
|
| 176 | 176 | $parameters[$k]=$v; |
| 177 | 177 | } |
| 178 | 178 | } |
@@ -186,8 +186,8 @@ discard block |
||
| 186 | 186 | * @param string $url The url of the request |
| 187 | 187 | * @param string $responseElement selector of the HTML element displaying the answer |
| 188 | 188 | */ |
| 189 | - private function _get($url, $responseElement="",$parameters=[]) { |
|
| 190 | - return $this->_ajax("get", $url,$responseElement,$parameters); |
|
| 189 | + private function _get($url, $responseElement="", $parameters=[]) { |
|
| 190 | + return $this->_ajax("get", $url, $responseElement, $parameters); |
|
| 191 | 191 | } |
| 192 | 192 | |
| 193 | 193 | /** |
@@ -196,9 +196,9 @@ discard block |
||
| 196 | 196 | * @param string $responseElement selector of the HTML element displaying the answer |
| 197 | 197 | * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null) |
| 198 | 198 | */ |
| 199 | - public function get($url, $responseElement="",$parameters=[]) { |
|
| 199 | + public function get($url, $responseElement="", $parameters=[]) { |
|
| 200 | 200 | $parameters["immediatly"]=true; |
| 201 | - return $this->_get($url,$responseElement,$parameters); |
|
| 201 | + return $this->_get($url, $responseElement, $parameters); |
|
| 202 | 202 | } |
| 203 | 203 | |
| 204 | 204 | /** |
@@ -208,9 +208,9 @@ discard block |
||
| 208 | 208 | * @param string $responseElement selector of the HTML element displaying the answer |
| 209 | 209 | * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null) |
| 210 | 210 | */ |
| 211 | - public function ajax($method,$url, $responseElement="", $parameters=[]) { |
|
| 211 | + public function ajax($method, $url, $responseElement="", $parameters=[]) { |
|
| 212 | 212 | $parameters["immediatly"]=true; |
| 213 | - return $this->_ajax($method,$url,$responseElement,$parameters); |
|
| 213 | + return $this->_ajax($method, $url, $responseElement, $parameters); |
|
| 214 | 214 | } |
| 215 | 215 | |
| 216 | 216 | /** |
@@ -220,9 +220,9 @@ discard block |
||
| 220 | 220 | * @param string $responseElement selector of the HTML element displaying the answer |
| 221 | 221 | * @param array $parameters default : array("params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null) |
| 222 | 222 | */ |
| 223 | - public function ajaxDeferred($method,$url, $responseElement="", $parameters=[]) { |
|
| 223 | + public function ajaxDeferred($method, $url, $responseElement="", $parameters=[]) { |
|
| 224 | 224 | $parameters["immediatly"]=false; |
| 225 | - return $this->_ajax($method,$url,$responseElement,$parameters); |
|
| 225 | + return $this->_ajax($method, $url, $responseElement, $parameters); |
|
| 226 | 226 | } |
| 227 | 227 | |
| 228 | 228 | /** |
@@ -235,7 +235,7 @@ discard block |
||
| 235 | 235 | * @param string $context |
| 236 | 236 | * @param boolean $immediatly |
| 237 | 237 | */ |
| 238 | - private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
| 238 | + private function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
| 239 | 239 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 240 | 240 | $retour=$this->_getAjaxUrl($url, $attr); |
| 241 | 241 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -258,8 +258,8 @@ discard block |
||
| 258 | 258 | * @param string $context |
| 259 | 259 | * @param boolean $immediatly |
| 260 | 260 | */ |
| 261 | - public function json($url, $method="get", $params="{}", $jsCallback=NULL,$context="document",$immediatly=false) { |
|
| 262 | - return $this->_json($url,$method,$params,$jsCallback,NULL,$context,$immediatly); |
|
| 261 | + public function json($url, $method="get", $params="{}", $jsCallback=NULL, $context="document", $immediatly=false) { |
|
| 262 | + return $this->_json($url, $method, $params, $jsCallback, NULL, $context, $immediatly); |
|
| 263 | 263 | } |
| 264 | 264 | |
| 265 | 265 | /** |
@@ -269,7 +269,7 @@ discard block |
||
| 269 | 269 | * @param string $url the request address |
| 270 | 270 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
| 271 | 271 | */ |
| 272 | - public function jsonOn($event,$element, $url,$parameters=array()) { |
|
| 272 | + public function jsonOn($event, $element, $url, $parameters=array()) { |
|
| 273 | 273 | $preventDefault=true; |
| 274 | 274 | $stopPropagation=true; |
| 275 | 275 | $jsCallback=null; |
@@ -279,7 +279,7 @@ discard block |
||
| 279 | 279 | $params="{}"; |
| 280 | 280 | $immediatly=true; |
| 281 | 281 | extract($parameters); |
| 282 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 282 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 283 | 283 | } |
| 284 | 284 | |
| 285 | 285 | /** |
@@ -290,8 +290,8 @@ discard block |
||
| 290 | 290 | * @param string $jsCallback javascript code to execute after the request |
| 291 | 291 | * @param string $context jquery DOM element, array container. |
| 292 | 292 | */ |
| 293 | - public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL,$context=NULL) { |
|
| 294 | - return $this->json($url, $method, $params, $jsCallback, $context,false); |
|
| 293 | + public function jsonDeferred($url, $method="get", $params="{}", $jsCallback=NULL, $context=NULL) { |
|
| 294 | + return $this->json($url, $method, $params, $jsCallback, $context, false); |
|
| 295 | 295 | } |
| 296 | 296 | |
| 297 | 297 | /** |
@@ -304,22 +304,22 @@ discard block |
||
| 304 | 304 | * @param string $rowClass the css class for the new element |
| 305 | 305 | * @param boolean $immediatly |
| 306 | 306 | */ |
| 307 | - private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$attr="id",$immediatly=false) { |
|
| 307 | + private function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $attr="id", $immediatly=false) { |
|
| 308 | 308 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 309 | 309 | $retour=$this->_getAjaxUrl($url, $attr); |
| 310 | - if($context===null){ |
|
| 310 | + if ($context===null) { |
|
| 311 | 311 | $parent="$('".$maskSelector."').parent()"; |
| 312 | - $newElm = "$('#'+newId)"; |
|
| 313 | - }else{ |
|
| 312 | + $newElm="$('#'+newId)"; |
|
| 313 | + } else { |
|
| 314 | 314 | $parent=$context; |
| 315 | - $newElm = $context.".find('#'+newId)"; |
|
| 315 | + $newElm=$context.".find('#'+newId)"; |
|
| 316 | 316 | } |
| 317 | 317 | $appendTo="\t\tnewElm.appendTo(".$parent.");\n"; |
| 318 | 318 | $retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n"; |
| 319 | 319 | $retour.=$parent.".find('._json').remove();"; |
| 320 | 320 | $retour.="\tdata=$.parseJSON(data);$.each(data, function(index, value) {\n"."\tvar created=false;var maskElm=$('".$maskSelector."').first();maskElm.hide();"."\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;"."\tvar newElm=".$newElm.";\n"."\tif(!newElm.length){\n"."\t\tnewElm=maskElm.clone(); |
| 321 | 321 | newElm.attr('id',newId);\n;newElm.addClass('{$rowClass}').removeClass('_jsonArrayModel');\nnewElm.find('[id]').each(function(){ var newId=$(this).attr('id')+'-'+index;$(this).attr('id',newId).removeClass('_jsonArrayChecked');});\n"; |
| 322 | - $retour.= $appendTo; |
|
| 322 | + $retour.=$appendTo; |
|
| 323 | 323 | $retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('__'+key+'__')>-1){\n"."\t\t\t\tcontent=$(html.split('__'+key+'__').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n"; |
| 324 | 324 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 325 | 325 | $retour.="\t".$jsCallback."\n"."});\n"; |
@@ -338,8 +338,8 @@ discard block |
||
| 338 | 338 | * @param string $context jquery DOM element, array container. |
| 339 | 339 | * @param boolean $immediatly |
| 340 | 340 | */ |
| 341 | - public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL,$immediatly=false) { |
|
| 342 | - return $this->_jsonArray($maskSelector, $url,$method,$params,$jsCallback,$rowClass,$context,NULL,$immediatly); |
|
| 341 | + public function jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL, $immediatly=false) { |
|
| 342 | + return $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, NULL, $immediatly); |
|
| 343 | 343 | } |
| 344 | 344 | |
| 345 | 345 | /** |
@@ -352,8 +352,8 @@ discard block |
||
| 352 | 352 | * @param string $rowClass the css class for the new element |
| 353 | 353 | * @param string $context jquery DOM element, array container. |
| 354 | 354 | */ |
| 355 | - public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL,$rowClass="_json",$context=NULL) { |
|
| 356 | - return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback,$rowClass,$context,false); |
|
| 355 | + public function jsonArrayDeferred($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $rowClass="_json", $context=NULL) { |
|
| 356 | + return $this->jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, false); |
|
| 357 | 357 | } |
| 358 | 358 | |
| 359 | 359 | /** |
@@ -363,18 +363,18 @@ discard block |
||
| 363 | 363 | * @param string $url the request url |
| 364 | 364 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","rowClass"=>"_json","immediatly"=>true) |
| 365 | 365 | */ |
| 366 | - public function jsonArrayOn($event,$element,$maskSelector, $url,$parameters=array()) { |
|
| 366 | + public function jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
| 367 | 367 | $preventDefault=true; |
| 368 | 368 | $stopPropagation=true; |
| 369 | 369 | $jsCallback=null; |
| 370 | 370 | $attr="id"; |
| 371 | 371 | $method="get"; |
| 372 | - $context = null; |
|
| 372 | + $context=null; |
|
| 373 | 373 | $params="{}"; |
| 374 | 374 | $immediatly=true; |
| 375 | 375 | $rowClass="_json"; |
| 376 | 376 | extract($parameters); |
| 377 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $rowClass, $context,$attr), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 377 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $rowClass, $context, $attr), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 378 | 378 | } |
| 379 | 379 | |
| 380 | 380 | /** |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | */ |
| 387 | 387 | public function getDeferred($url, $responseElement="", $parameters=[]) { |
| 388 | 388 | $parameters["immediatly"]=false; |
| 389 | - return $this->_get($url, $responseElement,$parameters); |
|
| 389 | + return $this->_get($url, $responseElement, $parameters); |
|
| 390 | 390 | } |
| 391 | 391 | |
| 392 | 392 | /** |
@@ -399,8 +399,8 @@ discard block |
||
| 399 | 399 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null) |
| 400 | 400 | */ |
| 401 | 401 | public function getOn($event, $element, $url, $responseElement="", $parameters=array()) { |
| 402 | - $this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]); |
|
| 403 | - return $this->_add_event($element, $this->getDeferred($url,$responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]); |
|
| 402 | + $this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]); |
|
| 403 | + return $this->_add_event($element, $this->getDeferred($url, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]); |
|
| 404 | 404 | } |
| 405 | 405 | |
| 406 | 406 | /** |
@@ -413,8 +413,8 @@ discard block |
||
| 413 | 413 | * @param array $parameters default : array("method"=>"get","preventDefault"=>true,"stopPropagation"=>true,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","jsCondition"=>NULL,"headers"=>null) |
| 414 | 414 | */ |
| 415 | 415 | public function ajaxOn($event, $element, $url, $responseElement="", $parameters=array()) { |
| 416 | - $this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true,"method"=>"get"]); |
|
| 417 | - return $this->_add_event($element, $this->ajaxDeferred($parameters["method"],$url,$responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]); |
|
| 416 | + $this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true, "method"=>"get"]); |
|
| 417 | + return $this->_add_event($element, $this->ajaxDeferred($parameters["method"], $url, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]); |
|
| 418 | 418 | } |
| 419 | 419 | |
| 420 | 420 | /** |
@@ -441,9 +441,9 @@ discard block |
||
| 441 | 441 | return $this->getOn("click", $element, $url, $responseElement, $parameters); |
| 442 | 442 | } |
| 443 | 443 | |
| 444 | - private function _post($url, $params="{}",$responseElement="", $parameters=[]) { |
|
| 444 | + private function _post($url, $params="{}", $responseElement="", $parameters=[]) { |
|
| 445 | 445 | $parameters["params"]=$params; |
| 446 | - return $this->_ajax("POST", $url,$responseElement,$parameters); |
|
| 446 | + return $this->_ajax("POST", $url, $responseElement, $parameters); |
|
| 447 | 447 | } |
| 448 | 448 | |
| 449 | 449 | /** |
@@ -453,8 +453,8 @@ discard block |
||
| 453 | 453 | * @param string $params JSON parameters |
| 454 | 454 | * @param array $parameters default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null) |
| 455 | 455 | */ |
| 456 | - public function post($url, $params="{}",$responseElement="", $parameters=[]) { |
|
| 457 | - return $this->_post($url, $params,$responseElement, $parameters); |
|
| 456 | + public function post($url, $params="{}", $responseElement="", $parameters=[]) { |
|
| 457 | + return $this->_post($url, $params, $responseElement, $parameters); |
|
| 458 | 458 | } |
| 459 | 459 | |
| 460 | 460 | /** |
@@ -465,7 +465,7 @@ discard block |
||
| 465 | 465 | * @param string $responseElement selector of the HTML element displaying the answer |
| 466 | 466 | * @param array $parameters default : array("jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null) |
| 467 | 467 | */ |
| 468 | - public function postDeferred($url, $params="{}",$responseElement="", $parameters=[]) { |
|
| 468 | + public function postDeferred($url, $params="{}", $responseElement="", $parameters=[]) { |
|
| 469 | 469 | $parameters["immediatly"]=false; |
| 470 | 470 | return $this->_post($url, $params, $responseElement, $parameters); |
| 471 | 471 | } |
@@ -481,8 +481,8 @@ discard block |
||
| 481 | 481 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>NULL,"headers"=>null) |
| 482 | 482 | */ |
| 483 | 483 | public function postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
| 484 | - $this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]); |
|
| 485 | - return $this->_add_event($element, $this->postDeferred($url, $params, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]); |
|
| 484 | + $this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]); |
|
| 485 | + return $this->_add_event($element, $this->postDeferred($url, $params, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]); |
|
| 486 | 486 | } |
| 487 | 487 | |
| 488 | 488 | /** |
@@ -499,24 +499,24 @@ discard block |
||
| 499 | 499 | } |
| 500 | 500 | |
| 501 | 501 | private function _postForm($url, $form, $responseElement, $parameters=[]) { |
| 502 | - $params="{}";$validation=false;$jsCallback=NULL;$attr="id";$hasLoader=true;$jqueryDone="html";$ajaxTransition=null;$immediatly=false;$jsCondition=NULL;$headers=NULL; |
|
| 502 | + $params="{}"; $validation=false; $jsCallback=NULL; $attr="id"; $hasLoader=true; $jqueryDone="html"; $ajaxTransition=null; $immediatly=false; $jsCondition=NULL; $headers=NULL; |
|
| 503 | 503 | \extract($parameters); |
| 504 | 504 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 505 | 505 | $retour=$this->_getAjaxUrl($url, $attr); |
| 506 | 506 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
| 507 | - if(isset($params)){ |
|
| 507 | + if (isset($params)) { |
|
| 508 | 508 | $retour.="params+='&'+".self::_correctParams($params).";\n"; |
| 509 | 509 | } |
| 510 | 510 | $responseElement=$this->_getResponseElement($responseElement); |
| 511 | 511 | $retour.="var self=this;\n"; |
| 512 | - if($hasLoader===true){ |
|
| 512 | + if ($hasLoader===true) { |
|
| 513 | 513 | $this->addLoading($retour, $responseElement); |
| 514 | 514 | } |
| 515 | 515 | $strHeaders=""; |
| 516 | - if(isset($headers)) |
|
| 516 | + if (isset($headers)) |
|
| 517 | 517 | $strHeaders=", 'headers: '".self::_correctParams($headers); |
| 518 | 518 | $retour.="$.ajax({'url':url,'data':params,'method':'POST'".$strHeaders."}).done(function( data ) {\n"; |
| 519 | - $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
|
| 519 | + $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone, $ajaxTransition, $jsCallback)."});\n"; |
|
| 520 | 520 | |
| 521 | 521 | if ($validation) { |
| 522 | 522 | $retour="$('#".$form."').validate({submitHandler: function(form) { |
@@ -566,8 +566,8 @@ discard block |
||
| 566 | 566 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"params"=>"{}","jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true,"jqueryDone"=>"html","ajaxTransition"=>null,"jsCondition"=>null,"headers"=>null) |
| 567 | 567 | */ |
| 568 | 568 | public function postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
| 569 | - $this->setDefaultParameters($parameters, ["preventDefault"=>true,"stopPropagation"=>true,"immediatly"=>true]); |
|
| 570 | - return $this->_add_event($element, $this->postFormDeferred($url, $form, $responseElement,$parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"],$parameters["immediatly"]); |
|
| 569 | + $this->setDefaultParameters($parameters, ["preventDefault"=>true, "stopPropagation"=>true, "immediatly"=>true]); |
|
| 570 | + return $this->_add_event($element, $this->postFormDeferred($url, $form, $responseElement, $parameters), $event, $parameters["preventDefault"], $parameters["stopPropagation"], $parameters["immediatly"]); |
|
| 571 | 571 | } |
| 572 | 572 | |
| 573 | 573 | /** |
@@ -49,8 +49,9 @@ discard block |
||
| 49 | 49 | $retour.="$.ajax({".$this->implodeAjaxParameters($ajaxParameters)."}).done(function( data, textStatus, jqXHR ) {\n"; |
| 50 | 50 | $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
| 51 | 51 | $retour=$this->_addJsCondition($jsCondition,$retour); |
| 52 | - if ($immediatly) |
|
| 53 | - $this->jquery_code_for_compile[]=$retour; |
|
| 52 | + if ($immediatly) { |
|
| 53 | + $this->jquery_code_for_compile[]=$retour; |
|
| 54 | + } |
|
| 54 | 55 | return $retour; |
| 55 | 56 | } |
| 56 | 57 | |
@@ -86,12 +87,13 @@ discard block |
||
| 86 | 87 | if(JString::isNotNull($attr)){ |
| 87 | 88 | if ($attr==="value"){ |
| 88 | 89 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
| 89 | - }elseif ($attr==="html"){ |
|
| 90 | + } elseif ($attr==="html"){ |
|
| 90 | 91 | $retour.="url=url+'".$slash."'+$(this).html();\n"; |
| 91 | - }elseif(\substr($attr, 0,3)==="js:"){ |
|
| 92 | + } elseif(\substr($attr, 0,3)==="js:"){ |
|
| 92 | 93 | $retour.="url=url+'".$slash."'+".\substr($attr, 3).";\n"; |
| 93 | - }elseif($attr!==null && $attr!=="") |
|
| 94 | - $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
| 94 | + } elseif($attr!==null && $attr!=="") { |
|
| 95 | + $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
| 96 | + } |
|
| 95 | 97 | } |
| 96 | 98 | return $retour; |
| 97 | 99 | } |
@@ -101,13 +103,14 @@ discard block |
||
| 101 | 103 | if ($responseElement!=="") { |
| 102 | 104 | if(isset($ajaxTransition)){ |
| 103 | 105 | $call=$this->setAjaxDataCall($ajaxTransition); |
| 104 | - }elseif(isset($this->ajaxTransition)){ |
|
| 106 | + } elseif(isset($this->ajaxTransition)){ |
|
| 105 | 107 | $call=$this->ajaxTransition; |
| 106 | 108 | } |
| 107 | - if(\is_callable($call)) |
|
| 108 | - $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
| 109 | - else |
|
| 110 | - $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
|
| 109 | + if(\is_callable($call)) { |
|
| 110 | + $retour="\t".$call($responseElement,$jqueryDone).";\n"; |
|
| 111 | + } else { |
|
| 112 | + $retour="\t$({$responseElement}).{$jqueryDone}( data );\n"; |
|
| 113 | + } |
|
| 111 | 114 | } |
| 112 | 115 | $retour.="\t".$jsCallback."\n"; |
| 113 | 116 | return $retour; |
@@ -121,8 +124,9 @@ discard block |
||
| 121 | 124 | } |
| 122 | 125 | |
| 123 | 126 | protected function _correctAjaxUrl($url) { |
| 124 | - if ($url!=="/" && JString::endsWith($url, "/")===true) |
|
| 125 | - $url=substr($url, 0, strlen($url)-1); |
|
| 127 | + if ($url!=="/" && JString::endsWith($url, "/")===true) { |
|
| 128 | + $url=substr($url, 0, strlen($url)-1); |
|
| 129 | + } |
|
| 126 | 130 | if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
| 127 | 131 | $url=$this->getUrl($url); |
| 128 | 132 | } |
@@ -142,8 +146,9 @@ discard block |
||
| 142 | 146 | public static function _implodeParams($parameters){ |
| 143 | 147 | $allParameters=[]; |
| 144 | 148 | foreach ($parameters as $params){ |
| 145 | - if(isset($params)) |
|
| 146 | - $allParameters[]=self::_correctParams($params); |
|
| 149 | + if(isset($params)) { |
|
| 150 | + $allParameters[]=self::_correctParams($params); |
|
| 151 | + } |
|
| 147 | 152 | } |
| 148 | 153 | return \implode("+'&'+", $allParameters); |
| 149 | 154 | } |
@@ -172,8 +177,9 @@ discard block |
||
| 172 | 177 | |
| 173 | 178 | protected function setDefaultParameters(&$parameters,$default){ |
| 174 | 179 | foreach ($default as $k=>$v){ |
| 175 | - if(!isset($parameters[$k])) |
|
| 176 | - $parameters[$k]=$v; |
|
| 180 | + if(!isset($parameters[$k])) { |
|
| 181 | + $parameters[$k]=$v; |
|
| 182 | + } |
|
| 177 | 183 | } |
| 178 | 184 | } |
| 179 | 185 | |
@@ -244,8 +250,9 @@ discard block |
||
| 244 | 250 | $retour.="\t".$jsCallback."\n". |
| 245 | 251 | "\t$(document).trigger('jsonReady',[data]);\n". |
| 246 | 252 | "});\n"; |
| 247 | - if ($immediatly) |
|
| 248 | - $this->jquery_code_for_compile[]=$retour; |
|
| 253 | + if ($immediatly) { |
|
| 254 | + $this->jquery_code_for_compile[]=$retour; |
|
| 255 | + } |
|
| 249 | 256 | return $retour; |
| 250 | 257 | } |
| 251 | 258 | |
@@ -310,7 +317,7 @@ discard block |
||
| 310 | 317 | if($context===null){ |
| 311 | 318 | $parent="$('".$maskSelector."').parent()"; |
| 312 | 319 | $newElm = "$('#'+newId)"; |
| 313 | - }else{ |
|
| 320 | + } else{ |
|
| 314 | 321 | $parent=$context; |
| 315 | 322 | $newElm = $context.".find('#'+newId)"; |
| 316 | 323 | } |
@@ -323,8 +330,9 @@ discard block |
||
| 323 | 330 | $retour.="\t}\n"."\tfor(var key in value){\n"."\t\t\tvar html = $('<div />').append($(newElm).clone()).html();\n"."\t\t\tif(html.indexOf('__'+key+'__')>-1){\n"."\t\t\t\tcontent=$(html.split('__'+key+'__').join(value[key]));\n"."\t\t\t\t$(newElm).replaceWith(content);newElm=content;\n"."\t\t\t}\n"."\t\tvar sel='[data-id=\"'+key+'\"]';if($(sel,newElm).length){\n"."\t\t\tvar selElm=$(sel,newElm);\n"."\t\t\t if(selElm.is('[value]')) { selElm.attr('value',value[key]);selElm.val(value[key]);} else { selElm.html(value[key]); }\n"."\t\t}\n"."}\n"."\t$(newElm).show(true);"."\n"."\t$(newElm).removeClass('hide');"."});\n"; |
| 324 | 331 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 325 | 332 | $retour.="\t".$jsCallback."\n"."});\n"; |
| 326 | - if ($immediatly) |
|
| 327 | - $this->jquery_code_for_compile[]=$retour; |
|
| 333 | + if ($immediatly) { |
|
| 334 | + $this->jquery_code_for_compile[]=$retour; |
|
| 335 | + } |
|
| 328 | 336 | return $retour; |
| 329 | 337 | } |
| 330 | 338 | |
@@ -513,8 +521,9 @@ discard block |
||
| 513 | 521 | $this->addLoading($retour, $responseElement); |
| 514 | 522 | } |
| 515 | 523 | $strHeaders=""; |
| 516 | - if(isset($headers)) |
|
| 517 | - $strHeaders=", 'headers: '".self::_correctParams($headers); |
|
| 524 | + if(isset($headers)) { |
|
| 525 | + $strHeaders=", 'headers: '".self::_correctParams($headers); |
|
| 526 | + } |
|
| 518 | 527 | $retour.="$.ajax({'url':url,'data':params,'method':'POST'".$strHeaders."}).done(function( data ) {\n"; |
| 519 | 528 | $retour.=$this->_getOnAjaxDone($responseElement, $jqueryDone,$ajaxTransition,$jsCallback)."});\n"; |
| 520 | 529 | |
@@ -525,8 +534,9 @@ discard block |
||
| 525 | 534 | $retour.="$('#".$form."').submit();\n"; |
| 526 | 535 | } |
| 527 | 536 | $retour=$this->_addJsCondition($jsCondition, $retour); |
| 528 | - if ($immediatly) |
|
| 529 | - $this->jquery_code_for_compile[]=$retour; |
|
| 537 | + if ($immediatly) { |
|
| 538 | + $this->jquery_code_for_compile[]=$retour; |
|
| 539 | + } |
|
| 530 | 540 | return $retour; |
| 531 | 541 | } |
| 532 | 542 | |