コード例 #1
0
        public static MvcHtmlString ThemeVarEditor(this HtmlHelper html, ThemeVariableInfo info, object value)
        {
            Guard.ArgumentNotNull(info, "info");

            string expression = html.NameForThemeVar(info);

			var strValue = string.Empty;

			var arrValue = value as string[];
			if (arrValue != null)
			{
				strValue = arrValue.Length > 0 ? arrValue[0] : value.ToString();
			}
			else
			{
				strValue = value.ToString();
			}

			var currentTheme = ThemeHelper.ResolveCurrentTheme();
			var isDefault = strValue.IsCaseInsensitiveEqual(info.DefaultValue);

			MvcHtmlString control;

            if (info.Type == ThemeVariableType.Color)
            {
				control = html.ColorBox(expression, strValue, info.DefaultValue);
            }
            else if (info.Type == ThemeVariableType.Boolean)
            {
				control = html.CheckBox(expression, strValue.ToBool());
            }
			else if (info.Type == ThemeVariableType.Select)
			{
				control = ThemeVarSelectEditor(html, info, expression, strValue);
			}
			else
			{
				control = html.TextBox(expression, isDefault ? "" : strValue, new { placeholder = info.DefaultValue });
			}

			if (currentTheme != info.Manifest)
			{
				// the variable is inherited from a base theme: display an info badge
				var chainInfo = "<span class='themevar-chain-info'><i class='fa fa-chain fa-flip-horizontal'></i>&nbsp;{0}</span>".FormatCurrent(info.Manifest.ThemeName);
				return MvcHtmlString.Create(control.ToString() + chainInfo);
			}
			else
			{
				return control;
			}	
        }
コード例 #2
0
        public static MvcHtmlString ThemeVarEditor(this HtmlHelper html, ThemeVariableInfo info, object value)
        {
            Guard.ArgumentNotNull(info, "info");

            string expression = html.NameForThemeVar(info);

            if (info.Type == ThemeVariableType.Color)
            {
                return html.ColorBox(expression, value.ToString());
            }
            else if (info.Type == ThemeVariableType.Boolean)
            {
                return html.CheckBox(expression, value.ToString().ToBool());
            }
            else if (info.Type == ThemeVariableType.Select)
            {
                return ThemeVarSelectEditor(html, info, expression, value.ToString());
            }

            return html.TextBox(expression, value);
        }