Files
website/src/coffee/controllers/item_controller.coffee
T
Andrew Miner 930b8049a2 Convert site to a single JavaScript archive
* Convert build to use a single JavaScript file on the site (instead
  of downloading each library separately). This also means that all
  global variables (e.g., `$` for JQuery, `_` for Underscore.js) can
  be removed.
* Remove unused scripts and/or move them to a more appropriate repo
* Update the `deploy` script to work with CircleCI's automation
* Update markdown display code to allow images to be located with the
  markdown data files instead of the pre-rendered index pages
2015-04-29 19:58:53 -07:00

45 lines
1.4 KiB
CoffeeScript

###
Crafting Guide - item_controller.coffee
Copyright (c) 2015 by Redwood Labs
All rights reserved.
###
BaseController = require './base_controller'
_ = require 'underscore'
########################################################################################################################
module.exports = class ItemController extends BaseController
constructor: (options={})->
if not options.imageLoader? then throw new Error 'options.imageLoader is required'
if not options.model? then throw new Error 'options.model is required'
if not options.modPack? then throw new Error 'options.modPack is required'
options.templateName = 'item'
super options
@imageLoader = options.imageLoader
@modPack = options.modPack
# BaseController Overrides #####################################################################
onDidRender: ->
@$icon = @$('img')
@$name = @$('.itemName')
@$nameLink = @$('a')
super
refresh: ->
display = @modPack.findItemDisplay @model.slug
@imageLoader.load display.iconUrl, @$icon
@$name.html display.itemName
@$nameLink.attr 'href', display.itemUrl
# Backbone.View Overrides ######################################################################
events: ->
return _.extend super,
'click a': 'routeLinkClick'