@@ -29,6 +29,15 @@ function scrollToAnchor(target) {
29
29
} , 400 , 'swing' , function ( ) {
30
30
window . location . hash = target ;
31
31
} ) ;
32
+
33
+ // Unique accordion functionality
34
+ // If the target is an accordion element, open the accordion after scrolling
35
+ if ( $target . hasClass ( 'expand' ) ) {
36
+ if ( $ ( target + ' .expand-label .expand-toggle' ) . hasClass ( 'open' ) ) { }
37
+ else {
38
+ $ ( target + '> .expand-label' ) . trigger ( 'click' ) ;
39
+ } ;
40
+ } ;
32
41
}
33
42
}
34
43
@@ -140,13 +149,36 @@ $(".truncate-toggle").click(function(e) {
140
149
$ ( this ) . closest ( '.truncate' ) . toggleClass ( 'closed' ) ;
141
150
} )
142
151
143
- ////////////////////////////// Expand Accordians ///////////////////////////////
152
+ ////////////////////////////// Expand Accordions ///////////////////////////////
144
153
145
154
$ ( '.expand-label' ) . click ( function ( ) {
146
155
$ ( this ) . children ( '.expand-toggle' ) . toggleClass ( 'open' )
147
156
$ ( this ) . next ( '.expand-content' ) . slideToggle ( 200 )
148
157
} )
149
158
159
+ // Expand accordions on load based on URL anchor
160
+ function openAccordionByHash ( ) {
161
+ var anchor = window . location . hash ;
162
+
163
+ function expandElement ( ) {
164
+ if ( $ ( anchor ) . parents ( '.expand' ) . length > 0 ) {
165
+ return $ ( anchor ) . closest ( '.expand' ) . children ( '.expand-label' ) ;
166
+ } else if ( $ ( anchor ) . hasClass ( 'expand' ) ) {
167
+ return $ ( anchor ) . children ( '.expand-label' ) ;
168
+ }
169
+ } ;
170
+
171
+ if ( expandElement ( ) != null ) {
172
+ if ( expandElement ( ) . children ( '.expand-toggle' ) . hasClass ( 'open' ) ) { }
173
+ else {
174
+ expandElement ( ) . children ( '.expand-toggle' ) . trigger ( 'click' ) ;
175
+ } ;
176
+ } ;
177
+ } ;
178
+
179
+ // Open accordions by hash on page load.
180
+ openAccordionByHash ( )
181
+
150
182
////////////////////////// Inject tooltips on load //////////////////////////////
151
183
152
184
$ ( '.tooltip' ) . each ( function ( ) {
0 commit comments