/// <summary> /// Adds given menu item as small button of specified width. /// </summary> /// <param name="item">Menu item to be added.</param> /// <param name="width">Width of button.</param> private void AddSmallButton(MenuItem item, int width) { item.CssClass = "SmallButton"; item.ImageAlign = ImageAlign.AbsMiddle; item.MinimalWidth = width; buttonsSmall.Buttons.Add(item); }
/// <summary> /// Adds given menu item as big button. /// </summary> /// <param name="item">Menu item to be added.</param> private void AddBigButton(MenuItem item) { item.CssClass = "BigButton"; item.ImageAlign = ImageAlign.Top; item.MinimalWidth = BigButtonMinimalWidth; buttonsBig.Buttons.Add(item); }
protected void Page_Load(object sender, EventArgs e) { const int bigButtonMinimalWidth = 40; const int smallButtonMinimalWidth = 65; // Big buttons MenuItem newItem = new MenuItem(); newItem.Text = GetString("general.new"); newItem.Tooltip = GetString("documents.newtooltip"); newItem.CssClass = "BigButton"; newItem.OnClientClick = "if (!NewItem()) return;"; newItem.ImagePath = GetImageUrl("CMSModules/CMS_Content/Menu/New.png"); newItem.ImageAltText = GetString("documents.newtooltip"); newItem.ImageAlign = ImageAlign.Top; newItem.MinimalWidth = bigButtonMinimalWidth; buttonsBig.Buttons.Add(newItem); MenuItem deleteItem = new MenuItem(); deleteItem.Text = GetString("general.delete"); deleteItem.Tooltip = GetString("documents.deletetooltip"); deleteItem.CssClass = "BigButton"; deleteItem.OnClientClick = "if (!DeleteItem()) return;"; deleteItem.ImagePath = GetImageUrl("CMSModules/CMS_Content/Menu/Delete.png"); deleteItem.ImageAltText = GetString("documents.deletetooltip"); deleteItem.ImageAlign = ImageAlign.Top; deleteItem.MinimalWidth = bigButtonMinimalWidth; buttonsBig.Buttons.Add(deleteItem); // Small buttons MenuItem upItem = new MenuItem(); upItem.Text = GetString("general.up"); upItem.Tooltip = GetString("documents.uptooltip"); upItem.CssClass = "SmallButton"; upItem.OnClientClick = "if (!MoveUp()) return;"; upItem.ImagePath = GetImageUrl("CMSModules/CMS_Content/Menu/Up.png"); upItem.ImageAltText = GetString("documents.uptooltip"); upItem.ImageAlign = ImageAlign.AbsMiddle; upItem.MinimalWidth = smallButtonMinimalWidth; buttonsSmall.Buttons.Add(upItem); MenuItem downItem = new MenuItem(); downItem.Text = GetString("general.down"); downItem.Tooltip = GetString("documents.downtooltip"); downItem.CssClass = "SmallButton"; downItem.OnClientClick = "if (!MoveDown()) return;"; downItem.ImagePath = GetImageUrl("CMSModules/CMS_Content/Menu/Down.png"); downItem.ImageAltText = GetString("documents.downtooltip"); downItem.ImageAlign = ImageAlign.AbsMiddle; downItem.MinimalWidth = smallButtonMinimalWidth; buttonsSmall.Buttons.Add(downItem); }
/// <summary> /// Method for adding submenu. /// </summary> /// <param name="button">Menu item button</param> /// <param name="cssClass">Button css class</param> /// <param name="identifier">Button identifier</param> private CMSPanel CreateSubMenu(MenuItem button, string cssClass, int identifier) { // Generate sub items container var pnlSubItems = new CMSPanel(); pnlSubItems.ID = "pnlSubItems" + identifier; pnlSubItems.ShortID = "ps" + identifier; pnlSubItems.CssClass = "SubMenuItems ContextMenu"; // Forward scroll button Panel pnlForward = new Panel { ID = "pnlForward", CssClass = "ForwardScroller" }; // Backward scroll button Panel pnlBackward = new Panel { ID = "pnlBackward", CssClass = "BackwardScroller" }; // Scrollable area ScrollPanel pnlMenu = new ScrollPanel { ID = "pnlCultureList", ShortID = "pcl" + identifier, CssClass = "ContextMenuContainer", ScrollAreaCssClass = "PortalContextMenu UniMenuContextMenu", Layout = RepeatDirection.Vertical, InnerItemClass = "Item", ForwardScrollerControlID = pnlForward.ID, BackwardScrollerControlID = pnlBackward.ID, ScrollStep = 200 }; pnlSubItems.Controls.Add(pnlForward); pnlSubItems.Controls.Add(pnlBackward); pnlSubItems.Controls.Add(pnlMenu); // Add menu items int subIdentifier = 0; foreach (SubMenuItem item in button.SubItems) { AddSubMenuItem(pnlMenu, item, cssClass, subIdentifier); subIdentifier++; } return(pnlSubItems); }
/// <summary> /// Applies styles to menu item according to UseSmallLanguageButton property. /// </summary> /// <param name="menuItem">Menu item to apply styles to.</param> private void SetStyles(MenuItem menuItem) { if (UseSmallLanguageButton) { menuItem.CssClass = "SmallButton"; menuItem.ImageAlign = ImageAlign.AbsMiddle; menuItem.MinimalWidth = 80; } else { menuItem.CssClass = "BigButton"; menuItem.ImageAlign = ImageAlign.Top; menuItem.MinimalWidth = 48; } }
protected void Page_Load(object sender, EventArgs e) { // Set mode script StringBuilder setMode = new StringBuilder(); setMode.AppendLine("function SetModeIcon(mode) {"); setMode.AppendLine(" var index = 0;"); setMode.AppendLine(" switch(mode)"); setMode.AppendLine(" {"); const int modeButtonMinimalWidth = 52; int i = 0; foreach (string name in Enum.GetNames(typeof(ContentViewMode))) { string lowerName = name.ToLowerCSafe(); string toolTip = GetString("mode." + lowerName + "tooltip"); MenuItem modeItem = new MenuItem(); modeItem.Text = GetString("general." + lowerName); modeItem.Tooltip = toolTip; modeItem.CssClass = "BigButton"; modeItem.OnClientClick = "if(!SetMode('" + lowerName + "')) return;"; modeItem.ImagePath = GetImageUrl("CMSModules/CMS_Content/Menu/" + name + ".png"); modeItem.ImageAltText = toolTip; modeItem.ImageAlign = ImageAlign.Top; modeItem.MinimalWidth = modeButtonMinimalWidth; buttonsBig.Buttons.Add(modeItem); if (SelectedMode.ToLowerCSafe() == name.ToLowerCSafe()) { buttonsBig.SelectedIndex = i; } setMode.AppendLine(" case '" + lowerName + "':"); setMode.AppendLine(" index = " + i + ";"); setMode.AppendLine(" break;"); i++; } setMode.AppendLine(" }"); setMode.AppendLine(" SelectButtonIndex_" + buttonsBig.ClientID + "(index);"); setMode.AppendLine(" return true;"); setMode.AppendLine("}"); ScriptHelper.RegisterClientScriptBlock(this, typeof(string), "setModeScript", ScriptHelper.GetScript(setMode.ToString())); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { CurrentUserInfo cui = CurrentUser; if (cui != null) { if (cui.IsAuthorizedPerUIElement("CMS.OnSiteEdit", "OnSiteHighlight")) { // Highlight button MenuItem highlightItem = new MenuItem(); highlightItem.CssClass = "BigButton OnSiteHighlightButton"; highlightItem.ImageAlign = ImageAlign.Top; highlightItem.ImagePath = GetImageUrl("CMSModules/CMS_PortalEngine/OnSiteEdit/highlight.png"); highlightItem.OnClientClick = "OEHighlightToggle(event, this);"; highlightItem.Text = GetString("onsiteedit.highlight"); highlightItem.Tooltip = GetString("onsiteedit.highlighttooltip"); highlightItem.ImageAltText = GetString("onsiteedit.highlight"); otherMenu.Buttons.Add(highlightItem); } if (cui.IsAuthorizedPerUIElement("CMS.OnSiteEdit", "OnSiteHidden")) { // Hidden button MenuItem hiddenItem = new MenuItem(); hiddenItem.CssClass = "BigButton OnSiteHiddenButton"; hiddenItem.ImageAlign = ImageAlign.Top; hiddenItem.ImagePath = GetImageUrl("CMSModules/CMS_PortalEngine/OnSiteEdit/hidden.png"); hiddenItem.Text = GetString("general.hidden"); hiddenItem.Tooltip = GetString("onsiteedit.hiddentooltip"); hiddenItem.ImageAltText = GetString("general.hidden"); // Add temporary empty sub menu item to ensure generating of the sub menu functions SubMenuItem epmtyItem = new SubMenuItem(); hiddenItem.SubItems.Add(epmtyItem); otherMenu.Buttons.Add(hiddenItem); } } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { var cui = CurrentUser; if (cui != null) { if (cui.IsAuthorizedPerUIElement("CMS.OnSiteEdit", "OnSiteHighlight")) { // Highlight button MenuItem highlightItem = new MenuItem(); highlightItem.CssClass = "BigButton"; highlightItem.ImageAlign = ImageAlign.Top; highlightItem.IconClass = "icon-square-dashed-line"; highlightItem.OnClientClick = "OEHighlightToggle(event, this);"; highlightItem.Text = PortalHelper.LocalizeStringForUI("onsiteedit.highlight"); highlightItem.Tooltip = PortalHelper.LocalizeStringForUI("onsiteedit.highlighttooltip"); highlightItem.ImageAltText = PortalHelper.LocalizeStringForUI("onsiteedit.highlight"); otherMenu.Buttons.Add(highlightItem); } if (cui.IsAuthorizedPerUIElement("CMS.OnSiteEdit", "OnSiteHidden")) { // Hidden button MenuItem hiddenItem = new MenuItem(); hiddenItem.CssClass = "BigButton OnSiteHiddenButton"; hiddenItem.ImageAlign = ImageAlign.Top; hiddenItem.IconClass = "icon-eye-slash"; hiddenItem.Text = PortalHelper.LocalizeStringForUI("general.hidden"); hiddenItem.Tooltip = PortalHelper.LocalizeStringForUI("onsiteedit.hiddentooltip"); hiddenItem.ImageAltText = PortalHelper.LocalizeStringForUI("general.hidden"); // Add temporary empty sub menu item to ensure generating of the sub menu functions SubMenuItem epmtyItem = new SubMenuItem(); hiddenItem.SubItems.Add(epmtyItem); otherMenu.Buttons.Add(hiddenItem); } } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { var cui = CurrentUser; if (cui != null) { if (cui.IsAuthorizedPerUIElement("CMS.OnSiteEdit", "OnSiteHighlight")) { // Highlight button MenuItem highlightItem = new MenuItem(); highlightItem.CssClass = "BigButton"; highlightItem.ImageAlign = ImageAlign.Top; highlightItem.IconClass = "icon-square-dashed-line"; highlightItem.OnClientClick = "OEHighlightToggle(event, this);"; highlightItem.Text = GetString("onsiteedit.highlight"); highlightItem.Tooltip = GetString("onsiteedit.highlighttooltip"); highlightItem.ImageAltText = GetString("onsiteedit.highlight"); otherMenu.Buttons.Add(highlightItem); } if (cui.IsAuthorizedPerUIElement("CMS.OnSiteEdit", "OnSiteHidden")) { // Hidden button MenuItem hiddenItem = new MenuItem(); hiddenItem.CssClass = "BigButton OnSiteHiddenButton"; hiddenItem.ImageAlign = ImageAlign.Top; hiddenItem.IconClass = "icon-eye-slash"; hiddenItem.Text = GetString("general.hidden"); hiddenItem.Tooltip = GetString("onsiteedit.hiddentooltip"); hiddenItem.ImageAltText = GetString("general.hidden"); // Add temporary empty sub menu item to ensure generating of the sub menu functions SubMenuItem epmtyItem = new SubMenuItem(); hiddenItem.SubItems.Add(epmtyItem); otherMenu.Buttons.Add(hiddenItem); } } }
protected void Page_Load(object sender, EventArgs e) { // Search button MenuItem searchItem = new MenuItem(); searchItem.Text = GetString("contentmenu.search"); searchItem.Tooltip = GetString("contentmenu.searchtooltip"); searchItem.CssClass = "BigButton"; searchItem.OnClientClick = "OpenSearch()"; searchItem.ImagePath = GetImageUrl("CMSModules/CMS_Content/Menu/search.png"); searchItem.ImageAltText = GetString("contentmenu.searchtooltip"); searchItem.ImageAlign = ImageAlign.Top; searchItem.MinimalWidth = 48; buttons.Buttons.Add(searchItem); // Maximize button - maximize button is not supported //MenuItem fullScreen = new MenuItem(); //fullScreen.Caption = GetString("contentmenu.maximize"); //fullScreen.Tooltip = GetString("contentmenu.maximizetooltip"); //fullScreen.CssClass = "ModeButton"; //fullScreen.OnClientClick = "FullScreen()"; //fullScreen.ImagePath = GetImageUrl("CMSModules/CMS_Content/Menu/FullScreen.png"); //buttons.Buttons.Add(fullScreen); }
protected void Page_Load(object sender, EventArgs e) { // New button MenuItem newItem = new MenuItem(); newItem.Text = GetTitleString("new"); newItem.Tooltip = GetTooltipString("newtooltip"); newItem.OnClientClick = "if (!NewItem()) return;"; newItem.ImagePath = NewImageUrl; newItem.ImageAltText = GetTooltipString("newtooltip"); if (AllButtonsAreSmall) { AddSmallButton(newItem, ShrinkedButtonMinimalWidth); } else { AddBigButton(newItem); } // Delete button MenuItem deleteItem = new MenuItem(); deleteItem.Text = GetTitleString("delete"); deleteItem.Tooltip = GetTooltipString("deletetooltip"); deleteItem.OnClientClick = "if(!DeleteItem()) return;"; deleteItem.ImagePath = DeleteImageUrl; deleteItem.ImageAltText = GetTooltipString("deletetooltip"); if (AllButtonsAreSmall) { AddSmallButton(deleteItem, ShrinkedButtonMinimalWidth); } else { AddBigButton(deleteItem); } // Copy button MenuItem copyItem = new MenuItem(); copyItem.Text = GetTitleString("copy"); copyItem.Tooltip = GetTooltipString("copytooltip"); copyItem.OnClientClick = "if(CheckChanges()) { CopyRef(GetSelectedNodeId()); };"; copyItem.ImagePath = GetImageUrl("CMSModules/CMS_Content/Menu/Copy.png"); copyItem.ImageAltText = GetTooltipString("copytooltip"); AddSmallButton(copyItem); // Move button MenuItem moveItem = new MenuItem(); moveItem.Text = GetTitleString("move"); moveItem.Tooltip = GetTooltipString("movetooltip"); moveItem.OnClientClick = "if(CheckChanges()) { MoveRef(GetSelectedNodeId()); };"; moveItem.ImagePath = GetImageUrl("CMSModules/CMS_Content/Menu/Move.png"); moveItem.ImageAltText = GetTooltipString("movetooltip"); AddSmallButton(moveItem); // Up button MenuItem upItem = new MenuItem(); upItem.Text = GetTitleString("up"); upItem.Tooltip = GetTooltipString("uptooltip"); upItem.OnClientClick = "if(!MoveUp()) return;"; upItem.ImagePath = GetImageUrl("CMSModules/CMS_Content/Menu/Up.png"); upItem.ImageAltText = GetTooltipString("uptooltip"); AddSmallButton(upItem); // Down button MenuItem downItem = new MenuItem(); downItem.Text = GetTitleString("down"); downItem.Tooltip = GetTooltipString("downtooltip"); downItem.OnClientClick = "if(!MoveDown()) return;"; downItem.ImagePath = GetImageUrl("CMSModules/CMS_Content/Menu/Down.png"); downItem.ImageAltText = GetTooltipString("downtooltip"); AddSmallButton(downItem); }
/// <summary> /// Loads device profile menu. /// </summary> private void LoadDevicesMenu() { string defaultSmallIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/default_list.png"); string defaultBigIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/default.png"); if ((Page is PortalPage) || (Page is TemplatePage)) { // Display grayscale icon in On-site editing defaultBigIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/default_grayscale.png"); defaultSmallIconUrl = defaultBigIconUrl; } string deviceSmallIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/list.png"); string deviceBigIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/module.png"); string defaultString = HTMLHelper.HTMLEncode(GetString("general.default")); MenuItem devMenuItem = new MenuItem { Text = defaultString, Tooltip = defaultString, ImagePath = defaultBigIconUrl, ImageAltText = defaultString }; SetStyles(devMenuItem); buttons.Buttons.Add(devMenuItem); // Load enabled profiles InfoDataSet <DeviceProfileInfo> ds = DeviceProfileInfoProvider.GetDeviceProfileInfos("ProfileEnabled = 1", "ProfileOrder"); if (!DataHelper.DataSourceIsEmpty(ds)) { // Create default item SubMenuItem defaultMenuItem = new SubMenuItem { Text = defaultString, Tooltip = defaultString, ImagePath = defaultSmallIconUrl, ImageAltText = defaultString, OnClientClick = String.Format("CMSUniMenu.ChangeButton(##BUTTON##, {0}, {1}); ChangeDevice('');", ScriptHelper.GetString(defaultString), ScriptHelper.GetString(ResolveUrl(defaultBigIconUrl))) }; devMenuItem.SubItems.Add(defaultMenuItem); foreach (DeviceProfileInfo profileInfo in ds.Items) { string bigIconUrl = null; string smallIconUrl = null; if (profileInfo.ProfileIconGuid == Guid.Empty) { smallIconUrl = deviceSmallIconUrl; bigIconUrl = deviceBigIconUrl; } else { string iconUrl = MetaFileURLProvider.GetMetaFileUrl(profileInfo.ProfileIconGuid, profileInfo.ProfileName); smallIconUrl = URLHelper.UpdateParameterInUrl(iconUrl, "maxsidesize", "16"); bigIconUrl = URLHelper.UpdateParameterInUrl(iconUrl, "maxsidesize", "24"); } string profileName = GetString(profileInfo.ProfileDisplayName); SubMenuItem menuItem = new SubMenuItem { Text = HTMLHelper.HTMLEncode(profileName), Tooltip = HTMLHelper.HTMLEncode(profileName), ImagePath = smallIconUrl, ImageAltText = HTMLHelper.HTMLEncode(profileName), OnClientClick = String.Format("CMSUniMenu.ChangeButton(##BUTTON##, {0}, {1}); ChangeDevice({2});", ScriptHelper.GetString(profileName), ScriptHelper.GetString(ResolveUrl(bigIconUrl)), ScriptHelper.GetString(profileInfo.ProfileName)) }; devMenuItem.SubItems.Add(menuItem); // Update main button if current device profile is equal currently processed profile if ((currentDevice != null) && (currentDevice.ProfileName.CompareToCSafe(profileInfo.ProfileName, true) == 0)) { devMenuItem.Text = HTMLHelper.HTMLEncode(profileName); devMenuItem.Tooltip = HTMLHelper.HTMLEncode(profileName); devMenuItem.ImagePath = bigIconUrl; devMenuItem.ImageAltText = HTMLHelper.HTMLEncode(profileName); } } } }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { string preferredCultureCode = LocalizationContext.PreferredCultureCode; InfoDataSet <CultureInfo> siteCultures = CultureSiteInfoProvider.GetSiteCultures(SiteContext.CurrentSiteName); pi = DocumentContext.CurrentPageInfo ?? DocumentContext.CurrentCultureInvariantPageInfo ?? new PageInfo(); // Cultures button MenuItem cultureItem = new MenuItem(); cultureItem.CssClass = "BigButton"; cultureItem.ImageAlign = ImageAlign.Top; cultureItem.ImagePath = URLHelper.UnResolveUrl(UIHelper.GetFlagIconUrl(Page, preferredCultureCode, "16x16"), SystemContext.ApplicationPath); cultureItem.Text = PortalHelper.LocalizeStringForUI("general.cultures"); cultureItem.Tooltip = PortalHelper.LocalizeStringForUI("onsiteedit.languageselector"); cultureItem.ImageAltText = PortalHelper.LocalizeStringForUI("general.cultures"); // Add all cultures to the sub menu foreach (CultureInfo culture in siteCultures) { string iconUrl = UIHelper.GetFlagIconUrl(Page, culture.CultureCode, "16x16"); string cultureName = culture.CultureName; string cultureCode = culture.CultureCode; if (cultureCode != preferredCultureCode) { SubMenuItem menuItem = new SubMenuItem { Text = cultureName, Tooltip = cultureName, ImagePath = iconUrl, ImageAltText = cultureName }; // Build the web part image html bool translationExists = NodeCultures.ContainsKey(cultureCode); if (translationExists) { // Assign click action which changes the document culture menuItem.OnClientClick = "document.location.replace(" + ScriptHelper.GetString(URLHelper.UpdateParameterInUrl(RequestContext.CurrentURL, URLHelper.LanguageParameterName, cultureCode)) + ");"; } else { // Display the "Not translated" image menuItem.RightImageIconClass = "icon-ban-sign"; menuItem.RightImageAltText = PortalHelper.LocalizeStringForUI("onsitedit.culturenotavailable"); // Assign click action -> Create new document culture menuItem.OnClientClick = "NewDocumentCulture(" + pi.NodeID + ",'" + cultureCode + "');"; } cultureItem.SubItems.Add(menuItem); } else { // Current culture cultureItem.Text = culture.CultureShortName; cultureItem.Tooltip = cultureName; cultureItem.ImagePath = iconUrl; cultureItem.ImageAltText = cultureName; } } btnCulture.Buttons.Add(cultureItem); }
/// <summary> /// Method for adding submenu. /// </summary> /// <param name="button">Menu item button</param> /// <param name="cssClass">Button css class</param> /// <param name="identifier">Button identifier</param> private CMSPanel CreateSubMenu(MenuItem button, string cssClass, int identifier) { // Generate sub items container var pnlSubItems = new CMSPanel(); pnlSubItems.ID = "pnlSubItems" + identifier; pnlSubItems.ShortID = "ps" + identifier; pnlSubItems.CssClass = "SubMenuItems ContextMenu"; // Forward scroll button Panel pnlForward = new Panel { ID = "pnlForward", CssClass = "ForwardScroller" }; // Backward scroll button Panel pnlBackward = new Panel { ID = "pnlBackward", CssClass = "BackwardScroller" }; // Scrollable area ScrollPanel pnlMenu = new ScrollPanel { ID = "pnlCultureList", ShortID = "pcl" + identifier, CssClass = "ContextMenuContainer", ScrollAreaCssClass = "PortalContextMenu UniMenuContextMenu", Layout = RepeatDirection.Vertical, InnerItemClass = "Item", ForwardScrollerControlID = pnlForward.ID, BackwardScrollerControlID = pnlBackward.ID, ScrollStep = 200 }; pnlSubItems.Controls.Add(pnlForward); pnlSubItems.Controls.Add(pnlBackward); pnlSubItems.Controls.Add(pnlMenu); // Add menu items int subIdentifier = 0; foreach (SubMenuItem item in button.SubItems) { AddSubMenuItem(pnlMenu, item, cssClass, subIdentifier); subIdentifier++; } return pnlSubItems; }
/// <summary> /// Method for adding button to controls. /// </summary> /// <param name="outerPanel">Panel to be added to</param> /// <param name="identifier">Index of button</param> private void AddButtonTo(CMSPanel outerPanel, int identifier) { MenuItem button = Buttons[identifier]; string caption = button.Text; string tooltip = button.Tooltip; string cssClass = button.CssClass; string onClick = button.OnClientClick; string redirectUrl = button.RedirectUrl; string imagePath = button.ImagePath; string alt = button.ImageAltText; int minWidth = button.MinimalWidth; ImageAlign imageAlign = GetImageAlign(button.ImageAlign); // Generate button image Image buttonImage = new Image(); buttonImage.ID = "img" + identifier; buttonImage.CssClass = "MenuButtonImage"; buttonImage.EnableViewState = false; buttonImage.AlternateText = alt ?? caption; if (!string.IsNullOrEmpty(imagePath)) { buttonImage.ImageUrl = ResolveUrl(imagePath); } buttonImage.ImageAlign = imageAlign; // Generate button text Literal captionLiteral = new Literal(); captionLiteral.ID = "ltlCaption" + identifier; captionLiteral.EnableViewState = false; string separator = (imageAlign == ImageAlign.Top) ? "<br />" : "\n"; captionLiteral.Text = String.Format("{0}<span class=\"MenuButtonText\">{1}</span>", separator, caption); CMSPanel pnlSubItems = null; if (button.SubItems.Count > 0) { // Ensure jQuery tool is loaded ScriptHelper.RegisterJQueryTools(Page); // Append submenu toogle script onClick = "CMSUniMenu.ToogleSubMenu(this);" + onClick; // Append arrow down image for idication sub menu captionLiteral.Text += " <img style=\"width:8px; height:8px;\" src=\"" + GetImageUrl("Design/Controls/UniMenu/ArrowDown.png") + "\" alt=\"Sub menu items\" class=\"SubItemsArrow\" />"; // Create submenu CreateSubMenu(button, ref pnlSubItems, cssClass, identifier); } // Generate button link HyperLink buttonLink = new HyperLink(); buttonLink.ID = "btn" + identifier; buttonLink.EnableViewState = false; buttonLink.Controls.Add(buttonImage); buttonLink.Controls.Add(captionLiteral); if (!string.IsNullOrEmpty(redirectUrl)) { buttonLink.NavigateUrl = ResolveUrl(redirectUrl); } // Generate left border CMSPanel pnlLeft = new CMSPanel(); pnlLeft.ID = "pnlLeft" + identifier; pnlLeft.ShortID = "pl" + identifier; pnlLeft.EnableViewState = false; pnlLeft.CssClass = "Left" + cssClass; // Generate middle part of button CMSPanel pnlMiddle = new CMSPanel(); pnlMiddle.ID = "pnlMiddle" + identifier; pnlMiddle.ShortID = "pm" + identifier; pnlMiddle.EnableViewState = false; pnlMiddle.CssClass = "Middle" + cssClass; pnlMiddle.Controls.Add(buttonLink); if (minWidth > 0) { pnlMiddle.Style.Add("min-width", minWidth + "px"); // IE7 issue with min-width CMSPanel pnlMiddleTmp = new CMSPanel(); pnlMiddleTmp.EnableViewState = false; pnlMiddleTmp.Style.Add("width", minWidth + "px"); pnlMiddle.Controls.Add(pnlMiddleTmp); } // Add sub items if exists if (pnlSubItems != null) { pnlMiddle.Controls.Add(pnlSubItems); } // Generate right border CMSPanel pnlRight = new CMSPanel(); pnlRight.ID = "pnlRight" + identifier; pnlRight.ShortID = "pr" + identifier; pnlRight.EnableViewState = false; pnlRight.CssClass = "Right" + cssClass; // Generate whole button CMSPanel pnlButton = new CMSPanel(); pnlButton.ID = "pnlButton" + identifier; pnlButton.ShortID = BUTTON_PANEL_SHORTID + identifier; pnlButton.EnableViewState = false; if ((AllowSelection && identifier == SelectedIndex) || (button.AllowToggle && button.IsToggled)) { cssClass += SelectedSuffix; } pnlButton.CssClass = cssClass; if (button.AllowToggle) { pnlButton.CssClass += " Toggle"; EnsureAllowToggleScript(); } //Generate button table (IE7 issue) Table tabButton = new Table(); TableRow tabRow = new TableRow(); TableCell tabCellLeft = new TableCell(); TableCell tabCellMiddle = new TableCell(); TableCell tabCellRight = new TableCell(); tabButton.CellPadding = 0; tabButton.CellSpacing = 0; tabButton.Rows.Add(tabRow); tabRow.Cells.Add(tabCellLeft); tabRow.Cells.Add(tabCellMiddle); tabRow.Cells.Add(tabCellRight); // Add inner controls tabCellLeft.Controls.Add(pnlLeft); tabCellMiddle.Controls.Add(pnlMiddle); tabCellRight.Controls.Add(pnlRight); pnlButton.Controls.Add(tabButton); pnlButton.ToolTip = tooltip ?? caption; outerPanel.Controls.Add(pnlButton); if (AllowDraggable) { mStartupScript.Append(String.Format("$j( '#{0}' ).draggable({{ helper:{1}, scope:'{2}' }});", pnlButton.ClientID, GetDraggableHandler(button.DraggableTemplateHandler), button.DraggableScope)); } if (AllowSelection) { onClick = "SelectButton(this);" + onClick; } else if (button.AllowToggle) { onClick = "ToggleButton(this);" + onClick; } pnlButton.Attributes["onclick"] = CheckChanges ? "if (CheckChanges()) {" + onClick + "}" : onClick; // In case of horizontal layout if (HorizontalLayout) { // Stack buttons underneath pnlButton.Style.Add("clear", "both"); } else { // Stack buttons side-by-side pnlButton.Style.Add("float", "left"); } }
/// <summary> /// Applies styles to menu item according to UseSmallButton property. /// </summary> /// <param name="menuItem">Menu item to apply styles to.</param> private void SetStyles(MenuItem menuItem) { menuItem.CssClass = BigButtonCssClass; menuItem.ImageAlign = ImageAlign.Top; menuItem.MinimalWidth = 48; }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { string prefferedCultureCode = LocalizationContext.PreferredCultureCode; string defaultString = GetString("general.default"); InfoDataSet<CultureInfo> siteCultures = CultureSiteInfoProvider.GetSiteCultures(SiteContext.CurrentSiteName); pi = DocumentContext.CurrentPageInfo ?? DocumentContext.CurrentCultureInvariantPageInfo ?? new PageInfo(); // Cultures button MenuItem cultureItem = new MenuItem(); cultureItem.CssClass = "BigButton"; cultureItem.ImageAlign = ImageAlign.Top; cultureItem.ImagePath = URLHelper.UnResolveUrl(UIHelper.GetFlagIconUrl(Page, prefferedCultureCode, "16x16"), SystemContext.ApplicationPath); cultureItem.Text = GetString("general.cultures"); cultureItem.Tooltip = GetString("onsiteedit.languageselector"); cultureItem.ImageAltText = GetString("general.cultures"); // Add all cultures to the sub menu foreach (CultureInfo culture in siteCultures) { string iconUrl = UIHelper.GetFlagIconUrl(Page, culture.CultureCode, "16x16"); string cultureName = culture.CultureName; string cultureCode = culture.CultureCode; string cultureShortName = culture.CultureShortName; if (cultureCode != prefferedCultureCode) { SubMenuItem menuItem = new SubMenuItem() { Text = cultureName, Tooltip = cultureName, ImagePath = iconUrl, ImageAltText = cultureName }; // Build the web part image html bool translationExists = NodeCultures.ContainsKey(cultureCode); if (translationExists) { // Assign click action which changes the document culture menuItem.OnClientClick = "document.location.replace(" + ScriptHelper.GetString(URLHelper.UpdateParameterInUrl(RequestContext.CurrentURL, URLHelper.LanguageParameterName, cultureCode)) + ");"; } else { // Display the "Not translated" image menuItem.RightImageIconClass = "icon-ban-sign"; menuItem.RightImageAltText = GetString("onsitedit.culturenotavailable"); // Assign click action -> Create new document culture menuItem.OnClientClick = "NewDocumentCulture(" + pi.NodeID + ",'" + cultureCode + "');"; } cultureItem.SubItems.Add(menuItem); } else { // Current culture cultureItem.Text = culture.CultureShortName; cultureItem.Tooltip = cultureName; cultureItem.ImagePath = iconUrl; cultureItem.ImageAltText = cultureName; } } btnCulture.Buttons.Add(cultureItem); }
/// <summary> /// Loads device profile menu. /// </summary> private void LoadDevicesMenu() { if (UseSmallButton) { plcSmallButton.Visible = true; } else { plcBigButton.Visible = true; } string defaultString = HTMLHelper.HTMLEncode(GetString("deviceselector.default", ResourceCulture)); StringBuilder sbDeviceProfiles = new StringBuilder(); MenuItem devMenuItem = null; if (!UseSmallButton) { devMenuItem = new MenuItem { Text = defaultString, Tooltip = defaultString, }; // Display icon in On-site editing if ((Page is PortalPage) || (Page is TemplatePage)) { devMenuItem.IconClass = "icon-monitor-smartphone"; } SetStyles(devMenuItem); buttons.Buttons.Add(devMenuItem); } // Load enabled profiles InfoDataSet<DeviceProfileInfo> ds = DeviceProfileInfoProvider.GetDeviceProfiles() .WhereEquals("ProfileEnabled", 1) .OrderBy("ProfileOrder") .TypedResult; if (!DataHelper.DataSourceIsEmpty(ds)) { // Create default item SubMenuItem defaultMenuItem = new SubMenuItem { Text = defaultString, Tooltip = defaultString, OnClientClick = "ChangeDevice('');", }; if (UseSmallButton) { // Insert the current device profile to the button btnProfilesSelector.Actions.Add(new CMSButtonAction() { OnClientClick = String.Format("ChangeDevice({0}); return false;", ScriptHelper.GetString(defaultString)), Text = defaultString }); } else { // Insert the current device profile to the context menu devMenuItem.SubItems.Add(defaultMenuItem); } // Load the profiles list foreach (DeviceProfileInfo profileInfo in ds.Items) { string profileName = GetString(profileInfo.ProfileDisplayName, ResourceCulture); CMSButtonAction deviceButton = null; if (UseSmallButton) { deviceButton = new CMSButtonAction() { OnClientClick = String.Format("ChangeDevice({0}); return false;", ScriptHelper.GetString(profileInfo.ProfileName)), Text = profileName, Name = profileName }; btnProfilesSelector.Actions.Add(deviceButton); } else { SubMenuItem menuItem = new SubMenuItem { Text = HTMLHelper.HTMLEncode(profileName), Tooltip = HTMLHelper.HTMLEncode(profileName), OnClientClick = String.Format("ChangeDevice({0});", ScriptHelper.GetString(profileInfo.ProfileName)) }; devMenuItem.SubItems.Add(menuItem); } // Update main button if current device profile is equal currently processed profile if ((currentDevice != null) && (currentDevice.ProfileName.CompareToCSafe(profileInfo.ProfileName, true) == 0)) { if (UseSmallButton) { btnProfilesSelector.SelectedActionName = profileName; } else { devMenuItem.Text = HTMLHelper.HTMLEncode(profileName); devMenuItem.Tooltip = HTMLHelper.HTMLEncode(profileName); } } } } }
/// <summary> /// Adds given menu item as small button. /// </summary> /// <param name="item">Menu item to be added.</param> private void AddSmallButton(MenuItem item) { AddSmallButton(item, SmallButtonMinimalWidth); }
/// <summary> /// Handles the Load event of the Page control. /// </summary> protected void Page_Load(object sender, EventArgs e) { string prefferedCultureCode = CMSContext.PreferredCultureCode; string defaultSmallIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfiles/default_list.png"); string defaultBigIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfiles/default.png"); string defaultString = GetString("general.default"); InfoDataSet <CultureInfo> siteCultures = CultureInfoProvider.GetSiteCultures(CMSContext.CurrentSiteName); pi = CMSContext.CurrentPageInfo ?? OnSiteEditHelper.PageInfoForPageNotFound; // Cultures button MenuItem cultureItem = new MenuItem(); cultureItem.CssClass = "BigButton"; cultureItem.ImageAlign = ImageAlign.Top; cultureItem.ImagePath = URLHelper.UnResolveUrl(UIHelper.GetFlagIconUrl(Page, prefferedCultureCode, "16x16"), URLHelper.ApplicationPath); cultureItem.Text = GetString("general.cultures"); cultureItem.Tooltip = GetString("onsiteedit.languageselector"); cultureItem.ImageAltText = GetString("general.cultures"); // Add all cultures to the sub menu foreach (CultureInfo culture in siteCultures) { string iconUrl = UIHelper.GetFlagIconUrl(Page, culture.CultureCode, "16x16"); string cultureName = culture.CultureName; string cultureCode = culture.CultureCode; string cultureShortName = culture.CultureShortName; if (cultureCode != prefferedCultureCode) { SubMenuItem menuItem = new SubMenuItem() { Text = cultureName, Tooltip = cultureName, ImagePath = iconUrl, ImageAltText = cultureName }; // Build the web part image html bool translationExists = NodeCultures.ContainsKey(cultureCode); if (translationExists) { // Assign click action which changes the document culture menuItem.OnClientClick = "document.location.replace(" + ScriptHelper.GetString(URLHelper.UpdateParameterInUrl(URLHelper.CurrentURL, URLHelper.LanguageParameterName, cultureCode)) + ");"; } else { // Display the "Not translated" image menuItem.RightImagePath = GetImageUrl("/CMSModules/CMS_PortalEngine/OnSiteEdit/no_culture.png"); menuItem.RightImageAltText = GetString("onsitedit.culturenotavailable"); // Assign click action -> Create new document culture menuItem.OnClientClick = "NewDocumentCulture(" + pi.NodeID + ",'" + cultureCode + "');"; } cultureItem.SubItems.Add(menuItem); } else { // Current culture cultureItem.Text = culture.CultureShortName; cultureItem.Tooltip = cultureName; cultureItem.ImagePath = iconUrl; cultureItem.ImageAltText = cultureName; } } btnCulture.Buttons.Add(cultureItem); }
protected void Page_Load(object sender, EventArgs e) { ScriptHelper.RegisterJQuery(Page); ScriptHelper.RegisterScriptFile(Page, "~/CMSAdminControls/UI/UniMenu/UniMenu.js"); currentSiteName = (SiteID != 0) ? SiteInfoProvider.GetSiteName(SiteID) : CMSContext.CurrentSiteName; DataSet siteCulturesDS = CultureInfoProvider.GetSiteCultures(currentSiteName); if (!DataHelper.DataSourceIsEmpty(siteCulturesDS)) { // Register jQuery cookie script ScriptHelper.RegisterJQueryCookie(Page); string defaultCulture = CultureHelper.GetDefaultCulture(currentSiteName); DataTable siteCultures = siteCulturesDS.Tables[0]; culturesCount = siteCultures.Rows.Count; if ((culturesCount <= MaxCulturesInRow) && (culturesCount > 1)) { // Disable cultures menu btnCultures.StopProcessing = true; for (int i = 0; i < culturesCount; i++) { string cultureCode = siteCultures.Rows[i]["CultureCode"].ToString(); string cultureShortName = siteCultures.Rows[i]["CultureShortName"].ToString(); string cultureLongName = ResHelper.LocalizeString(siteCultures.Rows[i]["CultureName"].ToString()); if (CMSString.Compare(cultureCode, defaultCulture, true) == 0) { cultureLongName += " " + GetString("general.defaultchoice"); } MenuItem item = new MenuItem(); item.Text = HTMLHelper.HTMLEncode(cultureShortName); item.Tooltip = cultureLongName; item.CssClass = "BigButton"; item.OnClientClick = "ChangeLanguage('" + cultureCode + "')"; item.ImagePath = GetFlagIconUrl(cultureCode, "48x48"); item.ImageAltText = cultureLongName; item.ImageAlign = ImageAlign.Top; item.MinimalWidth = 48; buttons.Buttons.Add(item); if (SelectedCulture.ToLowerCSafe() == cultureCode.ToLowerCSafe()) { buttons.SelectedIndex = i; } } } else { // Do not show culture selection buttons buttons.StopProcessing = true; CultureInfo ci = CultureInfoProvider.GetCultureInfo(SelectedCulture); MenuItem item = new MenuItem(); item.Text = ci.CultureShortName; item.Tooltip = GetString(ci.CultureName); item.ImagePath = GetFlagIconUrl(SelectedCulture, UseSmallLanguageButton ? "16x16" : "48x48"); item.ImageAltText = GetString(ci.CultureName); SetStyles(item); // Generate submenu only if more cultures to choose from if (culturesCount > 1) { foreach (DataRow row in siteCultures.Rows) { string cultureCode = row["CultureCode"].ToString(); string cultureShortName = row["CultureShortName"].ToString(); string cultureLongName = GetString(row["CultureName"].ToString()); if (CMSString.Compare(cultureCode, defaultCulture, true) == 0) { cultureLongName += " " + GetString("general.defaultchoice"); } string flagUrl = GetFlagIconUrl(cultureCode, "16x16"); string flagBigUrl = GetFlagIconUrl(cultureCode, "48x48"); SubMenuItem menuItem = new SubMenuItem() { Text = cultureLongName, Tooltip = cultureLongName, ImagePath = flagUrl, ImageAltText = cultureShortName, OnClientClick = String.Format("CMSUniMenu.ChangeButton(##BUTTON##, {0}, {1}); ChangeLanguage({2});", ScriptHelper.GetString(cultureShortName), ScriptHelper.GetString(ResolveUrl(flagBigUrl)), ScriptHelper.GetString(cultureCode)) }; item.SubItems.Add(menuItem); } } btnCultures.Buttons.Add(item); } if (culturesCount > 1) { string compare = GetString("SplitMode.Compare"); // Split mode button MenuItem splitItem = new MenuItem(); splitItem.Text = compare; splitItem.Tooltip = GetString("SplitMode.CompareLangVersions"); splitItem.OnClientClick = "ChangeSplitMode()"; splitItem.ImagePath = GetImageUrl("CMSModules/CMS_Content/Menu/Compare.png"); splitItem.ImageAltText = compare; splitItem.AllowToggle = true; splitItem.IsToggled = CMSContext.DisplaySplitMode; SetStyles(splitItem); splitView.Buttons.Add(splitItem); } else { splitView.StopProcessing = true; } } }
/// <summary> /// Loads device profile menu. /// </summary> private void LoadDevicesMenu() { string defaultSmallIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/default_list.png"); string defaultBigIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/default.png"); if ((Page is PortalPage) || (Page is TemplatePage)) { // Display grayscale icon in On-site editing defaultBigIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/default_grayscale.png"); defaultSmallIconUrl = defaultBigIconUrl; } string deviceSmallIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/list.png"); string deviceBigIconUrl = GetImageUrl("CMSModules/CMS_DeviceProfile/module.png"); string defaultString = HTMLHelper.HTMLEncode(GetString("general.default")); MenuItem devMenuItem = new MenuItem { Text = defaultString, Tooltip = defaultString, ImagePath = defaultBigIconUrl, ImageAltText = defaultString }; SetStyles(devMenuItem); buttons.Buttons.Add(devMenuItem); // Load enabled profiles InfoDataSet<DeviceProfileInfo> ds = DeviceProfileInfoProvider.GetDeviceProfileInfos("ProfileEnabled = 1", "ProfileOrder"); if (!DataHelper.DataSourceIsEmpty(ds)) { // Create default item SubMenuItem defaultMenuItem = new SubMenuItem { Text = defaultString, Tooltip = defaultString, ImagePath = defaultSmallIconUrl, ImageAltText = defaultString, OnClientClick = String.Format("CMSUniMenu.ChangeButton(##BUTTON##, {0}, {1}); ChangeDevice('');", ScriptHelper.GetString(defaultString), ScriptHelper.GetString(ResolveUrl(defaultBigIconUrl))) }; devMenuItem.SubItems.Add(defaultMenuItem); foreach (DeviceProfileInfo profileInfo in ds.Items) { string bigIconUrl = null; string smallIconUrl = null; if (profileInfo.ProfileIconGuid == Guid.Empty) { smallIconUrl = deviceSmallIconUrl; bigIconUrl = deviceBigIconUrl; } else { string iconUrl = MetaFileURLProvider.GetMetaFileUrl(profileInfo.ProfileIconGuid, profileInfo.ProfileName); smallIconUrl = URLHelper.UpdateParameterInUrl(iconUrl, "maxsidesize", "16"); bigIconUrl = URLHelper.UpdateParameterInUrl(iconUrl, "maxsidesize", "24"); } string profileName = GetString(profileInfo.ProfileDisplayName); SubMenuItem menuItem = new SubMenuItem { Text = HTMLHelper.HTMLEncode(profileName), Tooltip = HTMLHelper.HTMLEncode(profileName), ImagePath = smallIconUrl, ImageAltText = HTMLHelper.HTMLEncode(profileName), OnClientClick = String.Format("CMSUniMenu.ChangeButton(##BUTTON##, {0}, {1}); ChangeDevice({2});", ScriptHelper.GetString(profileName), ScriptHelper.GetString(ResolveUrl(bigIconUrl)), ScriptHelper.GetString(profileInfo.ProfileName)) }; devMenuItem.SubItems.Add(menuItem); // Update main button if current device profile is equal currently processed profile if ((currentDevice != null) && (currentDevice.ProfileName.CompareToCSafe(profileInfo.ProfileName, true) == 0)) { devMenuItem.Text = HTMLHelper.HTMLEncode(profileName); devMenuItem.Tooltip = HTMLHelper.HTMLEncode(profileName); devMenuItem.ImagePath = bigIconUrl; devMenuItem.ImageAltText = HTMLHelper.HTMLEncode(profileName); } } } }
/// <summary> /// Method for adding button to controls. /// </summary> /// <param name="outerPanel">Panel to be added to</param> /// <param name="identifier">Index of button</param> private void AddButtonTo(CMSPanel outerPanel, int identifier) { MenuItem button = Buttons[identifier]; string caption = button.Text; string tooltip = button.Tooltip; string cssClass = button.CssClass; string onClick = button.OnClientClick; string redirectUrl = button.RedirectUrl; string imagePath = button.ImagePath; string iconClass = button.IconClass; string alt = button.ImageAltText; int minWidth = button.MinimalWidth; ImageAlign imageAlign = GetImageAlign(button.ImageAlign); // Generate button image WebControl image = null; if (!string.IsNullOrEmpty(imagePath)) { var buttonImage = new Image { ID = "img" + identifier, CssClass = "MenuButtonImage", EnableViewState = false, AlternateText = alt ?? caption, ImageAlign = imageAlign, ImageUrl = ResolveUrl(imagePath) }; image = buttonImage; } else if (!string.IsNullOrEmpty(iconClass)) { var icon = new CMSIcon { ID = "ico" + identifier, EnableViewState = false, ToolTip = tooltip, CssClass = "cms-icon-80 " + iconClass }; image = icon; } // Generate button text Literal captionLiteral = new Literal(); captionLiteral.ID = "ltlCaption" + identifier; captionLiteral.EnableViewState = false; string separator = (imageAlign == ImageAlign.Top) ? "<br />" : "\n"; captionLiteral.Text = String.Format("{0}<span class=\"MenuButtonText\">{1}</span>", separator, caption); CMSPanel pnlSubItems = null; if (button.SubItems.Count > 0) { // Ensure jQuery tool is loaded ScriptHelper.RegisterJQueryTools(Page); // Register support script ScriptHelper.RegisterScriptFile(Page, "~/CMSAdminControls/UI/UniMenu/UniMenu.js"); // Append sub-menu toggle script onClick = "CMSUniMenu.ToogleSubMenu(this);" + onClick; // Append arrow down image for indication sub menu captionLiteral.Text += @"<i aria-hidden=""true"" class=""icon-caret-right-down cms-icon-30""></i>"; // Create submenu pnlSubItems = CreateSubMenu(button, cssClass, identifier); } // Generate button link HyperLink buttonLink = new HyperLink(); buttonLink.ID = "btn" + identifier; buttonLink.EnableViewState = false; if (image != null) { buttonLink.Controls.Add(image); } buttonLink.Controls.Add(captionLiteral); if (!string.IsNullOrEmpty(redirectUrl)) { buttonLink.NavigateUrl = ResolveUrl(redirectUrl); } // Generate left border CMSPanel pnlLeft = new CMSPanel(); pnlLeft.ID = "pnlLeft" + identifier; pnlLeft.ShortID = "pl" + identifier; pnlLeft.EnableViewState = false; pnlLeft.CssClass = "Left" + cssClass; // Generate middle part of button CMSPanel pnlMiddle = new CMSPanel(); pnlMiddle.ID = "pnlMiddle" + identifier; pnlMiddle.ShortID = "pm" + identifier; pnlMiddle.EnableViewState = false; pnlMiddle.CssClass = "Middle" + cssClass; pnlMiddle.Controls.Add(buttonLink); if (minWidth > 0) { pnlMiddle.Style.Add("min-width", minWidth + "px"); // IE7 issue with min-width CMSPanel pnlMiddleTmp = new CMSPanel(); pnlMiddleTmp.EnableViewState = false; pnlMiddleTmp.Style.Add("width", minWidth + "px"); pnlMiddle.Controls.Add(pnlMiddleTmp); } // Add sub items if exists if (pnlSubItems != null) { pnlMiddle.Controls.Add(pnlSubItems); } // Generate right border CMSPanel pnlRight = new CMSPanel(); pnlRight.ID = "pnlRight" + identifier; pnlRight.ShortID = "pr" + identifier; pnlRight.EnableViewState = false; pnlRight.CssClass = "Right" + cssClass; // Generate whole button CMSPanel pnlButton = new CMSPanel(); pnlButton.ID = "pnlButton" + identifier; pnlButton.ShortID = BUTTON_PANEL_SHORTID + identifier; // Propagate attributes to panel for JavaScript use foreach (var entry in button.Attributes) { pnlButton.Attributes.Add(entry.Key, entry.Value); } pnlButton.EnableViewState = false; if (button.AllowToggle && button.IsToggled) { cssClass += SelectedSuffix; } pnlButton.CssClass = cssClass; if (button.AllowToggle) { pnlButton.CssClass += " Toggle"; EnsureAllowToggleScript(); } //Generate button table (IE7 issue) Table tabButton = new Table(); TableRow tabRow = new TableRow(); TableCell tabCellLeft = new TableCell(); TableCell tabCellMiddle = new TableCell(); TableCell tabCellRight = new TableCell(); tabButton.CellPadding = 0; tabButton.CellSpacing = 0; tabButton.Rows.Add(tabRow); tabRow.Cells.Add(tabCellLeft); tabRow.Cells.Add(tabCellMiddle); tabRow.Cells.Add(tabCellRight); // Add inner controls tabCellLeft.Controls.Add(pnlLeft); tabCellMiddle.Controls.Add(pnlMiddle); tabCellRight.Controls.Add(pnlRight); pnlButton.Controls.Add(tabButton); pnlButton.ToolTip = tooltip ?? caption; outerPanel.Controls.Add(pnlButton); if (AllowDraggable) { mStartupScript.Append(String.Format("$cmsj( '#{0}' ).draggable({{ helper:{1}, scope:'{2}' }});", pnlButton.ClientID, GetDraggableHandler(button.DraggableTemplateHandler), button.DraggableScope)); } if (!AllowSelection && button.AllowToggle) { onClick = "ToggleButton(this);" + onClick; } pnlButton.Attributes["onclick"] = CheckChanges ? "if (CheckChanges()) {" + onClick + "}" : onClick; // In case of horizontal layout if (HorizontalLayout) { // Stack buttons underneath pnlButton.Style.Add("clear", "both"); } else { // Stack buttons side-by-side pnlButton.Style.Add("float", "left"); } if (button.IsSelectable) { // Collect panel client IDs for JavaScript mElemsIds += "#" + pnlButton.ClientID + ","; if (AllowSelection && (identifier == SelectedIndex)) { // Button should be selected by default, remember its ClientID for JavaScript defaultSelectedClientID = "#" + pnlButton.ClientID; } } }
/// <summary> /// Loads device profile menu. /// </summary> private void LoadDevicesMenu() { if (UseSmallButton) { plcSmallButton.Visible = true; } else { plcBigButton.Visible = true; } string defaultString = HTMLHelper.HTMLEncode(GetString("deviceselector.default", ResourceCulture)); StringBuilder sbDeviceProfiles = new StringBuilder(); MenuItem devMenuItem = null; if (!UseSmallButton) { devMenuItem = new MenuItem { Text = defaultString, Tooltip = defaultString, }; // Display icon in On-site editing if ((Page is PortalPage) || (Page is TemplatePage)) { devMenuItem.IconClass = "icon-monitor-smartphone"; } SetStyles(devMenuItem); buttons.Buttons.Add(devMenuItem); } // Load enabled profiles InfoDataSet <DeviceProfileInfo> ds = DeviceProfileInfoProvider.GetDeviceProfiles() .WhereEquals("ProfileEnabled", 1) .OrderBy("ProfileOrder") .TypedResult; if (!DataHelper.DataSourceIsEmpty(ds)) { // Create default item SubMenuItem defaultMenuItem = new SubMenuItem { Text = defaultString, Tooltip = defaultString, OnClientClick = "ChangeDevice('');", }; if (UseSmallButton) { // Insert the current device profile to the button btnProfilesSelector.Actions.Add(new CMSButtonAction() { OnClientClick = String.Format("ChangeDevice({0}); return false;", ScriptHelper.GetString(defaultString)), Text = defaultString }); } else { // Insert the current device profile to the context menu devMenuItem.SubItems.Add(defaultMenuItem); } // Load the profiles list foreach (DeviceProfileInfo profileInfo in ds.Items) { string profileName = GetString(profileInfo.ProfileDisplayName, ResourceCulture); CMSButtonAction deviceButton = null; if (UseSmallButton) { deviceButton = new CMSButtonAction() { OnClientClick = String.Format("ChangeDevice({0}); return false;", ScriptHelper.GetString(profileInfo.ProfileName)), Text = profileName, Name = profileName }; btnProfilesSelector.Actions.Add(deviceButton); } else { SubMenuItem menuItem = new SubMenuItem { Text = HTMLHelper.HTMLEncode(profileName), Tooltip = HTMLHelper.HTMLEncode(profileName), OnClientClick = String.Format("ChangeDevice({0});", ScriptHelper.GetString(profileInfo.ProfileName)) }; devMenuItem.SubItems.Add(menuItem); } // Update main button if current device profile is equal currently processed profile if ((currentDevice != null) && (currentDevice.ProfileName.CompareToCSafe(profileInfo.ProfileName, true) == 0)) { if (UseSmallButton) { btnProfilesSelector.SelectedActionName = profileName; } else { devMenuItem.Text = HTMLHelper.HTMLEncode(profileName); devMenuItem.Tooltip = HTMLHelper.HTMLEncode(profileName); } } } } }