Skip to content

Commit 6aabebf

Browse files
committed
Removed useless resize() function, now using CSS.
1 parent f65b283 commit 6aabebf

File tree

8 files changed

+21
-65
lines changed

8 files changed

+21
-65
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "rmodal",
33
"main": "rmodal.js",
4-
"version": "1.0.9",
4+
"version": "1.0.10",
55
"authors": [
66
"Iskren Slavov <iskren.s@gmail.com>"
77
],

dist/rmodal.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.modal {
2-
position: absolute;
32
display: none;
43
background: rgba(0, 0, 0, .30);
54
z-index: 999;
@@ -26,6 +25,15 @@ body.no-bootstrap.modal-open {
2625

2726
body.no-bootstrap .modal {
2827
padding: 30px 0;
28+
29+
position: fixed;
30+
top: 0;
31+
left: 0;
32+
right: 0;
33+
bottom: 0;
34+
35+
overflow-x: hidden;
36+
overflow-y: auto;
2937
}
3038

3139
body.no-bootstrap .modal .modal-dialog {

dist/rmodal.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

index.html

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@
4343
// , escapeClose: true
4444
});
4545

46-
window.addEventListener('resize', function() {
47-
modal.resize();
48-
}, false);
49-
5046
document.addEventListener('keydown', function(ev) {
5147
modal.keydown(ev);
5248
}, false);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "rmodal",
3-
"version": "1.0.9",
3+
"version": "1.0.10",
44
"description": "A simple modal dialog with no external dependencies. IE9+ supported.",
55
"main": "angular-messenger.js",
66
"repository": {

src/rmodal.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
.modal {
2-
position: absolute;
32
display: none;
43
background: rgba(0, 0, 0, .30);
54
z-index: 999;
@@ -26,6 +25,15 @@ body.no-bootstrap.modal-open {
2625

2726
body.no-bootstrap .modal {
2827
padding: 30px 0;
28+
29+
position: fixed;
30+
top: 0;
31+
left: 0;
32+
right: 0;
33+
bottom: 0;
34+
35+
overflow-x: hidden;
36+
overflow-y: auto;
2937
}
3038

3139
body.no-bootstrap .modal .modal-dialog {

src/rmodal.js

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@
7979
addClass(this.dialog, this.options.dialogOpenClass);
8080

8181
this.overlay.style.display = 'block';
82-
this.resize();
8382

8483
if (this.options.focus) {
8584
this.focusOutElement = document.activeElement;
@@ -131,18 +130,6 @@
131130
this.dialog.innerHTML = content;
132131
};
133132

134-
RModal.prototype.resize = function() {
135-
var overlayWidth = window.innerWidth;
136-
var overlayHeight = window.innerHeight;
137-
if (document.body.clientHeight > window.innerHeight) {
138-
overlayWidth = document.body.clientWidth;
139-
overlayHeight = document.body.clientHeight;
140-
}
141-
142-
this.overlay.style.width = overlayWidth + 'px';
143-
this.overlay.style.height = overlayHeight + 'px';
144-
};
145-
146133
RModal.prototype.elements = function(selector, fallback) {
147134
fallback = fallback || (window.navigator.appVersion.indexOf('MSIE 9.0') > -1);
148135
return [].filter.call(this._elementsAll(selector), function(element) {

test/rmodal.test.js

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -215,15 +215,6 @@ describe('RModal', function() {
215215
expect(instance.overlay.style.display).to.be.equal('block');
216216
});
217217

218-
it('should call "this.resize()"', function() {
219-
var stub = sinon.stub(RModal.prototype, 'resize');
220-
var instance = create();
221-
222-
instance._doOpen();
223-
expect(stub.calledOnce).to.be.true;
224-
RModal.prototype.resize.restore();
225-
});
226-
227218
it('should set "this.focusOutElement" to "document.activeElement"', function() {
228219
var expected = document.activeElement;
229220
var instance = create();
@@ -395,40 +386,6 @@ describe('RModal', function() {
395386
});
396387
});
397388

398-
describe('resize()', function() {
399-
it('should set "this.overlay.style[width,height]" to "window[innerWidth,innerHeight]"'
400-
, function() {
401-
var instance = create();
402-
403-
elBody.clientHeight = 312;
404-
elBody.clientWidth = 422;
405-
406-
window.innerHeight = 531;
407-
window.innerWidth = 542;
408-
409-
instance.resize();
410-
411-
expect(instance.overlay.style.width).to.be.equal(window.innerWidth + 'px');
412-
expect(instance.overlay.style.height).to.be.equal(window.innerHeight + 'px');
413-
}
414-
);
415-
416-
it('should set "this.overlay.style[width,height]" to "body[clientWidth,clientHeight]"'
417-
, function() {
418-
var instance = create();
419-
420-
elDialog.innerHTML = '<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>';
421-
window.innerHeight = 123;
422-
window.innerWidth = 182;
423-
424-
instance.resize();
425-
426-
expect(instance.overlay.style.width).to.be.equal(elBody.clientWidth + 'px');
427-
expect(instance.overlay.style.height).to.be.equal(elBody.clientHeight + 'px');
428-
}
429-
);
430-
});
431-
432389
describe('elements()', function() {
433390
it('should call "this._elementsAll" passing the "selector" param', function () {
434391
var spy = sinon.spy(RModal.prototype, '_elementsAll');

0 commit comments

Comments
 (0)