1 | import Parse from '../parse';
|
2 | import { addEvent } from '../helpers';
|
3 |
|
4 | class MobileRich extends Parse {
|
5 | constructor(option = { platform: 'mobile' }) {
|
6 | super(option);
|
7 | this.images = [];
|
8 | this.lazyLoad = true;
|
9 | this.unbindImageEvents = () => {};
|
10 | this.clientHeight = 0;
|
11 | }
|
12 |
|
13 | renderImage(props) {
|
14 | let { width, height } = props;
|
15 | let imgWidth = Math.floor(window.screen.width * 0.817);
|
16 | const paddingTop = width < imgWidth ? height + 'px' : (height / width) * 100 + '%';
|
17 | return `<div><div><div style="padding-top: ${paddingTop};"></div><img data-src="${
|
18 | props.url
|
19 | }"></div>${
|
20 | props.desc && props.desc !== '' ? `<span>${props.desc}</span>` : ''
|
21 | }</div>`;
|
22 | }
|
23 |
|
24 | renderLink(props) {
|
25 |
|
26 | return `<a href="${props.route.webUrl || props.route.webURL}" target="_blank">${props.content}</a>`;
|
27 | }
|
28 |
|
29 | renderVideo(props) {
|
30 | return `<video controls='controls'>
|
31 | <source src="${props.url}">
|
32 | </video>`
|
33 | }
|
34 | }
|
35 |
|
36 | export default MobileRich;
|