2014-10-20 16:48:07 -04:00
|
|
|
class @Project
|
2013-05-02 07:36:53 -04:00
|
|
|
constructor: ->
|
2015-11-24 20:38:36 -05:00
|
|
|
# Git protocol switcher
|
2015-12-23 19:57:30 -05:00
|
|
|
$('ul.clone-options-dropdown a').click ->
|
2015-11-24 20:38:36 -05:00
|
|
|
return if $(@).hasClass('active')
|
|
|
|
|
2015-12-08 05:01:24 -05:00
|
|
|
|
|
|
|
# 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')
|
2015-11-24 20:38:36 -05:00
|
|
|
|
2015-12-23 19:57:30 -05:00
|
|
|
url = $("#project_clone").val()
|
2015-11-24 20:38:36 -05:00
|
|
|
|
|
|
|
# Update the input field
|
|
|
|
$('#project_clone').val(url)
|
|
|
|
|
|
|
|
# Update the command line instructions
|
|
|
|
$('.clone').text(url)
|
2014-10-21 16:39:34 -04:00
|
|
|
|
|
|
|
# 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 })
|
2015-02-13 07:33:28 -05:00
|
|
|
$(@).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()
|
2014-10-21 16:39:34 -04:00
|
|
|
e.preventDefault()
|
2015-09-14 20:27:54 -04:00
|
|
|
|
|
|
|
$('.update-notification').on 'click', (e) ->
|
|
|
|
e.preventDefault()
|
2015-09-16 20:46:24 -04:00
|
|
|
notification_level = $(@).data 'notification-level'
|
2016-03-28 12:17:42 -04:00
|
|
|
label = $(@).data 'notification-title'
|
2016-03-29 11:42:38 -04:00
|
|
|
$('#notification_setting_level').val(notification_level)
|
2015-09-14 21:33:24 -04:00
|
|
|
$('#notification-form').submit()
|
2015-09-16 20:46:24 -04:00
|
|
|
$('#notifications-button').empty().append("<i class='fa fa-bell'></i>" + label + "<i class='fa fa-angle-down'></i>")
|
2015-09-14 21:50:13 -04:00
|
|
|
$(@).parents('ul').find('li.active').removeClass 'active'
|
2015-11-24 19:32:06 -05:00
|
|
|
$(@).parent().addClass 'active'
|
2016-01-15 04:13:12 -05:00
|
|
|
|
2016-03-29 11:42:38 -04:00
|
|
|
$('#notification-form').on 'ajax:success', (e, data) ->
|
|
|
|
if data.saved
|
|
|
|
new Flash("Notification settings saved", "notice")
|
|
|
|
else
|
|
|
|
new Flash("Failed to save new settings", "alert")
|
|
|
|
|
|
|
|
|
2016-01-17 09:54:28 -05:00
|
|
|
@projectSelectDropdown()
|
2016-01-15 04:13:12 -05:00
|
|
|
|
2016-01-17 09:54:28 -05:00
|
|
|
projectSelectDropdown: ->
|
2016-01-15 04:13:12 -05:00
|
|
|
new ProjectSelect()
|
|
|
|
|
2016-01-17 12:19:50 -05:00
|
|
|
$('.project-item-select').on 'click', (e) =>
|
|
|
|
@changeProject $(e.currentTarget).val()
|
2016-01-15 04:17:09 -05:00
|
|
|
|
2016-01-15 04:13:12 -05:00
|
|
|
$('.js-projects-dropdown-toggle').on 'click', (e) ->
|
|
|
|
e.preventDefault()
|
|
|
|
|
2016-01-17 12:19:50 -05:00
|
|
|
$('.js-projects-dropdown').select2('open')
|
|
|
|
|
|
|
|
changeProject: (url) ->
|
|
|
|
window.location = url
|