1
0
mirror of https://gitlab.com/Deukhoofd/BattleSim.git synced 2025-10-27 18:00:03 +00:00

Added Team reordering

This commit is contained in:
Deukhoofd
2016-04-13 01:28:59 +02:00
parent 07dc054ca9
commit 06d84a29c6
7 changed files with 218 additions and 6 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -1,5 +1,7 @@
.left.select-team.clickable-box.p1.mt1.ml1.relative(data-id=team.id, data-cid=team.cid)
h2.go-to-team.fake_link= team.getName()
.arrow-up
.arrow-down
!= window.JST['team_small']({team: team, window: window})
.team-meta
span.fake_link.export-team
@@ -13,5 +15,6 @@
span.fake_link.delete-team
span.icon-remove
| Delete
.show_spinner.flex-center.fill.bg-faded-white.rounded.hidden
!= window.JST['spinner']()

View File

@@ -1,5 +1,8 @@
h2 Your teams
.teambuilder_teams.clearfix
each team in teams
if team.isDefault
!= window.JST['teambuilder/team']({team: team, window: window})
each team in teams
!= window.JST['teambuilder/team']({team: team, window: window})
.button.button_blue.add-new-team Add new team