summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/issuable_form.js.coffee
blob: 48c249943f2d25489d5bfd916a012fa98d496bd1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class @IssuableForm
  constructor: (@form) ->
    GitLab.GfmAutoComplete.setup()
    new UsersSelect()
    new ZenMode()

    @titleField       = @form.find("input[name*='[title]']")
    @descriptionField = @form.find("textarea[name*='[description]']")

    return unless @titleField.length && @descriptionField.length

    @initAutosave()

    @form.on "submit", @resetAutosave
    @form.on "click", ".btn-cancel", @resetAutosave

  initAutosave: ->
    new Autosave @titleField, [
      document.location.pathname,
      document.location.search,
      "title"
    ]

    new Autosave @descriptionField, [
      document.location.pathname,
      document.location.search,
      "description"
    ]

  resetAutosave: =>
    @titleField.data("autosave").reset()
    @descriptionField.data("autosave").reset()