summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/project.js.coffee
blob: aba40742e5f0c6d0d07f2a0017997fce1d687c4c (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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
class @Project
  constructor: ->
    $('.project-edit-container').on 'ajax:before', =>
      $('.project-edit-container').hide()
      $('.save-project-loader').show()

    @initEvents()


  initEvents: ->
    disableButtonIfEmptyField '#project_name', '.project-submit'

    $('#project_issues_enabled').change ->
      if ($(this).is(':checked') == true)
        $('#project_issues_tracker').removeAttr('disabled')
      else
        $('#project_issues_tracker').attr('disabled', 'disabled')

      $('#project_issues_tracker').change()

    $('#project_issues_tracker').change ->
      if ($(this).val() == gon.default_issues_tracker || $(this).is(':disabled'))
        $('#project_issues_tracker_id').attr('disabled', 'disabled')
      else
        $('#project_issues_tracker_id').removeAttr('disabled')

$ ->
  # Git clone panel switcher
  scope = $ '.git-clone-holder'
  if scope.length > 0
    $('a, button', scope).click ->
      $('a, button', scope).removeClass 'active'
      $(@).addClass 'active'
      $('#project_clone', scope).val $(@).data 'clone'
      $(".clone").text("").append $(@).data 'clone'

  # Ref switcher
  $('.project-refs-select').on 'change', ->
    $(@).parents('form').submit()

  $('.hide-no-ssh-message').on 'click', (e) ->
    path = '/'
    $.cookie('hide_no_ssh_message', 'false', { path: path })
    $(@).parents('.no-ssh-key-message').hide()
    e.preventDefault()

  $('.project-home-panel .star').on 'ajax:success', (e, data, status, xhr) ->
    $(@).toggleClass('on').find('.count').html(data.star_count)
  .on 'ajax:error', (e, xhr, status, error) ->
    new Flash('Star toggle failed. Try again later.', 'alert')

  $("a[data-toggle='tab']").on "shown.bs.tab", (e) ->
      $.cookie "default_view", $(e.target).attr("href")

    defaultView = $.cookie("default_view")
    if defaultView
      $("a[href=" + defaultView + "]").tab "show"
    else
      $("a[data-toggle='tab']:first").tab "show"