Guest User

Untitled

a guest
Jun 19th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.83 KB | None | 0 0
  1. /* Usage::
  2. var element = $E([
  3. "<div class='window'>",
  4. "<div class='message'>#{message}</div>",
  5. "<input type='button' class='ok' value='#{ok}'/> <input type='button' class='cancel' value='#{cancel}'/>",
  6. "</div>"
  7. ].join(""), {
  8. data: {
  9. message : message || "dialog",
  10. ok : opts.ok || "OK",
  11. cancel : opts.cancel || "Cancel"
  12. },
  13. parent: document.body
  14. });
  15.  
  16. var style = resetStyle(element, [
  17. "._.window {",
  18. "border: 0.3em solid #ccc;",
  19. "-moz-border-radius: 1em;",
  20. "padding: 1em;",
  21. "margin: 1em;",
  22. "line-height: 1.33;",
  23. "}",
  24. "._ .message {",
  25. "margin : 1em;",
  26. "padding: 1em 0;",
  27. "margin: 0 0.5em;",
  28. "}",
  29. "._ input {",
  30. "display: inline;",
  31. "border: 0.3em solid #ccc;",
  32. "-moz-border-radius: 1em;",
  33. "width: 7em;",
  34. "padding: 0.2em 0;",
  35. "text-align: center;",
  36. "margin: 0 0.5em;",
  37. "}"
  38. ].join("\n"));
  39. style.position = "absolute";
  40. style.top = "0";
  41. style.left = "0";
  42. */
  43.  
  44. function resetStyle (ele, addtional) {
  45. if (!resetStyle.style) {
  46. resetStyle.style = [
  47. "azimuth: center;",
  48. "background: #fff;",
  49. "border: none;",
  50. "bottom: auto;",
  51. "caption-side: top;",
  52. "clear: none;",
  53. "clip: auto;",
  54. "color: #000;",
  55. "content: '';",
  56. "counter-increment: none;",
  57. "counter-reset: none;",
  58. "cue: none;",
  59. "cue-after: none;",
  60. "cue-before: none;",
  61. "cursor: auto;",
  62. "direction: ltr;",
  63. "display: block;",
  64. "elevation: level;",
  65. "empty-cells: show;",
  66. "float: none;",
  67. "font: normal;",
  68. "height: auto;",
  69. "left: auto;",
  70. "letter-spacing: none;",
  71. "list-style: disc outside none;",
  72. "margin: 0;",
  73. "marker-offset: auto;",
  74. "marks: none;",
  75. "max-height: none;",
  76. "max-width: none;",
  77. "min-height: 0;",
  78. "min-width: 0;",
  79. "orphans: 2;",
  80. "outline: none;",
  81. "overflow: visible;",
  82. "padding: 0;",
  83. "page: auto;",
  84. "page-break-after: auto;",
  85. "page-break-before: auto;",
  86. "page-break-inside: auto;",
  87. "position: static;",
  88. "right: auto;",
  89. "size: auto;",
  90. "speak: none;",
  91. "table-layout: auto;",
  92. "text-align: left;",
  93. "text-decoration: none;",
  94. "text-indent: 0;",
  95. "text-shadow: none;",
  96. "text-transform: none;",
  97. "top: auto;",
  98. "unicode-bidi: none;",
  99. "vertical-align: baseline;",
  100. "visibility: visible;",
  101. "white-space: normal;",
  102. "windows: 2;",
  103. "width: auto;",
  104. "z-index: auto;",
  105. ].join("");
  106. }
  107.  
  108. var className = "scriptreset" + String(Math.random()).slice(2);
  109.  
  110. var style = document.createElement('style');
  111. style.type = "text/css";
  112. style.appendChild(document.createTextNode([
  113. "." + className + " ,",
  114. "." + className + " * {",
  115. resetStyle.style.replace(/;/g, " !important;"),
  116. "} ",
  117. addtional.replace(/;/g, " !important;").replace(/_/g, className) || ""
  118. ].join("\n")));
  119.  
  120. ele.className += " " + className;
  121. document.getElementsByTagName('head')[0].appendChild(style);
  122. return ele.style;
  123. }
Add Comment
Please, Sign In to add comment