Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions bootstro.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,13 @@
font-weight:bold;
}

.bootstro-backdrop2
{
position: fixed;
z-index: 2;
opacity: 0.5;
background-color: black;
filter: alpha(opacity = 50);
}


41 changes: 36 additions & 5 deletions bootstro.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ $(document).ready(function(){

margin : 100, //if the currently shown element's margin is less than this value
// the element should be scrolled so that i can be viewed properly. This is useful
// for sites which have fixed top/bottom nav bar
// for sites which have fixed top/bottom nav bar

showBackdrop: true, // If false, don't show the overlay.
useBackdropMethod2: false, // Use alternative method to paint backdrop. Work around when there's
// z-index stack confusion (iScroll, etc)
};
var settings;

Expand Down Expand Up @@ -180,6 +184,7 @@ $(document).ready(function(){
else if (p.title == '')
p.title = t;

p.container = '#bootstro-wrapper';
p.content = $el.attr('data-bootstro-content') || '';
p.content = add_nav_btn(p.content, i);
p.placement = $el.attr('data-bootstro-placement') || 'top';
Expand Down Expand Up @@ -234,6 +239,7 @@ $(document).ready(function(){
bootstro.destroy_popover(activeIndex);
bootstro.unbind();
$("div.bootstro-backdrop").remove();
$("div.bootstro-backdrop2").remove();
if (typeof settings.onExit == 'function')
settings.onExit.call(this,{idx : activeIndex});
};
Expand All @@ -249,7 +255,11 @@ $(document).ready(function(){
var $el = get_element(idx);

$el.popover(p).popover('show');

$('#bootstro-top').css({top: 0, left: 0, height: $el.offset().top + 'px', width: '100%'});
$('#bootstro-left').css({top: $el.offset().top, left: 0, height: $el.outerHeight() + 'px', width: $el.offset().left + 'px'});
$('#bootstro-right').css({top: $el.offset().top, left: -1 + $el.offset().left + $el.outerWidth() + 'px', height: $el.outerHeight() + 'px', width: '100%' });
$('#bootstro-bot').css({top: $el.offset().top + + $el.outerHeight() + 'px', left: 0, height: '100%', width: '100%' });

//scroll if neccessary
var docviewTop = $(window).scrollTop();
var top = Math.min($(".popover.in").offset().top, $el.offset().top);
Expand Down Expand Up @@ -314,7 +324,23 @@ $(document).ready(function(){
if (count > 0 && $('div.bootstro-backdrop').length === 0)
{
// Prevents multiple copies
$('<div class="bootstro-backdrop"></div>').appendTo('body');
if (settings.showBackdrop)
{
if (!settings.useBackdropMethod2)
{
$('<div id="bootstro-wrapper"><div class="bootstro-backdrop"></div></div>').appendTo('body');
}
else
{
// Create a box to "punch a hole" through to the element. This works better if you're
// using something that does 3d transforms with z-Index (i.e. iScroll)
$('<div id="bootstro-wrapper" style="z-index: 1;"></div>').appendTo('body');
$('<div id="bootstro-top" class="bootstro-backdrop2"></div>').appendTo('#bootstro-wrapper');
$('<div id="bootstro-left" class="bootstro-backdrop2"></div>').appendTo('#bootstro-wrapper');
$('<div id="bootstro-right" class="bootstro-backdrop2"></div>').appendTo('#bootstro-wrapper');
$('<div id="bootstro-bot" class="bootstro-backdrop2"></div>').appendTo('#bootstro-wrapper');
}
}
bootstro.bind();
bootstro.go_to(0);
}
Expand Down Expand Up @@ -379,8 +405,13 @@ $(document).ready(function(){

if (settings.stopOnBackdropClick)
{
$("html").on('click.bootstro', 'div.bootstro-backdrop', function(e){
if ($(e.target).hasClass('bootstro-backdrop'))
if (settings.useBackdropMethod2) {
var classname = 'bootstro-backdrop2';
} else {
var classname = 'bootstro-backdrop';
}
$("html").on('click.bootstro', 'div.' + classname, function(e){
if ($(e.target).hasClass(classname))
bootstro.stop();
});
}
Expand Down