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';
|
var next = current === 'public' ? 'private' : 'public';
|
||||||
btn.dataset.visibility = next;
|
btn.dataset.visibility = next;
|
||||||
btn.textContent = next;
|
btn.textContent = next;
|
||||||
btn.className = btn.className.replace(' public', '');
|
btn.classList.toggle('public', next === 'public');
|
||||||
if (next === 'public') btn.className += ' public';
|
|
||||||
fetch('/api/visibility/' + encodeURIComponent(repo), {
|
fetch('/api/visibility/' + encodeURIComponent(repo), {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'application/json' },
|
headers: { 'Content-Type': 'application/json' },
|
||||||
body: JSON.stringify({ visibility: next })
|
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