diff --git a/example/pages/cell/index.js b/example/pages/cell/index.js index 0982978..d4ae536 100644 --- a/example/pages/cell/index.js +++ b/example/pages/cell/index.js @@ -240,7 +240,7 @@ export default class CellDemo extends React.Component { maxCount={6} files={this.state.demoFiles} onError={msg => alert(msg)} - onChange={file => { + onChange={(file,e) => { let newFiles = [...this.state.demoFiles, {url:file.data}]; this.setState({ demoFiles: newFiles diff --git a/src/components/form/textarea.js b/src/components/form/textarea.js index e22f9a0..11f1b7b 100644 --- a/src/components/form/textarea.js +++ b/src/components/form/textarea.js @@ -29,7 +29,7 @@ export default class TextArea extends React.Component { } render(){ - const { className, children, showCounter, maxlength, ...others } = this.props; + const { className, children, showCounter, maxlength, onChange, ...others } = this.props; const cls = classNames({ weui_textarea: true, [className]: className diff --git a/src/components/form/uploader.js b/src/components/form/uploader.js index b4b501b..410f0c7 100644 --- a/src/components/form/uploader.js +++ b/src/components/form/uploader.js @@ -4,6 +4,7 @@ import React, { Component, PropTypes } from 'react'; +import ReactDOM from 'react-dom'; import classNames from 'classnames'; export default class Uploader extends React.Component { @@ -30,26 +31,45 @@ export default class Uploader extends React.Component { }; handleFile(file,cb) { - let reader = new FileReader(); + let reader; + if(typeof FileReader !== 'undefined') { + reader = new FileReader(); + } else { + if(window.FileReader) reader = new window.FileReader(); + } + reader.onload = e => { - let img = new Image(); + let img; + if(typeof Image !== 'undefined') { + img = new Image(); + } else { + if(window.Image) img = new window.Image(); + } img.onload = ()=>{ let w = Math.min(this.props.maxWidth, img.width); let h = img.height * (w / img.width); let canvas = document.createElement('canvas'); let ctx = canvas.getContext('2d'); - canvas.width = w; - canvas.height = h; - ctx.drawImage(img, 0, 0, w, h); - let base64 = canvas.toDataURL('image/png'); - cb({ - lastModified: file.lastModified, - lastModifiedDate: file.lastModifiedDate, - name: file.name, - size: file.size, - type: file.type, - data: base64 - }); + + //check canvas support, for test + if(ctx){ + canvas.width = w; + canvas.height = h; + ctx.drawImage(img, 0, 0, w, h); + + let base64 = canvas.toDataURL('image/png'); + + cb({ + lastModified: file.lastModified, + lastModifiedDate: file.lastModifiedDate, + name: file.name, + size: file.size, + type: file.type, + data: base64 + },e); + }else{ + cb(file, e); + } }; img.src = e.target.result; } @@ -70,9 +90,11 @@ export default class Uploader extends React.Component { for(let key in _files) { if (!_files.hasOwnProperty(key)) continue; let file = _files[key]; - this.handleFile(file, _file=>{ + + this.handleFile(file, (_file,e)=>{ if(this.props.onChange) this.props.onChange(_file, e); - }); + ReactDOM.findDOMNode(this.refs.uploader).value=''; + },e); } } @@ -120,6 +142,7 @@ export default class Uploader extends React.Component {
{children}
+{children}
); } }; \ No newline at end of file diff --git a/src/components/mediabox/mediabox_header.js b/src/components/mediabox/mediabox_header.js index df63a95..8ff3e27 100644 --- a/src/components/mediabox/mediabox_header.js +++ b/src/components/mediabox/mediabox_header.js @@ -9,10 +9,10 @@ import classNames from 'classnames'; export default class MediaBoxHeader extends React.Component { render() { - const {children, ...others} = this.props; - const className = classNames({ + const {children, className, ...others} = this.props; + const clz = classNames({ weui_media_hd: true - }); + }, className); let childrenWithProps = React.Children.map(children, child => { if(child.type == 'img' && !child.props.className){ @@ -23,7 +23,7 @@ export default class MediaBoxHeader extends React.Component { }); return ( -文章描述
文章描述
MediaBox header wording
].map((child)=>{ + describe(`MediaBox Info wording
].map((child)=>{ + describe(`MediaBox InfoMeta wording
].map((child)=>{ + describe(`文章描述