MediaWiki:Fusion/scripts/Sidebar.js: Unterschied zwischen den Versionen

aus Memory Alpha, der freien deutschen Star-Trek-Datenbank
Spring zu: Navigation, suche
imported>Shisma
(extra javascript für die sidebar angelegt)
 
imported>Shisma
(+sidebar)
Zeile 1: Zeile 1:
 +
 
(function ($) {
 
(function ($) {
 
   $(function() {
 
   $(function() {
     console.log('Sidebar.js funktioniert');
+
      
 +
    $('.sidebar-division').each(function() {
 +
      var divisionHeader = $(this).children('.division-header');
 +
      var expandabilityIndicator = '<span class="expandability-indicator">&hellip;</span>';
 +
 +
      var divisionLabel = divisionHeader.html();
 +
      var cookieName = divisionLabel.toLowerCase().replace(/(<([^>]+)>)/ig,"");
 +
 +
      $(divisionHeader).append(expandabilityIndicator);
 +
 +
      if($.cookie('sidebar-division-state-' + cookieName) == 'collapsed') {
 +
        $(this).addClass('collapsed').children('.division-header').siblings().hide();
 +
      } else {
 +
        $(this).find('.expandability-indicator').hide(); 
 +
      }
 +
    });
 +
 +
    $('.division-header').css({cursor:'pointer'}).click(function() {
 +
 +
      var wrapper = $(this).parent();
 +
 +
      if(wrapper.hasClass('collapsed')) {
 +
 +
        var divisionLabel = $(this).children('strong').html();
 +
        var cookieName = divisionLabel.toLowerCase().replace(/(<([^>]+)>)/ig,"");
 +
 +
        $(this).siblings().slideDown('slow');
 +
        $(this).find('.expandability-indicator').fadeOut();
 +
        wrapper.removeClass('collapsed');
 +
        $.cookie('sidebar-division-state-' + cookieName, 'expended');
 +
      } else {
 +
 +
        var divisionLabel = $(this).children('strong').html();
 +
        var cookieName = divisionLabel.toLowerCase().replace(/(<([^>]+)>)/ig,"")
 +
 +
        $(this).siblings().slideUp('slow');
 +
        $(this).find('.expandability-indicator').fadeIn();
 +
        wrapper.addClass('collapsed');
 +
        $.cookie('sidebar-division-state-' + cookieName, 'collapsed');
 +
      }
 +
    });
 +
 
   });
 
   });
 
})(jQuery);
 
})(jQuery);

Version vom 27. August 2012, 20:07 Uhr

(function ($) {
  $(function() {
    
    $('.sidebar-division').each(function() {
      var divisionHeader = $(this).children('.division-header');
      var expandabilityIndicator = '<span class="expandability-indicator">&hellip;</span>';
 
      var divisionLabel = divisionHeader.html();
      var cookieName = divisionLabel.toLowerCase().replace(/(<([^>]+)>)/ig,"");
 
      $(divisionHeader).append(expandabilityIndicator);
 
      if($.cookie('sidebar-division-state-' + cookieName) == 'collapsed') {
        $(this).addClass('collapsed').children('.division-header').siblings().hide();
      } else {
        $(this).find('.expandability-indicator').hide();   
      }
    });
 
    $('.division-header').css({cursor:'pointer'}).click(function() {
 
      var wrapper = $(this).parent();
 
      if(wrapper.hasClass('collapsed')) {
 
        var divisionLabel = $(this).children('strong').html();
        var cookieName = divisionLabel.toLowerCase().replace(/(<([^>]+)>)/ig,"");
 
        $(this).siblings().slideDown('slow');
        $(this).find('.expandability-indicator').fadeOut();
        wrapper.removeClass('collapsed');
        $.cookie('sidebar-division-state-' + cookieName, 'expended');
      } else {
 
        var divisionLabel = $(this).children('strong').html();
        var cookieName = divisionLabel.toLowerCase().replace(/(<([^>]+)>)/ig,"")
 
        $(this).siblings().slideUp('slow');
        $(this).find('.expandability-indicator').fadeIn();
        wrapper.addClass('collapsed');
        $.cookie('sidebar-division-state-' + cookieName, 'collapsed');
      }
    });
 
  });
})(jQuery);