/// <summary> /// Creates a modal box. /// </summary> /// <param name="id"></param> /// <param name="includeCloseButton"></param> /// <param name="content"></param> /// <param name="open"></param> public ModalBox(ModalBoxId id, bool includeCloseButton, IReadOnlyCollection <FlowComponent> content, bool open = false) { children = new ElementComponent( context => { id.ElementId.AddId(context.Id); return(new ElementData( () => new ElementLocalData( "dialog", focusDependentData: new ElementFocusDependentData( includeIdAttribute: true, jsInitStatements: (includeCloseButton ? "$( '#{0}' ).click( function( e ) {{ if( e.target.id === '{0}' ) e.target.close(); }} );".FormatWith(context.Id) : "").ConcatenateWithSpace(open ? "document.getElementById( '{0}' ).showModal();".FormatWith(context.Id) : ""))), classes: boxClass, children: new GenericFlowContainer( (includeCloseButton ? new GenericFlowContainer( new EwfButton( new StandardButtonStyle("Close", icon: new ActionComponentIcon(new FontAwesomeIcon("fa-times"))), behavior: new CustomButtonBehavior(() => "document.getElementById( '{0}' ).close();".FormatWith(context.Id))).ToCollection(), classes: closeButtonContainerClass).ToCollection <FlowComponent>() : Enumerable.Empty <FlowComponent>()).Concat( id == EwfPage.Instance.BrowsingModalBoxId ? content : new GenericFlowContainer(content, classes: contentContainerClass).ToCollection()) .Materialize(), classes: boxClass).ToCollection())); }).ToCollection(); }
/// <summary> /// Creates a modal box. /// </summary> /// <param name="id"></param> /// <param name="content"></param> /// <param name="open"></param> public ModalBox(ModalBoxId id, IEnumerable <FlowComponent> content, bool open = false) { children = new ElementComponent( context => { id.ElementId.AddId(context.Id); return (new ElementData( () => new ElementLocalData( "dialog", includeIdAttribute: true, jsInitStatements: open ? "document.getElementById( '{0}' ).showModal();".FormatWith(context.Id) : ""), classes: CssElementCreator.Class, children: content)); }).ToCollection(); }
/// <summary> /// Creates an open-modal behavior. /// </summary> /// <param name="modalBoxId">Do not pass null.</param> /// <param name="etherealChildren"></param> public OpenModalBehavior(ModalBoxId modalBoxId, IReadOnlyCollection <EtherealComponent> etherealChildren = null) { this.modalBoxId = modalBoxId; this.etherealChildren = etherealChildren; }
internal static EtherealComponent CreateBrowsingModalBox(ModalBoxId id) => new ModalBox(id, true, Enumerable.Empty <FlowComponent>().Materialize());
/// <summary> /// Creates an open-modal behavior. /// </summary> /// <param name="modalBoxId">Do not pass null.</param> public OpenModalBehavior(ModalBoxId modalBoxId) { this.modalBoxId = modalBoxId; }