public static HtmlTag ActionAjax(this IHtmlHelper helper, string url, int minHeight, string placeholderText) { var placeholderTag = new DivTag(); placeholderTag.Append(new HtmlTag("h6").Text(placeholderText)); var spinnerTag = new DivTag(); spinnerTag.Append(new HtmlTag("i").AddClasses("fa", "fa-spinner", "fa-pulse", "fa-fw")); var errorMessage = "Restarting the ODS / API is known to solve issues with first time setup or previously cached information, and may help resolve this issue on its own." + " Please try restarting the ODS / API now and reload this to see if this same error occurs." + " If the error persists, please check the application logs and then feel to schedule a ticket via <a href='https://tracker.ed-fi.org/projects/EDFI/issues'>Ed-Fi Tracker</a>" + " or visit <a href='https://techdocs.ed-fi.org/display/ADMIN'>Admin App documentation</a> for more information."; var contentLoadingArea = new DivTag().Data("source-url", url).Data("error-message", errorMessage).AddClass("load-action-async"); if (minHeight > 0) { //adding a minimum height is optional, but can help prevent the page scrollbar from jumping around while content loads contentLoadingArea.Attr("style", $"min-height: {minHeight}px"); } contentLoadingArea.Append(placeholderTag); contentLoadingArea.Append(spinnerTag); return(contentLoadingArea); }
protected DivTag BuildDiv() { var divTag = new DivTag("imageDiv"); divTag.Attr("title", _toolTip); divTag.AddClasses(_divCssClasses); return(divTag); }
public static ScopedHtmlHelper <T> VisibleWhenChecked <T>(this HtmlHelper <T> helper, Expression <Func <T, bool> > property, bool visible, Action <HtmlTag> mutator = null) { var propertyName = property.GetExpressionText(); var name = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(propertyName); var modelChecked = helper.ViewData.ModelState.ContainsKey(name); if (!modelChecked) { var modelValue = ModelMetadata.FromLambdaExpression(property, helper.ViewData).Model; modelChecked = modelValue != null && (bool)modelValue; } var container = new DivTag().NoClosingTag(); if (visible && !modelChecked || !visible && modelChecked) { container.AddClasses("show-hide-hidden"); } if (visible) { container.Attr("data-checkbox-checked-show", name); } else { container.Attr("data-checkbox-checked-hide", name); } if (mutator != null) { mutator(container); } helper.ViewContext.Writer.Write(container.ToHtmlString()); return(new ScopedHtmlHelper <T>(helper, () => { helper.ViewContext.Writer.Write($"</{container.TagName()}>"); })); }
public static ScopedHtmlHelper <T> VisibleWhenValue <T>(this HtmlHelper <T> helper, Expression <Func <T, bool?> > property, string value, Action <HtmlTag> mutator = null) { var propertyName = property.GetExpressionText(); var name = helper.ViewContext.ViewData.TemplateInfo.GetFullHtmlFieldName(propertyName); string modelValue = null; var modelState = helper.ViewData.ModelState; if (modelState.ContainsKey(name)) { modelValue = (modelState[name].Value?.AttemptedValue ?? "").ToString(); } else { modelValue = (ModelMetadata.FromLambdaExpression(property, helper.ViewData).Model ?? "").ToString(); } var container = new DivTag().NoClosingTag(); if (modelValue != value) { container.AddClasses("show-hide-hidden"); } container.Attr("data-radio-show-name", name); container.Attr("data-radio-show-value", value); if (mutator != null) { mutator(container); } helper.ViewContext.Writer.Write(container.ToHtmlString()); return(new ScopedHtmlHelper <T>(helper, () => { helper.ViewContext.Writer.Write($"</{container.TagName()}>"); })); }
protected override HtmlTag CreateTag() { var label = new HtmlTag("label").Attr("for", _id); if (_mandatory && !_control.HandlesMandatoryInline()) { label.Append(NewMandatory()); } label.Append(new HtmlTag("span").Text(_labelText)); var controlTag = _control.GenerateTag(_mandatory); var inputWrapper = new DivTag().AddClasses("input-wrapper").Append(controlTag); var formGroup = new DivTag() .Id(_id + "_FormGroup") .AddClasses("form-group") .Append(label) .Append(inputWrapper); if (!string.IsNullOrWhiteSpace(_hintHtml)) { var hint = new HtmlTag("p").AddClasses("help-block").AppendHtml(_hintHtml); label.Append(hint); } if (_controlWidth.HasValue && _controlWidth.Value != ControlWidth.Max) { inputWrapper.AddClass("control-width-" + _controlWidth.Value.ToString().ToLower()); } if (_initiallyHidden) { formGroup.AddClasses("initially-hidden"); } if (!_visible) { formGroup.Style("display", "none"); } if (!string.IsNullOrWhiteSpace(_ajaxOnChangeAction)) { formGroup.Attr("data-ajax-change", UrlHelper.Content(_ajaxOnChangeAction)); } return(formGroup); }
public static HtmlTag ActionAjax(this IHtmlHelper helper, string url, int minHeight, string placeholderText) { var placeholderTag = new DivTag(); placeholderTag.Append(new HtmlTag("h6").Text(placeholderText)); var spinnerTag = new DivTag(); spinnerTag.Append(new HtmlTag("i").AddClasses("fa", "fa-spinner", "fa-pulse", "fa-fw")); var contentLoadingArea = new DivTag().Data("source-url", url).AddClass("load-action-async"); if (minHeight > 0) { //adding a minimum height is optional, but can help prevent the page scrollbar from jumping around while content loads contentLoadingArea.Attr("style", $"min-height: {minHeight}px"); } contentLoadingArea.Append(placeholderTag); contentLoadingArea.Append(spinnerTag); return(contentLoadingArea); }
public static HtmlTag ActionAjax(this HtmlHelper helper, string actionName, string controllerName, object routeValues, int minHeight = 0, string placeholderText = "") { var url = new UrlHelper(helper.ViewContext.RequestContext).Action(actionName, controllerName, routeValues); var placeholderTag = new DivTag(); placeholderTag.Append(new HtmlTag("h6").Text(placeholderText)); var spinnerTag = new DivTag(); spinnerTag.Append(new HtmlTag("i").AddClasses("fa", "fa-spinner", "fa-pulse", "fa-fw")); var contentLoadingArea = new DivTag().Data("source-url", url).AddClass("load-action-async"); if (minHeight > 0) { //adding a minimum height is optional, but can help prevent the page scrollbar from jumping around while content loads contentLoadingArea.Attr("style", $"min-height: {minHeight}px"); } contentLoadingArea.Append(placeholderTag); contentLoadingArea.Append(spinnerTag); return(contentLoadingArea); }