Skip to content

Commit

Permalink
add callback
Browse files Browse the repository at this point in the history
  • Loading branch information
effone committed Aug 22, 2018
1 parent ea9b4cb commit 07043dd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dist/jquery.ruk.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions example/base.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
$( "#ruk" ).ruk({
only: true
$("#ruk").ruk({
after: function (id, state) {
console.log(id + " : " + state);
}
});
16 changes: 10 additions & 6 deletions src/jquery.ruk.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
(function ($) {
$.fn.ruk = function (options) {
var settings = $.extend({
only: true
}, options);
$.fn.ruk = function (opts) {
var conf = $.extend({
only: false
}, opts);
$(this).addClass("ruk").children('div div').children('div:first-child').addClass("rq").next('div').addClass('ra');

$('.rq').on('click', function () {
if (settings.only) {
if (conf.only) {
$('.rq').not(this).next('.ra').slideUp('fast');
}
$(this).next('.ra').slideToggle('fast');
$(this).next('.ra').slideToggle('fast', function () {
if ($.isFunction(conf.after)) {
conf.after.call(this, $(this).parent().index() + 1, $(this).is(':visible'));
}
});
})
};
}(jQuery));

0 comments on commit 07043dd

Please sign in to comment.