-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmaterial-modal.js
More file actions
53 lines (53 loc) · 2.64 KB
/
Copy pathmaterial-modal.js
File metadata and controls
53 lines (53 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
materialCallback = null;
function materialAlert( title, text, callback ){
document.getElementById('materialModalTitle').innerHTML = title;
document.getElementById('materialModalText').innerHTML = text;
document.getElementById('materialModalButtonCANCEL').style.display = 'none';
document.getElementById('materialModal').className = 'show';
materialCallback = callback;
}
function materialConfirm( title, text, callback ){
materialAlert( title, text, callback );
document.getElementById('materialModalButtonCANCEL').style.display = 'block';
}
function closeMaterialAlert(e, result){
e.stopPropagation();
document.getElementById('materialModal').className = 'hide';
if(typeof materialCallback == 'function') materialCallback(result);
}
window.addEventListener('load', function(){
console.log('material-modal.js v1.1')
var materialModal = document.createElement('div');
materialModal.id = 'materialModal';
materialModal.className = 'hide';
materialModal.setAttribute('onclick', 'closeMaterialAlert(event, false);');
var materialModalCentered = document.createElement('div');
materialModalCentered.id = 'materialModalCentered'
var materialModalContent = document.createElement('div');
materialModalContent.id = 'materialModalContent'
materialModalContent.setAttribute('onclick', 'event.stopPropagation();');
var materialModalTitle = document.createElement('div');
materialModalTitle.id = 'materialModalTitle'
var materialModalText = document.createElement('div');
materialModalText.id = 'materialModalText'
var materialModalButtons = document.createElement('div');
materialModalButtons.id = 'materialModalButtons'
var materialModalButtonOK = document.createElement('div');
materialModalButtonOK.id = 'materialModalButtonOK'
materialModalButtonOK.className = 'materialModalButton'
materialModalButtonOK.setAttribute('onclick', 'closeMaterialAlert(event, true);');
materialModalButtonOK.innerHTML = 'OK'
var materialModalButtonCANCEL = document.createElement('div');
materialModalButtonCANCEL.id = 'materialModalButtonCANCEL'
materialModalButtonCANCEL.className = 'materialModalButton'
materialModalButtonCANCEL.setAttribute('onclick', 'closeMaterialAlert(event, false);');
materialModalButtonCANCEL.innerHTML = 'CANCEL'
materialModalButtons.appendChild(materialModalButtonOK);
materialModalButtons.appendChild(materialModalButtonCANCEL);
materialModalContent.appendChild(materialModalTitle)
materialModalContent.appendChild(materialModalText)
materialModalContent.appendChild(materialModalButtons)
materialModalCentered.appendChild(materialModalContent)
materialModal.appendChild(materialModalCentered);
document.body.appendChild(materialModal)
})