Différences entre les versions de « MediaWiki:Common.js »

De Encyclopédie francophone de la Roue du Temps
Aller à la navigation Aller à la recherche
(Page créée avec « $(function() { $('.mw-information-box .mw-gallery').each(function() { var $gallery = $(this); var $tabs = $gallery.find('.mw-gallery-tabs button'); var $... »)
 
Ligne 7 : Ligne 7 :
     $gallery.on('click', 'button[data-target]', function() {
     $gallery.on('click', 'button[data-target]', function() {
       var target = $(this).data('aria-controls');
       var target = $(this).data('aria-controls');
console.log(target);


       $tabs.each(function() {
       $tabs.each(function() {
         var $this = $(this);
         var $this = $(this);
         var active = $this.data('aria-controls') === target;
         var active = $this.data('aria-controls') === target;
console.log(this, active);


         $this
         $this
Ligne 21 : Ligne 23 :
         var $this = $(this);
         var $this = $(this);
         var active = $this.attr('id') === target;
         var active = $this.attr('id') === target;
 
console.log(this, active);
         $this.toggleClass('active', active);
         $this.toggleClass('active', active);
       });
       });

Version du 23 novembre 2023 à 21:19

$(function() {
  $('.mw-information-box .mw-gallery').each(function() {
    var $gallery = $(this);
    var $tabs = $gallery.find('.mw-gallery-tabs button');
    var $panes = $gallery.find('.mw-gallery-panes .mw-gallery-pane');

    $gallery.on('click', 'button[data-target]', function() {
      var target = $(this).data('aria-controls');
console.log(target);

      $tabs.each(function() {
        var $this = $(this);
        var active = $this.data('aria-controls') === target;
console.log(this, active);

        $this
          .toggleClass('active', active)
          .attr('aria-selected', active ? 'true' : 'false')
        ;
      });

      $panes.each(function() {
        var $this = $(this);
        var active = $this.attr('id') === target;
console.log(this, active);
        $this.toggleClass('active', active);
      });
    });
  });
});