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

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

Introduction

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

Prototype

public String css(String name) 

Source Link

Document

Return a style property on the first matched element.

Usage

From source file:com.arcbees.beestore.client.application.widget.slider.Slider.java

License:Apache License

Function createAnimation(final GQuery w) {
    return new Function() {
        @Override/*  w ww. ja va2s  . c om*/
        public void f() {
            final List<Element> elements = Lists.newArrayList(w.get(0), activeItem.get(0));
            final String indexOfSelected = w.css("order");

            activeAnimation = true;
            activeItem.bind(TRANSITION_END, new Function() {
                @Override
                public void f() {
                    $(this).unbind(TRANSITION_END);

                    activeItem.removeClass(sliderResources.style().activeProduct());
                    w.addClass(sliderResources.style().activeProduct());

                    $(elements).attr("style", "transform: scale(1);");

                    setOrder(w, String.valueOf(ACTIVE_BRAND_INDEX));
                    setOrder(activeItem, indexOfSelected);

                    activeItem = $(w.get(0));
                    queueFinishAnimation();
                }
            });

            $(elements).css("transform", "scale(0.1)");
        }
    };
}

From source file:com.arcbees.beestore.client.application.widget.slider.Slider.java

License:Apache License

private void handleClick(final GQuery w) {
    Function function = createAnimation(w);
    String indexOfSelected = w.css("order");

    if (!isActiveBrand(indexOfSelected)) {
        if (activeAnimation) {
            enforceNumberOfSuccessiveAnimations();
            calls.add(function);//ww w . jav a2s.c o  m
        } else {
            function.f();
        }
    }
}

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

License:Apache License

public void animateListItem(GQuery item, final Boolean addClass) {
    if (getOptions().isMobileAnimation()) {
        final String paddingTop = item.css("padding-top");
        final String paddingBottom = item.css("padding-bottom");
        final int speed = getOptions().getMobileAnimationSpeed();

        item.animate("height: 0, padding-top: 0, padding-bottom: 0", speed, new Function() {
            public void f() {
                $(this).animate(
                        "height: auto, padding-top: " + paddingTop + ", padding-bottom: " + paddingBottom,
                        speed);/*from ww  w.j  a va 2  s .  c om*/
                $(this).toggleClass(getCss().resultSelected(), addClass);
            }
        });
    } else {
        $(this).toggleClass(getCss().resultSelected(), addClass);
    }
}

From source file:com.pronoiahealth.olhie.client.pages.AbstractPage.java

License:Open Source License

/**
 * Add full page scrolling. This can only be done before the page is loaded.
 * //from w w w . jav a  2  s . com
 * @param fullPageScrollingActive
 */
protected void addFullPageScrolling() {
    // Activate full page scrolling
    // Get the root div
    final GQuery gObj = AppSelectors.INSTANCE.getCenterBackground();

    // Called when scrolling stops
    // Timer set in scroll event
    // Address weird Chrome/Safari (Webkit) issue
    // Just asking for some data from the element emitting
    // scroll events seems to refresh the display and
    // help fix the issue
    scrollStopTimer = new Timer() {
        @Override
        public void run() {
            int scrollTop = gObj.scrollTop();
            // gObj.scrollTop(scrollTop + 3);
            // gObj.scrollTop(scrollTop);
        }
    };

    // Make sure its overflow is set to auto
    gObj.css(CSS.OVERFLOW.with(Overflow.AUTO));

    // State of scroll link
    gObj.data("scrollLinkActive", Boolean.FALSE);

    // Create the scroll link
    scrollLink = $("<a href=\"#\" class=\"ph-BulletinBoard-Scrollup\">Scroll</a>");

    final Function fadeIn = new Function() {
        @Override
        public void f(Element e) {
            scrollLink.css(Properties.create("opacity: 1.0;"));
            // super.f(e);
        }
    };

    final Function fadeOut = new Function() {
        @Override
        public void f(Element e) {
            scrollLink.css(Properties.create("opacity: 0.0;"));
            // super.f(e);
        }
    };

    // Append the link to the root div
    gObj.append(scrollLink);

    // Bind the scroll event
    gObj.bind(Event.ONSCROLL, new Function() {
        @Override
        public boolean f(Event e) {
            // GQuery rootDiv = $(e);
            // int scrollTop = rootDiv.scrollTop();
            // Set timer
            scrollStopTimer.cancel();
            scrollStopTimer.schedule(500);

            // Test scroll top
            int scrollTop = gObj.scrollTop();
            boolean scrollLinkActive = (Boolean) gObj.data("scrollLinkActive");
            if (scrollTop >= 100 && scrollLinkActive == false) {
                gObj.data("scrollLinkActive", Boolean.TRUE);
                scrollLink.fadeIn(500, fadeIn);
            } else if (scrollTop < 100 && scrollLinkActive == true) {
                gObj.data("scrollLinkActive", Boolean.FALSE);
                scrollLink.fadeOut(500, fadeOut);
            }

            // return super.f(e);
            return false;
        }
    });

    // Bind to the scrollup link
    scrollLink.bind(Event.ONCLICK, new Function() {
        @Override
        public boolean f(Event e) {
            gObj.animate("scrollTop: 0", 500, (Function) null);
            scrollLink.hide();
            return false;
        }
    });

    this.fullPageScrollingActive = true;
}

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

License:Open Source License

/**
 * Used to add books in after the initial display
 * // w  w  w .ja v a 2  s .c  om
 * @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.scrolldiv.ScrollDiv.java

License:Open Source License

@PostConstruct
protected void postConstruct() {
    // Activate full page scrolling
    // Get the root div
    final GQuery gObj = $(root);

    // Make sure its overflow is set to auto
    gObj.css(CSS.OVERFLOW.with(Overflow.AUTO));

    // Create the scroll link
    scrollLink = $("<a href=\"#\" class=\"ph-BulletinBoard-Scrollup\">Scroll</a>");

    // Append the link to the root div
    gObj.append(scrollLink);// w  w w .  java2 s.  c o  m

    // Bind the scroll event
    gObj.bind(Event.ONSCROLL, new Function() {
        @Override
        public boolean f(Event e) {
            GQuery rootDiv = $(e);
            int scrollTop = rootDiv.scrollTop();
            if (scrollTop > 100) {
                scrollLink.fadeIn(500, new Function() {
                    @Override
                    public void f(com.google.gwt.dom.client.Element e) {
                        $(e).css(Properties.create("opacity: 1.0;"));
                        // super.f(e);
                    }
                });
            } else {
                scrollLink.fadeOut(500, new Function() {
                    @Override
                    public void f(com.google.gwt.dom.client.Element e) {
                        $(e).css(Properties.create("opacity: 0.0;"));
                        // super.f(e);
                    }
                });
            }
            return super.f(e);
        }
    });

    // Bind to the scrollup link
    scrollLink.bind(Event.ONCLICK, new Function() {
        @Override
        public boolean f(Event e) {
            gObj.animate("scrollTop: 0", 500, (Function) null);
            return false;
        }
    });
}

From source file:gwtquery.plugins.draggable.client.DraggableHandler.java

License:Apache License

private void calculateContainment() {
    String containmentAsString = options.getContainment();
    int[] containmentAsArray = options.getContainmentAsArray();
    GQuery $containement = options.getContainmentAsGQuery();

    if (containmentAsArray == null && containmentAsString == null && $containement == null) {
        containment = null;/*from   ww  w  . ja va2 s.  co m*/
        return;
    }

    if (containmentAsArray != null) {
        containment = containmentAsArray;
        return;
    }

    if (containmentAsString != null) {
        if ("window".equals(containmentAsString)) {
            containment = new int[] { 0 /*- relativeOffset.left - parentOffset.left*/,
                    0 /*- relativeOffset.top - parentOffset.top*/,
                    Window.getClientWidth() - helperDimension.getWidth() - margin.left,
                    Window.getClientHeight() - helperDimension.getHeight() - margin.top };

            return;
        }

        if ("parent".equals(containmentAsString)) {
            $containement = $(helper.get(0).getParentElement());
        } else if ("document".equals(containmentAsString)) {
            $containement = $("body");
        } else {
            $containement = $(containmentAsString);
        }
    }

    Element ce = $containement.get(0);
    if (ce == null) {
        return;
    }

    containment = impl.calculateContainment(this, $containement.offset(), ce,
            (!"hidden".equals($containement.css("overflow"))));

}

From source file:gwtquery.plugins.draggable.client.plugins.CursorPlugin.java

License:Apache License

public void onStart(DraggableHandler handler, DragContext ctx, GqEvent e) {

    if (ctx.getInitialDraggable() == ctx.getDraggable() && !isStarting) {
        isStarting = true;/* w  w w .j  a va 2  s .  c om*/
        GQuery $body = $(body);
        String oldCursor = $body.css(CURSOR_CSS);
        if (oldCursor != null) {
            $body.data(OLD_CURSOR_KEY, oldCursor);
        }
        $body.css(CURSOR_CSS, handler.getOptions().getCursor().getCssName());
    }

}