<commit_before>class OverlayMe.Overlays.ImagesManagementDiv extends Backbone.View

  tagName: 'fieldset'
  id: 'images_mgnt'

  initialize: ->
    $(@el).append @make 'legend', {}, 'Overlaying images'
    @controlBlock = @make 'div', { class: 'controls' }
    $(@el).append @controlBlock
    @controlBlock.appendChild @checkAllbox()
    @controlBlock.appendChild @make 'label', {}, 'All/None'
    @controlBlock.appendChild @hideInactiveBox()
    @controlBlock.appendChild @make 'label', {}, 'Hide Inactives'

    @overlaysListBlock = @make 'div', { class: 'overlays-list' }
    $(@el).append @overlaysListBlock

    $(@el).append @dynamicAddsBlock()

  append: (block) ->
    @overlaysListBlock.appendChild block

  del: (image_id) ->
    $(".overlay-image-block[data-img-id=#{image_id}]", @el).remove()
    $("#images_container ##{image_id}").remove()

  dynamicAddsBlock: ->
    @dynamicAddsBlock = @make 'div', { class: 'dynamic-adds' }
    @dynamicAddsBlock.appendChild @make 'label', {}, 'Add an image'
    image_text_input = @make 'input', { type: 'text', placeholder: "http://" }
    @dynamicAddsBlock.appendChild image_text_input
    $(image_text_input).bind 'keypress', (e) =>
      if e.charCode == 13
        OverlayMe.dyn_manager.addImage e.target.value
        e.target.value = ''
    @dynamicAddsBlock

  hideInactiveBox: ->
    @hideInactiveBox = @make 'input', { type: "checkbox", class: 'hide-inactive' }
    # if ( data = localStorage.getItem(@id) )
    #   console.log 'load:', data
    #   $(@hideInactiveBox).css(JSON.parse(data))
    if $(@hideInactiveBox).css('visibility') == 'visible'
      @hideInactiveBox.checked = true
    $(@hideInactiveBox).bind 'change', (event) =>
      @hideInactive @hideInactiveBox.checked
      @saveState()
    @hideInactiveBox

  hideInactive: (state) ->
    _.each $('.overlay-image-block'), (img_block) ->
      checkbox = $('input[type=checkbox]', img_block)
      img_id = $(img_block).attr 'data-img-id'
      if state and !checkbox.first()[0].checked
        $(img_block).hide()
        $("##{img_id}").hide()
      else
        $(img_block).show()
        $("##{img_id}").show()

  checkAllbox: ->
    @checkAllBox = @make 'input', { type: "checkbox", class: 'check-all' }<commit_msg>'Enter' use keyCode instead keyChar in Firefox..?<commit_after>class OverlayMe.Overlays.ImagesManagementDiv extends Backbone.View

  tagName: 'fieldset'
  id: 'images_mgnt'

  initialize: ->
    $(@el).append @make 'legend', {}, 'Overlaying images'
    @controlBlock = @make 'div', { class: 'controls' }
    $(@el).append @controlBlock
    @controlBlock.appendChild @checkAllbox()
    @controlBlock.appendChild @make 'label', {}, 'All/None'
    @controlBlock.appendChild @hideInactiveBox()
    @controlBlock.appendChild @make 'label', {}, 'Hide Inactives'

    @overlaysListBlock = @make 'div', { class: 'overlays-list' }
    $(@el).append @overlaysListBlock

    $(@el).append @dynamicAddsBlock()

  append: (block) ->
    @overlaysListBlock.appendChild block

  del: (image_id) ->
    $(".overlay-image-block[data-img-id=#{image_id}]", @el).remove()
    $("#images_container ##{image_id}").remove()

  dynamicAddsBlock: ->
    @dynamicAddsBlock = @make 'div', { class: 'dynamic-adds' }
    @dynamicAddsBlock.appendChild @make 'label', {}, 'Add an image'
    image_text_input = @make 'input', { type: 'text', placeholder: "http://" }
    @dynamicAddsBlock.appendChild image_text_input
    $(image_text_input).bind 'keypress', (e) =>
      if e.keyCode == 13
        OverlayMe.dyn_manager.addImage e.target.value
        e.target.value = ''
    @dynamicAddsBlock

  hideInactiveBox: ->
    @hideInactiveBox = @make 'input', { type: "checkbox", class: 'hide-inactive' }
    # if ( data = localStorage.getItem(@id) )
    #   console.log 'load:', data
    #   $(@hideInactiveBox).css(JSON.parse(data))
    if $(@hideInactiveBox).css('visibility') == 'visible'
      @hideInactiveBox.checked = true
    $(@hideInactiveBox).bind 'change', (event) =>
      @hideInactive @hideInactiveBox.checked
      @saveState()
    @hideInactiveBox

  hideInactive: (state) ->
    _.each $('.overlay-image-block'), (img_block) ->
      checkbox = $('input[type=checkbox]', img_block)
      img_id = $(img_block).attr 'data-img-id'
      if state and !checkbox.first()[0].checked
        $(img_block).hide()
        $("##{img_id}").hide()
      else
        $(img_block).show()
        $("##{img_id}").show()

  checkAllbox: ->
    @checkAllBox = @make 'input', { type: "checkbox", class: 'check-all' }
{'fraction_non_alphanumeric': 0.17730183263413557, 'fraction_numerical': 0.0013247957606535659, 'mean_word_length': 3.598984771573604, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, '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': '6541964', 'n_tokens_mistral': 1525, 'n_tokens_neox': 1495, 'n_words': 284}