<commit_before>Spine    = require("spine")
List     = require("models/list")
Task     = require("models/task")
ListItem = require("controllers/lists.item")
Keys     = require("utils/keys")
$        = Spine.$

class Lists extends Spine.Controller

  elements:
    "ul": "lists"
    "input": "input"
    ".list.all": "all"
    ".list.inbox": "inbox"
    ".list.completed": "completed"
    ".list.all .count": "allCount"
    ".list.inbox .count": "inboxCount"
    ".list.completed .count": "completedCount"

  events:
    "keyup input": "new"
    "click .title img": "searchToggle"
    "click .list.all": "showAllTasks"
    "click .list.inbox": "showInbox"
    "click .list.completed": "showCompleted"

  constructor: ->
    super
    List.bind "create", @addOne
    List.bind "refresh", @addAll
    List.bind "changeList", @change
    List.bind "destroy", @showInbox
    Task.bind "refresh change", @updateAll

    # Set up draggable on inbox
    @inbox.droppable
      hoverClass: "ui-state-active"
      tolerance: "pointer"
      drop: (event, ui) =>
        movedTask = Task.find(ui.draggable.attr("id").slice(5))
        List.current.moveTask(movedTask, List.find("inbox"))

  searchToggle: (e) ->
    $(".sidebar .searchToggle, .sidebar .normal").toggleClass("hide")

    if $(".sidebar .normal").hasClass("hide")
      $(".sidebar .title input").val("").focus()
    else
      $("header .search input").val("").trigger "keyup"

  new: (e) ->
    val = @input.val()

    # Handles correct box
    if $(e.currentTarget).hasClass("searcher")
      $("header .search input").val(val).trigger "keyup"

      # Overides the other function thingy
      if val.length is 0
        $(e.currentTarget).focus()
    else
      if e.which is Keys.ENTER and val
        list = List.create name: val
        List.trigger "changeList", list
        @input.val ""

  addOne: (list) =><commit_msg>fix new list creation<commit_after>Spine    = require("spine")
List     = require("models/list")
Task     = require("models/task")
ListItem = require("controllers/lists.item")
Keys     = require("utils/keys")
$        = Spine.$

class Lists extends Spine.Controller

  elements:
    "ul": "lists"
    "input": "input"
    ".list.all": "all"
    ".list.inbox": "inbox"
    ".list.completed": "completed"
    ".list.all .count": "allCount"
    ".list.inbox .count": "inboxCount"
    ".list.completed .count": "completedCount"

  events:
    "keyup input": "new"
    "click .title img": "searchToggle"
    "click .list.all": "showAllTasks"
    "click .list.inbox": "showInbox"
    "click .list.completed": "showCompleted"

  constructor: ->
    super
    List.bind "create", @addOne
    List.bind "refresh", @addAll
    List.bind "changeList", @change
    List.bind "destroy", @showInbox
    Task.bind "refresh change", @updateAll

    # Set up draggable on inbox
    @inbox.droppable
      hoverClass: "ui-state-active"
      tolerance: "pointer"
      drop: (event, ui) =>
        movedTask = Task.find(ui.draggable.attr("id").slice(5))
        List.current.moveTask(movedTask, List.find("inbox"))

  searchToggle: (e) ->
    $(".sidebar .searchToggle, .sidebar .normal").toggleClass("hide")

    if $(".sidebar .normal").hasClass("hide")
      $(".sidebar .title input").val("").focus()
    else
      $("header .search input").val("").trigger "keyup"

  new: (e) ->

    # Handles correct box
    if $(e.currentTarget).hasClass("searcher")
      $("header .search input").val($(e.currentTarget).val()).trigger "keyup"

      # Overides the other function thingy
      if val.length is 0
        $(e.currentTarget).focus()
    else
      if e.which is Keys.ENTER and $(e.currentTarget).val()
        console.log " helloo"
        list = List.create name: $(e.currentTarget).val()
        List.trigger "changeList", list
        $(e.currentTarget).val ""

  addOne: (list) =>
{'fraction_non_alphanumeric': 0.1689994815966822, 'fraction_numerical': 0.0010368066355624676, 'mean_word_length': 2.8245787908820614, 'pattern_counts': {'":': 26, '<': 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': '4525545', 'n_tokens_mistral': 1275, 'n_tokens_neox': 1244, 'n_words': 291}