project.js.coffee 2.1 KB
Newer Older
C
Ciro Santilli 已提交
1
class @Project
2
  constructor: ->
3
    # Git protocol switcher
4
    $('ul.clone-options-dropdown a').click ->
5 6
      return if $(@).hasClass('active')

B
Borja Aparicio 已提交
7 8 9 10 11

      # Remove the active class for all buttons (ssh, http, kerberos if shown)
      $('.active').not($(@)).removeClass('active');
      # Add the active class for the clicked button
      $(@).toggleClass('active')
12

13 14
      url = $("#project_clone").val()
      console.log("url",url)
15 16 17 18 19 20

      # Update the input field
      $('#project_clone').val(url)

      # Update the command line instructions
      $('.clone').text(url)
21 22 23 24 25 26 27 28

    # 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 })
29 30 31 32 33 34 35
      $(@).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()
36
      e.preventDefault()
37 38 39

    $('.update-notification').on 'click', (e) ->
      e.preventDefault()
40 41
      notification_level = $(@).data 'notification-level'
      $('#notification_level').val(notification_level)
42
      $('#notification-form').submit()
43 44 45 46 47 48 49 50
      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>")
51
      $(@).parents('ul').find('li.active').removeClass 'active'
52
      $(@).parent().addClass 'active'
P
Phil Hughes 已提交
53

P
Phil Hughes 已提交
54
    @projectSelectDropdown()
P
Phil Hughes 已提交
55

P
Phil Hughes 已提交
56
  projectSelectDropdown: ->
P
Phil Hughes 已提交
57 58
    new ProjectSelect()

P
Phil Hughes 已提交
59 60
    $('.project-item-select').on 'click', (e) =>
      @changeProject $(e.currentTarget).val()
61

P
Phil Hughes 已提交
62 63 64
    $('.js-projects-dropdown-toggle').on 'click', (e) ->
      e.preventDefault()

P
Phil Hughes 已提交
65 66 67 68
      $('.js-projects-dropdown').select2('open')

  changeProject: (url) ->
    window.location = url