27 "action" =>
"nothing",
42 $this->_template = include dirname(__FILE__) .
'/../templates/tplDropdown.php';
44 $this->_multiple =
false;
49 } elseif (
$value !== null) {
50 $text =
new HtmlSemDoubleElement(
"text-" . $this->identifier,
"div");
51 $text->setClass(
"text");
61 $this->tagName =
"div";
62 $this->_associative = $associative;
74 public function addItem($item,
$value = NULL, $image = NULL, $description = NULL) {
76 $this->items[] = $itemO;
80 public function addIcon($icon, $before =
true, $labeled =
false) {
82 $this->addIconP($icon, $before, $labeled);
83 $elm = $this->
getElementById(
"text-" . $this->identifier, $this->content);
85 $elm->setWrapAfter(
"");
91 $count = $this->
count();
92 for ($i = 0; $i < \sizeof($icons) && $i < $count; $i ++) {
93 $this->
getItem($i)->addIcon($icons[$i]);
106 $start = array_slice($this->items, 0, $position);
107 $end = array_slice($this->items, $position);
109 $this->items = array_merge($start, $end);
114 if (\
sizeof($this->content) > 1) {
115 unset($this->content[
"arrow"]);
116 $this->content = \array_values($this->content);
122 if (\is_array($item)) {
129 $itemO =
new HtmlDropdownItem(
"dd-item-" . $this->identifier .
"-" . \
sizeof($this->items), $item,
$value, $image, $description);
130 } elseif ($itemO instanceof HtmlDropdownItem) {
141 $this->
addItem($function($object));
148 $this->input =
new HtmlInput($name,
"hidden");
149 $this->input->setIdentifier(
"input-" . $this->identifier);
206 if (\is_array(
$items) && $this->_associative) {
207 foreach (
$items as $k => $v) {
208 $this->
addItem($v)->setData($k);
211 foreach (
$items as $item) {
226 if (\is_array($values) ===
false) {
227 $values = \array_fill(0, $this->
count(), $values);
229 foreach ($values as
$value) {
230 $c = $this->items[$i ++];
232 $c->setProperty($property, $value);
240 public function each($callBack) {
241 foreach ($this->items as $index =>
$value) {
242 $callBack($index,
$value);
248 return $this->items[$index];
256 return \sizeof($this->items);
264 if ($dropdown ===
false) {
265 $this->_template = include dirname(__FILE__) .
'/../templates/tplDropdownMenu.php';
268 $dropdown =
"dropdown";
269 $this->mClass =
"menu";
303 public function asSelect($name = NULL, $multiple =
false, $selection =
true) {
304 $this->_multiple = $multiple;
319 public function asSearch($name = NULL, $multiple =
false, $selection =
true) {
320 $this->
asSelect($name, $multiple, $selection);
324 public function setSelect($name = NULL, $multiple =
false) {
325 $this->_template =
'<%tagName% id="%identifier%" %properties%>%items%</%tagName%>';
334 $this->tagName =
"select";
336 $this->content = null;
337 foreach ($this->items as $item) {
344 $this->
setClass(
"ui dropdown link item");
345 if (isset($pointing)) {
367 if (isset($this->input) && isset(
$value)) {
368 $this->input->setProperty(
"value",
$value);
372 $textElement = $this->
getElementById(
"text-" . $this->identifier, $this->content);
373 if (isset($textElement) && ($textElement instanceof
HtmlDoubleElement) && ! $this->_multiple)
374 $textElement->setContent(
$value);
384 if (isset($this->_bsComponent) ===
false) {
385 $this->_bsComponent = $js->
semantic()->dropdown(
"#" . $this->identifier, $this->_params);
386 $this->_bsComponent->setItemSelector(
".item");
400 $this->_params[
"action"] = $action;
405 $this->_params[
"on"] = $on;
410 $this->_params[
"showOnFocus"] =
$value;
415 $this->_params[
"allowAdditions"] =
$value;
420 $this->_params[
"fullTextSearch"] =
$value;
426 return parent::compile($js, $view);
434 $this->content[
"arrow"] =
new HtmlIcon($this->identifier .
"-icon", $icon);
440 $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');}";
445 $this->_params[
"clearable"] =
$value;
454 $this->_params[
"onAdd"] = $jsCode;
463 $this->_params[
"onRemove"] = $jsCode;
static getValue($array, $key, $pos)
setAllowAdditions($value)
setIcon($icon="dropdown")
addToProperty($name, $value, $separator=" ")
setPropertyValues($property, $values)
Sets the values of a property for each item in the collection.
setPointing($value=Direction::NONE)
static searchInput($placeholder=NULL, $icon=NULL)
addIcon($icon, $before=true, $labeled=false)
propertyContains($propertyName, $value)
jsAddItem($caption, $value=null)
insertItem($item, $position=0)
Insert an item at a position.
asSelect($name=NULL, $multiple=false, $selection=true)
__construct($identifier, $value="", $items=array(), $associative=true)
addEventsOnRun(JsUtils $js=NULL)
setProperty($name, $value)
beforeAddItem($item, $value=NULL, $image=NULL, $description=NULL)
removePropertyValue($name, $value)
asSearch($name=NULL, $multiple=false, $selection=true)
asSubmenu($pointing=NULL)
addHeaderItem($caption=NULL, $icon=NULL)
Adds an header item.
static getConstantValues($postFix="", $prefixBefore=false)
static header($caption=NULL, $icon=NULL)
addSearchInputItem($placeHolder=NULL, $icon=NULL)
Adds a search input item.
semantic(Semantic $semantic=NULL)
getter or setter of the Semantic-UI variable
setSelect($name=NULL, $multiple=false)
setOnAdd($jsCode)
Is called after a dropdown selection is added using a multiple select dropdown, only receives the add...
Base class for Semantic double elements.
asButton($floating=false)
addDividerItem()
Adds a divider item.
addMiniAvatarImageItem($caption, $image)
addItem($item, $value=NULL, $image=NULL, $description=NULL)
compile(JsUtils $js=NULL, &$view=NULL)
fromDatabaseObject($object, $function)
static circular($caption, $color)
addToPropertyCtrl($name, $value, $typeCtrl)
getElementById($identifier, $elements)
addCircularLabelItem($caption, $color)
Adds an item with a circular label.
static avatar($caption, $image)
setFullTextSearch($value)
setOnRemove($jsCode)
Is called after a dropdown selection is removed using a multiple select dropdown, only receives the r...