Package com.google.gwt.query.client

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


  }

  public static Fx computeFxNumericProp(Element e, String key, String val,
      boolean hidden) {

    GQuery g = Effects.$(e);
    String unit = "";
    if ("toggle".equals(val)) {
      val = hidden ? "show" : "hide";
    }

    if (("show".equals(val) && !hidden) || ("hide").equals(val) && hidden) {
      return null;
    }

    if (hidden) {
      g.show();
    }

    // If key starts with $ we animate node attributes, otherwise css properties
    double cur;
    String rkey = null;
    if (key.startsWith("$")) {
      rkey = key.substring(1).toLowerCase();
      String attr = g.attr(rkey);
      MatchResult parts = REGEX_NUMBER_UNIT.exec(attr);
      if (parts != null) {
        String $1 = parts.getGroup(1);
        String $2 = parts.getGroup(2);
        cur = Double.parseDouble($1);
        unit = $2 == null ? "" : $2;
      } else {
        cur = g.cur(key, true);
        key = rkey;
      }
    } else {
      cur = g.cur(key, true);
    }

    double start = cur, end = start;

    if ("show".equals(val)) {
      g.saveCssAttrs(key);
      start = 0;
      unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : "px";
    } else if ("hide".equals(val)) {
      if (hidden) {
        return null;
      }
      g.saveCssAttrs(key);
      end = 0;
      unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : "px";
    } else {
      MatchResult parts = REGEX_SYMBOL_NUMBER_UNIT.exec(val);

      if (parts != null) {
        String $1 = parts.getGroup(1);
        String $2 = parts.getGroup(2);
        String $3 = parts.getGroup(3);
        end = Double.parseDouble($2);

        if (rkey == null) {
          unit = REGEX_NON_PIXEL_ATTRS.test(key) ? "" : //
            $3 == null || $3.isEmpty() ? "px" : $3;
          if (!"px".equals(unit)) {
            double to = end == 0 ? 1 : end;
            g.css(key, to + unit);
            start = to * start / g.cur(key, true);
            g.css(key, start + unit);
          }
        } else if ($3 != null && !$3.isEmpty()) {
          unit = $3;
        }

View Full Code Here


  }

  public void onModuleLoad() {
    // Ask GWT compiler to generate our interface
    final Slide s = GWT.create(Slide.class);
    final GQuery slides = $(s.allSlides());

    // we initially hide all slides and bullets
    slides.hide().eq(0).as(Effects).clipAppear();
    $(s.allSlideBullets()).hide();


    // add onclick handler to body element
    $(slides).click(new Function() {
      // two state variables to note current slide being shown
      // and current bullet
      int curSlide = 0;
      int curBullets = 0;

      // query and store all bullets of current slide
      GQuery bullets = $(s.slideBulletsCtx(slides.get(curSlide)));

      public boolean f(Event e) {
        // onclick, if not all bullets shown, show a bullet and increment
        if (curBullets < bullets.size()) {
          bullets.eq(curBullets++).as(Effects).fadeIn(Speed.SLOW);
        } else {
          // all bullets shown, hide them and current slide
          bullets.hide();

          // move to next slide, checking for wrap around
          int lastSlide = curSlide++;
          if (curSlide == slides.size()) {
            curSlide = 0;
          }

          // query for new set of bullets, and show next slide
          curBullets = 0;
          bullets = $(s.slideBulletsCtx(slides.get(curSlide)));

          // Hide the last slide and show the next when the effects finishes
          slides.eq(lastSlide).as(Effects).fadeOut(new Function() {
            public void f(Element e) {
              slides.eq(curSlide).as(Effects).clipAppear();
            }
          });
        }
        return true;
      }
View Full Code Here

    Element td = grid.getCellFormatter().getElement(selnumber + 1, benchnumber + 1);
    DOM.scrollIntoView((com.google.gwt.user.client.Element) td);
  }

  private void flagWinner(String idWinner) {
    GQuery g = $("#" + idWinner + "horse" + " nobr");
    $(".flag").appendTo(g).show();
  }
View Full Code Here

   */
  private void initSelects(Benchmark... benchs) {
    String opt = "<input type='checkbox' name='n' value='%ID%' %SEL%>%ID%</input><br/>";
    selectPanel.add(new HTML("<div id=selectcontainer><strong>Make your selection</strong><hr/></div>"));
    selectPanel.show();
    GQuery g = $("#selectcontainer");
    for (Benchmark b : benchs) {
      String select = opt;
      for (String s : defaultBenchmarks) {
        if (s.equals(b.getId())) {
          select = select.replaceAll("%SEL%", "checked='checked'");
        }
      }
      g.append(select.replaceAll("%ID%", b.getId() + " " + b.getName()).replaceAll("%SEL", ""));
    }
    g.append("<br/><button id=run>Run</button>");
    $("#run").click(runBenchMarks);
    selectPanel.hide();
  }
View Full Code Here

   * Initialize the track with the horses
   */
  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();
  }
View Full Code Here

    for (double d : totalTimes) {
      winnerTime = Math.min(winnerTime, d);
    }
    double winnerPos = row * (double) trackWidth / (double) ds.length;
    for (int i = 0; i < b.length; i++) {
      GQuery g = $("#" + b[i].getId() + "horse");
      double pos =   winnerPos * winnerTime / totalTimes[i];
      g.css("left", (int)pos + "px");
    }
  }
View Full Code Here

    public void enable() {
        enabled = true;
    }

    public void hide() {
        GQuery tooltip = getTip();

        tooltip.removeClass(style.in());

        if (options.isAnimation()) {
            tooltip.fadeOut(ANIMATION_DURATION, new Function() {
                @Override
                public void f() {
                    detach();
                }
            });
View Full Code Here

        $(document).unbind("click", autocloseFunction);
    }

    public void show() {
        GQuery tooltip = getTip();

        if (getTip().hasClass(style.in())) {
            return;
        }

        assignWidget();
        if (!enabled || noContentInTooltip()) {
            return;
        }

        tooltip.detach()
                .removeClass(style.in(), style.top(), style.bottom(), style.left(), style.right())
                .css("top", "0")
                .css("left", "0")
                .css("display", "block");

        String container = options.getContainer();

        if (container == null || "parent".equals(container)) {
            tooltip.insertAfter($element);
        } else if ("element".equals(container)) {
            tooltip.appendTo($element);
        } else {
            tooltip.appendTo($(container));
        }

        setContent();

        showTooltip();
View Full Code Here

            doShowTooltip();
        }
    }

    private void doShowTooltip() {
        GQuery tooltip = getTip();

        OffsetInfo oi = OffsetInfo.from($element);
        long actualWidth = tooltip.get(0).getOffsetWidth();
        long actualHeight = tooltip.get(0).getOffsetHeight();
        long finalTop = -1;
        long finalLeft = -1;
        String placementClass = null;

        switch (getPlacement()) {
            case BOTTOM:
                finalTop = oi.top + oi.height;
                finalLeft = oi.left + oi.width / 2 - actualWidth / 2;
                placementClass = style.bottom();
                break;
            case TOP:
                finalTop = oi.top - actualHeight;
                finalLeft = oi.left + oi.width / 2 - actualWidth / 2;
                placementClass = style.top();
                break;
            case LEFT:
                finalTop = oi.top + oi.height / 2 - actualHeight / 2;
                finalLeft = oi.left - actualWidth;
                placementClass = style.left();
                break;
            case RIGHT:
                finalTop = oi.top + oi.height / 2 - actualHeight / 2;
                finalLeft = oi.left + oi.width;
                placementClass = style.right();
                break;
        }

        Offset additionalOffset = getAdditionalOffset();
        if (additionalOffset != null) {
            finalTop += additionalOffset.top;
            finalLeft += additionalOffset.left;
        }

        tooltip.offset((int) finalTop, (int) finalLeft);
        tooltip.addClass(placementClass)
                .addClass(style.in());

        if (options.getTrigger() == TooltipTrigger.CLICK && options.isAutoClose()) {
            $(document).delay(1, new Function() {
                @Override
View Full Code Here

        return (title == null && widget == null) || (title != null && title.length() == 0);
    }

    private boolean onDocumentClick(Event e) {
        Element target = e.getEventTarget().cast();
        GQuery $e = $(target);

        // Ensure that the user didn't click on the tooltip
        if ($e.parents("." + style.tooltip()).length() == 0) {
            hide();
        }
        return false;
    }
View Full Code Here

TOP

Related Classes of com.google.gwt.query.client.GQuery

Copyright © 2018 www.massapicom. 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.