///////////////////////////////////////////////////////////////////////////////////
// COMBO-BOX
///////////////////////////////////////////////////////////////////////////////////
// Adds a drop-down list to win.
489805
func (win *Window) Combo(lbl label.Label, height int, updateFn UpdateFn) *Window {
	s, header, _ := win.widget()
	if !s {
		return nil
	}

	in := win.inputMaybe(s)
	state := win.widgets.PrevState(header)
	is_clicked := buttonBehaviorDo(&state, header, in, false)

	switch lbl.Kind {
	case label.ColorLabel:
		win.widgets.Add(state, header)
		drawComboColor(win, state, header, is_clicked, lbl.Color)
	case label.ImageLabel:
		win.widgets.Add(state, header)
		drawComboImage(win, state, header, is_clicked, lbl.Img)
	case label.ImageTextLabel:
		win.widgets.Add(state, header)
		drawComboImageText(win, state, header, is_clicked, lbl.Text, lbl.Img)
	case label.SymbolLabel:
		win.widgets.Add(state, header)
		drawComboSymbol(win, state, header, is_clicked, lbl.Symbol)
	case label.SymbolTextLabel:
		win.widgets.Add(state, header)
		drawComboSymbolText(win, state, header, is_clicked, lbl.Symbol, lbl.Text)
	case label.TextLabel:
		win.widgets.Add(state, header)
		drawComboText(win, state, header, is_clicked, lbl.Text)
	}

	if popup := win.ctx.Windows[len(win.ctx.Windows)-1]; updateFn == nil && popup.header == header {
		popup.specialPanelBegin()
		return popup
	}

	if !is_clicked {
		return nil
	}

	height = win.ctx.scale(height)

	var body rect.Rect
	body.X = header.X
	body.W = header.W
	body.Y = header.Y + header.H - 1
	body.H = height

	return win.ctx.nonblockOpen(windowCombo, body, header, updateFn)
}
659649
private void setUpComboBoxPosition() {

        m_fieldPosition.removeAllItems();

        List<CmsSite> sites = new ArrayList<CmsSite>();
        List<PositionComboBoxElementBean> beanList = new ArrayList<PositionComboBoxElementBean>();
        for (CmsSite site : OpenCms.getSiteManager().getAvailableSites(m_clonedCms, true)) {
            if (site.getSiteMatcher() != null) {
                sites.add(site);
            }
        }

        float maxValue = 0;
        float nextPos = 0;

        // calculate value for the first navigation position
        float firstValue = 1;
        if (sites.size() > 0) {
            try {
                maxValue = sites.get(0).getPosition();
            } catch (Exception e) {
                // should usually never happen
            }
        }

        if (maxValue != 0) {
            firstValue = maxValue / 2;
        }

        // add the first entry: before first element
        beanList.add(
            new PositionComboBoxElementBean(
                CmsVaadinUtils.getMessageText(Messages.GUI_SITE_CHNAV_POS_FIRST_0),
                firstValue));

        // show all present navigation elements in box
        for (int i = 0; i < sites.size(); i++) {

            float navPos = sites.get(i).getPosition();
            String siteRoot = sites.get(i).getSiteRoot();
            // get position of next nav element
            nextPos = navPos + 2;
            if ((i + 1) < sites.size()) {
                nextPos = sites.get(i + 1).getPosition();
            }
            // calculate new position of current nav element
            float newPos;
            if ((nextPos - navPos) > 1) {
                newPos = navPos + 1;
            } else {
                newPos = (navPos + nextPos) / 2;
            }
            // check new maxValue of positions and increase it
            if (navPos > maxValue) {
                maxValue = navPos;
            }
            // if the element is the current file, mark it in select box
            if ((m_site != null) && (m_site.getSiteRoot() != null) && m_site.getSiteRoot().equals(siteRoot)) {
                beanList.add(
                    new PositionComboBoxElementBean(
                        CmsVaadinUtils.getMessageText(Messages.GUI_SITE_CHNAV_POS_CURRENT_1, m_site.getTitle()),
                        -1));
            } else {
                beanList.add(new PositionComboBoxElementBean(sites.get(i).getTitle(), newPos));
            }
        }

        // add the entry: at the last position
        PositionComboBoxElementBean lastEntry = new PositionComboBoxElementBean(
            CmsVaadinUtils.getMessageText(Messages.GUI_SITE_CHNAV_POS_LAST_0),
            maxValue + 1);
        beanList.add(lastEntry);

        // add the entry: no change
        beanList.add(
            new PositionComboBoxElementBean(CmsVaadinUtils.getMessageText(Messages.GUI_SITE_CHNAV_POS_NOCHANGE_0), -1));

        BeanItemContainer<PositionComboBoxElementBean> objects = new BeanItemContainer<PositionComboBoxElementBean>(
            PositionComboBoxElementBean.class,
            beanList);

        m_fieldPosition.setContainerDataSource(objects);
        m_fieldPosition.setItemCaptionPropertyId("title");
        m_fieldPosition.setValue(beanList.get(beanList.size() - 1));
        if (m_site == null) {
            m_fieldPosition.setValue(lastEntry);
        }
    }
1018671
function() {

            var self = this,
                moveToOption = self.list.is(":visible") || !self.options["keydownOpen"];

            return {

                "down": function() {

                    // If the plugin options allow keyboard navigation
                    if (self.moveDown && moveToOption) {

                        self.moveDown();

                    }

                },

                "up": function() {

                     // If the plugin options allow keyboard navigation
                    if (self.moveUp && moveToOption) {

                        self.moveUp();

                    }

                },

                "enter": function() {

                    var activeElem = self.listItems.eq(self.currentFocus);

                    // Updates the dropdown list value
                    self._update(activeElem);

                    if (activeElem.attr("data-preventclose") !== "true") {

                        // Closes the drop down list options list
                        self.close();

                    }

                    // Triggers the `enter` events on the original select box
                    self.triggerEvent("enter");

                },

                "tab": function() {

                    // Triggers the custom `tab-blur` event on the original select box
                    self.triggerEvent("tab-blur");

                    // Closes the drop down list
                    self.close();

                },

                "backspace": function() {

                    // Triggers the custom `backspace` event on the original select box
                    self.triggerEvent("backspace");

                },

                "esc": function() {

                    // Closes the dropdown options list
                    self.close();

                }

            };

        }
836670
func (win *Window) ComboSimple(items []string, selected int, item_height int) int {
	if len(items) == 0 {
		return selected
	}

	item_height = win.ctx.scale(item_height)
	item_padding := win.ctx.Style.Combo.ButtonPadding.Y
	window_padding := win.style().Padding.Y
	max_height := (len(items)+1)*item_height + item_padding*3 + window_padding*2
	if w := win.Combo(label.T(items[selected]), max_height, nil); w != nil {
		w.RowScaled(item_height).Dynamic(1)
		for i := range items {
			if w.MenuItem(label.TA(items[i], "LC")) {
				selected = i
			}
		}
	}
	return selected
}
1372954
function(playerCards, dealerCard, handCount, dealerCheckedBlackjack, options)
    {
        const playerOptions = ExtractOptions(options);
        var exactCompositionOverride = null;
        var countResult = null;
        var handValue = HandTotal(playerCards);

        // If early surrender is allowed, check that now (that's what early surrender means - before dealer checks for blackjack
        if ((playerOptions.surrender == "early") && (ShouldPlayerSurrender(playerCards, dealerCard, handValue, handCount, playerOptions)))
        {
            return "surrender";
        }

        // OK, let's see if the count will change anything
        if (playerOptions.count.system == "HiLo")
        {
            countResult = AdjustPlayForHiLoCount(playerCards, dealerCard, handValue, handCount, dealerCheckedBlackjack, playerOptions);    
            if (countResult)
            {
                return countResult;
            }
        }
         
        // OK, if an ace is showing it's easy - never take insurance
        if (((dealerCard == 1) && !dealerCheckedBlackjack && playerOptions.offerInsurance))
        {
            return "noinsurance";    
        }

        if ((playerOptions.strategyComplexity == "easy"))
        {
            return easy.EasyBasicStrategy(playerCards, dealerCard, handValue, handCount, dealerCheckedBlackjack, playerOptions);
        }

        // OK, first, if there is an exact composition override use that
        exactCompositionOverride = ec.GetExactCompositionOverride(playerCards, dealerCard, handValue, handCount, dealerCheckedBlackjack, playerOptions);
        if (exactCompositionOverride)
        {
            return exactCompositionOverride;
        }

        // Check each situation
        if (ShouldPlayerSplit(playerCards, dealerCard, handValue, handCount, playerOptions))
        {
            return "split";
        }
        else if (ShouldPlayerDouble(playerCards, dealerCard, handValue, handCount, playerOptions))
        {
            return "double";
        }
        // Note if early surrender is allowed we already checked, so no need to check again
        else if ((playerOptions.surrender != "early") && ShouldPlayerSurrender(playerCards, dealerCard, handValue, handCount, playerOptions))
        {
            return "surrender";
        }
        else if (ShouldPlayerStand(playerCards, dealerCard, handValue, handCount, playerOptions))
        {
            return "stand";
        }
        else if (ShouldPlayerHit(playerCards, dealerCard, handValue, handCount, playerOptions))
        {
            return "hit";
        }

        // I got nothing
        return "none";
    }
747187
function SingleInput(options) {
    Selectivity.call(
        this,
        assign(
            {
                // Dropdowns for single-value inputs should open below the select box, unless there
                // is not enough space below, in which case the dropdown should be moved up just
                // enough so it fits in the window, but never so much that it reaches above the top.
                positionDropdown: function(el, selectEl) {
                    var rect = selectEl.getBoundingClientRect();
                    var dropdownTop = rect.bottom;

                    var deltaUp = Math.min(
                        Math.max(dropdownTop + el.clientHeight - window.innerHeight, 0),
                        rect.top + rect.height
                    );

                    assign(el.style, {
                        left: rect.left + 'px',
                        top: dropdownTop - deltaUp + 'px',
                        width: rect.width + 'px'
                    });
                }
            },
            options
        )
    );

    this.rerender();

    if (options.showSearchInputInDropdown === false) {
        this.initInput(this.$('.selectivity-single-select-input'), { search: false });
    }

    this.events.on({
        change: this.rerenderSelection,
        click: this._clicked,
        'click .selectivity-search-input': stopPropagation,
        'click .selectivity-single-selected-item-remove': this._itemRemoveClicked,
        'focus .selectivity-single-select-input': this._focused,
        'selectivity-selected': this._resultSelected
    });
}
658118
protected void enableComboMode() {

        String value = m_selectBox.getFormValueAsString();
        m_selectBox.removeFromParent();
        m_comboMode = true;
        m_panel.add(m_comboBox);
        m_comboBox.setFormValueAsString(value);
        m_comboBox.setErrorMessage(m_error);
        m_comboBox.setEnabled(m_selectBox.isEnabled());
    }
58056
function createDropdownMenu(dropdown) {
    var $menu = $('<div>', {
        'class': 'dropdown-menu',
        'html': '<div class="dropdown-caret"><span class="caret-outer"></span><span class="caret-inner"></span></div>'
    });

    if (_.isString(dropdown)) {
        $menu.append(dropdown);
    } else {
        var groups = _.map(dropdown, function(group) {
            if (_.isArray(group)) return group;
            else return [group];
        });

        // Create buttons groups
        _.each(groups, function(group) {
            var $group = $('<div>', {
                'class': 'buttons'
            });
            var sizeClass = 'size-'+group.length;

            // Append buttons
            _.each(group, function(btn) {
                btn = _.defaults(btn || {}, {
                    text: '',
                    className: '',
                    onClick: defaultOnClick
                });

                var $btn = $('<button>', {
                    'class': 'button '+sizeClass+' '+btn.className,
                    'text': btn.text
                });
                $btn.click(btn.onClick);

                $group.append($btn);
            });


            $menu.append($group);
        });

    }


    return $menu;
}
1033689
protected static void iniRole(CmsObject cms, String ou, com.vaadin.ui.ComboBox<CmsRole> roleComboBox, Log log) {

        try {
            List<CmsRole> roles = OpenCms.getRoleManager().getRoles(cms, ou, false);
            CmsRole.applySystemRoleOrder(roles);

            DataProvider provider = new ListDataProvider<CmsRole>(roles);

            roleComboBox.setDataProvider(provider);
            roleComboBox.setItemCaptionGenerator(role -> {
                try {
                    return role.getDisplayName(cms, A_CmsUI.get().getLocale());
                } catch (CmsException e) {
                    return "";
                }
            });
            roleComboBox.setEmptySelectionAllowed(false);

        } catch (CmsException e) {
            if (log != null) {
                log.error("Unable to read roles.", e);
            }
        }
    }
1046046
private void setupComboBoxFile() {

        m_target.setInputPrompt(CmsVaadinUtils.getMessageText(Messages.GUI_DATABASEAPP_EXPORT_FILE_NAME_EMPTY_0));
        m_target.setNewItemsAllowed(true);
        List<String> files = CmsDbManager.getFileListFromServer(true);
        for (String file : files) {
            m_target.addItem(file);
        }
    }
360203
function (config) {
			
			var position, choice;
			
			position = this.getChoicePosition(config);
			
			if (position !== -1) {
				
				choice = this.choicesList[position];
				
				if (!choice.visible) {
					
					choice.visible = true;
					this.appendChoiceNode(choice.node, position);
				
				}
				
			}
			
		}
693457
func (b Box) List() []string {
	var keys []string

	if b.data == nil || len(b.data) == 0 {
		b.Walk(func(path string, info File) error {
			finfo, _ := info.FileInfo()
			if !finfo.IsDir() {
				keys = append(keys, finfo.Name())
			}
			return nil
		})
	} else {
		for k := range b.data {
			keys = append(keys, k)
		}
	}
	return keys
}
801183
function applyListOptions( clist, options ){

    var cmap =          {};

    if ( options.recursive || options.fillRequirements ){
        cmap =          clist.reduce( fillRequirements, {} );
    }
    if ( options.recursive ){
        clist =         getValues( cmap );
    }

    if ( options.sort ){
        clist =         modularity.sortComponents( clist, options );
    }

    if ( options && options.parts ){
        return clist.filter( byParts( options.parts ));
    } else {
        return clist;
    }


    function fillRequirements( cmap, component ){

        if ( !component || !component.name ){
            return cmap;
        }

        if ( !cmap[component.name] ){
            cmap[component.name] =  component;
        }

        if ( !component.requiredComponents ){
            component.requiredComponents =  {};
            var reqs =                      modularity.getRequirements( component, options );
            for ( var k in reqs ){
                var reqUrl =                reqs[k];
                if ( !cmap[reqUrl] ){
                    fillRequirements( cmap, readComponent( reqUrl, options ));
                }
                component.requiredComponents[k] =   cmap[reqUrl];
            }
        }

        return cmap;
    }///
}
371926
function buildDropdown(trumbowyg) {
        var dropdown = [];

        $.each(trumbowyg.o.plugins.lineheight.sizeList, function(index, size) {
            trumbowyg.addBtnDef('lineheight_' + size, {
                text: trumbowyg.lang.lineheights[size] || size,
                hasIcon: false,
                fn: function(){
                    trumbowyg.saveRange();
                    var text = trumbowyg.getRangeText();
                    if (text.replace(/\s/g, '') !== '') {
                        try {
                            var parent = getSelectionParentElement();
                            $(parent).css('lineHeight', size);
                        } catch (e) {
                        }
                    }
                }
            });
            dropdown.push('lineheight_' + size);
        });

        return dropdown;
    }
673168
def populate_combo_box(self):
        """"""
        if self.radio_button_production.isChecked():
            self.source = production_api['url']
            available_data = production_api['available_data']

        else:
            self.source = development_api['url']
            available_data = development_api['available_data']

        self.city_combo_box.clear()
        for index, data in enumerate(available_data):
            self.city_combo_box.addItem(data['name'])
            self.city_combo_box.setItemData(
                index, data['code'], Qt.UserRole)
340925
function(value){
        var self = this;
        value = value + '';
    	value = value || '';
    	
        var values = value.split(',');
        if (this.mutilSelect === true) {
            if(self._combo_name_par)
                self._combo_name_par.innerHTML = '';
            this.value = '';
        }
        if(!value) {
            this._input.value = '';
            this.value = '';
        }
        this.comboDatas.forEach(function(item, index){
            if (this.mutilSelect === true){
                if (values.indexOf(item.value) != -1){
                    this.selectItem(index)
                }
            }else {
                if (item.value === value) {
                    this.selectItem(index);
                    return;
                }
            }
        }.bind(this));
        if(!this.onlySelect){
            this.value = value;
            this.trigger('select', {value: this.value, name: this._input.value});
        }
    }
266780
private ComboBox createSiteSelect(CmsObject cms) {

        final IndexedContainer availableSites = CmsVaadinUtils.getAvailableSitesContainer(cms, SITE_CAPTION);
        ComboBox combo = new ComboBox(null, availableSites);
        combo.setTextInputAllowed(true);
        combo.setNullSelectionAllowed(false);
        combo.setWidth("200px");
        combo.setInputPrompt(
            Messages.get().getBundle(UI.getCurrent().getLocale()).key(Messages.GUI_EXPLORER_CLICK_TO_EDIT_0));
        combo.setItemCaptionPropertyId(SITE_CAPTION);
        combo.select(cms.getRequestContext().getSiteRoot());
        combo.setFilteringMode(FilteringMode.CONTAINS);
        combo.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            public void valueChange(ValueChangeEvent event) {

                String value = (String)event.getProperty().getValue();
                if (availableSites.containsId(value)) {
                    changeSite(value, null);
                    m_appContext.updateOnChange();
                    availableSites.removeAllContainerFilters();
                }
            }
        });
        if (Page.getCurrent().getBrowserWindowHeight() > 650) {
            combo.setPageLength(20);
        }
        return combo;
    }