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:
@@ -452,6 +452,12 @@ h1{font-family:"PT Sans Narrow","Helvetica Neue",sans-serif;font-size:2em;font-w
|
||||
100%{-webkit-transform:translate(200%,100%);-moz-transform:translate(200%,100%);-o-transform:translate(200%,100%);-ms-transform:translate(200%,100%);transform:translate(200%,100%)}
|
||||
}.Team-Admin{border:1px solid #000;width:40%;margin-left:10px}
|
||||
.teambuilder input,.teambuilder select{-webkit-box-sizing:border-box;-moz-box-sizing:border-box;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%;}
|
||||
.arrow-up:hover{border-bottom-color:#a8a8a8}
|
||||
.arrow-up: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%;}
|
||||
.arrow-down:hover{border-top-color:#a8a8a8}
|
||||
.arrow-down:active{border-top-color:#696969}
|
||||
.teambuilder .selectize-input input{height:18px}
|
||||
.teambuilder{position:absolute;top:0;bottom:0;left:0;right:0;}
|
||||
.teambuilder select,.teambuilder input{margin-bottom:0 !important;width:100%}
|
||||
|
||||
@@ -6338,9 +6338,13 @@
|
||||
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
|
||||
|
||||
this.TeambuilderView = (function(_super) {
|
||||
var sortByKey;
|
||||
|
||||
__extends(TeambuilderView, _super);
|
||||
|
||||
function TeambuilderView() {
|
||||
this.moveTeamDown = __bind(this.moveTeamDown, this);
|
||||
this.moveTeamUp = __bind(this.moveTeamUp, this);
|
||||
this.renderSaved = __bind(this.renderSaved, this);
|
||||
this.renderSaving = __bind(this.renderSaving, this);
|
||||
this.validateImportedTeam = __bind(this.validateImportedTeam, this);
|
||||
@@ -6404,6 +6408,8 @@
|
||||
'click .go-to-team': 'clickTeam',
|
||||
'click .import-team': 'renderImportTeamModal',
|
||||
'click .get-teams': 'getAllTeamsAdmin',
|
||||
'click .arrow-up': 'moveTeamUp',
|
||||
'click .arrow-down': 'moveTeamDown',
|
||||
'click .change-format-dropdown a': 'changeTeamFormat',
|
||||
'blur .team_name': 'blurTeamName',
|
||||
'keypress .team_name': 'keypressTeamName',
|
||||
@@ -6591,7 +6597,6 @@
|
||||
jint = jint + 1;
|
||||
}
|
||||
_this.getTeam(id).save();
|
||||
$modal.find('.imported-team').val("");
|
||||
$modal.modal('hide');
|
||||
}
|
||||
return false;
|
||||
@@ -6716,8 +6721,10 @@
|
||||
};
|
||||
|
||||
TeambuilderView.prototype.renderTeams = function() {
|
||||
var allteams;
|
||||
allteams = sortByKey(this.getAllTeams(), "id");
|
||||
this.$('.display_teams').html(this.teamsTemplate({
|
||||
teams: this.getAllTeams(),
|
||||
teams: allteams,
|
||||
window: window
|
||||
}));
|
||||
this.$('.display_teams').removeClass('hidden');
|
||||
@@ -6860,6 +6867,86 @@
|
||||
return $team.find('.show_spinner').addClass('hidden');
|
||||
};
|
||||
|
||||
TeambuilderView.prototype.moveTeamUp = function(e) {
|
||||
var $team, allTeams, downID, id, index, indexno, num, team, team_, thisteam, upID, upTeam, _i, _len, _ref;
|
||||
this.resetTeams(PokeBattle.TeamStore);
|
||||
$team = $(e.currentTarget).closest('.select-team');
|
||||
id = $team.data('id');
|
||||
_ref = this.getAllTeams();
|
||||
for (indexno in _ref) {
|
||||
team_ = _ref[indexno];
|
||||
if (team_.id === id) {
|
||||
team = team_;
|
||||
}
|
||||
}
|
||||
allTeams = sortByKey(this.getAllTeams(), "id");
|
||||
index = -1;
|
||||
for (num = _i = 0, _len = allTeams.length; _i < _len; num = ++_i) {
|
||||
thisteam = allTeams[num];
|
||||
if (thisteam.id === id) {
|
||||
index = num;
|
||||
}
|
||||
}
|
||||
if (index === 0) {
|
||||
return;
|
||||
}
|
||||
upTeam = allTeams[index - 1];
|
||||
upID = upTeam.id;
|
||||
downID = team.id;
|
||||
upTeam.id = downID;
|
||||
team.id = upID;
|
||||
team.save();
|
||||
upTeam.save();
|
||||
this.resetTeams(PokeBattle.TeamStore);
|
||||
return this.renderTeams();
|
||||
};
|
||||
|
||||
TeambuilderView.prototype.moveTeamDown = function(e) {
|
||||
var $team, allTeams, downID, id, index, indexno, num, team, team_, thisteam, upID, upTeam, _i, _len, _ref;
|
||||
this.resetTeams(PokeBattle.TeamStore);
|
||||
$team = $(e.currentTarget).closest('.select-team');
|
||||
id = $team.data('id');
|
||||
_ref = this.getAllTeams();
|
||||
for (indexno in _ref) {
|
||||
team_ = _ref[indexno];
|
||||
if (team_.id === id) {
|
||||
team = team_;
|
||||
}
|
||||
}
|
||||
allTeams = sortByKey(this.getAllTeams(), "id");
|
||||
index = -1;
|
||||
for (num = _i = 0, _len = allTeams.length; _i < _len; num = ++_i) {
|
||||
thisteam = allTeams[num];
|
||||
if (thisteam.id === id) {
|
||||
index = num;
|
||||
}
|
||||
}
|
||||
if (index === (allTeams.length - 1)) {
|
||||
return;
|
||||
}
|
||||
upTeam = allTeams[index + 1];
|
||||
upID = upTeam.id;
|
||||
downID = team.id;
|
||||
upTeam.id = downID;
|
||||
team.id = upID;
|
||||
team.save();
|
||||
upTeam.save();
|
||||
this.resetTeams(PokeBattle.TeamStore);
|
||||
return this.renderTeams();
|
||||
};
|
||||
|
||||
sortByKey = function(array, key) {
|
||||
return array.sort(function(a, b) {
|
||||
if (a[key] < b[key]) {
|
||||
return -1;
|
||||
} else if (a[key] > b[key]) {
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
return TeambuilderView;
|
||||
|
||||
})(Backbone.View);
|
||||
|
||||
@@ -1077,13 +1077,41 @@ buf.push("</select></div>");
|
||||
this["JST"]["teambuilder/team"] = function anonymous(locals
|
||||
/**/) {
|
||||
var buf = [];
|
||||
var locals_ = (locals || {}),team = locals_.team,window = locals_.window;buf.push("<div" + (jade.attrs({ 'data-id':(team.id), 'data-cid':(team.cid), "class": [('left'),('select-team'),('clickable-box'),('p1'),('mt1'),('ml1'),('relative')] }, {"data-id":true,"data-cid":true})) + "><h2 class=\"go-to-team fake_link\">" + (jade.escape(null == (jade.interp = team.getName()) ? "" : jade.interp)) + "</h2>" + (null == (jade.interp = window.JST['team_small']({team: team, window: window})) ? "" : jade.interp) + "<div class=\"team-meta\"><span class=\"fake_link export-team\"><span class=\"icon-upload\"></span> Text Editor</span> | <span class=\"fake_link clone-team\"><span class=\"icon-copy\"></span> Clone</span> | <span class=\"fake_link delete-team\"><span class=\"icon-remove\"></span> Delete</span></div><div class=\"show_spinner flex-center fill bg-faded-white rounded hidden\">" + (null == (jade.interp = window.JST['spinner']()) ? "" : jade.interp) + "</div></div>");;return buf.join("");
|
||||
var locals_ = (locals || {}),team = locals_.team,window = locals_.window;buf.push("<div" + (jade.attrs({ 'data-id':(team.id), 'data-cid':(team.cid), "class": [('left'),('select-team'),('clickable-box'),('p1'),('mt1'),('ml1'),('relative')] }, {"data-id":true,"data-cid":true})) + "><h2 class=\"go-to-team fake_link\">" + (jade.escape(null == (jade.interp = team.getName()) ? "" : jade.interp)) + "</h2><div class=\"arrow-up\"></div><div class=\"arrow-down\"></div>" + (null == (jade.interp = window.JST['team_small']({team: team, window: window})) ? "" : jade.interp) + "<div class=\"team-meta\"><span class=\"fake_link export-team\"><span class=\"icon-upload\"></span> Text Editor</span> | <span class=\"fake_link clone-team\"><span class=\"icon-copy\"></span> Clone</span> | <span class=\"fake_link delete-team\"><span class=\"icon-remove\"></span> Delete</span></div><div class=\"show_spinner flex-center fill bg-faded-white rounded hidden\">" + (null == (jade.interp = window.JST['spinner']()) ? "" : jade.interp) + "</div></div>");;return buf.join("");
|
||||
};
|
||||
|
||||
this["JST"]["teambuilder/teams"] = function anonymous(locals
|
||||
/**/) {
|
||||
var buf = [];
|
||||
var locals_ = (locals || {}),teams = locals_.teams,window = locals_.window;buf.push("<h2>Your teams</h2><div class=\"teambuilder_teams clearfix\">");
|
||||
// iterate teams
|
||||
;(function(){
|
||||
var $$obj = teams;
|
||||
if ('number' == typeof $$obj.length) {
|
||||
|
||||
for (var $index = 0, $$l = $$obj.length; $index < $$l; $index++) {
|
||||
var team = $$obj[$index];
|
||||
|
||||
if ( team.isDefault)
|
||||
{
|
||||
buf.push(null == (jade.interp = window.JST['teambuilder/team']({team: team, window: window})) ? "" : jade.interp);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
var $$l = 0;
|
||||
for (var $index in $$obj) {
|
||||
$$l++; var team = $$obj[$index];
|
||||
|
||||
if ( team.isDefault)
|
||||
{
|
||||
buf.push(null == (jade.interp = window.JST['teambuilder/team']({team: team, window: window})) ? "" : jade.interp);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}).call(this);
|
||||
|
||||
// iterate teams
|
||||
;(function(){
|
||||
var $$obj = teams;
|
||||
|
||||
Reference in New Issue
Block a user