Replace jQuery animations with CSS animations

This commit is contained in:
Andrew Miner
2015-03-21 19:00:46 -07:00
parent 3d0908c421
commit 9956e64af0
32 changed files with 385 additions and 369 deletions
@@ -43,6 +43,7 @@ module.exports = class ItemPageController extends PageController
craftingPlanButtonClicked: ->
display = @modPack.findItemDisplay @model.item.slug
logger.debug "button clicked, going to: #{display.craftingUrl}"
router.navigate display.craftingUrl, trigger:true
return false
@@ -56,21 +57,13 @@ module.exports = class ItemPageController extends PageController
onDidRender: ->
@adsenseController = @addChild AdsenseController, '.view__adsense', model:'sidebar_skyscraper'
@_similarItemsController = @addChild ItemGroupController, '.similar .view__item_group',
imageLoader: @imageLoader
modPack: @modPack
@_usedAsToolToMakeController = @addChild ItemGroupController, '.usedAsToolToMake .view__item_group',
imageLoader: @imageLoader
modPack: @modPack
@_usedToMakeController = @addChild ItemGroupController, '.usedToMake .view__item_group',
imageLoader: @imageLoader
modPack: @modPack
options = imageLoader:@imageLoader, modPack:@modPack, show:false
@_similarItemsController = @addChild ItemGroupController, '.view__item_group.similar', options
@_usedAsToolToMakeController = @addChild ItemGroupController, '.view__item_group.usedAsToolToMake', options
@_usedToMakeController = @addChild ItemGroupController, '.view__item_group.usedToMake', options
@$byline = @$('.byline')
@$bylineLink = @$('.byline a')
@$craftingPlanButton = @$('button.craftingPlan')
@$descriptionPanel = @$('.description .panel')
@$descriptionSection = @$('.description')
@$name = @$('h1.name')
@@ -92,20 +85,18 @@ module.exports = class ItemPageController extends PageController
if @model.item?
display = @modPack.findItemDisplay @model.item.slug
@$craftingPlanButton.fadeIn duration:Duration.fast
@imageLoader.load display.iconUrl, @$titleImage
@$name.html display.itemName
if @model.item.officialUrl?
@$officialPageLink.attr 'href', @model.item.officialUrl
@$officialPageLink.fadeIn duration:Duration.normal
@show @$officialPageLink
else
@$officialPageLink.fadeOut duration:Duration.normal
@hide @$officialPageLink
@$el.slideDown duration:Duration.normal
@show()
else
@$craftingPlanButton.fadeOut duration:Duration.fast
@$el.slideUp duration:Duration.normal
@hide()
@_refreshByline()
@_refreshDescription()
@@ -121,10 +112,10 @@ module.exports = class ItemPageController extends PageController
events: ->
return _.extend super,
'click a.craftingPlan': 'routeLinkClick'
'click .byline a': 'routeLinkClick'
'click .markdown': 'routeLinkClick'
'click button.craftingPlan': 'craftingPlanButtonClicked'
'click a.craftingPlan': 'routeLinkClick'
'click .byline a': 'routeLinkClick'
'click .markdown': 'routeLinkClick'
'click button': 'craftingPlanButtonClicked'
# Private Methods ##############################################################################
@@ -133,25 +124,25 @@ module.exports = class ItemPageController extends PageController
if mod?.name?.length > 0
@$bylineLink.attr 'href', Url.mod modSlug:mod.slug
@$bylineLink.html mod.name
@$byline.fadeIn duration:Duration.fast
@show @$byline
else
@$byline.fadeOut duration:Duration.fast
@hide @$byline
_refreshDescription: ->
description = @model.compileDescription()
if description?
@$descriptionPanel.html description
@$descriptionSection.slideDown duration:Duration.normal
@show @$descriptionPanel
else
@$descriptionSection.slideUp duration:Duration.normal
@hide @$descriptionPanel
_refreshRecipes: ->
@_recipeControllers ?= []
index = 0
recipes = @model.findRecipes()
if recipes?
@$recipesSection.slideDown duration:Duration.normal
if recipes?.length > 0
@$recipesSectionTitle.html if recipes.length is 1 then 'Recipe' else 'Recipes'
for recipe in @model.findRecipes()
@@ -159,17 +150,18 @@ module.exports = class ItemPageController extends PageController
if not controller?
controller = new FullRecipeController imageLoader:@imageLoader, modPack:@modPack, model:recipe
@_recipeControllers.push controller
controller.render()
@$recipeContainer.append controller.$el
controller.render()
else
controller.model = recipe
index++
@show @$recipesSection
else
@$recipesSection.slideUp duration:Duration.normal
@hide @$recipesSection
while @_recipeControllers.length > index
controller = @_recipeControllers.pop()
controller.$el.slideUp duration:Duration.normal, complete:-> controller.$el.remove()
@_recipeControllers.pop().remove()
_refreshSimilarItems: ->
group = @model.item?.group
@@ -179,28 +171,13 @@ module.exports = class ItemPageController extends PageController
else
@_similarItemsController.model = null
if @_similarItemsController.model?
@$similarSection.slideDown duration:Duration.normal
else
@$similarSection.slideUp duration:Duration.normal
_refreshUsedAsToolToMake: ->
@_usedAsToolToMakeController.title = 'Used as Tool to Make'
@_usedAsToolToMakeController.model = @model.findToolForRecipes()
if @_usedAsToolToMakeController.model?
@$usedAsToolToMakeSection.slideDown duration:Duration.normal
else
@$usedAsToolToMakeSection.slideUp duration:Duration.normal
_refreshUsedToMake: ->
@_usedToMakeController.title = 'Used to Make'
@_usedToMakeController.model = @model.findComponentInItems()
if @_usedToMakeController.model?
@$usedToMakeSection.slideDown duration:Duration.normal
else
@$usedToMakeSection.slideUp duration:Duration.normal
_refreshVideos: ->
@_videoControllers ?= []
@@ -208,7 +185,6 @@ module.exports = class ItemPageController extends PageController
videos = @model?.item?.videos or []
if videos? and videos.length > 0
@$videosSection.slideDown duration:Duration.normal
@$videosSectionTitle.html if videos.length is 1 then 'Video' else 'Videos'
for video in videos
@@ -221,12 +197,13 @@ module.exports = class ItemPageController extends PageController
else
controller.model = video
index++
@show @$videosSection
else
@$videosSection.slideUp duration:Duration.normal
@hide @$videosSection
while @_videoControllers.length > index
controller = @_videoControllers.pop()
controller.$el.slideUp duration:Duration.normal, complete:-> controller.$el.remove()
@_videoControllers.pop().remove()
_resolveItemSlug: ->
return if @model.item?