Examples of GQuery


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

   * @param aPosition position to convert
   * @return
   */
  public Offset convertPositionTo(boolean absolute, Offset aPosition) {
    int mod = absolute ? 1 : -1;
    GQuery scroll = getScrollParent();
    boolean scrollIsRootNode = isRootNode(scroll.get(0));

    int top = aPosition.top
        + relativeOffset.top
        * mod
        + parentOffset.top
        * mod
        - ("fixed".equals(helperCssPosition) ? -helperScrollParent.scrollTop()
        : scrollIsRootNode ? 0 : scroll.scrollTop()) * mod;

    int left = aPosition.left
        + relativeOffset.left
        * mod
        + parentOffset.left
        * mod
        - ("fixed".equals(helperCssPosition) ? -helperScrollParent.scrollLeft()
        : scrollIsRootNode ? 0 : scroll.scrollLeft()) * mod;

    return new Offset(left, top);

  }
View Full Code Here

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

  }

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

    if (containmentAsArray == null && containmentAsString == null
        && $containement == null) {
      containment = null;
      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"))));

  }
View Full Code Here

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

    return new Offset(0, 0);
  }

  private Offset generatePosition(GqEvent e, boolean initPosition) {

    GQuery scroll = getScrollParent();
    boolean scrollIsRootNode = isRootNode(scroll.get(0));

    int pageX = e.pageX();
    int pageY = e.pageY();

    if (!initPosition) {
      if (containment != null && containment.length == 4) {
        if (e.pageX() - offsetClick.left < containment[0]) {
          pageX = containment[0] + offsetClick.left;
        }
        if (e.pageY() - offsetClick.top < containment[1]) {
          pageY = containment[1] + offsetClick.top;
        }
        if (e.pageX() - offsetClick.left > containment[2]) {
          pageX = containment[2] + offsetClick.left;
        }
        if (e.pageY() - offsetClick.top > containment[3]) {
          pageY = containment[3] + offsetClick.top;
        }
      }

      if (options.getGrid() != null) {
        int[] grid = options.getGrid();
        int roundedTop = originalEventPageY
            + Math.round((pageY - originalEventPageY) / grid[1]) * grid[1];
        int roundedLeft = originalEventPageX
            + Math.round((pageX - originalEventPageX) / grid[0]) * grid[0];

        if (containment != null && containment.length == 4) {
          boolean isOutOfContainment0 = roundedLeft - offsetClick.left < containment[0];
          boolean isOutOfContainment1 = roundedTop - offsetClick.top < containment[1];
          boolean isOutOfContainment2 = roundedLeft - offsetClick.left > containment[2];
          boolean isOutOfContainment3 = roundedTop - offsetClick.top > containment[3];

          pageY = !(isOutOfContainment1 || isOutOfContainment3) ? roundedTop
              : (!isOutOfContainment1) ? roundedTop - grid[1] : roundedTop
              + grid[1];
          pageX = !(isOutOfContainment0 || isOutOfContainment2) ? roundedLeft
              : (!isOutOfContainment0) ? roundedLeft - grid[0] : roundedLeft
              + grid[0];

        } else {
          pageY = roundedTop;
          pageX = roundedLeft;
        }

      }
    }

    int top = pageY
        - offsetClick.top
        - relativeOffset.top
        - parentOffset.top
        + ("fixed".equals(helperCssPosition) ? -helperScrollParent.scrollTop()
        : scrollIsRootNode ? 0 : scroll.scrollTop());

    int left = pageX
        - offsetClick.left
        - relativeOffset.left
        - parentOffset.left
        + ("fixed".equals(helperCssPosition) ? -helperScrollParent.scrollLeft()
        : scrollIsRootNode ? 0 : scroll.scrollLeft());
    return new Offset(left, top);
  }
View Full Code Here

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

  private boolean isElementAttached(GQuery $element) {
    // normally this test helper.parents().filter("body").length() == 0 is
    // sufficient but they are a bug in gwtquery in filter function
    // return helper.parents().filter("body").length() == 0;
    GQuery parents = $element.parents();
    for (Element parent : parents.elements()) {
      if (parent == body) {
        return true;
      }
    }
    return false;
View Full Code Here

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

  public void onHelperChange(ChangeEvent e) {
    HelperType type = HelperType.valueOf(helperListBox.getValue(helperListBox
        .getSelectedIndex()));

    if (type == HelperType.ELEMENT) {
      GQuery helper = $("<div class=\"myHelper\" style=\"width: 150px;height: 150px;\">I'm a custom helper</div>");
      getOptions().setHelper(helper);
    } else {
      getOptions().setHelper(type);
    }
  }
View Full Code Here

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

   * the container) defining by the selector.
   *
   * @param containment Widget takes as the container element.
   */
  public void setContainment(Widget container) {
    GQuery $container = $(container.getElement());
    options.setContainment($container);
  }
View Full Code Here

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

  public void onStart(DraggableHandler handler, DragContext ctx,
                      GqEvent e) {
    Element draggableElement = ctx.getDraggable();
    List<SnapElement> snapElements = new ArrayList<SnapElement>();
    GQuery snap = (handler.getOptions().getSnap_$() != null ? handler
        .getOptions().getSnap_$() : $(handler.getOptions().getSnap()));

    for (Element element : snap.elements()) {
      if (element != draggableElement) {
        GQuery $element = $(element);
        snapElements.add(new SnapElement($element.offset(), $element.outerWidth(),
            $element.outerHeight()));
      }
    }
    $(draggableElement).data(SNAP_ELEMENTS_KEY, snapElements);

  }
View Full Code Here

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

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

  public void onStart(DraggableHandler handler, DragContext ctx,
                      GqEvent e) {
    GQuery $element = (handler.getOptions().getHelperType() == HelperType.ORIGINAL) ? $(ctx.getDraggable()) : handler.getHelper();
    if ($element == null || $element.length() == 0) {
      return;
    }
    //String oldZIndex = $element.css(ZINDEX_CSS);
    String oldZIndex = getZIndex($element.get(0).getStyle());
    if (oldZIndex != null) {
      $element.data(OLD_ZINDEX_KEY, oldZIndex);
    }
    $element.css(ZINDEX_CSS, handler.getOptions().getZIndex().toString());

  }
View Full Code Here

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

  }

  public void onStop(DraggableHandler handler, DragContext ctx, GqEvent e) {
    //helper can be null if the draggableElement was unloaded and after loaded
    GQuery $element = (handler.getOptions().getHelperType() == HelperType.ORIGINAL) ? handler.getHelper() : $(ctx.getDraggable());
    if ($element == null || $element.length() == 0) {
      return;
    }
    String oldZIndex = $element.data(OLD_ZINDEX_KEY, String.class);
    $element.css(ZINDEX_CSS, oldZIndex);
  }
View Full Code Here

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

  public void onStart(DraggableHandler handler, DragContext ctx,
                      GqEvent e) {
    Float opacity = handler.getOptions().getOpacity();

    GQuery $helper = handler.getHelper();

    double oldOpacity = $helper.cur(OPACITY_CSS_KEY, true);
    $helper.data(OLD_OPACITY_KEY, new Double(oldOpacity));

    $helper.css(OPACITY_CSS_KEY, opacity.toString());

  }
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.