MediaWiki:Common.js: Difference between revisions

no edit summary
(Provided by Tiddlywinks: Allow a single ClickToggle button to have multiple targets)
No edit summary
Line 532: Line 532:
         var group = id[0];
         var group = id[0];
         var target = id[1];
         var target = id[1];
      if ($(this).attr('style') === undefined) $(this).attr('style', '');
        if ($(this).attr('style') === undefined) $(this).attr('style', '');
         if ($(this).data('active-style') !== undefined) {
         if ($(this).data('active-style') !== undefined) {
        $(this).data('inactive-style', $(this).attr('style'));
            $(this).data('inactive-style', $(this).attr('style'));
        if ($(this).hasClass("clicktoggle-active")) {
            if ($(this).hasClass("clicktoggle-active")) {
        $(this).attr('style', $(this).data('active-style'));
                $(this).attr('style', $(this).data('active-style'));
        }
            }
         }
         }
          
          
         $(this).click(function() {
         $(this).click(function() {
             $(this).addClass("clicktoggle-active");
             if (type == 'toggle') {
            $(document).find('.clicktoggle').each( function () {
                if ($(this).hasClass('clicktoggle-active')) {
                var id2 = $(this).data('for').split(',');
                    $(this).removeClass("clicktoggle-active");
                 if (group == id2[0]) {
                    if ($(this).data('inactive-style') !== undefined) {
                $(this).removeClass("clicktoggle-active");
                        $(this).attr('style', $(this).data('inactive-style'));
            if ($(this).data('inactive-style') !== undefined) {
                    }
            $(this).attr('style', $(this).data('inactive-style'));
                 } else {
            }
                    $(this).addClass("clicktoggle-active");
                    if ($(this).data('active-style') !== undefined) {
                        $(this).attr('style', $(this).data('active-style'));
                    }
                 }
                 }
                 if (group == id2[0] && target == id2[1]) {
            } else if (type == 'set') {
                $(this).addClass("clicktoggle-active");
                 $(this).addClass("clicktoggle-active");
                if ($(this).data('active-style') !== undefined) {
                $(document).find('.clicktoggle').each( function () {
                $(this).attr('style', $(this).data('active-style'));
                    var id2 = $(this).data('for').split(',');
                }
                    if (group == id2[0]) {
                 }
                        $(this).removeClass("clicktoggle-active");
             });
                        if ($(this).data('inactive-style') !== undefined) {
                            $(this).attr('style', $(this).data('inactive-style'));
                        }
                    }
                    if (group == id2[0] && target == id2[1]) {
                        $(this).addClass("clicktoggle-active");
                        if ($(this).data('active-style') !== undefined) {
                            $(this).attr('style', $(this).data('active-style'));
                        }
                    }
                 });
             }
              
              
             $(document).find('.clicktoggle-target').each( function () {
             $(document).find('.clicktoggle-target').each( function () {
Line 568: Line 582:
                             else
                             else
                                 $(this).css('display', 'none');
                                 $(this).css('display', 'none');
                        } else {
                            if ($(this).css('display') == '')
                                $(this).css('display', 'none');
                            else
                                $(this).css('display', '');
                         }
                         }
                     } else if (type == 'set') {
                     } else if (type == 'set') {
Line 588: Line 597:


$(function() {
$(function() {
clickToggleInit();
    clickToggleInit();
});
});


/* </pre> */
/* </pre> */