const Drawer = require( '../Drawer' ), util = require( '../util' ), icons = require( '../icons' ), ReferencesGateway = require( './ReferencesGateway' ), Icon = require( '../Icon' ), ReferencesHtmlScraperGateway = require( './ReferencesHtmlScraperGateway' ), IconButton = require( '../IconButton' ); /** * Create a callback for clicking references * * @ignore * @param {Function} onNestedReferenceClick * @return {Function} */ function makeOnNestedReferenceClickHandler( onNestedReferenceClick ) { return ( ev ) => { const target = ev.currentTarget.querySelector( 'a' ); if ( target ) { onNestedReferenceClick( target.getAttribute( 'href' ), target.textContent ); // Don't hide the already shown drawer via propagation return false; } }; } /** * Drawer for references * * @memberof module:mobile.startup/references * @uses IconButton * @param {Object} props * @param {boolean} [props.error] whether an error has occurred * @param {string} props.title of reference e.g [1] * @param {string} props.text is the HTML of the reference * @param {string} [props.parentText] is the HTML of the parent reference if there is one * @param {boolean} props.isSubref true when this reference has a parent * @param {Function} [props.onNestedReferenceClick] callback for when a reference * inside the reference is clicked. * @return {module:mobile.startup/Drawer} */ function referenceDrawer( props ) { const errorIcon = props.error ? new IconButton( { name: 'error', isSmall: true } ).$el : null; const mainRef = props.isSubref ? props.parentText : props.text; const mainRefHtml = util.parseHTML( '