@@ -70,14 +70,14 @@ discard block |
||
| 70 | 70 | $span->setTagName("div"); |
| 71 | 71 | $buttons=array(); |
| 72 | 72 | $i=1; |
| 73 | - foreach ($items as $item){ |
|
| 73 | + foreach ($items as $item) { |
|
| 74 | 74 | $bt=NULL; |
| 75 | - if(is_string($item)){ |
|
| 76 | - $bt=new HtmlButton($this->identifier."-bt-".$i++,$item); |
|
| 77 | - }elseif ($item instanceof HtmlButton){ |
|
| 75 | + if (is_string($item)) { |
|
| 76 | + $bt=new HtmlButton($this->identifier."-bt-".$i++, $item); |
|
| 77 | + }elseif ($item instanceof HtmlButton) { |
|
| 78 | 78 | $bt=$item; |
| 79 | 79 | } |
| 80 | - if(isset($bt)){ |
|
| 80 | + if (isset($bt)) { |
|
| 81 | 81 | $buttons[]=$bt; |
| 82 | 82 | } |
| 83 | 83 | } |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | public function setSize($size) { |
| 121 | 121 | if (is_int($size)) { |
| 122 | - return $this->addToMemberCtrl($this->mClass, CssRef::sizes("input-group")[$size],CssRef::sizes("input-group")); |
|
| 122 | + return $this->addToMemberCtrl($this->mClass, CssRef::sizes("input-group")[$size], CssRef::sizes("input-group")); |
|
| 123 | 123 | } |
| 124 | 124 | return $this->addToMemberCtrl($this->mClass, $size, CssRef::sizes("input-group")); |
| 125 | 125 | } |
@@ -28,10 +28,11 @@ discard block |
||
| 28 | 28 | $this->setProperty("aria-describedby", $id); |
| 29 | 29 | $span->setContent($text); |
| 30 | 30 | $span->setClass("input-group-addon"); |
| 31 | - if (strtolower($position)==="left") |
|
| 32 | - $this->addonLeft=$span; |
|
| 33 | - else |
|
| 34 | - $this->addonRight=$span; |
|
| 31 | + if (strtolower($position)==="left") { |
|
| 32 | + $this->addonLeft=$span; |
|
| 33 | + } else { |
|
| 34 | + $this->addonRight=$span; |
|
| 35 | + } |
|
| 35 | 36 | return $span; |
| 36 | 37 | } |
| 37 | 38 | |
@@ -74,7 +75,7 @@ discard block |
||
| 74 | 75 | $bt=NULL; |
| 75 | 76 | if(is_string($item)){ |
| 76 | 77 | $bt=new HtmlButton($this->identifier."-bt-".$i++,$item); |
| 77 | - }elseif ($item instanceof HtmlButton){ |
|
| 78 | + } elseif ($item instanceof HtmlButton){ |
|
| 78 | 79 | $bt=$item; |
| 79 | 80 | } |
| 80 | 81 | if(isset($bt)){ |
@@ -88,10 +89,11 @@ discard block |
||
| 88 | 89 | $dropdown->setBtnCaption($caption); |
| 89 | 90 | $dropdown->fromArray($items); |
| 90 | 91 | |
| 91 | - if (strtolower($position)==="left") |
|
| 92 | - $this->addonLeft=$dropdown; |
|
| 93 | - else |
|
| 94 | - $this->addonRight=$dropdown; |
|
| 92 | + if (strtolower($position)==="left") { |
|
| 93 | + $this->addonLeft=$dropdown; |
|
| 94 | + } else { |
|
| 95 | + $this->addonRight=$dropdown; |
|
| 96 | + } |
|
| 95 | 97 | return $dropdown; |
| 96 | 98 | } |
| 97 | 99 | |
@@ -126,10 +128,12 @@ discard block |
||
| 126 | 128 | |
| 127 | 129 | public function run(JsUtils $js) { |
| 128 | 130 | parent::run($js); |
| 129 | - if (isset($this->addonLeft)) |
|
| 130 | - $this->addonLeft->run($js); |
|
| 131 | - if (isset($this->addonRight)) |
|
| 132 | - $this->addonRight->run($js); |
|
| 131 | + if (isset($this->addonLeft)) { |
|
| 132 | + $this->addonLeft->run($js); |
|
| 133 | + } |
|
| 134 | + if (isset($this->addonRight)) { |
|
| 135 | + $this->addonRight->run($js); |
|
| 136 | + } |
|
| 133 | 137 | } |
| 134 | 138 | |
| 135 | 139 | } |
| 136 | 140 | \ No newline at end of file |
@@ -42,7 +42,7 @@ |
||
| 42 | 42 | */ |
| 43 | 43 | public function run(JsUtils $js) { |
| 44 | 44 | if ($this->getProperty("role")==="nav") { |
| 45 | - foreach ( $this->items as $dropdownItem ) { |
|
| 45 | + foreach ($this->items as $dropdownItem) { |
|
| 46 | 46 | $dropdownItem->runNav($js); |
| 47 | 47 | } |
| 48 | 48 | } |
@@ -71,7 +71,7 @@ |
||
| 71 | 71 | $element=new HtmlBsDoubleElement("", "p"); |
| 72 | 72 | $element->setContent($content); |
| 73 | 73 | $element->setClass("list-group-item-text"); |
| 74 | - $this->element->setContent(array ( |
|
| 74 | + $this->element->setContent(array( |
|
| 75 | 75 | $elementHeader, |
| 76 | 76 | $element |
| 77 | 77 | )); |
@@ -40,8 +40,9 @@ |
||
| 40 | 40 | * @return \Ajax\bootstrap\html\HtmlListgroupItem default : "list-group-item-default" |
| 41 | 41 | */ |
| 42 | 42 | public function setStyle($cssStyle) { |
| 43 | - if (!PhalconUtils::startsWith($cssStyle, "list-group-item")) |
|
| 44 | - $cssStyle="list-group-item".$cssStyle; |
|
| 43 | + if (!PhalconUtils::startsWith($cssStyle, "list-group-item")) { |
|
| 44 | + $cssStyle="list-group-item".$cssStyle; |
|
| 45 | + } |
|
| 45 | 46 | $this->element->addToPropertyCtrl("class", $cssStyle, CssRef::Styles("list-group-item")); |
| 46 | 47 | return $this->element; |
| 47 | 48 | } |
@@ -62,15 +62,15 @@ |
||
| 62 | 62 | */ |
| 63 | 63 | public function setIdentifier($identifier) { |
| 64 | 64 | parent::setIdentifier($identifier); |
| 65 | - if($this->content instanceof HtmlLink){ |
|
| 65 | + if ($this->content instanceof HtmlLink) { |
|
| 66 | 66 | $this->content->setIdentifier("link-".$identifier); |
| 67 | 67 | } |
| 68 | 68 | } |
| 69 | - public function setActive($value=true){ |
|
| 70 | - $this->setProperty("class", ($value)?"active":""); |
|
| 69 | + public function setActive($value=true) { |
|
| 70 | + $this->setProperty("class", ($value) ? "active" : ""); |
|
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - public function disable(){ |
|
| 73 | + public function disable() { |
|
| 74 | 74 | $this->setProperty("class", "disabled"); |
| 75 | 75 | } |
| 76 | 76 | } |
| 77 | 77 | \ No newline at end of file |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | parent::__construct($identifier); |
| 28 | 28 | $this->tagName="ul"; |
| 29 | 29 | $this->_template='<%tagName% id="%identifier%" class="nav navbar-nav %class%">%elements%</%tagName%>'; |
| 30 | - $this->elements=array (); |
|
| 30 | + $this->elements=array(); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | 33 | public function setClass($value) { |
@@ -39,7 +39,7 @@ discard block |
||
| 39 | 39 | } |
| 40 | 40 | |
| 41 | 41 | public function addElement($element) { |
| 42 | - if($element instanceof HtmlLink){ |
|
| 42 | + if ($element instanceof HtmlLink) { |
|
| 43 | 43 | $this->addLink($element); |
| 44 | 44 | } else if (is_object($element)) { |
| 45 | 45 | $this->elements []=$element; |
@@ -59,7 +59,7 @@ discard block |
||
| 59 | 59 | |
| 60 | 60 | public function addElements($elements) { |
| 61 | 61 | if (is_array($elements)) { |
| 62 | - foreach ( $elements as $key => $element ) { |
|
| 62 | + foreach ($elements as $key => $element) { |
|
| 63 | 63 | $iid=$this->getElementsCount()+1; |
| 64 | 64 | if ($element instanceof HtmlDropdownItem) |
| 65 | 65 | $this->elements []=$element; |
@@ -87,9 +87,9 @@ discard block |
||
| 87 | 87 | public function addLink($caption, $href="#") { |
| 88 | 88 | $iid=$this->getElementsCount()+1; |
| 89 | 89 | $li=new HtmlBsDoubleElement($this->identifier."-li-".$iid, "li"); |
| 90 | - if($caption instanceof HtmlLink){ |
|
| 90 | + if ($caption instanceof HtmlLink) { |
|
| 91 | 91 | $link=$caption; |
| 92 | - }else{ |
|
| 92 | + } else { |
|
| 93 | 93 | $link=new HtmlLink($this->identifier."-link-".$iid, $href, $caption); |
| 94 | 94 | } |
| 95 | 95 | $li->setContent($link); |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | } |
| 123 | 123 | |
| 124 | 124 | public function run(JsUtils $js) { |
| 125 | - foreach ( $this->elements as $element ) { |
|
| 125 | + foreach ($this->elements as $element) { |
|
| 126 | 126 | $element->run($js); |
| 127 | 127 | } |
| 128 | 128 | } |
@@ -143,7 +143,7 @@ discard block |
||
| 143 | 143 | * @param int $index |
| 144 | 144 | * @return BaseHtml |
| 145 | 145 | */ |
| 146 | - public function getElement($index){ |
|
| 146 | + public function getElement($index) { |
|
| 147 | 147 | return $this->elements[$index]; |
| 148 | 148 | } |
| 149 | 149 | } |
| 150 | 150 | \ No newline at end of file |
@@ -61,9 +61,9 @@ discard block |
||
| 61 | 61 | if (is_array($elements)) { |
| 62 | 62 | foreach ( $elements as $key => $element ) { |
| 63 | 63 | $iid=$this->getElementsCount()+1; |
| 64 | - if ($element instanceof HtmlDropdownItem) |
|
| 65 | - $this->elements []=$element; |
|
| 66 | - else if (is_array($element)) { |
|
| 64 | + if ($element instanceof HtmlDropdownItem) { |
|
| 65 | + $this->elements []=$element; |
|
| 66 | + } else if (is_array($element)) { |
|
| 67 | 67 | if (is_string($key)===true) { |
| 68 | 68 | $dropdown=new HtmlDropdown($this->identifier."-dropdown-".$iid); |
| 69 | 69 | $dropdown->addItems($element); |
@@ -89,7 +89,7 @@ discard block |
||
| 89 | 89 | $li=new HtmlBsDoubleElement($this->identifier."-li-".$iid, "li"); |
| 90 | 90 | if($caption instanceof HtmlLink){ |
| 91 | 91 | $link=$caption; |
| 92 | - }else{ |
|
| 92 | + } else{ |
|
| 93 | 93 | $link=new HtmlLink($this->identifier."-link-".$iid, $href, $caption); |
| 94 | 94 | } |
| 95 | 95 | $li->setContent($link); |
@@ -14,7 +14,7 @@ |
||
| 14 | 14 | public function __construct($identifier, $tagName="div") { |
| 15 | 15 | parent::__construct($identifier, $tagName); |
| 16 | 16 | $this->setProperty("class", "tab-content"); |
| 17 | - $this->content=array (); // HtmlTabContentItem |
|
| 17 | + $this->content=array(); // HtmlTabContentItem |
|
| 18 | 18 | } |
| 19 | 19 | |
| 20 | 20 | public function addTabItem($identifier) { |
@@ -23,8 +23,9 @@ |
||
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function getTabItem($index) { |
| 26 | - if ($index<sizeof($this->content)) |
|
| 27 | - return $this->content [$index]; |
|
| 26 | + if ($index<sizeof($this->content)) { |
|
| 27 | + return $this->content [$index]; |
|
| 28 | + } |
|
| 28 | 29 | } |
| 29 | 30 | |
| 30 | 31 | public function getTabItems() { |
@@ -15,22 +15,22 @@ discard block |
||
| 15 | 15 | class HtmlGridCol extends HtmlBsDoubleElement { |
| 16 | 16 | private $positions; |
| 17 | 17 | private $offsets; |
| 18 | - public function __construct($identifier,$size=CssSize::SIZE_MD,$width=1){ |
|
| 19 | - parent::__construct($identifier,"div"); |
|
| 18 | + public function __construct($identifier, $size=CssSize::SIZE_MD, $width=1) { |
|
| 19 | + parent::__construct($identifier, "div"); |
|
| 20 | 20 | $this->positions=array(); |
| 21 | 21 | $this->offsets=array(); |
| 22 | - $this->addPosition($size,$width); |
|
| 22 | + $this->addPosition($size, $width); |
|
| 23 | 23 | } |
| 24 | - public function addPosition($size=CssSize::SIZE_MD,$width=1){ |
|
| 24 | + public function addPosition($size=CssSize::SIZE_MD, $width=1) { |
|
| 25 | 25 | $this->positions[$size]=$width; |
| 26 | 26 | return $this; |
| 27 | 27 | } |
| 28 | - private function _generateClass(){ |
|
| 28 | + private function _generateClass() { |
|
| 29 | 29 | $result=array(); |
| 30 | - foreach ($this->positions as $size=>$width){ |
|
| 30 | + foreach ($this->positions as $size=>$width) { |
|
| 31 | 31 | $result[]="col-".$size."-".$width; |
| 32 | 32 | } |
| 33 | - foreach ($this->offsets as $size=>$offset){ |
|
| 33 | + foreach ($this->offsets as $size=>$offset) { |
|
| 34 | 34 | $result[]="col-".$size."-offset-".$offset; |
| 35 | 35 | } |
| 36 | 36 | return implode(" ", $result); |
@@ -38,63 +38,63 @@ discard block |
||
| 38 | 38 | |
| 39 | 39 | public function compile(JsUtils $js=NULL, &$view=NULL) { |
| 40 | 40 | $this->setProperty("class", $this->_generateClass()); |
| 41 | - return parent::compile($js,$view); |
|
| 41 | + return parent::compile($js, $view); |
|
| 42 | 42 | } |
| 43 | 43 | |
| 44 | - public function setOffset($size,$offset){ |
|
| 44 | + public function setOffset($size, $offset) { |
|
| 45 | 45 | $this->offsets[$size]=$offset; |
| 46 | 46 | return $this; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - public function setOffsetForAll($newOffset){ |
|
| 50 | - foreach ($this->offsets as &$value){ |
|
| 49 | + public function setOffsetForAll($newOffset) { |
|
| 50 | + foreach ($this->offsets as &$value) { |
|
| 51 | 51 | $value=$newOffset; |
| 52 | 52 | } |
| 53 | 53 | unset($value); |
| 54 | 54 | return $this; |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - public function setWidthForAll($newWidth){ |
|
| 58 | - foreach ($this->positions as &$pos){ |
|
| 57 | + public function setWidthForAll($newWidth) { |
|
| 58 | + foreach ($this->positions as &$pos) { |
|
| 59 | 59 | $pos=$newWidth; |
| 60 | 60 | } |
| 61 | 61 | unset($pos); |
| 62 | 62 | return $this; |
| 63 | 63 | } |
| 64 | 64 | |
| 65 | - public function setWidth($size=CssSize::SIZE_MD,$width=1){ |
|
| 65 | + public function setWidth($size=CssSize::SIZE_MD, $width=1) { |
|
| 66 | 66 | $this->positions[$size]=$width; |
| 67 | 67 | return $this; |
| 68 | 68 | } |
| 69 | 69 | |
| 70 | - public function setPosition($size=CssSize::SIZE_MD,$width=1){ |
|
| 71 | - return $this->addPosition($size,$width); |
|
| 70 | + public function setPosition($size=CssSize::SIZE_MD, $width=1) { |
|
| 71 | + return $this->addPosition($size, $width); |
|
| 72 | 72 | } |
| 73 | 73 | |
| 74 | - public function getWidth($size){ |
|
| 74 | + public function getWidth($size) { |
|
| 75 | 75 | return @$this->positions[$size]; |
| 76 | 76 | } |
| 77 | 77 | |
| 78 | - public function getOffest($size){ |
|
| 78 | + public function getOffest($size) { |
|
| 79 | 79 | return @$this->offsets[$size]; |
| 80 | 80 | } |
| 81 | 81 | |
| 82 | - public function addClear(){ |
|
| 83 | - $this->wrap("","<div class='clearfix'></div>"); |
|
| 82 | + public function addClear() { |
|
| 83 | + $this->wrap("", "<div class='clearfix'></div>"); |
|
| 84 | 84 | } |
| 85 | 85 | public function setOffsets($offsets) { |
| 86 | - $this->offsets = $offsets; |
|
| 86 | + $this->offsets=$offsets; |
|
| 87 | 87 | return $this; |
| 88 | 88 | } |
| 89 | 89 | |
| 90 | - public function copy($identifier){ |
|
| 90 | + public function copy($identifier) { |
|
| 91 | 91 | $result=new HtmlGridCol($identifier); |
| 92 | 92 | $result->setPositions($this->positions); |
| 93 | 93 | $result->setOffsets($this->offsets); |
| 94 | 94 | return $result; |
| 95 | 95 | } |
| 96 | 96 | public function setPositions($positions) { |
| 97 | - $this->positions = $positions; |
|
| 97 | + $this->positions=$positions; |
|
| 98 | 98 | return $this; |
| 99 | 99 | } |
| 100 | 100 | public function getOffsets() { |
@@ -50,14 +50,14 @@ |
||
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
| 53 | - * render the content of $controller::$action and set the response to a new panel |
|
| 54 | - * @param JsUtils $js |
|
| 55 | - * @param string $title The panel title |
|
| 56 | - * @param Controller $initialController |
|
| 57 | - * @param string $controller a Phalcon controller |
|
| 58 | - * @param string $action a Phalcon action |
|
| 59 | - * @param array $params |
|
| 60 | - */ |
|
| 53 | + * render the content of $controller::$action and set the response to a new panel |
|
| 54 | + * @param JsUtils $js |
|
| 55 | + * @param string $title The panel title |
|
| 56 | + * @param Controller $initialController |
|
| 57 | + * @param string $controller a Phalcon controller |
|
| 58 | + * @param string $action a Phalcon action |
|
| 59 | + * @param array $params |
|
| 60 | + */ |
|
| 61 | 61 | public function forwardPanel(JsUtils $js,$title,$initialController,$controller,$action,$params=array()){ |
| 62 | 62 | return $this->addPanel($title, $js->forward($initialController, $controller, $action,$params)); |
| 63 | 63 | } |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | $this->setClass("panel-group"); |
| 20 | 20 | $this->setRole("tablist"); |
| 21 | 21 | $this->setProperty("aria-multiselectable", "true"); |
| 22 | - $this->content=array (); |
|
| 22 | + $this->content=array(); |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | public function addPanel($title, $content) { |
@@ -45,8 +45,8 @@ discard block |
||
| 45 | 45 | * @param string $viewName |
| 46 | 46 | * @param $params The parameters to pass to the view |
| 47 | 47 | */ |
| 48 | - public function renderViewPanel(JsUtils $js,$title,$initialController, $viewName, $params=array()) { |
|
| 49 | - return $this->addPanel($title, $js->renderContent($initialController, $viewName,$params)); |
|
| 48 | + public function renderViewPanel(JsUtils $js, $title, $initialController, $viewName, $params=array()) { |
|
| 49 | + return $this->addPanel($title, $js->renderContent($initialController, $viewName, $params)); |
|
| 50 | 50 | } |
| 51 | 51 | |
| 52 | 52 | /** |
@@ -58,12 +58,12 @@ discard block |
||
| 58 | 58 | * @param string $action a Phalcon action |
| 59 | 59 | * @param array $params |
| 60 | 60 | */ |
| 61 | - public function forwardPanel(JsUtils $js,$title,$initialController,$controller,$action,$params=array()){ |
|
| 62 | - return $this->addPanel($title, $js->forward($initialController, $controller, $action,$params)); |
|
| 61 | + public function forwardPanel(JsUtils $js, $title, $initialController, $controller, $action, $params=array()) { |
|
| 62 | + return $this->addPanel($title, $js->forward($initialController, $controller, $action, $params)); |
|
| 63 | 63 | } |
| 64 | 64 | |
| 65 | 65 | public function run(JsUtils $js) { |
| 66 | - foreach ( $this->content as $content ) { |
|
| 66 | + foreach ($this->content as $content) { |
|
| 67 | 67 | $content->run($js); |
| 68 | 68 | } |
| 69 | 69 | } |
@@ -69,7 +69,8 @@ |
||
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | public function getPanel($index) { |
| 72 | - if ($index<sizeof($this->content)) |
|
| 73 | - return $this->content [$index]; |
|
| 72 | + if ($index<sizeof($this->content)) { |
|
| 73 | + return $this->content [$index]; |
|
| 74 | + } |
|
| 74 | 75 | } |
| 75 | 76 | } |
| 76 | 77 | \ No newline at end of file |
@@ -10,7 +10,7 @@ discard block |
||
| 10 | 10 | protected $ajaxLoader='<span></span><span></span><span></span><span></span><span></span>'; |
| 11 | 11 | |
| 12 | 12 | public abstract function _prep_value($value); |
| 13 | - public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false,$immediatly=true); |
|
| 13 | + public abstract function _add_event($element, $js, $event, $preventDefault=false, $stopPropagation=false, $immediatly=true); |
|
| 14 | 14 | protected function addLoading(&$retour, $responseElement) { |
| 15 | 15 | $loading_notifier='<div class="ajax-loader">'; |
| 16 | 16 | if ($this->ajaxLoader=='') { |
@@ -23,20 +23,20 @@ discard block |
||
| 23 | 23 | $retour.="\t\t$({$responseElement}).prepend('{$loading_notifier}');\n"; |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 27 | - return $this->_ajax("get", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
| 26 | + public function _get($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 27 | + return $this->_ajax("get", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
| 28 | 28 | } |
| 29 | - public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 30 | - return $this->_ajax("post", $url,$params,$responseElement,$jsCallback,$attr,$hasLoader,$immediatly); |
|
| 29 | + public function _post($url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 30 | + return $this->_ajax("post", $url, $params, $responseElement, $jsCallback, $attr, $hasLoader, $immediatly); |
|
| 31 | 31 | } |
| 32 | 32 | |
| 33 | - protected function _ajax($method,$url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 34 | - if(JString::isNull($params)){$params="{}";} |
|
| 33 | + protected function _ajax($method, $url, $params="{}", $responseElement="", $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 34 | + if (JString::isNull($params)) {$params="{}"; } |
|
| 35 | 35 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 36 | 36 | $retour=$this->_getAjaxUrl($url, $attr); |
| 37 | 37 | $responseElement=$this->_getResponseElement($responseElement); |
| 38 | 38 | $retour.="var self=this;\n"; |
| 39 | - if($hasLoader===true){ |
|
| 39 | + if ($hasLoader===true) { |
|
| 40 | 40 | $this->addLoading($retour, $responseElement); |
| 41 | 41 | } |
| 42 | 42 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
@@ -46,22 +46,22 @@ discard block |
||
| 46 | 46 | return $retour; |
| 47 | 47 | } |
| 48 | 48 | |
| 49 | - protected function _getAjaxUrl($url,$attr){ |
|
| 49 | + protected function _getAjaxUrl($url, $attr) { |
|
| 50 | 50 | $url=$this->_correctAjaxUrl($url); |
| 51 | 51 | $retour="url='".$url."';\n"; |
| 52 | 52 | $slash="/"; |
| 53 | - if(JString::endswith($url, "/")===true) |
|
| 53 | + if (JString::endswith($url, "/")===true) |
|
| 54 | 54 | $slash=""; |
| 55 | - if(JString::isNotNull($attr)){ |
|
| 55 | + if (JString::isNotNull($attr)) { |
|
| 56 | 56 | if ($attr=="value") |
| 57 | 57 | $retour.="url=url+'".$slash."'+$(this).val();\n"; |
| 58 | - else if($attr!=null && $attr!=="") |
|
| 58 | + else if ($attr!=null && $attr!=="") |
|
| 59 | 59 | $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
| 60 | 60 | } |
| 61 | 61 | return $retour; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - protected function _getOnAjaxDone($responseElement,$jsCallback){ |
|
| 64 | + protected function _getOnAjaxDone($responseElement, $jsCallback) { |
|
| 65 | 65 | $retour=""; |
| 66 | 66 | if ($responseElement!=="") { |
| 67 | 67 | $retour="\t$({$responseElement}).html( data );\n"; |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | return $retour; |
| 71 | 71 | } |
| 72 | 72 | |
| 73 | - protected function _getResponseElement($responseElement){ |
|
| 73 | + protected function _getResponseElement($responseElement) { |
|
| 74 | 74 | if ($responseElement!=="") { |
| 75 | 75 | $responseElement=$this->_prep_value($responseElement); |
| 76 | 76 | } |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | protected function _correctAjaxUrl($url) { |
| 81 | 81 | if ($url!=="/" && JString::endsWith($url, "/")===true) |
| 82 | 82 | $url=substr($url, 0, strlen($url)-1); |
| 83 | - if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
|
| 83 | + if (strncmp($url, 'http://', 7)!=0 && strncmp($url, 'https://', 8)!=0) { |
|
| 84 | 84 | $url=$this->jsUtils->getUrl($url); |
| 85 | 85 | } |
| 86 | 86 | return $url; |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | * @param string $jsCallback javascript code to execute after the request |
| 95 | 95 | * @param boolean $immediatly |
| 96 | 96 | */ |
| 97 | - public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document",$immediatly=false) { |
|
| 97 | + public function _json($url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context="document", $immediatly=false) { |
|
| 98 | 98 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 99 | 99 | $retour=$this->_getAjaxUrl($url, $attr); |
| 100 | 100 | $retour.="$.{$method}(url,".$params.").done(function( data ) {\n"; |
@@ -115,7 +115,7 @@ discard block |
||
| 115 | 115 | * @param string $url the request address |
| 116 | 116 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get","immediatly"=>true) |
| 117 | 117 | */ |
| 118 | - public function _jsonOn($event,$element, $url,$parameters=array()) { |
|
| 118 | + public function _jsonOn($event, $element, $url, $parameters=array()) { |
|
| 119 | 119 | $preventDefault=true; |
| 120 | 120 | $stopPropagation=true; |
| 121 | 121 | $jsCallback=null; |
@@ -125,7 +125,7 @@ discard block |
||
| 125 | 125 | $params="{}"; |
| 126 | 126 | $immediatly=true; |
| 127 | 127 | extract($parameters); |
| 128 | - return $this->_add_event($element, $this->_json($url,$method, $params,$jsCallback, $attr,$context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 128 | + return $this->_add_event($element, $this->_json($url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 129 | 129 | } |
| 130 | 130 | |
| 131 | 131 | /** |
@@ -137,19 +137,19 @@ discard block |
||
| 137 | 137 | * @param string $context jquery DOM element, array container. |
| 138 | 138 | * @param boolean $immediatly |
| 139 | 139 | */ |
| 140 | - public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null,$immediatly=false) { |
|
| 140 | + public function _jsonArray($maskSelector, $url, $method="get", $params="{}", $jsCallback=NULL, $attr="id", $context=null, $immediatly=false) { |
|
| 141 | 141 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 142 | 142 | $retour=$this->_getAjaxUrl($url, $attr); |
| 143 | - if($context===null){ |
|
| 143 | + if ($context===null) { |
|
| 144 | 144 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
| 145 | - $newElm = "$('#'+newId)"; |
|
| 146 | - }else{ |
|
| 145 | + $newElm="$('#'+newId)"; |
|
| 146 | + } else { |
|
| 147 | 147 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
| 148 | - $newElm = $context.".find('#'+newId)"; |
|
| 148 | + $newElm=$context.".find('#'+newId)"; |
|
| 149 | 149 | } |
| 150 | 150 | $retour.="var self = $(this);\n$.{$method}(url,".$params.").done(function( data ) {\n"; |
| 151 | 151 | $retour.="\tdata=$.parseJSON(data);$.each(data, function(index, value) {\n"."\tvar created=false;var maskElm=$('".$maskSelector."').first();maskElm.hide();"."\tvar newId=(maskElm.attr('id') || 'mask')+'-'+index;"."\tvar newElm=".$newElm.";\n"."\tif(!newElm.length){\n"."\t\tnewElm=maskElm.clone();newElm.attr('id',newId);\n"; |
| 152 | - $retour.= $appendTo; |
|
| 152 | + $retour.=$appendTo; |
|
| 153 | 153 | $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"; |
| 154 | 154 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 155 | 155 | $retour.="\t".$jsCallback."\n"."});\n"; |
@@ -164,26 +164,26 @@ discard block |
||
| 164 | 164 | * @param string $url the request address |
| 165 | 165 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","params"=>"{}","method"=>"get", "context"=>null) |
| 166 | 166 | */ |
| 167 | - public function _jsonArrayOn($event,$element, $maskSelector,$url,$parameters=array()) { |
|
| 167 | + public function _jsonArrayOn($event, $element, $maskSelector, $url, $parameters=array()) { |
|
| 168 | 168 | $preventDefault=true; |
| 169 | 169 | $stopPropagation=true; |
| 170 | 170 | $jsCallback=null; |
| 171 | 171 | $attr="id"; |
| 172 | 172 | $method="get"; |
| 173 | - $context = null; |
|
| 173 | + $context=null; |
|
| 174 | 174 | $params="{}"; |
| 175 | 175 | $immediatly=true; |
| 176 | 176 | extract($parameters); |
| 177 | - return $this->_add_event($element, $this->_jsonArray($maskSelector,$url,$method, $params,$jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 177 | + return $this->_add_event($element, $this->_jsonArray($maskSelector, $url, $method, $params, $jsCallback, $attr, $context), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 178 | 178 | } |
| 179 | 179 | |
| 180 | - public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true,$immediatly=false) { |
|
| 180 | + public function _postForm($url, $form, $responseElement, $validation=false, $jsCallback=NULL, $attr="id", $hasLoader=true, $immediatly=false) { |
|
| 181 | 181 | $jsCallback=isset($jsCallback) ? $jsCallback : ""; |
| 182 | 182 | $retour=$this->_getAjaxUrl($url, $attr); |
| 183 | 183 | $retour.="\nvar params=$('#".$form."').serialize();\n"; |
| 184 | 184 | $responseElement=$this->_getResponseElement($responseElement); |
| 185 | 185 | $retour.="var self=this;\n"; |
| 186 | - if($hasLoader===true){ |
|
| 186 | + if ($hasLoader===true) { |
|
| 187 | 187 | $this->addLoading($retour, $responseElement); |
| 188 | 188 | } |
| 189 | 189 | $retour.="$.post(url,params).done(function( data ) {\n"; |
@@ -210,7 +210,7 @@ discard block |
||
| 210 | 210 | * @param string $responseElement |
| 211 | 211 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
| 212 | 212 | */ |
| 213 | - public function _getOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 213 | + public function _getOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 214 | 214 | $preventDefault=true; |
| 215 | 215 | $stopPropagation=true; |
| 216 | 216 | $jsCallback=null; |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | $hasLoader=true; |
| 219 | 219 | $immediatly=true; |
| 220 | 220 | extract($parameters); |
| 221 | - return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 221 | + return $this->_add_event($element, $this->_get($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 222 | 222 | } |
| 223 | 223 | |
| 224 | 224 | /** |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | * @param string $responseElement |
| 232 | 232 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true) |
| 233 | 233 | */ |
| 234 | - public function _postOn($event,$element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 234 | + public function _postOn($event, $element, $url, $params="{}", $responseElement="", $parameters=array()) { |
|
| 235 | 235 | $preventDefault=true; |
| 236 | 236 | $stopPropagation=true; |
| 237 | 237 | $jsCallback=null; |
@@ -239,7 +239,7 @@ discard block |
||
| 239 | 239 | $hasLoader=true; |
| 240 | 240 | $immediatly=true; |
| 241 | 241 | extract($parameters); |
| 242 | - return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 242 | + return $this->_add_event($element, $this->_post($url, $params, $responseElement, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 243 | 243 | } |
| 244 | 244 | |
| 245 | 245 | /** |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | * @param string $responseElement |
| 253 | 253 | * @param array $parameters default : array("preventDefault"=>true,"stopPropagation"=>true,"validation"=>false,"jsCallback"=>NULL,"attr"=>"id","hasLoader"=>true,"immediatly"=>true) |
| 254 | 254 | */ |
| 255 | - public function _postFormOn($event,$element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 255 | + public function _postFormOn($event, $element, $url, $form, $responseElement="", $parameters=array()) { |
|
| 256 | 256 | $preventDefault=true; |
| 257 | 257 | $stopPropagation=true; |
| 258 | 258 | $validation=false; |
@@ -261,6 +261,6 @@ discard block |
||
| 261 | 261 | $hasLoader=true; |
| 262 | 262 | $immediatly=true; |
| 263 | 263 | extract($parameters); |
| 264 | - return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr,$hasLoader), $event, $preventDefault, $stopPropagation,$immediatly); |
|
| 264 | + return $this->_add_event($element, $this->_postForm($url, $form, $responseElement, $validation, $jsCallback, $attr, $hasLoader), $event, $preventDefault, $stopPropagation, $immediatly); |
|
| 265 | 265 | } |
| 266 | 266 | } |
| 267 | 267 | \ No newline at end of file |
@@ -41,8 +41,9 @@ discard block |
||
| 41 | 41 | } |
| 42 | 42 | $retour.="$.".$method."(url,".$params.").done(function( data ) {\n"; |
| 43 | 43 | $retour.=$this->_getOnAjaxDone($responseElement, $jsCallback)."});\n"; |
| 44 | - if ($immediatly) |
|
| 45 | - $this->jquery_code_for_compile[]=$retour; |
|
| 44 | + if ($immediatly) { |
|
| 45 | + $this->jquery_code_for_compile[]=$retour; |
|
| 46 | + } |
|
| 46 | 47 | return $retour; |
| 47 | 48 | } |
| 48 | 49 | |
@@ -50,13 +51,15 @@ discard block |
||
| 50 | 51 | $url=$this->_correctAjaxUrl($url); |
| 51 | 52 | $retour="url='".$url."';\n"; |
| 52 | 53 | $slash="/"; |
| 53 | - if(JString::endswith($url, "/")===true) |
|
| 54 | - $slash=""; |
|
| 54 | + if(JString::endswith($url, "/")===true) { |
|
| 55 | + $slash=""; |
|
| 56 | + } |
|
| 55 | 57 | if(JString::isNotNull($attr)){ |
| 56 | - if ($attr=="value") |
|
| 57 | - $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
| 58 | - else if($attr!=null && $attr!=="") |
|
| 59 | - $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
| 58 | + if ($attr=="value") { |
|
| 59 | + $retour.="url=url+'".$slash."'+$(this).val();\n"; |
|
| 60 | + } else if($attr!=null && $attr!=="") { |
|
| 61 | + $retour.="url=url+'".$slash."'+($(this).attr('".$attr."')||'');\n"; |
|
| 62 | + } |
|
| 60 | 63 | } |
| 61 | 64 | return $retour; |
| 62 | 65 | } |
@@ -78,8 +81,9 @@ discard block |
||
| 78 | 81 | } |
| 79 | 82 | |
| 80 | 83 | protected function _correctAjaxUrl($url) { |
| 81 | - if ($url!=="/" && JString::endsWith($url, "/")===true) |
|
| 82 | - $url=substr($url, 0, strlen($url)-1); |
|
| 84 | + if ($url!=="/" && JString::endsWith($url, "/")===true) { |
|
| 85 | + $url=substr($url, 0, strlen($url)-1); |
|
| 86 | + } |
|
| 83 | 87 | if (strncmp($url, 'http://', 7)!=0&&strncmp($url, 'https://', 8)!=0) { |
| 84 | 88 | $url=$this->jsUtils->getUrl($url); |
| 85 | 89 | } |
@@ -103,8 +107,9 @@ discard block |
||
| 103 | 107 | $retour.="\t".$jsCallback."\n". |
| 104 | 108 | "\t$(document).trigger('jsonReady',[data]);\n". |
| 105 | 109 | "});\n"; |
| 106 | - if ($immediatly) |
|
| 107 | - $this->jquery_code_for_compile[]=$retour; |
|
| 110 | + if ($immediatly) { |
|
| 111 | + $this->jquery_code_for_compile[]=$retour; |
|
| 112 | + } |
|
| 108 | 113 | return $retour; |
| 109 | 114 | } |
| 110 | 115 | |
@@ -143,7 +148,7 @@ discard block |
||
| 143 | 148 | if($context===null){ |
| 144 | 149 | $appendTo="\t\tnewElm.appendTo($('".$maskSelector."').parent());\n"; |
| 145 | 150 | $newElm = "$('#'+newId)"; |
| 146 | - }else{ |
|
| 151 | + } else{ |
|
| 147 | 152 | $appendTo="\t\tnewElm.appendTo(".$context.");\n"; |
| 148 | 153 | $newElm = $context.".find('#'+newId)"; |
| 149 | 154 | } |
@@ -153,8 +158,9 @@ discard block |
||
| 153 | 158 | $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"; |
| 154 | 159 | $retour.="\t$(document).trigger('jsonReady',[data]);\n"; |
| 155 | 160 | $retour.="\t".$jsCallback."\n"."});\n"; |
| 156 | - if ($immediatly) |
|
| 157 | - $this->jquery_code_for_compile[]=$retour; |
|
| 161 | + if ($immediatly) { |
|
| 162 | + $this->jquery_code_for_compile[]=$retour; |
|
| 163 | + } |
|
| 158 | 164 | return $retour; |
| 159 | 165 | } |
| 160 | 166 | /** |
@@ -195,8 +201,9 @@ discard block |
||
| 195 | 201 | }});\n"; |
| 196 | 202 | $retour.="$('#".$form."').submit();\n"; |
| 197 | 203 | } |
| 198 | - if ($immediatly) |
|
| 199 | - $this->jquery_code_for_compile[]=$retour; |
|
| 204 | + if ($immediatly) { |
|
| 205 | + $this->jquery_code_for_compile[]=$retour; |
|
| 206 | + } |
|
| 200 | 207 | return $retour; |
| 201 | 208 | } |
| 202 | 209 | |