Add timeago js library to show in the start_time of recordings

This commit is contained in:
Leonardo Crauss Daronco 2016-12-09 11:50:09 -02:00
parent 04ae45e4f4
commit 6726504ec3
5 changed files with 20 additions and 13 deletions

View File

@ -61,5 +61,6 @@ gem 'bootstrap-social-rails', '~> 4.12'
gem 'font-awesome-rails'
gem 'jquery-ui-rails'
gem 'jquery-datatables-rails', '~> 3.4.0'
gem 'rails-timeago', '~> 2.0'
gem 'http_accept_language'

View File

@ -152,6 +152,9 @@ GEM
nokogiri (~> 1.6.0)
rails-html-sanitizer (1.0.3)
loofah (~> 2.0)
rails-timeago (2.15.0)
actionpack (>= 3.1)
activesupport (>= 3.1)
railties (5.0.0.1)
actionpack (= 5.0.0.1)
activesupport (= 5.0.0.1)
@ -224,6 +227,7 @@ DEPENDENCIES
omniauth-twitter (= 1.2.1)
puma (~> 3.0)
rails (~> 5.0.0, >= 5.0.0.1)
rails-timeago (~> 2.0)
sass-rails (~> 5.0)
spring
spring-watcher-listen (~> 2.0.0)
@ -237,4 +241,4 @@ RUBY VERSION
ruby 2.3.1p112
BUNDLED WITH
1.13.5
1.13.6

View File

@ -18,6 +18,7 @@
//= require jquery-ui
//= require dataTables/jquery.dataTables
//= require dataTables/bootstrap/3/jquery.dataTables.bootstrap
//= require rails-timeago-all
//= require bootstrap-sprockets
//= require turbolinks
//= require_self

View File

@ -45,10 +45,13 @@ class @Recordings
targets: 0,
render: (data, type, row) ->
if type == 'display'
return new Date(data)
date = new Date(data)
title = date
.toLocaleString($('html').attr('lang'),
{month: 'long', day: 'numeric', year: 'numeric',
hour12: 'true', hour: '2-digit', minute: '2-digit'})
timeago = '<time datetime="'+date.toISOString()+'" data-time-ago="'+date.toISOString()+'">'+date.toISOString()+'</time>'
return title+'<span class="timeago">('+timeago+')</span>'
return data
},
{
@ -194,7 +197,7 @@ class @Recordings
btn.prop('disabled', false)
)
this.table.on 'click', '.recording-delete', (event) ->
@getTable().on 'click', '.recording-delete', (event) ->
btn = $(this)
row = table_api.row($(this).closest('tr')).data()
url = $('.meeting-url').val()
@ -209,6 +212,9 @@ class @Recordings
btn.prop('disabled', false)
)
@getTable().on 'draw.dt', (event) ->
$('time[data-time-ago]').timeago();
getTable: ->
@table

View File

@ -37,16 +37,11 @@
.dataTables_empty {
text-align: center;
}
.recording-update:hover > {
.default {
display: none;
}
.hover {
display: inline-block;
}
}
.fa.hover {
display: none;
.timeago {
margin-left: 5px;
font-size: 13px;
cursor: pointer;
color: #999;
}
}
}