lualoader: Allow carousel 'items' to be a table as well as a function
We don't have any in-tree users of this, but for a static set of carousel options having to define a callback is excessive.
This commit is contained in:
parent
a51f9f0c48
commit
4f437f9eab
@ -190,8 +190,10 @@ drawer.menu_name_handlers = {
|
||||
[core.MENU_CAROUSEL_ENTRY] = function(drawing_menu, entry)
|
||||
local carid = entry.carousel_id
|
||||
local caridx = config.getCarouselIndex(carid)
|
||||
local choices = entry.items()
|
||||
|
||||
local choices = entry.items
|
||||
if type(choices) == "function" then
|
||||
choices = choices()
|
||||
end
|
||||
if #choices < caridx then
|
||||
caridx = 1
|
||||
end
|
||||
|
@ -65,8 +65,10 @@ menu.handlers = {
|
||||
-- carousel (rotating) functionality
|
||||
local carid = entry.carousel_id
|
||||
local caridx = config.getCarouselIndex(carid)
|
||||
local choices = entry.items()
|
||||
|
||||
local choices = entry.items
|
||||
if type(choices) == "function" then
|
||||
choices = choices()
|
||||
end
|
||||
if #choices > 0 then
|
||||
caridx = (caridx % #choices) + 1
|
||||
config.setCarouselIndex(carid, caridx)
|
||||
|
Loading…
x
Reference in New Issue
Block a user