MCPcopy
hub / github.com/9001/copyparty / clmod

Function clmod

copyparty/web/util.js:523–552  ·  view source on GitHub ↗
(el, cls, add)

Source from the content-addressed store, hash-verified

521
522
523function clmod(el, cls, add) {
524 if (!el)
525 return false;
526
527 if (el.classList) {
528 var have = el.classList.contains(cls);
529 if (add == 't')
530 add = !have;
531
532 if (!add == !have)
533 return false;
534
535 el.classList[add ? 'add' : 'remove'](cls);
536 return true;
537 }
538
539 var re = new RegExp('\\s*\\b' + cls + '\\s*\\b', 'g'),
540 n1 = el.className;
541
542 if (add == 't')
543 add = !re.test(n1);
544
545 var n2 = n1.replace(re, ' ') + (add ? ' ' + cls : '');
546
547 if (n1 == n2)
548 return false;
549
550 el.className = n2;
551 return true;
552}
553
554
555function clgot(el, cls) {

Callers 15

raverFunction · 0.85
meadup.jsFile · 0.85
bcfg_upd_uiFunction · 0.85
util.jsFile · 0.85
scrollchkFunction · 0.85
unscrollFunction · 0.85
md_changedFunction · 0.85
save_cbFunction · 0.85
add_dlsFunction · 0.85
setosFunction · 0.85
browser.jsFile · 0.85
gotoFunction · 0.85

Calls 1

testMethod · 0.45

Tested by

no test coverage detected