public static string ParseText(IAttributes attributes, SiteInfo siteInfo, int channelId, TableStyleInfo styleInfo, StringBuilder extraBuilder) { var validateAttributes = InputParserUtils.GetValidateAttributes(styleInfo.Additional.IsValidate, styleInfo.DisplayName, styleInfo.Additional.IsRequired, styleInfo.Additional.MinNum, styleInfo.Additional.MaxNum, styleInfo.Additional.ValidateType, styleInfo.Additional.RegExp, styleInfo.Additional.ErrorMessage); if (styleInfo.Additional.IsValidate) { extraBuilder.Append( $@"<span id=""{styleInfo.AttributeName}_msg"" style=""color:red;display:none;"">*</span><script>event_observe('{styleInfo.AttributeName}', 'blur', checkAttributeValue);</script>"); } if (styleInfo.Additional.IsFormatString) { var formatStrong = false; var formatEm = false; var formatU = false; var formatColor = string.Empty; var formatValues = attributes.GetString(ContentAttribute.GetFormatStringAttributeName(styleInfo.AttributeName)); if (!string.IsNullOrEmpty(formatValues)) { ContentUtility.SetTitleFormatControls(formatValues, out formatStrong, out formatEm, out formatU, out formatColor); } extraBuilder.Append( $@"<a class=""btn"" href=""javascript:;"" onclick=""$('#div_{styleInfo.AttributeName}').toggle();return false;""><i class=""icon-text-height""></i></a> <script type=""text/javascript""> function {styleInfo.AttributeName}_strong(e){{ var e = $(e); if ($('#{styleInfo.AttributeName}_formatStrong').val() == 'true'){{ $('#{styleInfo.AttributeName}_formatStrong').val('false'); e.removeClass('btn-success'); }}else{{ $('#{styleInfo.AttributeName}_formatStrong').val('true'); e.addClass('btn-success'); }} }} function {styleInfo.AttributeName}_em(e){{ var e = $(e); if ($('#{styleInfo.AttributeName}_formatEM').val() == 'true'){{ $('#{styleInfo.AttributeName}_formatEM').val('false'); e.removeClass('btn-success'); }}else{{ $('#{styleInfo.AttributeName}_formatEM').val('true'); e.addClass('btn-success'); }} }} function {styleInfo.AttributeName}_u(e){{ var e = $(e); if ($('#{styleInfo.AttributeName}_formatU').val() == 'true'){{ $('#{styleInfo.AttributeName}_formatU').val('false'); e.removeClass('btn-success'); }}else{{ $('#{styleInfo.AttributeName}_formatU').val('true'); e.addClass('btn-success'); }} }} function {styleInfo.AttributeName}_color(){{ if ($('#{styleInfo.AttributeName}_formatColor').val()){{ $('#{styleInfo.AttributeName}_colorBtn').css('color', $('#{styleInfo.AttributeName}_formatColor').val()); $('#{styleInfo.AttributeName}_colorBtn').addClass('btn-success'); }}else{{ $('#{styleInfo.AttributeName}_colorBtn').css('color', ''); $('#{styleInfo.AttributeName}_colorBtn').removeClass('btn-success'); }} $('#{styleInfo.AttributeName}_colorContainer').hide(); }} </script> "); extraBuilder.Append($@" <div class=""btn-group btn-group-sm"" style=""float:left;""> <button class=""btn{(formatStrong ? @" btn-success" : string.Empty)}"" style=""font-weight:bold;font-size:12px;"" onclick=""{styleInfo .AttributeName}_strong(this);return false;"">粗体</button> <button class=""btn{(formatEm ? " btn-success" : string.Empty)}"" style=""font-style:italic;font-size:12px;"" onclick=""{styleInfo .AttributeName}_em(this);return false;"">斜体</button> <button class=""btn{(formatU ? " btn-success" : string.Empty)}"" style=""text-decoration:underline;font-size:12px;"" onclick=""{styleInfo .AttributeName}_u(this);return false;"">下划线</button> <button class=""btn{(!string.IsNullOrEmpty(formatColor) ? " btn-success" : string.Empty)}"" style=""font-size:12px;"" id=""{styleInfo .AttributeName}_colorBtn"" onclick=""$('#{styleInfo.AttributeName}_colorContainer').toggle();return false;"">颜色</button> </div> <div id=""{styleInfo.AttributeName}_colorContainer"" class=""input-append"" style=""float:left;display:none""> <input id=""{styleInfo.AttributeName}_formatColor"" name=""{styleInfo.AttributeName}_formatColor"" class=""input-mini color {{required:false}}"" type=""text"" value=""{formatColor}"" placeholder=""颜色值""> <button class=""btn"" type=""button"" onclick=""Title_color();return false;"">确定</button> </div> <input id=""{styleInfo.AttributeName}_formatStrong"" name=""{styleInfo.AttributeName}_formatStrong"" type=""hidden"" value=""{formatStrong .ToString().ToLower()}"" /> <input id=""{styleInfo.AttributeName}_formatEM"" name=""{styleInfo.AttributeName}_formatEM"" type=""hidden"" value=""{formatEm .ToString().ToLower()}"" /> <input id=""{styleInfo.AttributeName}_formatU"" name=""{styleInfo.AttributeName}_formatU"" type=""hidden"" value=""{formatU .ToString().ToLower()}"" /> "); } if (channelId > 0 && styleInfo.AttributeName == ContentAttribute.Title) { extraBuilder.Append(@" <script type=""text/javascript""> function getTitles(title){ $.get('[url]&title=' + encodeURIComponent(title) + '&channelID=' + $('#channelID').val() + '&r=' + Math.random(), function(data) { if(data !=''){ var arr = data.split('|'); var temp=''; for(i=0;i<arr.length;i++) { temp += '<li><a>'+arr[i].replace(title,'<b>' + title + '</b>') + '</a></li>'; } var myli='<ul>'+temp+'</ul>'; $('#titleTips').html(myli); $('#titleTips').show(); }else{ $('#titleTips').hide(); } $('#titleTips li').click(function () { $('#Title').val($(this).text()); $('#titleTips').hide(); }) }); } $(document).ready(function () { $('#Title').keyup(function (e) { if (e.keyCode != 40 && e.keyCode != 38) { var title = $('#Title').val(); if (title != ''){ window.setTimeout(""getTitles('"" + title + ""');"", 200); }else{ $('#titleTips').hide(); } } }).blur(function () { window.setTimeout(""$('#titleTips').hide();"", 200); })}); </script> <div id=""titleTips"" class=""inputTips""></div>"); extraBuilder.Replace("[url]", AjaxCmsService.GetTitlesUrl(siteInfo.Id, channelId)); } var value = StringUtils.HtmlDecode(attributes.GetString(styleInfo.AttributeName)); return ($@"<input id=""{styleInfo.AttributeName}"" name=""{styleInfo.AttributeName}"" type=""text"" class=""form-control"" value=""{value}"" {validateAttributes} />"); }