55use Ajax \semantic \html \base \HtmlSemDoubleElement ;
66use Ajax \common \html \HtmlDoubleElement ;
77use Ajax \common \html \html5 \HtmlImg ;
8- use Ajax \common \html \html5 \HtmlInput ;
9- use Ajax \service \JArray ;
108use Ajax \semantic \html \base \traits \IconTrait ;
119use Ajax \semantic \html \elements \HtmlLabel ;
1210use Ajax \semantic \html \elements \HtmlIcon ;
11+ use Ajax \semantic \html \collections \menus \HtmlMenu ;
12+ use Ajax \semantic \html \base \traits \MenuItemTrait ;
1313
1414class 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 /**
0 commit comments