Sha256: b56482e3e34601614524ee5c372b93be465bcbe8b4a3d08a1374cd175b358f07

Contents?: true

Size: 666 Bytes

Versions: 2

Compression:

Stored size: 666 Bytes

Contents

#= require moment

$.fn.extend
  moment_ago: ->
    for dom in @
      $dom = $(dom)
      continue unless $dom.data("time")?
      m = _.min([moment(), moment($dom.data("time"))])
      title_format = $dom.data("title-format") || 'llll'
      title_text = m.format(title_format)
      $dom.attr(title: title_text)

      body_text = m.fromNow();
      if $dom.data("display-date")
        body_text += " (#{title_text})"
      $dom.html(body_text)
    return @

$.moment_ago = (time) ->
  $("<span class='moment_ago', data-time='#{time}'></span>").moment_ago()[0]

$ ->
  $(".moment_ago").moment_ago()
  setInterval ->
    $(".moment_ago").moment_ago()
  , 1000*60

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
moment_ago-0.0.3 vendor/assets/javascripts/moment_ago.coffee
moment_ago-0.0.2 vendor/assets/javascripts/moment_ago.coffee