Skip to content

Commit 50fc655

Browse files
committed
popup compilation
1 parent 172c54c commit 50fc655

File tree

14 files changed

+160
-68
lines changed

14 files changed

+160
-68
lines changed

Ajax/common/html/HtmlCollection.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use Ajax\common\html\HtmlDoubleElement;
66
use Ajax\service\JArray;
7-
use Ajax\JsUtils;
87

98
/**
109
* Base class for Html collections

Ajax/semantic/components/Popup.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ public function setOn($value="click") {
2727
* @return $this
2828
*/
2929
public function setOnShow($jsCode) {
30+
$jsCode=str_ireplace("\"","%quote%", $jsCode);
3031
return $this->setParam("onShow", "%function(){".$jsCode."}%");
3132
}
3233

Ajax/semantic/components/Rating.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ public function __construct(JsUtils $js) {
1111
parent::__construct($js);
1212
$this->uiName="rating";
1313
}
14+
1415
//TODO other events implementation
1516
}

Ajax/semantic/html/base/HtmlSemDoubleElement.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Ajax\semantic\html\elements\HtmlLabel;
1111
use Ajax\semantic\html\base\constants\Direction;
1212
use Ajax\JsUtils;
13+
use Phalcon\Mvc\View;
1314

1415
/**
1516
* Base class for Semantic double elements
@@ -92,8 +93,8 @@ public function jsShowDimmer($show=true) {
9293
}
9394

9495
public function compile(JsUtils $js=NULL, &$view=NULL) {
95-
if (isset($this->_popup))
96-
$this->_popup->compile();
96+
if (isset($this->_popup))
97+
$this->_popup->compile($js);
9798
return parent::compile($js, $view);
9899
}
99100

Ajax/semantic/html/base/traits/IconTrait.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function addIcon($icon,$direction=Direction::LEFT){
2424
$iconO=new HtmlIcon("icon-".$this->identifier, $icon);
2525
}
2626
$this->addToPropertyCtrl("class", $direction." icon", Direction::getConstantValues("icon"));
27-
$this->addContent($iconO,false);
27+
$this->addContent($iconO,$direction===Direction::LEFT);
2828
$this->_hasIcon=true;
2929
}else{
3030
$iconO=$this->getIcon();
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
namespace Ajax\semantic\html\base\traits;
3+
4+
use Ajax\service\JArray;
5+
use Ajax\service\JString;
6+
use Ajax\semantic\html\elements\HtmlInput;
7+
use Ajax\semantic\html\base\constants\Direction;
8+
9+
trait MenuItemTrait {
10+
11+
public function setContent($content){
12+
if($content==="-"){
13+
$this->asDivider();
14+
}elseif($content==="-search-"){
15+
$values=\explode(",",$content,-1);
16+
$this->asSearchInput(JArray::getDefaultValue($values, 0, "Search..."),JArray::getDefaultValue($values, 1, "search"));
17+
}elseif(JString::startswith($content, "-")){
18+
$content=\ltrim($content,"-");
19+
$this->asHeader($content);
20+
}else
21+
parent::setContent($content);
22+
return $this;
23+
}
24+
25+
/**
26+
* @param string $placeholder
27+
* @param string $icon
28+
* @return \Ajax\semantic\html\content\HtmlDropdownItem|\Ajax\semantic\html\content\HtmlMenuItem
29+
*/
30+
public function asSearchInput($placeholder=NULL,$icon=NULL){
31+
$this->setClass("ui icon search input");
32+
$input=new HtmlInput("search-".$this->identifier);
33+
if(isset($placeholder))
34+
$input->setProperty("placeholder", $placeholder);
35+
$this->content=$input;
36+
if(isset($icon))
37+
$this->addIcon($icon);
38+
return $this;
39+
}
40+
41+
/**
42+
* @return \Ajax\semantic\html\content\HtmlDropdownItem|\Ajax\semantic\html\content\HtmlMenuItem
43+
*/
44+
public function asDivider(){
45+
$this->content=NULL;
46+
$this->tagName="div";
47+
$this->setClass("divider");
48+
return $this;
49+
}
50+
51+
/**
52+
* @param string $caption
53+
* @param string $icon
54+
* @return \Ajax\semantic\html\content\HtmlDropdownItem|\Ajax\semantic\html\content\HtmlMenuItem
55+
*/
56+
public function asHeader($caption=NULL,$icon=NULL){
57+
$this->setClass("header");
58+
$this->tagName="div";
59+
$this->content=$caption;
60+
if(isset($icon))
61+
$this->addIcon($icon,Direction::LEFT);
62+
return $this;
63+
}
64+
}

Ajax/semantic/html/collections/HtmlGrid.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,9 +137,9 @@ protected function hasOnlyCols($count) {
137137
* @return \Ajax\semantic\html\collections\HtmlGrid
138138
*/
139139
public function setColsCount($numCols, $toCreate=true, $width=NULL) {
140-
/*if (isset($width)==false) {
140+
if (isset($width)==false) {
141141
$this->setWide($numCols);
142-
}*/
142+
}
143143
if ($toCreate == true) {
144144
$count=$this->count();
145145
if ($count == 0 || $this->hasOnlyCols($count)) {

Ajax/semantic/html/collections/menus/HtmlMenu.php

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use Ajax\semantic\html\elements\HtmlInput;
1616
use Ajax\semantic\html\elements\HtmlButton;
1717
use Ajax\semantic\html\base\traits\AttachedTrait;
18+
use Ajax\semantic\html\content\HtmlMenuItem;
1819

1920
/**
2021
* Semantic Menu component
@@ -50,15 +51,14 @@ public function setActiveItem($index) {
5051

5152
private function getItemToInsert($item) {
5253
if ($item instanceof HtmlInput || $item instanceof HtmlImg || $item instanceof HtmlIcon || $item instanceof HtmlButton || ($item instanceof HtmlDropdown && $this->propertyContains("class", "vertical")===false)) {
53-
$itemO=new HtmlSemDoubleElement("item-" . $this->identifier, "div", "");
54-
$itemO->setContent($item);
54+
$itemO=new HtmlMenuItem("item-" . $this->identifier, $item);
5555
$item=$itemO;
5656
}
5757
return $item;
5858
}
5959

6060
private function afterInsert($item) {
61-
if (!$item instanceof HtmlMenu)
61+
if (!$item instanceof HtmlMenu && $item->propertyContains("class", "header")===false)
6262
$item->addToPropertyCtrl("class", "item", array ("item" ));
6363
else {
6464
$this->setSecondary();
@@ -124,7 +124,8 @@ public function addDropdownAsItem($value, $items=NULL) {
124124
if (\is_string($value)) {
125125
$dd=new HtmlDropdown("dropdown-" . $this->identifier . "-" . $this->count(), $value, $items);
126126
}
127-
return $this->addItem($dd);
127+
$this->addItem($dd);
128+
return $dd;
128129
}
129130

130131
/**
@@ -134,16 +135,21 @@ public function addDropdownAsItem($value, $items=NULL) {
134135
* @see \Ajax\common\html\html5\HtmlCollection::createItem()
135136
*/
136137
protected function createItem($value) {
137-
$itemO=new HtmlLink($this->identifier."item" . \sizeof($this->content), "", $value);
138-
return $itemO->setClass("item");
138+
$itemO=new HtmlMenuItem($this->identifier."item" . \sizeof($this->content),"");
139+
$itemO->setTagName("a");
140+
$itemO->setContent($value);
141+
return $itemO;
139142
}
140143

141144
public function setInverted() {
142145
return $this->addToProperty("class", "inverted");
143146
}
144147

145-
public function setSecondary() {
146-
return $this->addToProperty("class", "secondary");
148+
public function setSecondary($value=true) {
149+
if($value)
150+
$this->addToProperty("class", "secondary");
151+
else
152+
$this->removePropertyValue("class", "secondary");
147153
}
148154

149155
public function setVertical() {

Ajax/semantic/html/content/HtmlDropdownItem.php

Lines changed: 12 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
use Ajax\semantic\html\base\HtmlSemDoubleElement;
66
use Ajax\common\html\HtmlDoubleElement;
77
use Ajax\common\html\html5\HtmlImg;
8-
use Ajax\common\html\html5\HtmlInput;
9-
use Ajax\service\JArray;
108
use Ajax\semantic\html\base\traits\IconTrait;
119
use Ajax\semantic\html\elements\HtmlLabel;
1210
use Ajax\semantic\html\elements\HtmlIcon;
11+
use Ajax\semantic\html\collections\menus\HtmlMenu;
12+
use Ajax\semantic\html\base\traits\MenuItemTrait;
1313

1414
class HtmlDropdownItem extends HtmlSemDoubleElement {
15-
use IconTrait;
15+
use IconTrait,MenuItemTrait;
1616
public function __construct($identifier, $content="",$value=NULL,$image=NULL,$description=NULL) {
1717
parent::__construct($identifier, "a");
1818
$this->setClass("item");
@@ -34,6 +34,7 @@ public function setDescription($description){
3434

3535
public function setData($value){
3636
$this->setProperty("data-value", $value);
37+
return $this;
3738
}
3839

3940
public function asOption(){
@@ -78,48 +79,16 @@ public function asCircularLabel($caption,$color){
7879
return $this;
7980
}
8081

81-
public function asSearchInput($placeholder=NULL,$icon=NULL){
82-
$this->setClass("ui icon search input");
83-
$input=new HtmlInput("search-".$this->identifier);
84-
if(isset($placeholder))
85-
$input->setProperty("placeholder", $placeholder);
86-
$this->content=$input;
87-
if(isset($icon))
88-
$this->addIcon($icon);
89-
return $this;
90-
}
9182

92-
public function setContent($content){
93-
if($content==="-"){
94-
$this->asDivider();
95-
}elseif($content==="-search-"){
96-
$values=\explode(",",$content,-1);
97-
$this->asSearchInput(JArray::getDefaultValue($values, 0, "Search..."),JArray::getDefaultValue($values, 1, "search"));
98-
}else
99-
parent::setContent($content);
100-
return $this;
101-
}
10283

103-
/**
104-
* @return \Ajax\semantic\html\content\HtmlDropdownItem
105-
*/
106-
public function asDivider(){
107-
$this->content=NULL;
108-
$this->setClass("divider");
109-
return $this;
110-
}
111-
112-
/**
113-
* @param string $caption
114-
* @param string $icon
115-
* @return \Ajax\semantic\html\content\HtmlDropdownItem
116-
*/
117-
public function asHeader($caption=NULL,$icon=NULL){
118-
$this->setClass("header");
119-
$this->content=$caption;
120-
if(isset($icon))
121-
$this->addIcon($icon,true);
122-
return $this;
84+
public function addMenuItem($items) {
85+
$menu=new HtmlMenu("menu-" . $this->identifier, $items);
86+
$content=$this->content;
87+
$this->setTagName("div");
88+
$this->setProperty("class", "item");
89+
$icon=new HtmlIcon("", "dropdown");
90+
$this->content=[$icon,new HtmlSemDoubleElement("","span","text",$content),$menu];
91+
return $menu;
12392
}
12493

12594
/**

Ajax/semantic/html/content/HtmlMenuItem.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,13 @@
33
namespace Ajax\semantic\html\content;
44

55
use Ajax\service\JArray;
6+
use Ajax\semantic\html\base\traits\MenuItemTrait;
7+
use Ajax\semantic\html\base\HtmlSemDoubleElement;
68

7-
class HtmlMenuItem extends HtmlAbsractItem {
8-
9+
class HtmlMenuItem extends HtmlSemDoubleElement {
10+
use MenuItemTrait;
911
public function __construct($identifier, $content) {
10-
parent::__construct($identifier,"item",$content);
12+
parent::__construct($identifier,"div","item",$content);
1113
}
1214

1315
protected function initContent($content){

0 commit comments

Comments
 (0)