admin.js.coffee 1.67 KB
Newer Older
1
class @Admin
2
  constructor: ->
3 4
    $('input#user_force_random_password').on 'change', (elem) ->
      elems = $('#user_password, #user_password_confirmation')
5

6 7 8 9
      if $(@).attr 'checked'
        elems.val('').attr 'disabled', true
      else
        elems.removeAttr 'disabled'
randx's avatar
randx committed
10

11 12
    $('body').on 'click', '.js-toggle-colors-link', (e) ->
      e.preventDefault()
13
      $('.js-toggle-colors-container').toggle()
14 15

    $('input#broadcast_message_color').on 'input', ->
16
      previewColor = $(@).val()
17 18 19
      $('div.broadcast-message-preview').css('background-color', previewColor)

    $('input#broadcast_message_font').on 'input', ->
20
      previewColor = $(@).val()
21 22 23
      $('div.broadcast-message-preview').css('color', previewColor)

    $('textarea#broadcast_message_message').on 'input', ->
24 25
      previewMessage = $(@).val()
      previewMessage = "Your message here" if previewMessage.trim() == ''
26 27
      $('div.broadcast-message-preview span').text(previewMessage)

28 29 30
    $('.log-tabs a').click (e) ->
      e.preventDefault()
      $(this).tab('show')
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
31

32 33
    $('.log-bottom').click (e) ->
      e.preventDefault()
34
      visible_log = $(".file-content:visible")
35 36 37 38
      visible_log.animate({ scrollTop: visible_log.find('ol').height() }, "fast")

    modal = $('.change-owner-holder')

39 40
    $('.change-owner-link').bind "click", (e) ->
      e.preventDefault()
41 42
      $(this).hide()
      modal.show()
43

44 45
    $('.change-owner-cancel-link').bind "click", (e) ->
      e.preventDefault()
46 47
      modal.hide()
      $('.change-owner-link').show()
48

49
    $('li.project_member').bind 'ajax:success', ->
50 51
      Turbolinks.visit(location.href)

52
    $('li.group_member').bind 'ajax:success', ->
53
      Turbolinks.visit(location.href)