From 62cc6b41dffa082ab18f28c934d4b75e0f2e4776 Mon Sep 17 00:00:00 2001 From: vrde Date: Fri, 5 Jun 2015 14:14:59 +0200 Subject: [PATCH] Lint code --- js/actions/edition_list_actions.js | 2 +- js/components/ascribe_media/media_player.js | 26 +++++++++++++++++---- js/mixins/inject_in_head_mixin.js | 10 ++++---- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/js/actions/edition_list_actions.js b/js/actions/edition_list_actions.js index 83b9abfe..ca653323 100644 --- a/js/actions/edition_list_actions.js +++ b/js/actions/edition_list_actions.js @@ -35,4 +35,4 @@ class EditionListActions { } } -export default alt.createActions(EditionListActions); \ No newline at end of file +export default alt.createActions(EditionListActions); diff --git a/js/components/ascribe_media/media_player.js b/js/components/ascribe_media/media_player.js index 6a7d741b..55188568 100644 --- a/js/components/ascribe_media/media_player.js +++ b/js/components/ascribe_media/media_player.js @@ -1,3 +1,5 @@ +'use strict'; + import React from 'react'; import InjectInHeadMixin from '../../mixins/inject_in_head_mixin'; import Panel from 'react-bootstrap/lib/Panel'; @@ -15,6 +17,10 @@ import Panel from 'react-bootstrap/lib/Panel'; let Other = React.createClass({ + propTypes: { + url: React.PropTypes.string.isRequired + }, + render() { let ext = this.props.url.split('.').pop(); @@ -29,6 +35,11 @@ let Other = React.createClass({ }); let Image = React.createClass({ + propTypes: { + url: React.PropTypes.string.isRequired, + preview: React.PropTypes.string.isRequired + }, + mixins: [InjectInHeadMixin], componentDidMount() { @@ -37,7 +48,7 @@ let Image = React.createClass({ Promise.all([ this.inject('node_modules/shmui/shmui.css'), this.inject('node_modules/shmui/jquery.shmui.js') - ]).then(() => { $('.shmui-ascribe').shmui(); })); + ]).then(() => { window.jQuery('.shmui-ascribe').shmui(); })); }, render() { @@ -66,7 +77,11 @@ let Video = React.createClass({ Promise.all([ this.inject('https://cdnjs.cloudflare.com/ajax/libs/mediaelement/2.17.0/mediaelement-and-player.min.js'), this.inject('https://cdnjs.cloudflare.com/ajax/libs/mediaelement/2.17.0/mediaelementplayer.min.css') - ]).then(() => { this.setState({ready: true}); })); + ]).then(this.ready)); + }, + + ready() { + this.setState({ready: true}); }, render() { @@ -79,7 +94,7 @@ let Video = React.createClass({ ); } else { - return( + return ( ); } @@ -91,13 +106,14 @@ let resourceMap = { 'image': Image, 'video': Video, 'other': Other -} +}; let MediaPlayer = React.createClass({ propTypes: { mimetype: React.PropTypes.oneOf(['image', 'video', 'audio', 'pdf', 'other']).isRequired, preview: React.PropTypes.string.isRequired, - url: React.PropTypes.string.isRequired + url: React.PropTypes.string.isRequired, + extraData: React.PropTypes.array }, render() { diff --git a/js/mixins/inject_in_head_mixin.js b/js/mixins/inject_in_head_mixin.js index a336c25f..b537246b 100644 --- a/js/mixins/inject_in_head_mixin.js +++ b/js/mixins/inject_in_head_mixin.js @@ -2,7 +2,7 @@ let mapAttr = { link: 'href', - source: 'src' + script: 'src' }; let mapTag = { @@ -24,14 +24,14 @@ let InjectInHeadMixin = { return document.querySelector(query); }, - injectTag(tag, src, extraAttrs) { + injectTag(tag, src) { let promise = new Promise((resolve, reject) => { if (InjectInHeadMixin.isPresent(tag, src)) { resolve(); } else { let attr = mapAttr[tag]; let element = document.createElement(tag); - if (tag == 'script') { + if (tag === 'script') { element.onload = () => resolve(); element.onerror = () => reject(); } else { @@ -39,8 +39,8 @@ let InjectInHeadMixin = { } document.head.appendChild(element); element[attr] = src; - if (tag == 'link') { - element['rel'] = 'stylesheet'; + if (tag === 'link') { + element.rel = 'stylesheet'; } } });