BigW Consortium Gitlab

datetime_utility.js.coffee 630 Bytes
Newer Older
1 2 3 4 5 6 7 8
((w) ->

  w.gl ?= {}
  w.gl.utils ?= {}

  w.gl.utils.formatDate = (datetime) ->
    dateFormat(datetime, 'mmm d, yyyy h:MMtt Z')

9
  w.gl.utils.localTimeAgo = ($timeagoEls, setTimeago = true) ->
10 11 12 13 14
    $timeagoEls.each( ->
          $el = $(@)
          $el.attr('title', gl.utils.formatDate($el.attr('datetime')))
    )

15 16 17 18 19 20 21 22
    if setTimeago
      $timeagoEls.timeago()
      $timeagoEls.tooltip('destroy')

      # Recreate with custom template
      $timeagoEls.tooltip(
        template: '<div class="tooltip local-timeago" role="tooltip"><div class="tooltip-arrow"></div><div class="tooltip-inner"></div></div>'
      )
23

24
) window