Exemple #1
0
        internal override void RefreshInternal()
        {
            ToolbarProperties props = (ToolbarProperties)Properties;
            bool twoRow             = (CUIUtility.SafeString(props.Size) == DataNodeWrapper.TWOROW);

            // Create the outer DOM Element of the toolbar if it hasn't been created yet
            if (CUIUtility.IsNullOrUndefined(ElementInternal))
            {
                CreateToolbarStructure(twoRow);
            }

            ElementInternal = Utility.RemoveChildNodes(ElementInternal);

            if (twoRow)
            {
                // Add the toolbar structure to the page
                ElementInternal.AppendChild(_elmToolbarTopBars);

                // Add the buttondocks
                AppendChildrenToElement(_elmTopBar2);
            }
            else
            {
                // Add the jewel to the toolbar
                if (_hasJewel)
                {
                    ElementInternal.AppendChild(_elmJewelPlaceholder);
                }

                // Add the buttondocks
                AppendChildrenToElement(ElementInternal);
            }

            Dirty = false;
        }
Exemple #2
0
        /// <summary>
        /// Tab constructor
        /// </summary>
        /// <param name="ribbon">the Ribbon that created this Tab and that it is a part of</param>
        /// <param name="id">Component id of the Tab</param>
        /// <param name="title">Title of the Tab</param>
        /// <param name="description">Description of the Tab</param>
        /// <param name="contextual">whether this Tab is a contextual Tab or not</param>
        /// <param name="command">the command for this Tab.  Used in enabling or disabling the tab.</param>
        /// <param name="contextualGroupId">the id of the ContextualGroup that this Tab is a part of.</param>
        internal Tab(SPRibbon ribbon,
                     string id,
                     string title,
                     string description,
                     string command,
                     bool contextual,
                     string contextualGroupId,
                     string cssClass)
            : base(ribbon, id, title, description)
        {
            _lastScalingIndex  = -1;
            _scalingInfo       = new Scaling();
            _contextual        = contextual;
            _contextualGroupId = CUIUtility.SafeString(contextualGroupId);
            _command           = CUIUtility.SafeString(command);
            _cssClass          = CUIUtility.SafeString(cssClass);

            // Contextual tabs are invisible by default
            if (contextual)
            {
                VisibleInternal = false;
            }
#if DEBUG
            if (command == "DEBUG_ALWAYS_ENABLED")
            {
                VisibleInternal = true;
            }
#endif
        }
Exemple #3
0
        internal override void AttachDOMElementsForDisplayMode(string displayMode)
        {
            Span elm = (Span)Browser.Document.GetById(Id + "-" + displayMode);

            StoreElementForDisplayMode(elm, displayMode);
            currentDisplayMode = displayMode;

            switch (displayMode)
            {
            case "Large":
            {
                if (!CUIUtility.IsNullOrUndefined(elm))
                {
                    _elmLarge = elm;
                }
                _elmLargeButton     = (Anchor)_elmLarge.ChildNodes[0];
                _elmLargeImgCont    = (Span)_elmLargeButton.ChildNodes[0].ChildNodes[0];
                _elmLargeMenuButton = (Anchor)_elmLarge.ChildNodes[1];
                HtmlElement elmLargeLabel = (HtmlElement)_elmLargeMenuButton.ChildNodes[0];

                _elmLargeArrowImg = null;
                // We might have a <br> and/or text nodes in here, so we have to search for the element we want
                HtmlElementCollection candidates = elmLargeLabel.GetElementsByTagName("span");
                foreach (HtmlElement elt in candidates)
                {
                    string tag = elt.TagName;
                    if (CUIUtility.SafeString(tag) == "span")
                    {
                        _elmLargeArrowImg = (Image)elt.ChildNodes[0];
                        break;
                    }
                }
                break;
            }

            case "Medium":
                if (!CUIUtility.IsNullOrUndefined(elm))
                {
                    _elmMedium = elm;
                }
                _elmMediumButton     = (Anchor)_elmMedium.ChildNodes[0];
                _elmMediumImgCont    = (Span)_elmMediumButton.ChildNodes[0].ChildNodes[0];
                _elmMediumMenuButton = (Anchor)_elmMedium.ChildNodes[1];
                _elmMediumArrowImg   = (Image)_elmMediumMenuButton.ChildNodes[1].ChildNodes[0];
                break;

            case "Small":
                if (!CUIUtility.IsNullOrUndefined(elm))
                {
                    _elmSmall = elm;
                }
                _elmSmallButton     = (Anchor)_elmSmall.ChildNodes[0];
                _elmSmallImgCont    = (Span)_elmSmallButton.ChildNodes[0].ChildNodes[0];
                _elmSmallMenuButton = (Anchor)_elmSmall.ChildNodes[1];
                _elmSmallArrowImg   = (Image)_elmSmallMenuButton.ChildNodes[1].ChildNodes[0];
                break;
            }
        }
Exemple #4
0
        public static string GetAttribute(object data, string attributeName)
        {
            // We don't want to do a bunch of checks in here because of performance
            // We assume that the attribute is present and crash if it is not
            // If we need something that is more forgiving, we can add another one
            // that does the checks but is slower GetNodeAttributeWithChecks() etc.
            JSObject attrsNode = GetNodeAttributes(data);

            return(CUIUtility.SafeString(attrsNode.GetField <string>(attributeName)));
        }
Exemple #5
0
        private string GetCellTitle(int row, int column)
        {
            string title = Properties.Alt;

            if (string.IsNullOrEmpty(title))
            {
                title = CUIUtility.SafeString(Properties.MenuSectionTitle);
            }
            title = String.Format(title, column.ToString(), row.ToString());
            return(title);
        }
Exemple #6
0
        private void UnselectAll()
        {
            for (int i = 0; i < 100; i++)
            {
                _innerDivs[i].ClassName = "ms-cui-it-inactiveCell";
                _outerDivs[i].ClassName = "ms-cui-it-inactiveCellOuter";
            }

            _oldIdx = -1;
            string title = CUIUtility.SafeString(Properties.MenuSectionInitialTitle);

            HostMenuSection.SetTitleImmediate(title);
        }
Exemple #7
0
        internal override void PollForStateAndUpdate()
        {
            // Attaching a command to the label is not required
            if (string.IsNullOrEmpty(Properties.Command))
            {
                return;
            }

            bool succeeded = PollForStateAndUpdateInternal(Properties.Command,
                                                           Properties.QueryCommand,
                                                           StateProperties,
                                                           false);

            // Only update the state if there is a query command and the poll for state was successful
            if (succeeded && !string.IsNullOrEmpty(Properties.QueryCommand))
            {
                string strInnerTextSav = CUIUtility.SafeString(_strInnerText);

                if (!string.IsNullOrEmpty(StateProperties[LabelCommandProperties.Value]))
                {
                    UIUtility.SetInnerText(_elmDefaultLabel, StateProperties[LabelCommandProperties.Value]);
                    _strInnerText = StateProperties[LabelCommandProperties.Value];
                }
                else
                {
                    UIUtility.SetInnerText(_elmDefaultLabel, Properties.LabelText);
                    _strInnerText = Properties.LabelText;
                }

                // If we're changed the size of the label, then the
                // whole ribbon may need to be re-scaled.
                if (_strInnerText != strInnerTextSav)
                {
                    Root.NeedScaling = true;
                }
            }
        }
Exemple #8
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 #9
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            string alt        = CUIUtility.SafeString(Properties.Alt);
            string altArrow   = CUIUtility.SafeString(Properties.AltArrow);
            bool   needsLabel = true;

            if (string.IsNullOrEmpty(altArrow) && !string.IsNullOrEmpty(Properties.ToolTipTitle))
            {
                altArrow = Properties.ToolTipTitle;
            }

            MSLabel elmHiddenLabel;

            switch (displayMode)
            {
            case "Text":     // Remove once project's ribbon doesn't use it anymore
            case "Medium":
                // Top Level Element
                _elmMedium           = new Span();
                _elmMedium.ClassName = "ms-cui-dd";
                _elmMedium.SetAttribute("mscui:controltype", ControlType);

                // Selected Item Element
                _elmMediumSelectedItem             = new Span();
                _elmMediumSelectedItem.ClassName   = "ms-cui-dd-text";
                _elmMediumSelectedItem.Style.Width = Properties.Width;

                string dictKey = DropDownCommandProperties.SelectedItemId;
                string itemId  = StateProperties.ContainsKey(dictKey) ? StateProperties[dictKey] : "";
                if (string.IsNullOrEmpty(itemId))
                {
                    itemId = Properties.InitialItem;
                }
                if (!string.IsNullOrEmpty(itemId))
                {
                    SelectMenuItemById(itemId);
                }

                // Arrow Button Element
                _elmMediumBtnA = new Anchor();
                _elmMediumBtnA.SetAttribute("role", AriaRole);
                _elmMediumBtnA.SetAttribute("aria-haspopup", "true");
                Utility.EnsureCSSClassOnElement(_elmMediumBtnA, "ms-cui-dd-arrow-button");
                Utility.SetAriaTooltipProperties(Properties, _elmMediumBtnA);
                Utility.NoOpLink(_elmMediumBtnA);
                _elmMediumBtnA.Id = Id;
                _elmMediumArwImg  = new Image();

                _elmMediumArwImgCont = Utility.CreateClusteredImageContainerNew(
                    ImgContainerSize.Size5by3,
                    Root.Properties.ImageDownArrow,
                    Root.Properties.ImageDownArrowClass,
                    _elmMediumArwImg,
                    true,
                    false,
                    Root.Properties.ImageDownArrowTop,
                    Root.Properties.ImageDownArrowLeft
                    );

                if (string.IsNullOrEmpty(Properties.ToolTipTitle))
                {
                    _elmMediumBtnA.SetAttribute("title", altArrow);
                    _elmMediumSelectedItem.Title = alt;
                    _elmMediumArwImg.Alt         = altArrow;
                    needsLabel = false;
                }

                // Set up event handlers for the Drop Down Arrow Button
                AttachEventsForDisplayMode("Medium");

                // Build DOM Structure
                _elmMedium.AppendChild(_elmMediumSelectedItem);
                _elmMedium.AppendChild(_elmMediumBtnA);
                _elmMediumBtnA.AppendChild(_elmMediumArwImgCont);

                if (needsLabel)
                {
                    elmHiddenLabel = Utility.CreateHiddenLabel(altArrow);
                    _elmMediumBtnA.AppendChild(elmHiddenLabel);
                }

                return(_elmMedium);

            default:
                EnsureValidDisplayMode(displayMode);
                return(null);
            }
        }
Exemple #10
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            bool    needsLabel = true;
            string  alt        = CUIUtility.SafeString(Properties.Alt);
            string  width      = (displayMode == "Medium" && !string.IsNullOrEmpty(Properties.Width)) ? Properties.Width : "auto";
            MSLabel hiddenLabel;
            string  itemId = StateProperties[DropDownCommandProperties.SelectedItemId];

            if (string.IsNullOrEmpty(itemId))
            {
                itemId = Properties.InitialItem;
            }

            _buildingDOMElement = true;

            switch (displayMode)
            {
            case "Large":

                _elmLarge = new Span();
                _elmLarge.SetAttribute("mscui:controltype", ControlType);
                // _elmLarge.ClassName = "ms-cui-sb";
                Utility.EnsureCSSClassOnElement(_elmLarge, "ms-cui-ctl-large");

                _elmLargeSelectedItem           = new Span();
                _elmLargeSelectedItem.ClassName = "ms-cui-mrusb-selecteditem";

                if (!SelectMenuItemById(itemId))
                {
                    if (!Utility.IsTrue(Properties.PopulateDynamically))
                    {
                        throw new InvalidOperationException("No menu item with id '" + Properties.InitialItem + "' exists in this control's menu");
                    }
                    else
                    {
                        _elmLargeSelectedItem.Style.Width  = "32px";
                        _elmLargeSelectedItem.Style.Height = "32px";
                    }
                }

                _elmLargeBtn               = new Anchor();
                _elmLargeBtn.ClassName     = "ms-cui-ctl-a2";
                _elmLargeBtn.Style.Display = "block";
                _elmLargeBtn.SetAttribute("role", AriaRole);
                _elmLargeBtn.SetAttribute("aria-haspopup", true.ToString());

                Utility.NoOpLink(_elmLargeBtn);
                Utility.SetAriaTooltipProperties(Properties, _elmLargeBtn);

                _elmLargeArrowImg = new Image();
                Span elmLargeArrowImgCont = Utility.CreateClusteredImageContainerNew(
                    ImgContainerSize.Size5by3,
                    Root.Properties.ImageDownArrow,
                    Root.Properties.ImageDownArrowClass,
                    _elmLargeArrowImg,
                    true,
                    false,
                    Root.Properties.ImageDownArrowTop,
                    Root.Properties.ImageDownArrowLeft
                    );

                if (string.IsNullOrEmpty(Properties.ToolTipTitle))
                {
                    needsLabel            = false;
                    _elmLargeBtn.Title    = alt;
                    _elmLargeArrowImg.Alt = alt;
                }

                // Set up event handlers for the drop down button
                AttachEventsForDisplayMode(displayMode);

                // Build DOM structure
                _elmLargeBtn.AppendChild(elmLargeArrowImgCont);

                if (needsLabel)
                {
                    hiddenLabel = Utility.CreateHiddenLabel(alt);
                    _elmLargeBtn.AppendChild(hiddenLabel);
                }
                _elmLarge.AppendChild(_elmLargeSelectedItem);
                _elmLarge.AppendChild(_elmLargeBtn);

                _buildingDOMElement = false;
                return(_elmLarge);

            case "Medium":
                _elmMedium = new Span();
                _elmMedium.SetAttribute("mscui:controltype", ControlType);
                _elmMedium.ClassName = "ms-cui-ctl-medium ms-cui-ctl";

                _elmMediumSelectedItem             = new Span();
                _elmMediumSelectedItem.ClassName   = "ms-cui-mrusb-selecteditem";
                _elmMediumSelectedItem.Style.Width = width;
                if (!SelectMenuItemById(itemId))
                {
                    throw new InvalidOperationException("No menu item with id '" + Properties.InitialItem + "' exists in this control's menu");
                }

                _elmMediumBtn = new Anchor();
                Utility.NoOpLink(_elmMediumBtn);
                Utility.SetAriaTooltipProperties(Properties, _elmMediumBtn);
                _elmMediumBtn.ClassName = "ms-cui-ctl";
                _elmMediumBtn.SetAttribute("role", AriaRole);
                _elmMediumBtn.SetAttribute("aria-haspopup", true.ToString());
                _elmMediumArrowImg = new Image();
                if (string.IsNullOrEmpty(Properties.ToolTipTitle))
                {
                    needsLabel             = false;
                    _elmMediumBtn.Title    = alt;
                    _elmMediumArrowImg.Alt = alt;
                }

                Span _elmMediumArrowImgCont = Utility.CreateClusteredImageContainerNew(
                    ImgContainerSize.Size5by3,
                    Root.Properties.ImageDownArrow,
                    Root.Properties.ImageDownArrowClass,
                    _elmMediumArrowImg,
                    true,
                    false,
                    Root.Properties.ImageDownArrowTop,
                    Root.Properties.ImageDownArrowLeft
                    );


                // Set up event handlers for the drop down button
                AttachEventsForDisplayMode(displayMode);

                //Build DOM structure
                _elmMediumBtn.AppendChild(_elmMediumArrowImgCont);
                if (needsLabel)
                {
                    hiddenLabel = Utility.CreateHiddenLabel(alt);
                    _elmMediumBtn.AppendChild(hiddenLabel);
                }
                _elmMedium.AppendChild(_elmMediumSelectedItem);
                _elmMedium.AppendChild(_elmMediumBtn);

                _buildingDOMElement = false;
                return(_elmMedium);

            case "Small":
                _elmSmall = new Span();
                _elmSmall.SetAttribute("mscui:controltype", ControlType);
                _elmSmall.ClassName               = "ms-cui-ctl-medium ms-cui-ctl";
                _elmSmallSelectedItem             = new Span();
                _elmSmallSelectedItem.ClassName   = "ms-cui-mrusb-selecteditem";
                _elmSmallSelectedItem.Style.Width = width;
                if (!SelectMenuItemById(itemId))
                {
                    throw new InvalidOperationException("No menu item with id '" + Properties.InitialItem + "' exists in this control's menu");
                }

                _elmSmallBtn = new Anchor();
                Utility.NoOpLink(_elmSmallBtn);
                Utility.SetAriaTooltipProperties(Properties, _elmSmallBtn);
                _elmSmallBtn.SetAttribute("role", AriaRole);
                _elmSmallBtn.SetAttribute("aria-haspopup", true.ToString());
                _elmSmallBtn.ClassName = "ms-cui-ctl ms-cui-mrusb-arwbtn";
                _elmSmallArrowImg      = new Image();

                if (string.IsNullOrEmpty(Properties.ToolTipTitle))
                {
                    _elmSmallBtn.Title    = alt;
                    _elmSmallArrowImg.Alt = alt;
                    needsLabel            = false;
                }

                Span _elmSmallArrowImgCont = Utility.CreateClusteredImageContainerNew(
                    ImgContainerSize.Size5by3,
                    Root.Properties.ImageDownArrow,
                    Root.Properties.ImageDownArrowClass,
                    _elmSmallArrowImg,
                    true,
                    false,
                    Root.Properties.ImageDownArrowTop,
                    Root.Properties.ImageDownArrowLeft
                    );

                // Set up event handlers for the drop down button
                AttachEventsForDisplayMode(displayMode);

                //Build DOM structure
                _elmSmallBtn.AppendChild(_elmSmallArrowImgCont);
                if (needsLabel)
                {
                    hiddenLabel = Utility.CreateHiddenLabel(alt);
                    _elmSmallBtn.AppendChild(hiddenLabel);
                }
                _elmSmall.AppendChild(_elmSmallSelectedItem);
                _elmSmall.AppendChild(_elmSmallBtn);

                _buildingDOMElement = false;
                return(_elmSmall);

            default:
                _buildingDOMElement = false;
                EnsureValidDisplayMode(displayMode);
                return(null);
            }
        }
Exemple #11
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            if (displayMode != "Default")
            {
                EnsureValidDisplayMode(displayMode);
                return(null);
            }

            string alt = CUIUtility.SafeString(Properties.Alt);

            // Create Elements
            _elmDefault = new Span();

            _elmDefault.Id        = Properties.Id + "-Default";
            _elmDefault.ClassName = "ms-cui-jewel-jewelMenuLauncher";

            _elmDefaultA = new Anchor();
            Utility.NoOpLink(_elmDefaultA);
            _elmDefaultA.Title = alt;

            _inLabelMode = !string.IsNullOrEmpty(Properties.LabelText);

            if (!_inLabelMode)
            {
                _elmDefaultImg = new Image();

                _elmDefaultImgCont = Utility.CreateClusteredImageContainerNew(
                    ImgContainerSize.Size56by24,
                    Properties.Image,
                    Properties.ImageClass,
                    _elmDefaultImg,
                    true,
                    false,
                    Properties.ImageTop,
                    Properties.ImageLeft);
                _elmDefaultImg.Alt = alt;
                _elmDefaultA.AppendChild(_elmDefaultImgCont);
            }
            else
            {
                bool hasLeftImage  = !string.IsNullOrEmpty(Properties.ImageLeftSide);
                bool hasRightImage = !string.IsNullOrEmpty(Properties.ImageRightSide);

                if (hasLeftImage)
                {
                    _elmLeft           = new Span();
                    _elmLeft.ClassName = "ms-cui-jewel-left";
                    _elmLeft.Id        = Properties.Id + "-Default-left";
                    Utility.PrepareClusteredBackgroundImageContainer(_elmLeft,
                                                                     Properties.ImageLeftSide,
                                                                     Properties.ImageLeftSideClass,
                                                                     Properties.ImageLeftSideTop,
                                                                     Properties.ImageLeftSideLeft,
                                                                     null,
                                                                     Properties.Height);

                    _elmLeft.Style.Width  = Properties.ImageLeftSideWidth + "px";
                    _elmLeft.Style.Height = Properties.Height + "px";
                    _elmDefaultA.AppendChild(_elmLeft);
                }

                _elmMiddle           = new Span();
                _elmMiddle.ClassName = "ms-cui-jewel-middle";
                _elmMiddle.Id        = Properties.Id + "-Default-middle";
                Utility.PrepareClusteredBackgroundImageContainer(_elmMiddle,
                                                                 Properties.Image,
                                                                 Properties.ImageClass,
                                                                 Properties.ImageTop,
                                                                 Properties.ImageLeft,
                                                                 null,
                                                                 Properties.Height);
                _elmLabel = new Span();
                if (!string.IsNullOrEmpty(Properties.LabelCss))
                {
                    _elmLabel.Style.CssText = Properties.LabelCss;
                }
                _elmLabel.ClassName = "ms-cui-jewel-label";
                if (!string.IsNullOrEmpty(Properties.Height))
                {
                    _elmLabel.Style.MarginTop = (Math.Floor(Int32.Parse(Properties.Height) - 14 /* 8px for text, 6px for existing padding */) / 2) + "px";
                }
                UIUtility.SetInnerText(_elmLabel, Properties.LabelText);
                _elmMiddle.AppendChild(_elmLabel);
                _elmDefaultA.AppendChild(_elmMiddle);

                if (hasRightImage)
                {
                    _elmRight           = new Span();
                    _elmRight.ClassName = "ms-cui-jewel-right";
                    _elmRight.Id        = Properties.Id + "-Default-right";
                    Utility.PrepareClusteredBackgroundImageContainer(_elmRight,
                                                                     Properties.ImageRightSide,
                                                                     Properties.ImageRightSideClass,
                                                                     Properties.ImageRightSideTop,
                                                                     Properties.ImageRightSideLeft,
                                                                     null,
                                                                     Properties.Height);

                    _elmRight.Style.Width  = Properties.ImageRightSideWidth + "px";
                    _elmRight.Style.Height = Properties.Height + "px";
                    _elmDefaultA.AppendChild(_elmRight);
                }
            }

            // Setup Event Handlers
            AttachEventsForDisplayMode(displayMode);

            // Build DOM Structure
            _elmDefault.AppendChild(_elmDefaultA);

            return(_elmDefault);
        }
Exemple #12
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            switch (displayMode)
            {
            case "Large":
            case "Menu":
                string alt = CUIUtility.SafeString(Properties.Alt);
                // Create elements
                _elmDefault = new Span();
                _elmDefault.SetAttribute("mscui:controltype", ControlType);
                _elmDefault.ClassName = "ms-cui-gallerybutton ms-cui-gallerybutton-" + Utility.GalleryElementDimensionsToSizeString[(int)ElementDimensions];

                _elmDefaultA           = new Anchor();
                _elmDefaultA.Title     = alt;
                _elmDefaultA.ClassName = "ms-cui-gallerybutton-a";
                Utility.NoOpLink(_elmDefaultA);
                Utility.SetAriaTooltipProperties(Properties, _elmDefaultA);
                _elmDefault.AppendChild(_elmDefaultA);

                if (!string.IsNullOrEmpty(Properties.InnerHTML))
                {
                    _elmDefaultA.InnerHtml = Properties.InnerHTML;
                    Utility.SetUnselectable(_elmDefaultA, true, true);
                }
                else
                {
                    if (string.IsNullOrEmpty(Properties.Image))
                    {
                        throw new ArgumentNullException("InnerHTML or Image must be defined for this GalleryButton");
                    }

                    ImgContainerSize size = ImgContainerSize.Size32by32;
                    switch (ElementDimensions)
                    {
                    case GalleryElementDimensions.Size16by16:
                        size = ImgContainerSize.Size16by16;
                        break;

                    case GalleryElementDimensions.Size32by32:
                        size = ImgContainerSize.Size32by32;
                        break;

                    case GalleryElementDimensions.Size48by48:
                        size = ImgContainerSize.Size48by48;
                        break;

                    case GalleryElementDimensions.Size64by48:
                        size = ImgContainerSize.Size64by48;
                        break;

                    case GalleryElementDimensions.Size72by96:
                        size = ImgContainerSize.Size72by96;
                        break;

                    case GalleryElementDimensions.Size96by72:
                        size = ImgContainerSize.Size96by72;
                        break;

                    case GalleryElementDimensions.Size96by96:
                        size = ImgContainerSize.Size96by96;
                        break;
                    }

                    _elmDefaultImage     = new Image();
                    _elmDefaultImageCont = Utility.CreateClusteredImageContainerNew(
                        size,
                        Properties.Image,
                        Properties.ImageClass,
                        _elmDefaultImage,
                        true,
                        false,
                        Properties.ImageTop,
                        Properties.ImageLeft);
                    _elmDefaultImage.Alt = alt;
                    _elmDefaultA.AppendChild(_elmDefaultImageCont);
                }

                // Setup event handlers
                AttachEventsForDisplayMode(displayMode);

                return(_elmDefault);

            default:
                EnsureValidDisplayMode(displayMode);
                return(null);
            }
        }
Exemple #13
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            switch (displayMode)
            {
            case "Medium":
                _elmDefault           = new Span();
                _elmDefault.ClassName = "ms-cui-spn";
                _elmDefault.SetAttribute("mscui:controltype", ControlType);

                _elmDefaultInput           = new Input();
                _elmDefaultInput.ClassName = "ms-cui-spn-txtbx";
                _elmDefaultInput.Id        = Id;
                _elmDefaultInput.SetAttribute("role", "textbox");

                Utility.SetAriaTooltipProperties(Properties, _elmDefaultInput);
                Utility.SetImeMode(_elmDefaultInput, Properties.ImeEnabled);

                _elmDefaultArwBox           = new Span();
                _elmDefaultArwBox.ClassName = "ms-cui-spn-arwbx";

                _elmDefaultUpArw           = new Anchor();
                _elmDefaultUpArw.ClassName = "ms-cui-spn-btnup";
                _elmDefaultUpArw.SetAttribute("role", "spinbutton");

                _elmDefaultDownArw           = new Anchor();
                _elmDefaultDownArw.ClassName = "ms-cui-spn-btndown";
                _elmDefaultDownArw.SetAttribute("role", "spinbutton");

                _upArwImg     = new Image();
                _upArwImg.Alt = "";
                _upArwImgCont = Utility.CreateClusteredImageContainerNew(
                    ImgContainerSize.Size5by3,
                    Root.Properties.ImageUpArrow,
                    Root.Properties.ImageUpArrowClass,
                    _upArwImg,
                    true,
                    false,
                    Root.Properties.ImageUpArrowTop,
                    Root.Properties.ImageUpArrowLeft);


                Utility.EnsureCSSClassOnElement(_upArwImgCont, "ms-cui-spn-imgcnt");
                _elmDefaultUpArw.Title = CUIUtility.SafeString(Properties.AltUpArrow);

                _downArwImg     = new Image();
                _downArwImg.Alt = "";
                _downArwImgCont = Utility.CreateClusteredImageContainerNew(
                    ImgContainerSize.Size5by3,
                    Root.Properties.ImageDownArrow,
                    Root.Properties.ImageDownArrowClass,
                    _downArwImg,
                    true,
                    false,
                    Root.Properties.ImageDownArrowTop,
                    Root.Properties.ImageDownArrowLeft);

                Utility.EnsureCSSClassOnElement(_downArwImgCont, "ms-cui-spn-imgcnt");
                _elmDefaultDownArw.Title = CUIUtility.SafeString(Properties.AltDownArrow);

                // Set up event handlers
                AttachEventsForDisplayMode(displayMode);

                // Build DOM Structure
                _elmDefault.AppendChild(_elmDefaultInput);
                _elmDefault.AppendChild(_elmDefaultArwBox);
                _elmDefaultArwBox.AppendChild(_elmDefaultUpArw);
                _elmDefaultArwBox.AppendChild(_elmDefaultDownArw);
                _elmDefaultUpArw.AppendChild(_upArwImgCont);
                _elmDefaultDownArw.AppendChild(_downArwImgCont);

                return(_elmDefault);

            default:
                EnsureValidDisplayMode(displayMode);
                return(null);
            }
        }
Exemple #14
0
        protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode)
        {
            switch (displayMode)
            {
            case "Medium":
                string alt      = CUIUtility.SafeString(CBProperties.Alt);
                string altArrow = CUIUtility.SafeString(CBProperties.AltArrow);

                // Top Level Element
                _elmMedium           = new Span();
                _elmMedium.ClassName = "ms-cui-cb";
                _elmMedium.SetAttribute("mscui:controltype", ControlType);

                // Input Element
                _elmMediumInput = new Input();
                _elmMediumInput.SetAttribute("name", CBProperties.Command);
                _elmMediumInput.Type        = "text";
                _elmMediumInput.Style.Width = CBProperties.Width;
                _elmMediumInput.ClassName   = "ms-cui-cb-input";
                _elmMediumInput.SetAttribute("autocomplete", "off");
                _elmMediumInput.Id = CBProperties.Id;
                if (string.IsNullOrEmpty(Properties.ToolTipTitle))
                {
                    _elmMediumInput.Title = alt;
                }
                Utility.SetImeMode(_elmMediumInput, ((ComboBoxProperties)Properties).ImeEnabled);

                string itemId = (string)StateProperties[ComboBoxCommandProperties.SelectedItemId];
                if (string.IsNullOrEmpty(itemId))
                {
                    itemId = CBProperties.InitialItem;
                }
                if (!string.IsNullOrEmpty(itemId))
                {
                    SelectMenuItemById(itemId);
                }

                Utility.SetAriaTooltipProperties(Properties, _elmMediumInput);

                // Arrow Button Element
                _elmMediumBtnA = new Anchor();
                Utility.EnsureCSSClassOnElement(_elmMediumBtnA, "ms-cui-dd-arrow-button");
                Utility.NoOpLink(_elmMediumBtnA);

                _elmMediumBtnA.TabIndex = -1;     // Only the input box should be tab-able
                _elmMediumBtnA.SetAttribute("aria-haspopup", "true");

                _elmMediumArwImg = new Image();

                _elmMediumArwImgCont = Utility.CreateClusteredImageContainerNew(
                    ImgContainerSize.Size5by3,
                    Root.Properties.ImageDownArrow,
                    Root.Properties.ImageDownArrowClass,
                    _elmMediumArwImg,
                    true,
                    false,
                    Root.Properties.ImageDownArrowTop,
                    Root.Properties.ImageDownArrowLeft
                    );

                if (string.IsNullOrEmpty(Properties.ToolTipTitle))
                {
                    _elmMediumArwImg.Alt = altArrow;
                    _elmMediumBtnA.Title = altArrow;
                }

                // Set up event handlers for the Drop Down Arrow Button
                AttachEventsForDisplayMode("Medium");

                // Build DOM Structure
                _elmMedium.AppendChild(_elmMediumInput);
                _elmMedium.AppendChild(_elmMediumBtnA);

                _elmMediumBtnA.AppendChild(_elmMediumArwImgCont);
                return(_elmMedium);

            default:
                EnsureValidDisplayMode(displayMode);
                return(null);
            }
        }
Exemple #15
0
        public static string GetNodeName(object data)
        {
            JSObject obj = (JSObject)data;

            return(CUIUtility.SafeString(obj.GetField <string>(NAME)));
        }
Exemple #16
0
 /// <summary>
 /// Creates a new Strip.
 /// </summary>
 /// <param name="ribbon">The Toolbar that this ButtonDock was created by and is a part of.</param>
 /// <param name="id">The Component id of this ButtonDock.</param>
 internal ButtonDock(Root root, string id, ButtonDockProperties properties)
     : base(root, id, "", "")
 {
     _alignment = CUIUtility.SafeString(properties.Alignment);
 }
Exemple #17
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);
        }