Skip to content

Commit

Permalink
Add detection of fragment (opens)
Browse files Browse the repository at this point in the history
If a fragment is detected in a collapsible region, the section is opened by default.

Closed #13
  • Loading branch information
nico3333fr committed Feb 21, 2017
1 parent feedad4 commit 942cd06
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions jquery-accessible-hide-show-aria.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ jQuery(document).ready(function($){

/*
* jQuery simple and accessible hide-show system (collapsible regions), using ARIA
* @version v1.3.6
* @version v1.4.0
* Website: http://a11y.nicolas-hoffmann.net/hide-show/
* License MIT: https://github.com/nico3333fr/jquery-accessible-hide-show-aria/blob/master/LICENSE
*/
Expand All @@ -15,7 +15,8 @@ jQuery(document).ready(function($){
$expandmore = $('.js-expandmore'),
$to_expand = $('.js-to_expand'),
$body = $('body'),
delay = 1500;
delay = 1500,
hash = window.location.hash.replace( "#", "" );


if ( $expandmore.length && $to_expand.length ) { // if there are at least one :)
Expand Down Expand Up @@ -44,13 +45,14 @@ jQuery(document).ready(function($){
$to_expand.attr('id', 'expand_' + index_lisible);
$to_expand.attr(attr_hidden, 'true');
$to_expand.attr(attr_labelledby, 'label_expand_' + index_lisible);
// quick tip to open
if ($to_expand.hasClass('is-opened') ){

// quick tip to open (if it has class is-opened or if hash is in expand)
if ($to_expand.hasClass('is-opened') || ( hash !== "" && $to_expand.find($( "#" + hash )).length ) ){
$button.addClass('is-opened').attr(attr_expanded, 'true');
$to_expand.removeClass('is-opened').removeAttr(attr_hidden);
}


});


Expand Down Expand Up @@ -94,7 +96,6 @@ jQuery(document).ready(function($){


});



});

0 comments on commit 942cd06

Please sign in to comment.