<commit_before>class ProdShotsGallery
  maxImages:
    limited: 4
    full: 12

  constructor: (opts) ->
    @elemContainer = opts.elemContainer
    
    @toggleButton = @elemContainer.querySelector('[data-gallery-toggle]')
    @showLabel = @elemContainer.querySelector('[data-show-label]')
    @hideLabel = @elemContainer.querySelector('[data-hide-label]')
    @fadeOverlay = @elemContainer.querySelector('.fade-out-overlay')

    @gallery = @elemContainer.querySelector('.show-photos')
    @galleryInner = @elemContainer.querySelector('.show-photos__inner')

    @galleryOpen

    @controls = @elemContainer.querySelector('.show-photos-controls')

    # Lazy image loading
    @lazyImages = @elemContainer.querySelectorAll('.lazy-image')
    @lazyComplete = false
    @prePreLoad()

    # Limited gallery (doesn't open, just forwards to smugmug)
    @limitedGallery = @elemContainer.querySelector('.gallery-control').style.display == "none"
    
    # Event listeners
    if not @limitedGallery
      @toggleButton.addEventListener('click', @toggleClick)
      @fadeOverlay.addEventListener('click', @toggleClick)
      window.requestAnimationFrame(@computeControlStickyness)

  prePreLoad: ->
    if @limitedGallery
      pre = @maxImages.limited
    else
      pre = @maxImages.full

    for iKey in [0..pre]
      @lazyLoad(@lazyImages[iKey])

  lazyLoad: (elem) ->
    if elem.src != elem.dataset.lazySrc
      elem.src = elem.dataset.lazySrc

  lazyLoads: (elems) ->
    for elem in elems
      @lazyLoad(elem)
    @lazyComplete = true

  toggleClick: (ev) =>
    ev.preventDefault()
    @toggleButton.blur()

    if @galleryOpen
      @closeGallery(ev)
    else
      @openGallery(ev)
<commit_msg>Fix #607, js exception with prod shots less than pre-lazyload maximum<commit_after>class ProdShotsGallery
  maxImages:
    limited: 4
    full: 12

  constructor: (opts) ->
    @elemContainer = opts.elemContainer
    
    @toggleButton = @elemContainer.querySelector('[data-gallery-toggle]')
    @showLabel = @elemContainer.querySelector('[data-show-label]')
    @hideLabel = @elemContainer.querySelector('[data-hide-label]')
    @fadeOverlay = @elemContainer.querySelector('.fade-out-overlay')

    @gallery = @elemContainer.querySelector('.show-photos')
    @galleryInner = @elemContainer.querySelector('.show-photos__inner')

    @galleryOpen

    @controls = @elemContainer.querySelector('.show-photos-controls')

    # Lazy image loading
    @lazyImages = @elemContainer.querySelectorAll('.lazy-image')
    @lazyComplete = false
    @preLazyLoad()

    # Limited gallery (doesn't open, just forwards to smugmug)
    @limitedGallery = @elemContainer.querySelector('.gallery-control').style.display == "none"
    
    # Event listeners
    if not @limitedGallery
      @toggleButton.addEventListener('click', @toggleClick)
      @fadeOverlay.addEventListener('click', @toggleClick)
      window.requestAnimationFrame(@computeControlStickyness)

  preLazyLoad: ->
    if @limitedGallery
      pre = @maxImages.limited
    else
      pre = @maxImages.full

    for iKey in [0..pre]
      if @lazyImages[iKey]
        @lazyLoad(@lazyImages[iKey])

  lazyLoad: (elem) ->
    if elem.src != elem.dataset.lazySrc
      elem.src = elem.dataset.lazySrc

  lazyLoads: (elems) ->
    for elem in elems
      @lazyLoad(elem)
    @lazyComplete = true

  toggleClick: (ev) =>
    ev.preventDefault()
    @toggleButton.blur()

    if @galleryOpen
      @closeGallery(ev)
    else
      @openGallery(ev)

{'fraction_non_alphanumeric': 0.12467829568201315, 'fraction_numerical': 0.0031455533314269373, 'mean_word_length': 3.4846153846153847, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '3918953', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1066, 'n_words': 198}