BigW Consortium Gitlab

issuable_context.js.coffee 1.7 KB
Newer Older
1
class @IssuableContext
Jacob Schatz committed
2
  constructor: (currentUser) ->
3
    @initParticipants()
4
    new UsersSelect(currentUser)
5 6
    $('select.select2').select2({width: 'resolve', dropdownAutoWidth: true})

7
    $(".issuable-sidebar .inline-update").on "change", "select", ->
8
      $(this).submit()
9
    $(".issuable-sidebar .inline-update").on "change", ".js-assignee", ->
10 11
      $(this).submit()

12
    $(document)
13 14
      .off 'click', '.issuable-sidebar .dropdown-content a'
      .on 'click', '.issuable-sidebar .dropdown-content a', (e) ->
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
        e.preventDefault()

    $(document)
      .off 'click', '.edit-link'
      .on 'click', '.edit-link', (e) ->
        e.preventDefault()

        $block = $(@).parents('.block')
        $selectbox = $block.find('.selectbox')
        if $selectbox.is(':visible')
          $selectbox.hide()
          $block.find('.value').show()
        else
          $selectbox.show()
          $block.find('.value').hide()

        if $selectbox.is(':visible')
          setTimeout ->
            $block.find('.dropdown-menu-toggle').trigger 'click'
          , 0

36
    $(".right-sidebar").niceScroll()
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60

  initParticipants: ->
    _this = @
    $(document).on "click", ".js-participants-more", @toggleHiddenParticipants

    $(".js-participants-author").each (i) ->
      if i >= _this.PARTICIPANTS_ROW_COUNT
        $(@)
          .addClass "js-participants-hidden"
          .hide()

  toggleHiddenParticipants: (e) ->
    e.preventDefault()

    currentText = $(this).text().trim()
    lessText = $(this).data("less-text")
    originalText = $(this).data("original-text")

    if currentText is originalText
      $(this).text(lessText)
    else
      $(this).text(originalText)

    $(".js-participants-hidden").toggle()