Show mod icons in mod ballot
This commit is contained in:
@@ -15,12 +15,15 @@ PageController = require '../page_controller'
|
||||
module.exports = class BrowsePageController extends PageController
|
||||
|
||||
constructor: (options={})->
|
||||
if not options.client then throw new Error 'options.client is required'
|
||||
if not options.modPack then throw new Error 'options.modPack is required'
|
||||
if not options.client then throw new Error 'options.client is required'
|
||||
if not options.imageLoader then throw new Error 'options.imageLoader is required'
|
||||
if not options.modPack then throw new Error 'options.modPack is required'
|
||||
|
||||
options.templateName = 'browse_page'
|
||||
super options
|
||||
|
||||
@_client = options.client
|
||||
@_imageLoader = options.imageLoader
|
||||
@_modPack = options.modPack
|
||||
@_tileControllers = []
|
||||
|
||||
@@ -48,7 +51,10 @@ module.exports = class BrowsePageController extends PageController
|
||||
# BaseController Overrides #####################################################################
|
||||
|
||||
onDidRender: ->
|
||||
@_modBallotController = @addChild ModBallotController, '.view__mod_ballot', client:@_client, user:@_user
|
||||
@_modBallotController = @addChild ModBallotController, '.view__mod_ballot',
|
||||
client: @_client
|
||||
imageLoader: @_imageLoader
|
||||
user: @_user
|
||||
|
||||
@$tileContainer = @$('.tile_container')
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
.button.vote-now: .bezel: p Vote Now!
|
||||
|
||||
.status.loading
|
||||
img(src="/images/wait.gif")
|
||||
.status-message
|
||||
|
||||
.status.loaded
|
||||
|
||||
@@ -22,10 +22,29 @@ $ballot-move-duration: 0.2s;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.status-message {
|
||||
margin-bottom: $size-margin-large;
|
||||
|
||||
font-family: $font-family-header;
|
||||
font-size: $font-size-medium;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&.initial {
|
||||
padding: 0 15%;
|
||||
}
|
||||
|
||||
&.loading {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
img {
|
||||
margin-top: $size-margin-large;
|
||||
margin-bottom: $size-margin-medium;
|
||||
}
|
||||
}
|
||||
|
||||
&.loaded {
|
||||
padding: 0 15%;
|
||||
|
||||
@@ -63,14 +82,6 @@ $ballot-move-duration: 0.2s;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
|
||||
.status-message {
|
||||
margin-bottom: $size-margin-large;
|
||||
|
||||
font-family: $font-family-header;
|
||||
font-size: $font-size-medium;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.button {
|
||||
width: $size-minecraft-block * 10;
|
||||
}
|
||||
|
||||
@@ -27,12 +27,15 @@ module.exports = class ModBallotController extends BaseController
|
||||
@::VOTE_ERROR = 'Sorry! Something went wrong casting your vote. Please try again.'
|
||||
|
||||
constructor: (options={})->
|
||||
if not options.client then throw new Error "options.client is required"
|
||||
if not options.client then throw new Error 'options.client is required'
|
||||
if not options.imageLoader then throw new Error 'options.imageLoader is required'
|
||||
|
||||
options.model = ballot:null, votes:null
|
||||
options.templateName = 'browse_page/mod_ballot'
|
||||
super options
|
||||
|
||||
@_client = options.client
|
||||
@_imageLoader = options.imageLoader
|
||||
@_lineControllers = {}
|
||||
@_status = @STATUS.INITIAL
|
||||
|
||||
@@ -184,7 +187,8 @@ module.exports = class ModBallotController extends BaseController
|
||||
model = {ballotLine:line, vote:@_findVote(line.modId)}
|
||||
if not controller?
|
||||
controller = new ModBallotLineController
|
||||
model: model
|
||||
imageLoader: @_imageLoader
|
||||
model: model
|
||||
onVoteButtonClicked: (controller)=> @onVoteButtonClicked controller
|
||||
controller.render()
|
||||
@$ballotList.append controller.$el
|
||||
|
||||
+11
@@ -12,9 +12,11 @@ BaseController = require '../../../base_controller'
|
||||
module.exports = class ModBallotLineController extends BaseController
|
||||
|
||||
constructor: (options={})->
|
||||
if not options.imageLoader then throw new Error 'options.imageLoader is required'
|
||||
options.templateName = 'browse_page/mod_ballot/mod_ballot_line'
|
||||
super options
|
||||
|
||||
@_imageLoader = options.imageLoader
|
||||
@_onVoteButtonClicked = options.onVoteButtonClicked or (controller)-> # do nothing
|
||||
|
||||
# Event Methods ################################################################################
|
||||
@@ -56,6 +58,7 @@ module.exports = class ModBallotLineController extends BaseController
|
||||
refresh: ->
|
||||
@$name.html @model.ballotLine?.name or ''
|
||||
@$voteCount.html @model.ballotLine?.voteCount or ''
|
||||
@_refreshIcon()
|
||||
@_refreshVoteButton()
|
||||
super
|
||||
|
||||
@@ -67,6 +70,14 @@ module.exports = class ModBallotLineController extends BaseController
|
||||
|
||||
# Private Methods ##############################################################################
|
||||
|
||||
_refreshIcon: ->
|
||||
if @model.ballotLine?
|
||||
modSlug = _.slugify(@model.ballotLine.name)
|
||||
url = c.url.modIcon modSlug:modSlug
|
||||
@_imageLoader.load url, @$image
|
||||
else
|
||||
@$image.attr 'src', '/images/unknown.png'
|
||||
|
||||
_refreshVoteButton: ->
|
||||
if @isWaiting
|
||||
@$wait.removeClass 'hidden'
|
||||
|
||||
Reference in New Issue
Block a user