2014-03-24 10:12:23 -04:00
|
|
|
# This is a manifest file that'll be compiled into including all the files listed below.
|
|
|
|
# Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
|
|
|
# be included in the compiled file accessible from http://example.com/assets/application.js
|
|
|
|
# It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
|
|
# the compiled file.
|
|
|
|
#
|
|
|
|
#= require jquery
|
|
|
|
#= require jquery.ui.all
|
|
|
|
#= require jquery_ujs
|
|
|
|
#= require jquery.cookie
|
|
|
|
#= require jquery.endless-scroll
|
|
|
|
#= require jquery.highlight
|
|
|
|
#= require jquery.history
|
|
|
|
#= require jquery.waitforimages
|
|
|
|
#= require jquery.atwho
|
2014-05-22 11:19:50 -04:00
|
|
|
#= require jquery.scrollTo
|
2014-03-24 10:12:23 -04:00
|
|
|
#= require jquery.blockUI
|
|
|
|
#= require jquery.turbolinks
|
2014-09-26 04:17:26 -04:00
|
|
|
#= require turbolinks
|
2015-02-06 10:21:26 -05:00
|
|
|
#= require autosave
|
2014-03-24 10:12:23 -04:00
|
|
|
#= require bootstrap
|
|
|
|
#= require select2
|
|
|
|
#= require raphael
|
|
|
|
#= require g.raphael-min
|
|
|
|
#= require g.bar-min
|
2014-09-26 13:32:44 -04:00
|
|
|
#= require chart-lib.min
|
2014-03-24 10:12:23 -04:00
|
|
|
#= require branch-graph
|
|
|
|
#= require ace/ace
|
2014-08-28 04:08:02 -04:00
|
|
|
#= require ace/ext-searchbox
|
2014-03-24 10:12:23 -04:00
|
|
|
#= require d3
|
|
|
|
#= require underscore
|
|
|
|
#= require nprogress
|
|
|
|
#= require nprogress-turbolinks
|
2014-05-23 04:22:00 -04:00
|
|
|
#= require dropzone
|
2014-08-21 04:14:31 -04:00
|
|
|
#= require mousetrap
|
2014-09-11 12:19:49 -04:00
|
|
|
#= require mousetrap/pause
|
2014-08-21 04:14:31 -04:00
|
|
|
#= require shortcuts
|
|
|
|
#= require shortcuts_navigation
|
|
|
|
#= require shortcuts_dashboard_navigation
|
2015-04-18 15:20:15 -04:00
|
|
|
#= require shortcuts_issuable
|
2014-08-21 04:14:31 -04:00
|
|
|
#= require shortcuts_network
|
2015-01-28 16:18:22 -05:00
|
|
|
#= require cal-heatmap
|
2015-07-14 06:29:57 -04:00
|
|
|
#= require jquery.nicescroll.min
|
2014-03-24 10:12:23 -04:00
|
|
|
#= require_tree .
|
|
|
|
|
2012-09-09 05:59:15 -04:00
|
|
|
window.slugify = (text) ->
|
|
|
|
text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase()
|
|
|
|
|
|
|
|
window.ajaxGet = (url) ->
|
|
|
|
$.ajax({type: "GET", url: url, dataType: "script"})
|
|
|
|
|
2012-12-17 22:14:05 -05:00
|
|
|
window.split = (val) ->
|
|
|
|
return val.split( /,\s*/ )
|
|
|
|
|
|
|
|
window.extractLast = (term) ->
|
|
|
|
return split( term ).pop()
|
|
|
|
|
2014-08-11 14:15:12 -04:00
|
|
|
window.rstrip = (val) ->
|
2014-08-22 11:40:25 -04:00
|
|
|
return if val then val.replace(/\s+$/, '') else val
|
2014-08-11 14:15:12 -04:00
|
|
|
|
2012-10-10 09:41:20 -04:00
|
|
|
# Disable button if text field is empty
|
2012-09-09 05:59:15 -04:00
|
|
|
window.disableButtonIfEmptyField = (field_selector, button_selector) ->
|
|
|
|
field = $(field_selector)
|
2014-08-13 08:22:34 -04:00
|
|
|
closest_submit = field.closest('form').find(button_selector)
|
2012-09-09 05:59:15 -04:00
|
|
|
|
2014-08-11 14:15:12 -04:00
|
|
|
closest_submit.disable() if rstrip(field.val()) is ""
|
2012-09-09 05:59:15 -04:00
|
|
|
|
2014-08-13 08:22:34 -04:00
|
|
|
field.on 'input', ->
|
2014-08-11 14:15:12 -04:00
|
|
|
if rstrip($(@).val()) is ""
|
|
|
|
closest_submit.disable()
|
|
|
|
else
|
|
|
|
closest_submit.enable()
|
|
|
|
|
|
|
|
# Disable button if any input field with given selector is empty
|
2014-08-13 08:22:34 -04:00
|
|
|
window.disableButtonIfAnyEmptyField = (form, form_selector, button_selector) ->
|
2014-08-11 14:15:12 -04:00
|
|
|
closest_submit = form.find(button_selector)
|
2014-08-27 06:12:42 -04:00
|
|
|
updateButtons = ->
|
|
|
|
filled = true
|
2014-08-11 14:15:12 -04:00
|
|
|
form.find('input').filter(form_selector).each ->
|
2014-08-27 06:12:42 -04:00
|
|
|
filled = rstrip($(this).val()) != "" || !$(this).attr('required')
|
2014-08-11 14:15:12 -04:00
|
|
|
|
2014-08-27 06:12:42 -04:00
|
|
|
if filled
|
2012-09-09 07:08:13 -04:00
|
|
|
closest_submit.enable()
|
2014-08-27 06:12:42 -04:00
|
|
|
else
|
|
|
|
closest_submit.disable()
|
|
|
|
|
|
|
|
updateButtons()
|
|
|
|
form.keyup(updateButtons)
|
2012-09-09 05:59:15 -04:00
|
|
|
|
2013-03-19 09:54:58 -04:00
|
|
|
window.sanitize = (str) ->
|
|
|
|
return str.replace(/<(?:.|\n)*?>/gm, '')
|
|
|
|
|
2013-06-21 15:34:38 -04:00
|
|
|
window.unbindEvents = ->
|
|
|
|
$(document).off('scroll')
|
2013-05-28 11:59:01 -04:00
|
|
|
|
2015-01-14 22:39:10 -05:00
|
|
|
window.shiftWindow = ->
|
2015-08-29 04:59:04 -04:00
|
|
|
scrollBy 0, -100
|
2015-01-14 22:39:10 -05:00
|
|
|
|
2013-06-21 15:34:38 -04:00
|
|
|
document.addEventListener("page:fetch", unbindEvents)
|
2013-03-19 09:54:58 -04:00
|
|
|
|
2015-01-14 22:39:10 -05:00
|
|
|
window.addEventListener "hashchange", shiftWindow
|
|
|
|
|
2015-08-29 04:59:04 -04:00
|
|
|
window.onload = ->
|
|
|
|
# Scroll the window to avoid the topnav bar
|
|
|
|
# https://github.com/twitter/bootstrap/issues/1768
|
|
|
|
if location.hash
|
|
|
|
setTimeout shiftWindow, 100
|
|
|
|
|
2012-09-09 05:59:15 -04:00
|
|
|
$ ->
|
2015-07-14 06:29:57 -04:00
|
|
|
$(".nicescroll").niceScroll(cursoropacitymax: '0.4', cursorcolor: '#FFF', cursorborder: "1px solid #FFF")
|
|
|
|
|
2014-10-31 06:56:35 -04:00
|
|
|
# Click a .js-select-on-focus field, select the contents
|
2015-05-24 09:00:00 -04:00
|
|
|
$(".js-select-on-focus").on "focusin", ->
|
|
|
|
# Prevent a mouseup event from deselecting the input
|
|
|
|
$(this).select().one 'mouseup', (e) ->
|
|
|
|
e.preventDefault()
|
2012-09-09 05:59:15 -04:00
|
|
|
|
2013-07-16 15:19:07 -04:00
|
|
|
$('.remove-row').bind 'ajax:success', ->
|
|
|
|
$(this).closest('li').fadeOut()
|
|
|
|
|
2015-08-25 04:52:10 -04:00
|
|
|
$('.js-remove-tr').bind 'ajax:before', ->
|
|
|
|
$(this).hide()
|
|
|
|
|
|
|
|
$('.js-remove-tr').bind 'ajax:success', ->
|
|
|
|
$(this).closest('tr').fadeOut()
|
|
|
|
|
2014-01-11 05:11:54 -05:00
|
|
|
# Initialize select2 selects
|
2014-01-11 05:36:10 -05:00
|
|
|
$('select.select2').select2(width: 'resolve', dropdownAutoWidth: true)
|
2012-09-10 02:09:55 -04:00
|
|
|
|
2014-08-21 04:14:31 -04:00
|
|
|
# Close select2 on escape
|
|
|
|
$('.js-select2').bind 'select2-close', ->
|
|
|
|
setTimeout ( ->
|
|
|
|
$('.select2-container-active').removeClass('select2-container-active')
|
|
|
|
$(':focus').blur()
|
|
|
|
), 1
|
|
|
|
|
2012-11-05 13:12:26 -05:00
|
|
|
# Initialize tooltips
|
2015-12-02 08:05:10 -05:00
|
|
|
$('body').tooltip(
|
|
|
|
selector: '.has_tooltip, [data-toggle="tooltip"]'
|
2015-04-25 16:03:18 -04:00
|
|
|
placement: (_, el) ->
|
|
|
|
$el = $(el)
|
2015-12-02 08:05:10 -05:00
|
|
|
$el.data('placement') || 'bottom'
|
|
|
|
)
|
|
|
|
|
|
|
|
$('.header-logo .home').tooltip(
|
|
|
|
placement: (_, el) ->
|
|
|
|
$el = $(el)
|
|
|
|
if $('.page-with-sidebar').hasClass('page-sidebar-collapsed') then 'right' else 'bottom'
|
|
|
|
container: 'body'
|
|
|
|
)
|
|
|
|
|
|
|
|
$('.page-with-sidebar').tooltip(
|
|
|
|
selector: '.sidebar-collapsed .nav-sidebar a, .sidebar-collapsed a.sidebar-user'
|
|
|
|
placement: 'right'
|
|
|
|
container: 'body'
|
|
|
|
)
|
2012-11-21 00:14:05 -05:00
|
|
|
|
2013-02-18 09:40:11 -05:00
|
|
|
# Form submitter
|
|
|
|
$('.trigger-submit').on 'change', ->
|
|
|
|
$(@).parents('form').submit()
|
|
|
|
|
2015-06-17 15:52:46 -04:00
|
|
|
$('abbr.timeago, .js-timeago').timeago()
|
2013-03-19 08:39:32 -04:00
|
|
|
|
2012-11-29 16:51:51 -05:00
|
|
|
# Flash
|
2013-02-28 04:06:52 -05:00
|
|
|
if (flash = $(".flash-container")).length > 0
|
|
|
|
flash.click -> $(@).fadeOut()
|
|
|
|
flash.show()
|
2012-11-21 00:14:05 -05:00
|
|
|
|
2012-09-09 07:08:13 -04:00
|
|
|
# Disable form buttons while a form is submitting
|
2012-09-09 05:59:15 -04:00
|
|
|
$('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) ->
|
2012-10-10 09:41:20 -04:00
|
|
|
buttons = $('[type="submit"]', @)
|
2012-09-09 05:59:15 -04:00
|
|
|
|
|
|
|
switch e.type
|
|
|
|
when 'ajax:beforeSend', 'submit'
|
2012-09-09 07:08:13 -04:00
|
|
|
buttons.disable()
|
2012-09-09 05:59:15 -04:00
|
|
|
else
|
2012-09-09 07:08:13 -04:00
|
|
|
buttons.enable()
|
2012-09-09 05:59:15 -04:00
|
|
|
|
|
|
|
# Show/Hide the profile menu when hovering the account box
|
2012-10-10 09:41:20 -04:00
|
|
|
$('.account-box').hover -> $(@).toggleClass('hover')
|
2012-09-09 05:59:15 -04:00
|
|
|
|
|
|
|
# Commit show suppressed diff
|
2015-07-23 15:55:49 -04:00
|
|
|
$(document).on 'click', '.diff-content .js-show-suppressed-diff', ->
|
|
|
|
$container = $(@).parent()
|
|
|
|
$container.next('table').show()
|
|
|
|
$container.remove()
|
2012-09-09 05:59:15 -04:00
|
|
|
|
2015-06-01 11:55:20 -04:00
|
|
|
$('.navbar-toggle').on 'click', ->
|
|
|
|
$('.header-content .title').toggle()
|
|
|
|
$('.header-content .navbar-collapse').toggle()
|
2015-10-08 23:05:55 -04:00
|
|
|
$('.navbar-toggle').toggleClass('active')
|
2015-06-01 11:55:20 -04:00
|
|
|
|
2014-06-25 04:40:33 -04:00
|
|
|
# Show/hide comments on diff
|
|
|
|
$("body").on "click", ".js-toggle-diff-comments", (e) ->
|
2015-03-18 20:53:43 -04:00
|
|
|
$(@).toggleClass('active')
|
2014-06-25 04:40:33 -04:00
|
|
|
$(@).closest(".diff-file").find(".notes_holder").toggle()
|
|
|
|
e.preventDefault()
|
|
|
|
|
2015-04-20 14:05:51 -04:00
|
|
|
$(document).off "click", '.js-confirm-danger'
|
2014-10-08 06:57:54 -04:00
|
|
|
$(document).on "click", '.js-confirm-danger', (e) ->
|
|
|
|
e.preventDefault()
|
|
|
|
btn = $(e.target)
|
|
|
|
text = btn.data("confirm-danger-message")
|
|
|
|
form = btn.closest("form")
|
|
|
|
new ConfirmDangerModal(form, text)
|
|
|
|
|
2015-02-22 01:01:27 -05:00
|
|
|
new Aside()
|