コード例 #1
0
        public static MvcHtmlString Semantic_Button(this HtmlHelper helper, string id, string text, enButtonType btnType, Size size, object htmlAttributes = null)
        {
            StringBuilder sbHtml = new StringBuilder();

            sbHtml.Append(" <button ");

            var    arrType  = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes).Where(w => w.Key.ToLower() == "type").ToList();
            var    arrClass = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes).Where(w => w.Key.ToLower() == "class").Select(s => s.Value).ToList();;
            string addClass = string.Empty;

            if (arrClass.Count() > 0)
            {
                addClass = string.Join(" ", arrClass);
            }
            if (arrType.Count > 0)
            {
                sbHtml.Append(arrType[0].Key).Append("='").Append(arrType[0].Value).Append("'");
            }
            else
            {
                sbHtml.Append("type='button'");
            }
            sbHtml.Append(" class='ui ");
            switch (btnType)
            {
            case enButtonType.Del:
                sbHtml.Append(" ").Append(SemanticUIHelper.enColor.red.ToString()).Append(" ");
                break;

            case enButtonType.Cancel:
                sbHtml.Append(" ").Append(SemanticUIHelper.enColor.orange.ToString()).Append(" ");
                break;

            case enButtonType.New:
                sbHtml.Append(" ").Append(SemanticUIHelper.enColor.teal.ToString()).Append(" ");
                break;

            case enButtonType.Request:
                sbHtml.Append(" ").Append(SemanticUIHelper.enColor.olive.ToString()).Append(" ");
                break;

            case enButtonType.Save:
                sbHtml.Append(" ").Append(SemanticUIHelper.enColor.blue.ToString()).Append(" ");
                break;

            case enButtonType.Excel:
                sbHtml.Append(" ").Append(SemanticUIHelper.enColor.green.ToString()).Append(" ");
                break;

            case enButtonType.ToList:
                sbHtml.Append(" ").Append(SemanticUIHelper.enColor.grey.ToString()).Append(" ");
                break;

            default:
                break;
            }
            sbHtml.Append(size.ToString()).Append(" button ").Append(addClass).Append("' id='").Append(id).Append("' name='").Append(id).Append("'").Append(SemanticUIHelper.GetHtmlAttributeString(htmlAttributes)).Append("> ").Append("\n");
            sbHtml.Append(text).Append("\n");
            sbHtml.Append(" </button>").Append("\n");

            return(MvcHtmlString.Create(sbHtml.ToString().Trim()));
        }
コード例 #2
0
        /// <summary>
        /// Semintic UI TextBox 정의
        /// </summary>
        /// <param name="helper"></param>
        /// <param name="id"></param>
        /// <param name="value"></param>
        /// <param name="size"></param>
        /// <param name="htmlAttributes"></param>
        /// <returns></returns>
        public static MvcHtmlString Semantic_TextBox(this HtmlHelper helper, string id, string value, Size size, string width, object htmlAttributes = null, string iconName = null, string firstIcon = null)
        {
            StringBuilder sbHtml = new StringBuilder();


            var sHtmlAttr = SemanticUIHelper.GetHtmlAttributeString(htmlAttributes);

            RouteValueDictionary arrHtmlAtribute = HtmlHelper.AnonymousObjectToHtmlAttributes(htmlAttributes);


            if (htmlAttributes != null)
            {
                var classData = arrHtmlAtribute.Where(w => w.Key == "class").ToList();
                if (classData.Count() > 0)
                {
                    arrHtmlAtribute["class"] = arrHtmlAtribute["class"] + " ui input field ";
                    var array = Enum.GetNames(typeof(SemanticUIHelper.Size)).ToList();
                    if (array.Where(w => ((string)classData[0].Value).Contains(w)).Count() == 0)
                    {
                        arrHtmlAtribute["class"] = arrHtmlAtribute["class"] + size.ToString();
                    }
                }
            }

            arrHtmlAtribute["class"] = string.IsNullOrEmpty((string)arrHtmlAtribute["class"]) ? "ui input field " + size.ToString() : arrHtmlAtribute["class"];
            arrHtmlAtribute["class"] = arrHtmlAtribute["class"] + (!string.IsNullOrEmpty(iconName) ? " icon" : "");
            arrHtmlAtribute["class"] = arrHtmlAtribute["class"] + (!string.IsNullOrEmpty(firstIcon) ? " left icon" : "");

            sbHtml.Append("<div ").Append(SemanticUIHelper.GetHtmlAttributeString(arrHtmlAtribute));
            if (width != null)
            {
                sbHtml.Append(" style='width:").Append(width).Append("'");
            }
            sbHtml.Append("> ");

            if (((string)arrHtmlAtribute.Where(w => w.Key == "class").First().Value).Contains("dataclear"))
            {
                /*  <!-- 크롬 비번 자동완성 방지를 위한 input -->
                 *                  <input type="password" style="display: block; width:0px; height:0px; border: 0;" @@focus="$refs.pwdInput.focus()">
                 *                  <input type="password" class="form-control m-b-5" placeholder="패스워드" v-model="user.password" autocomplete="off" ref="pwdInput" />*/

                string addType = arrHtmlAtribute.Where(w => w.Key == "type").Count() > 0 ? " type='" + (string)arrHtmlAtribute.Where(w => w.Key == "type").FirstOrDefault().Value + "' " : "";
                sbHtml.Append("<input  id ='").Append(id).Append("_fake' name = '").Append(id).Append("_fake'").Append(addType).Append(" autocomplete = 'new-password' class='fake-autofill-fields' style = 'display: none;' @focus='$refs.").Append(id).Append("_ref.focus()'>");
            }
            if (!string.IsNullOrEmpty(firstIcon))
            {
                sbHtml.Append("<i class='").Append(firstIcon).Append("'></i>");
            }
            sbHtml.Append("<input  id='").Append(id).Append("' name='").Append(id).Append("' value='").Append(value).Append("'").Append(SemanticUIHelper.GetHtmlAttributeString(htmlAttributes)).Append(" ref='").Append(id).Append("_ref'");

            if (!SemanticUIHelper.GetHtmlAttributeString(htmlAttributes).ToUpper().Contains("TYPE"))
            {
                sbHtml.Append(" type='text' ");
            }

            sbHtml.Append("> ");
            if (!string.IsNullOrEmpty(iconName))
            {
                sbHtml.Append("<i class='").Append(iconName).Append("'></i>");
            }
            sbHtml.Append("</div>                      ");
            return(new MvcHtmlString(sbHtml.ToString().Trim()));
        }