Adds the possibility to put sections (of formats) in other columns by changing it serverside

This commit is contained in:
Quinella 2013-09-23 18:43:55 +02:00
parent 99cf301eba
commit 51ecb2a6e6
2 changed files with 36 additions and 7 deletions

View File

@ -609,7 +609,7 @@
initialize: function(data) {
var curFormat = data.format;
var selectType = (this.sourceEl.closest('form').data('search') ? 'search' : 'challenge');
var bufs = ['',''];
var bufs = [];
var curBuf = 0;
var curSection = '';
for (var i in BattleFormats) {
@ -620,17 +620,33 @@
if (format.section && format.section !== curSection) {
curSection = format.section;
curBuf = (curSection === 'Doubles' || curSection === 'Past Generations') ? 1 : 0;
if (!BattleFormats._supportsColumns) {
curBuf = (curSection === 'Doubles' || curSection === 'Past Generations') ? 1 : 0;
} else {
curBuf = format.column || 0;
}
if (!bufs[curBuf]) {
bufs[curBuf] = '';
}
bufs[curBuf] += '<li><h3>'+Tools.escapeHTML(curSection)+'</li>';
}
bufs[curBuf] += '<li><button name="selectFormat" value="' + i + '"' + (curFormat === i ? ' class="sel"' : '') + '>' + Tools.escapeHTML(format.name) + '</button></li>';
}
if (bufs[1]) {
this.$el.html('<ul class="popupmenu" style="float:left">'+bufs[0]+'</ul><ul class="popupmenu" style="float:left;padding-left:5px">'+bufs[1]+'</ul><div style="clear:left"></div>');
} else {
this.$el.html('<ul class="popupmenu">'+bufs[0]+'</ul>');
var html = '';
for (var i = 0, l = bufs.length; i < l; i++) {
html += '<ul class="popupmenu"';
if (l > 1) {
html += ' style="float:left';
if (i > 0) {
html += ';padding-left:5px';
}
html += '"';
}
html += '>' + bufs[i] + '</ul>';
}
html += '<div style="clear:left"></div>';
this.$el.html(html);
},
selectFormat: function(format) {
var $teamButton = this.sourceEl.closest('form').find('button[name=team]');

View File

@ -919,13 +919,23 @@
parseFormats: function(formatsList) {
var isSection = false;
var section = '';
var column = 0;
var columnChanged = false;
BattleFormats = {};
for (var j=1; j<formatsList.length; j++) {
if (isSection) {
section = formatsList[j];
isSection = false;
} else if (formatsList[j] === '') {
} else if (formatsList[j] === '' || !isNaN(formatsList[j])) {
isSection = true;
var newColumn = parseInt(formatsList[j]) || 0;
if (column !== newColumn) {
column = newColumn;
columnChanged = true;
}
} else {
var searchShow = true;
var challengeShow = true;
@ -958,6 +968,7 @@
name: $.trim(name.substr(0, parenPos)),
team: team,
section: section,
column: column,
rated: challengeShow && searchShow,
isTeambuilderFormat: true,
effectType: 'Format'
@ -974,6 +985,7 @@
name: name,
team: team,
section: section,
column: column,
searchShow: searchShow,
challengeShow: challengeShow,
rated: challengeShow && searchShow,
@ -983,6 +995,7 @@
};
}
}
BattleFormats._supportsColumns = columnChanged;
this.trigger('init:formats');
},
uploadReplay: function(data) {