-
Notifications
You must be signed in to change notification settings - Fork 119
Bootstrapped Accordions on Write Plan page #629
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,27 @@ | ||
| <!--show annotations. annotation is passed as an argument--> | ||
| <h3 class="accordion_heading_text"> | ||
| <%= (plan.template.org.abbreviation.present? ? plan.template.org.abbreviation : plan.template.org.name) %> | ||
| <% if annotation.example_answer? %> | ||
| <%= _('Example Answer') %> | ||
| <% else %> | ||
| <%= _('Guidance') %> | ||
| <% end %> | ||
| <span class="fa fa-plus" aria-hidden="true"></span> | ||
| </h3> | ||
| <div class="panel panel-default"> | ||
| <div class="panel-heading" role="tab" id="heading-annotation-<%= annotation.id %>"> | ||
| <h2 class="panel-title"> | ||
| <a role="button" data-toggle="collapse" | ||
| data-parent="<%= question.id %>-guidance" | ||
| href="#collapse-annotation-<%= annotation.id %>" | ||
| aria-controls="collapse-annotation-<%= annotation.id %>"> | ||
|
|
||
| <div class="accordion-section"><%= raw annotation.text %></div> | ||
| <%= (plan.template.org.abbreviation.present? ? plan.template.org.abbreviation : plan.template.org.name) %> | ||
| <% if annotation.example_answer? %> | ||
| <%= _('Example Answer') %> | ||
| <% else %> | ||
| <%= _('Guidance') %> | ||
| <% end %> | ||
|
|
||
| <span class="fa fa-plus" aria-hidden="true"></span> | ||
| </a> | ||
| </h2> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div id="collapse-annotation-<%= annotation.id %>" class="panel-collapse collapse" | ||
| role="tabpanel" aria-labelledby="heading-annotation-<%= annotation.id %>"> | ||
| <div class="panel-body"> | ||
| <%= raw annotation.text %> | ||
| </div> | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,24 @@ | ||
| <h3 class="accordion_heading_text"> | ||
| <%= group[:org] %> guidance on <%= theme %> | ||
| <span class="fa fa-plus" aria-hidden="true"></span> | ||
| </h3> | ||
| <div class="panel panel-default"> | ||
| <div class="panel-heading" role="tab" id="heading-guidance-<%= guidance_accordion_id %>"> | ||
| <h2 class="panel-title"> | ||
| <a role="button" data-toggle="collapse" | ||
| data-parent="<%= question.id %>-guidance" | ||
| href="#collapse-guidance-<%= guidance_accordion_id %>" | ||
| aria-controls="collapse-guidance-<%= guidance_accordion_id %>"> | ||
|
|
||
| <div id="collapse-guidance-<%= question.id %>-<%= guidance_accordion_id %>" class="accordion-section collapse"> | ||
| <%= raw group[:text] %> | ||
| </div> | ||
| <%= group[:org] %> guidance on <%= theme %> | ||
|
|
||
| <span class="fa fa-plus" aria-hidden="true"></span> | ||
| </a> | ||
| </h2> | ||
| </div> | ||
| </div> | ||
|
|
||
| <div id="collapse-guidance-<%= guidance_accordion_id %>" | ||
| class="panel-collapse collapse" | ||
| role="tabpanel" | ||
| aria-labelledby="heading-guidance-<%= guidance_accordion_id %>"> | ||
| <div class="panel-body"> | ||
| <%= raw group[:text] %> | ||
| </div> | ||
| </div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| import 'bootstrap-sass/assets/javascripts/bootstrap.min'; | ||
|
|
||
| /* | ||
| * This method expects an expand/collapse all link to be contained within a div with | ||
| * the '.accordion-controls' class. The div container should have a 'data-parent' that | ||
| * corresponds with the id of your accordion container. The links should have a | ||
| * 'data-toggle-direction' attribute that contains either 'show' or 'hide'. | ||
| * ------------------------------------------------------------ | ||
| * <div class="accordion-controls" data-parent="accordion"> | ||
| * <a href="#" data-toggle-direction="show"><%= _('expand all') %></a> | ||
| * <a href="#" data-toggle-direction="hide"><%= _('collapse all') %></a> | ||
| * </div> | ||
| * | ||
| * Your accordion should follow the Boostrap 3.x layout: | ||
| * ------------------------------------------------------------ | ||
| * <div id="accordion" class="panel-group" role="tablist" aria-multiselectable="true"> | ||
| * <div class="panel panel-default"> | ||
| * <div class="panel-heading" role="tab" id="headingA"> | ||
| * <h2 class="panel-title"> | ||
| * <a role="button" data-toggle="collapse" data-parent="accordion" | ||
| * href="#collapseA" aria-controls="collapseA" aria-expanded="false"> | ||
| * Section A | ||
| * </a> | ||
| * </h2> | ||
| * </div> | ||
| * </div> | ||
| * <div id="collapseA" class="panel-collapse collapse" role="tabpanel" | ||
| * aria-labelledby="headingA"> | ||
| * <div class="panel-body"> | ||
| * This is test section A. | ||
| * </div> | ||
| * </div> | ||
| * </div> | ||
| * </div> | ||
| */ | ||
| export default () => { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice collapsible abstraction! |
||
| $.each($('.accordion-controls'), (idx, el) => { | ||
| const accordion = $(el).attr('data-parent'); | ||
|
|
||
| $.each($(el).children('a[data-toggle-direction]'), (i, a) => { | ||
| $(a).click((event) => { | ||
| event.preventDefault(); | ||
| $(`#${accordion} div.panel-collapse`).collapse(`${$(a).attr('data-toggle-direction')}`); | ||
| }); | ||
| }); | ||
| }); | ||
| }; | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
only import the bootstrap plugin that you are going to use (e.g. ... javascripts/bootstrap/collapse.js