Exemple #1
0
 public override void Dispose()
 {
     base.Dispose();
     _elmMedium = null;
     _elmMediumCheckboxInput = null;
     _elmMediumLabel         = null;
     _elmSmall = null;
     _elmSmallCheckboxInput = null;
 }
Exemple #2
0
        internal override void AttachDOMElementsForDisplayMode(string displayMode)
        {
            Span elm = (Span)Browser.Document.GetById(Id + "-" + displayMode);

            this.StoreElementForDisplayMode(elm, displayMode);

            // Only do hookup for non-menu display modes for now
            switch (displayMode)
            {
            case "Medium":
                _elmMedium = elm;
                _elmMediumCheckboxInput = (Input)elm.FirstChild;
                _elmMediumLabel         = (MSLabel)elm.ChildNodes[1];
                break;

            case "Small":
                _elmSmall = elm;
                _elmSmallCheckboxInput = (Input)elm.FirstChild;
                break;
            }
        }
Exemple #3
0
 public override void Dispose()
 {
     base.Dispose();
     _elmMedium = null;
     _elmMediumCheckboxInput = null;
     _elmMediumLabel = null;
     _elmSmall = null;
     _elmSmallCheckboxInput = null;
 }
Exemple #4
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            string alt = string.IsNullOrEmpty(Properties.Alt) ?
                        Properties.LabelText : Properties.Alt;
            alt = CUIUtility.SafeString(alt);

            switch (displayMode)
            {
                case "Small":
                    // Create DOM elements
                    _elmSmall = new Span();
                    _elmSmall.ClassName = "ms-cui-cbx";
                    _elmSmall.SetAttribute("mscui:controltype", ControlType);

                    _elmSmallCheckboxInput = new Input();
                    _elmSmallCheckboxInput.Type = "checkbox";
                    _elmSmallCheckboxInput.ClassName = "ms-cui-cbx-input";
                    _elmSmallCheckboxInput.Id = _id + "-Small-checkbox";
                    if (string.IsNullOrEmpty(Properties.ToolTipTitle))
                    {
                        _elmSmallCheckboxInput.Title = alt;
                    }

                    _elmSmallCheckboxInput.SetAttribute("role", AriaRole);
                    Utility.SetAriaTooltipProperties(Properties, _elmSmallCheckboxInput);

                    // Set up event handlers
                    AttachEvents(_elmSmallCheckboxInput, null);

                    //Build DOM Structure
                    _elmSmall.AppendChild(_elmSmallCheckboxInput);

                    return _elmSmall;
                case "Medium":
                    // Create DOM elements
                    _elmMedium = new Span();
                    _elmMedium.ClassName = "ms-cui-cbx";
                    _elmMedium.SetAttribute("mscui:controltype", ControlType);

                    _elmMediumCheckboxInput = new Input();
                    _elmMediumCheckboxInput.Type = "checkbox";
                    _elmMediumCheckboxInput.ClassName = "ms-cui-cbx-input";
                    _elmMediumCheckboxInput.Id = _id + "-Medium-checkbox";
                    if (string.IsNullOrEmpty(Properties.ToolTipTitle))
                    {
                        _elmMediumCheckboxInput.Title = alt;

                    }
                    _elmMediumCheckboxInput.SetAttribute("role", AriaRole);
                    Utility.SetAriaTooltipProperties(Properties, _elmMediumCheckboxInput);

                    bool hasLabel = false;
                    if (!string.IsNullOrEmpty(Properties.LabelText))
                    {
                        _elmMediumLabel = new MSLabel();
                        if (BrowserUtility.InternetExplorer7)
                        {
                            _elmMediumLabel.SetAttribute("htmlFor", _id + "-Medium-checkbox");
                        }
                        else
                        {
                            _elmMediumLabel.SetAttribute("for", _id + "-Medium-checkbox");
                        }
                        UIUtility.SetInnerText(_elmMediumLabel, Properties.LabelText);
                        hasLabel = true;
                    }

                    // Set up event handlers
                    AttachEvents(_elmMediumCheckboxInput, _elmMediumLabel);

                    // Build DOM Structure
                    _elmMedium.AppendChild(_elmMediumCheckboxInput);
                    if (hasLabel)
                        _elmMedium.AppendChild(_elmMediumLabel);

                    return _elmMedium;
                default:
                    EnsureValidDisplayMode(displayMode);
                    return null;
            }
        }
Exemple #5
0
        internal override void AttachDOMElementsForDisplayMode(string displayMode)
        {
            Span elm = (Span)Browser.Document.GetById(Id + "-" + displayMode);
            this.StoreElementForDisplayMode(elm, displayMode);

            // Only do hookup for non-menu display modes for now
            switch (displayMode)
            {
                case "Medium":
                    _elmMedium = elm;
                    _elmMediumCheckboxInput = (Input)elm.FirstChild;
                    _elmMediumLabel = (MSLabel)elm.ChildNodes[1];
                    break;
                case "Small":
                    _elmSmall = elm;
                    _elmSmallCheckboxInput = (Input)elm.FirstChild;
                    break;
            }
        }
Exemple #6
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            string alt = string.IsNullOrEmpty(Properties.Alt) ?
                         Properties.LabelText : Properties.Alt;

            alt = CUIUtility.SafeString(alt);

            switch (displayMode)
            {
            case "Small":
                // Create DOM elements
                _elmSmall           = new Span();
                _elmSmall.ClassName = "ms-cui-cbx";
                _elmSmall.SetAttribute("mscui:controltype", ControlType);

                _elmSmallCheckboxInput           = new Input();
                _elmSmallCheckboxInput.Type      = "checkbox";
                _elmSmallCheckboxInput.ClassName = "ms-cui-cbx-input";
                _elmSmallCheckboxInput.Id        = _id + "-Small-checkbox";
                if (string.IsNullOrEmpty(Properties.ToolTipTitle))
                {
                    _elmSmallCheckboxInput.Title = alt;
                }

                _elmSmallCheckboxInput.SetAttribute("role", AriaRole);
                Utility.SetAriaTooltipProperties(Properties, _elmSmallCheckboxInput);

                // Set up event handlers
                AttachEvents(_elmSmallCheckboxInput, null);

                //Build DOM Structure
                _elmSmall.AppendChild(_elmSmallCheckboxInput);

                return(_elmSmall);

            case "Medium":
                // Create DOM elements
                _elmMedium           = new Span();
                _elmMedium.ClassName = "ms-cui-cbx";
                _elmMedium.SetAttribute("mscui:controltype", ControlType);

                _elmMediumCheckboxInput           = new Input();
                _elmMediumCheckboxInput.Type      = "checkbox";
                _elmMediumCheckboxInput.ClassName = "ms-cui-cbx-input";
                _elmMediumCheckboxInput.Id        = _id + "-Medium-checkbox";
                if (string.IsNullOrEmpty(Properties.ToolTipTitle))
                {
                    _elmMediumCheckboxInput.Title = alt;
                }
                _elmMediumCheckboxInput.SetAttribute("role", AriaRole);
                Utility.SetAriaTooltipProperties(Properties, _elmMediumCheckboxInput);

                bool hasLabel = false;
                if (!string.IsNullOrEmpty(Properties.LabelText))
                {
                    _elmMediumLabel = new MSLabel();
                    if (BrowserUtility.InternetExplorer7)
                    {
                        _elmMediumLabel.SetAttribute("htmlFor", _id + "-Medium-checkbox");
                    }
                    else
                    {
                        _elmMediumLabel.SetAttribute("for", _id + "-Medium-checkbox");
                    }
                    UIUtility.SetInnerText(_elmMediumLabel, Properties.LabelText);
                    hasLabel = true;
                }

                // Set up event handlers
                AttachEvents(_elmMediumCheckboxInput, _elmMediumLabel);

                // Build DOM Structure
                _elmMedium.AppendChild(_elmMediumCheckboxInput);
                if (hasLabel)
                {
                    _elmMedium.AppendChild(_elmMediumLabel);
                }

                return(_elmMedium);

            default:
                EnsureValidDisplayMode(displayMode);
                return(null);
            }
        }
Exemple #7
0
 internal static Label CreateHiddenLabel(string text)
 {
     Label ret = new Label();
     ret.SetAttribute("unselectable", "on");
     ret.ClassName = "ms-cui-hidden";
     UIUtility.SetInnerText(ret, text);
     return ret;
 }
Exemple #8
0
        static protected Anchor CreateStandardControlDOMElementCore(
            Control control,
            Root root,
            string displayMode,
            string id,
            string image32by32,
            string image32by32Class,
            string image32by32Top,
            string image32by32Left,
            string image16by16,
            string image16by16Class,
            string image16by16Top,
            string image16by16Left,
            string labelText,
            string labelCss,
            string alt,
            string description,
            string tooltipTitle,
            bool menu,
            bool arrow)
        {
            // O14:503464 - Missing label text should be empty instead of "undefined"
            if (string.IsNullOrEmpty(labelText))
            {
                labelText = "";
            }

            bool   isMenu           = false;
            bool   needsHiddenLabel = true;
            Anchor elm = Utility.CreateNoOpLink();

            string outerStyle = null;

            if (displayMode == "Large")
            {
                outerStyle = "ms-cui-ctl-large";
            }
            else if (displayMode == "Medium")
            {
                outerStyle = "ms-cui-ctl-medium";
            }
            else if (displayMode == "Menu16" || displayMode == "Menu")
            {
                outerStyle = "ms-cui-ctl-menu";
                isMenu     = true;
            }
            else if (displayMode == "Menu32")
            {
                outerStyle = "ms-cui-ctl-menu ms-cui-ctl-menu32";
                isMenu     = true;
            }
            else
            {
                outerStyle = "ms-cui-ctl";
            }

            Utility.EnsureCSSClassOnElement(elm, outerStyle);

            if (displayMode == "Menu")
            {
                Utility.EnsureCSSClassOnElement(elm, "ms-cui-textmenuitem");
            }

            if (!string.IsNullOrEmpty(tooltipTitle))
            {
                elm.SetAttribute("aria-describedby", id + "_ToolTip");
            }

            elm.SetAttribute("mscui:controltype", control.ControlType);

            // Create the image
            Image elmImage = new Image();

            string           imageUrl   = null;
            string           imageClass = null;
            string           imageTop   = null;
            string           imageLeft  = null;
            ImgContainerSize imgSize    = ImgContainerSize.None;

            elmImage.Alt = "";
            alt          = string.IsNullOrEmpty(alt) ? labelText : alt;
            elm.SetAttribute("role", control.AriaRole);
            if (control is FlyoutAnchor)
            {
                elm.SetAttribute("aria-haspopup", "true");
            }

            if (string.IsNullOrEmpty(tooltipTitle))
            {
                elm.Title        = alt;
                elmImage.Alt     = alt;
                needsHiddenLabel = false;
            }

            if (displayMode == "Large" || displayMode == "Menu32")
            {
                imageUrl   = image32by32;
                imageClass = image32by32Class;
                imageTop   = image32by32Top;
                imageLeft  = image32by32Left;
                imgSize    = ImgContainerSize.Size32by32;
            }
            else
            {
                imageUrl   = image16by16;
                imageClass = image16by16Class;
                imageTop   = image16by16Top;
                imageLeft  = image16by16Left;
                imgSize    = ImgContainerSize.Size16by16;
            }

            Span elmImageCont = Utility.CreateClusteredImageContainerNew(
                imgSize,
                imageUrl,
                imageClass,
                elmImage,
                true,
                false,
                imageTop,
                imageLeft);
            Span elmIconContainer = new Span();

            elmIconContainer.ClassName = displayMode == "Large" ? "ms-cui-ctl-largeIconContainer" : "ms-cui-ctl-iconContainer";
            elmIconContainer.AppendChild(elmImageCont);

            // Create the label
            // The small display mode of controls does not have label text
            // However, controls with arrows like FlyoutAnchor still need
            // this element.
            SPLabel     hiddenLabel = null;
            HtmlElement elmLabel    = null;

            if (needsHiddenLabel)
            {
                hiddenLabel = Utility.CreateHiddenLabel(alt);
            }
            if (displayMode != "Small" || arrow)
            {
                elmLabel = new Span();
                if (displayMode != "Small")
                {
                    if (displayMode == "Large")
                    {
                        Utility.EnsureCSSClassOnElement(elmLabel, "ms-cui-ctl-largelabel");
                        elmLabel.InnerHtml = Utility.FixLargeControlText(labelText, arrow);
                    }
                    else
                    {
                        string text = labelText;
                        if (arrow)
                        {
                            text = text + " ";
                        }

                        Utility.EnsureCSSClassOnElement(elmLabel, "ms-cui-ctl-mediumlabel");
                        UIUtility.SetInnerText(elmLabel, text);
                    }
                    if (!string.IsNullOrEmpty(labelCss))
                    {
                        elmLabel.Style.CssText = labelCss;
                    }
                }
                else
                {
                    // If the displaymode is Small and there is an arrow
                    Utility.EnsureCSSClassOnElement(elmLabel, "ms-cui-ctl-smalllabel");
                    UIUtility.SetInnerText(elmLabel, " ");
                }
            }
            else if (needsHiddenLabel)
            {
                elmLabel = Utility.CreateHiddenLabel(alt);
            }

            // Create the arrow image if one was specified
            Span elmArrowCont = null;

            if (arrow)
            {
                Image elmArrowImage = new Image();
                elmArrowImage.Alt = "";
                if (string.IsNullOrEmpty(tooltipTitle))
                {
                    elmArrowImage.Alt = alt;
                }
                elmArrowCont = Utility.CreateClusteredImageContainerNew(
                    ImgContainerSize.Size5by3,
                    root.Properties.ImageDownArrow,
                    root.Properties.ImageDownArrowClass,
                    elmArrowImage,
                    true,
                    false,
                    root.Properties.ImageDownArrowTop,
                    root.Properties.ImageDownArrowLeft);
            }

            // This is used for Menu32.  It can have a description under the label text.
            Span elmTextContainer   = null;
            Span elmDescriptionText = null;
            Span elmMenu32Clear     = null;

            if (displayMode == "Menu32")
            {
                elmTextContainer           = new Span();
                elmTextContainer.ClassName = "ms-cui-ctl-menulabel";
                Utility.EnsureCSSClassOnElement(elmLabel, "ms-cui-btn-title");
                elmTextContainer.AppendChild(elmLabel);
                if (!string.IsNullOrEmpty(description))
                {
                    elmDescriptionText = new Span();
                    Utility.EnsureCSSClassOnElement(elmDescriptionText, "ms-cui-btn-menu-description");
                    UIUtility.SetInnerText(elmDescriptionText, description);
                    elmDescriptionText.Style.Display = "block";
                    elmTextContainer.AppendChild(elmDescriptionText);
                }
                elmMenu32Clear           = new Span();
                elmMenu32Clear.ClassName = "ms-cui-ctl-menu32clear";
                elmMenu32Clear.InnerHtml = " ";
            }

            elm.AppendChild(elmIconContainer);

            if (!CUIUtility.IsNullOrUndefined(elmLabel))
            {
                if (!CUIUtility.IsNullOrUndefined(elmTextContainer))
                {
                    elm.AppendChild(elmTextContainer);
                    elm.AppendChild(elmMenu32Clear);
                }
                else
                {
                    elm.AppendChild(elmLabel);
                    if (displayMode == "Small" && arrow && needsHiddenLabel) // if no alt is present add a hidden label for MSAA
                    {
                        elm.AppendChild(hiddenLabel);
                    }
                }
                if (!CUIUtility.IsNullOrUndefined(elmArrowCont))
                {
                    elmLabel.AppendChild(elmArrowCont);
                }
            }

            if (isMenu)
            {
                Span elmMenuGlass = Utility.CreateGlassElement();
                elm.AppendChild(elmMenuGlass);
            }

            return(elm);
        }
Exemple #9
0
        static protected Span CreateTwoAnchorControlDOMElementCore(
            Control control,
            Root root,
            string displayMode,
            string id,
            string image32by32,
            string image32by32Class,
            string image32by32Top,
            string image32by32Left,
            string image16by16,
            string image16by16Class,
            string image16by16Top,
            string image16by16Left,
            string labelText,
            string alt,
            string tooltipTitle,
            bool arrow)
        {
            bool needsHiddenLabel = true;

            labelText = CUIUtility.SafeString(labelText);

            // Create the outer <span> element for this two anchor control
            Span elm = new Span();

            if (displayMode == "Large")
            {
                elm.ClassName = "ms-cui-ctl-large";
            }
            else if (displayMode == "Medium")
            {
                elm.ClassName = "ms-cui-ctl ms-cui-ctl-medium";
            }
            else
            {
                elm.ClassName = "ms-cui-ctl ms-cui-ctl-small";
            }

            if (!string.IsNullOrEmpty(tooltipTitle))
            {
                elm.SetAttribute("aria-describedby", id + "_ToolTip");
            }

            elm.SetAttribute("mscui:controltype", control.ControlType);

            Anchor elmA1 = Utility.CreateNoOpLink();
            Anchor elmA2 = Utility.CreateNoOpLink();

            elmA1.ClassName = "ms-cui-ctl-a1";
            elmA2.ClassName = "ms-cui-ctl-a2";
            alt             = string.IsNullOrEmpty(alt) ? labelText : alt;

            // Setting aria properties for screen readers
            elmA1.SetAttribute("role", control.AriaRole);
            elmA2.SetAttribute("role", control.AriaRole);
            elmA2.SetAttribute("aria-haspopup", "true");

            Span elmA1Internal = new Span();

            elmA1Internal.ClassName = "ms-cui-ctl-a1Internal";

            // Create the image
            Image            elmImage   = new Image();
            string           imageUrl   = null;
            string           imageClass = null;
            string           imageTop   = null;
            string           imageLeft  = null;
            ImgContainerSize imgSize    = ImgContainerSize.None;

            elmImage.Alt = "";

            // Display alt only if no supertooltip is present
            if (string.IsNullOrEmpty(tooltipTitle))
            {
                elmA1.Title      = alt;
                elmA2.Title      = alt;
                elmImage.Alt     = alt;
                needsHiddenLabel = false;
            }

            if (displayMode == "Large" || displayMode == "Menu32")
            {
                imageUrl   = image32by32;
                imageClass = image32by32Class;
                imageTop   = image32by32Top;
                imageLeft  = image32by32Left;
                imgSize    = ImgContainerSize.Size32by32;
            }
            else
            {
                imageUrl   = image16by16;
                imageClass = image16by16Class;
                imageTop   = image16by16Top;
                imageLeft  = image16by16Left;
                imgSize    = ImgContainerSize.Size16by16;
            }

            Span elmImageCont = Utility.CreateClusteredImageContainerNew(
                imgSize,
                imageUrl,
                imageClass,
                elmImage,
                true,
                false,
                imageTop,
                imageLeft);

            // Controls lacking a label and with supertooltips need hidden labels
            SPLabel elmHiddenBtnLabel   = null;
            SPLabel elmHiddenArrowLabel = null;

            if (needsHiddenLabel)
            {
                elmHiddenBtnLabel   = Utility.CreateHiddenLabel(alt);
                elmHiddenArrowLabel = Utility.CreateHiddenLabel(alt);
            }

            // Create the label
            // The small display mode of controls does not have label text
            // However, controls with arrows like FlyoutAnchor still need
            // this element.
            Span elmLabel = null;

            if (displayMode != "Small" || arrow)
            {
                elmLabel = new Span();
                if (displayMode != "Small")
                {
                    if (displayMode == "Large")
                    {
                        Utility.EnsureCSSClassOnElement(elmLabel, "ms-cui-ctl-largelabel");
                        elmLabel.InnerHtml = Utility.FixLargeControlText(labelText, arrow);
                    }
                    else if (displayMode == "Medium")
                    {
                        Utility.EnsureCSSClassOnElement(elmLabel, "ms-cui-ctl-mediumlabel");
                        UIUtility.SetInnerText(elmLabel, labelText);
                    }
                }
            }

            Span elmArrowCont = null;

            if (arrow)
            {
                Image elmArrowImage = new Image();
                if (string.IsNullOrEmpty(tooltipTitle))
                {
                    elmArrowImage.Alt = alt;
                }
                elmArrowCont = Utility.CreateClusteredImageContainerNew(
                    ImgContainerSize.Size5by3,
                    root.Properties.ImageDownArrow,
                    root.Properties.ImageDownArrowClass,
                    elmArrowImage,
                    true,
                    false,
                    root.Properties.ImageDownArrowTop,
                    root.Properties.ImageDownArrowLeft);
            }

            elm.AppendChild(elmA1);
            elm.AppendChild(elmA2);
            elmA1.AppendChild(elmA1Internal);
            elmA1Internal.AppendChild(elmImageCont);

            if (!CUIUtility.IsNullOrUndefined(elmLabel))
            {
                if (displayMode == "Large")
                {
                    elmA2.AppendChild(elmLabel);
                    if (needsHiddenLabel)
                    {
                        elmA1.AppendChild(elmHiddenBtnLabel);
                    }
                }
                else
                {
                    elmA1Internal.AppendChild(elmLabel);
                    if (needsHiddenLabel)
                    {
                        elmA2.AppendChild(elmHiddenArrowLabel);
                    }
                }

                if (displayMode == "Small" && needsHiddenLabel)
                {
                    elmA1.AppendChild(elmHiddenBtnLabel);
                }
            }
            if (!CUIUtility.IsNullOrUndefined(elmArrowCont))
            {
                if (displayMode == "Large")
                {
                    elmLabel.AppendChild(elmArrowCont);
                }
                else
                {
                    elmA2.AppendChild(elmArrowCont);
                }
            }

            return(elm);
        }