1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 09:23:13 +01:00

Lint code

This commit is contained in:
vrde 2015-06-05 14:14:59 +02:00
parent e8627cd0a3
commit 62cc6b41df
3 changed files with 27 additions and 11 deletions

View File

@ -35,4 +35,4 @@ class EditionListActions {
}
}
export default alt.createActions(EditionListActions);
export default alt.createActions(EditionListActions);

View File

@ -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({
</video>
);
} else {
return(
return (
<Image src={this.props.preview} />
);
}
@ -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() {

View File

@ -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';
}
}
});