Package com.google.gwt.query.client

Examples of com.google.gwt.query.client.GQuery


    public void insertStyledItemToGroup(String item, String value, String className, Direction dir, int indentLevel,
            int groupIndex, int itemIndex) {
        if (indentLevel < 0) {
            throw new IllegalArgumentException("[indentLevel] must be non-negative.");
        }
        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();

        if (!(className == null || className.trim().isEmpty())) {
            option.addClassName(className);
        }
        if (indentLevel > 0) {
            // Calculate total indentation, not forgetting that being in a group is adding one extra indent step
            int leftPadding = options.getResources().css().indent() * (indentLevel + 1);
            option.setAttribute("style", "padding-left: " + leftPadding + "px;");
        }

        Element optGroupElement = optgroup.get(0);
        int itemCount = optGroupElement.getChildCount();

        if (itemIndex < 0 || itemIndex > itemCount - 1) {
            optgroup.append(option);
        } else {
            GQuery before = $(optGroupElement.getChild(itemIndex));
            before.before(option);
        }
        // setText must be after the element has been appended to the DOM - see javadoc
        setOptionText(option, item, dir);
        option.setValue(value);
    }
View Full Code Here


        options.setDisableSearchThreshold(disableSearchThreshold);
    }

    @Override
    public void setFocus(boolean focused) {
        GQuery focusElement = getFocusableElement();
        if (focused) {
            focusElement.focus();
        } else {
            focusElement.blur();
        }
    }
View Full Code Here

        options.setHighlightSearchTerm(highlightSearchTerm);
    }

    @Override
    protected com.google.gwt.user.client.Element getStyleElement() {
        GQuery chosenElement = getChosenElement();
        if (!chosenElement.isEmpty()) {
            return chosenElement.get(0).cast();
        }

        return super.getStyleElement();
    }
View Full Code Here

    @Override
    public void setVisible(boolean visible) {
        this.visible = visible;

        if (isSupported()) {
            GQuery chosenElement = getChosenElement();
            if (visible) {
                chosenElement.show();
            } else {
                chosenElement.hide();
            }
        } else {
            super.setVisible(visible);
        }
    }
View Full Code Here

        super.onUnload();
        $(getElement()).as(Chosen).destroy();
    }

    private GQuery getFocusableElement() {
        GQuery chosen = getChosenElement();
        GQuery focusableElement = chosen.children("a");
        if (focusableElement.isEmpty()) {
            focusableElement = chosen.find("input");
        }

        return focusableElement;
    }
View Full Code Here

    private boolean choicesClick(Event e) {
        e.preventDefault();

        Element target = e.getEventTarget().cast();
        GQuery $e = $(target);

        if (activeField
                && !($e.hasClass(css.searchChoice()) || !$e.parents("." + css.searchChoice()).isEmpty())
                && !resultsShowing) {
            resultsShow();
        }
        return true;
    }
View Full Code Here

    private boolean containerMouseDown(Event e) {
        if (isDisabled) {
            return true;
        }
        Element target = e.getEventTarget().cast();
        GQuery $e = $(target);

        boolean targetCloseLink = $e.hasClass(css.searchChoiceClose());

        if (!resultsShowing) {
            e.stopPropagation();
        }

        if (!pendingDestroyClick && !targetCloseLink) {
            if (!activeField) {
                if (isMultiple) {
                    searchField.val("");
                }
                $(document).click(clickTestAction);
                resultsShow();
            } else if (!isMultiple && !$e.isEmpty()
                    && ($e.get(0) == selectedItem.get(0) || $e.parents("a." + css.chznSingle()).length() > 0)) {
                e.preventDefault();
                resultsToggle();
            }

            activateField(e);
View Full Code Here

        return false;
    }

    private boolean containerMouseUp(Event e) {
        Element target = e.getEventTarget().cast();
        GQuery $e = $(target);

        if (!$e.isEmpty() && "ABBR".equalsIgnoreCase($e.get(0).getNodeName()) && !isDisabled) {
            resultsReset(e);
            return false;
        }

        return true;
View Full Code Here

        return element.parents().filter("body").isEmpty();
    }

    private void keydownArrow() {
        if (resultHighlight == null || isDetached(resultHighlight)) {
            GQuery firstActive = searchResults.find("li." + css.activeResult()).first();
            if (firstActive != null) {
                resultDoHighlight(firstActive);
            }
        } else if (resultsShowing) {
            // TODO should be replaced by :
            // GQuery nextSibling = resultHighlight.nextAll("li."+css.activeResult()).first();
            // but performance is bad... See http://code.google.com/p/gwtquery/issues/detail?id=146

            GQuery nextSibling = resultHighlight.next();

            while (!nextSibling.isEmpty() && !nextSibling.is("li." + css.activeResult())) {
                nextSibling = nextSibling.next();
            }

            resultDoHighlight(nextSibling);

        }
View Full Code Here

        } else if (resultHighlight != null) {
            // TODO should be replaced by :
            // GQuery prevSibs = resultHighlight.prevAll("li." + css.activeResult());
            // but performance is bad... See http://code.google.com/p/gwtquery/issues/detail?id=146

            GQuery prevSibling = resultHighlight.prev();

            while (!prevSibling.isEmpty() && !prevSibling.is("li." + css.activeResult())) {
                prevSibling = prevSibling.prev();
            }

            if (prevSibling.length() > 0) {
                resultDoHighlight(prevSibling.first());
            } else {
                if (choices > 0) {
                    resultsHide();
                }
View Full Code Here

TOP

Related Classes of com.google.gwt.query.client.GQuery

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.