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

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

Introduction

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

Prototype

public GQuery remove() 

Source Link

Document

Removes all matched elements from the DOM.

Usage

From source file:com.arcbees.chosen.client.ChosenImpl.java

License:Apache License

private void setup() {
    boolean isHidden = false;
    containerId = buildContainerId();// w w  w.  j a v  a2  s . c  o  m
    fWidth = $selectElement.outerWidth();

    isRTL = LocaleInfo.getCurrentLocale().isRTL() || $selectElement.hasClass("chzn-rtl");
    // Temporary fix. IIf the select element is inside a hidden container
    // GQuery cannot get the size of the select element.
    if (fWidth == 0) {
        $("body").append("<div id='gwt_chosen_temp_div' style='display:block;position:absolute;"
                + (isRTL ? "right" : "left") + ":-9000px; visibility:hidden'> </div>");
        GQuery tempDiv = $("#gwt_chosen_temp_div");
        tempDiv.append($selectElement.clone());

        fWidth = tempDiv.children("select").outerWidth();

        tempDiv.remove();
        isHidden = fWidth > 0;
    }

    String containerClass = getContainerClass();

    String cssClasses = isRTL ? containerClass + " " + css.chznRtl() : containerClass;

    // recopy classes present on the select element
    cssClasses += " " + selectElement.getClassName();

    GQuery containerTemp = $(ChosenTemplate.templates.container(containerId, cssClasses).asString())
            .width(fWidth);

    final SafeStylesBuilder ssb = new SafeStylesBuilder();
    if (isRTL) {
        ssb.right(HORIZONTAL_OFFSET, Style.Unit.PX);
    } else {
        ssb.left(HORIZONTAL_OFFSET, Style.Unit.PX);
    }
    ssb.top(VERTICAL_OFFSET, Style.Unit.PX);

    containerTemp.html(buildContainerHtml(defaultText, ssb).asString());

    // insert container after the select elements
    $selectElement.hide().after(containerTemp);
    container = $("#" + containerId);
    container.addClass(isMultiple() ? css.chznContainerMulti() : css.chznContainerSingle());

    dropdown = container.find("div." + css.chznDrop()).first();
    int ddWidth = fWidth - getSideBorderPadding(dropdown, isHidden);

    dropdown.css("width", buildDropdownWidth(ddWidth));

    searchField = container.find("input").first();
    searchResults = container.find("ul." + css.chznResults()).first();
    searchFieldScale(fWidth);

    initSearchElement(ddWidth, isHidden);

    resultsBuild(true);

    setTabIndex();

    fireEvent(new ReadyEvent(this));
}

From source file:com.arcbees.chosen.client.DesktopMultipleChosenImpl.java

License:Apache License

@Override
protected void searchFieldScale(int fWidth) {
    StringBuilder styleBlock = new StringBuilder("position:absolute; " + (isRTL() ? "right" : "left")
            + ": -1000px; top: -1000px; " + "visibility:hidden;");
    String[] styleToCopy = { "font-size", "font-style", "font-weight", "font-family", "line-height",
            "text-transform", "letter-spacing" };

    for (String style : styleToCopy) {
        styleBlock.append(style).append(':').append(getSearchField().css(style)).append(";");
    }//from w w w.j ava2 s .  c om

    GQuery div = $("<div />").attr("style", styleBlock.toString()).text(getSearchField().val());
    $("body").append(div);

    int w = div.width() + 25;
    div.remove();

    if (w > fWidth - 10) {
        w = fWidth - 10;
    }

    getSearchField().css("width", w + "px");
}

From source file:com.pronoiahealth.olhie.client.widgets.booklist3d.BookList3D.java

License:Open Source License

/**
 * Remove all events from list//from  ww w.  ja  va  2  s.co m
 */
public void removeEventsFromLst() {
    if (books != null) {
        books.each(new Function() {
            @Override
            public void f(Element e) {
                final GQuery book = $(e);
                final GQuery page = book.children("div.bk-page");
                final GQuery parent = book.parent();
                final GQuery bookview = parent.find("button.bk-bookview");
                final GQuery flipAction = parent.find("button.bk-bookback");
                final GQuery toc = page.find("div.bk-toc");
                final GQuery tocPageMyCollectionsBtn = toc.find("a.bk-tocPage-myCollectionsBtn");
                final GQuery content = page.children("div.bk-content");
                final GQuery downloadContentBtns = page.find("a.bk-download-btn");
                final GQuery viewContentBtns = page.find("a.bk-view-btn");
                final GQuery tocItems = page.find("div.bk-toc-item");
                final GQuery tocLinks = page.find("div.bk-toc-link");

                book.unbind(Event.ONCLICK);
                flipAction.unbind(Event.ONCLICK);
                bookview.unbind(Event.ONCLICK);
                if (content.length() > 1) {
                    GQuery navPrev = page.find(".bk-page-prev");
                    if (navPrev != null) {
                        navPrev.unbind(Event.ONCLICK);
                        navPrev.remove();
                    }

                    GQuery navNext = page.find(".bk-page-next");
                    if (navNext != null) {
                        navNext.unbind(Event.ONCLICK);
                        navNext.remove();
                    }

                    // Unbind TOC items
                    tocItems.each().unbind(Event.ONCLICK);
                }
                tocPageMyCollectionsBtn.unbind(Event.ONCLICK);
                tocItems.each(new Function() {
                    @Override
                    public void f(com.google.gwt.dom.client.Element e) {
                        $(e).unbind(Event.ONCLICK);
                    }
                });
                tocLinks.each(new Function() {
                    @Override
                    public void f(com.google.gwt.dom.client.Element e) {
                        $(e).unbind(Event.ONCLICK);
                    }
                });
                viewContentBtns.each(new Function() {
                    @Override
                    public void f(com.google.gwt.dom.client.Element e) {
                        $(e).unbind(Event.ONCLICK);
                    }
                });
                downloadContentBtns.each(new Function() {
                    @Override
                    public void f(com.google.gwt.dom.client.Element e) {
                        $(e).unbind(Event.ONCLICK);
                    }
                });
            }
        });
    }
}

From source file:com.watopi.chosen.client.ChosenImpl.java

License:Open Source License

private void searchFieldScale() {
    if (!isMultiple) {
        return;//  w w  w.j a va 2 s  .c o m
    }

    StringBuilder styleBlock = new StringBuilder(
            "position:absolute; " + (isRTL ? "right" : "left") + ": -1000px; top: -1000px; visibility:hidden;");
    String[] styleToCopy = { "font-size", "font-style", "font-weight", "font-family", "line-height",
            "text-transform", "letter-spacing" };

    for (String style : styleToCopy) {
        styleBlock.append(style).append(':').append(searchField.css(style));
    }

    GQuery div = $("<div />").attr("style", styleBlock.toString()).text(searchField.val());
    $("body").append(div);

    int w = div.width() + 25;
    div.remove();

    if (w > fWidth - 10) {
        w = fWidth - 10;
    }

    searchField.css("width", w + "px");

    int ddTop = container.height();
    dropdown.css("top", ddTop + "px");
}

From source file:com.watopi.chosen.client.ChosenImpl.java

License:Open Source License

private void setup() {
    boolean isHidden = false;
    containerId = buildContainerId();//from w w w  .j a v  a2  s.  c  o  m
    fWidth = $selectElement.outerWidth();

    //Temporary fix. IIf the select element is inside a hidden container
    //GQuery cannot get the size of the select element.
    if (fWidth == 0) {
        $("body").append("<div id='gwt_chosen_temp_div' style='display:block;position:absolute;"
                + (isRTL ? "right" : "left") + ":-9000px; visibility:hidden'> </div>");
        GQuery tempDiv = $("#gwt_chosen_temp_div");
        tempDiv.append($selectElement.clone());

        fWidth = tempDiv.children("select").outerWidth();

        tempDiv.remove();
        isHidden = fWidth > 0;

    }

    isRTL = LocaleInfo.getCurrentLocale().isRTL() || $selectElement.hasClass("chzn-rtl");

    String cssClasses = isRTL ? css.chznContainer() + " " + css.chznRtl() : css.chznContainer();

    GQuery containerTemp = $(ChozenTemplate.templates.container(containerId, cssClasses).asString())
            .width(fWidth);

    if (isMultiple) {
        containerTemp.html(ChozenTemplate.templates.contentMultiple(css.chznChoices(), css.searchField(),
                defaultText, css.defaultClass(), css.chznDrop(), css.chznResults(), (isRTL ? "right" : "left"))
                .asString());
    } else {
        containerTemp.html(ChozenTemplate.templates.contentSingle(css.chznSingle(), css.chznDefault(),
                defaultText, css.chznDrop(), css.chznSearch(), css.chznResults(), (isRTL ? "right" : "left"))
                .asString());
    }

    // insert container after the select elements
    $selectElement.hide().after(containerTemp);
    container = $("#" + containerId);
    container.addClass(isMultiple ? css.chznContainerMulti() : css.chznContainerSingle());

    dropdown = container.find("div." + css.chznDrop()).first();
    int ddTop = container.height();
    int ddWidth = fWidth - getSideBorderPadding(dropdown, isHidden);
    dropdown.css(Properties.create("{\"width\": " + ddWidth + "px, \"top\": " + ddTop + "px}"));

    searchField = container.find("input").first();
    searchResults = container.find("ul." + css.chznResults()).first();
    searchFieldScale();

    if (isMultiple) {
        searchChoices = container.find("ul." + css.chznChoices()).first();
        searchContainer = container.find("li." + css.searchField()).first();
    } else {
        searchContainer = container.find("div." + css.chznSearch()).first();
        selectedItem = container.find("." + css.chznSingle()).first();
        int searchFieldWidth = ddWidth - getSideBorderPadding(searchContainer, isHidden)
                - getSideBorderPadding(searchField, isHidden);
        searchField.css("width", searchFieldWidth + "px");
    }

    resultsBuild();

    setTabIndex();

    fireEvent(new ReadyEvent(this));

}

From source file:com.wcs.wcslib.vaadin.widget.filtertablestate.client.FilterTableStateConnector.java

License:Apache License

public void addPopupOpenButton() {
    GQuery querySelector = $("." + COLUMN_SELECTOR_STYLE, filterTable);

    buttonElement = DOM.createDiv();//w  w w  .  j  a  va2 s.co m
    querySelector.after(buttonElement);
    querySelector.remove();

    buttonElement.addClassName(COLUMN_SELECTOR_STYLE);

    addButtonClickListener(buttonElement);
}

From source file:gwtquery.plugins.draggable.client.impl.DraggableHandlerImpl.java

License:Apache License

public void removeHelper(GQuery helper, HelperType helperType) {
    helper.remove();
}

From source file:org.bonitasoft.web.toolkit.client.ui.component.menu.MenuFolder.java

License:Open Source License

public void setImage(final Image image) {
    this.image = image;

    if (isGenerated()) {

        final GQuery link = $(this.element).children("a");
        final GQuery img = link.find("img");

        if (image == null) {
            img.remove();
        } else if (img.length() > 0) {
            img.replaceWith(image.getElement());
        } else {//  ww  w .ja v  a 2s .  com
            link.prepend(image.getElement());
        }
    }
}

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

License:Apache License

private void searchFieldScale() {
    if (!isMultiple) {
        return;/*  ww  w. java 2 s  .c o m*/
    }

    StringBuilder styleBlock = new StringBuilder("position:absolute; " + (isRTL ? "right" : "left")
            + ": -1000px; top: -1000px; " + "visibility:hidden;");
    String[] styleToCopy = { "font-size", "font-style", "font-weight", "font-family", "line-height",
            "text-transform", "letter-spacing" };

    for (String style : styleToCopy) {
        styleBlock.append(style).append(':').append(searchField.css(style));
    }

    GQuery div = $("<div />").attr("style", styleBlock.toString()).text(searchField.val());
    $("body").append(div);

    int w = div.width() + 25;
    div.remove();

    if (w > fWidth - 10) {
        w = fWidth - 10;
    }

    searchField.css("width", w + "px");

    int ddTop = container.height();
    dropdown.css("top", ddTop + "px");
}

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

License:Apache License

private void setup() {
    boolean isHidden = false;
    containerId = buildContainerId();//  ww w  . j  a  v a 2s .c  o m
    fWidth = $selectElement.outerWidth();

    //Temporary fix. IIf the select element is inside a hidden container
    //GQuery cannot get the size of the select element.
    if (fWidth == 0) {
        $("body").append("<div id='gwt_chosen_temp_div' style='display:block;position:absolute;"
                + (isRTL ? "right" : "left") + ":-9000px; visibility:hidden'> </div>");
        GQuery tempDiv = $("#gwt_chosen_temp_div");
        tempDiv.append($selectElement.clone());

        fWidth = tempDiv.children("select").outerWidth();

        tempDiv.remove();
        isHidden = fWidth > 0;

    }

    isRTL = LocaleInfo.getCurrentLocale().isRTL() || $selectElement.hasClass("chzn-rtl");

    String cssClasses = isRTL ? css.chznContainer() + " " + css.chznRtl() : css.chznContainer();

    GQuery containerTemp = $(ChozenTemplate.templates.container(containerId, cssClasses).asString())
            .width(fWidth);

    SafeStyles horizontalOffset = isRTL ? SafeStylesUtils.forRight(HORIZONTAL_OFFSET, Style.Unit.PX)
            : SafeStylesUtils.forLeft(HORIZONTAL_OFFSET, Style.Unit.PX);

    if (isMultiple) {
        containerTemp.html(
                ChozenTemplate.templates.contentMultiple(css.chznChoices(), css.searchField(), defaultText,
                        css.defaultClass(), css.chznDrop(), css.chznResults(), horizontalOffset).asString());
    } else {
        containerTemp.html(ChozenTemplate.templates.contentSingle(css.chznSingle(), css.chznDefault(),
                defaultText, css.chznDrop(), css.chznSearch(), css.chznResults(), horizontalOffset).asString());
    }

    // insert container after the select elements
    $selectElement.hide().after(containerTemp);
    container = $("#" + containerId);
    container.addClass(isMultiple ? css.chznContainerMulti() : css.chznContainerSingle());

    dropdown = container.find("div." + css.chznDrop()).first();
    int ddTop = container.height();
    int ddWidth = fWidth - getSideBorderPadding(dropdown, isHidden);
    dropdown.css(Properties.create("{\"width\": " + ddWidth + "px, \"top\": " + ddTop + "px}"));

    searchField = container.find("input").first();
    searchResults = container.find("ul." + css.chznResults()).first();
    searchFieldScale();

    if (isMultiple) {
        searchChoices = container.find("ul." + css.chznChoices()).first();
        searchContainer = container.find("li." + css.searchField()).first();
    } else {
        searchContainer = container.find("div." + css.chznSearch()).first();
        selectedItem = container.find("." + css.chznSingle()).first();
        int searchFieldWidth = ddWidth - getSideBorderPadding(searchContainer, isHidden)
                - getSideBorderPadding(searchField, isHidden);
        searchField.css("width", searchFieldWidth + "px");
    }

    resultsBuild();

    setTabIndex();

    fireEvent(new ReadyEvent(this));

}