1
0
mirror of https://github.com/maximebf/php-debugbar.git synced 2025-07-28 04:00:43 +02:00

Merge pull request #252 from codewizz/codewizz-dynamic-margin

Offset calculation change to body margin-bottom
This commit is contained in:
Barry vd. Heuvel
2016-04-29 10:57:56 +02:00

View File

@@ -395,8 +395,8 @@ if (typeof(PhpDebugBar) == 'undefined') {
className: "phpdebugbar " + csscls('minimized'),
options: {
bodyPaddingBottom: true,
bodyPaddingBottomHeight: parseInt($('body').css('padding-bottom'))
bodyMarginBottom: true,
bodyMarginBottomHeight: parseInt($('body').css('margin-bottom'))
},
initialize: function() {
@@ -793,7 +793,16 @@ if (typeof(PhpDebugBar) == 'undefined') {
this.$el.addClass(csscls('closed'));
this.recomputeBottomOffset();
},
/**
* Checks if the panel is closed
*
* @return {Boolean}
*/
isClosed: function() {
return this.$el.hasClass(csscls('closed'));
},
/**
* Restore the debug bar
*
@@ -813,13 +822,17 @@ if (typeof(PhpDebugBar) == 'undefined') {
},
/**
* Recomputes the padding-bottom css property of the body so
* Recomputes the margin-bottom css property of the body so
* that the debug bar never hides any content
*/
recomputeBottomOffset: function() {
if (this.options.bodyPaddingBottom) {
var height = parseInt(this.$el.height()) + this.options.bodyPaddingBottomHeight;
$('body').css('padding-bottom', height);
if (this.options.bodyMarginBottom) {
if (this.isMinimized() || this.isClosed()) {
return $('body').css('margin-bottom', this.options.bodyMarginBottomHeight || '');
}
var offset = parseInt(this.$el.height()) + this.options.bodyMarginBottomHeight;
$('body').css('margin-bottom', offset);
}
},