@@ -34,8 +34,8 @@ public function __construct($identifier, $value="", $items=array()) {
3434 $ this ->addItems ($ items );
3535 }
3636
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 );
3939 $ this ->items []=$ itemO ;
4040 return $ itemO ;
4141 }
@@ -44,6 +44,7 @@ public function addIcon($icon,$before=true,$labeled=false){
4444 $ this ->addIconP ($ icon ,$ before ,$ labeled );
4545 return $ this ->getElementById ("text- " .$ this ->identifier , $ this ->content )->setWrapAfter ("" );
4646 }
47+
4748 /**
4849 * Insert an item at a position
4950 * @param mixed $item
@@ -59,15 +60,16 @@ public function insertItem($item,$position=0){
5960 return $ itemO ;
6061 }
6162
62- protected function beforeAddItem ($ item ,$ value =NULL ,$ image =NULL ){
63+ protected function beforeAddItem ($ item ,$ value =NULL ,$ image =NULL , $ description = NULL ){
6364 $ itemO =$ item ;
6465 if (\is_array ($ item )){
66+ $ description =JArray::getValue ($ item , "description " , 3 );
6567 $ value =JArray::getValue ($ item , "value " , 1 );
6668 $ image =JArray::getValue ($ item , "image " , 2 );
6769 $ item =JArray::getValue ($ item , "item " , 0 );
6870 }
6971 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 );
7173 }elseif ($ itemO instanceof HtmlDropdownItem){
7274 $ this ->addToProperty ("class " , "vertical " );
7375 }
@@ -88,6 +90,53 @@ public function addInput($name){
8890 $ this ->input =new HtmlInput ($ name ,"hidden " );
8991 }
9092
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+
91140 public function addItems ($ items ){
92141 if (JArray::isAssociative ($ items )){
93142 foreach ($ items as $ k =>$ v ){
@@ -100,6 +149,9 @@ public function addItems($items){
100149 }
101150 }
102151
152+ /**
153+ * @return int
154+ */
103155 public function count (){
104156 return \sizeof ($ this ->items );
105157 }
@@ -128,6 +180,7 @@ public function setSimple(){
128180 public function asButton ($ floating =false ){
129181 if ($ floating )
130182 $ this ->addToProperty ("class " , "floating " );
183+ $ this ->removePropertyValue ("class " , "selection " );
131184 return $ this ->addToProperty ("class " , "button " );
132185 }
133186
@@ -136,12 +189,14 @@ public function asSelect($name=NULL,$multiple=false,$selection=true){
136189 $ this ->addInput ($ name );
137190 if ($ multiple )
138191 $ 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+ }
141196 return $ this ;
142197 }
143198
144- public function asSearch ($ name =NULL ,$ multiple =false ,$ selection =false ){
199+ public function asSearch ($ name =NULL ,$ multiple =false ,$ selection =true ){
145200 $ this ->asSelect ($ name ,$ multiple ,$ selection );
146201 return $ this ->addToProperty ("class " , "search " );
147202 }
0 commit comments