Skip to content

Commit 2ea039e

Browse files
committed
adds accessibility to pages
1 parent 29f3f16 commit 2ea039e

31 files changed

+14498
-86
lines changed

app.js

100644100755
File mode changed.

public/js/3.js

+229-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/3.js.gz

-125 KB
Binary file not shown.

public/js/4.js

+370-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/4.js.gz

-105 KB
Binary file not shown.

public/js/5.js

+3,127-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/5.js.gz

558 KB
Binary file not shown.

public/js/6.js

+9,810-1
Large diffs are not rendered by default.

public/js/6.js.gz

662 KB
Binary file not shown.

public/js/truRequire.js

+328-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/truRequire.js.gz

255 KB
Binary file not shown.

public/js/trudesk.min.js

+306-1
Large diffs are not rendered by default.

public/js/trudesk.min.js.gz

2.11 KB
Binary file not shown.

public/js/vendor.js

+133-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/js/vendor.js.gz

126 KB
Binary file not shown.

src/client/components/Nav/SidebarItem/index.jsx

+61-24
Original file line numberDiff line numberDiff line change
@@ -11,54 +11,91 @@
1111
* Updated: 1/20/19 4:46 PM
1212
* Copyright (c) 2014-2019. All rights reserved.
1313
*/
14-
1514
import React, { Component } from 'react'
1615
import PropTypes from 'prop-types'
1716

1817
import Helpers from 'modules/helpers'
1918

20-
// import './style.sass';
21-
2219
class NavButton extends Component {
23-
constructor (props) {
20+
constructor(props) {
2421
super(props)
22+
this.announcementRef = React.createRef()
23+
}
24+
25+
componentDidMount() {
26+
this.setupClickHandler()
2527
}
2628

27-
componentDidUpdate () {
29+
componentDidUpdate() {
2830
Helpers.UI.bindAccordion()
2931
Helpers.UI.tetherUpdate()
32+
this.setupClickHandler()
33+
}
34+
35+
setupClickHandler() {
36+
const anchor = this.anchorRef.querySelector('a')
37+
if (anchor) {
38+
anchor.removeEventListener('click', this.handleClick)
39+
anchor.addEventListener('click', this.handleClick)
40+
}
41+
}
42+
43+
handleClick = (event) => {
44+
event.preventDefault()
45+
const announcement = `Moving to ${this.props.text} page`
46+
if (this.announcementRef.current) {
47+
this.announcementRef.current.innerHTML = announcement
48+
setTimeout(() => {
49+
this.announcementRef.current.innerHTML = ''
50+
}, 1000)
51+
}
52+
setTimeout(() => {
53+
window.location.href = this.props.href
54+
}, 100)
3055
}
3156

32-
renderAnchorLink () {
57+
renderAnchorLink() {
3358
return (
3459
<a href={this.props.href} className={this.props.class} target={this.props.target || ''}>
35-
<i className='material-icons'>{this.props.icon}</i>
60+
<i className='material-icons' aria-hidden='true'>{this.props.icon}</i>
3661
{this.props.text}
3762
</a>
3863
)
3964
}
4065

41-
render () {
42-
if (this.props.hasSubmenu) {
43-
return (
66+
render() {
67+
const { hasSubmenu, active, subMenuTarget, children } = this.props
68+
69+
return (
70+
<>
4471
<li
45-
className={'hasSubMenu' + (this.props.active ? ' active' : '')}
46-
data-nav-id={this.props.subMenuTarget}
72+
ref={(el) => this.anchorRef = el}
73+
className={`${hasSubmenu ? 'hasSubMenu' : ''} ${active ? 'active' : ''}`}
74+
data-nav-id={subMenuTarget}
4775
data-nav-accordion
48-
data-nav-accordion-target={'side-nav-accordion-' + this.props.subMenuTarget}
76+
data-nav-accordion-target={hasSubmenu ? `side-nav-accordion-${subMenuTarget}` : undefined}
4977
>
5078
{this.renderAnchorLink()}
51-
{this.props.children}
79+
{children}
5280
</li>
53-
)
54-
} else {
55-
return (
56-
<li className={this.props.active ? ' active ' : ''}>
57-
{this.renderAnchorLink()}
58-
{this.props.children}
59-
</li>
60-
)
61-
}
81+
<div
82+
ref={this.announcementRef}
83+
aria-live="assertive"
84+
className="sr-only"
85+
style={{
86+
position: 'absolute',
87+
width: '1px',
88+
height: '1px',
89+
padding: '0',
90+
margin: '-1px',
91+
overflow: 'hidden',
92+
clip: 'rect(0, 0, 0, 0)',
93+
whiteSpace: 'nowrap',
94+
border: '0'
95+
}}
96+
></div>
97+
</>
98+
)
6299
}
63100
}
64101

@@ -74,4 +111,4 @@ NavButton.propTypes = {
74111
children: PropTypes.node
75112
}
76113

77-
export default NavButton
114+
export default NavButton

src/client/components/Nav/SubmenuItem/index.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class SubmenuItem extends React.Component {
2222
{this.props.hasSeperator && <hr />}
2323
<li className={this.props.active ? ' active ' : ''}>
2424
<a href={this.props.href}>
25-
<i className='material-icons fa-sub-icon'>{this.props.icon}</i>
25+
<i className='material-icons fa-sub-icon' aria-hidden='true'>{this.props.icon}</i>
2626
{this.props.text}
2727
</a>
2828
</li>

src/client/containers/Modals/BaseModal.jsx

+33
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ class BaseModal extends React.Component {
2727
modal: null
2828
}
2929
this.clearModal = this.clearModal.bind(this)
30+
this.handleKeyDown = this.handleKeyDown.bind(this)
3031
}
3132

3233
componentDidMount () {
@@ -36,11 +37,43 @@ class BaseModal extends React.Component {
3637
},
3738
() => {
3839
this.state.modal.show()
40+
$(this.modal).focus()
3941
$(this.modal).on('hide.uk.modal', this.clearModal)
42+
this.focusableElements = this.modal.querySelectorAll('a[href], button, textarea, input, select')
43+
this.firstFocusableElement = this.focusableElements[0]
44+
this.lastFocusableElement = this.focusableElements[this.focusableElements.length - 1]
45+
this.modal.addEventListener('keydown', this.handleKeyDown)
4046
}
4147
)
4248
}
4349

50+
componentWillUnmount() {
51+
if (this.state.modal) {
52+
$(this.modal).off('hide.uk.modal', this.clearModal)
53+
this.modal.removeEventListener('keydown', this.handleKeyDown)
54+
}
55+
}
56+
57+
handleKeyDown(e) {
58+
const isTabPressed = e.key === 'Tab' || e.keyCode === 9
59+
60+
if (!isTabPressed) {
61+
return
62+
}
63+
64+
if (e.shiftKey) {
65+
if (document.activeElement === this.firstFocusableElement) {
66+
e.preventDefault()
67+
this.lastFocusableElement.focus()
68+
}
69+
} else {
70+
if (document.activeElement === this.lastFocusableElement) {
71+
e.preventDefault()
72+
this.firstFocusableElement.focus()
73+
}
74+
}
75+
}
76+
4477
show () {
4578
if (this.state.modal) this.state.modal.show()
4679
}

src/controllers/api/v1/routes.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,12 @@ module.exports = function (middleware, router, controllers) {
113113
router.delete('/api/v1/tags/:id', apiv1, isAgentOrAdmin, apiCtrl.tags.deleteTag)
114114

115115
// Public Tickets
116-
const checkCaptcha = middleware.checkCaptcha
116+
// const checkCaptcha = middleware.checkCaptcha
117117
const checkOrigin = middleware.checkOrigin
118118

119-
router.post('/api/v1/public/users/checkemail', checkCaptcha, checkOrigin, apiCtrl.users.checkEmail)
120-
router.post('/api/v1/public/tickets/create', checkCaptcha, checkOrigin, apiCtrl.tickets.createPublicTicket)
121-
router.post('/api/v1/public/account/create', checkCaptcha, checkOrigin, apiCtrl.users.createPublicAccount)
119+
router.post('/api/v1/public/users/checkemail', checkOrigin, apiCtrl.users.checkEmail)
120+
router.post('/api/v1/public/tickets/create', checkOrigin, apiCtrl.tickets.createPublicTicket)
121+
router.post('/api/v1/public/account/create', checkOrigin, apiCtrl.users.createPublicAccount)
122122

123123
// Groups
124124
router.get('/api/v1/groups', apiv1, apiCtrl.groups.get)

src/middleware/middleware.js

+15-15
Original file line numberDiff line numberDiff line change
@@ -129,25 +129,25 @@ middleware.cache = function (seconds) {
129129
}
130130
}
131131

132-
middleware.checkCaptcha = function (req, res, next) {
133-
var postData = req.body
134-
if (postData === undefined) {
135-
return res.status(400).json({ success: false, error: 'Invalid Captcha' })
136-
}
132+
// middleware.checkCaptcha = function (req, res, next) {
133+
// var postData = req.body
134+
// if (postData === undefined) {
135+
// return res.status(400).json({ success: false, error: 'Invalid Captcha' })
136+
// }
137137

138-
var captcha = postData.captcha
139-
var captchaValue = req.session.captcha
138+
// var captcha = postData.captcha
139+
// var captchaValue = req.session.captcha
140140

141-
if (captchaValue === undefined) {
142-
return res.status(400).json({ success: false, error: 'Invalid Captcha' })
143-
}
141+
// if (captchaValue === undefined) {
142+
// return res.status(400).json({ success: false, error: 'Invalid Captcha' })
143+
// }
144144

145-
if (captchaValue.toString() !== captcha.toString()) {
146-
return res.status(400).json({ success: false, error: 'Invalid Captcha' })
147-
}
145+
// if (captchaValue.toString() !== captcha.toString()) {
146+
// return res.status(400).json({ success: false, error: 'Invalid Captcha' })
147+
// }
148148

149-
return next()
150-
}
149+
// return next()
150+
// }
151151

152152
middleware.checkOrigin = function (req, res, next) {
153153
var origin = req.headers.origin

src/views/about.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<div id="about-container"></div>
1+
<div id="about-container" id="page-content"></div>

src/views/accounts.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div id="accounts-container" data-title="{{title}}" data-view="{{data.view}}"></div>
1+
<div id="accounts-container" id="page-content" data-title="{{title}}" data-view="{{data.view}}"></div>
22

33

44
{{#contentFor 'js-plugins'}}

src/views/dashboard.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<div id="dashboard-container"></div>
1+
<div id="dashboard-container" id="page-content"></div>

src/views/departments.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<div id="departments-container"></div>
1+
<div id="departments-container" id="page-content"></div>

src/views/groups.hbs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<div id="groups-container"></div>
1+
<div id="groups-container" id="page-content"></div>

0 commit comments

Comments
 (0)