summaryrefslogtreecommitdiff
path: root/indra/newview/scripts/lua/popup.lua
blob: 8a01ab7836cfaf55fa8c9e3a6c1027f8f44d70e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
local leap = require 'leap'

-- notification is any name defined in notifications.xml as
-- <notification name=>
-- vars is a table providing values for [VAR] substitution keys in the
-- notification body.
local popup_meta = {
    -- setting this function as getmetatable(popup).__call() means this gets
    -- called when a consumer calls popup(notification, vars, payload)
    __call = function(self, notification, vars, payload)
        return leap.request('LLNotifications',
                            {op='requestAdd', name=notification,
                             substitutions=vars,
                             payload=payload})
    end
}

local popup = setmetatable({}, popup_meta)

function popup:alert(message)
    return self('GenericAlert', {MESSAGE=message})
end

function popup:alertOK(message)
    return self('GenericAlertOK', {MESSAGE=message})
end

function popup:alertYesCancel(message)
    return self('GenericAlertYesCancel', {MESSAGE=message})
end

return popup