Skip to content

Commit 4c0b624

Browse files
committed
Merge pull request php-debugbar#252 from codewizz/codewizz-dynamic-margin
Offset calculation change to body margin-bottom
2 parents d930289 + 88ba3c6 commit 4c0b624

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

src/DebugBar/Resources/debugbar.js

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -395,8 +395,8 @@ if (typeof(PhpDebugBar) == 'undefined') {
395395
className: "phpdebugbar " + csscls('minimized'),
396396

397397
options: {
398-
bodyPaddingBottom: true,
399-
bodyPaddingBottomHeight: parseInt($('body').css('padding-bottom'))
398+
bodyMarginBottom: true,
399+
bodyMarginBottomHeight: parseInt($('body').css('margin-bottom'))
400400
},
401401

402402
initialize: function() {
@@ -793,7 +793,16 @@ if (typeof(PhpDebugBar) == 'undefined') {
793793
this.$el.addClass(csscls('closed'));
794794
this.recomputeBottomOffset();
795795
},
796-
796+
797+
/**
798+
* Checks if the panel is closed
799+
*
800+
* @return {Boolean}
801+
*/
802+
isClosed: function() {
803+
return this.$el.hasClass(csscls('closed'));
804+
},
805+
797806
/**
798807
* Restore the debug bar
799808
*
@@ -813,13 +822,17 @@ if (typeof(PhpDebugBar) == 'undefined') {
813822
},
814823

815824
/**
816-
* Recomputes the padding-bottom css property of the body so
825+
* Recomputes the margin-bottom css property of the body so
817826
* that the debug bar never hides any content
818827
*/
819828
recomputeBottomOffset: function() {
820-
if (this.options.bodyPaddingBottom) {
821-
var height = parseInt(this.$el.height()) + this.options.bodyPaddingBottomHeight;
822-
$('body').css('padding-bottom', height);
829+
if (this.options.bodyMarginBottom) {
830+
if (this.isMinimized() || this.isClosed()) {
831+
return $('body').css('margin-bottom', this.options.bodyMarginBottomHeight || '');
832+
}
833+
834+
var offset = parseInt(this.$el.height()) + this.options.bodyMarginBottomHeight;
835+
$('body').css('margin-bottom', offset);
823836
}
824837
},
825838

0 commit comments

Comments
 (0)