internal static string GetBrowsingModalBoxOpenStatements(BrowsingContextSetup browsingContextSetup, string url) { browsingContextSetup = browsingContextSetup ?? new BrowsingContextSetup(); // As of February 2018, iOS ignores iframe width and height styles, and sizes them to fit their content. See // http://andyshora.com/iframes-responsive-web-apps-tips.html. return("if( !!navigator.platform && /iPad|iPhone|iPod/.test( navigator.platform ) ) window.location = '{0}'; else {{ {1} }}".FormatWith( url, StringTools.ConcatenateWithDelimiter( " ", "var dl = document.getElementById( '{0}' );".FormatWith(EwfPage.Instance.BrowsingModalBoxId.ElementId.Id), "var dv = dl.firstElementChild;", "$( dv ).children( 'iframe' ).remove();", "var fr = document.createElement( 'iframe' );", "fr.src = '{0}';".FormatWith(url), "fr.style.width = '{0}';".FormatWith(browsingContextSetup.Width?.Value ?? ""), "fr.style.height = '{0}';".FormatWith(browsingContextSetup.Height?.Value ?? ""), "dv.insertAdjacentElement( 'beforeend', fr );", "dl.showModal();"))); }
/// <summary> /// Creates a behavior object that navigates to this resource in a modal box. /// </summary> /// <param name="destination">Where to navigate. Specify null if you don't want the link to do anything.</param> /// <param name="browsingContextSetup">The setup object for the browsing context (i.e. the iframe).</param> public static HyperlinkBehavior ToHyperlinkModalBoxBehavior(this ResourceInfo destination, BrowsingContextSetup browsingContextSetup = null) { return(new HyperlinkBehavior(destination, "_blank", url => browsingModalBoxOpenStatementGetter(browsingContextSetup, url))); }
/// <summary> /// Creates a behavior object that navigates to this resource in a modal box. /// </summary> /// <param name="destination">Where to navigate. Specify null if you don’t want the link to do anything.</param> /// <param name="disableAuthorizationCheck">Pass true to allow navigation to a resource that the authenticated user cannot access. Use with caution.</param> /// <param name="browsingContextSetup">The setup object for the browsing context (i.e. the iframe).</param> public static HyperlinkBehavior ToHyperlinkModalBoxBehavior( this ResourceInfo destination, bool disableAuthorizationCheck = false, BrowsingContextSetup browsingContextSetup = null) => new HyperlinkBehavior(destination, disableAuthorizationCheck, "_blank", url => browsingModalBoxOpenStatementGetter(browsingContextSetup, url));