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
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329700
@ -190,8 +190,10 @@ drawer.menu_name_handlers = {
|
|||||||
[core.MENU_CAROUSEL_ENTRY] = function(drawing_menu, entry)
|
[core.MENU_CAROUSEL_ENTRY] = function(drawing_menu, entry)
|
||||||
local carid = entry.carousel_id
|
local carid = entry.carousel_id
|
||||||
local caridx = config.getCarouselIndex(carid)
|
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
|
if #choices < caridx then
|
||||||
caridx = 1
|
caridx = 1
|
||||||
end
|
end
|
||||||
|
@ -65,8 +65,10 @@ menu.handlers = {
|
|||||||
-- carousel (rotating) functionality
|
-- carousel (rotating) functionality
|
||||||
local carid = entry.carousel_id
|
local carid = entry.carousel_id
|
||||||
local caridx = config.getCarouselIndex(carid)
|
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
|
if #choices > 0 then
|
||||||
caridx = (caridx % #choices) + 1
|
caridx = (caridx % #choices) + 1
|
||||||
config.setCarouselIndex(carid, caridx)
|
config.setCarouselIndex(carid, caridx)
|
||||||
|
Loading…
Reference in New Issue
Block a user