internal override void RefreshInternal() { EnsureDOMElementAndEmpty(); _elmWrapper = new Div(); _elmWrapper.ClassName = "ms-cui-menusection"; ElementInternal.AppendChild(_elmWrapper); if (!string.IsNullOrEmpty(Title)) { _elmTitle = new Div(); UIUtility.SetInnerText(_elmTitle, Title); _elmTitle.ClassName = "ms-cui-menusection-title"; _elmWrapper.AppendChild(_elmTitle); } _elmItems = new UnorderedList(); _elmItems.ClassName = "ms-cui-menusection-items"; string cssclassname; if (_displayMode == "Menu32") { if (Root.TextDirection == Direction.LTR) { cssclassname = "ms-cui-menusection-items32"; } else { cssclassname = "ms-cui-menusection-items32rtl"; } Component parent = Parent; if (parent is Menu) { // For IE7, we can't put a max width on the menu section since hasLayout // will become enabled and force the menu items to not be full-width // We can, however, set a max-width on the menu itself if there are any menu32 // sections within it. (O14:448689) Utility.EnsureCSSClassOnElement(parent.ElementInternal, "ms-cui-menu32"); } } else if (_displayMode == "Menu16") { if (Root.TextDirection == Direction.LTR) { cssclassname = "ms-cui-menusection-items16"; } else { cssclassname = "ms-cui-menusection-items16rtl"; } } else { cssclassname = ""; } if (cssclassname != "") { Utility.EnsureCSSClassOnElement(_elmItems, cssclassname); } if (_scrollable) { _elmItems.Style.OverflowY = "auto"; _elmItems.Style.Position = "relative"; } if (!string.IsNullOrEmpty(_maxHeight)) _elmItems.Style.MaxHeight = _maxHeight; _elmWrapper.AppendChild(_elmItems); AppendChildrenToElement(_elmItems); }
protected void CreateToolbarStructure(bool twoRow) { if (_hasJewel) { _elmJewelPlaceholder = new Div(); _elmJewelPlaceholder.Id = "jewelcontainer"; _elmJewelPlaceholder.ClassName = "ms-cui-jewel-container"; _elmJewelPlaceholder.Style.Display = "none"; } if (twoRow) { _elmTopBar1 = new Div(); _elmTopBar1.ClassName = "ms-cui-topBar1"; _elmTopBar1.Style.Display = "none"; _elmTopBar2 = new Div(); _elmTopBar2.ClassName = "ms-cui-topBar2"; if (_hasJewel) _elmTopBar2.AppendChild(_elmJewelPlaceholder); _elmToolbarTopBars = new Div(); _elmToolbarTopBars.ClassName = "ms-cui-ribbonTopBars"; _elmToolbarTopBars.AppendChild(_elmTopBar1); _elmToolbarTopBars.AppendChild(_elmTopBar2); // Create peripheral content placeholders as necessary _elmQATRowCenter = (Div)Browser.Document.GetById(ClientID + "-" + RibbonPeripheralSection.QATRowCenter); _elmQATRowRight = (Div)Browser.Document.GetById(ClientID + "-" + RibbonPeripheralSection.QATRowRight); if (!CUIUtility.IsNullOrUndefined(_elmQATRowCenter)) { _elmQATRowCenter.ParentNode.RemoveChild(_elmQATRowCenter); _elmTopBar1.AppendChild(_elmQATRowCenter); _elmQATRowCenter.Style.Display = "inline-block"; _elmTopBar1.Style.Display = "block"; Utility.SetUnselectable(_elmQATRowCenter, true, false); } if (!CUIUtility.IsNullOrUndefined(_elmQATRowRight)) { _elmQATRowRight.ParentNode.RemoveChild(_elmQATRowRight); _elmTopBar1.AppendChild(_elmQATRowRight); _elmQATRowRight.Style.Display = "inline-block"; _elmTopBar1.Style.Display = "block"; Utility.SetUnselectable(_elmQATRowRight, true, false); } } // Initialize the outer DOM element of this component EnsureDOMElement(); }
protected override HtmlElement CreateDOMElementForDisplayMode(string displayMode) { switch (displayMode) { case "Menu": _elmDefault = new Table(); _elmDefault.SetAttribute("mscui:controltype", ControlType); _elmDefaultTbody = new TableBody(); _elmDefaultTbody.ClassName = "ms-cui-it"; _elmDefault.SetAttribute("cellspacing", "0"); _elmDefault.SetAttribute("cellpadding", "0"); _elmDefaultTbody.SetAttribute("cellspacing", "0"); _elmDefaultTbody.SetAttribute("cellpadding", "0"); _elmDefault.MouseOut += OnControlMouseOut; EnsureDivArrays(); TableRow elmRow; TableCell elmCell; Anchor elmCellA; Div elmDiv; Div elmDivOuter; int idx = 0; for (int i = 0; i < 10; i++) { elmRow = new TableRow(); _elmDefaultTbody.AppendChild(elmRow); for (int j = 0; j < 10; j++) { elmCell = new TableCell(); elmCell.Style.Padding = "0px"; elmRow.AppendChild(elmCell); elmCellA = new Anchor(); Utility.NoOpLink(elmCellA); Utility.SetAriaTooltipProperties(Properties, elmCellA); elmCellA.Focus += OnCellFocus; elmDiv = new Div(); elmDiv.ClassName = "ms-cui-it-inactiveCell"; elmDivOuter = new Div(); elmDivOuter.Id = this.Id + "-" + idx; elmDivOuter.ClassName = "ms-cui-it-inactiveCellOuter"; elmCell.MouseOver += OnCellHover; elmCell.Click += OnCellClick; elmCell.AppendChild(elmDivOuter); elmDivOuter.AppendChild(elmDiv); elmDiv.AppendChild(elmCellA); _innerDivs[idx] = elmDiv; _outerDivs[idx] = elmDivOuter; idx++; } } _elmDefault.AppendChild(_elmDefaultTbody); return _elmDefault; default: EnsureValidDisplayMode(displayMode); break; } return null; }
private void OnReturnRibbonAndInitialTab(DataQueryResult res) { PMetrics.PerfMark(PMarker.perfCUIRibbonInitStart); RibbonBuildContext rbc = (RibbonBuildContext)res.ContextData; // Apply any extensions to the data. res.QueryData = ApplyDataExtensions(res.QueryData); Utility.EnsureCSSClassOnElement(Placeholder, "loaded"); JSObject templates = DataNodeWrapper.GetFirstChildNodeWithName(res.QueryData, DataNodeWrapper.TEMPLATES); if (!CUIUtility.IsNullOrUndefined(templates)) TemplateManager.Instance.LoadTemplates(templates); Ribbon = BuildRibbon(res.QueryData, rbc); Ribbon.RibbonBuilder = this; BuildClient.OnComponentCreated(Ribbon, Ribbon.Id); if (RibbonBuildOptions.Minimized) { Ribbon.MinimizedInternal = true; } else { Ribbon.MinimizedInternal = false; Tab firstTab = (Tab)Ribbon.GetChild(rbc.InitialTabId); if (!CUIUtility.IsNullOrUndefined(firstTab)) { // We need this in order to set the "ChangedByUser" property of the first // TabSwitch command that comes out of the ribbon correctly. firstTab.SelectedByUser = RibbonBuildOptions.InitialTabSelectedByUser; Ribbon.MakeTabSelectedInternal(firstTab); } } Ribbon.ClientID = RibbonBuildOptions.ClientID; bool shouldAttach = !RibbonBuildOptions.Minimized && RibbonBuildOptions.AttachToDOM; if (shouldAttach) { // Scale the ribbon to the scaling index that matches the ribbon that was // rendered by the server. This sets the in memory Ribbon structure to match // what was rendered by the server. This is needed so that Ribbon.AttachInternal() // will work properly. if (!((RibbonBuildOptions)Options).Minimized) { // We subtract one from this scaling index because internally // this scaling index is an entry into an array of "<ScaleStep>" so // the MaxSize for all the groups is actually index "-1" and the first // step is index 0. Ribbon.ScaleIndex(rbc.InitialScalingIndex - 1); } Ribbon.AttachInternal(true); // Attach to the QAT and Jewel if (!string.IsNullOrEmpty(RibbonBuildOptions.ShowQATId)) Ribbon.BuildAndSetQAT(RibbonBuildOptions.ShowQATId, true, DataSource); if (!string.IsNullOrEmpty(RibbonBuildOptions.ShowJewelId)) Ribbon.BuildAndSetJewel(RibbonBuildOptions.ShowJewelId, true, DataSource); #if DEBUG // Validate that the server rendered ribbon is identical to the client rendered one // for this tab. if (Options.ValidateServerRendering) { RibbonBuilder rb2 = new RibbonBuilder(this.RibbonBuildOptions, this.Placeholder, null); DataSource ds = new DataSource(this.DataSource.DataUrl, this.DataSource.Version, this.DataSource.Lcid); rb2.DataSource = ds; SPRibbon r2 = rb2.BuildRibbon(res.QueryData, rbc); r2.Id += "-client"; r2.ClientID = RibbonBuildOptions.ClientID + "-client"; r2.RibbonBuilder = this; if (!RibbonBuildOptions.Minimized) r2.Minimized = false; // Clone all the peripheral sections for the client-rendering version Div p_qrc = (Div)Browser.Document.GetById(RibbonBuildOptions.ClientID + "-" + RibbonPeripheralSection.QATRowCenter); Div p_qrr = (Div)Browser.Document.GetById(RibbonBuildOptions.ClientID + "-" + RibbonPeripheralSection.QATRowRight); Div p_trl = (Div)Browser.Document.GetById(RibbonBuildOptions.ClientID + "-" + RibbonPeripheralSection.TabRowLeft); Div p_trr = (Div)Browser.Document.GetById(RibbonBuildOptions.ClientID + "-" + RibbonPeripheralSection.TabRowRight); Div hiddenClonedPeripherals = new Div(); hiddenClonedPeripherals.Style.Display = "none"; Browser.Document.Body.AppendChild(hiddenClonedPeripherals); Div clone; if (null != p_qrc) { clone = (Div)p_qrc.CloneNode(true); clone.Id = clone.Id.Replace(RibbonBuildOptions.ClientID, r2.ClientID); hiddenClonedPeripherals.AppendChild(clone); } if (null != p_qrr) { clone = (Div)p_qrr.CloneNode(true); clone.Id = clone.Id.Replace(RibbonBuildOptions.ClientID, r2.ClientID); hiddenClonedPeripherals.AppendChild(clone); } if (null != p_trl) { clone = (Div)p_trl.CloneNode(true); clone.Id = clone.Id.Replace(RibbonBuildOptions.ClientID, r2.ClientID); hiddenClonedPeripherals.AppendChild(clone); } if (null != p_trr) { clone = (Div)p_trr.CloneNode(true); clone.Id = clone.Id.Replace(RibbonBuildOptions.ClientID, r2.ClientID); hiddenClonedPeripherals.AppendChild(clone); } r2.MakeTabSelectedInternal((Tab)r2.GetChild(rbc.InitialTabId)); r2.RefreshInternal(); if (!string.IsNullOrEmpty(RibbonBuildOptions.ShowQATId)) r2.BuildAndSetQAT(RibbonBuildOptions.ShowQATId, false, ds); if (!string.IsNullOrEmpty(RibbonBuildOptions.ShowJewelId)) r2.BuildAndSetJewel(RibbonBuildOptions.ShowJewelId, false, ds); r2.ScaleIndex(rbc.InitialScalingIndex - 1); r2.CompleteConstruction(); // If this returns a message it means that it found some inconsistencies // between the DOM Nodes CompareNodes(Ribbon.ElementInternal, r2.ElementInternal); } #endif } else { // Do the minimum amount of work necessary in order to be able to // get the outer ribbon element and to be able to attach the Jewel and QAT. Ribbon.EnsureDOMElement(); // Build the QAT and Jewel after the ribbon so that the placeholders // will have been created within the ribbon via Ribbon.RefreshInternal() if (!string.IsNullOrEmpty(RibbonBuildOptions.ShowQATId)) Ribbon.BuildAndSetQAT(RibbonBuildOptions.ShowQATId, false, DataSource); if (!string.IsNullOrEmpty(RibbonBuildOptions.ShowJewelId)) Ribbon.BuildAndSetJewel(RibbonBuildOptions.ShowJewelId, false, DataSource); // Remove anything else that is in the placeholder in case there is a temporary // animated gif or a static ribbon in there while the ribbon is loading. // We're doing this the slow way since partners might have a reference to this node Utility.RemoveChildNodesSlow(Placeholder); Placeholder.AppendChild(Ribbon.ElementInternal); } Ribbon.Scale(); OnRootBuilt(Ribbon); BuildClient.OnComponentBuilt(Ribbon, Ribbon.Id); if (RibbonBuildOptions.LaunchedByKeyboard) Ribbon.SetFocusOnRibbon(); PMetrics.PerfMark(PMarker.perfCUIRibbonInitPercvdEnd); }
/// <summary> /// Create some rows or cells in _colorTable /// </summary> /// <param name="colorRules"></param> /// <param name="styleName"></param> private void AddColorCells(HtmlElement colorTableBody, ColorStyle[] colorRules) { int rowNumber = 0; TableRow row = new TableRow(); int totalRows = colorRules.Length / ColumnSize; for (int i = 0; i < colorRules.Length; i++) { if ((i % ColumnSize) == 0) { row = new TableRow(); colorTableBody.AppendChild(row); rowNumber++; } TableCell cell = new TableCell(); cell.ClassName = NormalCellCssClassName; cell.SetAttribute("arrayPosition", i.ToString()); // Make the first row have spacing. if (rowNumber == 1) { cell.Style.Padding = "2px"; cell.Style.Height = "16px"; } row.AppendChild(cell); Anchor link = new Anchor(); link.Href = "javascript:"; string displayName = colorRules[i].Title; link.Title = displayName; link.ClassName = CellAnchorCssClassName; link.Focus += OnCellFocus; Div elmDiv = new Div(); string color = colorRules[i].DisplayColor; elmDiv.Style.BackgroundColor = color; elmDiv.ClassName = CellDivClassName; int size = DefaultCellHeight; if (rowNumber == 1 || rowNumber == 2) { elmDiv.Style.BorderTopWidth = "1px"; size--; } if (rowNumber == 1 || rowNumber == totalRows) { elmDiv.Style.BorderBottomWidth = "1px"; size--; } if (size != DefaultCellHeight) { elmDiv.Style.Height = size + "px"; } Div internalelmDiv = new Div(); internalelmDiv.ClassName = CellInternalDivClassName; link.MouseOver += OnCellHover; link.MouseOut += OnCellBlur; link.Click += OnCellClick; cell.AppendChild(link); link.AppendChild(elmDiv); elmDiv.AppendChild(internalelmDiv); cell.SetAttribute(ColorInformation + "Color", colorRules[i].Color); cell.SetAttribute(ColorInformation + "Style", colorRules[i].Style); // add the cell to _colorCells so that we could reset the highlight _colorCells.Add(cell); } }
/// <summary> /// Creates the HTML for the ToolTip. /// </summary> /// <owner alias="HillaryM" /> internal override void RefreshInternal() { if (NeedsDelayIniting) DoDelayedInit(); EnsureDOMElementAndEmpty(); // set the aria role ElementInternal.SetAttribute("role", "tooltip"); // set the aria visibility ElementInternal.SetAttribute("aria-hidden", "true"); if (CUIUtility.IsNullOrUndefined(_elmBody)) { _elmBody = new Div(); _elmBody.ClassName = "ms-cui-tooltip-body"; } else { _elmBody = (Div)Utility.RemoveChildNodes(_elmBody); } ElementInternal.AppendChild(_elmBody); if (CUIUtility.IsNullOrUndefined(_elmInnerDiv)) { _elmInnerDiv = new Div(); _elmInnerDiv.ClassName = "ms-cui-tooltip-glow"; _elmBody.AppendChild(_elmInnerDiv); } else { _elmInnerDiv = (Div)Utility.RemoveChildNodes(_elmInnerDiv); } // set the title and shortcut if (CUIUtility.IsNullOrUndefined(_elmTitle)) { _elmTitle = new Heading1(); if (TitleInternal.Length > _controlTitleLength) { UIUtility.SetInnerText(_elmTitle, TitleInternal.Substring(0, _controlTitleLength)); } else { UIUtility.SetInnerText(_elmTitle, Title); } _elmInnerDiv.AppendChild(_elmTitle); } // set the image if available if (CUIUtility.IsNullOrUndefined(_elmDescriptionImage) && !string.IsNullOrEmpty(Properties.ToolTipImage32by32)) { _elmDescriptionImage = new Image(); _elmDescriptionImageCont = Utility.CreateClusteredImageContainerNew( ImgContainerSize.Size32by32, Properties.ToolTipImage32by32, Properties.ToolTipImage32by32Class, _elmDescriptionImage, true, false, Properties.ToolTipImage32by32Top, Properties.ToolTipImage32by32Left); _elmDescriptionImageCont.ClassName = _elmDescriptionImageCont.ClassName + " ms-cui-tooltip-bitmap "; _elmInnerDiv.AppendChild(_elmDescriptionImageCont); } // set the description string selectedItemTitle = Properties.ToolTipSelectedItemTitle; string descriptionText = Description; if (CUIUtility.IsNullOrUndefined(_elmDescription) && (!string.IsNullOrEmpty(descriptionText) || !string.IsNullOrEmpty(selectedItemTitle))) { _elmDescription = new Div(); _elmDescription.ClassName = "ms-cui-tooltip-description"; if (!string.IsNullOrEmpty(Properties.ToolTipImage32by32)) { _elmDescription.Style.Width = "80%"; } _elmInnerDiv.AppendChild(_elmDescription); string seletedItemTitlePrefix = Root.Properties.ToolTipSelectedItemTitlePrefix; if (!string.IsNullOrEmpty(selectedItemTitle) && !string.IsNullOrEmpty(seletedItemTitlePrefix)) { string selectedItemText = String.Format(seletedItemTitlePrefix, selectedItemTitle); _elmSelectedItemTitle = new Paragraph(); UIUtility.SetInnerText(_elmSelectedItemTitle, selectedItemText); _elmDescription.AppendChild(_elmSelectedItemTitle); _spacerRow3 = new Break(); _elmDescription.AppendChild(_spacerRow3); } if (!string.IsNullOrEmpty(descriptionText)) { if (descriptionText.Length > _controlDescriptionLength) { _elmDescription.InnerHtml = _elmDescription.InnerHtml + Utility.HtmlEncodeAllowSimpleTextFormatting(descriptionText.Substring(0, _controlDescriptionLength), true); } else { _elmDescription.InnerHtml = _elmDescription.InnerHtml + Utility.HtmlEncodeAllowSimpleTextFormatting(descriptionText, true); } } } // Disabled info explaining why a command is currently disabled if (CUIUtility.IsNullOrUndefined(_elmDisabledInfo) && !CUIUtility.IsNullOrUndefined(_disabledInfoProperties) && !string.IsNullOrEmpty(_disabledInfoProperties.Title)) { // provide spacer to distinguish from main description above _spacerDiv1 = new Div(); _spacerDiv1.ClassName = "ms-cui-tooltip-clear"; _elmInnerDiv.AppendChild(_spacerDiv1); _spacerRow1 = new HorizontalRule(); _elmInnerDiv.AppendChild(_spacerRow1); // title for this message _elmDisabledInfoTitle = new Div(); _elmDisabledInfoTitle.ClassName = "ms-cui-tooltip-footer"; _elmInnerDiv.AppendChild(_elmDisabledInfoTitle); _elmDisabledInfoTitleText = new Div(); UIUtility.SetInnerText(_elmDisabledInfoTitleText, _disabledInfoProperties.Title); // icon for this message _elmDisabledInfoIcon = new Image(); _elmDisabledInfoIconCont = Utility.CreateClusteredImageContainerNew( ImgContainerSize.Size16by16, _disabledInfoProperties.Icon, _disabledInfoProperties.IconClass, _elmDisabledInfoIcon, true, false, _disabledInfoProperties.IconTop, _disabledInfoProperties.IconLeft); _elmDisabledInfoIconCont.Style.VerticalAlign = "top"; // switch display based on text direction // REVIEW(jkern,josefl): I don't think that we need to manually do this. We should get it for free in // the browser with the "dir=rtl" attribute. Check this when the RTL work is done. if (Root.TextDirection == Direction.LTR) { _elmDisabledInfoTitle.AppendChild(_elmDisabledInfoIconCont); _elmDisabledInfoTitle.AppendChild(_elmDisabledInfoTitleText); } else { _elmDisabledInfoTitle.AppendChild(_elmDisabledInfoTitleText); _elmDisabledInfoTitle.AppendChild(_elmDisabledInfoIconCont); } // disabled info text if (!string.IsNullOrEmpty(_disabledInfoProperties.Description)) { _elmDisabledInfo = new Div(); _elmDisabledInfo.ClassName = "ms-cui-tooltip-description"; _elmDisabledInfo.Style.Width = "90%"; UIUtility.SetInnerText(_elmDisabledInfo, _disabledInfoProperties.Description); _elmInnerDiv.AppendChild(_elmDisabledInfo); } } // set the footer if (!CUIUtility.IsNullOrUndefined(_elmFooter) && !string.IsNullOrEmpty(Root.Properties.ToolTipFooterText) && !string.IsNullOrEmpty(Root.Properties.ToolTipFooterImage16by16) && (((!CUIUtility.IsNullOrUndefined(_disabledInfoProperties)) && (!string.IsNullOrEmpty(_disabledInfoProperties.HelpKeyWord))) || (!string.IsNullOrEmpty(Properties.ToolTipHelpKeyWord)))) { _spacerDiv2 = new Div(); _spacerDiv2.ClassName = "ms-cui-tooltip-clear"; _elmInnerDiv.AppendChild(_spacerDiv2); _spacerRow2 = new HorizontalRule(); _elmInnerDiv.AppendChild(_spacerRow2); _elmFooter = new Div(); _elmFooter.ClassName = "ms-cui-tooltip-footer"; _elmInnerDiv.AppendChild(_elmFooter); _elmFooterTitleText = new Div(); UIUtility.SetInnerText(_elmFooterTitleText, Root.Properties.ToolTipFooterText); _elmFooterIcon = new Image(); _elmFooterIconCont = Utility.CreateClusteredImageContainerNew( ImgContainerSize.Size16by16, Root.Properties.ToolTipFooterImage16by16, Root.Properties.ToolTipFooterImage16by16Class, _elmFooterIcon, true, false, Root.Properties.ToolTipFooterImage16by16Top, Root.Properties.ToolTipFooterImage16by16Left ); _elmFooterIconCont.Style.VerticalAlign = "top"; // switch display based on text direction // REVIEW(jkern,josefl): I don't think that we need to manually do this. We should get it for free in // the browser with the "dir=rtl" attribute. Check this when the RTL work is done. if (Root.TextDirection == Direction.LTR) { _elmFooter.AppendChild(_elmFooterIconCont); _elmFooter.AppendChild(_elmFooterTitleText); } else { _elmFooter.AppendChild(_elmFooterTitleText); _elmFooter.AppendChild(_elmFooterIconCont); } } // build DOM structure this.AppendChildrenToElement(_elmBody); base.RefreshInternal(); }