project.js.coffee 1.39 KB
Newer Older
1 2
class Project
  constructor: ->
3 4
    $('.project-edit-container').on 'ajax:before', =>
      $('.project-edit-container').hide()
5 6
      $('.save-project-loader').show()

7 8
    @initEvents()

9

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

13 14 15 16 17 18 19 20 21 22 23 24 25 26
    $('#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')

27

28 29 30 31
@Project = Project

$ ->
  # Git clone panel switcher
32
  scope = $ '.git-clone-holder'
33 34 35 36 37
  if scope.length > 0
    $('a, button', scope).click ->
      $('a, button', scope).removeClass 'active'
      $(@).addClass 'active'
      $('#project_clone', scope).val $(@).data 'clone'
38
      $(".clone").text("").append $(@).data 'clone'
39 40 41 42

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

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