From 5e3679519abf51b5372990c4e76c84399eb6663b Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Mon, 14 Sep 2015 19:11:13 +0200 Subject: [PATCH] Improved frontendTimeUpdateItem(), reduced dom updates. --- .../controllers/_application_controller.js.coffee | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/app/controllers/_application_controller.js.coffee b/app/assets/javascripts/app/controllers/_application_controller.js.coffee index 1483b5ab0..11bd1ac74 100644 --- a/app/assets/javascripts/app/controllers/_application_controller.js.coffee +++ b/app/assets/javascripts/app/controllers/_application_controller.js.coffee @@ -219,16 +219,19 @@ class App.Controller extends Spine.Controller ui = @ $('.humanTimeFromNow').each( -> item = $(this) -# console.log('rewrite frontendTimeUpdate', this, $(this).hasClass('escalation')) - ui.frontendTimeUpdateItem(item) + currentVal = item.text() + ui.frontendTimeUpdateItem(item, currentVal) ) App.Interval.set( update, 61000, 'frontendTimeUpdate', 'ui' ) - frontendTimeUpdateItem: (item) => + frontendTimeUpdateItem: (item, currentVal) => timestamp = item.data('time') time = @humanTime( timestamp, item.hasClass('escalation') ) - item.attr( 'data-tooltip', App.i18n.translateTimestamp(timestamp) ) - item.html( time ) + + # only do dom updates on changes + return if time is currentVal + item.attr('data-tooltip', App.i18n.translateTimestamp(timestamp)) + item.html(time) ticketPopups: (position = 'right') ->