Improved frontendTimeUpdateItem(), reduced dom updates.
This commit is contained in:
parent
29936d2acd
commit
5e3679519a
1 changed files with 8 additions and 5 deletions
|
@ -219,16 +219,19 @@ class App.Controller extends Spine.Controller
|
||||||
ui = @
|
ui = @
|
||||||
$('.humanTimeFromNow').each( ->
|
$('.humanTimeFromNow').each( ->
|
||||||
item = $(this)
|
item = $(this)
|
||||||
# console.log('rewrite frontendTimeUpdate', this, $(this).hasClass('escalation'))
|
currentVal = item.text()
|
||||||
ui.frontendTimeUpdateItem(item)
|
ui.frontendTimeUpdateItem(item, currentVal)
|
||||||
)
|
)
|
||||||
App.Interval.set( update, 61000, 'frontendTimeUpdate', 'ui' )
|
App.Interval.set( update, 61000, 'frontendTimeUpdate', 'ui' )
|
||||||
|
|
||||||
frontendTimeUpdateItem: (item) =>
|
frontendTimeUpdateItem: (item, currentVal) =>
|
||||||
timestamp = item.data('time')
|
timestamp = item.data('time')
|
||||||
time = @humanTime( timestamp, item.hasClass('escalation') )
|
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') ->
|
ticketPopups: (position = 'right') ->
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue