Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 871839e

Browse files
author
Adiatma Kamarudin
authoredNov 5, 2017
Merge pull request #10 from tutorjs/develop
MODIFIED: tydi and add comment
2 parents aec67d0 + e423a51 commit 871839e

File tree

3 files changed

+20
-13
lines changed

3 files changed

+20
-13
lines changed
 

‎index.html

-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ <h1>Halo Dunia</h1>
9797
modal: '.my-modal',
9898
content: '.my-content',
9999
trigger: '.show-modal',
100-
background: 'tranparent'
101100
})
102101

103102
// My Outher Modal

‎src/css/simple-modal.css

+5-3
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*/
55

66
*,
7-
*:after,
8-
*:before {
7+
*::after,
8+
*::before {
99
box-sizing: border-box;
1010
}
1111

@@ -43,6 +43,8 @@ body {
4343
color: #ddd;
4444
}
4545

46-
.clear {
46+
.clear::after {
47+
content: " ";
4748
clear: both;
49+
display: table;
4850
}

‎src/js/simple-modal.js

+15-9
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,44 @@
1919
return element.querySelectorAll(selector);
2020
}
2121

22-
function createModalContent() {
22+
function createModalContentElement() {
2323
var modalContent = document.createElement('div');
2424
modalContent.classList.add('modal-content');
2525
return modalContent;
2626
}
2727

28-
function createSpanClose() {
28+
function createSpanCloseElement() {
2929
var spanClose = document.createElement('span');
3030
spanClose.classList.add('close');
3131
spanClose.innerHTML = '&times;';
3232
return spanClose;
3333
}
3434

35-
function createClear() {
35+
function createClearElement() {
3636
var clear = document.createElement('div');
3737
clear.classList.add('clear');
3838
return clear;
3939
}
4040

4141
function configModal(options) {
42-
42+
43+
// Get all options
4344
this.options = Object.assign({}, options);
4445

46+
// Get width options
4547
this.width = this.options.width || 400;
4648

49+
// Get background options
4750
this.background = this.options.background || '#FFF';
4851

4952
this.wrapModalContent = this.wrapModalContent.bind(this);
5053

51-
this.makeModal();
54+
// render modal
55+
this.renderModal();
5256

5357
};
5458

55-
configModal.prototype.makeModal = function makeModal() {
59+
configModal.prototype.renderModal = function renderModal() {
5660

5761
// Add class modal
5862
var modal = el(this.options.modal);
@@ -80,13 +84,15 @@
8084

8185
configModal.prototype.wrapModalContent = function wrapModalContent(children) {
8286
var fragmentModalContent = document.createDocumentFragment();
83-
var modalContent = createModalContent();
87+
var modalContent = createModalContentElement();
88+
89+
// Styling
8490
modalContent.style.width = this.width + 'px';
8591
modalContent.style.background = this.background;
8692

8793
Array.prototype.forEach.call(children, function(e) {
88-
modalContent.appendChild(createSpanClose());
89-
modalContent.appendChild(createClear());
94+
modalContent.appendChild(createSpanCloseElement());
95+
modalContent.appendChild(createClearElement());
9096
modalContent.appendChild(e);
9197
fragmentModalContent.appendChild(modalContent);
9298
});

0 commit comments

Comments
 (0)
Failed to load comments.