'use strict'; import React from 'react'; import Q from 'q'; import { escapeHTML } from '../../utils/general_utils'; import InjectInHeadMixin from '../../mixins/inject_in_head_mixin'; import Panel from 'react-bootstrap/lib/Panel'; import ProgressBar from 'react-bootstrap/lib/ProgressBar'; import AppConstants from '../../constants/application_constants.js'; /** * 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.isRequired, preview: React.PropTypes.string.isRequired }, mixins: [InjectInHeadMixin], componentDidMount() { this.inject('https://code.jquery.com/jquery-2.1.4.min.js') .then(() => Q.all([ this.inject(AppConstants.baseUrl + 'static/thirdparty/shmui/shmui.css'), this.inject(AppConstants.baseUrl + 'static/thirdparty/shmui/jquery.shmui.js') ]).then(() => { window.jQuery('.shmui-ascribe').shmui(); })); }, render() { return ( ); } }); let Audio = React.createClass({ propTypes: { url: React.PropTypes.string.isRequired }, mixins: [InjectInHeadMixin], componentDidMount() { this.inject(AppConstants.baseUrl + 'static/thirdparty/audiojs/audiojs/audio.min.js').then(this.ready); }, ready() { window.audiojs.events.ready(function() { window.audiojs.createAll(); }); }, render() { return (