Created
February 6, 2012 10:04
-
-
Save zheileman/1751193 to your computer and use it in GitHub Desktop.
jQuery timeago rails helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This will work together with this jQuery timeago plugin fork: | |
# https://github.com/zheileman/jquery-timeago | |
# Please note the original jQuery timeago plugin use the 'title' to store the timestamp. | |
# This forked version use a 'data-time' attribute to store the timestamp and have | |
# a configurable setting to enable/disable overwriting the title with tag's content. | |
# | |
# $.timeago.settings.overwriteTitle = [true|false] | |
def js_timeago(time, options = {}) | |
css_classes = (options.delete(:class) || "").strip.split | ["timeago"] | |
content_tag(:span, time.to_s, options.merge('data-time' => time.getutc.iso8601, :class => css_classes.join(' '))) if time | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment