public static IHtmlControl GetFoundTagListView(SiteState state, out string title) { title = string.Format("Найденные теги по запросу: {0}", state.Option.Get(OptionType.SearchQuery)); List <IHtmlControl> elements = new List <IHtmlControl>(); int[] foundTagIds = state.Option.Get(OptionType.FoundTagIds); if (foundTagIds != null) { foreach (int tagId in foundTagIds) { RowLink tagRow = context.Tags.TagBox.ObjectById.AnyRow(tagId); if (tagRow == null) { continue; } string tagDisplay = TagType.DisplayName.Get(tagRow); elements.Add( new HPanel( new HLink(ViewTagHlp.TagUrl(tagId, 0), tagDisplay) ).MarginBottom(4) ); } } return(new HPanel( Decor.Title(title), new HPanel( elements.ToArray() ) )); }
static IHtmlControl GetSearchPanel(SiteState state) { string editName = "searchText"; string buttonName = "searchButton"; string contentName = "searchContent"; return(new HPanel( new HTextEdit(editName, new HPlaceholder(new HTone().Color("#ccc")).ToStyles()) .BoxSizing().Width(150).Placeholder("Поиск по тегам") .Padding(6).TabIndex(1).Color("#fff").Border("none").Background("none") .CssAttribute("user-select", "none").CssAttribute("outline", "none") .OnKeyDown(string.Format("if (e.keyCode == 13) $('.{0}').click();", buttonName)), new HButton(buttonName, " ", std.BeforeAwesome(@"\f002", 0).FontSize(18).Color(Decor.menuColor) ).PositionAbsolute().Left(0).Top(5).MarginLeft(12) .Title("Найти тег") .Event("search_tag", contentName, delegate(JsonData json) { string searchQuery = json.GetText(editName); if (searchQuery == null || searchQuery.Length < 1) { state.Operation.Message = "Введите тег"; return; } int[] tagIds = context.Tags.SearchByTags(context.FabricConnection, searchQuery); if (tagIds.Length == 0) { state.Operation.Message = "Ничего не найдено"; return; } if (tagIds.Length == 1) { state.RedirectUrl = ViewTagHlp.TagUrl(tagIds[0], 0); return; } state.Option.Set(OptionType.SearchQuery, searchQuery); state.Option.Set(OptionType.FoundTagIds, tagIds); } ) ).InlineBlock().PositionRelative().EditContainer(contentName).FontSize(12) .PaddingLeft(35).PaddingRight(10).MarginLeft(17).MarginBottom(4).MarginTop(3) .Background("rgba(255,255,255,0.2)").Border("1px solid #aaa").BorderRadius(15)); }