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 turbolinks
|
|
|
|
#= require jquery.turbolinks
|
|
|
|
#= require bootstrap
|
|
|
|
#= require select2
|
|
|
|
#= require raphael
|
|
|
|
#= require g.raphael-min
|
|
|
|
#= require g.bar-min
|
|
|
|
#= require branch-graph
|
|
|
|
#= require highlightjs.min
|
|
|
|
#= require ace/ace
|
|
|
|
#= 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-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()
|
|
|
|
|
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)
|
|
|
|
closest_submit = field.closest("form").find(button_selector)
|
|
|
|
|
2012-09-09 11:08:13 +00:00
|
|
|
closest_submit.disable() if field.val() is ""
|
2012-09-09 09:59:15 +00:00
|
|
|
|
2012-10-27 15:00:51 +00:00
|
|
|
field.on "input", ->
|
2012-10-10 13:41:20 +00:00
|
|
|
if $(@).val() is ""
|
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
|
|
|
|
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()
|
2013-08-17 14:36:44 +00:00
|
|
|
setTimeout (-> flash.fadeOut()), 5000
|
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
|
|
|
|
|
|
|
# Focus search field by pressing 's' key
|
|
|
|
$(document).keypress (e) ->
|
|
|
|
# Don't do anything if typing in an input
|
|
|
|
return if $(e.target).is(":input")
|
|
|
|
|
|
|
|
switch e.which
|
|
|
|
when 115
|
|
|
|
$("#search").focus()
|
|
|
|
e.preventDefault()
|
2013-07-05 12:19:31 +00:00
|
|
|
when 63
|
|
|
|
new Shortcuts()
|
|
|
|
e.preventDefault()
|
|
|
|
|
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
|
|
|
|
|
|
|
(($) ->
|
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)
|