'use strict'; import React from 'react'; import Q from 'q'; import Panel from 'react-bootstrap/lib/Panel'; import ProgressBar from 'react-bootstrap/lib/ProgressBar'; import AppConstants from '../../constants/application_constants'; import { escapeHTML } from '../../utils/general_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 preview; if (tokens.length > 1) { preview = '.' + tokens.pop(); } else { preview = 'file'; } return (

{preview}

); } }); let Image = React.createClass({ propTypes: { url: React.PropTypes.string, preview: 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, preview } = this.props; if(url) { 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 (