Ejemplo n.º 1
0
        public static string Detail(this Tk5FieldInfoEx field, IFieldValueProvider row, bool showHint, bool needId)
        {
            TkDebug.AssertArgumentNull(field, "field", null);

            HtmlAttributeBuilder builder = new HtmlAttributeBuilder();

            AddNormalAttribute(field, builder, field.NickName, needId, true);
            object fieldValue = row[field.NickName];

            builder.Add("data-value", fieldValue.ToString());
            HtmlAttribute classAttr = builder["class"];

            if (classAttr == null)
            {
                builder.Add("class", "detail-content");
            }
            else
            {
                classAttr.Value = HtmlCommonUtil.MergeClass(classAttr.Value, "detail-content");
            }
            string displayValue = DisplayUtil.GetDisplayString(field.ListDetail.DetailDisplay,
                                                               fieldValue, field, row);

            return(string.Format(ObjectUtil.SysCulture, "<div {0}>{1}</div>",
                                 builder.CreateAttribute(), displayValue));
        }
Ejemplo n.º 2
0
        internal static string GetTotalClass(string @class, BootcssButton buttonType, bool block)
        {
            string buttonClass = BUTTON_ARRAY[(int)buttonType];
            string blockClass  = block ? "btn-block" : string.Empty;
            string totalClass  = HtmlCommonUtil.MergeClass("btn", buttonClass, blockClass, @class);

            return(totalClass);
        }
        public string GetHtml(Tk5FieldInfoEx field, IFieldValueProvider provider, bool needId)
        {
            TkDebug.AssertArgumentNull(field, "field", this);

            string startHtml = field.EasySearch(provider, true);
            string endHtml   = HtmlCommonExtension.EasySearchEnd(field, provider);

            return(HtmlCommonUtil.GetRangeCtrl(startHtml, endHtml));
        }
Ejemplo n.º 4
0
        private static string CreateRowOperator(IFieldValueProvider row, HtmlAttributeBuilder attrBuilder, Operator operRow)
        {
            string caption    = operRow.Caption;
            string urlContent = operRow.Content;

            if (string.IsNullOrEmpty(urlContent))
            {
                return(string.Format(ObjectUtil.SysCulture, "<li>{0}</li>", caption));
            }
            else
            {
                attrBuilder.Clear();
                attrBuilder.Add("href", "#");
                string info = operRow.Info ?? string.Empty;
                bool   isJs = info.Contains("JS");
                if (isJs)
                {
                    string js = "javascript:" + HtmlCommonUtil.ResolveString(row, urlContent);
                    attrBuilder.Add("onClick", js);
                }
                else
                {
                    string attrUrl;
                    if (info.Contains("Dialog"))
                    {
                        string dialogTitle = HtmlCommonUtil.ResolveString(row, operRow.DialogTitle);
                        attrBuilder.Add("data-title", dialogTitle);
                        attrUrl = "data-dialog-url";
                    }
                    else if (info.Contains("AjaxUrl"))
                    {
                        attrUrl = "data-ajax-url";
                    }
                    else
                    {
                        attrUrl = "data-url";
                    }
                    attrBuilder.Add(attrUrl, HtmlUtil.ParseLinkUrl(row, urlContent));
                    string dataConfirm = operRow.ConfirmData;
                    if (!string.IsNullOrEmpty(dataConfirm))
                    {
                        attrBuilder.Add("data-confirm", dataConfirm);
                    }
                }
                if (info.Contains("_blank"))
                {
                    attrBuilder.Add("data-target", "_blank");
                }
                return(string.Format(ObjectUtil.SysCulture, "<li><a {0}>{1}</a></li>",
                                     attrBuilder.CreateAttribute(), caption));
            }
        }
Ejemplo n.º 5
0
        private static void AddNormalAttribute(Tk5FieldInfoEx field, HtmlAttributeBuilder builder,
                                               string name, bool needId, bool isHidden = false)
        {
            if (needId)
            {
                builder.Add("id", name);
            }
            builder.Add("name", name);
            string editClass = field.Edit == null ? null : field.Edit.Class;

            if (!isHidden)
            {
                builder.Add("class", HtmlCommonUtil.MergeClass("form-control", editClass));
                builder.Add("data-title", field.DisplayName);
            }
            else if (!string.IsNullOrEmpty(editClass))
            {
                builder.Add("class", editClass);
            }
            if (field.Edit != null)
            {
                builder.AddRange(field.Edit.AttributeList);
            }
        }
Ejemplo n.º 6
0
        public static string ParseLinkUrl(IFieldValueProvider provider, string content)
        {
            string linkUrl = HtmlCommonUtil.ResolveString(provider, content);

            return(WebUtil.ResolveUrl(linkUrl));
        }
Ejemplo n.º 7
0
 public static string EditCaption(string nickName, string caption, int col, string @class)
 {
     return(string.Format(ObjectUtil.SysCulture,
                          "<label for=\"{0}\" class=\"{1}\">{2}</label>", nickName,
                          HtmlCommonUtil.MergeClass(GetColClass(col), @class), caption));
 }
Ejemplo n.º 8
0
        private static string ListButtonFromConfig(Operator optr, IFieldValueProvider receiver)
        {
            string icon;

            if (!string.IsNullOrEmpty(optr.IconClass))
            {
                icon = string.Format(ObjectUtil.SysCulture, "<i class=\"{0} mr5\"></i>",
                                     optr.IconClass);
            }
            else
            {
                icon = string.Empty;
            }
            HtmlAttributeBuilder builder = new HtmlAttributeBuilder();
            string totalClass            = BootcssCommonUtil.GetTotalClass("mr10", BootcssButton.Default, false);

            builder.Add("type", "button");
            builder.Add("class", totalClass);

            string info = optr.Info ?? string.Empty;
            string attrUrl;
            bool   isJs = info.Contains("JS");

            if (isJs)
            {
                string js = "javascript:" + HtmlCommonUtil.ResolveString(receiver,
                                                                         optr.Content);
                builder.Add("onClick", js);
            }
            else
            {
                if (info.Contains("Dialog"))
                {
                    attrUrl = "data-dialog-url";
                    string dialogTitle = HtmlCommonUtil.ResolveString(receiver, optr.DialogTitle);
                    builder.Add("data-title", dialogTitle);
                }
                else if (info.Contains("AjaxUrl"))
                {
                    attrUrl = "data-ajax-url";
                    if (info.Contains("Post"))
                    {
                        builder.Add("data-method", "post");
                    }
                }
                else
                {
                    attrUrl = "data-url";
                }
                builder.Add(attrUrl, HtmlUtil.ParseLinkUrl(receiver, optr.Content));
                if (!string.IsNullOrEmpty(optr.ConfirmData))
                {
                    builder.Add("data-confirm", optr.ConfirmData);
                }
            }

            string button = string.Format(ObjectUtil.SysCulture, "<button {1}>{2}{0}</button>",
                                          optr.Caption, builder.CreateAttribute(), icon);

            return(button);
        }