2014-03-24 14:12:23 +00: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 15:19:50 +00:00
|
|
|
#= require jquery.scrollTo
|
2014-03-24 14:12:23 +00:00
|
|
|
#= require jquery.blockUI
|
|
|
|
#= require jquery.turbolinks
|
2014-09-26 08:17:26 +00:00
|
|
|
#= require turbolinks
|
2014-03-24 14:12:23 +00:00
|
|
|
#= require bootstrap
|
|
|
|
#= require select2
|
|
|
|
#= require raphael
|
|
|
|
#= require g.raphael-min
|
|
|
|
#= require g.bar-min
|
2014-09-26 17:32:44 +00:00
|
|
|
#= require chart-lib.min
|
2014-03-24 14:12:23 +00:00
|
|
|
#= require branch-graph
|
2014-07-09 06:47:06 +00:00
|
|
|
#= require highlight.pack
|
2014-03-24 14:12:23 +00:00
|
|
|
#= require ace/ace
|
2014-08-28 08:08:02 +00:00
|
|
|
#= require ace/ext-searchbox
|
2014-03-24 14:12:23 +00:00
|
|
|
#= require d3
|
|
|
|
#= require underscore
|
|
|
|
#= require nprogress
|
|
|
|
#= require nprogress-turbolinks
|
2014-05-23 08:22:00 +00:00
|
|
|
#= require dropzone
|
2014-06-14 09:17:11 +00:00
|
|
|
#= require semantic-ui/sidebar
|
2014-08-21 08:14:31 +00:00
|
|
|
#= require mousetrap
|
2014-09-11 16:19:49 +00:00
|
|
|
#= require mousetrap/pause
|
2014-08-21 08:14:31 +00:00
|
|
|
#= require shortcuts
|
|
|
|
#= require shortcuts_navigation
|
|
|
|
#= require shortcuts_dashboard_navigation
|
|
|
|
#= require shortcuts_issueable
|
|
|
|
#= require shortcuts_network
|
2014-03-24 14:12:23 +00:00
|
|
|
#= require_tree .
|
|
|
|
|
2012-09-09 09:59:15 +00:00
|
|
|
window.slugify = (text) ->
|
|
|
|
text.replace(/[^-a-zA-Z0-9]+/g, '_').toLowerCase()
|
|
|
|
|
|
|
|
window.ajaxGet = (url) ->
|
|
|
|
$.ajax({type: "GET", url: url, dataType: "script"})
|
|
|
|
|
2013-03-27 18:07:52 +00:00
|
|
|
window.showAndHide = (selector) ->
|
|
|
|
|
2012-12-13 16:42:15 +00:00
|
|
|
window.errorMessage = (message) ->
|
|
|
|
ehtml = $("<p>")
|
|
|
|
ehtml.addClass("error_message")
|
|
|
|
ehtml.html(message)
|
|
|
|
ehtml
|
|
|
|
|
2012-12-18 03:14:05 +00:00
|
|
|
window.split = (val) ->
|
|
|
|
return val.split( /,\s*/ )
|
|
|
|
|
|
|
|
window.extractLast = (term) ->
|
|
|
|
return split( term ).pop()
|
|
|
|
|
2014-08-11 18:15:12 +00:00
|
|
|
window.rstrip = (val) ->
|
|
|
|
return val.replace(/\s+$/, '')
|
|
|
|
|
2012-10-10 13:41:20 +00:00
|
|
|
# Disable button if text field is empty
|
2012-09-09 09:59:15 +00:00
|
|
|
window.disableButtonIfEmptyField = (field_selector, button_selector) ->
|
|
|
|
field = $(field_selector)
|
2014-08-13 12:22:34 +00:00
|
|
|
closest_submit = field.closest('form').find(button_selector)
|
2012-09-09 09:59:15 +00:00
|
|
|
|
2014-08-11 18:15:12 +00:00
|
|
|
closest_submit.disable() if rstrip(field.val()) is ""
|
2012-09-09 09:59:15 +00:00
|
|
|
|
2014-08-13 12:22:34 +00:00
|
|
|
field.on 'input', ->
|
2014-08-11 18:15:12 +00: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 12:22:34 +00:00
|
|
|
window.disableButtonIfAnyEmptyField = (form, form_selector, button_selector) ->
|
2014-08-11 18:15:12 +00:00
|
|
|
closest_submit = form.find(button_selector)
|
|
|
|
empty = false
|
|
|
|
form.find('input').filter(form_selector).each ->
|
|
|
|
empty = true if rstrip($(this).val()) is ""
|
|
|
|
|
|
|
|
if empty
|
|
|
|
closest_submit.disable()
|
|
|
|
else
|
|
|
|
closest_submit.enable()
|
|
|
|
|
|
|
|
form.keyup ->
|
|
|
|
empty = false
|
|
|
|
form.find('input').filter(form_selector).each ->
|
|
|
|
empty = true if rstrip($(this).val()) is ""
|
|
|
|
|
|
|
|
if empty
|
2012-09-09 11:08:13 +00:00
|
|
|
closest_submit.disable()
|
2012-09-09 09:59:15 +00:00
|
|
|
else
|
2012-09-09 11:08:13 +00:00
|
|
|
closest_submit.enable()
|
2012-09-09 09:59:15 +00:00
|
|
|
|
2013-03-19 13:54:58 +00:00
|
|
|
window.sanitize = (str) ->
|
|
|
|
return str.replace(/<(?:.|\n)*?>/gm, '')
|
|
|
|
|
|
|
|
window.linkify = (str) ->
|
|
|
|
exp = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig
|
|
|
|
return str.replace(exp,"<a href='$1'>$1</a>")
|
|
|
|
|
2013-05-24 06:49:49 +00:00
|
|
|
window.simpleFormat = (str) ->
|
|
|
|
linkify(sanitize(str).replace(/\n/g, '<br />'))
|
|
|
|
|
2013-06-21 19:34:38 +00:00
|
|
|
window.unbindEvents = ->
|
2013-05-28 15:59:01 +00:00
|
|
|
$(document).unbind('scroll')
|
2013-06-21 19:34:38 +00:00
|
|
|
$(document).off('scroll')
|
2013-05-28 15:59:01 +00:00
|
|
|
|
2013-06-21 19:34:38 +00:00
|
|
|
document.addEventListener("page:fetch", unbindEvents)
|
2013-03-19 13:54:58 +00:00
|
|
|
|
2012-09-09 09:59:15 +00:00
|
|
|
$ ->
|
2012-09-09 11:17:01 +00:00
|
|
|
# Click a .one_click_select field, select the contents
|
2012-10-10 13:41:20 +00:00
|
|
|
$(".one_click_select").on 'click', -> $(@).select()
|
2012-09-09 09:59:15 +00:00
|
|
|
|
2013-07-16 19:19:07 +00:00
|
|
|
$('.remove-row').bind 'ajax:success', ->
|
|
|
|
$(this).closest('li').fadeOut()
|
|
|
|
|
2014-01-11 10:11:54 +00:00
|
|
|
# Initialize select2 selects
|
2014-01-11 10:36:10 +00:00
|
|
|
$('select.select2').select2(width: 'resolve', dropdownAutoWidth: true)
|
2012-09-10 06:09:55 +00:00
|
|
|
|
2014-08-21 08:14:31 +00:00
|
|
|
# Close select2 on escape
|
|
|
|
$('.js-select2').bind 'select2-close', ->
|
|
|
|
setTimeout ( ->
|
|
|
|
$('.select2-container-active').removeClass('select2-container-active')
|
|
|
|
$(':focus').blur()
|
|
|
|
), 1
|
|
|
|
|
2012-11-05 18:12:26 +00:00
|
|
|
# Initialize tooltips
|
|
|
|
$('.has_tooltip').tooltip()
|
|
|
|
|
2012-11-21 05:14:05 +00:00
|
|
|
# Bottom tooltip
|
|
|
|
$('.has_bottom_tooltip').tooltip(placement: 'bottom')
|
|
|
|
|
2013-02-18 14:40:11 +00:00
|
|
|
# Form submitter
|
|
|
|
$('.trigger-submit').on 'change', ->
|
|
|
|
$(@).parents('form').submit()
|
|
|
|
|
2013-03-19 12:39:32 +00:00
|
|
|
$("abbr.timeago").timeago()
|
2013-12-30 12:38:42 +00:00
|
|
|
$('.js-timeago').timeago()
|
2013-03-19 12:39:32 +00:00
|
|
|
|
2012-11-29 21:51:51 +00:00
|
|
|
# Flash
|
2013-02-28 09:06:52 +00:00
|
|
|
if (flash = $(".flash-container")).length > 0
|
|
|
|
flash.click -> $(@).fadeOut()
|
|
|
|
flash.show()
|
2012-11-21 05:14:05 +00:00
|
|
|
|
2012-09-09 11:08:13 +00:00
|
|
|
# Disable form buttons while a form is submitting
|
2012-09-09 09:59:15 +00:00
|
|
|
$('body').on 'ajax:complete, ajax:beforeSend, submit', 'form', (e) ->
|
2012-10-10 13:41:20 +00:00
|
|
|
buttons = $('[type="submit"]', @)
|
2012-09-09 09:59:15 +00:00
|
|
|
|
|
|
|
switch e.type
|
|
|
|
when 'ajax:beforeSend', 'submit'
|
2012-09-09 11:08:13 +00:00
|
|
|
buttons.disable()
|
2012-09-09 09:59:15 +00:00
|
|
|
else
|
2012-09-09 11:08:13 +00:00
|
|
|
buttons.enable()
|
2012-09-09 09:59:15 +00:00
|
|
|
|
|
|
|
# Show/Hide the profile menu when hovering the account box
|
2012-10-10 13:41:20 +00:00
|
|
|
$('.account-box').hover -> $(@).toggleClass('hover')
|
2012-09-09 09:59:15 +00:00
|
|
|
|
|
|
|
# Commit show suppressed diff
|
2014-02-24 07:43:45 +00:00
|
|
|
$(".diff-content").on "click", ".supp_diff_link", ->
|
2012-10-10 13:41:20 +00:00
|
|
|
$(@).next('table').show()
|
|
|
|
$(@).remove()
|
2012-09-09 09:59:15 +00:00
|
|
|
|
2014-06-25 08:40:33 +00:00
|
|
|
# Show/hide comments on diff
|
|
|
|
$("body").on "click", ".js-toggle-diff-comments", (e) ->
|
|
|
|
$(@).find('i').
|
2014-10-01 22:21:29 +00:00
|
|
|
toggleClass('fa fa-chevron-down').
|
|
|
|
toggleClass('fa fa-chevron-up')
|
2014-06-25 08:40:33 +00:00
|
|
|
$(@).closest(".diff-file").find(".notes_holder").toggle()
|
|
|
|
e.preventDefault()
|
|
|
|
|
2012-09-09 09:59:15 +00:00
|
|
|
(($) ->
|
2012-09-09 11:08:13 +00:00
|
|
|
# Disable an element and add the 'disabled' Bootstrap class
|
|
|
|
$.fn.extend disable: ->
|
2012-10-10 13:41:20 +00:00
|
|
|
$(@).attr('disabled', 'disabled').addClass('disabled')
|
2012-09-09 11:08:13 +00:00
|
|
|
|
|
|
|
# Enable an element and remove the 'disabled' Bootstrap class
|
|
|
|
$.fn.extend enable: ->
|
2012-10-10 13:41:20 +00:00
|
|
|
$(@).removeAttr('disabled').removeClass('disabled')
|
2012-09-09 11:08:13 +00:00
|
|
|
|
2012-09-09 09:59:15 +00:00
|
|
|
)(jQuery)
|