Keep newly opened format folders visible

Normally, when navigating away from an empty format folder, it'll
disappear from the folder list. This keeps the folder visible if you
just opened it from a team selector or the 'New format folder'
button, so you can drag teams from other folders to that folder.
This commit is contained in:
Guangcong Luo 2015-12-16 01:09:48 -05:00
parent c00e4088d7
commit 69cb27b596
2 changed files with 26 additions and 25 deletions

View File

@ -827,8 +827,8 @@
initialize: function (data) {
var curFormat = data.format;
this.onselect = data.onselect;
var selectType = (this.sourceEl.closest('form').data('search') ? 'search' : 'challenge');
if (this.sourceEl.hasClass('teambuilderformatselect')) selectType = 'teambuilder';
var selectType = data.selectType;
if (!selectType) selectType = (this.sourceEl.closest('form').data('search') ? 'search' : 'challenge');
var bufs = [];
var curBuf = 0;
var curSection = '';
@ -972,8 +972,7 @@
app.joinRoom('teambuilder');
var teambuilder = app.rooms['teambuilder'];
if (!teambuilder.exportMode && !teambuilder.curTeam && teamFormat) {
teambuilder.curFormat = teamFormat;
teambuilder.update();
teambuilder.selectFolder(teamFormat);
}
},
selectTeam: function (i) {

View File

@ -29,6 +29,7 @@
this.saveFlag = false;
app.user.trigger('saveteams');
}
this.curFormatKeep = '';
},
events: {
// team changes
@ -171,20 +172,22 @@
buf += '<div class="folder' + (!this.curFormat ? ' cur"><div class="folderhack3"><div class="folderhack1"></div><div class="folderhack2"></div>' : '">') + '<div class="selectFolder" data-value="all">(all)</div></div>' + (!this.curFormat ? '</div>' : '');
var folderTable = {};
var folders = [];
if (Storage.teams) for (var i = -1; i < Storage.teams.length; i++) {
if (Storage.teams) for (var i = -2; i < Storage.teams.length; i++) {
var format;
if (i >= 0) {
format = Storage.teams[i].format;
} else {
if (i === -2) {
format = this.curFormatKeep;
} else if (i === -1) {
format = this.curFormat;
} else {
format = Storage.teams[i].format;
if (!format || format === 'gen6') {
if ('gen6' in folderTable) continue;
folderTable['gen6'] = 1;
folders.push('A~');
continue;
}
}
if (!format || format === 'gen6') {
if (i < 0 && format) continue;
if ('gen6' in folderTable) continue;
folderTable['gen6'] = 1;
folders.push('A~');
continue;
}
if (!format) continue;
if (format in folderTable) continue;
folderTable[format] = 1;
switch (format.slice(0, 4)) {
@ -321,10 +324,15 @@
format = $(e.currentTarget).data('value');
e.preventDefault();
if (format === '+') {
this.format('', e.currentTarget);
e.stopImmediatePropagation();
var self = this;
app.addPopup(FormatPopup, {format: '', sourceEl: e.currentTarget, selectType: 'teambuilder', onselect: function (newFormat) {
self.changeFormat(newFormat);
}});
return;
}
} else {
this.curFormatKeep = format;
}
this.curFormat = (format === 'all' ? '' : format);
this.updateFolderList();
@ -892,15 +900,9 @@
return;
}
var self = this;
if (this.curTeam) {
app.addPopup(FormatPopup, {format: format, sourceEl: button, onselect: function (newFormat) {
self.changeFormat(newFormat);
}});
} else {
app.addPopup(FormatPopup, {format: format, sourceEl: button, onselect: function (newFormat) {
self.selectFolder(newFormat);
}});
}
app.addPopup(FormatPopup, {format: format, sourceEl: button, selectType: 'teambuilder', onselect: function (newFormat) {
self.changeFormat(newFormat);
}});
},
changeFormat: function (format) {
this.curTeam.format = format;