diff options
author | Mike Greiling <mike@pixelcog.com> | 2017-02-02 20:45:58 +0300 |
---|---|---|
committer | Mike Greiling <mike@pixelcog.com> | 2017-02-02 20:45:58 +0300 |
commit | 7ca57c59c8b29dfbf714b9921583f3544c76bdb3 (patch) | |
tree | 52a5cca34c203d5a311e923cc5a474c1a42bf509 /app/assets/javascripts/behaviors | |
parent | 5a099315eb29c345925141609dc5a3a395312016 (diff) | |
parent | 4615d0995117e8369acc7b1f5f2b8497426ba5c7 (diff) |
Merge branch 'master' into webpack
* master: (63 commits)
Use `add_$role` helper in snippets specs
removes old css class from everywhere
Fixes broken build: Use jquery to get the element position in the page
Check public snippets for spam
Keep snippet visibility on error
Update pipeline and commit URL and text on CI status change
Support non-ASCII characters in GFM autocomplete
Active tense test coverage
Fix filtered search manager spec teaspoon error
Reduce the number of loops that Cycle Analytics specs use
Remove unnecessary returns / unset variables from the CoffeeScript -> JS conversion.
update spec
Change the reply shortcut to focus the field even without a selection.
use destroy_all
Remove settings cog from within admin scroll tabs; keep links centered
add changelog
remove old project members from project
add spec replicating validation error
Improve styling of the new issue message
Don't capitalize environment name in show page
...
Diffstat (limited to 'app/assets/javascripts/behaviors')
-rw-r--r-- | app/assets/javascripts/behaviors/toggler_behavior.js | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/app/assets/javascripts/behaviors/toggler_behavior.js b/app/assets/javascripts/behaviors/toggler_behavior.js index 6a49715590c..a7181904ac9 100644 --- a/app/assets/javascripts/behaviors/toggler_behavior.js +++ b/app/assets/javascripts/behaviors/toggler_behavior.js @@ -1,6 +1,19 @@ /* eslint-disable wrap-iife, func-names, space-before-function-paren, prefer-arrow-callback, vars-on-top, no-var, max-len */ (function(w) { $(function() { + var toggleContainer = function(container, /* optional */toggleState) { + var $container = $(container); + + $container + .find('.js-toggle-button .fa') + .toggleClass('fa-chevron-up', toggleState) + .toggleClass('fa-chevron-down', toggleState !== undefined ? !toggleState : undefined); + + $container + .find('.js-toggle-content') + .toggle(toggleState); + }; + // Toggle button. Show/hide content inside parent container. // Button does not change visibility. If button has icon - it changes chevron style. // @@ -10,14 +23,7 @@ // $('body').on('click', '.js-toggle-button', function(e) { e.preventDefault(); - $(this) - .find('.fa') - .toggleClass('fa-chevron-down fa-chevron-up') - .end() - .closest('.js-toggle-container') - .find('.js-toggle-content') - .toggle() - ; + toggleContainer($(this).closest('.js-toggle-container')); }); // If we're accessing a permalink, ensure it is not inside a @@ -26,8 +32,8 @@ var anchor = hash && document.getElementById(hash); var container = anchor && $(anchor).closest('.js-toggle-container'); - if (container && container.find('.js-toggle-content').is(':hidden')) { - container.find('.js-toggle-button').trigger('click'); + if (container) { + toggleContainer(container, true); anchor.scrollIntoView(); } }); |