Exemplo n.º 1
0
        public IHtmlNode Build()
        {
            IHtmlNode datagrid = null;
            IHtmlNode div = new HtmlElement("div")
                .Attribute("id", Component.Id)
                .Attributes(Component.HtmlAttributes);
            IHtmlNode script = new HtmlElement("script");

            StringBuilder builder = new StringBuilder();
            builder.AppendFormat("$('#{0}').datagrid(", Component.Id);

            if (Component.Options.Count > 0 ||
                Component.FrozenColumns.Count > 0 ||
                Component.Columns.Count > 0 ||
                Component.ToolBar.Count > 0)
            {
                builder.Append("{ ");
                builder.Append(string.Format("{0}, {1}{2}{3}",
                    Component.Options.ToDataOptionsString(),
                    ConvertColumnsString(Component.FrozenColumns, "frozenColumns"),
                    ConvertColumnsString(Component.Columns, "columns"),
                    ConvertToolbarString(Component.ToolBar)).TrimStart(',').Trim().TrimEnd(','));
                builder.Append(" }");
            }
            builder.Append(");");

            script.Html(builder.ToString());

            datagrid = new LiteralNode(string.Format("{0}\r\n{1}", div.ToString(), script.ToString()));
            return datagrid;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates the file input element.
        /// </summary>
        /// <returns></returns>
        public IHtmlNode CreateFileInput()
        {
            var element = new HtmlElement("input", TagRenderMode.SelfClosing)
                .Attributes(new { type = "file", name = upload.Name, id = upload.Id });

            return element;
        }
        public IHtmlNode Build()
        {
            var div = new HtmlElement("div")
                        .Attributes( new { id = renderingData.Id })
                        .Attributes(renderingData.HtmlAttributes)
                        .ToggleClass("t-state-disabled", !renderingData.Enabled);

            new HtmlElement("input", TagRenderMode.SelfClosing)
                   .Attributes(new
                   {
                       type = "range",
                       name = string.Format("{0}[0]",renderingData.Name),
                       step = renderingData.SmallStep,
                       value = renderingData.SelectionStart
                   })
                   .AppendTo(div);

            new HtmlElement("input", TagRenderMode.SelfClosing)
                   .Attributes(new
                   {
                       type = "range",
                       name = string.Format("{0}[1]", renderingData.Name),
                       step = renderingData.SmallStep,
                       value = renderingData.SelectionEnd
                   })
                   .AppendTo(div);

            return div;
        }
        public IHtmlNode HiddenInputTag()
        {
            IHtmlNode input = new HtmlElement("input", TagRenderMode.SelfClosing)
                    .Attributes(new
                    {
                        type = "text",
                        style = "display:none"
                    });

            if (Component.Items.Any())
            {
                DropDownItem selectedItem = Component.Items[Component.SelectedIndex];
                input.Attribute("value", selectedItem.Value.HasValue() ? selectedItem.Value : selectedItem.Text);
            }

            if (Component.Name.HasValue())
            {
                input.Attributes(Component.GetUnobtrusiveValidationAttributes())
                     .Attributes(new
                     {
                         name = Component.GetName(string.Empty),
                         id = Component.Id
                     })
                     .Attributes(Component.HiddenInputHtmlAttributes);
            }

            return input;
        }
Exemplo n.º 5
0
        private static IHtmlElement CreateBreadcrumpNode(SiteMapNode siteMapNode, Predicate<IHtmlElement> isLastCondition)
        {
            var wrapper = new HtmlElement("li")
                .AddCssClass("toolbar-menu-item")
                .ToggleCssClass("toolbar-menu-current", element => ReferenceEquals(siteMapNode, System.Web.SiteMap.CurrentNode));

            var url = String.IsNullOrEmpty(siteMapNode.Url)
                          ? "javascript:void(0);"
                          : VirtualPathUtility.ToAbsolute(siteMapNode.Url);
            var anchor = new HtmlElement("a", TagRenderMode.Normal)
                .Attribute("href", url)
                .Attribute("title", siteMapNode.Description)
                .ToggleCssClass("home", element => ReferenceEquals(siteMapNode, System.Web.SiteMap.RootNode))
                .ToggleCssClass("last", isLastCondition)
                .AppendTo(wrapper);

            if (String.IsNullOrEmpty(siteMapNode.Title))
            {
                anchor.Html("&nbsp;");
            }
            else
            {
                anchor.Text(siteMapNode.Title);
            }

            return wrapper;
        }
        public IHtmlNode InnerContentTag()
        {
            IHtmlNode root = new HtmlElement("div").AddClass("t-dropdown-wrap", UIPrimitives.DefaultState);

            string text = "&nbsp;";
            var items = Component.Items;
            int selectedIndex = Component.SelectedIndex;

            if (items.Count > 0 && !(string.IsNullOrEmpty(items[selectedIndex].Text) || items[selectedIndex].Text.Trim().Length == 0))
            {
                text = items[selectedIndex].Text;

                if (Component.Encoded) {
                    text = HttpUtility.HtmlEncode(text);
                }
            }

            new HtmlElement("span")
                .AddClass("t-input")
                .Html(text)
                .AppendTo(root);

            IHtmlNode link = new HtmlElement("span").AddClass("t-select");

            new HtmlElement("span")
                .AddClass(UIPrimitives.Icon, "t-arrow-down")
                .Html("select")
                .AppendTo(link);

            link.AppendTo(root);

            return root;
        }
Exemplo n.º 7
0
        private static IHtmlElement CreateMenuNode(IMenuItem node)
        {
            var wrapper = new HtmlElement("li")
                .MergeAttributes(node.HtmlAttributes)
                .ToggleCssClass("active", element => node.IsSelected);

            var url = String.IsNullOrEmpty(node.NavigationUri)
                          ? "javascript:void(0);"
                          : VirtualPathUtility.ToAbsolute(node.NavigationUri);

            var anchor = new HtmlElement("a", TagRenderMode.Normal)
                .Attribute("href", url)
                .Attribute("title", node.Description)
//                .ToggleCssClass("home", element => ReferenceEquals(siteMapNode, System.Web.SiteMap.RootNode))
//                .ToggleCssClass("last", isLastCondition)
                .AppendTo(wrapper);
            
            if (String.IsNullOrEmpty(node.Title))
            {
                anchor.Html("&nbsp;");
            }
            else
            {
                anchor.Text(node.Title);
            }

            return wrapper;
        }
Exemplo n.º 8
0
        public void Should_output_children()
        {
            IHtmlNode tag = new HtmlElement("div");
            tag.Children.Add(new HtmlElement("div"));

            Assert.Equal("<div><div></div></div>", tag.ToString());
        }
Exemplo n.º 9
0
        public void Should_append_to_parent()
        {
            IHtmlNode parent = new HtmlElement("div");
            IHtmlNode child = new HtmlElement("div");
            child.AppendTo(parent);

            Assert.Contains(child, parent.Children);
        }
Exemplo n.º 10
0
        public void Should_not_replace_existing_attributes()
        {
            IHtmlNode tag = new HtmlElement("div");
            tag.Attributes(new Dictionary<string, string> { { "class", "t-widget" } });
            tag.Attributes(new Dictionary<string, string> { { "class", "t-other" } }, false);

            Assert.Equal("t-widget", tag.Attribute("class"));
        }
Exemplo n.º 11
0
        public void Should_attribute_replaces_by_default()
        {
            IHtmlNode tag = new HtmlElement("div");

            tag.Attribute("class", "t-widget");
            tag.Attribute("class", "t-other");

            Assert.Equal("t-other", tag.Attribute("class"));
        }
Exemplo n.º 12
0
        public void Should_clear_children_when_setting_text()
        {
            IHtmlNode tag = new HtmlElement("div");
            tag.Children.Add(new HtmlElement("div"));

            tag.Text("test");

            Assert.Equal(0, tag.Children.Count);
        }
Exemplo n.º 13
0
        public IHtmlNode Build()
        {
            IHtmlNode root = new HtmlElement("div")
                            .Attributes(Component.HtmlAttributes)
                            .PrependClass(UIPrimitives.Widget, "t-combobox", UIPrimitives.Header)
                            .ToggleClass("t-state-disabled", !Component.Enabled);

            this.InnerContentTag().AppendTo(root);
            this.HiddenInputTag().AppendTo(root);

            return root;
        }
Exemplo n.º 14
0
        /// <summary>
        /// Creates the file input element.
        /// </summary>
        /// <returns></returns>
        public IHtmlNode CreateFileInput()
        {
            var element = new HtmlElement("input", TagRenderMode.SelfClosing)
                .Attributes(new { type = "file", name = upload.Name, id = upload.Id });

            if (upload.HtmlAttributes.ContainsKey("accept"))
            {
                element.Attributes(new { accept = upload.HtmlAttributes["accept"].ToString().ToLowerInvariant() });
            }

            return element;
        }
Exemplo n.º 15
0
        public IHtmlElement Render()
        {
            var wrapper = new HtmlElement("div")
                .MergeAttributes(context.HtmlAttributes)
                .AddCssClass("lib-grid-wrapper");

            RenderTableHeader(wrapper);
            RenderTableBody(wrapper);
            RenderTableFooter(wrapper);

            return wrapper;
        }
Exemplo n.º 16
0
        public IHtmlNode NotificationTag()
        {
            var defaultOptions = new Dictionary<string, object>();
            FluentDictionary.For(defaultOptions)
                .Add("id", Notification.Name);

            var el = new HtmlElement(Notification.Tag)
                   .Attributes(defaultOptions)
                   .Attributes(Notification.HtmlAttributes);

            return el;
        }
Exemplo n.º 17
0
        public IHtmlNode Build()
        {
            IHtmlNode textbox = new HtmlElement("a")
                .Attribute("id", Component.Id)
                .Attribute("onclick", Component.OnClick)
                .Attribute("data-options", Component.Options.ToDataOptionsString())
                .AddClass(new string[] { "easyui-linkbutton" })
                .Attributes(Component.HtmlAttributes)
                .Text(Component.Text);

            return textbox;
        }
Exemplo n.º 18
0
        public IHtmlNode ButtonTag(IWindowButton button)
        {
            IHtmlNode linkTag = new HtmlElement("a")
                                .AddClass(UIPrimitives.Link)
                                .Attribute("href", button.Url);

            linkTag.Children.Add(new HtmlElement("span")
                            .AddClass(UIPrimitives.Icon, button.CssClass)
                            .Html(button.Name));

            return linkTag;
        }
Exemplo n.º 19
0
        private void AppendCol(HtmlElement colgroup, string columnWidth, bool hidden)
        {
            if (hidden) return;

            var col = new HtmlElement("col",TagRenderMode.SelfClosing);

            if (columnWidth.HasValue())
            {
                col.Css("width", columnWidth);
            }

            col.AppendTo(colgroup);
        }
        public IHtmlNode ButtonTag()
        {
            IHtmlNode wrapper = new HtmlElement("span")
                                .AddClass("t-select");

            new HtmlElement("span")
                .AddClass(UIPrimitives.Icon, "t-icon-calendar")
                .Attribute("title", Component.ButtonTitle)
                .Html(Component.ButtonTitle)
                .AppendTo(wrapper);

            return wrapper;
        }
Exemplo n.º 21
0
        protected override void WriteHtmlTo(HtmlTextWriter writer)
        {
            var ul = new HtmlElement("ul");

            ul.MergeAttributes(HtmlAttributes);

            foreach (var current in Items)
            {
                CreateMenuNode(current).AppendTo(ul);
            }

            ul.WriteTo(writer);
        }
Exemplo n.º 22
0
        public IHtmlNode ButtonTag()
        {
            var defaultOptions = new Dictionary<string, object>();
            FluentDictionary.For(defaultOptions)
                .Add("id", Button.Name);

            var el = new HtmlElement(Button.Tag)
                   .Attributes(defaultOptions)
                   .Attributes(Button.HtmlAttributes);

            Button.Template.Apply(el);

            return el;
        }
        public IHtmlNode Build()
        {
            IHtmlNode root = new HtmlElement("div")
                                .Attributes(Component.HtmlAttributes)
                                .PrependClass(UIPrimitives.Widget, "t-dropdown", UIPrimitives.Header)
                                .ToggleClass("t-state-disabled", !Component.Enabled)
                                .ToggleClass("input-validation-error", !Component.IsValid());

            this.InnerContentTag().AppendTo(root);

            this.HiddenInputTag().AppendTo(root);

            return root;
        }
Exemplo n.º 24
0
        /// <summary>
        /// 新增
        /// </summary>
        /// <param name="title"></param>
        /// <param name="htmlAttributes"></param>
        /// <returns></returns>
        public static HtmlElement Create(string title = null, Dictionary<string, string> htmlAttributes = null)
        {
            var ele = new HtmlElement("input")
                .Set("type", "submit")
                .Set("value", title ?? "确认新增")
                .Set("class", "button green");

            if (htmlAttributes != null)
                foreach (var htmlAttribute in htmlAttributes)
                {
                    ele.Set(htmlAttribute.Key, htmlAttribute.Value);
                }
            return ele;
        }
Exemplo n.º 25
0
        protected override void WriteHtmlTo(HtmlTextWriter writer)
        {
            var ul = new HtmlElement("ul");

            ul.MergeAttributes(HtmlAttributes);

            for (var current = System.Web.SiteMap.CurrentNode; current != null; current = current.ParentNode)
            {
                CreateBreadcrumpNode(current, element => false).PrependTo(ul);
            }

            CreateBreadcrumpNode(LastNode(), element => true).AppendTo(ul);

            ul.WriteTo(writer);
        }
Exemplo n.º 26
0
        /// <summary>
        /// 关闭
        /// </summary>
        /// <param name="title"></param>
        /// <param name="htmlAttributes"></param>
        /// <returns></returns>
        public static HtmlElement Close(string title = null, Dictionary<string, string> htmlAttributes = null)
        {
            var ele = new HtmlElement("input")
                .Set("type", "button")
                .Set("value", title ?? "关闭")
                .Set("class", "button white")
                .Set("onclick", "javascript: self.close()");

            if (htmlAttributes != null)
                foreach (var htmlAttribute in htmlAttributes)
                {
                    ele.Set(htmlAttribute.Key, htmlAttribute.Value);
                }
            return ele;
        }
Exemplo n.º 27
0
        public IHtmlNode CreateTable()
        {
            var table = new HtmlElement("table");

            var colgroup = new HtmlElement("colgroup");
            colgroup.AppendTo(table);

            foreach (var colData in colsData)
            {
                AppendCol(colgroup, colData.Width, colData.Hidden);
            }

            ApplyDecorators(table);

            return table;
        }
        public IHtmlNode Build()
        {
            IHtmlNode wrapper = new HtmlElement("div")
                                .Attributes(Component.HtmlAttributes)
                                .PrependClass(UIPrimitives.Widget, "t-timepicker");

            IHtmlNode innerWrapper = new HtmlElement("div")
                                    .AddClass("t-picker-wrap")
                                    .AppendTo(wrapper);

            InputTag().AppendTo(innerWrapper);

            if(Component.ShowButton)
                ButtonTag().AppendTo(innerWrapper);

            return wrapper;
        }
Exemplo n.º 29
0
        public IHtmlNode CreateUpload()
        {
            var element = new HtmlElement("input", TagRenderMode.SelfClosing);
            var attributes = new Dictionary<string, object>
            {   { "type", "file" },
                { "name", upload.Name },
                { "id", upload.Id }
            };

            foreach (var attr in upload.HtmlAttributes)
            {
                attributes[attr.Key] = attr.Value;
            }

            element.Attributes(attributes);

            return element;
        }
Exemplo n.º 30
0
        private void RenderTableHeader(IHtmlElement wrapper)
        {
            var container = new HtmlElement("div")
                .AddCssClass("lib-grid-header")
                .AppendTo(wrapper);

            if (!String.IsNullOrEmpty(context.Caption))
            {
//                new HtmlElement("caption").Text(context.Caption).AppendTo(table);
                new HtmlElement("caption").Text(context.Caption).AppendTo(container);
            }

            var c = new HtmlElement("div").AddCssClass("lib-grid-columns").AppendTo(container);

            if (context.Scrolling.Enabled)
            {
                c.Css("padding-right", Unit.Pixels(17).ToString());
            }

            var table = new HtmlElement("table")
                .Css("width", new Unit(100, UnitType.Percentage).ToString())
                .AppendTo(c);

            CreateColGroups(table);

            /*var groups = new HtmlElement("colgroup").AppendTo(table);

            foreach (var column in context.Columns.Where(column => column.Visible))
            {
                var group = new HtmlElement("col", TagRenderMode.SelfClosing);

                if (column.Widht != Unit.Empty)
                {
                    group.Css("width", column.Widht.ToString()).AppendTo(groups);
                }
            }*/

            var head = new HtmlElement("thead").AppendTo(table);

            headerRendererFactory
                .CreateRenderer(context)
                .RenderHeader()
                .AppendTo(head);
        }