Fix ModPageController to load progressively
This commit is contained in:
@@ -13,6 +13,7 @@ All rights reserved.
|
|||||||
}
|
}
|
||||||
|
|
||||||
td {
|
td {
|
||||||
|
height: 4.8em; width: 4.8em;
|
||||||
background: $color-gray-faint;
|
background: $color-gray-faint;
|
||||||
border: 0.1em solid $color-gray-light;
|
border: 0.1em solid $color-gray-light;
|
||||||
padding: 0.1em;
|
padding: 0.1em;
|
||||||
|
|||||||
@@ -16,11 +16,13 @@ module.exports = class ModPageController extends BaseController
|
|||||||
|
|
||||||
constructor: (options={})->
|
constructor: (options={})->
|
||||||
if not options.modPack? then throw new Error 'options.modPack is required'
|
if not options.modPack? then throw new Error 'options.modPack is required'
|
||||||
|
options.delayStep ?= 100
|
||||||
options.templateName = 'mod_page'
|
options.templateName = 'mod_page'
|
||||||
super options
|
super options
|
||||||
|
|
||||||
@_modPack = options.modPack
|
@_modPack = options.modPack
|
||||||
@_recipeControllers = []
|
@_recipeControllers = []
|
||||||
|
@_delayStep = options.delayStep
|
||||||
|
|
||||||
# BaseController Overrides #####################################################################
|
# BaseController Overrides #####################################################################
|
||||||
|
|
||||||
@@ -33,17 +35,19 @@ module.exports = class ModPageController extends BaseController
|
|||||||
@$title.html if @model? then @model.name else ''
|
@$title.html if @model? then @model.name else ''
|
||||||
|
|
||||||
controllerIndex = 0
|
controllerIndex = 0
|
||||||
|
delay = 0
|
||||||
if @model?.activeModVersion?.isLoaded
|
if @model?.activeModVersion?.isLoaded
|
||||||
@$recipes.show duration:Duration.fast
|
@$recipes.show duration:Duration.fast
|
||||||
@model.eachItem (item)=>
|
@model.eachItem (item)=>
|
||||||
|
recipe = item.getPrimaryRecipe()
|
||||||
|
return if not recipe
|
||||||
|
|
||||||
controller = @_recipeControllers[controllerIndex]
|
controller = @_recipeControllers[controllerIndex]
|
||||||
if not controller?
|
if not controller?
|
||||||
controller = new RecipeController modPack:@_modPack
|
_.delay (=> @_createRecipeController recipe), delay
|
||||||
controller.render()
|
delay += @_delayStep
|
||||||
@_recipeControllers.push controller
|
else
|
||||||
@$recipes.append controller.$el
|
controller.model = recipe
|
||||||
|
|
||||||
controller.model = item.getPrimaryRecipe()
|
|
||||||
controllerIndex += 1
|
controllerIndex += 1
|
||||||
else
|
else
|
||||||
@$recipes.hide duration:Duration.fast
|
@$recipes.hide duration:Duration.fast
|
||||||
@@ -53,3 +57,14 @@ module.exports = class ModPageController extends BaseController
|
|||||||
controller.$el.slideUp duration:Duration.fast, complete:-> @remove()
|
controller.$el.slideUp duration:Duration.fast, complete:-> @remove()
|
||||||
|
|
||||||
super
|
super
|
||||||
|
|
||||||
|
# Private Methods ##############################################################################
|
||||||
|
|
||||||
|
_createRecipeController: (recipe)->
|
||||||
|
controller = new RecipeController model:recipe, modPack:@_modPack
|
||||||
|
controller.$el.hide()
|
||||||
|
controller.render()
|
||||||
|
|
||||||
|
@_recipeControllers.push controller
|
||||||
|
@$recipes.append controller.$el
|
||||||
|
controller.$el.slideDown duration:Duration.fast
|
||||||
|
|||||||
@@ -81,7 +81,8 @@ module.exports = class BaseModel extends Backbone.Model
|
|||||||
|
|
||||||
trigger: (name, model, args...)->
|
trigger: (name, model, args...)->
|
||||||
if @logEvents
|
if @logEvents
|
||||||
logger.trace "#{@constructor.name}.#{@cid} triggered event #{name} with args: #{args}"
|
argText = ("#{arg}"[0..50] for arg in args).join ", "
|
||||||
|
logger.trace "#{@constructor.name}.#{@cid} triggered event #{name} with args: #{argText}"
|
||||||
super
|
super
|
||||||
|
|
||||||
# Object Overrides #############################################################################
|
# Object Overrides #############################################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user