Advertisement
Guest User

Untitled

a guest
Nov 16th, 2015
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
F# 1.99 KB | None | 0 0
  1. open IntelliFactory.WebSharper
  2. open IntelliFactory.WebSharper.Sitelets
  3. module FormletSnippets =
  4.     open IntelliFactory.WebSharper.Formlet
  5.     open IntelliFactory.WebSharper.Html
  6.  
  7.     [<JavaScript>]
  8.     let Snippet1 = Controls.Input "initial value"
  9.  
  10.     [<JavaScript>]
  11.     let RunInBlock title f formlet =
  12.         let output = Div []
  13.         formlet
  14.         |> Formlet.Run (fun res -> let elem = f res in output -< [ elem ] |> ignore)
  15.         |> fun form ->
  16.             Div [Attr.Style "float:left;margin-right:20px;width:300px;min-height:200px;"] -< [
  17.  
  18.                 H5 [Text title]
  19.                 Div [form]
  20.                 output
  21.             ]
  22.  
  23.     [<JavaScript>]
  24.     let RunSnippet title formlet =
  25.         formlet |> RunInBlock title (fun s -> Div [ P ["You entered: " + s |> Text] ])
  26.  
  27. module Formlets =
  28.     open FormletSnippets
  29.     open IntelliFactory.WebSharper.Html
  30.  
  31.     type Snippets() =
  32.         inherit Web.Control()
  33.         [<JavaScript>] override this.Body = Div [ RunSnippet "Snippet1"  Snippet1 ]  :> _
  34.  
  35. module VariousFormletSnippets =
  36.     open IntelliFactory.Html
  37.     open IntelliFactory.WebSharper.Sitelets
  38.    
  39.     type Action = | Home
  40.     module Pages =
  41.         let SnippetsPage =
  42.             Content.PageContent <| fun ctx ->
  43.                 { Page.Default with
  44.                     Title = Some "Formlet snippets"
  45.                     Body =
  46.                         [
  47.                             H1 [Text "Snippets"]
  48.                             Div [new Formlets.Snippets()]
  49.                         ]
  50.                 }
  51.  
  52.     let EntireSite =
  53.         Sitelet.Content "/" Action.Home Pages.SnippetsPage
  54.  
  55.     type Website() =
  56.         interface IWebsite<Action> with
  57.             member this.Sitelet = EntireSite
  58.             member this.Actions = []
  59.  
  60. type Global() =
  61.     inherit System.Web.HttpApplication()
  62.  
  63.     member g.Application_Start(sender: obj, args: System.EventArgs) =
  64.         ()
  65.  
  66. [<assembly: Website(typeof<VariousFormletSnippets.Website>)>]
  67. do ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement