Merge branch 'supermodel_patch' of https://github.com/rubenvereecken/codecombat into rubenvereecken-supermodel_patch

This commit is contained in:
Scott Erickson 2014-07-07 18:48:26 -07:00
commit c1f77e3f07
2 changed files with 6 additions and 4 deletions

View file

@ -44,7 +44,7 @@ module.exports = class CocoRouter extends Backbone.Router
return @openRoute(args.join('/'))
view = new ViewClass({}, slugOrId)
view.render()
if view then @openView(view) else @showNotFound()
@openView if view then view else @notFoundView()
cache: {}
openRoute: (route) ->
@ -99,7 +99,7 @@ module.exports = class CocoRouter extends Backbone.Router
return document.location.reload()
path = "views/#{path}"
ViewClass = @tryToLoadModule path
return @showNotFound() if not ViewClass
return @openView @notFoundView() if not ViewClass
view = new ViewClass({}, args...) # options, then any path fragment args
view.render()
@openView(view)
@ -117,7 +117,7 @@ module.exports = class CocoRouter extends Backbone.Router
break if ViewClass
split -= 1
return @showNotFound() if not ViewClass
return @notFoundView() if not ViewClass
args = pieces[split+1..]
view = new ViewClass({}, args...) # options, then any path fragment args
view.render()
@ -129,7 +129,7 @@ module.exports = class CocoRouter extends Backbone.Router
if error.toString().search('Cannot find module "' + path + '" from') is -1
throw error
showNotFound: ->
notFoundView: ->
NotFoundView = require('views/not_found')
view = new NotFoundView()
view.render()

View file

@ -137,12 +137,14 @@ module.exports = class CocoView extends Backbone.View
resourceIndex: r.rid,
responseText: r.jqxhr?.responseText
})).i18n()
@$el.find('.progress').hide()
onRetryResource: (e) ->
res = @supermodel.getResource($(e.target).data('resource-index'))
# different views may respond to this call, and not all have the resource to reload
return unless res and res.isFailed
res.load()
@$el.find('.progress').show()
$(e.target).closest('.loading-error-alert').remove()
# Modals