MediaWiki:Common.js: Difference between revisions

From SEGGER Knowledge Base
Jump to navigation Jump to search
No edit summary
No edit summary
Line 2: Line 2:


/* Add icons to expandable entries in TOC */
/* Add icons to expandable entries in TOC */
$(document).ready(function(){
//$(document).ready(function(){
  $('#toc li a').each(function(a,b){
//  $('#toc li a').each(function(a,b){
    var numSiblings = $(this).siblings('ul:hidden').size();
//    var numSiblings = $(this).siblings('ul:hidden').size();
    if (numSiblings > 0) {
//    if (numSiblings > 0) {
      $(this).before(' <span class="toggleicon">[]</span> ');
//      $(this).before(' <span class="toggleicon">[]</span> ');
      updateIcons();
//      updateIcons();
    }
//    }
  });
//  });
});
//});




$('#toc span.toggleicon').click(function(){
//$('#toc span.toggleicon').click(function(){
  $(this).siblings('ul').toggle({
//  $(this).siblings('ul').toggle({
    duration: 200,
//    duration: 200,
    complete: updateIcons
//    complete: updateIcons
  });
//  });
});
//});




function updateIcons() {
//function updateIcons() {
  $('#toc span.toggleicon').each(function(){
//  $('#toc span.toggleicon').each(function(){
    if ($(this).siblings('ul').first().is(':hidden')) {
//    if ($(this).siblings('ul').first().is(':hidden')) {
      $(this).html('[&plus;]');
//      $(this).html('[&plus;]');
    } else {
//    } else {
      $(this).html('[&minus;]');
//      $(this).html('[&minus;]');
    }
//    }
  })
//  })
}
//}

Revision as of 19:50, 29 March 2019

/* Any JavaScript here will be loaded for all users on every page load. */

/* Add icons to expandable entries in TOC */
//$(document).ready(function(){
//  $('#toc li a').each(function(a,b){
//    var numSiblings = $(this).siblings('ul:hidden').size();
//    if (numSiblings > 0) {
//      $(this).before(' <span class="toggleicon">[]</span> ');
//      updateIcons();
//    }
//  });
//});


//$('#toc span.toggleicon').click(function(){
//  $(this).siblings('ul').toggle({
//    duration: 200,
//    complete: updateIcons
//  });
//});


//function updateIcons() {
//  $('#toc span.toggleicon').each(function(){
//    if ($(this).siblings('ul').first().is(':hidden')) {
//      $(this).html('[&plus;]');
//    } else {
//      $(this).html('[&minus;]');
//    }
//  })
//}