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

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

Introduction

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

Prototype

public GQuery find(String... filters) 

Source Link

Document

Searches for all elements that match the specified css expression.

Usage

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

License:Apache License

void noResults(String terms) {
    GQuery noResults = $(ChosenTemplate.templates.noResults(css.noResults(), resultsNoneFound).asString());
    noResults.find("span").html(terms);

    searchResults.append(noResults);/*from  ww w .j  a  va  2 s .co  m*/
}

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

License:Apache License

private GQuery getFocusableElement() {
    GQuery chosen = getChosenElement();
    GQuery focusableElement = chosen.children("a");
    if (focusableElement.isEmpty()) {
        focusableElement = chosen.find("input");
    }//from  ww w .  ja v a  2 s. c  o m

    return focusableElement;
}

From source file:com.jci.client.application.program.ProgramPageView.java

License:Apache License

private void bindGwtQuery() {
    //Tooltip clicking
    $("." + tooltipStyleNameProgram).unbind("click");
    $("." + tooltipStyleNameProgram).click(new Function() {
        @Override//from  ww w. j a  v  a 2s . c om
        public void f(Element e) {
            getEvent().stopPropagation();
        }
    });

    $("a", divButtons).unbind("click");
    $("a", divButtons).click(new Function() {
        @Override
        public void f(Element e) {
            $("." + activeStyleName).removeClass(activeStyleName);
            $("." + downNameProgram).removeClass(downNameProgram);

            if ($(e).hasClass("firstButton")) {
                $("." + overflowNameProgram).addClass(downNameProgram);
            }

            $(e).addClass(activeStyleName);
            pauseCarousel();
        }
    });

    $(divCalendar).unbind("click");
    $(divCalendar).click(new Function() {
        @Override
        public void f(Element e) {
            untoggleTooltipClick(e);
        }
    });

    $("." + eventStyleNameProgram, divCalendar).unbind("click");
    $("." + eventStyleNameProgram, divCalendar).click(new Function() {
        @Override
        public void f(Element e) {
            if ($(e).hasClass(activeStyleNameProgram)) {
                untoggleTooltipClick(e);
            } else {
                untoggleTooltipClick(e);
                $(e).addClass(activeStyleNameProgram);
                $("." + tooltipStyleNameProgram, e).addClass(activeTooltipStyleNameProgram);
            }
            getEvent().stopPropagation();
        }
    });

    $("." + pagerButtonContainerStyleName + " a").unbind("click");
    $("." + pagerButtonContainerStyleName + " a").click(new Function() {
        @Override
        public void f(Element e) {
            GQuery gQueryPager = $(e).parents("." + pagerContainerStyleName);
            int positionIndex = gQueryPager.find("." + pagerButtonStyleName).index(e) + 1;

            //Reset all butons and divs
            gQueryPager.find("." + pagerButtonStyleName).removeClass(activeExcursionStyleName);
            gQueryPager.find("." + pagerDivStyleName).hide();
            //Activate good button and div
            $(e).addClass(activeExcursionStyleName);
            gQueryPager.find("." + pagerDivStyleName + ":nth-child(" + positionIndex + ")").show();
        }
    });
}

From source file:com.pronoiahealth.olhie.client.pages.bookcase.widgets.BookCaseContainerWidget.java

License:Open Source License

/**
 * Configure the update when a users moves a book in the display and
 * configure the button click on a book display.
 *///w w  w.ja va2s .  co m
private void config() {
    // Configure the sortable container
    // JSONObject obj = new JSONObject();
    // configSortable(this, sortableContainer, obj.getJavaScriptObject());

    // Configure sortable
    GQuery sortableContainerQry = $(sortableContainer);
    sortableContainerQry.as(Ui).sortable().bind("sortupdate", new Function() {
        @Override
        public boolean f(Event e, Object data) {
            GQuery lstQry = $(sortableContainer).find(".ui-state-default");
            int size = lstQry.length();
            Map<String, Integer> map = new HashMap<String, Integer>();
            for (int i = 0; i < size; i++) {
                com.google.gwt.dom.client.Element ret = lstQry.get(i);
                GQuery retQry = $(ret).find(".bookCase-Detail-Button");
                String val = retQry.attr("userBookRelationshipId");
                map.put(val, Integer.valueOf(i));
            }

            // Tell the server to update the data
            bookcaseBookWidgetReorderEvent.fire(new BookcaseBookWidgetReorderEvent(map));

            // Event propagation stops here
            return false;
        }
    });

    // Configure the click events, bind the bookClickFunction to each
    // element
    GQuery sortableQry = sortableContainerQry.find(".bookCase-Detail-Button");
    sortableQry.each(new Function() {
        @Override
        public void f(com.google.gwt.dom.client.Element e) {
            $(e).bind(Event.ONCLICK, new Function() {
                @Override
                public boolean f(Event e) {
                    // Fire the event which will get the clicked book for
                    // display
                    String bookId = $(e).attr("bookId");
                    if (bookId != null && bookId.length() > 0) {
                        bookListBookSelectedEvent.fire(new BookcaseBookListBookSelectedEvent(bookId));
                    }
                    return false;
                }
            });
        }
    });
}

From source file:com.pronoiahealth.olhie.client.pages.bookcase.widgets.BookCaseContainerWidget.java

License:Open Source License

/**
 * Clears book item widgets/*from   w  ww  .  j  ava2s. c  om*/
 */
private void disposeBookCaseDraggableBookWidgets() {
    if (sortableContainer != null && sortableContainer.hasChildNodes()) {
        GQuery sortableContainerQry = $(sortableContainer);

        // Unbind the click events
        GQuery sortableQry = sortableContainerQry.find(".bookCase-Detail-Button");
        sortableQry.each(new Function() {
            @Override
            public void f(com.google.gwt.dom.client.Element e) {
                $(e).unbind(Event.ONCLICK);
            }
        });

        // Unbind the sortable
        sortableContainerQry.as(Ui).sortable().unbind("sortupdate");
        sortableContainerQry.as(Ui).sortable().destroy();

        // Remove all the widgets
        int cnt = DOM.getChildCount(sortableContainer);
        for (int i = 0; i < cnt; i++) {
            Element e = DOM.getChild(sortableContainer, i);
            EventListener listener = DOM.getEventListener((com.google.gwt.user.client.Element) e);
            // No listener attached to the element, so no widget exist for
            // this element
            if (listener != null && listener instanceof BookCaseDraggableBookWidget) {
                bookCaseDraggableBookWidgetDisposer.dispose((BookCaseDraggableBookWidget) listener);
            }
        }
    }

    // Destroy physical
    Node node = null;
    while ((node = sortableContainer.getFirstChild()) != null) {
        sortableContainer.removeChild(node);
    }
}

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

License:Open Source License

/**
 * Used to add books in after the initial display
 * //from   w w  w  .ja v  a 2  s .c  o m
 * @param bookDiv
 */
public void attachEventsToLst() {
    this.books = $("#bk-list > li > div.bk-book", bookList.getParentElement());
    this.currentBookCnt = books.length();

    books.each(new Function() {
        @Override
        public void f(Element e) {
            final GQuery book = $(e);
            final GQuery other = books.not(book);
            final GQuery parent = book.parent();
            final GQuery page = book.children("div.bk-page");
            final GQuery bookview = parent.find("button.bk-bookview");
            final GQuery flipAction = parent.find("button.bk-bookback");
            final GQuery content = page.children("div.bk-content");
            final GQuery toc = page.find("div.bk-toc");
            final GQuery tocPageMyCollectionsBtn = toc.find("a.bk-tocPage-myCollectionsBtn");
            final GQuery tocPageCommentRatingBtn = toc.find("a.bk-tocPage-commentRatingBtn");
            final GQuery tocItems = page.find("div.bk-toc-item");
            final GQuery tocLinks = page.find("div.bk-toc-link");
            final GQuery downloadContentBtns = page.find("a.bk-download-btn");
            final GQuery viewContentBtns = page.find("a.bk-view-btn");
            final GQuery linkContentBtns = page.find("a.bk-link-btn");
            final IntHolder current = new IntHolder();

            // Book Id
            final String bookId = book.attr("bookId");

            // Bind the call back
            book.bind(Event.ONCLICK, new Function() {
                @Override
                public boolean f(Event e) {
                    checkBookIsAuthorRequestEvent.fire(new CheckBookIsAuthorRequestEvent(bookId));
                    return false;
                }
            });

            flipAction.bind(Event.ONCLICK, new Function() {
                @Override
                public boolean f(Event e) {
                    // Toggle the button
                    if (flipAction.hasClass("bk-bookback-pressed") == true) {
                        flipAction.removeClass("bk-bookback-pressed");
                    } else {
                        flipAction.addClass("bk-bookback-pressed");
                    }

                    bookview.removeClass("bk-active");
                    boolean flipVal = false;
                    Object flipObj = book.data("flip");
                    if (flipObj != null) {
                        flipVal = (Boolean) flipObj;
                    }
                    if (flipVal == true) {
                        book.data("opened", false).data("flip", false);
                        book.removeClass("bk-viewback");
                        book.addClass("bk-bookdefault");
                    } else {
                        book.data("opened", false).data("flip", true);
                        book.removeClass("bk-viewinside").removeClass("bk-bookdefault");
                        book.addClass("bk-viewback");
                    }
                    return true;
                }
            });

            bookview.bind(Event.ONCLICK, new Function() {
                @Override
                public boolean f(Event e) {

                    // If the view back cover was pressed need to reset
                    // the button
                    if (flipAction.hasClass("bk-bookback-pressed") == true) {
                        flipAction.removeClass("bk-bookback-pressed");
                    }

                    GQuery thisPt = $(e);
                    other.data("opened", false);
                    other.removeClass("bk-viewinside");
                    GQuery otherParent = other.parent().css(CSS.ZINDEX.with(0));
                    otherParent.find("button.bk-bookview").removeClass("bk-active");

                    if (!other.hasClass("bk-viewback")) {
                        other.addClass("bk-bookdefault");
                    }

                    boolean openedVal = false;
                    Object openedObj = book.data("opened");
                    if (openedObj != null) {
                        openedVal = (Boolean) openedObj;
                    }
                    if (openedVal == true) {
                        thisPt.removeClass("bk-active");
                        book.data("opened", false).data("flip", false);
                        book.removeClass("bk-viewinside");
                        book.addClass("bk-bookdefault");
                    } else {
                        thisPt.addClass("bk-active");
                        book.data("opened", true).data("flip", false);
                        book.removeClass("bk-viewback").removeClass("bk-bookdefault");
                        book.addClass("bk-viewinside");
                        parent.css(CSS.ZINDEX.with(currentBookCnt++));
                        current.setIntVal(0);
                        content.removeClass("bk-content-current").eq(current.getIntVal())
                                .addClass("bk-content-current");
                    }
                    return true;
                }
            });

            // If it is a btn-success buton we want to add the book to the
            // users collection, otherwise remove for the collection.
            // Clear results container
            tocPageMyCollectionsBtn.bind(Event.ONCLICK, new Function() {
                @Override
                public boolean f(Event e) {
                    GQuery anchor = $(e);
                    boolean addToCollection = anchor.hasClass("btn-success");
                    adjustMyCollection(bookId, addToCollection);
                    return false;
                }
            });

            tocPageCommentRatingBtn.bind(Event.ONCLICK, new Function() {
                @Override
                public boolean f(Event e) {
                    addUpdateComment(bookId);
                    return false;
                }
            });

            if (content.length() > 1) {
                GQuery navPrev = $("<span class=\"bk-page-prev\">&lt;</span>");
                GQuery navNext = $("<span class=\"bk-page-next\">&gt;</span>");
                page.append($("<nav></nav>").append(navPrev).append(navNext));

                navPrev.bind(Event.ONCLICK, new Function() {
                    @Override
                    public boolean f(Event e) {
                        if (current.getIntVal() > 0) {
                            current.subOne();
                            content.removeClass("bk-content-current").eq(current.getIntVal())
                                    .addClass("bk-content-current");
                        }
                        return false;
                    }
                });

                navNext.bind(Event.ONCLICK, new Function() {
                    @Override
                    public boolean f(Event e) {
                        if (current.getIntVal() < content.length() - 1) {
                            current.plusOne();
                            content.removeClass("bk-content-current").eq(current.getIntVal())
                                    .addClass("bk-content-current");
                        }
                        return false;
                    }
                });

                // TOC items
                tocItems.each(new Function() {
                    @Override
                    public void f(Element e) {
                        GQuery item = $(e);
                        item.bind(Event.ONCLICK, new Function() {
                            @Override
                            public boolean f(Event e) {
                                GQuery thisItem = $(e);
                                String refStr = thisItem.attr("item-ref");
                                int refInt = Integer.parseInt(refStr);
                                if (refInt <= content.length() - 1) {
                                    current.setIntVal(refInt);
                                    content.removeClass("bk-content-current").eq(current.getIntVal())
                                            .addClass("bk-content-current");
                                }
                                return false;
                            }
                        });
                    }
                });

                // TOC link
                tocLinks.each(new Function() {
                    @Override
                    public void f(Element e) {
                        GQuery item = $(e);
                        item.bind(Event.ONCLICK, new Function() {
                            @Override
                            public boolean f(Event e) {
                                current.setIntVal(0);
                                content.removeClass("bk-content-current").eq(current.getIntVal())
                                        .addClass("bk-content-current");
                                return false;
                            }
                        });
                    }
                });

                // Link buttons
                linkContentBtns.each(new Function() {
                    @Override
                    public void f(Element e) {
                        GQuery btn = $(e);
                        btn.bind(Event.ONCLICK, new Function() {
                            @Override
                            public boolean f(Event e) {
                                GQuery thisAnchor = $(e);
                                String href = thisAnchor.attr("href");
                                Window.open(href, "_black", "");
                                return false;
                            }
                        });
                    }
                });

                // Download content buttons
                downloadContentBtns.each(new Function() {
                    @Override
                    public void f(Element e) {
                        GQuery btn = $(e);
                        btn.bind(Event.ONCLICK, new Function() {
                            @Override
                            public boolean f(Event e) {
                                GQuery thisAnchor = $(e);
                                String assetId = thisAnchor.attr("bookassetid");
                                downloadBookAssetEvent.fire(new DownloadBookAssetEvent(assetId));
                                return false;
                            }
                        });
                    }
                });

                // view content buttons
                viewContentBtns.each(new Function() {
                    @Override
                    public void f(Element e) {
                        GQuery btn = $(e);

                        // fire action if they are not disabled
                        btn.bind(Event.ONCLICK, new Function() {
                            @Override
                            public boolean f(Event e) {
                                GQuery thisAnchor = $(e);
                                String disabledStr = thisAnchor.attr("disabled");
                                boolean disabled = (disabledStr != null ? Boolean.parseBoolean(disabledStr)
                                        : false);
                                if (disabled == false) {
                                    String assetId = thisAnchor.attr("bookassetid");
                                    String contentTypeKey = thisAnchor.attr("viewable-content-key");
                                    showViewBookassetDialogEvent
                                            .fire(new ShowViewBookassetDialogEvent(assetId, contentTypeKey));
                                }
                                return false;
                            }
                        });
                    }
                });
            }
        }
    });

    // Add Tooltips
    $("[rel=tooltip]", bookList.getParentElement()).as(Tooltip).tooltip();
}

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

License:Open Source License

/**
 * Remove all events from list/*from   w w w . ja v a 2s . c om*/
 */
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 noResults(String terms) {
    GQuery noResults = $(ChozenTemplate.templates.noResults(css.noResults(), resultsNoneFound).asString());
    noResults.find("span").html(terms);

    searchResults.append(noResults);//from w  w  w.j  ava 2s.c o  m

}

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

License:Open Source License

public void setLabel(final String label) {
    this.label = label;

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

        link.text(label);/*from   w w  w.j  a va 2 s.c  o m*/
        if (image.length() > 0) {
            link.prepend(image);
        }
    }
}

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();/* ww  w.  j a  va2s . c  om*/
        } else if (img.length() > 0) {
            img.replaceWith(image.getElement());
        } else {
            link.prepend(image.getElement());
        }
    }
}