AnnotationPanel: handle case where removing languages leaves one previously disabled language (fixes #2454)

This commit is contained in:
rlx 2014-09-03 13:23:19 +02:00
parent dd83182f22
commit 5aaeda46c5

View file

@ -562,11 +562,24 @@ Ox.AnnotationPanel = function(options, self) {
enabledLanguages = self.enabledLanguages;
self.languages = getLanguages();
self.enabledLanguages = self.languages.filter(function(language) {
// enabled if it was enabled, was just added, or is the only
// language
return Ox.contains(enabledLanguages, language)
|| !Ox.contains(languages, language);
|| !Ox.contains(languages, language)
|| self.languages.length == 1;
}).map(function(language) {
return language.code;
});
if (
self.languages.length == 1
&& !Ox.contains(enabledLanguages, self.languages[0].code)
) {
// last remaining language was enabled by removing all other
// languages
self.$folder.forEach(function($folder) {
$folder.options({languages: self.enabledLanguages});
});
}
}
/*@