mirror of
https://github.com/ascribe/onion.git
synced 2024-11-15 01:25:17 +01:00
Add shmui to handle images
This commit is contained in:
parent
8f65aa7a2d
commit
a4b3438a2d
@ -29,11 +29,20 @@ let Other = React.createClass({
|
|||||||
});
|
});
|
||||||
|
|
||||||
let Image = React.createClass({
|
let Image = React.createClass({
|
||||||
|
mixins: [InjectInHeadMixin],
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.inject('http://code.jquery.com/jquery-2.1.4.min.js')
|
||||||
|
.then(() =>
|
||||||
|
Promise.all([
|
||||||
|
this.inject('node_modules/shmui/shmui.css'),
|
||||||
|
this.inject('node_modules/shmui/jquery.shmui.js')
|
||||||
|
]).then(() => { $('.shmui-ascribe').shmui(); }));
|
||||||
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
return (
|
return (
|
||||||
<a href={this.props.url} target="_blank" >
|
<img className="shmui-ascribe" src={this.props.preview} data-large-src={this.props.url}/>
|
||||||
<img src={this.props.preview} />
|
|
||||||
</a>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -22,7 +22,7 @@ let InjectInHeadMixin = {
|
|||||||
return document.querySelector(query);
|
return document.querySelector(query);
|
||||||
},
|
},
|
||||||
|
|
||||||
injectTag(tag, src){
|
injectTag(tag, src, extraAttrs) {
|
||||||
let promise = new Promise((resolve, reject) => {
|
let promise = new Promise((resolve, reject) => {
|
||||||
if (InjectInHeadMixin.isPresent(tag, src)) {
|
if (InjectInHeadMixin.isPresent(tag, src)) {
|
||||||
resolve();
|
resolve();
|
||||||
@ -37,6 +37,9 @@ let InjectInHeadMixin = {
|
|||||||
}
|
}
|
||||||
document.head.appendChild(element);
|
document.head.appendChild(element);
|
||||||
element[attr] = src;
|
element[attr] = src;
|
||||||
|
if (tag == 'link') {
|
||||||
|
element['rel'] = 'stylesheet';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -35,10 +35,10 @@
|
|||||||
"object-assign": "^2.0.0",
|
"object-assign": "^2.0.0",
|
||||||
"react": "^0.13.2",
|
"react": "^0.13.2",
|
||||||
"react-bootstrap": "~0.22.6",
|
"react-bootstrap": "~0.22.6",
|
||||||
|
"react-datepicker": "~0.8.0",
|
||||||
"react-router": "^0.13.3",
|
"react-router": "^0.13.3",
|
||||||
"uglifyjs": "^2.4.10",
|
"shmui": "^0.1.0",
|
||||||
"react-bootstrap": "~0.22.6",
|
"uglifyjs": "^2.4.10"
|
||||||
"react-datepicker": "~0.8.0"
|
|
||||||
},
|
},
|
||||||
"jest": {
|
"jest": {
|
||||||
"scriptPreprocessor": "node_modules/babel-jest",
|
"scriptPreprocessor": "node_modules/babel-jest",
|
||||||
|
Loading…
Reference in New Issue
Block a user