Ejemplo n.º 1
0
        /// <summary>
        /// Returns all CSS class names applicable to the given container, based on its
        /// state.  The array of class names returned includes the renderer's own CSS
        /// class, followed by a CSS class indicating the container's orientation,
        /// followed by any state-specific CSS classes.
        /// </summary>
        /// <param name="container">Container whose CSS classes are to be</param>
        ///     returned.
        /// <returns>Array of CSS class names applicable to the
        ///      container.</returns>
        public JsArray <string> getClassNames(goog.ui.Container container)
        {
            var baseClass    = this.getCssClass();
            var isHorizontal =
                container.getOrientation() == goog.ui.Container.Orientation.HORIZONTAL;
            var classNames = new JsArray <string> {
                baseClass, (isHorizontal ? le.getCssName(baseClass, "horizontal") :
                            le.getCssName(baseClass, "vertical"))
            };

            if (!container.isEnabled())
            {
                classNames.Push(le.getCssName(baseClass, "disabled"));
            }
            return(classNames);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Takes a container and an element that may contain child elements, decorates
 /// the child elements, and adds the corresponding components to the container
 /// as child components.  Any non-element child nodes (e.g. empty text nodes
 /// introduced by line breaks in the HTML source) are removed from the element.
 /// </summary>
 /// <param name="container">Container whose children are to be</param>
 ///     discovered.
 /// <param name="element">Element whose children are to be decorated.</param>
 /// <param name="opt_firstChild">the first child to be decorated.</param>
 public void decorateChildren(
     goog.ui.Container container, HTMLElement element, HTMLElement opt_firstChild = null)
 {
     if (element != null)
     {
         var  node = opt_firstChild ?? element.FirstChild;
         Node next;
         // Tag soup HTML may result in a DOM where siblings have different parents.
         while (node != null && node.ParentNode == element)
         {
             // Get the next sibling here, since the node may be replaced or removed.
             next = node.NextSibling;
             if (node.NodeType == NodeType.Element)
             {
                 // Decorate element node.
                 var child = this.getDecoratorForChild((HTMLElement)node);
                 if (child != null)
                 {
                     // addChild() may need to look at the element.
                     child.setElementInternal((HTMLElement)node);
                     // If the container is disabled, mark the child disabled too.  See
                     // bug 1263729.  Note that this must precede the call to addChild().
                     if (!container.isEnabled())
                     {
                         child.setEnabled(false);
                     }
                     container.addChild(child);
                     child.decorate((HTMLElement)node);
                 }
             }
             else if (node.NodeValue == null || node.NodeValue.ToString().Trim() == "")
             {
                 // Remove empty text node, otherwise madness ensues (e.g. controls that
                 // use goog-inline-block will flicker and shift on hover on Gecko).
                 element.RemoveChild(node);
             }
             node = next;
         }
     }
 }