webmcp

diff framework/env/ui/link.lua @ 11:d76a8857ba62

Added ui.partial and other functions, which allow partial content replacement using XMLHttpRequests; Image support for ui.link

Also includes following changes:
- Fix for rocketcgi library to accept POST data content-types, which contain additional charset information.
- Support arrays passed as params to encode.url (only for keys ending with "[]")
- Version information changed to "1.0.7"

Documentation for added functions is not yet complete.
author jbe/bsw
date Fri Feb 12 18:40:22 2010 +0100 (2010-02-12)
parents 5e32ef998acf
children f3d3203cd2e4
line diff
     1.1 --- a/framework/env/ui/link.lua	Wed Feb 03 00:57:18 2010 +0100
     1.2 +++ b/framework/env/ui/link.lua	Fri Feb 12 18:40:22 2010 +0100
     1.3 @@ -9,7 +9,13 @@
     1.4    params    = params,     -- optional parameters to be passed to the view or action
     1.5    routing   = routing,    -- optional routing information for action links, as described for ui.form{...}
     1.6    text      = text,       -- link text
     1.7 -  content   = content     -- link content (overrides link text, except for submit buttons for action calls without JavaScript)
     1.8 +  content   = content,    -- link content (overrides link text, except for submit buttons for action calls without JavaScript)
     1.9 +  partial   = {           -- TODO: documentation
    1.10 +    module = module,
    1.11 +    view   = view,
    1.12 +    id     = id,
    1.13 +    params = params
    1.14 +  }
    1.15  }
    1.16  
    1.17  This function inserts a link into the active slot. It may be either an internal application link ('module' given and 'view' or 'action' given), or a link to an external web page ('external' given), or a link to a file in the static file directory of the application ('static' given).
    1.18 @@ -21,7 +27,9 @@
    1.19    local content = args.content or args.text
    1.20    assert(content, "ui.link{...} needs a text.")
    1.21    local function wrapped_content()
    1.22 -    -- TODO: icon/image
    1.23 +    if args.image then
    1.24 +      ui.image(args.image)
    1.25 +    end
    1.26      if type(content) == "function" then
    1.27        content()
    1.28      else
    1.29 @@ -49,6 +57,7 @@
    1.30        id       = args.id,
    1.31        params   = args.params,
    1.32        routing  = args.routing,
    1.33 +      partial  = args.partial,
    1.34        attr     = form_attr,
    1.35        content  = function()
    1.36          ui.submit{ text = args.text, attr = args.submit_attr }
    1.37 @@ -85,6 +94,9 @@
    1.38        id        = args.id,
    1.39        params    = args.params,
    1.40      }
    1.41 +    if ui.is_partial_loading_enabled() and args.partial then
    1.42 +      a_attr.onclick = ui._partial_load_js(args.partial)
    1.43 +    end
    1.44      return ui.tag{ tag  = "a", attr = a_attr, content = wrapped_content }
    1.45    end
    1.46  end

Impressum / About Us