Sha256: e30fa9d40745c1b3d27d182c001ed58850cef656a03ae287b70bd68a2dbe486f

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

class Lanes.Components.ImageAsset extends Lanes.React.Component

    propTypes:
        model: Lanes.PropTypes.Model.isRequired
        name: React.PropTypes.string.isRequired
        size: React.PropTypes.oneOf([
            'thumb', 'medium', 'original'
        ]).isRequired

    dataObjects:
        asset: -> @props.model[@props.name]

    listenNetworkEvents: true

    bindDataEvents: ->
        model: "change:#{@props.name} change:#{@props.name}_data"

    handleImageChange: (ev) ->
        ev.preventDefault()
        @asset.blob = ev.target.files[0]

    renderImage: ->
        <img className="preview" src={@asset.thumbnail_url} />

    blankImage: ->
        null

    render: ->
        Component = if @asset.hasImage then @renderImage else @blankImage
        className = _.classnames('image-asset', @props.className, {
            'with-image': @asset.hasImage
        })

        <LC.FieldWrapper
            {...@props}
            className={className}
            displayComponent={Component}
        >
            <Component />
            <form>
                <label className="selector">
                    <span>{if @asset.hasImage then 'Update' else 'Choose'}</span>
                    <input id='file' className="file" type="file" onChange={@handleImageChange} />
                </label>
            </form>
        </LC.FieldWrapper>

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lanes-0.5.6 client/lanes/components/shared/ImageAsset.cjsx
lanes-0.5.5 client/lanes/components/shared/ImageAsset.cjsx
lanes-0.5.0 client/lanes/components/shared/ImageAsset.cjsx