public static HtmlTag DataBind(this HtmlTag tag, string appendValue) { var value = string.Empty; if (tag.HasAttr("data-bind")) { value = tag.Attr("data-bind") + ", "; } value += appendValue; tag.Attr("data-bind", value); return tag; }
/// <summary> /// /// </summary> /// <param name="e"></param> /// <param name="className"></param> /// <returns></returns> public static XElement SetClassName(this XElement e, string className) { if (!e.HasClassName(className)) { var currentClasses = e.Attr("class").SmartSplit(false, true, ' '); currentClasses.Add(className); var currentClass = string.Join(" ", currentClasses); e.SetAttributeValue("class",currentClass); } return e; }
internal static List<MethodInfo> GetActionMethods(this Type t) { if (t.HasAttr<ArgActionType>()) { t = t.Attr<ArgActionType>().ActionType; } return (from m in t.GetMethods() where m.HasAttr<ArgActionMethod>() select m).ToList(); }
/// <summary> /// Populates the input tag with unobtrusive validation attributes /// </summary> /// <param name="tag"></param> /// <param name="info"></param> /// <returns></returns> public static HtmlTag AddValidationAttributes(this HtmlTag tag, ModelInfo info) { if (!tag.IsInputElement()) return tag; var all = ModelValidatorProviders.Providers.GetValidators(info.Meta, info.ViewContext) .SelectMany(d => d.GetClientValidationRules()); var attr = new Dictionary<string, object>(); UnobtrusiveValidationAttributesGenerator.GetValidationAttributes(all, attr); foreach (var kv in attr) { tag.Attr(kv.Key, kv.Value); } return tag; }
public static HtmlTag Watermark(this HtmlTag textbox, string watermark) { return textbox .Attr("onfocus", "javascript:Watermark.focusInput($(this));") .Attr("onblur", "javascript:Watermark.blurInput($(this));") .WrapWith(new HtmlTag("div")) .Style("position", "relative") .Style("display", "inline") .Append(new HtmlTag("span") .AddClass("watermark") .Style("position", "absolute") .Style("left", "15px") .Style("top", "2px") .Text(" " + watermark + " ") .Attr("onclick", "javascript:Watermark.focusSpan($(this));") .Attr("onfocus", "javascript:Watermark.focusSpan($(this));") .Attr("onblur", "javascript:Watermark.blurSpan($(this));") ); }
public static HtmlTag RowSpan(this HtmlTag tag, int rowSpan) { tag.Attr(HtmlAttributeConstants.Rowspan, rowSpan); return tag; }
public static CQ Attr(this CQ cq, string attrName, Func<string, string> transformAttribute) { cq.Attr(attrName, transformAttribute(cq.Attr(attrName))); return cq; }
public static HtmlTag ClickToEditContext(this HtmlTag tag, object context) { tag.Attr("ClickToEditContext", JsonUtil.ToJson(context)); return tag; }
public static HtmlTag ColumnSpan(this HtmlTag tag, int columns) { tag.Attr(HtmlAttributeConstants.Colspan, columns); return tag; }
public static HtmlTag ShouldHaveAttribute(this HtmlTag tag, string key, string value) { tag.Attr(key).ShouldEqual(value); return tag; }
/// <summary> /// /// </summary> /// <param name="e"></param> /// <param name="className"></param> /// <returns></returns> public static bool HasClassName(this XElement e, string className) { return e.Attr("class").SmartSplit(false, true, ' ').Contains(className); }
/// <summary> /// Applys the autofocus attribute to a given field /// </summary> /// <param name="config">Field configuration to modify</param> /// <returns>The instance of IFieldConfiguration passed in to continue chaining things</returns> public static IFieldConfiguration AutoFocus(this IFieldConfiguration config) { if (config != null) return config.Attr("autofocus", "autofocus"); return null; }
public static HtmlTag AddPlaceholder(this HtmlTag tag, string placeholder) { return tag.Attr("placeholder", placeholder); }
public static HtmlTag Value(this HtmlTag tag, object value) { tag.Attr(HtmlAttributeConstants.Value, value); return tag; }
/// <summary> /// Sets the tab index of a given field /// </summary> /// <param name="config">Field configuration to update</param> /// <param name="index">Tab index to be set</param> /// <returns>The instance of IFieldConfiguration passed in to continue chaining things</returns> public static IFieldConfiguration TabIndex(this IFieldConfiguration config, int index) { if (config != null) return config.Attr("tabindex", index); return null; }
public static String ConfigName(this Type t) { if (t == null) return null; t.HasAttr<ConfigAttribute>().AssertTrue(); return t.Attr<ConfigAttribute>().Name; }
// The `WithMedia` Extension allows you to set the media attribute of // the rendered CSS tag. public static IBale WithMedia(this IBale bale, string media) { return bale.Attr("media", media); }
public static CheckboxTag Name(this CheckboxTag tag, string name) { tag.Attr(HtmlAttributeConstants.Name, name); return tag; }
public static HtmlTag Autocomplete(this HtmlTag tag, bool turnedOn) { return tag.Attr("autocomplete", turnedOn ? "on" : "off"); }
public static bool BuildSitefinityReference(this CQ htmlElement) { bool result = false; string imgFile = Path.GetFileName(htmlElement.Attr("src")); var sfImg = App.WorkWith().Images().Where(i => i.Status == ContentLifecycleStatus.Master).Get().ToList().Where(i => Path.GetFileName(i.FilePath) == imgFile.ToLower()).FirstOrDefault(); if (sfImg != null) { var manager = LibrariesManager.GetManager(); var album = manager.GetAlbums().Where(a => a.Id == sfImg.Album.Id).FirstOrDefault(); string urlRoot = Telerik.Sitefinity.Configuration.Config.Get<LibrariesConfig>().Images.UrlRoot; var sfImgLive = App.WorkWith().Image(sfImg.Id).GetLive().Get(); var sfRef = "[" + urlRoot + "|" + (LibrariesDataProvider)album.Provider + "]" + sfImgLive.Id; htmlElement.Attr("sfref", sfRef); string relativeUrl = new Uri(sfImg.MediaUrl).AbsolutePath; htmlElement.Attr("src", relativeUrl); result = true; } return result; }
public static HtmlTag Autofocus(this HtmlTag tag) { return tag.Attr("autofocus", "autofocus"); }
/// <summary> /// Adds the given icon to the start of a navigation button. /// </summary> /// <example> /// @n.Submit("Submit").WithIcon("arrow-right") /// // Output: /// <button type="submit"><span class="glyphicon glyphicon-arrow-right"></span> Submit</button> /// </example> /// <param name="attrs">The Html Attributes from a navigation button</param> /// <param name="icon">The icon to use; see http://getbootstrap.com/components/#glyphicons-glyphs</param> /// <returns>The Html Attribute object so other methods can be chained off of it</returns> public static ButtonHtmlAttributes WithIcon(this ButtonHtmlAttributes attrs, string icon) { attrs.Attr(TwitterBootstrapFormTemplate.IconAttrKey, icon); return attrs; }
public static bool Attr(this XElement elem, XName name, bool defaultValue) { bool value; return bool.TryParse(elem.Attr(name),out value) ? value : defaultValue; }
public static HtmlTag ClickToEditAction(this HtmlTag tag, string actionUrl) { tag.Attr("ClickToEditAction", actionUrl); return tag; }
public static IHtml AttrIf(this IHtml n, bool condition, Func<object[]> trueFn, Func<object[]> falseFn = null) { return condition ? n.Attr(trueFn()) : falseFn == null ? n : n.Attr(falseFn()); }
public static InputTag Name(this InputTag tag, string name) { tag.Attr(HtmlAttributeConstants.Name, name); return tag; }
public static TagBuilder Id(this TagBuilder builder, string id) { builder.Attr("id", id); return builder; }
public static HtmlTag ShouldHaveAtt(this HtmlTag tag, string attName, string attValue) { tag.Attr(attName).ShouldEqual(attValue); return tag; }