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

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

Introduction

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

Prototype

public int width() 

Source Link

Document

Get the current computed, pixel, width of the first matched element.

Usage

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

License:Apache License

protected int getSideBorderPadding(GQuery elmt, boolean isHidden) {
    if (isHidden) {
        // bug in gquery when one parent of the element is hidden
        return (int) (elmt.cur("padding-left", true) + elmt.cur("padding-right", true)
                + elmt.cur("border-left-width", true) + elmt.cur("border-right-width", true));
    }//from  w w w .j  a  v  a  2s.com
    return elmt.outerWidth() - elmt.width();
}

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 ww  w .java2 s  .c  o m

    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.watopi.chosen.client.ChosenImpl.java

License:Open Source License

private int getSideBorderPadding(GQuery elmt, boolean isHidden) {
    if (isHidden) {
        //bug in gquery when one parent of the element is hidden
        return (int) (elmt.cur("padding-left", true) + elmt.cur("padding-right", true)
                + elmt.cur("border-left-width", true) + elmt.cur("border-right-width", true));
    }/*from www  .j a  v a2 s.com*/
    return elmt.outerWidth() - elmt.width();
}

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

License:Open Source License

private void searchFieldScale() {
    if (!isMultiple) {
        return;/*from  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:gwtquery.samples.client.GwtQueryBenchModule.java

License:Apache License

/**
 * Initialize the track with the horses//w  ww .  j  a  v a  2 s  .  co  m
 */
private void initTrack(Benchmark... benchs) {
    if (!useTrack)
        return;
    String tpl = "<div id=%ID%horse class=horse><nobr><img class=himg src=images/bench/horse.gif><span>%ID%</span></nobr></div>";
    GQuery g = $("#racefield").html("");
    for (Benchmark b : benchs) {
        String id = b.getId();
        String lg = id.contains("gwt") ? "gwt" : id;
        String s = tpl.replaceAll("%ID%", id).replaceAll("%LG%", lg);
        g.append($(s));
    }

    GQuery flag = $("<img class=flag src='images/bench/animated-flag.gif'/>").appendTo(document);

    // These values are set in the css.
    int horseHeight = 35;
    int horseWidth = 150;
    int flagWidth = 35;

    int height = horseHeight * (benchs.length + 1);
    $("#racetrack").css("height", height + "px");

    trackWidth = g.width() - horseWidth - flagWidth;
    flag.hide();
}

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

License:Apache License

private void searchFieldScale() {
    if (!isMultiple) {
        return;//  w  w  w.j  a  v  a  2s  .  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");
}