Last active
August 29, 2015 14:26
-
-
Save Gix075/6b317a8996b08992b135 to your computer and use it in GitHub Desktop.
Simple collapsible text system
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
/*! | |
============================================================== | |
Easy Readmore - version 1.0.0 | |
http://factory.brainleaf.eu/tools/jquery/easy-readmore | |
============================================================== | |
*/ | |
function easyReadmore (options) { | |
var defaults = { | |
btnClass: ".readmore", | |
hideOpenBtn: true, | |
ease: "swing", //jquery ease plugin needed | |
speed: 300 | |
}, | |
settings = $.extend({}, defaults, options); | |
wrapper = settings.btnClass + "-wrapper", | |
openBtn = settings.btnClass + ".open", | |
closeBtn = settings.btnClass + ".close", | |
hiddenBox = settings.btnClass + "-hidden"; | |
// open readmore box | |
// ========================================================= | |
$(openBtn).on('click', function (e) { | |
e.preventDefault(); | |
if (settings.hideOpenBtn === true) $(this).hide(); | |
$(this).closest(wrapper).find(hiddenBox).slideDown({ | |
duration: settings.speed, | |
easing: settings.ease | |
}); | |
}); | |
// close readmore box | |
// ========================================================= | |
$(closeBtn).on('click', function (e) { | |
e.preventDefault(); | |
$(this).closest(hiddenBox).slideUp({ | |
duration: settings.speed, | |
easing: settings.ease, | |
done: function() { | |
if (settings.hideOpenBtn === true) $(this).closest(wrapper).find(openBtn).fadeIn(); | |
} | |
}); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment