I am trying to make this small plugin work but I am stuck at the moment. This is my first attempt to convert a function to a plugin.. Currently it's not working..
jQuery.fn.overlay_AS = function(opts) {
clickable_link.click(function(evt){
evt.preventDefault();
var overlay_content = $('#'+current_link);
overlay.children().fadeOut(200).promise().done(function () {
overlay_content.fadeIn();
});
//don't need to make the overlay fadeIn every time
if (!overlay.is(':visible')) overlay.fadeIn();
});
overlay.click(function(){
overlay.fadeOut();
overlay.children().fadeOut(500);
});
};
$('.p_wrapper p').click(function(){
$('.p_wrapper p').overlay_AS({
clickable_link:$(this),
current_link:$(this).attr('class'),
overlay: $('#overlay')
});
});
HTML:
<div class="p_wrapper">
<p class="one">Link 1</p>
<p class="two">Link 2</p>
<p class="three">Link 3</p>
</div>
<div id="overlay">
<p id="one">You clicked on p1</p>
<p id="two">You clicked on p2</p>
<p id="three">You clicked on p3</p>
</div>
ALl it does is fading an overlay in and loading different content depending on what link you clicked on.