'use strict'; import React from 'react'; import Panel from 'react-bootstrap/lib/Panel'; import audiojs from '../../third_party/imports/audiojs'; import shmui from '../../third_party/imports/shmui'; import videojs from '../../third_party/imports/videojs'; import { escapeHTML } from '../../utils/dom'; import { extractFileExtensionFromUrl } from '../../utils/file'; /** * This is the component that implements display-specific functionality. * * ResourceViewer handles the following mimetypes: * - image * - video * - audio * - pdf * - other */ let Other = React.createClass({ propTypes: { url: React.PropTypes.string.isRequired }, render() { let filename = this.props.url.split('/').pop(); let tokens = filename.split('.'); let thumbnail; if (tokens.length > 1) { thumbnail = '.' + tokens.pop(); } else { thumbnail = 'file'; } return (

{thumbnail}

); } }); let Image = React.createClass({ propTypes: { url: React.PropTypes.string, thumbnail: React.PropTypes.string.isRequired }, componentDidMount() { if (this.props.url) { shmui .importLib() .then(() => window.jQuery('.shmui-ascribe').shmui()); } }, render() { const { url, thumbnail } = this.props; // TIFFs can not be displayed by the browser, so we just display their thumbnail // url is not necessarily defined, which would cause this function to fail if (url && extractFileExtensionFromUrl(url) !== 'tif' && extractFileExtensionFromUrl(url) !== 'tiff') { return ( ); } else { return ( ); } } }); let Audio = React.createClass({ propTypes: { url: React.PropTypes.string.isRequired }, componentDidMount() { audiojs .importLib() .then(() => window.audiojs.events.ready(() => window.audiojs.createAll())); }, render() { return (