Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.16 KB | None | 0 0
  1. var width = 720;
  2. var height = 350;
  3. var modal = document.createElement('div');
  4. modal.className = "modal";
  5. modal.style.width = width;
  6. modal.style.height = height;
  7. modal.style.position = 'absolute';
  8. modal.style.top = (window.innerHeight - parseInt(modal.style.height)) / 2 +'px';
  9. modal.style.left = (window.innerWidth - parseInt(modal.style.width)) / 2 +'px';
  10.  
  11. var ngroup = modal;
  12. var title = document.createElement('span');
  13. title.innerHTML = "TYPE GROUP NAME"
  14. var input = document.createElement('input');
  15. input.type = "text";
  16. ngroup.appendChild(title);
  17. ngroup.appendChild(input);
  18.  
  19. var del = modal;
  20. var dtitle = document.createElement('span');
  21. dtitle.innerHTML = "DO YO WANT TO DELETE SELECTED COLOR(S)"
  22. var dinput = document.createElement('input');
  23. dinput.type = "button";
  24. dinput.value = "yes";
  25. var dinput1 = document.createElement('input');
  26. dinput1.type = "button";
  27. dinput1.value = "no";
  28. del.appendChild(dtitle);
  29. del.appendChild(dinput);
  30. del.appendChild(dinput1);
  31. function openModal(type) {
  32. var body = document.getElementsByTagName('body')[0];
  33. body.appendChild(type);
  34. }
  35. function closeModal() {
  36. document.body.removeChild(modal);
  37. }
  38.  
  39. document.addEventListener('keydown', function(event) {
  40. if(event.keyCode == 71) {
  41. openModal(del);
  42. }
  43. else if(event.keyCode == 39) {
  44. closeModal();
  45. }
  46. });
  47.  
  48. <div id="d_dialog" style="display:none" class="dialog">
  49. <span>DO YO WANT TO DELETE SELECTED COLOR(S)</span>
  50. <input type="button" value="yes"/>
  51. <input type="button" value="no"/>
  52. </div>
  53.  
  54. document.getElementById('d_dialog').style.display = '';
  55.  
  56. var del = modal;
  57.  
  58. del.appendChild(dtitle);
  59.  
  60. modal.appendChild(dtitle);
  61.  
  62. opendDialog(del);
  63.  
  64. openDialog(modal);
  65.  
  66. function createModal()
  67. {
  68. var width = 720;
  69. var height = 350;
  70. var modal = document.createElement('div');
  71. modal.className = "modal";
  72. modal.style.width = width;
  73. modal.style.height = height;
  74. modal.style.position = 'absolute';
  75. modal.style.top = (window.innerHeight - parseInt(modal.style.height)) / 2 +'px';
  76. modal.style.left = (window.innerWidth - parseInt(modal.style.width)) / 2 +'px';
  77. return modal;
  78. }
  79.  
  80. var del = modal;
  81.  
  82. var del = createModal();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement