/// <summary>
 /// Creates a remaining data object.
 /// </summary>
 /// <param name="groupName">The name of the group and any other information you want in the group head.</param>
 /// <param name="groupActions">Group action components.</param>
 /// <param name="groupHeadActivationBehavior">The activation behavior for the group head</param>
 /// <param name="initiallyCollapsed">Whether the group is initially collapsed. Null means the group cannot be collapsed and is always visible.</param>
 /// <param name="tailUpdateRegions">The tail update regions for the group. If a table uses item limiting, these regions will include all subsequent item
 /// groups in the table. This is necessary because any number of items could be appended to this item group, potentially causing subsequent item groups to
 /// become invisible.</param>
 public EwfTableItemGroupRemainingData(
     IReadOnlyCollection <FlowComponent> groupName, IReadOnlyCollection <ActionComponentSetup> groupActions = null,
     ElementActivationBehavior groupHeadActivationBehavior    = null, bool?initiallyCollapsed = null,
     IReadOnlyCollection <TailUpdateRegion> tailUpdateRegions = null)
 {
     GroupName    = groupName ?? Enumerable.Empty <FlowComponent>().Materialize();
     GroupActions = groupActions ?? Enumerable.Empty <ActionComponentSetup>().Materialize();
     GroupHeadActivationBehavior = groupHeadActivationBehavior;
     InitiallyCollapsed          = initiallyCollapsed;
     TailUpdateRegions           = tailUpdateRegions ?? Enumerable.Empty <TailUpdateRegion>().Materialize();
 }
Exemple #2
0
 /// <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>
 // NOTE: Change classes type to ElementClassSet when DynamicTable is gone.
 public TableCellSetup(
     int fieldSpan = 1, int itemSpan = 1, IEnumerable <string> classes = null, TextAlignment textAlignment = TextAlignment.NotSpecified,
     ElementActivationBehavior activationBehavior            = null, bool containsActivatableElements = false,
     IReadOnlyCollection <EtherealComponent> etherealContent = null)
 {
     FieldSpan                   = fieldSpan;
     ItemSpan                    = itemSpan;
     Classes                     = classes ?? new string[0];
     TextAlignment               = textAlignment;
     ActivationBehavior          = activationBehavior;
     ContainsActivatableElements = containsActivatableElements;
     EtherealContent             = etherealContent ?? Enumerable.Empty <EtherealComponent>().Materialize();
 }
 /// <summary>
 /// Creates a table field.
 /// </summary>
 /// <param name="classes">The classes. When used on a column, sets the classes on every cell since most styles don't work on col elements.</param>
 /// <param name="size">The height or width. For an EWF table, this is the column width. For a column primary table, this is the row height. If you specify
 /// percentage widths for some or all columns in a table, these values need not add up to 100; they will be automatically scaled if necessary. The automatic
 /// scaling will not happen if there are any columns without a specified width.</param>
 /// <param name="textAlignment">The text alignment of the cells in this field.</param>
 /// <param name="verticalAlignment">The vertical alignment of the cells in this field.</param>
 /// <param name="activationBehavior">The activation behavior.</param>
 public EwfTableField(
     ElementClassSet classes = null, CssLength size = null, TextAlignment textAlignment = TextAlignment.NotSpecified,
     TableCellVerticalAlignment verticalAlignment = TableCellVerticalAlignment.NotSpecified, ElementActivationBehavior activationBehavior = null)
 {
     FieldOrItemSetup = new EwfTableFieldOrItemSetup(classes, size, textAlignment, verticalAlignment, activationBehavior);
 }
 private ColumnPrimaryItemGroup(
     IReadOnlyCollection <FlowComponent> groupName, IReadOnlyCollection <ActionComponentSetup> groupActions,
     ElementActivationBehavior groupHeadActivationBehavior, IReadOnlyCollection <SelectedItemAction <int> > selectedItemActions, IEnumerable <EwfTableItem> items)
     : base(groupName, groupActions, groupHeadActivationBehavior, selectedItemActions, items)
 {
 }
 /// <summary>
 /// Creates an item group with a specified item ID type.
 /// </summary>
 /// <param name="groupName">The name of the group and any other information you want in the group head.</param>
 /// <param name="groupActions">Group action components.</param>
 /// <param name="groupHeadActivationBehavior">The activation behavior for the group head</param>
 /// <param name="selectedItemActions">Group selected-item actions. Passing one or more of these will add a new row to the table containing a checkbox for
 /// each item with an ID, within this group.</param>
 /// <param name="items">The items</param>
 public static ColumnPrimaryItemGroup <ItemIdType> CreateWithItemIdType <ItemIdType>(
     IReadOnlyCollection <FlowComponent> groupName, IReadOnlyCollection <ActionComponentSetup> groupActions = null,
     ElementActivationBehavior groupHeadActivationBehavior = null, IReadOnlyCollection <SelectedItemAction <ItemIdType> > selectedItemActions = null,
     IEnumerable <EwfTableItem <ItemIdType> > items        = null) =>
 new ColumnPrimaryItemGroup <ItemIdType>(groupName, groupActions, groupHeadActivationBehavior, selectedItemActions, items);
 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()));
 });
Exemple #7
0
        /// <summary>
        /// BasicPage.master use only.
        /// </summary>
        public Section(
            DisplaySetup displaySetup, SectionStyle style, ElementClassSet classes, string heading, IReadOnlyCollection <FlowComponent> postHeadingComponents,
            IReadOnlyCollection <FlowComponent> content, bool?expanded, bool disableStatePersistence, IReadOnlyCollection <EtherealComponent> etherealContent)
        {
            children = new DisplayableElement(
                context => {
                var hiddenFieldId = new HiddenFieldId();
                var expandedPmv   = heading.Any() && expanded.HasValue && !disableStatePersistence ? new PageModificationValue <string>() : null;

                FlowComponent getHeadingButton()
                {
                    var headingComponents =
                        new DisplayableElement(
                            headingContext => new DisplayableElementData(
                                null,
                                () => new DisplayableElementLocalData("h1"),
                                classes: headingClass,
                                children: heading.ToComponents())).Concat(postHeadingComponents ?? Enumerable.Empty <FlowComponent>());

                    return(expanded.HasValue
                                                               ?
                           // We cannot use EwfButton because we have flow content.
                           ElementActivationBehavior.GetActivatableElement(
                               "div",
                               ElementClassSet.Empty,
                               Enumerable.Empty <Tuple <string, string> >().Materialize(),
                               ElementActivationBehavior.CreateButton(
                                   buttonBehavior: new CustomButtonBehavior(
                                       () => disableStatePersistence
                                                                                                     ? "$( '#{0}' ).toggleClass( '{1}', 200 );".FormatWith(
                                           context.Id,
                                           StringTools.ConcatenateWithDelimiter(
                                               " ",
                                               style == SectionStyle.Normal
                                                                                                                             ? new[] { normalClosedClass.ClassName, normalExpandedClass.ClassName }
                                                                                                                             : new[] { boxClosedClass.ClassName, boxExpandedClass.ClassName }))
                                                                                                     : hiddenFieldId.GetJsValueModificationStatements(
                                           "document.getElementById( '{0}' ).value === '{2}' ? '{1}' : '{2}'".FormatWith(
                                               hiddenFieldId.ElementId.Id,
                                               bool.FalseString,
                                               bool.TrueString)))),
                               new GenericFlowContainer(
                                   new GenericPhrasingContainer("Click to Expand".ToComponents(), classes: closeClass).ToCollection()
                                   .Append(new GenericPhrasingContainer("Click to Close".ToComponents(), classes: expandClass))
                                   .Concat(headingComponents)
                                   .Materialize(),
                                   classes: headingClass).ToCollection(),
                               Enumerable.Empty <EtherealComponent>().Materialize())
                                                               : new GenericFlowContainer(new GenericFlowContainer(headingComponents.Materialize(), classes: headingClass).ToCollection()));
                }

                content = content ?? Enumerable.Empty <FlowComponent>().Materialize();
                return(new DisplayableElementData(
                           displaySetup,
                           () => new DisplayableElementLocalData(
                               "section",
                               focusDependentData:
                               new DisplayableElementFocusDependentData(includeIdAttribute: heading.Any() && expanded.HasValue && disableStatePersistence)),
                           classes: allStylesBothStatesClass
                           .Add(
                               style == SectionStyle.Normal
                                                                        ? getSectionClasses(expanded, expandedPmv, normalClosedClass, normalExpandedClass)
                                                                        : getSectionClasses(expanded, expandedPmv, boxClosedClass, boxExpandedClass))
                           .Add(classes ?? ElementClassSet.Empty),
                           children: (heading.Any() ? getHeadingButton().ToCollection() : Enumerable.Empty <FlowComponent>()).Concat(
                               content.Any() ? new GenericFlowContainer(content, classes: contentClass).ToCollection() : Enumerable.Empty <FlowComponent>())
                           .Materialize(),
                           etherealChildren: (expandedPmv != null
                                                                            ? new EwfHiddenField(expanded.Value.ToString(), id: hiddenFieldId, pageModificationValue: expandedPmv).PageComponent
                                              .ToCollection()
                                                                            : Enumerable.Empty <EtherealComponent>()).Concat(etherealContent ?? Enumerable.Empty <EtherealComponent>())
                           .Materialize()));
            }).ToCollection();
        }