Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.45 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width">
  6. <title>JS Bin</title>
  7. </head>
  8. <body>
  9.  
  10. <script id="jsbin-javascript">
  11. var menuData = {
  12. menu: [
  13. {
  14. name: "language",
  15. icon: "icon-switcher",
  16. display: false,
  17. alias: "Language",
  18. value: "Change the language",
  19. menus: [
  20. {
  21. name: "English",
  22. icon: "",
  23. display: false,
  24. alias: "/SwithtoEnglish"
  25. },
  26. {
  27. name: "Spanish",
  28. icon: "",
  29. display: false,
  30. alias: "/SwithtoSpanish"
  31. }
  32. ]
  33. },
  34. {
  35. name: "panic",
  36. icon: "icon-panic",
  37. display: false,
  38. alias: "/help"
  39. }
  40. ]
  41. };
  42. var menuDiv = "";
  43. var buildChatMenu = function(menu) {
  44. var dropDownLi;
  45. if (!menu.menus) {
  46. dropDownLi = `<li><span class="${
  47. menu.icon ? menu.icon : ""
  48. }"></span><a tabindex="-1" href="#" data-display=${
  49. menu.display ? menu.display : true
  50. } data-alias=${menu.alias ? menu.alias : ""}>${menu.name}</a></li>`;
  51. } else {
  52. dropDownLi = `<li class="dropdown-submenu"><span class="${menu.icon}"></span>
  53. <a class="submenu" tabindex="-1" href="#"><span class="caret"></span></a>`
  54. }
  55. };
  56. for (var key in menuData.menu) {
  57. menuDiv = `<ul id="chatMenuDropdown" class="dropdown-menu"></ul`;
  58. buildChatMenu(menuData.menu[key]);
  59. }
  60.  
  61. // var setListenersMenu = function() {
  62. // $(".chatActionIcons")
  63. // .off("click")
  64. // .on("click", function() {
  65. // $(this)
  66. // .find("#chatMenuDropdown")
  67. // .get(0)
  68. // .classList.toggle("show");
  69. // });
  70. // };
  71.  
  72. // $("body").on("click", function(event) {
  73. // if (!event.target.matches("#panicButton")) {
  74. // var dropdowns = document.getElementsByClassName("dropdown-content");
  75. // var i;
  76. // for (i = 0; i < dropdowns.length; i++) {
  77. // var openDropdown = dropdowns[i];
  78. // console.log("clicked:::", openDropdown.classList.contains("show"));
  79. // if (openDropdown.classList.contains("show")) {
  80. // openDropdown.classList.remove("show");
  81. // }
  82. // }
  83. // }
  84. // });
  85. // var buildMenuButton = function(menuList) {
  86. // var list = menuList
  87. // .map((menu, i) => {
  88. // return `<a href="#" data-value="${
  89. // menu.value ? menu.value : ""
  90. // }" data-alias="${menu.alias ? menu.alias : ""}">${menu.name}</a>`;
  91. // })
  92. // .join("");
  93. // var div = `<div id="chatMenuDropdown" class="dropdown-content">
  94. // ${list}
  95. // </div>`;
  96. // $("#chatMenuDropdown").remove();
  97. // $(div).appendTo("header .chatActionIcons");
  98. // $("#panicButton").off("click");
  99. // setListenersMenu();
  100. // };
  101.  
  102. // $("body").on("click", "#chatMenuDropdown a", function(event) {
  103. // var msgObj = getMsgObj(this);
  104. // SentMessage_Func(msgObj);
  105. // });
  106. </script>
  107.  
  108.  
  109.  
  110. <script id="jsbin-source-javascript" type="text/javascript">var menuData = {
  111. menu: [
  112. {
  113. name: "language",
  114. icon: "icon-switcher",
  115. display: false,
  116. alias: "Language",
  117. value: "Change the language",
  118. menus: [
  119. {
  120. name: "English",
  121. icon: "",
  122. display: false,
  123. alias: "/SwithtoEnglish"
  124. },
  125. {
  126. name: "Spanish",
  127. icon: "",
  128. display: false,
  129. alias: "/SwithtoSpanish"
  130. }
  131. ]
  132. },
  133. {
  134. name: "panic",
  135. icon: "icon-panic",
  136. display: false,
  137. alias: "/help"
  138. }
  139. ]
  140. };
  141. var menuDiv = "";
  142. var buildChatMenu = function(menu) {
  143. var dropDownLi;
  144. if (!menu.menus) {
  145. dropDownLi = `<li><span class="${
  146. menu.icon ? menu.icon : ""
  147. }"></span><a tabindex="-1" href="#" data-display=${
  148. menu.display ? menu.display : true
  149. } data-alias=${menu.alias ? menu.alias : ""}>${menu.name}</a></li>`;
  150. } else {
  151. dropDownLi = `<li class="dropdown-submenu"><span class="${menu.icon}"></span>
  152. <a class="submenu" tabindex="-1" href="#"><span class="caret"></span></a>`
  153. }
  154. };
  155. for (var key in menuData.menu) {
  156. menuDiv = `<ul id="chatMenuDropdown" class="dropdown-menu"></ul`;
  157. buildChatMenu(menuData.menu[key]);
  158. }
  159.  
  160. // var setListenersMenu = function() {
  161. // $(".chatActionIcons")
  162. // .off("click")
  163. // .on("click", function() {
  164. // $(this)
  165. // .find("#chatMenuDropdown")
  166. // .get(0)
  167. // .classList.toggle("show");
  168. // });
  169. // };
  170.  
  171. // $("body").on("click", function(event) {
  172. // if (!event.target.matches("#panicButton")) {
  173. // var dropdowns = document.getElementsByClassName("dropdown-content");
  174. // var i;
  175. // for (i = 0; i < dropdowns.length; i++) {
  176. // var openDropdown = dropdowns[i];
  177. // console.log("clicked:::", openDropdown.classList.contains("show"));
  178. // if (openDropdown.classList.contains("show")) {
  179. // openDropdown.classList.remove("show");
  180. // }
  181. // }
  182. // }
  183. // });
  184. // var buildMenuButton = function(menuList) {
  185. // var list = menuList
  186. // .map((menu, i) => {
  187. // return `<a href="#" data-value="${
  188. // menu.value ? menu.value : ""
  189. // }" data-alias="${menu.alias ? menu.alias : ""}">${menu.name}</a>`;
  190. // })
  191. // .join("");
  192. // var div = `<div id="chatMenuDropdown" class="dropdown-content">
  193. // ${list}
  194. // </div>`;
  195. // $("#chatMenuDropdown").remove();
  196. // $(div).appendTo("header .chatActionIcons");
  197. // $("#panicButton").off("click");
  198. // setListenersMenu();
  199. // };
  200.  
  201. // $("body").on("click", "#chatMenuDropdown a", function(event) {
  202. // var msgObj = getMsgObj(this);
  203. // SentMessage_Func(msgObj);
  204. // });
  205.  
  206.  
  207.  
  208.  
  209. </script></body>
  210. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement