|
19 | 19 | return element.querySelectorAll(selector);
|
20 | 20 | }
|
21 | 21 |
|
22 |
| - function createModalContent() { |
| 22 | + function createModalContentElement() { |
23 | 23 | var modalContent = document.createElement('div');
|
24 | 24 | modalContent.classList.add('modal-content');
|
25 | 25 | return modalContent;
|
26 | 26 | }
|
27 | 27 |
|
28 |
| - function createSpanClose() { |
| 28 | + function createSpanCloseElement() { |
29 | 29 | var spanClose = document.createElement('span');
|
30 | 30 | spanClose.classList.add('close');
|
31 | 31 | spanClose.innerHTML = '×';
|
32 | 32 | return spanClose;
|
33 | 33 | }
|
34 | 34 |
|
35 |
| - function createClear() { |
| 35 | + function createClearElement() { |
36 | 36 | var clear = document.createElement('div');
|
37 | 37 | clear.classList.add('clear');
|
38 | 38 | return clear;
|
39 | 39 | }
|
40 | 40 |
|
41 | 41 | function configModal(options) {
|
42 |
| - |
| 42 | + |
| 43 | + // Get all options |
43 | 44 | this.options = Object.assign({}, options);
|
44 | 45 |
|
| 46 | + // Get width options |
45 | 47 | this.width = this.options.width || 400;
|
46 | 48 |
|
| 49 | + // Get background options |
47 | 50 | this.background = this.options.background || '#FFF';
|
48 | 51 |
|
49 | 52 | this.wrapModalContent = this.wrapModalContent.bind(this);
|
50 | 53 |
|
51 |
| - this.makeModal(); |
| 54 | + // render modal |
| 55 | + this.renderModal(); |
52 | 56 |
|
53 | 57 | };
|
54 | 58 |
|
55 |
| - configModal.prototype.makeModal = function makeModal() { |
| 59 | + configModal.prototype.renderModal = function renderModal() { |
56 | 60 |
|
57 | 61 | // Add class modal
|
58 | 62 | var modal = el(this.options.modal);
|
|
80 | 84 |
|
81 | 85 | configModal.prototype.wrapModalContent = function wrapModalContent(children) {
|
82 | 86 | var fragmentModalContent = document.createDocumentFragment();
|
83 |
| - var modalContent = createModalContent(); |
| 87 | + var modalContent = createModalContentElement(); |
| 88 | + |
| 89 | + // Styling |
84 | 90 | modalContent.style.width = this.width + 'px';
|
85 | 91 | modalContent.style.background = this.background;
|
86 | 92 |
|
87 | 93 | Array.prototype.forEach.call(children, function(e) {
|
88 |
| - modalContent.appendChild(createSpanClose()); |
89 |
| - modalContent.appendChild(createClear()); |
| 94 | + modalContent.appendChild(createSpanCloseElement()); |
| 95 | + modalContent.appendChild(createClearElement()); |
90 | 96 | modalContent.appendChild(e);
|
91 | 97 | fragmentModalContent.appendChild(modalContent);
|
92 | 98 | });
|
|
0 commit comments