'use strict'; import React from 'react'; import Q from 'q'; import Panel from 'react-bootstrap/lib/Panel'; import AppConstants from '../../constants/application_constants'; import { escapeHTML } from '../../utils/general_utils'; import { extractFileExtensionFromUrl } from '../../utils/file_utils'; import { InjectInHeadUtils } from '../../utils/inject_utils'; /** * 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) { InjectInHeadUtils.inject(AppConstants.jquery.sdkUrl) .then(() => Q.all([ InjectInHeadUtils.inject(AppConstants.shmui.cssUrl), InjectInHeadUtils.inject(AppConstants.shmui.sdkUrl) ]).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() { InjectInHeadUtils.inject(AppConstants.audiojs.sdkUrl).then(this.ready); }, ready() { window.audiojs.events.ready(function() { window.audiojs.createAll(); }); }, render() { return (