Key shortcuts

merge-requests/30/head
Bob Mottram 2021-04-22 12:51:19 +01:00
parent 01ae322139
commit 5343c38ff2
7 changed files with 51 additions and 10 deletions

View File

@ -456,7 +456,11 @@ def htmlCalendar(personCache: {}, cssCache: {}, translate: {},
htmlHideFromScreenReader('') + ' ' + translate['Previous month']
navLinks[prevMonthStr] = calActor + '/calendar?year=' + str(prevYear) + \
'?month=' + str(prevMonthNumber)
# TODO
navAccessKeys = {
}
screenReaderCal = \
htmlKeyboardNavigation(textModeBanner, navLinks, monthName)
htmlKeyboardNavigation(textModeBanner, navLinks, navAccessKeys,
monthName)
return headerStr + screenReaderCal + calendarStr + htmlFooter()

View File

@ -84,7 +84,7 @@ def htmlLogin(cssCache: {}, translate: {},
copyfile(baseDir + '/img/login.png', loginImageFilename)
textModeLogo = getTextModeLogo(baseDir)
textModeLogoHtml = htmlKeyboardNavigation(textModeLogo, {})
textModeLogoHtml = htmlKeyboardNavigation(textModeLogo, {}, {})
if os.path.isfile(baseDir + '/accounts/login-background-custom.jpg'):
if not os.path.isfile(baseDir + '/accounts/login-background.jpg'):

View File

@ -119,7 +119,7 @@ def htmlPersonOptions(defaultTimeline: str,
instanceTitle = \
getConfigParam(baseDir, 'instanceTitle')
optionsStr = htmlHeaderWithExternalStyle(cssFilename, instanceTitle)
optionsStr += htmlKeyboardNavigation(textModeBanner, {})
optionsStr += htmlKeyboardNavigation(textModeBanner, {}, {})
optionsStr += '<br><br>\n'
optionsStr += '<div class="options">\n'
optionsStr += ' <div class="optionsAvatar">\n'

View File

@ -755,7 +755,19 @@ def htmlProfile(rssIconAtTop: bool,
menuShares: userPathStr + '/shares#timeline',
menuLogout: '/logout'
}
profileStr = htmlKeyboardNavigation(textModeBanner, navLinks)
navAccessKeys = {
menuTimeline: 't',
menuEdit: 'e',
menuFollowing: 'f',
menuFollowers: 'g',
menuRoles: 'o',
menuSkills: 's',
menuShares: 'h',
menuLogout: 'x'
}
profileStr = htmlKeyboardNavigation(textModeBanner,
navLinks, navAccessKeys,
navAccessKeys)
profileStr += profileHeaderStr + donateSection
profileStr += '<div class="container" id="buttonheader">\n'
@ -1471,7 +1483,12 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
menuProfile: userPathStr,
menuTimeline: userTimalineStr
}
editProfileForm += htmlKeyboardNavigation(textModeBanner, navLinks)
navAccessKeys = {
menuProfile: 'p',
menuTimeline: 't'
}
editProfileForm += htmlKeyboardNavigation(textModeBanner,
navLinks, navAccessKeys)
# top banner
editProfileForm += \

View File

@ -342,7 +342,7 @@ def htmlSearch(cssCache: {}, translate: {},
searchBannerFile, searchBannerFilename = \
getSearchBannerFile(baseDir, searchNickname, domain, theme)
textModeBannerStr = htmlKeyboardNavigation(textModeBanner, {})
textModeBannerStr = htmlKeyboardNavigation(textModeBanner, {}, {})
if textModeBannerStr is None:
textModeBannerStr = ''

View File

@ -479,10 +479,26 @@ def htmlTimeline(cssCache: {}, defaultTimeline: str,
menuNewswire: usersPath + '/newswiremobile',
menuLinks: usersPath + '/linksmobile'
}
navAccessKeys = {
menuProfile: 'p',
menuInbox: 'i',
menuSearch: '/',
menuNewPost: 'n',
menuCalendar: 'c',
menuDM: 'm',
menuReplies: 'r',
menuOutbox: 'o',
menuBookmarks: 'k',
menuShares: 's',
menuBlogs: 'b',
menuNewswire: 'w',
menuLinks: 'l'
}
if moderator:
navLinks[menuModeration] = usersPath + '/moderation#modtimeline'
tlStr += htmlKeyboardNavigation(textModeBanner, navLinks, None,
usersPath, translate, followApprovals)
tlStr += htmlKeyboardNavigation(textModeBanner, navLinks, navAccessKeys,
None, usersPath, translate,
followApprovals)
# banner and row of buttons
tlStr += \

View File

@ -1114,7 +1114,7 @@ def htmlHideFromScreenReader(htmlStr: str) -> str:
return '<span aria-hidden="true">' + htmlStr + '</span>'
def htmlKeyboardNavigation(banner: str, links: {},
def htmlKeyboardNavigation(banner: str, links: {}, accessKeys: {},
subHeading=None,
usersPath=None, translate=None,
followApprovals=False) -> str:
@ -1138,8 +1138,12 @@ def htmlKeyboardNavigation(banner: str, links: {},
# show the list of links
for title, url in links.items():
accessKeyStr = ''
if accessKeys.get(title):
accessKeyStr = 'accesskey="' + accessKeys[title] + '"'
htmlStr += '<li><label class="transparent">' + \
'<a href="' + str(url) + '">' + \
'<a href="' + str(url) + '" ' + accessKeyStr + '>' + \
str(title) + '</a></label></li>\n'
htmlStr += '</ul></div>\n'
return htmlStr