UNPKG

1.07 kBJavaScriptView Raw
1import Parse from '../parse';
2import { addEvent } from '../helpers';
3
4class 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 // return `<p><a href="${props.url}" target="_blank">${props.text}</a></p>`;
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
36export default MobileRich;