/// <summary>
        /// Wraps the given text caption or existing DOM node(s) in a structural element
        /// containing the menu item's contents.
        /// </summary>
        /// <param name="content">Menu item contents.</param>
        /// <param name="dom">DOM helper for document interaction.</param>
        /// <returns>Menu item content element.</returns>
        private HTMLElement createContent(ControlContent content, dom.DomHelper dom)
        {
            var contentClassName = this.getCompositeCssClass_(
                goog.ui.MenuItemRenderer.CompositeCssClassIndex_.CONTENT);

            return(dom.createDom(goog.dom.TagName.DIV, contentClassName, content));
        }
Beispiel #2
0
        /// <summary>
        /// Decorates the element for the UI component. If the element is in the
        /// document, the enterDocument method will be called.
        ///
        /// If goog.ui.Component.ALLOW_DETACHED_DECORATION is false, the caller must
        /// pass an element that is in the document.
        /// </summary>
        /// <param name="element">Element to decorate.</param>
        public void decorate(HTMLElement element)
        {
            if (this.inDocument_)
            {
                throw new Exception(goog.ui.Component.Error.ALREADY_RENDERED);
            }
            else if (element != null && this.canDecorate(element))
            {
                this.wasDecorated_ = true;

                // Set the DOM helper of the component to match the decorated element.
                var doc = goog.dom.getOwnerDocument(element);
                if (this.dom_ == null || this.dom_.getDocument() != doc)
                {
                    this.dom_ = goog.dom.getDomHelper(element);
                }

                // Call specific component decorate logic.
                this.decorateInternal(element);

                // If supporting detached decoration, check that element is in doc.
                if (!goog.ui.Component.ALLOW_DETACHED_DECORATION ||
                    goog.dom.contains(doc, element))
                {
                    this.enterDocument();
                }
            }
            else
            {
                throw new Exception(goog.ui.Component.Error.DECORATE_INVALID);
            }
        }
 /// <summary>
 /// Popup color picker widget.
 /// </summary>
 /// <param name="opt_domHelper">Optional DOM helper.</param>
 /// <param name="opt_colorPicker">Optional color picker to use
 /// for this popup.</param>
 public PopupColorPicker(dom.DomHelper opt_domHelper = null, ColorPicker opt_colorPicker = null)
     : base(opt_domHelper)
 {
     if (opt_colorPicker != null)
     {
         this.colorPicker_ = opt_colorPicker;
     }
 }
Beispiel #4
0
        /// <summary>
        /// A palette is a grid of DOM nodes that the user can highlight or select via
        /// the keyboard or the mouse.  The selection state of the palette is controlled
        /// an ACTION event.  Event listeners may retrieve the selected item using the
        /// {@link #getSelectedItem} or {@link #getSelectedIndex} method.
        ///
        /// Use this class as the base for components like color palettes or emoticon
        /// pickers.  Use {@link #setContent} to set/change the items in the palette
        /// after construction.  See palette.html demo for example usage.
        /// </summary>
        /// <param name="items">Array of DOM nodes to be displayed as items
        /// in the palette grid (limited to one per cell).</param>
        /// <param name="opt_renderer">Renderer used to render or
        /// decorate the palette; defaults to {@link goog.ui.PaletteRenderer}.</param>
        /// <param name="opt_domHelper">Optional DOM helper, used for
        /// document interaction.</param>
        public Palette(JsArray <Node> items, PaletteRenderer opt_renderer = null,
                       dom.DomHelper opt_domHelper = null)
            : base(new ControlContent(items),
                   opt_renderer ?? goog.ui.PaletteRenderer.getInstance(), opt_domHelper)
        {
            this.setAutoStates(
                goog.ui.Component.State.CHECKED | goog.ui.Component.State.SELECTED |
                goog.ui.Component.State.OPENED,
                false);

            this.currentCellControl_ = new goog.ui.Palette.CurrentCell_();
            this.currentCellControl_.setParentEventTarget(this);

            this.lastHighlightedIndex_ = -1;
        }
 public DefaultDatePickerRenderer(string baseCssClass, dom.DomHelper opt_domHelper)
 {
     this.baseCssClass_ = baseCssClass;
     this.dom_          = opt_domHelper ?? goog.dom.getDomHelper();
 }
Beispiel #6
0
 /// <summary>
 /// </summary>
 /// Default implementation of UI component.
 /// <param name="opt_domHelper">Optional DOM helper.</param>
 public Component(dom.DomHelper opt_domHelper = null)
 {
     this.dom_ = opt_domHelper ?? goog.dom.getDomHelper();
 }