whistles icon indicating copy to clipboard operation
whistles copied to clipboard

Allow user to set "active" section

Open justintadlock opened this issue 11 years ago • 4 comments

For tabs, toggles, and accordions, the user should be able to set an active section. Something like:

[whistles active="1]

And, setting it to 0 should make no section active for toggles/accordions and leave first section active for tabs.

justintadlock avatar Sep 11 '13 01:09 justintadlock

I am having this same problem, where I am unable to have the first whistle in a group "closed". The code I am currently using is [whistles type="accordion" group="information" order="DESC" orderby="title" limit="-2"]. I tried adding active="0" into this but it didn't change anything. I am quite new to this so I could be doing something wrong but anything I have tried either leaves the first whistle "open" or stops the whistle group from showing at all. Do you have any advise please?

jesschri avatar Dec 28 '13 11:12 jesschri

Good idea. Would also love to have this feature.

matthiaspabst avatar Jan 08 '14 13:01 matthiaspabst

I might send a PR for this some time but for now if you just want to prevent the first item from being open by default, you can remove the code that shows and selects the item in the JavaScript. Since I was using the whistles accordion, I commented out the following lines in whistles.js:

//jQuery( '.whistles-accordion .whistle-content:first-of-type' ).show();
//jQuery( '.whistles-accordion .whistle-title:first-of-type' ).attr( 'aria-selected', 'true' );

And compiled that to whistles.min.js, and updated the date to the current date for this script in whistles.php:

wp_register_script( 
  'whistles', 
  WHISTLES_URI . 'js/whistles.min.js', 
  array( 'jquery' ),
  '20140530',
  true
);

nikolas avatar May 30 '14 17:05 nikolas

Hi @nikolas - thank you for this, it has helped me out. I commented out the two lines as suggested and then compiled it to whistles.min.js, and it prevented the first item from being open by default. Great!

I haven't carried out the final step though, namely updating the date to the current date for this script in whistles.php. Is this necessary? Excuse my niavety but what is the purpose of this final step?

jamesdanielclark avatar Jul 17 '14 12:07 jamesdanielclark