From cf6d6fdbed8889431ae1d34e2c21f0ea3c3a720f Mon Sep 17 00:00:00 2001 From: Andrew Miner Date: Mon, 9 Feb 2015 20:25:54 -0800 Subject: [PATCH] Add link to crafting plan from item detail #83 --- src/css/templates/item_page.scss | 14 +++++++++++- .../controllers/item_page_controller.coffee | 22 +++++++++++-------- src/scripts/models/mod_pack.coffee | 5 +++-- src/templates/item_page.jade | 3 ++- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/src/css/templates/item_page.scss b/src/css/templates/item_page.scss index b4b4e967c..dce1d63f2 100644 --- a/src/css/templates/item_page.scss +++ b/src/css/templates/item_page.scss @@ -24,6 +24,18 @@ All rights reserved. @include pixel-image; } } + + a { + position: relative; width: 80%; + margin: 0 10%; + display: none; + + p { + font-family: $font-family-normal; + font-size: $font-size-normal; + text-align: center; + } + } } .mainBody { @@ -74,7 +86,7 @@ All rights reserved. display: none; } - .usedInMaking { + .usedToMake { display: none; } } diff --git a/src/scripts/controllers/item_page_controller.coffee b/src/scripts/controllers/item_page_controller.coffee index a897e5178..e6a0759b0 100644 --- a/src/scripts/controllers/item_page_controller.coffee +++ b/src/scripts/controllers/item_page_controller.coffee @@ -40,16 +40,17 @@ module.exports = class ItemPageController extends BaseController onDidRender: -> @_similarItemsController = @addChild ItemGroupController, '.similar .view__item_group', modPack:@_modPack - @_usedInMakingController = @addChild ItemGroupController, '.usedInMaking .view__item_group', modPack:@_modPack + @_usedToMakeController = @addChild ItemGroupController, '.usedToMake .view__item_group', modPack:@_modPack @$byline = @$('.byline') @$bylineLink = @$('.byline a') + @$craftingPlanLink = @$('a.craftingPlan') @$name = @$('h1.name') @$recipeContainer = @$('.recipes .panel') @$recipesSection = @$('.recipes') @$similarContainer = @$('.similar') @$titleImage = @$('.titleImage img') - @$usedInMakingContainer = @$('.usedInMaking') + @$usedToMakeContainer = @$('.usedToMake') super refresh: -> @@ -58,16 +59,19 @@ module.exports = class ItemPageController extends BaseController display = @_modPack.findItemDisplay @model.item?.slug if display? + @$craftingPlanLink.attr href:display.craftingUrl + @$craftingPlanLink.fadeIn duration:Duration.fast @_imageLoader.load display.iconUrl, @$titleImage @$name.html display.itemName else + @$craftingPlanLink.fadeOut duration:Duration.fast @$titleImage.removeAttr 'src' @$name.html '' @_refreshByline() @_refreshRecipes() @_refreshSimilarItems() - @_refreshComponentIn() + @_refreshUsedToMake() super @@ -82,14 +86,14 @@ module.exports = class ItemPageController extends BaseController else @$byline.fadeOut duration:Duration.fast - _refreshComponentIn: -> - @_usedInMakingController.title = 'Used to Make' + _refreshUsedToMake: -> + @_usedToMakeController.title = 'Used to Make' - @_usedInMakingController.model = @model.findComponentInItems() - if @_usedInMakingController.model? - @$usedInMakingContainer.fadeIn duration:Duration.fast + @_usedToMakeController.model = @model.findComponentInItems() + if @_usedToMakeController.model? + @$usedToMakeContainer.fadeIn duration:Duration.fast else - @$usedInMakingContainer.fadeOut duration:Duration.fast + @$usedToMakeContainer.fadeOut duration:Duration.fast _refreshRecipes: -> @_recipeControllers ?= [] diff --git a/src/scripts/models/mod_pack.coffee b/src/scripts/models/mod_pack.coffee index ed2441f84..cc8fc06bb 100644 --- a/src/scripts/models/mod_pack.coffee +++ b/src/scripts/models/mod_pack.coffee @@ -60,8 +60,9 @@ module.exports = class ModPack extends BaseModel result.slug = slug result.itemName = @findName slug, includeDisabled:true - result.iconUrl = Url.itemIcon result - result.itemUrl = Url.item result + result.craftingUrl = Url.crafting inventoryText:slug + result.iconUrl = Url.itemIcon result + result.itemUrl = Url.item result return result findName: (slug)-> diff --git a/src/templates/item_page.jade b/src/templates/item_page.jade index 453b73009..9600d70fe 100644 --- a/src/templates/item_page.jade +++ b/src/templates/item_page.jade @@ -8,6 +8,7 @@ .view__item_page .sidebar .titleImage: img + a.craftingPlan: p Full Crafting Plan .mainBody h1.name @@ -18,6 +19,6 @@ h2 Recipes .panel - .usedInMaking: .view__item_group + .usedToMake: .view__item_group .similar: .view__item_group .plan \ No newline at end of file