<div id="content">
<button id="test1_btn">test1</button>
<button id="test2_btn">test2</button>
</div>
<div id="test1" class="alk-bottom-panel">
<p>bottom panel test 1</p>
<p>this is a standard panel that will partially cover viewport</p>
<p>click anywhere to close</p>
</div>
<div id="test2" class="alk-bottom-panel alk-bottom-panel-full">
<div class="alk-bottom-panel-header">header</div>
<p>bottom panel test 2</p>
<p>full bottom panel with a button to open a third</p>
<p>click header to close</p>
<button id="test3_btn">test3</button>
</div>
<div id="test3" class="alk-bottom-panel">
<div class="alk-bottom-panel-header">header</div>
<p>bottom panel test 3</p>
<p>this is a partial panel opened from the previous full panel</p>
<p>click header to close</p>
</div>
$('#test1_btn').on('click', function () { $('#test1').alkBottomPanel(); });
$('#test1').on('click', function () { $('#test1').alkBottomPanel(); });
$('#test2_btn').on('click', function () { $('#test2').alkBottomPanel(); });
$('#test2 .alk-bottom-panel-header').on('click', function () {
$('#test2').alkBottomPanel();
})
$('#test3_btn').on('click', function () { $('#test3').alkBottomPanel(); });
$('#test3 .alk-bottom-panel-header').on('click', function () { $('#test3').alkBottomPanel(); })
$.fn.alkBottomPanel = function() {
return this.each(function () {
var $this = $(this);
var $body = $('body');
var $blocker = $('.alk-bottom-panel-blocker');
// check for blocker
if ($blocker.length === 0) {
$body.append('<div class="alk-bottom-panel-blocker"></div>');
$blocker = $('.alk-bottom-panel-blocker');
}
// delay to allow for blocker creation if needed
window.setTimeout(function () {
// check to make sure it's a valid element
if ($this.hasClass('alk-bottom-panel')) {
// check for active panel
if (!$('.alk-bottom-panel-opened').length > 0 || $this.hasClass('alk-bottom-panel-opened')) {
// there is no active panel or
// active panel is the one just set in motion
// therefore toggle classes as expected
$body.toggleClass('alk-bottom-panel-active');
$blocker.toggleClass('alk-bottom-panel-blocker-show');
$this.toggleClass('alk-bottom-panel-opened');
} else {
// there is an active panel as new one is activated
// hide initial panel
$('.alk-bottom-panel-opened').removeClass('alk-bottom-panel-opened');
// show newly activated panel
$this.addClass('alk-bottom-panel-opened');
}
}
}, 100);
});
};
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.