/// <summary> /// Creates a setup object for a read-only numeric-text control. /// </summary> /// <param name="displaySetup"></param> /// <param name="classes">The classes on the control.</param> /// <param name="validationPredicate"></param> /// <param name="validationErrorNotifier"></param> public static NumericTextControlSetup CreateReadOnly( DisplaySetup displaySetup = null, ElementClassSet classes = null, Func <bool, bool> validationPredicate = null, Action validationErrorNotifier = null) { return(new NumericTextControlSetup( new TextControlSetup( displaySetup, "text", null, null, true, classes, false, true, "", "", null, null, null, null, null, null, null, validationPredicate, validationErrorNotifier), validationErrorNotifier)); }
private ElementActivationBehavior(ResourceInfo resource = null, FormAction action = null, string script = "") { if (action == null && !script.Any()) { HyperlinkBehavior hyperlinkBehavior = resource; Classes = hyperlinkBehavior.HasDestination ? ActivatableClass : ElementClassSet.Empty; AttributeGetter = () => hyperlinkBehavior.AttributeGetter(true); IncludesIdAttribute = () => hyperlinkBehavior.IncludesIdAttribute(true); EtherealChildren = hyperlinkBehavior.EtherealChildren; JsInitStatementGetter = id => hyperlinkBehavior.JsInitStatementGetter(id, true); IsFocusable = hyperlinkBehavior.IsFocusable; PostBackAdder = hyperlinkBehavior.PostBackAdder; } else { var buttonBehavior = action != null ? (ButtonBehavior) new FormActionBehavior(action) : new CustomButtonBehavior(() => script + ";"); Classes = ActivatableClass; AttributeGetter = () => buttonBehavior.GetAttributes().Materialize(); IncludesIdAttribute = buttonBehavior.IncludesIdAttribute; EtherealChildren = buttonBehavior.GetEtherealChildren(); JsInitStatementGetter = buttonBehavior.GetJsInitStatements; IsFocusable = true; PostBackAdder = buttonBehavior.AddPostBack; } }
/// <summary> /// Creates a setup object for a numeric-text control with auto-complete behavior. /// </summary> /// <param name="autoCompleteResource">The resource containing the auto-complete items. Do not pass null.</param> /// <param name="displaySetup"></param> /// <param name="classes">The classes on the control.</param> /// <param name="placeholder">The hint word or phrase that will appear when the control has an empty value. Do not pass null.</param> /// <param name="autoFillTokens">A list of auto-fill detail tokens (see /// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-detail-tokens), or "off" to instruct the browser to disable auto-fill /// (see https://stackoverflow.com/a/23234498/35349 for an explanation of why this could be ignored). Do not pass null.</param> /// <param name="action">The action that will occur when the user hits Enter on the control. Pass null to use the current default action.</param> /// <param name="triggersActionWhenItemSelected">Pass true to also trigger the action when the user selects an auto-complete item.</param> /// <param name="valueChangedAction">The action that will occur when the value is changed. Pass null for no action.</param> /// <param name="pageModificationValue"></param> /// <param name="numericPageModificationValue"></param> /// <param name="validationPredicate"></param> /// <param name="validationErrorNotifier"></param> public static NumericTextControlSetup CreateAutoComplete( ResourceInfo autoCompleteResource, DisplaySetup displaySetup = null, ElementClassSet classes = null, string placeholder = "", string autoFillTokens = "", SpecifiedValue <FormAction> action = null, bool triggersActionWhenItemSelected = false, FormAction valueChangedAction = null, PageModificationValue <string> pageModificationValue = null, PageModificationValue <long?> numericPageModificationValue = null, Func <bool, bool> validationPredicate = null, Action validationErrorNotifier = null) { return(new NumericTextControlSetup( new TextControlSetup( displaySetup, "text", null, null, false, classes, false, true, placeholder, autoFillTokens, autoCompleteResource, null, action, triggersActionWhenItemSelected, valueChangedAction, pageModificationValue, numericPageModificationValue, validationPredicate, validationErrorNotifier), validationErrorNotifier)); }
internal static FlowComponent GetActivatableElement( string elementName, ElementClassSet classes, IReadOnlyCollection <ElementAttribute> attributes, ElementActivationBehavior activationBehavior, IReadOnlyCollection <FlowComponent> children, IReadOnlyCollection <EtherealComponent> etherealChildren) => new ElementComponent( context => { activationBehavior?.PostBackAdder(); return(new ElementData( () => new ElementLocalData( elementName, new FocusabilityCondition(activationBehavior?.IsFocusable == true), isFocused => new ElementFocusDependentData( attributes: attributes.Concat(activationBehavior != null ? activationBehavior.AttributeGetter() : Enumerable.Empty <ElementAttribute>()) .Concat( activationBehavior?.IsFocusable == true ? new[] { new ElementAttribute("tabindex", "0"), new ElementAttribute("role", "button") } : Enumerable.Empty <ElementAttribute>()), includeIdAttribute: activationBehavior?.IncludesIdAttribute() == true || isFocused, jsInitStatements: (activationBehavior != null ? activationBehavior.JsInitStatementGetter(context.Id) : "").AppendDelimiter( // This list of keys is duplicated in the JavaScript file. " $( '#{0}' ).keypress( function( e ) {{ if( e.key === ' ' || e.key === 'Enter' ) {{ e.preventDefault(); $( this ).click(); }} }} );" .FormatWith(context.Id)) .ConcatenateWithSpace(isFocused ? "document.getElementById( '{0}' ).focus();".FormatWith(context.Id) : ""))), classes: classes.Add(activationBehavior != null ? activationBehavior.Classes : ElementClassSet.Empty), children: children, etherealChildren: (activationBehavior?.EtherealChildren ?? Enumerable.Empty <EtherealComponent>()).Concat(etherealChildren).Materialize())); });
/// <summary> /// Creates a setup object for a text control with auto-complete behavior. /// </summary> /// <param name="autoCompleteResource">The resource containing the auto-complete items. Do not pass null.</param> /// <param name="displaySetup"></param> /// <param name="widthOverride">The width of the control. This overrides any value that may be specified via CSS. If no width is specified via CSS and you /// pass null for this parameter, the width will be based on the maximum number of characters a user can input.</param> /// <param name="numberOfRows">The number of lines in the text control. Must be one or more.</param> /// <param name="classes">The classes on the control.</param> /// <param name="disableTrimming">Pass true to disable white-space trimming.</param> /// <param name="placeholder">The hint word or phrase that will appear when the control has an empty value. Do not pass null.</param> /// <param name="autoFillTokens">A list of auto-fill detail tokens (see /// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-detail-tokens), or "off" to instruct the browser to disable auto-fill /// (see https://stackoverflow.com/a/23234498/35349 for an explanation of why this could be ignored). Do not pass null.</param> /// <param name="checksSpellingAndGrammar">Pass true to enable spelling and grammar checking, false to disable it, and null for default behavior.</param> /// <param name="action">The action that will occur when the user hits Enter on the control. Pass null to use the current default action. Currently has no /// effect for multiline controls.</param> /// <param name="triggersActionWhenItemSelected">Pass true to also trigger the action when the user selects an auto-complete item.</param> /// <param name="valueChangedAction">The action that will occur when the value is changed. Pass null for no action.</param> /// <param name="pageModificationValue"></param> /// <param name="validationPredicate"></param> /// <param name="validationErrorNotifier"></param> public static TextControlSetup CreateAutoComplete( ResourceInfo autoCompleteResource, DisplaySetup displaySetup = null, ContentBasedLength widthOverride = null, int numberOfRows = 1, ElementClassSet classes = null, bool disableTrimming = false, string placeholder = "", string autoFillTokens = "", bool?checksSpellingAndGrammar = null, SpecifiedValue <FormAction> action = null, bool triggersActionWhenItemSelected = false, FormAction valueChangedAction = null, PageModificationValue <string> pageModificationValue = null, Func <bool, bool> validationPredicate = null, Action validationErrorNotifier = null) { return(new TextControlSetup( displaySetup, numberOfRows == 1 ? "text" : "", widthOverride, numberOfRows, false, classes, disableTrimming, false, placeholder, autoFillTokens, autoCompleteResource, checksSpellingAndGrammar, action, triggersActionWhenItemSelected, valueChangedAction, pageModificationValue, null, validationPredicate, validationErrorNotifier)); }
/// <summary> /// Creates a setup object for a standard URL control. /// </summary> /// <param name="displaySetup"></param> /// <param name="classes">The classes on the control.</param> /// <param name="placeholder">The hint word or phrase that will appear when the control has an empty value. Do not pass null.</param> /// <param name="autoFillTokens">A list of auto-fill detail tokens (see /// https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#autofill-detail-tokens), or "off" to instruct the browser to disable auto-fill /// (see https://stackoverflow.com/a/23234498/35349 for an explanation of why this could be ignored). Do not pass null.</param> /// <param name="action">The action that will occur when the user hits Enter on the control. Pass null to use the current default action.</param> /// <param name="valueChangedAction">The action that will occur when the value is changed. Pass null for no action.</param> /// <param name="pageModificationValue"></param> /// <param name="validationPredicate"></param> /// <param name="validationErrorNotifier"></param> public static UrlControlSetup Create( DisplaySetup displaySetup = null, ElementClassSet classes = null, string placeholder = "", string autoFillTokens = "", SpecifiedValue <FormAction> action = null, FormAction valueChangedAction = null, PageModificationValue <string> pageModificationValue = null, Func <bool, bool> validationPredicate = null, Action validationErrorNotifier = null) { return(new UrlControlSetup( new TextControlSetup( displaySetup, "url", null, null, false, classes, false, false, placeholder, autoFillTokens, null, null, action, null, valueChangedAction, pageModificationValue, null, validationPredicate, validationErrorNotifier))); }
/// <summary> /// Creates a submit button. /// </summary> /// <param name="style">The style.</param> /// <param name="displaySetup"></param> /// <param name="classes">The classes on the button.</param> /// <param name="postBack">Pass null to use the post-back corresponding to the first of the current data modifications.</param> public SubmitButton(ButtonStyle style, DisplaySetup displaySetup = null, ElementClassSet classes = null, PostBack postBack = null) { var elementChildren = style.GetChildren(); var postBackAction = new PostBackFormAction(postBack ?? FormState.Current.PostBack); children = new DisplayableElement( context => { FormAction action = postBackAction; action.AddToPageIfNecessary(); if (EwfPage.Instance.SubmitButtonPostBack != null) { throw new ApplicationException("A submit button already exists on the page."); } EwfPage.Instance.SubmitButtonPostBack = postBackAction.PostBack; return(new DisplayableElementData( displaySetup, () => new DisplayableElementLocalData( "button", attributes: new[] { Tuple.Create("name", EwfPage.ButtonElementName), Tuple.Create("value", "v") }, jsInitStatements: style.GetJsInitStatements(context.Id)), classes: style.GetClasses().Add(classes ?? ElementClassSet.Empty), children: elementChildren)); }).ToCollection(); }
/// <summary> /// Adds element classes to this set. /// </summary> public ElementClassSet Add(ElementClassSet classSet) { if (ConditionsByClassName.Keys.Intersect(classSet.ConditionsByClassName.Keys).Any()) { throw new ApplicationException("At least one class exists in both sets."); } return(new ElementClassSet(ConditionsByClassName.AddRange(classSet.ConditionsByClassName))); }
/// <summary> /// Creates a component-list setup object. /// </summary> /// <param name="displaySetup"></param> /// <param name="isOrdered">Pass true if the list items have been intentionally ordered, such that changing the order would change the meaning of the page.</param> /// <param name="classes">The classes on the list.</param> /// <param name="lastItemAutofocusCondition">Pass a value to wrap the last list item in an autofocus region with the specified condition.</param> /// <param name="tailUpdateRegions">The tail update regions.</param> /// <param name="itemInsertionUpdateRegions"></param> /// <param name="etherealContent"></param> public ComponentListSetup( DisplaySetup displaySetup = null, bool isOrdered = false, ElementClassSet classes = null, AutofocusCondition lastItemAutofocusCondition = null, IEnumerable <TailUpdateRegion> tailUpdateRegions = null, IEnumerable <ItemInsertionUpdateRegion> itemInsertionUpdateRegions = null, IReadOnlyCollection <EtherealComponent> etherealContent = null) { componentGetter = (listTypeClasses, items) => { items = items.ToImmutableArray(); var itemComponents = items.Select(i => i.Item2).ToImmutableArray(); var itemComponentsById = items.Where(i => i.Item1.Id.Any()).ToDictionary(i => i.Item1.Id, i => i.Item2); return(new IdentifiedFlowComponent( () => new IdentifiedComponentData <FlowComponentOrNode>( "", new[] { new UpdateRegionLinker( "tail", from region in tailUpdateRegions ?? ImmutableArray <TailUpdateRegion> .Empty let staticItemCount = items.Count() - region.UpdatingItemCount select new PreModificationUpdateRegion(region.Sets, () => itemComponents.Skip(staticItemCount), staticItemCount.ToString), arg => itemComponents.Skip(int.Parse(arg))), new UpdateRegionLinker( "add", from region in itemInsertionUpdateRegions ?? ImmutableArray <ItemInsertionUpdateRegion> .Empty select new PreModificationUpdateRegion( region.Sets, () => ImmutableArray <PageComponent> .Empty, () => StringTools.ConcatenateWithDelimiter(",", region.NewItemIdGetter().ToArray())), arg => arg.Separate(",", false).Where(itemComponentsById.ContainsKey).Select(i => itemComponentsById[i])), new UpdateRegionLinker( "remove", items.Select( (item, index) => new PreModificationUpdateRegion( item.Item1.RemovalUpdateRegionSets, () => itemComponents.ElementAt(index).ToCollection(), () => "")), arg => ImmutableArray <PageComponent> .Empty) }, new ErrorSourceSet(), errorsBySource => new DisplayableElement( context => { return new DisplayableElementData( displaySetup, () => new DisplayableElementLocalData(isOrdered ? "ol" : "ul"), classes: CssElementCreator.AllListsClass.Add(listTypeClasses).Add(classes ?? ElementClassSet.Empty), children: itemComponents.Select( (component, index) => index == itemComponents.Length - 1 && lastItemAutofocusCondition != null ? new FlowAutofocusRegion( lastItemAutofocusCondition, new CustomFlowComponent(component.ToCollection()).ToCollection()) : component) .Materialize(), etherealChildren: etherealContent); }).ToCollection())).ToCollection()); }; }
internal HyperlinkBehavior(string mailtoUri) { Classes = ElementClassSet.Empty; Url = "mailto:{0}".FormatWith(mailtoUri); AttributeGetter = () => Tuple.Create("href", Url).ToCollection(); EtherealChildren = ImmutableArray <EtherealComponent> .Empty; JsInitStatementGetter = id => ""; PostBackAdder = () => { }; }
/// <summary> /// Creates a list item containing components that represent this string. The string must not be null. /// </summary> /// <param name="text"></param> /// <param name="displaySetup"></param> /// <param name="classes">The classes on the item.</param> /// <param name="visualOrderRank"></param> /// <param name="updateRegionSets">The intermediate-post-back update-region sets that this item will be a part of.</param> /// <param name="etherealContent"></param> public static ComponentListItem ToComponentListItem( this string text, DisplaySetup displaySetup = null, ElementClassSet classes = null, int?visualOrderRank = null, IEnumerable <UpdateRegionSet> updateRegionSets = null, IReadOnlyCollection <EtherealComponent> etherealContent = null) => text.ToComponents() .ToComponentListItem( displaySetup: displaySetup, classes: classes, visualOrderRank: visualOrderRank, updateRegionSets: updateRegionSets, etherealContent: etherealContent);
private ElementActivationBehavior(ButtonBehavior buttonBehavior) { Classes = ActivatableClass; AttributeGetter = () => buttonBehavior.GetAttributes().Materialize(); IncludesIdAttribute = buttonBehavior.IncludesIdAttribute; EtherealChildren = buttonBehavior.GetEtherealChildren(); JsInitStatementGetter = buttonBehavior.GetJsInitStatements; IsFocusable = true; PostBackAdder = buttonBehavior.AddPostBack; }
/// <summary> /// Creates an HTML block container. Do not pass null for HTML. This overload is useful when you've already loaded the HTML. /// </summary> /// <param name="html"></param> /// <param name="displaySetup"></param> /// <param name="classes">The classes on the container.</param> public HtmlBlockContainer(string html, DisplaySetup displaySetup = null, ElementClassSet classes = null) { this.html = html; children = new DisplayableElement( context => new DisplayableElementData( displaySetup, () => new DisplayableElementLocalData("div"), classes: elementClass.Add(classes ?? ElementClassSet.Empty), children: new TrustedHtmlString(html).ToComponent().ToCollection())).ToCollection(); }
/// <summary> /// Creates an element-data object. /// </summary> public ElementData( Func <ElementLocalData> localDataGetter, ElementClassSet classes = null, IReadOnlyCollection <FlowComponentOrNode> children = null, IReadOnlyCollection <EtherealComponentOrElement> etherealChildren = null) { classes = classes ?? ElementClassSet.Empty; NodeDataGetter = context => { classes.AddElementId(context.Id); return(new ElementNodeData(() => localDataGetter().NodeDataGetter(classes), children: children, etherealChildren: etherealChildren)); }; }
private ElementActivationBehavior(HyperlinkBehavior hyperlinkBehavior) { Classes = hyperlinkBehavior.HasDestination ? ActivatableClass : ElementClassSet.Empty; AttributeGetter = () => hyperlinkBehavior.AttributeGetter(true); IncludesIdAttribute = () => hyperlinkBehavior.IncludesIdAttribute(true); EtherealChildren = hyperlinkBehavior.EtherealChildren; JsInitStatementGetter = id => hyperlinkBehavior.JsInitStatementGetter(id, true); IsFocusable = hyperlinkBehavior.IsFocusable; PostBackAdder = hyperlinkBehavior.PostBackAdder; }
private FlowCheckboxSetup( DisplaySetup displaySetup, ElementClassSet classes, CheckboxSetup checkboxSetup, bool highlightedWhenChecked, Func <IReadOnlyCollection <FlowComponent> > nestedContentGetter, bool nestedContentAlwaysDisplayed) { DisplaySetup = displaySetup; Classes = classes; CheckboxSetup = checkboxSetup; HighlightedWhenChecked = highlightedWhenChecked; NestedContentGetter = nestedContentGetter; NestedContentAlwaysDisplayed = nestedContentAlwaysDisplayed; }
private FlowRadioButtonSetup( DisplaySetup displaySetup, ElementClassSet classes, RadioButtonSetup radioButtonSetup, bool highlightedWhenSelected, Func <IReadOnlyCollection <FlowComponent> > nestedContentGetter, bool nestedContentAlwaysDisplayed) { DisplaySetup = displaySetup; Classes = classes; RadioButtonSetup = radioButtonSetup; HighlightedWhenSelected = highlightedWhenSelected; NestedContentGetter = nestedContentGetter; NestedContentAlwaysDisplayed = nestedContentAlwaysDisplayed; }
/// <summary> /// Creates a setup object for a BLOB file manager. /// </summary> /// <param name="displaySetup"></param> /// <param name="classes">The classes on the element.</param> /// <param name="thumbnailResourceGetter">A function that takes a file ID and returns the corresponding thumbnail resource. Do not return null.</param> /// <param name="omitNoExistingFileMessage">Pass true if you do not want to show “No existing file” when there is no file in the database.</param> /// <param name="uploadValidationPredicate"></param> /// <param name="uploadValidationErrorNotifier"></param> /// <param name="uploadValidationMethod"></param> public static BlobFileManagerSetup Create( DisplaySetup displaySetup = null, ElementClassSet classes = null, Func <int, ResourceInfo> thumbnailResourceGetter = null, bool omitNoExistingFileMessage = false, Func <bool, bool> uploadValidationPredicate = null, Action uploadValidationErrorNotifier = null, Action <RsFile, Validator> uploadValidationMethod = null) => new BlobFileManagerSetup( displaySetup, classes, thumbnailResourceGetter, omitNoExistingFileMessage, uploadValidationPredicate, uploadValidationErrorNotifier, uploadValidationMethod);
internal BlobFileManagerSetup( DisplaySetup displaySetup, ElementClassSet classes, Func <int, ResourceInfo> thumbnailResourceGetter, bool omitNoExistingFileMessage, Func <bool, bool> uploadValidationPredicate, Action uploadValidationErrorNotifier, Action <RsFile, Validator> uploadValidationMethod) { DisplaySetup = displaySetup; Classes = classes; ThumbnailResourceGetter = thumbnailResourceGetter; OmitNoExistingFileMessage = omitNoExistingFileMessage; UploadValidationPredicate = uploadValidationPredicate; UploadValidationErrorNotifier = uploadValidationErrorNotifier; UploadValidationMethod = uploadValidationMethod; }
/// <summary> /// Adds element classes to this set. /// </summary> public ElementClassSet Add(ElementClassSet classSet) { if ( JsModificationStatementAdderAndInclusionPredicatePairsByClassName.Keys.Intersect( classSet.JsModificationStatementAdderAndInclusionPredicatePairsByClassName.Keys).Any()) { throw new ApplicationException("At least one class exists in both sets."); } return (new ElementClassSet( JsModificationStatementAdderAndInclusionPredicatePairsByClassName.AddRange(classSet.JsModificationStatementAdderAndInclusionPredicatePairsByClassName))); }
/// <summary> /// Creates a setup object for a read-only radio button. /// </summary> /// <param name="displaySetup"></param> /// <param name="classes">The classes on the container.</param> /// <param name="highlightedWhenSelected"></param> /// <param name="nestedContentGetter">A function that gets the content that will appear beneath the radio button.</param> /// <param name="nestedContentAlwaysDisplayed">Pass true to force the nested content to always be displayed instead of only when the button is selected. /// </param> public static FlowRadioButtonSetup CreateReadOnly( DisplaySetup displaySetup = null, ElementClassSet classes = null, bool highlightedWhenSelected = false, Func <IReadOnlyCollection <FlowComponent> > nestedContentGetter = null, bool nestedContentAlwaysDisplayed = false) { return(new FlowRadioButtonSetup( displaySetup, classes, RadioButtonSetup.CreateReadOnly(), highlightedWhenSelected, nestedContentGetter, nestedContentAlwaysDisplayed)); }
internal HyperlinkBehavior(ResourceInfo destination, string target) { this.destination = destination; Classes = destination?.AlternativeMode is NewContentResourceMode ? ActionComponentCssElementCreator.NewContentClass : ElementClassSet.Empty; Url = destination != null?destination.GetUrl(true, false, true) : ""; var isPostBackHyperlink = destination != null && !(destination.AlternativeMode is DisabledResourceMode) && !target.Any() && EwfPage.Instance.IsAutoDataUpdater; FormAction postBackAction = null; AttributeGetter = () => (Url.Any() ? Tuple.Create("href", Url).ToCollection() : Enumerable.Empty <Tuple <string, string> >()).Concat( target.Any() ? Tuple.Create("target", target).ToCollection() : Enumerable.Empty <Tuple <string, string> >()) .Concat( isPostBackHyperlink ? Tuple.Create(JsWritingMethods.onclick, postBackAction.GetJsStatements() + " return false").ToCollection() : Enumerable.Empty <Tuple <string, string> >()) .ToImmutableArray(); var disabledResourceMode = destination?.AlternativeMode as DisabledResourceMode; if (disabledResourceMode != null) { IncludeIdAttribute = true; Func <string, string> toolTipInitStatementGetter; EtherealChildren = new ToolTip( (disabledResourceMode.Message.Any() ? disabledResourceMode.Message : Translation.ThePageYouRequestedIsDisabled).ToComponents(), out toolTipInitStatementGetter).ToCollection(); JsInitStatementGetter = id => "$( '#{0}' ).click( function( e ) {{ e.preventDefault(); }} );".FormatWith(id) + toolTipInitStatementGetter(id); } else { EtherealChildren = ImmutableArray <EtherealComponent> .Empty; JsInitStatementGetter = id => ""; } if (isPostBackHyperlink) { PostBackAdder = () => { postBackAction = GetHyperlinkPostBackAction(destination); postBackAction.AddToPageIfNecessary(); } } ; else { PostBackAdder = () => { } }; }
/// <summary> /// Creates a list item containing this component. /// </summary> /// <param name="content"></param> /// <param name="id">The ID of the item. This is required if you're adding the item on an intermediate post-back or want to remove the item on an /// intermediate post-back. Do not pass null or the empty string.</param> /// <param name="displaySetup"></param> /// <param name="classes">The classes on the item.</param> /// <param name="visualOrderRank"></param> /// <param name="updateRegionSets">The intermediate-post-back update-region sets that this item will be a part of.</param> /// <param name="removalUpdateRegionSets">The intermediate-post-back update-region sets that this item's removal will be a part of.</param> /// <param name="etherealContent"></param> public static ComponentListItem ToComponentListItem( this FlowComponent content, string id, DisplaySetup displaySetup = null, ElementClassSet classes = null, int?visualOrderRank = null, IEnumerable <UpdateRegionSet> updateRegionSets = null, IEnumerable <UpdateRegionSet> removalUpdateRegionSets = null, IReadOnlyCollection <EtherealComponent> etherealContent = null) => content.ToCollection() .ToComponentListItem( id: id, displaySetup: displaySetup, classes: classes, visualOrderRank: visualOrderRank, updateRegionSets: updateRegionSets, removalUpdateRegionSets: removalUpdateRegionSets, etherealContent: etherealContent);
/// <summary> /// Creates a setup object for a standard radio button. /// </summary> /// <param name="displaySetup"></param> /// <param name="classes">The classes on the container.</param> /// <param name="highlightedWhenSelected"></param> /// <param name="action">The action that will occur when the user hits Enter on the radio button. Pass null to use the current default action.</param> /// <param name="pageModificationValue"></param> /// <param name="nestedContentGetter">A function that gets the content that will appear beneath the radio button.</param> /// <param name="nestedContentAlwaysDisplayed">Pass true to force the nested content to always be displayed instead of only when the button is selected. /// </param> public static FlowRadioButtonSetup Create( DisplaySetup displaySetup = null, ElementClassSet classes = null, bool highlightedWhenSelected = false, SpecifiedValue <FormAction> action = null, PageModificationValue <bool> pageModificationValue = null, Func <IReadOnlyCollection <FlowComponent> > nestedContentGetter = null, bool nestedContentAlwaysDisplayed = false) { return(new FlowRadioButtonSetup( displaySetup, classes, RadioButtonSetup.Create(action: action, pageModificationValue: pageModificationValue), highlightedWhenSelected, nestedContentGetter, nestedContentAlwaysDisplayed)); }
internal DurationControlSetup( DisplaySetup displaySetup, bool isReadOnly, ElementClassSet classes, SpecifiedValue <FormAction> action, FormAction valueChangedAction, PageModificationValue <string> pageModificationValue, Func <bool, bool> validationPredicate, Action validationErrorNotifier) { DisplaySetup = displaySetup; IsReadOnly = isReadOnly; Classes = classes; Action = action != null ? action.Value : FormState.Current.FormControlDefaultAction; ValueChangedAction = valueChangedAction; PageModificationValue = pageModificationValue; ValidationPredicate = validationPredicate; ValidationErrorNotifier = validationErrorNotifier; }
/// <summary> /// Creates a cell setup object. /// </summary> /// <param name="fieldSpan">The number of fields this cell will span. /// NOTE: Don't allow this to be less than one. Zero is allowed by the HTML spec but is too difficult for us to implement right now. /// </param> /// <param name="itemSpan">The number of items this cell will span. /// NOTE: Don't allow this to be less than one. Zero is allowed by the HTML spec but is too difficult for us to implement right now. /// </param> /// <param name="classes">The classes on the cell.</param> /// <param name="textAlignment">The text alignment of the cell.</param> /// <param name="activationBehavior">The activation behavior.</param> /// <param name="containsActivatableElements">Pass true if the cell contains “activatable” elements, e.g. hyperlinks, buttons, or form controls.</param> /// <param name="etherealContent"></param> public TableCellSetup( int fieldSpan = 1, int itemSpan = 1, ElementClassSet classes = null, TextAlignment textAlignment = TextAlignment.NotSpecified, ElementActivationBehavior activationBehavior = null, bool containsActivatableElements = false, IReadOnlyCollection <EtherealComponent> etherealContent = null) { FieldSpan = fieldSpan; ItemSpan = itemSpan; Classes = classes ?? ElementClassSet.Empty; TextAlignment = textAlignment; ActivationBehavior = activationBehavior; ContainsActivatableElements = containsActivatableElements; EtherealContent = etherealContent ?? Enumerable.Empty <EtherealComponent>().Materialize(); }
internal HyperlinkBehavior(string mailtoUri) { Classes = ElementClassSet.Empty; Url = new Lazy <string>(() => "mailto:{0}".FormatWith(mailtoUri)); AttributeGetter = forNonHyperlinkElement => forNonHyperlinkElement?Enumerable.Empty <Tuple <string, string> >().Materialize() : Tuple.Create("href", Url.Value).ToCollection(); IncludesIdAttribute = forNonHyperlinkElement => forNonHyperlinkElement; EtherealChildren = null; JsInitStatementGetter = (id, forNonHyperlinkElement) => forNonHyperlinkElement ? "window.location.href = '{0}';".FormatWith(Url.Value) : ""; IsFocusable = true; PostBackAdder = () => {}; }
/// <summary> /// Creates a form-item-list setup object. /// </summary> /// <param name="displaySetup"></param> /// <param name="classes">The classes on the list.</param> /// <param name="buttonSetup">Pass a value to have a button added as the last form item and formatted automatically.</param> /// <param name="enableSubmitButton">Pass true to enable the button to be a a submit button if possible.</param> public FormItemListSetup( DisplaySetup displaySetup = null, ElementClassSet classes = null, ButtonSetup buttonSetup = null, bool enableSubmitButton = false) { DisplaySetup = displaySetup; Classes = classes; ButtonItemGetter = setupGetter => buttonSetup == null ? Enumerable.Empty <FormItem>().Materialize() : buttonSetup.GetActionComponent( null, (text, icon) => new StandardButtonStyle(text, icon: icon), enableSubmitButton: enableSubmitButton) .ToFormItem(setup: setupGetter(buttonSetup.DisplaySetup)) .ToCollection(); }
/// <summary> /// Creates a setup object for a standard duration control. /// </summary> /// <param name="displaySetup"></param> /// <param name="classes">The classes on the control container.</param> /// <param name="action">The action that will occur when the user hits Enter on the control. Pass null to use the current default action.</param> /// <param name="valueChangedAction">The action that will occur when the value is changed. Pass null for no action.</param> /// <param name="pageModificationValue"></param> /// <param name="validationPredicate"></param> /// <param name="validationErrorNotifier"></param> public static DurationControlSetup Create( DisplaySetup displaySetup = null, ElementClassSet classes = null, SpecifiedValue <FormAction> action = null, FormAction valueChangedAction = null, PageModificationValue <string> pageModificationValue = null, Func <bool, bool> validationPredicate = null, Action validationErrorNotifier = null) { return(new DurationControlSetup( displaySetup, false, classes, action, valueChangedAction, pageModificationValue, validationPredicate, validationErrorNotifier)); }
/// <summary> /// Creates a section. /// </summary> /// <param name="heading">The section's heading. Do not pass null.</param> /// <param name="content">The section's content.</param> /// <param name="displaySetup"></param> /// <param name="style">The section's style.</param> /// <param name="classes">The classes on the section.</param> /// <param name="postHeadingComponents">Components that follow the heading but are still part of the heading container.</param> /// <param name="expanded">Set to true or false if you want users to be able to expand or close the section by clicking on the heading.</param> /// <param name="etherealContent"></param> public Section( string heading, IReadOnlyCollection <FlowComponent> content, DisplaySetup displaySetup = null, SectionStyle style = SectionStyle.Normal, ElementClassSet classes = null, IReadOnlyCollection <FlowComponent> postHeadingComponents = null, bool?expanded = null, IReadOnlyCollection <EtherealComponent> etherealContent = null) : this( displaySetup, style, classes, heading, postHeadingComponents, content, expanded, false, etherealContent) { }