mirror of
				https://github.com/KevinMidboe/linguist.git
				synced 2025-10-29 17:50:22 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			24 lines
		
	
	
		
			536 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			24 lines
		
	
	
		
			536 B
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
class App.FromNowView extends Ember.View
 | 
						|
    tagName: 'time'
 | 
						|
    template: Ember.Handlebars.compile '{{view.output}}'
 | 
						|
    output: ~>
 | 
						|
        return moment(@value).fromNow()
 | 
						|
 | 
						|
    didInsertElement: ->
 | 
						|
        @tick()
 | 
						|
 | 
						|
    tick: ->
 | 
						|
        f = ->
 | 
						|
            @notifyPropertyChange 'output'
 | 
						|
            @tick()
 | 
						|
 | 
						|
        nextTick = Ember.run.later(this, f, 1000)
 | 
						|
        @set 'nextTick', nextTick
 | 
						|
 | 
						|
    willDestroyElement: ->
 | 
						|
        nextTick = @nextTick
 | 
						|
        Ember.run.cancel nextTick
 | 
						|
 | 
						|
Ember.Handlebars.helper 'fromNow', App.FromNowView
 | 
						|
 |