| ... |
... |
@@ -1,7 +1,7 @@ |
| 1 |
1 |
require(['jquery'], function($) { |
| 2 |
2 |
function onClick () { |
| 3 |
3 |
var button = $(this), |
| 4 |
|
- content = button.closest('.showhide-header').next('.showhidecontent'), |
|
4 |
+ content = button.parent().next(), |
| 5 |
5 |
effect = button.attr('data-show-effect'), |
| 6 |
6 |
data = button.data(); |
| 7 |
7 |
|
| ... |
... |
@@ -8,12 +8,15 @@ |
| 8 |
8 |
if ($.inArray(effect, ['toggle', 'fadeToggle', 'slideToggle']) == -1) |
| 9 |
9 |
effect = 'toggle'; |
| 10 |
10 |
|
|
11 |
+ // Toggle-Zustand berechnen |
| 11 |
11 |
data.showHideState = !(('showHideState' in data) ? data.showHideState : content.is(':visible')); |
| 12 |
12 |
|
|
14 |
+ // Pfeil und Text setzen |
| 13 |
13 |
var message = button.attr(data.showHideState ? 'data-hide-message' : 'data-show-message'); |
| 14 |
14 |
var icon = data.showHideState ? '▼ ' : '► '; |
| 15 |
15 |
button.html(icon + message); |
| 16 |
16 |
|
|
19 |
+ // Inhalt ein-/ausblenden |
| 17 |
17 |
content.stop()[effect](parseInt(button.attr('data-show-duration'))); |
| 18 |
18 |
|
| 19 |
19 |
return false; |