Java Code Examples for gwt.material.design.jquery.client.api.JQueryElement

The following examples show how to use gwt.material.design.jquery.client.api.JQueryElement. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: gwt-material   Source File: ScrollHelper.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Will scroll to target offset.
 */
public void scrollTo(double offset) {
    this.offset = offset;

    ScrollOption option = new ScrollOption();
    JQueryElement target = getContainerElement();
    if (containerElement != getDefaultContainer()) {
        offset = target.scrollTop() - target.offset().top + offset;
    } else {
        target = $("html, body");
    }
    option.scrollTop = offset - addedScrollOffset;

    target.animate(option, duration, easing, () -> {
        if (completeCallback != null) {
            completeCallback.call();
        }
    });
}
 
Example 2
Source Project: gwt-material-addins   Source File: MaterialComboBox.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Will get the Selection Results ul element containing all the combobox items.
 */
public JQueryElement getDropdownResultElement() {
    String dropdownId = getDropdownContainerElement().attr("id").toString();
    if (dropdownId != null && !(dropdownId.isEmpty())) {
        dropdownId = dropdownId.replace("container", "results");
        return $("#" + dropdownId);
    } else {
        GWT.log("The element dropdown-result ul element is undefined.", new NullPointerException());
    }
    return null;
}
 
Example 3
Source Project: gwt-material   Source File: MaterialWidget.java    License: Apache License 2.0 5 votes vote down vote up
public MaterialWidget(JQueryElement jQueryElement) {
    this();

    setElement(jQueryElement.asElement());

    // We are already attached to the DOM.
    // This will happen in instances where
    // we are taking an element from JQuery.
    onAttach();
}
 
Example 4
Source Project: gwt-material   Source File: ScrollHelper.java    License: Apache License 2.0 5 votes vote down vote up
public boolean isInViewPort(Element element, double addedHeight) {
    double elementTop = getElementTop(element) + addedHeight;
    double elementBottom = elementTop + $(element).outerHeight() + addedHeight;

    JQueryElement target = getContainerElement();
    double viewportTop = target.scrollTop();

    if (target.asElement() != getDefaultContainer()) {
        viewportTop = getElementTop(target.asElement());
    }

    double viewportBottom = viewportTop + target.height();

    return elementBottom > viewportTop && elementTop < viewportBottom;
}
 
Example 5
Source Project: gwt-material-addins   Source File: MaterialSplitPanel.java    License: Apache License 2.0 5 votes vote down vote up
protected void applySplitterLineColor(Color splitterLineColor) {
    if (splitterLineColor != null) {
        JQueryElement splitterBar = $(getElement()).find(".splitter-bar");
        if (splitterBar != null) {
            MaterialWidget widget = new MaterialWidget(splitterBar);
            widget.setBackgroundColor(splitterLineColor);
        }
    }
}
 
Example 6
Source Project: gwt-material   Source File: TooltipMixin.java    License: Apache License 2.0 5 votes vote down vote up
public void addTooltipClass(String... classes) {
    JQueryElement tooltipElement = this.tooltip.getTooltipElement();
    if (tooltipElement != null) {
        for (String tooltipClass : classes) {
            tooltipElement.addClass(tooltipClass);
        }
    }
}
 
Example 7
Source Project: gwt-material   Source File: OverlayStyleMixin.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void applyOverlayStyle(JQueryElement overlayElement) {
    this.overlayElement = overlayElement;

    applyBackgroundColor(overlayOption.getBackgroundColor());
    applyBlur(overlayOption.getBlur(), false);
    applyOpacity(overlayOption.getOpacity());
    applyVisibility(overlayOption.getVisibility());
}
 
Example 8
Source Project: gwt-material   Source File: OverlayStyleMixin.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Will apply the blur into the provided list of {@link JQueryElement}.
 * If reset was true then we set the filter property to empty value.
 */
protected void applyBlur(Blur blur, boolean reset) {
    if (blur != null && blur.getTargets() != null) {
        for (JQueryElement target : blur.getTargets()) {
            String blurValue = "blur(" + blur.getValue() + "px)";
            if (reset) {
                 blurValue = "";
            }
            target.css("filter",  blurValue != null ? blurValue : "");
        }
    }
}
 
Example 9
Source Project: gwt-material   Source File: MaterialListValueBox.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public void load() {
    JQueryElement listBoxElement = $(listBox.getElement());
    JsMaterialElement.$(listBox.getElement()).material_select(() -> $("input.select-dropdown").trigger("close", true));
    listBoxElement.change((e, param) -> {
        try {
            ValueChangeEvent.fire(this, getValue());
        } catch (IndexOutOfBoundsException ex) {
            GWT.log("ListBox value change handler threw an exception.", ex);
        }
        return true;
    });

    JQueryElement selectDropdown = listBoxElement.siblings("input.select-dropdown");
    selectDropdown.mousedown((event, o) -> {
        $("input[data-activates!='" + listBoxElement.attr("data-activates") + "'].select-dropdown").trigger("close", true);
        return true;
    });

    selectDropdown.blur((e, param1) -> {
        DomEvent.fireNativeEvent(Document.get().createBlurEvent(), this);
        return true;
    });

    selectDropdown.focus((e, param1) -> {
        DomEvent.fireNativeEvent(Document.get().createFocusEvent(), this);

        if (isAsynchronous() && !isLoaded()) {
            load(getAsyncCallback());
        }

        return true;
    });

    if (isAllowBlank()) {
        addBlankItemIfNeeded();
    }
}
 
Example 10
Source Project: gwt-material-addins   Source File: ContinuousRangeSlider.java    License: Apache License 2.0 5 votes vote down vote up
protected void updateDom(Integer value) {
    JQueryElement sliderFill = $(getElement()).find(".slider-fill");
    JQueryElement sliderHandler = $(getElement()).find(".slider-handle");
    double percent = (value * 1.0 / getMax()) * 100;
    if (sliderFill != null && sliderHandler != null) {
        sliderFill.css("width", percent + "%");
        sliderHandler.css("left", percent + "%");
    }
}
 
Example 11
Source Project: gwt-material-addins   Source File: DragEventDispatcher.java    License: Apache License 2.0 5 votes vote down vote up
public void fireDragLeaveEvent(JQueryElement relatedTarget) {
    target.fireEvent(new GwtEvent<DragLeaveEvent.DragLeaveHandler>() {
        @Override
        public Type<DragLeaveEvent.DragLeaveHandler> getAssociatedType() {
            return DragLeaveEvent.TYPE;
        }

        @Override
        protected void dispatch(DragLeaveEvent.DragLeaveHandler handler) {
            handler.onDragLeave(new DragLeaveEvent(relatedTarget));
        }
    });
}
 
Example 12
Source Project: gwt-material-addins   Source File: DropEventDispatcher.java    License: Apache License 2.0 5 votes vote down vote up
public void fireDropEvent(JQueryElement relatedTarget) {
    target.fireEvent(new GwtEvent<DropEvent.DropHandler>() {
        @Override
        public Type<DropEvent.DropHandler> getAssociatedType() {
            return DropEvent.TYPE;
        }

        @Override
        protected void dispatch(DropEvent.DropHandler handler) {
            handler.onDrop(new DropEvent(relatedTarget));
        }
    });
}
 
Example 13
Source Project: gwt-material-addins   Source File: MaterialComboBox.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Will get the Selection dropdown container rendered
 */
public JQueryElement getDropdownContainerElement() {
    JQueryElement element = $(getElement()).find(".select2 .selection .select2-selection__rendered");
    if (element == null) {
        GWT.log("The element dropdown-container element is undefined.", new NullPointerException());
    }
    return element;
}
 
Example 14
Source Project: gwt-material   Source File: MaterialWidget.java    License: Apache License 2.0 4 votes vote down vote up
public static JQueryElement window() {
    if (window == null) {
        window = $(JQuery.window());
    }
    return window;
}
 
Example 15
Source Project: gwt-material   Source File: MaterialWidget.java    License: Apache License 2.0 4 votes vote down vote up
public JQueryElement $this() {
    if ($this == null) {
        $this = JQuery.$(this);
    }
    return $this;
}
 
Example 16
Source Project: gwt-material   Source File: MaterialWidget.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public JQueryElement getTooltipElement() {
    return getTooltipMixin().getTooltipElement();
}
 
Example 17
Source Project: gwt-material   Source File: ScrollHelper.java    License: Apache License 2.0 4 votes vote down vote up
public JQueryElement getContainerElement() {
    if (containerElement == null) {
        return $("html, body");
    }
    return $(containerElement);
}
 
Example 18
Source Project: gwt-material   Source File: AbstractSideNav.java    License: Apache License 2.0 4 votes vote down vote up
public JQueryElement getOverlayElement() {
    return $("#sidenav-overlay");
}
 
Example 19
Source Project: gwt-material-addins   Source File: JsBubble.java    License: Apache License 2.0 4 votes vote down vote up
@JsMethod
public native JQueryElement bubble(JsBubbleOptions options);
 
Example 20
Source Project: gwt-material   Source File: TooltipMixin.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public JQueryElement getTooltipElement() {
    return tooltip.getTooltipElement();
}
 
Example 21
Source Project: gwt-material   Source File: MaterialPreLoader.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void applyOverlayStyle(JQueryElement overlayElement) {
    getOverlayStyleMixin().applyOverlayStyle(overlayElement);
}
 
Example 22
Source Project: gwt-material   Source File: MaterialTooltip.java    License: Apache License 2.0 4 votes vote down vote up
public JQueryElement getTooltipElement() {
    return tooltipElement;
}
 
Example 23
Source Project: gwt-material   Source File: MaterialToast.java    License: Apache License 2.0 4 votes vote down vote up
public JQueryElement getElement() {
    return element;
}
 
Example 24
Source Project: gwt-material   Source File: MaterialDialog.java    License: Apache License 2.0 4 votes vote down vote up
public void setOverlayElement(JQueryElement overlayElement) {
    this.overlayElement = overlayElement;
}
 
Example 25
Source Project: gwt-material   Source File: MaterialDialog.java    License: Apache License 2.0 4 votes vote down vote up
public JQueryElement getOverlayElement() {
    return overlayElement;
}
 
Example 26
Source Project: gwt-material   Source File: MaterialDialog.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void applyOverlayStyle(JQueryElement overlayElement) {
    getOverlayStyleMixin().applyOverlayStyle(overlayElement);
}
 
Example 27
Source Project: gwt-material   Source File: MaterialProgress.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public void applyOverlayStyle(JQueryElement overlayElement) {
    getOverlayStyleMixin().applyOverlayStyle(overlayElement);
}
 
Example 28
Source Project: gwt-material   Source File: JsMaterialElement.java    License: Apache License 2.0 4 votes vote down vote up
@JsMethod(name = "$", namespace = JsPackage.GLOBAL)
public static native JsMaterialElement $(JQueryElement element);
 
Example 29
Source Project: gwt-material   Source File: JsMaterialElement.java    License: Apache License 2.0 4 votes vote down vote up
@JsMethod
public native JQueryElement tabs(String method, String id);
 
Example 30
Source Project: gwt-material-addins   Source File: JsCarousel.java    License: Apache License 2.0 4 votes vote down vote up
@JsMethod(name = "$", namespace = JsPackage.GLOBAL)
public static native JsCarousel $(JQueryElement element);