0
0
mirror of https://github.com/twbs/bootstrap.git synced 2024-12-01 13:24:25 +01:00

change modal.js to use is-fixed classes to target padding-right

This commit is contained in:
Jacob Thornton 2015-08-15 12:10:24 -07:00
parent db14bac42f
commit c830956d17
6 changed files with 23 additions and 20 deletions

View File

@ -1669,6 +1669,7 @@ var Modal = (function ($) {
}; };
var ClassName = { var ClassName = {
SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
BACKDROP: 'modal-backdrop', BACKDROP: 'modal-backdrop',
OPEN: 'modal-open', OPEN: 'modal-open',
FADE: 'fade', FADE: 'fade',
@ -1679,7 +1680,7 @@ var Modal = (function ($) {
DIALOG: '.modal-dialog', DIALOG: '.modal-dialog',
DATA_TOGGLE: '[data-toggle="modal"]', DATA_TOGGLE: '[data-toggle="modal"]',
DATA_DISMISS: '[data-dismiss="modal"]', DATA_DISMISS: '[data-dismiss="modal"]',
SCROLLBAR_MEASURER: 'modal-scrollbar-measure' FIXED_CONTENT: '.navbar-fixed-top, .navbar-fixed-bottom, .is-fixed'
}; };
/** /**
@ -2029,7 +2030,7 @@ var Modal = (function ($) {
}, { }, {
key: '_setScrollbar', key: '_setScrollbar',
value: function _setScrollbar() { value: function _setScrollbar() {
var bodyPadding = parseInt($(document.body).css('padding-right') || 0, 10); var bodyPadding = parseInt($(Selector.FIXED_CONTENT).css('padding-right') || 0, 10);
this._originalBodyPadding = document.body.style.paddingRight || ''; this._originalBodyPadding = document.body.style.paddingRight || '';
@ -2047,7 +2048,7 @@ var Modal = (function ($) {
value: function _getScrollbarWidth() { value: function _getScrollbarWidth() {
// thx d.walsh // thx d.walsh
var scrollDiv = document.createElement('div'); var scrollDiv = document.createElement('div');
scrollDiv.className = Selector.SCROLLBAR_MEASURER; scrollDiv.className = ClassName.SCROLLBAR_MEASURER;
document.body.appendChild(scrollDiv); document.body.appendChild(scrollDiv);
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
document.body.removeChild(scrollDiv); document.body.removeChild(scrollDiv);

File diff suppressed because one or more lines are too long

View File

@ -74,6 +74,7 @@
}; };
var ClassName = { var ClassName = {
SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
BACKDROP: 'modal-backdrop', BACKDROP: 'modal-backdrop',
OPEN: 'modal-open', OPEN: 'modal-open',
FADE: 'fade', FADE: 'fade',
@ -84,7 +85,7 @@
DIALOG: '.modal-dialog', DIALOG: '.modal-dialog',
DATA_TOGGLE: '[data-toggle="modal"]', DATA_TOGGLE: '[data-toggle="modal"]',
DATA_DISMISS: '[data-dismiss="modal"]', DATA_DISMISS: '[data-dismiss="modal"]',
SCROLLBAR_MEASURER: 'modal-scrollbar-measure' FIXED_CONTENT: '.navbar-fixed-top, .navbar-fixed-bottom, .is-fixed'
}; };
/** /**
@ -434,7 +435,7 @@
}, { }, {
key: '_setScrollbar', key: '_setScrollbar',
value: function _setScrollbar() { value: function _setScrollbar() {
var bodyPadding = parseInt($(document.body).css('padding-right') || 0, 10); var bodyPadding = parseInt($(Selector.FIXED_CONTENT).css('padding-right') || 0, 10);
this._originalBodyPadding = document.body.style.paddingRight || ''; this._originalBodyPadding = document.body.style.paddingRight || '';
@ -452,7 +453,7 @@
value: function _getScrollbarWidth() { value: function _getScrollbarWidth() {
// thx d.walsh // thx d.walsh
var scrollDiv = document.createElement('div'); var scrollDiv = document.createElement('div');
scrollDiv.className = Selector.SCROLLBAR_MEASURER; scrollDiv.className = ClassName.SCROLLBAR_MEASURER;
document.body.appendChild(scrollDiv); document.body.appendChild(scrollDiv);
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
document.body.removeChild(scrollDiv); document.body.removeChild(scrollDiv);

7
js/dist/modal.js vendored
View File

@ -57,6 +57,7 @@ var Modal = (function ($) {
}; };
var ClassName = { var ClassName = {
SCROLLBAR_MEASURER: 'modal-scrollbar-measure',
BACKDROP: 'modal-backdrop', BACKDROP: 'modal-backdrop',
OPEN: 'modal-open', OPEN: 'modal-open',
FADE: 'fade', FADE: 'fade',
@ -67,7 +68,7 @@ var Modal = (function ($) {
DIALOG: '.modal-dialog', DIALOG: '.modal-dialog',
DATA_TOGGLE: '[data-toggle="modal"]', DATA_TOGGLE: '[data-toggle="modal"]',
DATA_DISMISS: '[data-dismiss="modal"]', DATA_DISMISS: '[data-dismiss="modal"]',
SCROLLBAR_MEASURER: 'modal-scrollbar-measure' FIXED_CONTENT: '.navbar-fixed-top, .navbar-fixed-bottom, .is-fixed'
}; };
/** /**
@ -417,7 +418,7 @@ var Modal = (function ($) {
}, { }, {
key: '_setScrollbar', key: '_setScrollbar',
value: function _setScrollbar() { value: function _setScrollbar() {
var bodyPadding = parseInt($(document.body).css('padding-right') || 0, 10); var bodyPadding = parseInt($(Selector.FIXED_CONTENT).css('padding-right') || 0, 10);
this._originalBodyPadding = document.body.style.paddingRight || ''; this._originalBodyPadding = document.body.style.paddingRight || '';
@ -435,7 +436,7 @@ var Modal = (function ($) {
value: function _getScrollbarWidth() { value: function _getScrollbarWidth() {
// thx d.walsh // thx d.walsh
var scrollDiv = document.createElement('div'); var scrollDiv = document.createElement('div');
scrollDiv.className = Selector.SCROLLBAR_MEASURER; scrollDiv.className = ClassName.SCROLLBAR_MEASURER;
document.body.appendChild(scrollDiv); document.body.appendChild(scrollDiv);
var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; var scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth;
document.body.removeChild(scrollDiv); document.body.removeChild(scrollDiv);

File diff suppressed because one or more lines are too long

View File

@ -55,17 +55,18 @@ const Modal = (($) => {
} }
const ClassName = { const ClassName = {
BACKDROP : 'modal-backdrop', SCROLLBAR_MEASURER : 'modal-scrollbar-measure',
OPEN : 'modal-open', BACKDROP : 'modal-backdrop',
FADE : 'fade', OPEN : 'modal-open',
IN : 'in' FADE : 'fade',
IN : 'in'
} }
const Selector = { const Selector = {
DIALOG : '.modal-dialog', DIALOG : '.modal-dialog',
DATA_TOGGLE : '[data-toggle="modal"]', DATA_TOGGLE : '[data-toggle="modal"]',
DATA_DISMISS : '[data-dismiss="modal"]', DATA_DISMISS : '[data-dismiss="modal"]',
SCROLLBAR_MEASURER : 'modal-scrollbar-measure' FIXED_CONTENT : '.navbar-fixed-top, .navbar-fixed-bottom, .is-fixed'
} }
@ -414,7 +415,7 @@ const Modal = (($) => {
_setScrollbar() { _setScrollbar() {
let bodyPadding = parseInt( let bodyPadding = parseInt(
$(document.body).css('padding-right') || 0, $(Selector.FIXED_CONTENT).css('padding-right') || 0,
10 10
) )
@ -432,7 +433,7 @@ const Modal = (($) => {
_getScrollbarWidth() { // thx d.walsh _getScrollbarWidth() { // thx d.walsh
let scrollDiv = document.createElement('div') let scrollDiv = document.createElement('div')
scrollDiv.className = Selector.SCROLLBAR_MEASURER scrollDiv.className = ClassName.SCROLLBAR_MEASURER
document.body.appendChild(scrollDiv) document.body.appendChild(scrollDiv)
let scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth let scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth
document.body.removeChild(scrollDiv) document.body.removeChild(scrollDiv)