MediaWiki:Gadget-ExplainTooltips.js: Difference between revisions

From SmashWiki, the Super Smash Bros. wiki
Jump to navigationJump to search
 
No edit summary
Line 2: Line 2:
   Useful for mobile users, since there's no mouse-over. */
   Useful for mobile users, since there's no mouse-over. */


var explain_spans = document.getElementsByClassName('explain');
$(function() {
for(var e = 0; e < explain_spans.length; e++) {
var explain_spans = document.getElementsByClassName('explain');
  explain_spans[e].onclick = function(){ toggleExplain(this); };
for(var e = 0; e < explain_spans.length; e++) {
}
  explain_spans[e].onclick = function(){ toggleExplain(this); };
function toggleExplain(e) {
}
  var old = e.getAttribute('oldContent');
function toggleExplain(e) {
  if(old && old.length > 0) {
  var old = e.getAttribute('oldContent');
    e.innerHTML = old;
  if(old && old.length > 0) {
    e.setAttribute('oldContent', '');
    e.innerHTML = old;
    e.style.borderBottom = '1px dotted';
    e.setAttribute('oldContent', '');
  } else {
    e.style.borderBottom = '1px dotted';
    e.setAttribute('oldContent', e.innerHTML);
  } else {
    e.innerHTML = e.getAttribute('title');
    e.setAttribute('oldContent', e.innerHTML);
    e.style.borderBottom = '1px dashed';
    e.innerHTML = e.getAttribute('title');
  }
    e.style.borderBottom = '1px dashed';
}
  }
}
});

Revision as of 15:35, May 16, 2019

/* Make it so users can click on "explain" spans to toggle their content.
   Useful for mobile users, since there's no mouse-over. */

$(function() {
 var explain_spans = document.getElementsByClassName('explain');
 for(var e = 0; e < explain_spans.length; e++) {
   explain_spans[e].onclick = function(){ toggleExplain(this); };
 }
 function toggleExplain(e) {
   var old = e.getAttribute('oldContent');
   if(old && old.length > 0) {
     e.innerHTML = old;
     e.setAttribute('oldContent', '');
     e.style.borderBottom = '1px dotted';
   } else {
     e.setAttribute('oldContent', e.innerHTML);
     e.innerHTML = e.getAttribute('title');
     e.style.borderBottom = '1px dashed';
   }
 }
});