mirror of
https://gitlab.com/Deukhoofd/BattleSim.git
synced 2025-10-28 02:00:04 +00:00
Added Team reordering
This commit is contained in:
@@ -11,6 +11,34 @@ $pokemon-list-height = 50px
|
||||
box-sizing border-box
|
||||
height 28px
|
||||
|
||||
.arrow-up
|
||||
width 0;
|
||||
height 0;
|
||||
border-left 7px solid transparent
|
||||
border-right 7px solid transparent
|
||||
border-bottom 12px solid #939393
|
||||
position absolute
|
||||
left 88%
|
||||
top 25%
|
||||
&:hover
|
||||
border-bottom-color #a8a8a8
|
||||
&:active
|
||||
border-bottom-color #696969
|
||||
|
||||
.arrow-down
|
||||
width 0
|
||||
height 0
|
||||
border-left 7px solid transparent
|
||||
border-right 7px solid transparent
|
||||
border-top 12px solid #939393
|
||||
position absolute
|
||||
left 88%
|
||||
top 40%
|
||||
&:hover
|
||||
border-top-color #a8a8a8
|
||||
&:active
|
||||
border-top-color #696969
|
||||
|
||||
.teambuilder .selectize-input input
|
||||
height 18px
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ class @TeambuilderView extends Backbone.View
|
||||
'click .go-to-team' : 'clickTeam'
|
||||
'click .import-team' : 'renderImportTeamModal'
|
||||
'click .get-teams' : 'getAllTeamsAdmin'
|
||||
'click .arrow-up' : 'moveTeamUp'
|
||||
'click .arrow-down' : 'moveTeamDown'
|
||||
|
||||
# Teambuild view
|
||||
'click .change-format-dropdown a': 'changeTeamFormat'
|
||||
@@ -157,7 +159,6 @@ class @TeambuilderView extends Backbone.View
|
||||
@getTeam(id).replace(jint, jPkmn)
|
||||
jint = jint+1
|
||||
@getTeam(id).save()
|
||||
$modal.find('.imported-team').val("")
|
||||
$modal.modal('hide')
|
||||
return false
|
||||
$modal.find('.exported-team').first().focus()
|
||||
@@ -252,7 +253,8 @@ class @TeambuilderView extends Backbone.View
|
||||
@renderTeams()
|
||||
|
||||
renderTeams: =>
|
||||
@$('.display_teams').html @teamsTemplate(teams: @getAllTeams(), window: window)
|
||||
allteams = sortByKey(@getAllTeams(), "id")
|
||||
@$('.display_teams').html @teamsTemplate(teams: allteams, window: window)
|
||||
@$('.display_teams').removeClass('hidden')
|
||||
@$('.display_pokemon').addClass('hidden')
|
||||
this
|
||||
@@ -344,4 +346,59 @@ class @TeambuilderView extends Backbone.View
|
||||
|
||||
renderSaved: (team) =>
|
||||
$team = $(".select-team[data-cid='#{team.cid}']")
|
||||
$team.find('.show_spinner').addClass('hidden')
|
||||
$team.find('.show_spinner').addClass('hidden')
|
||||
|
||||
moveTeamUp: (e) =>
|
||||
@resetTeams(PokeBattle.TeamStore)
|
||||
$team = $(e.currentTarget).closest('.select-team')
|
||||
id = $team.data('id')
|
||||
for indexno, team_ of @getAllTeams()
|
||||
if team_.id is id
|
||||
team = team_
|
||||
allTeams = sortByKey(@getAllTeams(), "id")
|
||||
index = -1
|
||||
for thisteam, num in allTeams
|
||||
index = num if thisteam.id is id
|
||||
if index is 0
|
||||
return
|
||||
upTeam = allTeams[index - 1]
|
||||
upID = upTeam.id
|
||||
downID = team.id
|
||||
upTeam.id = downID
|
||||
team.id = upID
|
||||
team.save()
|
||||
upTeam.save()
|
||||
@resetTeams(PokeBattle.TeamStore)
|
||||
@renderTeams()
|
||||
|
||||
moveTeamDown: (e) =>
|
||||
@resetTeams(PokeBattle.TeamStore)
|
||||
$team = $(e.currentTarget).closest('.select-team')
|
||||
id = $team.data('id')
|
||||
for indexno, team_ of @getAllTeams()
|
||||
if team_.id is id
|
||||
team = team_
|
||||
allTeams = sortByKey(@getAllTeams(), "id")
|
||||
index = -1
|
||||
for thisteam, num in allTeams
|
||||
index = num if thisteam.id is id
|
||||
if (index is (allTeams.length - 1))
|
||||
return
|
||||
upTeam = allTeams[index + 1]
|
||||
upID = upTeam.id
|
||||
downID = team.id
|
||||
upTeam.id = downID
|
||||
team.id = upID
|
||||
team.save()
|
||||
upTeam.save()
|
||||
@resetTeams(PokeBattle.TeamStore)
|
||||
@renderTeams()
|
||||
|
||||
sortByKey = (array, key) ->
|
||||
array.sort (a,b) ->
|
||||
if a[key] < b[key]
|
||||
-1
|
||||
else if a[key] > b[key]
|
||||
1
|
||||
else
|
||||
0
|
||||
Reference in New Issue
Block a user