53,110
edits
(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).data('active-style') !== undefined) { | if ($(this).data('active-style') !== undefined) { | ||
$(this).data('inactive-style', $(this).attr('style')); | |||
if ($(this).hasClass("clicktoggle-active")) { | |||
$(this).attr('style', $(this).data('active-style')); | |||
} | |||
} | } | ||
$(this).click(function() { | $(this).click(function() { | ||
$(this). | if (type == 'toggle') { | ||
if ($(this).hasClass('clicktoggle-active')) { | |||
$(this).removeClass("clicktoggle-active"); | |||
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"); | |||
$(document).find('.clicktoggle').each( function () { | |||
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 (type == 'set') { | } else if (type == 'set') { | ||
Line 588: | Line 597: | ||
$(function() { | $(function() { | ||
clickToggleInit(); | |||
}); | }); | ||
/* </pre> */ | /* </pre> */ |