2016-06-16 23:09:34 +05:30
|
|
|
((w) ->
|
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
w.gl or= {}
|
|
|
|
w.gl.utils or= {}
|
2016-06-16 23:09:34 +05:30
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
w.gl.utils.isInGroupsPage = ->
|
2016-06-16 23:09:34 +05:30
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
return gl.utils.getPagePath() is 'groups'
|
2016-06-16 23:09:34 +05:30
|
|
|
|
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
w.gl.utils.isInProjectPage = ->
|
2016-06-16 23:09:34 +05:30
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
return gl.utils.getPagePath() is 'projects'
|
2016-06-16 23:09:34 +05:30
|
|
|
|
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
w.gl.utils.getProjectSlug = ->
|
2016-06-16 23:09:34 +05:30
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
return if @isInProjectPage() then $('body').data 'project' else null
|
|
|
|
|
|
|
|
|
|
|
|
w.gl.utils.getGroupSlug = ->
|
|
|
|
|
|
|
|
return if @isInGroupsPage() then $('body').data 'group' else null
|
2016-06-16 23:09:34 +05:30
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gl.utils.updateTooltipTitle = ($tooltipEl, newTitle) ->
|
|
|
|
|
|
|
|
$tooltipEl
|
|
|
|
.tooltip 'destroy'
|
|
|
|
.attr 'title', newTitle
|
|
|
|
.tooltip 'fixTitle'
|
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
|
2016-06-16 23:09:34 +05:30
|
|
|
gl.utils.preventDisabledButtons = ->
|
|
|
|
|
|
|
|
$('.btn').click (e) ->
|
|
|
|
if $(this).hasClass 'disabled'
|
|
|
|
e.preventDefault()
|
|
|
|
e.stopImmediatePropagation()
|
|
|
|
return false
|
|
|
|
|
2016-08-24 12:49:21 +05:30
|
|
|
gl.utils.getPagePath = ->
|
|
|
|
return $('body').data('page').split(':')[0]
|
|
|
|
|
2016-06-22 15:30:34 +05:30
|
|
|
|
|
|
|
jQuery.timefor = (time, suffix, expiredLabel) ->
|
|
|
|
|
|
|
|
return '' unless time
|
|
|
|
|
|
|
|
suffix or= 'remaining'
|
|
|
|
expiredLabel or= 'Past due'
|
|
|
|
|
|
|
|
jQuery.timeago.settings.allowFuture = yes
|
|
|
|
|
|
|
|
{ suffixFromNow } = jQuery.timeago.settings.strings
|
|
|
|
jQuery.timeago.settings.strings.suffixFromNow = suffix
|
|
|
|
|
|
|
|
timefor = $.timeago time
|
|
|
|
|
|
|
|
if timefor.indexOf('ago') > -1
|
|
|
|
timefor = expiredLabel
|
|
|
|
|
|
|
|
jQuery.timeago.settings.strings.suffixFromNow = suffixFromNow
|
|
|
|
|
|
|
|
return timefor
|
|
|
|
|
2016-06-16 23:09:34 +05:30
|
|
|
) window
|