import JDImage from '../image/image';
import ImageSize from '../../../../util/ImageSize';
class JDImageWH extends JDImage {
    constructor(config) {
        super(config);
    }
    
    _getConfig(config) {
        const { domData } = config;
        const validate = domData.validate || {};
        const w = validate.width || '1-9999';
        const h = validate.height || '1-9999';
        const format = w + ',' + h;
        const sizeCn = ImageSize.getTip(format);
        const tips = '支持' + sizeCn + '，大小不超过800KB的JPG、PNG图片';
        const param = $.extend(true, {}, {
            domData: { tips },
            format,
        }, config);
        param.defaultImage = config.defaultImage ? config.defaultImage.value : '';
        return param;
    }
    
    getData() {
        let key = this.config.domData.name;
        let value = this.element.find('.cd-image-panel').attr('data-url');
        let $imgSize = this.element.find('.J_imgSize');
        let picWidth = $imgSize.attr('picWidth');
        let picHeight = $imgSize.attr('picHeight');
        let result = {};
        result[key] = {
            value,
            picWidth,
            picHeight,
        };
        return result;
    }
}
export default JDImageWH;