BigW Consortium Gitlab

project.js.coffee 1.58 KB
Newer Older
1
class @Project
2
  constructor: ->
3
    # Git clone panel switcher
4 5
    cloneHolder = $('.git-clone-holder')
    if cloneHolder.length
6 7
      $('a, button', cloneHolder).click ->
        $('a, button', cloneHolder).removeClass 'active'
8
        $(@).addClass 'active'
9
        $('#project_clone', cloneHolder).val $(@).data 'clone'
10 11 12 13 14 15 16 17 18
        $(".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 })
19 20 21 22 23 24 25
      $(@).parents('.no-ssh-key-message').remove()
      e.preventDefault()

    $('.hide-no-password-message').on 'click', (e) ->
      path = '/'
      $.cookie('hide_no_password_message', 'false', { path: path })
      $(@).parents('.no-password-message').remove()
26
      e.preventDefault()
27 28 29

    $('.update-notification').on 'click', (e) ->
      e.preventDefault()
30 31
      notification_level = $(@).data 'notification-level'
      $('#notification_level').val(notification_level)
32
      $('#notification-form').submit()
33 34 35 36 37 38 39 40
      label = null
      switch notification_level
        when 0 then label = ' Disabled '
        when 1 then label = ' Participating '
        when 2 then label = ' Watching '
        when 3 then label = ' Global '
        when 4 then label = ' On Mention '
      $('#notifications-button').empty().append("<i class='fa fa-bell'></i>" + label + "<i class='fa fa-angle-down'></i>")
41 42
      $(@).parents('ul').find('li.active').removeClass 'active'
      $(@).parent().addClass 'active'