PageSourceSearch

https://fondationbodmer.ch/wp-content/plugins/smooth-accordion/assets/js/smoothaccordion.js?ver=1.1

js fondationbodmer.ch collected 2026-09-24 21:11:05 UTC 6,272 bytes, 203 lines download raw bytes

1if(typeof($add)=="undefined")var $add={version:{},auto:{disabled:false}};(function($){
2  $add.version.Accordion = "1.0.0";
3  $add.Accordion = function(selector, settings){
4    $(selector).each(function(i, el){
5      var $el = $(el);
6      if($el.hasClass("smooth-Accordion")) return;
7      $el.addClass("smooth-Accordion");
8      var S = $.extend({
9        initial: 0,
10        change: "click",
11        maxOpened: 1
12      }, $el.data(), settings);
13
14      if(S.change == "hover"){
15        S.change = "mouseover";
16      }
17      var $headers = $el.find("[role=header]").addClass("smooth-Accordion-header");
18      var $contents = $el.find("[role=content]").addClass("smooth-Accordion-content").hide();
19
20      $headers.eq(0).addClass("smooth-Accordion-first");
21      $contents.eq(0).addClass("smooth-Accordion-first");
22      $headers.last().addClass("smooth-Accordion-last");
23      $contents.last().addClass("smooth-Accordion-last");
24
25      function countOpen(){
26        var count = 0;
27        $headers.each(function(i, header){
28          if($(header).hasClass("smooth-Accordion-open")){
29            count++;
30          }
31        });
32        return count;
33      }
34      function open(index){
35        if(S.maxOpened && countOpen() >= S.maxOpened){
36          // closeLastOpen();
37        }
38        $headers.eq(index).addClass("smooth-Accordion-open");
39        $contents.eq(index).addClass("smooth-Accordion-open").slideDown({duration:100});
40      }
41      function close(index){
42        $headers.eq(index).removeClass("smooth-Accordion-open");
43        $contents.eq(index).removeClass("smooth-Accordion-open").slideUp({duration:100});
44      }
45      function closeAll(){
46        $headers.removeClass("smooth-Accordion-open");
47        $content.removeClass("smooth-Accordion-open").slideUp({duration:100});
48      }
49      function closeLastOpen(){
50        var lastOpenIndex = 0;
51        $headers.each(function(i, header){
52          if($(header).hasClass("smooth-Accordion-open")){
53            lastOpenIndex = i;
54          }
55        });
56        close(lastOpenIndex);
57      }
58      function toggle(index){
59        if($headers.eq(index).hasClass("smooth-Accordion-open")){
60          close(index);
61        } else {
62          open(index);
63        }
64      }
65
66      $headers.each(function(i, header){
67        var $header = $(header);
68        $header.on(S.change, function(){
69          if(S.change == "mouseover"){
70            if(!$header.hasClass("smooth-Accordion-open")){
71              open(i);
72            }
73          } else {
74            toggle(i);
75          }
76        });
77      })
78
79      if(S.initial instanceof Array){
80        for(var i=0 ;i<S.initial.length; i++){
81          $contents.eq(S.initial[i]).show();
82          open(S.initial[i]);
83        }
84      } else {
85        $contents.eq(S.initial).show();
86        open(S.initial);
87      }
88    });
89  };
90  $.fn.addAccordion = function(settings){
91    $add.Accordion(this, settings);
92  };
93  $add.auto.Accordion = function(){
94    if(!$add.auto.disabled){
95      $("[data-smooth=accordion]").addAccordion();
96    }
97  };
98})(jQuery);
99jQuery(function(){for(var k in $add.auto){if(typeof($add.auto[k])=="function"){$add.auto[k]();}}});
100
101
102// _Accordion
103(function($){
104  $add.version.Accordion = "1.0.0";
105  $add.Accordion = function(selector, settings){
106    $(selector).each(function(i, el){
107      var $el = $(el);
108      if($el.hasClass("smooth-Accordion")) return;
109      $el.addClass("smooth-Accordion");
110      var S = $.extend({
111        initial: 0,
112        change: "click",
113        maxOpened: 1
114      }, $el.data(), settings);
115
116      if(S.change == "hover"){
117        S.change = "mouseover";
118      }
119      if(typeof(S.inital) == "string" && S.initial.indexOf(",")){
120        S.initial = S.initial.split(",");
121      }
122      var $headers = $el.find("[role=header]").addClass("smooth-Accordion-header");
123      var $contents = $el.find("[role=content]").addClass("smooth-Accordion-content").hide();
124
125      $headers.eq(0).addClass("smooth-Accordion-first");
126      $contents.eq(0).addClass("smooth-Accordion-first");
127      $headers.last().addClass("smooth-Accordion-last");
128      $contents.last().addClass("smooth-Accordion-last");
129
130      function countOpen(){
131        var count = 0;
132        $headers.each(function(i, header){
133          if($(header).hasClass("smooth-Accordion-open")){
134            count++;
135          }
136        });
137        return count;
138      }
139      function open(index){
140        if(S.maxOpened && countOpen() >= S.maxOpened){
141          //closeLastOpen();
142        }
143        $headers.eq(index).addClass("smooth-Accordion-open");
144        $contents.eq(index).addClass("smooth-Accordion-open").slideDown({duration:100});
145      }
146      function close(index){
147        $headers.eq(index).removeClass("smooth-Accordion-open");
148        $contents.eq(index).removeClass("smooth-Accordion-open").slideUp({duration:100});
149      }
150      function closeAll(){
151        $headers.removeClass("smooth-Accordion-open");
152        $content.removeClass("smooth-Accordion-open").slideUp({duration:100});
153      }
154      function closeLastOpen(){
155        var lastOpenIndex = 0;
156        $headers.each(function(i, header){
157          if($(header).hasClass("smooth-Accordion-open")){
158            lastOpenIndex = i;
159          }
160        });
161        close(lastOpenIndex);
162      }
163      function toggle(index){
164        if($headers.eq(index).hasClass("smooth-Accordion-open")){
165          close(index);
166        } else {
167          open(index);
168        }
169      }
170
171      $headers.each(function(i, header){
172        var $header = $(header);
173        $header.on(S.change, function(){
174          if(S.change == "mouseover"){
175            if(!$header.hasClass("smooth-Accordion-open")){
176              open(i);
177            }
178          } else {
179            toggle(i);
180          }
181        });
182      })
183
184      if(S.initial instanceof Array){
185        for(var i=0 ;i<S.initial.length; i++){
186          $contents.eq(S.initial[i]).show();
187          open(S.initial[i]);
188        }
189      } else {
190        $contents.eq(S.initial).show();
191        open(S.initial);
192      }
193    });
194  };
195  $.fn.addAccordion = function(settings){
196    $add.Accordion(this, settings);
197  };
198  $add.auto.Accordion = function(){
199    if(!$add.auto.disabled){
200      $("[data-smooth=accordion]").addAccordion();
201    }
202  };
203})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.