Skip to content

Commit

Permalink
disable adding feed while processing
Browse files Browse the repository at this point in the history
  • Loading branch information
eguitarz committed Jul 26, 2013
1 parent 9e60165 commit 889cfcc
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions app/js/classes/feeds.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ app = @App
@App.FeedsController = Ember.ArrayController.extend
newFeedUrl: null
urlPrompt: false
isProcessing: false
selectFeed: (feed)->
@get('content').forEach( (i)->
i.set('selected', false)
Expand All @@ -25,9 +26,8 @@ app = @App
# )


@App.FeedsView = Ember.View.extend {
@App.FeedsView = Ember.View.extend
classNames: ['inmiddle']
}

@App.NewFeedView = Ember.View.extend
click: ->
Expand All @@ -40,25 +40,29 @@ app = @App
keyUp: (e)->
url = @get('controller.newFeedUrl')
view = @
if e.keyCode == 13 && !!url
$.post( '/v1/feeds', {url: url} ).done (json)->
if e.keyCode == 13 && !!url && !@get('isProcessing')
@set('isProcessing', true)
@$('input').attr('disabled', true)
$.post( '/v1/feeds', {url: url} ).done (json)=>
json = JSON.parse(json)
$.get( 'v1/feeds/' + json.id ).done (json)=>
@set('isProcessing', false)
@$('input').attr('disabled', false)
json = JSON.parse(json)
$.get( 'v1/feeds/' + json.id ).done (json)->
json = JSON.parse(json)
items = json.feed.items.map((i)->
o = Ember.Object.create().setProperties(i)
o.set('selected', false)
)
feed = Ember.Object.create {
title: json.feed.title
url: url
created_at: new Date()
items: items
selected: false
}
view.get('controller.content').pushObject( feed )
view.set('controller.urlPrompt', false)
view.set('controller.newFeedUrl', null)
items = json.feed.items.map((i)->
o = Ember.Object.create().setProperties(i)
o.set('selected', false)
)
feed = Ember.Object.create {
title: json.feed.title
url: url
created_at: new Date()
items: items
selected: false
}
view.get('controller.content').pushObject( feed )
view.set('controller.urlPrompt', false)
view.set('controller.newFeedUrl', null)

# if e.keyCode == 13 && !!url
# @get('controller').newFeed {"url": encodeURIComponent(url)}

0 comments on commit 889cfcc

Please sign in to comment.