1 2/** 3 * SMK Accordion jQuery Plugin 4 * ---------------------------------------------------- 5 * Author: Smartik 6 * Author URL: http://smartik.ws/ 7 * Copyright: (c) Smartik. 8 * License: MIT 9 */ 10;(function ( $ ) { 11 12 $.fn.smk_Accordion = function( options ) { 13 14 // Defaults 15 var settings = $.extend({ 16 // These are the defaults. 17 animation: true, 18 showIcon: true, 19 closeAble: false, 20 slideSpeed: 200 21 }, options ); 22 23 // Cache current instance 24 // To avoid scope issues, use 'plugin' instead of 'this' 25 // to reference this class from internal events and functions. 26 var plugin = this; 27 28 //"Constructor" 29 var init = function() { 30 plugin.createStructure(); 31 plugin.clickHead(); 32 } 33 34 // Add .smk_accordion class 35 this.createStructure = function() { 36 37 //Add Class 38 plugin.addClass('smk_accordion'); 39 if( true === settings.showIcon ){ 40 plugin.addClass('acc_with_icon'); 41 } 42 43 //Append icon 44 if( true === settings.showIcon ){ 45 plugin.find('.acc_head').prepend('<div class="acc_icon_expand"></div>'); 46 } 47 48 plugin.find('.accordion_in .acc_content').not('.acc_active .acc_content').hide(); 49 50 } 51 52 // Action when the user click accordion head 53 this.clickHead = function() { 54 55 plugin.on('click', '.acc_head', function(){ 56 57 var s_parent = $(this).parent(); 58 59 if( s_parent.hasClass('acc_active') == false ){ 60 plugin.find('.acc_content').slideUp(settings.slideSpeed); 61 plugin.find('.accordion_in').removeClass('acc_active'); 62 } 63 64 if( s_parent.hasClass('acc_active') ){ 65 if( false !== settings.closeAble){ 66 s_parent.children('.acc_content').slideUp(settings.slideSpeed); 67 s_parent.removeClass('acc_active'); 68 } 69 } 70 else{ 71 $(this).next('.acc_content').slideDown(settings.slideSpeed); 72 s_parent.addClass('acc_active'); 73 } 74 75 }); 76 77 } 78 79 //"Constructor" init 80 init(); 81 return this; 82 83 }; 84 85 86}( jQuery ));
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.