Add missing detail data to item pages
This commit is contained in:
@@ -5,30 +5,31 @@
|
||||
# All rights reserved.
|
||||
#
|
||||
|
||||
BaseController = require '../../base_controller'
|
||||
BaseController = require "../../base_controller"
|
||||
|
||||
########################################################################################################################
|
||||
|
||||
module.exports = class VideoController extends BaseController
|
||||
|
||||
constructor: (options={})->
|
||||
if not options.model? then throw new Error 'options.model is required'
|
||||
options.templateName = 'common/video'
|
||||
if not options.model? then throw new Error "options.model is required"
|
||||
options.templateName = "common/video"
|
||||
super options
|
||||
|
||||
# BaseController Overrides #####################################################################
|
||||
|
||||
onDidRender: ->
|
||||
@$iframe = @$('iframe')
|
||||
@$caption = @$('.caption p')
|
||||
@$iframe = @$("iframe")
|
||||
@$caption = @$(".caption p")
|
||||
super
|
||||
|
||||
refresh: ->
|
||||
@$caption.html @model.name
|
||||
@$iframe.attr 'src', @_createYouTubeUrl()
|
||||
@$iframe.attr "src", @_createYouTubeUrl()
|
||||
super
|
||||
|
||||
# Private ######################################################################################
|
||||
|
||||
_createYouTubeUrl: ->
|
||||
return "http://www.youtube.com/embed/#{@model.youTubeId}?modestbranding=1&autohide=1&showinfo=0"
|
||||
|
||||
|
||||
@@ -119,8 +119,8 @@ module.exports = class ItemPageController extends PageController
|
||||
|
||||
@_descriptionController.imageBase = c.url.itemImageDir @model.itemDisplay
|
||||
|
||||
if @model.item.officialUrl?
|
||||
@$officialLink.attr 'href', @model.item.officialUrl
|
||||
if @model.item.detail?.links.length > 0
|
||||
@$officialLink.attr 'href', @model.item.detail.links[0]
|
||||
@show @$aboutLinks
|
||||
else
|
||||
@hide @$aboutLinks
|
||||
@@ -217,8 +217,8 @@ module.exports = class ItemPageController extends PageController
|
||||
throw e
|
||||
|
||||
_refreshDescription: ->
|
||||
if @model.item?.description?.length > 0
|
||||
@_descriptionController.model = @model.item.description
|
||||
if @model.item.detail?.description.length > 0
|
||||
@_descriptionController.model = @model.item.detail.description
|
||||
@_descriptionController.resetToDefaultState()
|
||||
|
||||
_refreshMultiblock: ->
|
||||
@@ -284,7 +284,7 @@ module.exports = class ItemPageController extends PageController
|
||||
@_videoControllers ?= []
|
||||
index = 0
|
||||
|
||||
videos = @model?.item?.videos or []
|
||||
videos = @model.item.detail?.videos
|
||||
if videos? and videos.length > 0
|
||||
@$videosSectionTitle.html if videos.length is 1 then 'Video' else 'Videos'
|
||||
|
||||
@@ -305,3 +305,4 @@ module.exports = class ItemPageController extends PageController
|
||||
|
||||
while @_videoControllers.length > index
|
||||
@_videoControllers.pop().remove()
|
||||
|
||||
|
||||
@@ -103,6 +103,8 @@ module.exports = class Router extends Backbone.Router
|
||||
if not item? then throw new Error "could not find item #{modId}__#{itemSlug}"
|
||||
|
||||
itemPage = new ItemPage item
|
||||
itemPage.loadDetails()
|
||||
|
||||
params = new UrlParams login:{type:'boolean', default:false}
|
||||
controller = new ItemPageController @_makeOptions {model:itemPage, login:params.login}
|
||||
@_siteController.setPage 'browseModItem', controller
|
||||
|
||||
Reference in New Issue
Block a user