Package elemental.dom

Examples of elemental.dom.Element

The articles listed here span the above and include links to the appropriate W3C DOM specification.

While these interfaces are generally shared by most HTML and XML elements, there are more specialized interfaces for particular objects listed in the DOM HTML Specification. Note, however, that these HTML interfaces are "only for [HTML 4.01] and [XHTML 1.0] documents and are not guaranteed to work with any future version of XHTML." The HTML 5 draft does state it aims for backwards compatibility with these HTML interfaces but says of them that "some features that were formerly deprecated, poorly supported, rarely used or considered unnecessary have been removed." One can avoid the potential conflict by moving entirely to DOM XML attribute methods such as getAttribute().

Html , Head , Link , Title , Meta , Base , IsIndex , Style , Body , Form , Select , OptGroup , Option, Input , TextArea , Button , Label , FieldSet , Legend , UList , OList , DList , Directory , Menu , LI , Div , Paragraph , Heading , Quote , Pre , BR , BaseFont , Font , HR , Mod , Anchor , Image , Object , Param , Applet , Map , Area , Script , Table , TableCaption , TableCol , TableSection , TableRow , TableCell , FrameSet , Frame , IFrame


  /**
   * Tests that addEventListener() correctly adds a listener.
   */
  public void testAddEventListener() {
    final Element body = Browser.getDocument().getBody();

    final ListenerDidFire a = new ListenerDidFire();
    final ListenerDidFire b = new ListenerDidFire();
   
    // Ensure that addEventListener works.
    body.addEventListener("click", a, false);
    // Ensure that setOnClick also works.
    body.setOnclick(b);
   
    assertEquals(b, body.getOnclick());

    TestUtils.click(body);
   
    assertTrue(a.didFire());
    assertTrue(b.didFire());
View Full Code Here


   * Tests that removeEventListener() correctly removes the listener, so that no
   * events are fired afterwards.
   */
  @SuppressWarnings("deprecation")
  public void testRemoveEventListener() {
    final Element body = Browser.getDocument().getBody();

    final ListenerDidFire listener = new ListenerDidFire();
   
    // Ensure that EventRemover works.
    body.addEventListener("click", listener, false).remove();
    TestUtils.click(body);
    assertFalse(listener.didFire());
   
    // Ensure that removeEventListener works.
    body.addEventListener("click", listener, false);
    body.removeEventListener("click", listener, false);
    TestUtils.click(body);
    assertFalse(listener.didFire());
   
    // Ensure that onclick = null works.
    body.setOnclick(listener);
    body.setOnclick(null);
    TestUtils.click(body);   
    assertFalse(listener.didFire());   
  }
View Full Code Here

  /**
   * Tests {@link Element#hasClassName(String)}.
   */
  public void testHasClassName() {
    final Element e = btn;
    e.setClassName("jimmy crack corn");
    assertTrue(e.getClassList().contains("jimmy"));
    assertTrue(e.getClassList().contains("crack"));
    assertTrue(e.getClassList().contains("corn"));
    assertFalse(e.getClassList().contains("jim"));
    assertFalse(e.getClassList().contains("popcorn"));

    e.setClassName("turtles");
    assertTrue(e.getClassList().contains("turtles"));
  }
View Full Code Here

  /**
   * Convenience method for creating a new div with a classname.
   */
  private static Element div(String className) {
    final Element e = div();
    e.setClassName(className);
    return e;
  }
View Full Code Here

  /**
   * Handles all DOM events for the app.
   */
  @Override
  public void handleEvent(Event evt) {
    final Element target = (Element) evt.getTarget();

    // Handle searches.
    if (target == search) {
  //      if (((KeyboardEvent)evt).getKeyCode() == 42) {
  //        clearSearch();
View Full Code Here

    results.getStyle().setVisibility(Visibility.HIDDEN);
    results.addEventListener("click", this, false);

    // Browser info indicator.
    // TODO(knorton): Put this in a debug perm.
    final Element info = Browser.getDocument().getElementById("f");
    info.setClassName(css.browserInfo());
    info.setTextContent(getBrowserInfoString());
   
    model = new Model(this);
    model.load();
  }
View Full Code Here

      final int x = (int) (dx * i) + padding;
      final int h = (int) (dy * value) - topPadding;
      final int w = (int) dx - padding * 2;

      // Create the vertical bar.
      final Element bar = div(css.bar());
      final CSSStyleDeclaration barStyle = bar.getStyle();
      barStyle.setLeft(x, Unit.PX);
      barStyle.setBottom("0");
      barStyle.setHeight(h, Unit.PX);
      barStyle.setWidth(w, Unit.PX);

      // Add a count at the top.
      final Element count = div(css.count());
      count.setTextContent("" + value);

      bar.appendChild(count);
      root.appendChild(bar);
    }

    // Render labels
    for (int i = 0, n = histogram.length(); i <= n; ++i) {
      final int x = (int) (dx * i);
      final int w = (int) dx;

      final String time = secondsToTime(i * Model.SECONDS_PER_HISTOGRAM_BUCKET, false);

      final Element label = div(css.label());
      label.setTextContent(time);
      final CSSStyleDeclaration labelStyle = label.getStyle();
      labelStyle.setLeft(x - dx, Unit.PX);
      labelStyle.setWidth(w, Unit.PX);
      root.appendChild(label);

      // TODO(knorton): Heh, that's pretty trashy. I should fix that. :-)
      final Element tick =
          div(time.charAt(time.length() - 1) == '0' && time.charAt(time.length() - 2) == '0'
              ? css.tickMajor() : css.tickMinor());
      tick.getStyle().setLeft(x, Unit.PX);
      root.appendChild(tick);
    }
  }
View Full Code Here

        }
      }
      root.appendChild(icon);
    }

    final Element label;
    if (mouseDownListener != null) {
      label = Elements.createAnchorElement(css.label());
      ((AnchorElement) label).setHref("javascript:;");
      label.addEventListener(Event.MOUSEDOWN, mouseDownListener, false);
    } else {
      label = Elements.createSpanElement(css.label());
    }

    label.setTextContent(name);

    root.appendChild(label);

    return root;
  }
View Full Code Here

  @Override
  public void updateNodeContents(TreeNodeElement<FileTreeNode> treeNode) {
    if (treeNode.getData().isDirectory()) {
      // Update folder icon based on icon state.
      Element icon = treeNode.getNodeLabel().getFirstChildElement();
      icon.setClassName(css.icon());
      if (treeNode.getData().isLoading()) {
        icon.addClassName(css.folderLoading());
      } else if (((DirInfo)treeNode.getData()).isPackage()) {
        icon.addClassName(css.packageIcon());
      } else if (treeNode.isOpen()) {
        icon.addClassName(css.folderOpen());
      } else {
        icon.addClassName(css.folder());
      }
    }
  }
View Full Code Here

    verticalSplit = new SplitPanel(true);
   
    headerEl = Browser.getDocument().createDivElement();
    headerEl.getStyle().setHeight(58, "px");
    Browser.getDocument().getBody().appendChild(headerEl);
    Element el = getView().getElement();
    el.getStyle().setTop(58, "px");
   
    verticalSplit.addChild(middleBar.getElement(), 0.6);
    verticalSplit.addChild(bottomBar.getElement(), 0.4);
    el.appendChild(verticalSplit.getElement());
   
    bar = new ShowableUiComponent<View<?>>() {
      // We aren't using the toolbar just yet.
      @Override
      public void hide() {
View Full Code Here

TOP

Related Classes of elemental.dom.Element

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.