@@ -34,8 +34,8 @@ public function __construct($identifier, $value="", $items=array()) {
34
34
$ this ->addItems ($ items );
35
35
}
36
36
37
- public function addItem ($ item ,$ value =NULL ,$ image =NULL ){
38
- $ itemO =$ this ->beforeAddItem ($ item ,$ value ,$ image );
37
+ public function addItem ($ item ,$ value =NULL ,$ image =NULL , $ description = NULL ){
38
+ $ itemO =$ this ->beforeAddItem ($ item ,$ value ,$ image, $ description );
39
39
$ this ->items []=$ itemO ;
40
40
return $ itemO ;
41
41
}
@@ -44,6 +44,7 @@ public function addIcon($icon,$before=true,$labeled=false){
44
44
$ this ->addIconP ($ icon ,$ before ,$ labeled );
45
45
return $ this ->getElementById ("text- " .$ this ->identifier , $ this ->content )->setWrapAfter ("" );
46
46
}
47
+
47
48
/**
48
49
* Insert an item at a position
49
50
* @param mixed $item
@@ -59,15 +60,16 @@ public function insertItem($item,$position=0){
59
60
return $ itemO ;
60
61
}
61
62
62
- protected function beforeAddItem ($ item ,$ value =NULL ,$ image =NULL ){
63
+ protected function beforeAddItem ($ item ,$ value =NULL ,$ image =NULL , $ description = NULL ){
63
64
$ itemO =$ item ;
64
65
if (\is_array ($ item )){
66
+ $ description =JArray::getValue ($ item , "description " , 3 );
65
67
$ value =JArray::getValue ($ item , "value " , 1 );
66
68
$ image =JArray::getValue ($ item , "image " , 2 );
67
69
$ item =JArray::getValue ($ item , "item " , 0 );
68
70
}
69
71
if (!$ item instanceof HtmlDropdownItem){
70
- $ itemO =new HtmlDropdownItem ("dd-item- " .$ this ->identifier ."- " .\sizeof ($ this ->items ),$ item ,$ value ,$ image );
72
+ $ itemO =new HtmlDropdownItem ("dd-item- " .$ this ->identifier ."- " .\sizeof ($ this ->items ),$ item ,$ value ,$ image, $ description );
71
73
}elseif ($ itemO instanceof HtmlDropdownItem){
72
74
$ this ->addToProperty ("class " , "vertical " );
73
75
}
@@ -88,6 +90,53 @@ public function addInput($name){
88
90
$ this ->input =new HtmlInput ($ name ,"hidden " );
89
91
}
90
92
93
+ /**
94
+ * Adds a search input item
95
+ * @param string $placeHolder
96
+ * @param string $icon
97
+ * @return \Ajax\semantic\html\content\HtmlDropdownItem
98
+ */
99
+ public function addSearchInputItem ($ placeHolder =NULL ,$ icon =NULL ){
100
+ return $ this ->addItem (HtmlDropdownItem::searchInput ($ placeHolder ,$ icon ));
101
+ }
102
+
103
+ /**
104
+ * Adds a divider item
105
+ * @return \Ajax\semantic\html\content\HtmlDropdownItem
106
+ */
107
+ public function addDividerItem (){
108
+ return $ this ->addItem (HtmlDropdownItem::divider ());
109
+ }
110
+
111
+ /**
112
+ * Adds an header item
113
+ * @param string $caption
114
+ * @param string $icon
115
+ * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown
116
+ */
117
+ public function addHeaderItem ($ caption =NULL ,$ icon =NULL ){
118
+ return $ this ->addItem (HtmlDropdownItem::header ($ caption ,$ icon ));
119
+ }
120
+
121
+ /**
122
+ * Adds an item with a circular label
123
+ * @param string $caption
124
+ * @param string $color
125
+ * @return \Ajax\semantic\html\content\HtmlDropdownItem|unknown
126
+ */
127
+ public function addCircularLabelItem ($ caption ,$ color ){
128
+ return $ this ->addItem (HtmlDropdownItem::circular ($ caption , $ color ));
129
+ }
130
+
131
+ /**
132
+ * @param string $caption
133
+ * @param string $image
134
+ * @return \Ajax\semantic\html\content\HtmlDropdownItem
135
+ */
136
+ public function addMiniAvatarImageItem ($ caption ,$ image ){
137
+ return $ this ->addItem (HtmlDropdownItem::avatar ($ caption , $ image ));
138
+ }
139
+
91
140
public function addItems ($ items ){
92
141
if (JArray::isAssociative ($ items )){
93
142
foreach ($ items as $ k =>$ v ){
@@ -100,6 +149,9 @@ public function addItems($items){
100
149
}
101
150
}
102
151
152
+ /**
153
+ * @return int
154
+ */
103
155
public function count (){
104
156
return \sizeof ($ this ->items );
105
157
}
@@ -128,6 +180,7 @@ public function setSimple(){
128
180
public function asButton ($ floating =false ){
129
181
if ($ floating )
130
182
$ this ->addToProperty ("class " , "floating " );
183
+ $ this ->removePropertyValue ("class " , "selection " );
131
184
return $ this ->addToProperty ("class " , "button " );
132
185
}
133
186
@@ -136,12 +189,14 @@ public function asSelect($name=NULL,$multiple=false,$selection=true){
136
189
$ this ->addInput ($ name );
137
190
if ($ multiple )
138
191
$ this ->addToProperty ("class " , "multiple " );
139
- if ($ selection )
140
- $ this ->addToPropertyCtrl ("class " , "selection " ,array ("selection " ));
192
+ if ($ selection ){
193
+ if ($ this ->propertyContains ("class " , "button " )===false )
194
+ $ this ->addToPropertyCtrl ("class " , "selection " ,array ("selection " ));
195
+ }
141
196
return $ this ;
142
197
}
143
198
144
- public function asSearch ($ name =NULL ,$ multiple =false ,$ selection =false ){
199
+ public function asSearch ($ name =NULL ,$ multiple =false ,$ selection =true ){
145
200
$ this ->asSelect ($ name ,$ multiple ,$ selection );
146
201
return $ this ->addToProperty ("class " , "search " );
147
202
}
0 commit comments