Created
July 3, 2014 05:52
-
-
Save fronteer-kr/9091e43f62e467a2cc7b to your computer and use it in GitHub Desktop.
This file contains 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
;(function ($, window, document, undefined) { | |
$.fn.sectionCollapsible = function(options) { | |
var defaults = { | |
duration : 500, // animation 시간 | |
easing : "swing" // animation 유형 | |
}; | |
var settings = $.extend({}, defaults, options); | |
return this.each(function() { | |
var section = this; | |
$(section).find("h3:first").append('<button type="button" class="btn-section-collapsible"/>'); | |
if ($(section).hasClass("collapsed")) { // 초기상태 collapsed 자동닫힘 처리 | |
$(section).find(".section-body, .section-footer").hide(); | |
} | |
$(section).find(".btn-section-collapsible").on("click", function(){ | |
$(this).blur(); // focus 방지용 | |
$(section).find(".section-body, .section-footer").stop().animate({height: "toggle"}, settings.duration, settings.easing); | |
$(section).toggleClass("collapsed"); | |
// toggle 로 모두 처리! (toggle, toggleClass, animate({height:"toggle"}) | |
}); | |
}); | |
}; | |
})(jQuery, window, document); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment