Examples of GQuery


Examples of com.google.gwt.query.client.GQuery

  }

  private static class GQueryUiImpl {

    public GQuery scrollParent(final UiPlugin gQueryUi) {
      GQuery scrollParent;

      if ("fixed".equals(gQueryUi.css("position", false))) {
        return GQuery.$(getViewportElement());
      }

      if (scrollParentPositionTest(gQueryUi)) {
        scrollParent = gQueryUi.parents().filter(new Predicate() {

          public boolean f(Element e, int index) {
            GQuery $e = GQuery.$(e);
            String position = $e.css("position", true);
            return ("relative".equals(position) || "absolute".equals(position) || "fixed"
                .equals(position))
                && isOverflowEnabled($e);
          }
        });
View Full Code Here

Examples of com.google.gwt.query.client.GQuery

  public void testFade() {
    $(e)
    .html(
        "<p id='id1' style='display: inline'>Content 1</p><p id='id2'>Content 2</p><p id='id3'>Content 3</p>");

    final GQuery sectA = $("#id1");
    final GQuery sectB = $("#id2");

    // fadeIn() & fadeOut() are tested with delayed assertions
    sectA.hide();
    sectA.fadeIn(2000);
    sectB.fadeOut(2000);

    // Configure the max duration for this test
    // If the test exceeds the timeout without calling finishTest() it will fail
    delayTestFinish(2500);

    // Delayed assertions at different intervals
    Timer timerShortTime = new Timer() {
      public void run() {
        double o = Double.valueOf(sectA.css("opacity", false));
        assertTrue(
            "'sectA' opacity must be in the interval 0-0.5 but is: " + o, o > 0
                && o < 0.5);
        o = Double.valueOf(sectB.css("opacity", false));
        assertTrue(
            "'sectB' opacity must be in the interval 0.5-1 but is: " + o,
            o > 0.5 && o < 1);
      }
    };
    Timer timerMidTime = new Timer() {
      public void run() {
        assertEquals("inline", sectA.css("display", false));
        assertEquals("", sectB.css("display", false));
        double o = Double.valueOf(sectA.css("opacity", false));
        assertTrue(
            "'sectA' opacity must be in the interval 0.5-1 but is: " + o,
            o > 0.5 && o < 1);
        o = Double.valueOf(sectB.css("opacity", false));
        assertTrue(
            "'sectB' opacity must be in the interval 0-0.5 but is: " + o, o > 0
                && o < 0.5);
      }
    };
    Timer timerLongTime = new Timer() {
      public void run() {
        assertEquals("inline", sectA.css("display", false));
        assertEquals("none", sectB.css("display", false));
        // Last delayed assertion has to stop the test to avoid a timeout
        // failure
        finishTest();
      }
    };
View Full Code Here

Examples of com.google.gwt.query.client.GQuery

  public void testPropertiesAnimationComputeEffects() {
    $(e)
        .html(
            "<div id='parent' style='background-color: yellow; width: 100px; height: 200px; top:130px; position: absolute; left: 130px'><p id='child' style='background-color: pink; width: 100px; height: 100px; position: absolute; padding: 5px; margin: 0px'>Content 1</p></div>");
    GQuery g = $("#child");
    Properties prop1;

    assertEquals("cssprop=marginTop value=-110px start=0 end=-110 unit=px",
        PropertiesAnimation.computeFxProp(g.get(0), "marginTop", "-110px",
            false).toString());
    assertEquals("cssprop=marginLeft value=-110px start=0 end=-110 unit=px",
        PropertiesAnimation.computeFxProp(g.get(0), "marginLeft", "-110px",
            false).toString());
    assertEquals("cssprop=top value=50% start=0 end=50 unit=%",
        PropertiesAnimation.computeFxProp(g.get(0), "top", "50%", false)
            .toString());
    assertEquals("cssprop=left value=50% start=0 end=50 unit=%",
        PropertiesAnimation.computeFxProp(g.get(0), "left", "50%", false)
            .toString());
    assertEquals("cssprop=width value=174px start=100 end=174 unit=px",
        PropertiesAnimation.computeFxProp(g.get(0), "width", "174px", false)
            .toString());
    assertEquals("cssprop=height value=174px start=100 end=174 unit=px",
        PropertiesAnimation.computeFxProp(g.get(0), "height", "174px", false)
            .toString());
    assertEquals("cssprop=padding value=20px start=5 end=20 unit=px",
        PropertiesAnimation.computeFxProp(g.get(0), "padding", "20px", false)
            .toString());

    prop1 = GQuery.$$("marginTop: '-110px', marginLeft: '-110px', top: '50%', left: '50%', width: '174px', height: '174px', padding: '20px'");
    PropertiesAnimation an = new PropertiesAnimation(EasingCurve.swing, g.get(0), prop1);
    an.onStart();
    an.onComplete();

    assertEquals("cssprop=marginTop value=0 start=-110 end=0 unit=px",
        PropertiesAnimation.computeFxProp(g.get(0), "marginTop", "0", false)
            .toString());
    assertEquals("cssprop=marginLeft value=0 start=-110 end=0 unit=px",
        PropertiesAnimation.computeFxProp(g.get(0), "marginLeft", "0", false)
            .toString());
    assertEquals("cssprop=top value=0% start=50 end=0 unit=%", PropertiesAnimation
        .computeFxProp(g.get(0), "top", "0%", false).toString());
    assertEquals("cssprop=left value=0% start=50 end=0 unit=%",
        PropertiesAnimation.computeFxProp(g.get(0), "left", "0%", false)
            .toString());
    assertEquals("cssprop=width value=100px start=174 end=100 unit=px",
        PropertiesAnimation.computeFxProp(g.get(0), "width", "100px", false)
            .toString());
    assertEquals("cssprop=height value=100px start=174 end=100 unit=px",
        PropertiesAnimation.computeFxProp(g.get(0), "height", "100px", false)
            .toString());
    assertEquals("cssprop=padding value=5px start=20 end=5 unit=px",
        PropertiesAnimation.computeFxProp(g.get(0), "padding", "5px", false)
            .toString());

    prop1 = GQuery.$$("marginTop: '0', marginLeft: '0', top: '0%', left: '0%', width: '100px', height: '100px', padding: '5px'");
    an = new PropertiesAnimation(EasingCurve.swing, g.get(0), prop1);
    an.onStart();
    an.onComplete();

    assertEquals("cssprop=marginTop value=-110px start=0 end=-110 unit=px",
        PropertiesAnimation.computeFxProp(g.get(0), "marginTop", "-110px",
            false).toString());
    assertEquals("cssprop=marginLeft value=-110px start=0 end=-110 unit=px",
        PropertiesAnimation.computeFxProp(g.get(0), "marginLeft", "-110px",
            false).toString());
    assertEquals("cssprop=top value=50% start=0 end=50 unit=%",
        PropertiesAnimation.computeFxProp(g.get(0), "top", "50%", false)
            .toString());
    assertEquals("cssprop=left value=50% start=0 end=50 unit=%",
        PropertiesAnimation.computeFxProp(g.get(0), "left", "50%", false)
            .toString());
    assertEquals("cssprop=width value=174px start=100 end=174 unit=px",
        PropertiesAnimation.computeFxProp(g.get(0), "width", "174px", false)
            .toString());
    assertEquals("cssprop=height value=174px start=100 end=174 unit=px",
        PropertiesAnimation.computeFxProp(g.get(0), "height", "174px", false)
            .toString());
    assertEquals("cssprop=padding value=20px start=5 end=20 unit=px",
        PropertiesAnimation.computeFxProp(g.get(0), "padding", "20px", false)
            .toString());
  }
View Full Code Here

Examples of com.google.gwt.query.client.GQuery

  }

  public void testAttrEffect() {
    $(e).html("<table border=1 id=idtest width=440><tr><td width=50%>A</td><td width=50%>B</td></tr></table>");

    final GQuery g = $("#idtest").css("position", "absolute");
    final int duration = 500;

    assertEquals("cssprop=$width attr=width value=+=100 start=440 end=540 unit=",
        PropertiesAnimation.computeFxProp(g.get(0), "$width", "+=100", false).toString());

    delayTestFinish(duration * 3);

    g.as(Effects).
        animate($$("$width: +=100; $border: +=4"), duration, EasingCurve.linear);

    final Timer timer = new Timer() {
      public void run() {
        assertEquals(540.0, Double.parseDouble(g.attr("width")));
        assertEquals(5.0, Double.parseDouble(g.attr("border")));
        finishTest();
      }
    };
    timer.schedule(duration * 2);
  }
View Full Code Here

Examples of com.google.gwt.query.client.GQuery

   * are linked to a widget to adopt them.
   *
   */
  protected void adoptSubWidgets(Element root) {

    GQuery children = $(root).children();

    for (Element child : children.elements()) {
      Widget w = $(child).widget();
      if (w != null) {
        doAdopt(w);
      } else {
        adoptSubWidgets(child);
View Full Code Here

Examples of com.google.gwt.query.client.GQuery

  }
 
  public void testComputeFxPropTransitions() {
    $(e).html("<table border=1 id=idtest><tr><td width=200px>A</td><td width=100px>B</td></tr></table>");
    $("#idtest").css("position", "absolute").find("td");
    final GQuery g = $("#idtest td");
   
    TransitFx fx = (TransitFx)TransitionsAnimation.computeFxProp(g.get(0), "width", "+=100", false);
    assertEquals("10", fx.transitStart.replace(".0",""));
    assertEquals("110", fx.transitEnd.replace(".0",""));
    assertEquals("px", fx.unit);
  }
View Full Code Here

Examples of com.google.gwt.query.client.GQuery

  public void testStop() {
    $(e)
    .html(
        "<p id='id1' style='display: inline'>Content 1</p><p id='id2'>Content 2</p><p id='id3'>Content 3</p>");

    final GQuery sectA = $("#id1");
    final GQuery sectB = $("#id2");
    final GQuery sectC = $("#id2");

    sectA.hide();
    sectA.fadeIn(2000);
    sectB.fadeOut(2000).delay(500).fadeIn(1000);
    sectC.fadeOut(2000).delay(500).fadeIn(1000);

    // Call stop
    Timer timerMidTime = new Timer() {
      public void run() {
        sectA.stop();
        sectB.stop(true, true);
        sectC.stop(false, false);

        Double o  = Double.valueOf(sectA.css("opacity"));
        sectA.data("opacityA", o);
        assertTrue(
            "'sectA' opacity must be in the interval 0.5-1 but is: " + o,
            o > 0.5 && o < 1);

        //animation should jump to the end
        assertEquals("none", sectB.css("display"));

        o = Double.valueOf(sectC.css("opacity"));
        sectC.data("opacityC", o);
        assertTrue(
            "'sectC' opacity must be in the interval 0-0.5 but is: " + o,
            o > 0 && o < 0.5);
      }
    };


    Timer timerLongTime = new Timer() {
      public void run() {
        Double midAOpacity = sectA.data("opacityA", Double.class);
        //animation was stopped, opacity should not change
        assertEquals(midAOpacity, Double.valueOf(sectA.css("opacity")));
        //animation was stopped and jumped to the end, the queue was cleared so no change too.
        assertEquals("none", sectB.css("display"));

        //fadeOut was stopped but fadeIn should continue
        Double midCOpacity = sectC.data("opacityC", Double.class);
        Double laterCOpacity = Double.valueOf(sectC.css("opacity"));
        assertTrue(laterCOpacity > midCOpacity);
        // Last delayed assertion has to stop the test to avoid a timeout
        // failure
        finishTest();
      }
View Full Code Here

Examples of com.google.gwt.query.client.GQuery

    final Widget w = new Label("some animation");
    w.setVisible(false);
    RootPanel.get().add(w);
    w.getElement().setId("e");
    GQuery g = $(w);

    int test_duration = 1000;
    int fx_duration = 200;
    final int loops = test_duration / fx_duration;

    // Queue a set of effects which will use the data cache
    for (int i = 0; i < loops ; i++) {
      final char[] bulk = new char[5*1024*1024]; // let's leak 5MBs
      g.fadeToggle(fx_duration, new Function() {
        public void f() {
          animationRunCounter ++;
          bulk[0] = 0; // we keep it in handler
        }
      });
    }

    // Testing delay as well
    g.delay(fx_duration, new Function(){
      public void f() {
        animationRunCounter ++;
      }
    });

    // We do the assertions after all effects have been run
    g.queue(new Function() {
      public void f() {
        // after running queue method it is mandatory to call dequeue,
        // otherwise the queue get stuck
        $(this).dequeue();
        // Check that all animations and the delayed function has been run
View Full Code Here

Examples of com.google.gwt.query.client.GQuery

    executeSelectInAllImplementations("input[name=\"wantedName\"]", e, 1);
  }

  public void testSelectElementsInsideContext() {
    $(e).html("<spam><p>s</p></spam>");
    GQuery q = $("spam", e);
    // TODO: in XPath engine returns 2 when it should return 1
    executeSelectInAllImplementations("*", q.get(0), 1, 2);
  }
View Full Code Here

Examples of com.google.gwt.query.client.GQuery

  public void testOddEvenNthChild(){

    $(e).append(
              "<div id='parent'><div id='first' class='evenClass' role='treeItem'>branchA target</div><div id='second' class='oddClass' role='treeItem'>branchA target</div><div id='third' class='evenClass' role='treeItem'>branchA target</div><div id='fourth' class='oddClass' role='treeItem'>branchA target</div></div>");

    GQuery odd = $("#parent > div:odd",e);
    assertEquals(2, odd.size());
    for (Element el : odd.elements()){
      assertEquals("oddClass", el.getClassName());
    }

    GQuery even = $("#parent > div:even", e);
    assertEquals(2, even.size());
    for (Element el : even.elements()){
      assertEquals("evenClass", el.getClassName());
    }

    //test filter
    odd = $("#parent > div",e).filter(":odd");
    assertEquals(2, odd.size());
    for (Element el : odd.elements()){
      assertEquals("oddClass", el.getClassName());
    }

    even = $("#parent > div", e).filter(":even");
    assertEquals(2, even.size());
    for (Element el : even.elements()){
      assertEquals("evenClass", el.getClassName());
    }

    //test nth-child
    GQuery second = $("#parent > div",e).filter(":nth-child(2)");
    assertEquals(1, second.size());
    assertEquals("second", second.attr("id"));

    GQuery third =$("#parent > div:nth-child(3)", e);
    assertEquals(1, third.size());
    assertEquals("third", third.attr("id"));

    //test nth-child with function
    GQuery secondAndFourth = $("#parent > div",e).filter(":nth-child(2n)");
    assertEquals(2, secondAndFourth.size());
    assertEquals("second", secondAndFourth.eq(0).attr("id"));
    assertEquals("fourth", secondAndFourth.eq(1).attr("id"));

    // odd and even with attribute filters
    secondAndFourth = $("div[role=treeItem]:odd", e);
    assertEquals("second", secondAndFourth.eq(0).attr("id"));
    assertEquals("fourth", secondAndFourth.eq(1).attr("id"));

    GQuery treeItemFirstAndThird = $("div[role=treeItem]:even", e);
    assertEquals("first", treeItemFirstAndThird.eq(0).attr("id"));
    assertEquals("third", treeItemFirstAndThird.eq(1).attr("id"));
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.