forked from defunkt/toes
Use classList.toggle instead of className replace
This commit is contained in:
parent
c81513b0ea
commit
0f197849b6
|
|
@ -23,12 +23,15 @@ function toggleVisibility(btn) {
|
|||
var next = current === 'public' ? 'private' : 'public';
|
||||
btn.dataset.visibility = next;
|
||||
btn.textContent = next;
|
||||
btn.className = btn.className.replace(' public', '');
|
||||
if (next === 'public') btn.className += ' public';
|
||||
btn.classList.toggle('public', next === 'public');
|
||||
fetch('/api/visibility/' + encodeURIComponent(repo), {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ visibility: next })
|
||||
}).catch(function() {
|
||||
btn.dataset.visibility = current;
|
||||
btn.textContent = current;
|
||||
btn.classList.toggle('public', current === 'public');
|
||||
});
|
||||
}
|
||||
`
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user