<commit_before>#
# Image Collection section allows uploading a mix of images and artworks
#
_ = require 'underscore'
React = require 'react'
imagesLoaded = require 'imagesloaded'
Artwork = React.createFactory require './components/artwork.coffee'
Image = React.createFactory require './components/image.coffee'
Controls = React.createFactory require './components/controls.coffee'
DragContainer = React.createFactory require '../../../../../../components/drag_drop/index.coffee'
{ fillWidth }  = require '../../../../../../components/fill_width/index.coffee'
{ div, section, ul, li } = React.DOM

components = require('@artsy/reaction-force/dist/components/publishing/index').default
ImagesetPreview = React.createFactory components.ImagesetPreview

module.exports = React.createClass
  displayName: 'SectionImageCollection'

  getInitialState: ->
    progress: null
    imagesLoaded: false
    dimensions: []

  componentDidMount: ->
    @$list = $(@refs.images)
    @onChange()

  onChange: ->
    sizes = @getFillWidthSizes()
    imagesLoaded $(@refs.images), @onImagesLoaded(sizes)

  onImagesLoaded: (sizes) ->
    @setState
      progress: null
      imagesLoaded: true
      dimensions: fillWidth(
        @props.section.get('images'),
        sizes.targetHeight,
        sizes.containerSize,
        @props.section.get('layout') || @props.section.get('type')
      )

  getFillWidthSizes: ->
    containerSize = 860
    targetHeight = 450
    if @props.section.get('type') is 'image_set' and @props.section.get('images').length > 3
      targetHeight = 300
    else if @props.section.get('layout') is 'column_width'
      containerSize = 580
      targetHeight = 550
    return {containerSize: containerSize, targetHeight: targetHeight}

  setProgress: (progress) ->
    if progress
      @setState
        progress: progress
        imagesLoaded: false
    else
      @onChange()

  removeItem: (item) -> =><commit_msg>scale by page height<commit_after>#
# Image Collection section allows uploading a mix of images and artworks
#
_ = require 'underscore'
React = require 'react'
imagesLoaded = require 'imagesloaded'
Artwork = React.createFactory require './components/artwork.coffee'
Image = React.createFactory require './components/image.coffee'
Controls = React.createFactory require './components/controls.coffee'
DragContainer = React.createFactory require '../../../../../../components/drag_drop/index.coffee'
{ fillWidth }  = require '../../../../../../components/fill_width/index.coffee'
{ div, section, ul, li } = React.DOM

components = require('@artsy/reaction-force/dist/components/publishing/index').default
ImagesetPreview = React.createFactory components.ImagesetPreview

module.exports = React.createClass
  displayName: 'SectionImageCollection'

  getInitialState: ->
    progress: null
    imagesLoaded: false
    dimensions: []

  componentDidMount: ->
    @$list = $(@refs.images)
    @onChange()

  onChange: ->
    sizes = @getFillWidthSizes()
    imagesLoaded $(@refs.images), @onImagesLoaded(sizes)

  onImagesLoaded: (sizes) ->
    @setState
      progress: null
      imagesLoaded: true
      dimensions: fillWidth(
        @props.section.get('images'),
        sizes.targetHeight,
        sizes.containerSize,
        @props.section.get('layout') || @props.section.get('type')
      )

  getFillWidthSizes: ->
    containerSize = 860
    targetHeight = window.innerHeight * .7
    if @props.section.get('type') is 'image_set' and @props.section.get('images').length > 3
      targetHeight = 400
    else if @props.section.get('layout') is 'column_width'
      containerSize = 580
    return {containerSize: containerSize, targetHeight: targetHeight}

  setProgress: (progress) ->
    if progress
      @setState
        progress: progress
        imagesLoaded: false
    else
      @onChange()

  removeItem: (item) -> =>
{'fraction_non_alphanumeric': 0.1321928460342146, 'fraction_numerical': 0.006998444790046656, 'mean_word_length': 3.36045197740113, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7662275', 'n_tokens_mistral': 1124, 'n_tokens_neox': 1091, 'n_words': 250}