Add support for videos on mod pages
This commit is contained in:
@@ -24,6 +24,10 @@
|
|||||||
a.documentation(target="documentation") documentation
|
a.documentation(target="documentation") documentation
|
||||||
a.download(target="download") download
|
a.download(target="download") download
|
||||||
|
|
||||||
|
section.videos
|
||||||
|
h2 Videos
|
||||||
|
.panel
|
||||||
|
|
||||||
section.tutorials
|
section.tutorials
|
||||||
h2 Tutorials
|
h2 Tutorials
|
||||||
.panel
|
.panel
|
||||||
|
|||||||
@@ -59,6 +59,18 @@
|
|||||||
@include layout-link-list;
|
@include layout-link-list;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
section.videos {
|
||||||
|
.panel {
|
||||||
|
display: flex;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
|
||||||
|
.view__video {
|
||||||
|
flex: 0 0 50%;
|
||||||
|
margin-bottom: $size-margin-large;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@include screen-size(mobile) {
|
@include screen-size(mobile) {
|
||||||
@@ -97,5 +109,13 @@
|
|||||||
margin-right: $size-margin-medium;
|
margin-right: $size-margin-medium;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
section.videos {
|
||||||
|
.panel {
|
||||||
|
.view__video {
|
||||||
|
flex: 0 0 100%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,12 +5,13 @@
|
|||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
|
|
||||||
{Item} = require('crafting-guide-common').deprecated.game
|
{Item} = require("crafting-guide-common").deprecated.game
|
||||||
ItemGroupController = require '../common/item_group/item_group_controller'
|
ItemGroupController = require "../common/item_group/item_group_controller"
|
||||||
{Mod} = require('crafting-guide-common').deprecated.game
|
{Mod} = require("crafting-guide-common").deprecated.game
|
||||||
ModVersionSelectorController = require '../common/mod_version_selector/mod_version_selector_controller'
|
ModVersionSelectorController = require "../common/mod_version_selector/mod_version_selector_controller"
|
||||||
PageController = require '../page_controller'
|
PageController = require "../page_controller"
|
||||||
TutorialController = require './tutorial/tutorial_controller'
|
TutorialController = require "./tutorial/tutorial_controller"
|
||||||
|
VideoController = require "../common/video/video_controller"
|
||||||
|
|
||||||
########################################################################################################################
|
########################################################################################################################
|
||||||
|
|
||||||
@@ -53,12 +54,16 @@ module.exports = class ModPageController extends PageController
|
|||||||
@$title = @$('.about .title')
|
@$title = @$('.about .title')
|
||||||
@$tutorialsContainer = @$('section.tutorials .panel')
|
@$tutorialsContainer = @$('section.tutorials .panel')
|
||||||
@$tutorialsSection = @$('section.tutorials')
|
@$tutorialsSection = @$('section.tutorials')
|
||||||
|
@$videosContainer = @$('section.videos .panel')
|
||||||
|
@$videosSection = @$('section.videos')
|
||||||
|
@$videosSectionTitle = @$('section.videos h2')
|
||||||
super
|
super
|
||||||
|
|
||||||
refresh: ->
|
refresh: ->
|
||||||
@_refreshAboutBlock()
|
@_refreshAboutBlock()
|
||||||
@_refreshItemGroups()
|
@_refreshItemGroups()
|
||||||
@_refreshTutorials()
|
@_refreshTutorials()
|
||||||
|
@_refreshVideos()
|
||||||
super
|
super
|
||||||
|
|
||||||
# Backbone.View Overrides ######################################################################
|
# Backbone.View Overrides ######################################################################
|
||||||
@@ -136,3 +141,29 @@ module.exports = class ModPageController extends PageController
|
|||||||
@show @$tutorialsSection
|
@show @$tutorialsSection
|
||||||
else
|
else
|
||||||
@hide @$tutorialsSection
|
@hide @$tutorialsSection
|
||||||
|
|
||||||
|
_refreshVideos: ->
|
||||||
|
@_videoControllers ?= []
|
||||||
|
index = 0
|
||||||
|
|
||||||
|
videos = @model?.videos or []
|
||||||
|
if videos? and videos.length > 0
|
||||||
|
@$videosSectionTitle.html if videos.length is 1 then 'Video' else 'Videos'
|
||||||
|
|
||||||
|
for video in videos
|
||||||
|
controller = @_videoControllers[index]
|
||||||
|
if not controller?
|
||||||
|
controller = new VideoController model:video
|
||||||
|
@_videoControllers.push controller
|
||||||
|
controller.render()
|
||||||
|
@$videosContainer.append controller.$el
|
||||||
|
else
|
||||||
|
controller.model = video
|
||||||
|
index++
|
||||||
|
|
||||||
|
@show @$videosSection
|
||||||
|
else
|
||||||
|
@hide @$videosSection
|
||||||
|
|
||||||
|
while @_videoControllers.length > index
|
||||||
|
@_videoControllers.pop().remove()
|
||||||
|
|||||||
Reference in New Issue
Block a user