19 protected $mClass =
"menu";
26 "action" =>
"nothing",
41 $this->_template = include dirname(__FILE__) .
'/../templates/tplDropdown.php';
43 $this->_multiple =
false;
48 } elseif (
$value !==
null) {
50 $text->setClass(
"text");
60 $this->tagName =
"div";
61 $this->_associative = $associative;
73 public function addItem($item,
$value = NULL, $image = NULL, $description = NULL) {
75 $this->items[] = $itemO;
79 public function addIcon($icon, $before =
true, $labeled =
false) {
81 $this->
addIconP($icon, $before, $labeled);
82 $elm = $this->
getElementById(
"text-" . $this->identifier, $this->content);
84 $elm->setWrapAfter(
"");
90 $count = $this->
count();
91 for ($i = 0; $i < \sizeof($icons) && $i < $count; $i ++) {
92 $this->
getItem($i)->addIcon($icons[$i]);
105 $start = array_slice($this->items, 0, $position);
106 $end = array_slice($this->items, $position);
108 $this->items = array_merge($start, $end);
113 if (\
sizeof($this->content) > 1) {
114 unset($this->content[
"arrow"]);
115 $this->content = \array_values($this->content);
121 if (\is_array($item)) {
122 $description = JArray::getValue($item,
"description", 3);
123 $value = JArray::getValue($item,
"value", 1);
124 $image = JArray::getValue($item,
"image", 2);
125 $item = JArray::getValue($item,
"item", 0);
128 $itemO =
new HtmlDropdownItem(
"dd-item-" . $this->identifier .
"-" . \
sizeof($this->items), $item,
$value, $image, $description);
140 $this->
addItem($function($object));
147 $this->input =
new HtmlInput($name,
"hidden");
148 $this->input->setIdentifier(
"input-" . $this->identifier);
160 return $this->
addItem(HtmlDropdownItem::searchInput($placeHolder, $icon));
169 return $this->
addItem(HtmlDropdownItem::divider());
180 return $this->
addItem(HtmlDropdownItem::header($caption, $icon));
191 return $this->
addItem(HtmlDropdownItem::circular($caption, $color));
201 return $this->
addItem(HtmlDropdownItem::avatar($caption, $image));
205 if (\is_array(
$items) && $this->_associative) {
206 foreach (
$items as $k => $v) {
207 $this->
addItem($v)->setData($k);
210 foreach (
$items as $item) {
225 if (\is_array($values) ===
false) {
226 $values = \array_fill(0, $this->
count(), $values);
228 foreach ($values as
$value) {
229 $c = $this->items[$i ++];
231 $c->setProperty($property,
$value);
239 public function each($callBack) {
240 foreach ($this->items as $index =>
$value) {
241 $callBack($index,
$value);
247 return $this->items[$index];
255 return \sizeof($this->items);
263 if ($dropdown ===
false) {
264 $this->_template = include dirname(__FILE__) .
'/../templates/tplDropdownMenu.php';
267 $dropdown =
"dropdown";
268 $this->mClass =
"menu";
302 public function asSelect($name = NULL, $multiple =
false, $selection =
true) {
303 $this->_multiple = $multiple;
318 public function asSearch($name = NULL, $multiple =
false, $selection =
true) {
319 $this->
asSelect($name, $multiple, $selection);
323 public function setSelect($name = NULL, $multiple =
false) {
324 $this->_template =
'<%tagName% id="%identifier%" %properties%>%items%</%tagName%>';
333 $this->tagName =
"select";
335 $this->content =
null;
336 foreach ($this->items as $item) {
343 $this->
setClass(
"ui dropdown link item");
344 if (isset($pointing)) {
366 if (isset($this->input) && isset(
$value)) {
367 $this->input->setProperty(
"value",
$value);
371 $textElement = $this->
getElementById(
"text-" . $this->identifier, $this->content);
372 if (isset($textElement) && ($textElement instanceof
HtmlDoubleElement) && ! $this->_multiple)
373 $textElement->setContent(
$value);
383 if (isset($this->_bsComponent) ===
false) {
384 $this->_bsComponent = $js->
semantic()->dropdown(
"#" . $this->identifier, $this->_params);
385 $this->_bsComponent->setItemSelector(
".item");
399 $this->_params[
"action"] = $action;
404 $this->_params[
"on"] = $on;
409 $this->_params[
"showOnFocus"] =
$value;
414 $this->_params[
"allowAdditions"] =
$value;
419 $this->_params[
"fullTextSearch"] =
$value;
425 return parent::compile($js, $view);
433 $this->content[
"arrow"] =
new HtmlIcon($this->identifier .
"-icon", $icon);
439 $js =
"var first=$('#{$this->identifier} .item').first();if(first!=undefined){var newItem =first.clone();first.parent().append(newItem);newItem.html({$caption});newItem.attr('data-value',{$value}).removeClass('active filtered');}";
444 $this->_params[
"clearable"] =
$value;
453 $this->_params[
"onAdd"] = $jsCode;
462 $this->_params[
"onRemove"] = $jsCode;
semantic(Semantic $semantic=NULL)
getter or setter of the Semantic-UI variable
getElementById($identifier, $elements)
addEventsOnRun(JsUtils $js=NULL)
removePropertyValue($name, $value)
propertyContains($propertyName, $value)
Base class for Semantic double elements.
addToPropertyCtrl($name, $value, $typeCtrl)
setProperty($name, $value)
addToProperty($name, $value, $separator=" ")
addSearchInputItem($placeHolder=NULL, $icon=NULL)
Adds a search input item.
__construct($identifier, $value="", $items=array(), $associative=true)
setAllowAdditions($value)
setPointing($value=Direction::NONE)
beforeAddItem($item, $value=NULL, $image=NULL, $description=NULL)
setSelect($name=NULL, $multiple=false)
run(JsUtils $js)
{{SimpleExtComponent\Ajax\common\html\BaseHtmlrun()\Ajax\common\html\BaseHtmlrun()}HtmlDoubleElement:...
addDividerItem()
Adds a divider item.
addIcon($icon, $before=true, $labeled=false)
Adds an icon before or after.
addMiniAvatarImageItem($caption, $image)
setFullTextSearch($value)
addHeaderItem($caption=NULL, $icon=NULL)
Adds an header item.
asSearch($name=NULL, $multiple=false, $selection=true)
setOnAdd($jsCode)
Is called after a dropdown selection is added using a multiple select dropdown, only receives the add...
compile(JsUtils $js=NULL, &$view=NULL)
{{}BaseHtml::compile()}
setPropertyValues($property, $values)
Sets the values of a property for each item in the collection.
setOnRemove($jsCode)
Is called after a dropdown selection is removed using a multiple select dropdown, only receives the r...
addItem($item, $value=NULL, $image=NULL, $description=NULL)
asButton($floating=false)
asSubmenu($pointing=NULL)
setIcon($icon="dropdown")
asSelect($name=NULL, $multiple=false, $selection=true)
jsAddItem($caption, $value=null)
insertItem($item, $position=0)
Insert an item at a position.
addCircularLabelItem($caption, $color)
Adds an item with a circular label.
fromDatabaseObject($object, $function)