Example usage for com.google.gwt.query.client GQuery children

List of usage examples for com.google.gwt.query.client GQuery children

Introduction

In this page you can find the example usage for com.google.gwt.query.client GQuery children.

Prototype

public GQuery children() 

Source Link

Document

Get a set of elements containing all of the unique immediate children of each of the matched set of elements.

Usage

From source file:com.arcbees.chosen.client.gwt.ChosenListBox.java

License:Apache License

/**
 * Insert a group to the list box./*from   w w w . j a  v  a2  s.c o  m*/
 *
 * @param label the text of the group to be added
 * @param id    the id of the optgroup element
 * @param index the index at which to insert it
 */
public void insertGroup(String label, String id, int index) {
    GQuery optGroup = $("<optgroup></optgroup>").attr("label", label);
    if (id != null) {
        optGroup.attr("id", id);
    }
    GQuery select = $(getElement());

    int itemCount = SelectElement.as(getElement()).getLength();

    if (index < 0 || index > itemCount) {
        select.append(optGroup);
    } else {
        GQuery before = select.children().eq(index);
        before.before(optGroup);
    }
}

From source file:com.arcbees.gquery.elastic.client.ElasticImpl.java

License:Apache License

void update(boolean fullUpdate) {
    int prevColumnNumber = columnHeights.size();
    columnHeights.clear();/*from   w  w w  .  j  a  v a2s .  com*/
    columnPriorities.clear();
    ignoredColumn.clear();

    GQuery $container = $(container);
    // check if children returns text elements
    GQuery items = $container.children();

    containerPaddingLeft = $container.cur("paddingLeft", true);
    containerPaddingRight = $container.cur("paddingRight", true);
    containerPaddingTop = $container.cur("paddingTop", true);
    containerPaddingBottom = $container.cur("paddingBottom", true);

    double totalColumnWidth = $container.innerWidth() - containerPaddingLeft - containerPaddingRight;

    int colNumber = calculateNumberOfColumn(totalColumnWidth);

    columnWidth = (totalColumnWidth - ((colNumber - 1) * options.getInnerColumnMargin())) / colNumber;
    columnWidth = max(columnWidth, options.getMinimumColumnWidth());
    if (options.getMaximumColumnWidth() != -1) {
        int maxWidth = max(options.getMinimumColumnWidth(), options.getMaximumColumnWidth());
        columnWidth = min(columnWidth, maxWidth);
    }

    double initialTop = useTranslate3d ? 0 : containerPaddingTop;
    for (int i = 0; i < colNumber; i++) {
        columnHeights.add(initialTop);
        columnPriorities.add(i);
        ignoredColumn.add(false);
    }

    // Use four different loops in order to avoid browser reflows
    if (fullUpdate) {
        for (Element e : items.elements()) {
            initItem(e);
        }
    }

    if (!canUseCalc() || prevColumnNumber != colNumber) {
        for (Element e : items.elements()) {
            setItemWidth(e, colNumber);
        }
    }

    for (Element e : items.elements()) {
        readItemHeight(e);
    }

    for (Element e : items.elements()) {
        placeItem(e, colNumber);
    }

    setHeightContainer();
}

From source file:com.watopi.chosen.client.gwt.ChosenListBox.java

License:Open Source License

/**
 * Insert a group to the list box.//from   w  w w. ja v  a2  s .c o m
 * 
 * @param group
 *            the text of the group to be added
 * @param index
 *            the index at which to insert it
 */
public void insertGroup(String group, int index) {
    GQuery optGroup = $("<optgroup></optgroup>").attr("label", group);
    GQuery select = $(getElement());

    int itemCount = SelectElement.as(getElement()).getLength();

    if (index < 0 || index > itemCount) {
        select.append(optGroup);
    } else {
        GQuery before = select.children().eq(index);
        before.before(optGroup);
    }
}

From source file:org.otalo.ao.client.widget.chlist.gwt.ChosenListBox.java

License:Apache License

/**
 * Adds an item to the an optgroup of the list box. If no optgroup exists,
 * the item will be add at the end ot the list box.
 *
 * @param item       the text of the item to be added
 * @param value      the value of the item to be added
 * @param itemIndex  the index inside the optgroup at which to insert the item
 * @param groupIndex the index of the optGroup where the item will be inserted
 *///from  w w w.  ja  v  a2 s. c o m
public void insertItemToGroup(String item, Direction dir, String value, int groupIndex, int itemIndex) {
    GQuery optgroupList = $(OPTGROUP_TAG, getElement());

    int groupCount = optgroupList.size();

    if (groupCount == 0) {
        // simply insert the item to the listbox
        insertItem(item, dir, value, itemIndex);
        return;
    }

    if (groupIndex < 0 || groupIndex > groupCount - 1) {
        groupIndex = groupCount - 1;
    }

    GQuery optgroup = optgroupList.eq(groupIndex);

    OptionElement option = Document.get().createOptionElement();
    setOptionText(option, item, dir);
    option.setValue(value);

    int itemCount = optgroup.children().size();

    if (itemIndex < 0 || itemIndex > itemCount - 1) {
        optgroup.append(option);
    } else {
        GQuery before = optgroup.children().eq(itemIndex);
        before.before(option);
    }

}