Example #1
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);
            }
        }
Example #2
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;
            }
        }
Example #3
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;
 }