-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #81 from chrisgarrity/feature/html-resources
Convert PDFs on the Teach/curricula and /assessments pages to HTML to make them easier to translate
- Loading branch information
Showing
263 changed files
with
5,765 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import {withRouter} from 'react-router-dom'; | ||
import ReactRouterPropTypes from 'react-router-prop-types'; | ||
import debounceFn from 'lodash.debounce'; | ||
|
||
class ScrollManager extends React.Component { | ||
|
||
constructor (props) { | ||
super(props); | ||
|
||
this.scrollSyncData = { | ||
x: 0, | ||
y: 0, | ||
attemptsRemaining: props.scrollSyncAttemptLimit | ||
}; | ||
|
||
const scrollCapture = () => { | ||
requestAnimationFrame(() => { | ||
const {pageXOffset: x, pageYOffset: y} = window; | ||
let {pathname} = this.props.location; | ||
|
||
// router location does not include basename, since this function is setting | ||
// window.location later, pathname needs basename prepended | ||
if (typeof (this.props.basename) === 'string') { | ||
pathname = this.props.basename + pathname; | ||
} | ||
|
||
// use browser history instead of router history to avoid infinite | ||
// history.replace loop | ||
const historyState = window.history.state || {}; | ||
const { | ||
state = {} | ||
} = historyState; | ||
if (!state.scroll || state.scroll.x !== pageXOffset || state.scroll.y !== pageYOffset) { | ||
window.history.replaceState({ | ||
...historyState, | ||
state: { | ||
...state, | ||
scroll: {x, y} | ||
} | ||
}, null, pathname); | ||
} | ||
}); | ||
}; | ||
|
||
const _scrollSync = () => { | ||
requestAnimationFrame(() => { | ||
const {x, y, attemptsRemaining} = this.scrollSyncData; | ||
|
||
if (attemptsRemaining < 1) { | ||
return; | ||
} | ||
|
||
const {pageXOffset, pageYOffset} = window; | ||
if (y < window.document.body.scrollHeight && (x !== pageXOffset || y !== pageYOffset)) { | ||
window.scrollTo(x, y); | ||
this.scrollSyncData.attemptsRemaining = attemptsRemaining - 1; | ||
_scrollSync(); | ||
} | ||
}); | ||
}; | ||
|
||
const scrollSync = (x = 0, y = 0) => { | ||
this.scrollSyncData = { | ||
x, | ||
y, | ||
attemptsRemaining: this.props.scrollSyncAttemptLimit | ||
}; | ||
_scrollSync(); | ||
}; | ||
|
||
this.debouncedScroll = debounceFn(scrollCapture, props.scrollCaptureDebounce); | ||
this.debouncedScrollSync = debounceFn(scrollSync, props.scrollSyncDebounce); | ||
} | ||
|
||
componentWillMount () { | ||
const {location, onLocationChange} = this.props; | ||
if (onLocationChange) { | ||
onLocationChange(location); | ||
} | ||
} | ||
|
||
componentDidMount () { | ||
this.onPop(this.props); | ||
window.addEventListener('scroll', this.debouncedScroll, {passive: true}); | ||
} | ||
|
||
componentWillReceiveProps (nextProps) { | ||
switch (nextProps.history.action) { | ||
case 'PUSH': | ||
case 'REPLACE': | ||
this.onPush(nextProps); | ||
break; | ||
case 'POP': | ||
this.onPop(nextProps); | ||
break; | ||
default: | ||
console.warn( // eslint-disable-line no-console | ||
`Unrecognized location change action! "${nextProps.history.action}"` | ||
); | ||
} | ||
if (nextProps.onLocationChange) { | ||
nextProps.onLocationChange(nextProps.location); | ||
} | ||
} | ||
|
||
componentWillUnmount () { | ||
this.scrollSyncPending = false; | ||
window.removeEventListener('scroll', this.debouncedScroll, {passive: true}); | ||
} | ||
|
||
onPush ({location}) { | ||
if (!location.hash) { | ||
this.debouncedScrollSync(0, 0); | ||
} | ||
} | ||
|
||
onPop ({ | ||
location: { | ||
state = {} | ||
} | ||
}) { | ||
// attempt location restore | ||
const { | ||
x = 0, | ||
y = 0 | ||
} = state.scroll || {}; | ||
this.debouncedScrollSync(x, y); | ||
} | ||
|
||
render () { | ||
return this.props.children; | ||
} | ||
} | ||
ScrollManager.propTypes = { | ||
basename: PropTypes.string, | ||
children: PropTypes.node.isRequired, | ||
history: ReactRouterPropTypes.history.isRequired, | ||
location: ReactRouterPropTypes.location, | ||
onLocationChange: PropTypes.func, | ||
scrollCaptureDebounce: PropTypes.number, | ||
scrollSyncAttemptLimit: PropTypes.number, | ||
scrollSyncDebounce: PropTypes.number | ||
}; | ||
ScrollManager.defaultProps = { | ||
scrollCaptureDebounce: 50, | ||
scrollSyncDebounce: 100, | ||
scrollSyncAttemptLimit: 5 | ||
}; | ||
export default withRouter(ScrollManager); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from 'react'; | ||
import htmlContent from './student_answer_sheet.html'; | ||
|
||
import '../print.css'; | ||
import '../../../components/sectionitem/sectionitem.scss'; | ||
|
||
const AnswerSheetHtml = () => ( | ||
<div dangerouslySetInnerHTML={{__html: htmlContent}} /> // eslint-disable-line react/no-danger | ||
); | ||
export default AnswerSheetHtml; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.