mirror of https://github.com/koreader/koreader
KeyValuePages: Handle not having anything to show slightly better (#7353)
By disabling the pagination buttons, and showing a specific label, like Menu (https://github.com/koreader/koreader/pull/7347#issuecomment-786768640)reviewable/pr7355/r1
parent
2e507a42a4
commit
c2db948ff2
@ -1,28 +0,0 @@
|
|||||||
local tableutil = {}
|
|
||||||
|
|
||||||
|
|
||||||
--http://stackoverflow.com/questions/15706270/sort-a-table-in-lua
|
|
||||||
function tableutil.spairs(t, order)
|
|
||||||
-- collect the keys
|
|
||||||
local keys = {}
|
|
||||||
for k in pairs(t) do keys[#keys + 1] = k end
|
|
||||||
|
|
||||||
-- if order function given, sort by it by passing the table and keys a, b,
|
|
||||||
-- otherwise just sort the keys
|
|
||||||
if order then
|
|
||||||
table.sort(keys, function(a, b) return order(t, a, b) end)
|
|
||||||
else
|
|
||||||
table.sort(keys)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- return the iterator function
|
|
||||||
local i = 0
|
|
||||||
return function()
|
|
||||||
i = i + 1
|
|
||||||
if keys[i] then
|
|
||||||
return keys[i], t[keys[i]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return tableutil
|
|
Loading…
Reference in New Issue