Last active
          September 2, 2019 10:23 
        
      - 
      
 - 
        
Save zdimaz/373be229f95c5462add222ac74f2d801 to your computer and use it in GitHub Desktop.  
    accordion plugin jq 
  
        
  
    
      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
    
  
  
    
  | self.jqueryExtend(); | |
| /* | |
| * | |
| * | |
| * Accordion | |
| * | |
| */ | |
| jqueryExtend: function() { | |
| $.fn.extend({ | |
| /** | |
| ** accordion plugin | |
| ** @param toggle - set to true, if need to be toggle | |
| ** @return jquery | |
| **/ | |
| accordion: function(toggle) { | |
| return this.each(function() { | |
| var $this = $(this), | |
| active = $this.children('.js_accordion_title.active').length ? $this.children('.js_accordion_title.active') : null; | |
| $this.children('.js_accordion_title').not(active).next().hide(); | |
| $this.on('click', '.js_accordion_title', function() { | |
| var $this = $(this); | |
| if (!toggle) { | |
| if ($(this).hasClass('active')) { | |
| $(this).removeClass('active') | |
| .siblings('.js_accordion_title') | |
| .removeClass('active') | |
| .end() | |
| .siblings('.js_accordion_content') | |
| .stop() | |
| .slideUp(); | |
| } else { | |
| $(this).addClass('active') | |
| .siblings('.js_accordion_title') | |
| .removeClass('active') | |
| .end() | |
| .next('.js_accordion_content') | |
| .stop() | |
| .slideDown(500) | |
| .siblings('.js_accordion_content') | |
| .stop() | |
| .slideUp(); | |
| } | |
| } else { | |
| $(this).toggleclass('active').next().stop().slidetoggle(); | |
| } | |
| }); | |
| }); | |
| } | |
| }); | |
| }, | |
| if ($(".js_accordion").length) { | |
| $(".js_accordion").accordion(); | |
| }; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment