From 7a1749065c757743234109649936b833671faa59 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Sun, 8 Feb 2015 15:10:48 +0100 Subject: [PATCH] Improved showing time after ticket popover is shown. --- .../_application_controller.js.coffee | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller.js.coffee b/app/assets/javascripts/app/controllers/_application_controller.js.coffee index 0bef0a08c..c106e7e2d 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.js.coffee @@ -206,14 +206,18 @@ class App.Controller extends Spine.Controller update = => ui = @ $('.humanTimeFromNow').each( -> + item = $(this) # console.log('rewrite frontendTimeUpdate', this, $(this).hasClass('escalation')) - timestamp = $(this).data('time') - time = ui.humanTime( timestamp, $(this).hasClass('escalation') ) - $(this).attr( 'data-tooltip', App.i18n.translateTimestamp(timestamp) ) - $(this).html( time ) + ui.frontendTimeUpdateItem(item) ) App.Interval.set( update, 30000, 'frontendTimeUpdate', 'ui' ) + frontendTimeUpdateItem: (item) => + timestamp = item.data('time') + time = @humanTime( timestamp, item.hasClass('escalation') ) + item.attr( 'data-tooltip', App.i18n.translateTimestamp(timestamp) ) + item.html( time ) + ticketPopups: (position = 'right') -> # open ticket in new task if curent user agent @@ -241,12 +245,17 @@ class App.Controller extends Spine.Controller ticket = App.Ticket.fullLocal( ticket_id ) App.Utils.htmlEscape( ticket.title ) content: -> - ticket_id = $(@).data('id') - ticket = App.Ticket.fullLocal( ticket_id ) - ticket.humanTime = ui.humanTime(ticket.created_at) - App.view('popover/ticket')( + ticket_id = $(@).data('id') + ticket = App.Ticket.fullLocal( ticket_id ) + html = App.view('popover/ticket')( ticket: ticket ) + html = $( html ) + html.find('.humanTimeFromNow').each( -> + item = $(this) + ui.frontendTimeUpdateItem(item) + ) + html ) ticketPopupsDestroy: =>