liquid_feedback_frontend

diff env/ui/field/location.lua @ 1309:32cc544d5a5b

Cumulative patch for upcoming frontend version 4
author bsw/jbe
date Sun Jul 15 14:07:29 2018 +0200 (2018-07-15)
parents
children 056bccb61eee
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/env/ui/field/location.lua	Sun Jul 15 14:07:29 2018 +0200
     1.3 @@ -0,0 +1,33 @@
     1.4 +function ui.field.location(args)
     1.5 +  if config.map then
     1.6 +    ui.form_element(args, {fetch_value = true}, function(args)
     1.7 +      ui.tag{
     1.8 +        tag = "input",
     1.9 +        attr = { type = "hidden", name = args.name, value = args.value, id = "ui_field_location_value" }
    1.10 +      }
    1.11 +    end)
    1.12 +    ui.map({}, "ui_field_location_value")
    1.13 +  elseif config.firstlife then
    1.14 +    ui.form_element(args, {fetch_value = true}, function(args)
    1.15 +      ui.tag{
    1.16 +        tag = "input",
    1.17 +        attr = { type = "hidden", name = args.name, value = args.value, id = "ui_field_location_value" }
    1.18 +      }
    1.19 +      ui.tag{ tag = "iframe", attr = { src = config.firstlife.inputmap_url .. "/src/index.html?domain=" .. request.get_absolute_baseurl() .. "&" .. config.firstlife.coordinates .. "&lightArea=false&contrast=false&mode=lite", id = "ui_field_location", class = "ui_field_location" }, content = "" }
    1.20 +      
    1.21 +      ui.script{ script = [[
    1.22 +
    1.23 +        window.addEventListener("message", function (e) {
    1.24 +          if (e.origin !== "]] .. config.firstlife.inputmap_url .. [[") return;
    1.25 +          var data = e.data;
    1.26 +          if (data.src == "InputMap") {
    1.27 +            var el = document.getElementById("ui_field_location_value");
    1.28 +            el.value = JSON.stringify({ "type": "Point", "coordinates": [data.lng, data.lat], "zoom_level": data.zoom_level });
    1.29 +            console.log(el.value);
    1.30 +          }
    1.31 +        });
    1.32 +        
    1.33 +      ]] }
    1.34 +    end)
    1.35 +  end
    1.36 +end

Impressum / About Us