Advertisement
Guest User

lyto

a guest
Aug 17th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 17.56 KB | None | 0 0
  1. /*======================================================================*\
  2. || #################################################################### ||
  3. || # vBulletin 4.1.4
  4. || # ---------------------------------------------------------------- # ||
  5. || # Copyright ©2000-2011 vBulletin Solutions Inc. All Rights Reserved. ||
  6. || # This file may not be redistributed in whole or significant part. # ||
  7. || # ---------------- VBULLETIN IS NOT FREE SOFTWARE ---------------- # ||
  8. || # http://www.vbulletin.com | http://www.vbulletin.com/license.html # ||
  9. || #################################################################### ||
  10. \*======================================================================*/
  11. vBulletin.add_event("vBmenuShow");
  12. vBulletin.add_event("vBmenuHide");
  13.  
  14. function vB_Popup_Handler() {
  15. this.open_steps = 10;
  16. this.open_fade = false;
  17. this.active = false;
  18. this.menus = new Array();
  19. this.activemenu = null;
  20. this.suggest = null
  21. }
  22. vB_Popup_Handler.prototype.activate = function(A) {
  23. this.active = A;
  24. console.log("vBmenu :: System Activated")
  25. };
  26. vB_Popup_Handler.prototype.register = function(D, A, C) {
  27. this.menus[D] = new vB_Popup_Menu(D, A, C);
  28. var B = YAHOO.util.Dom.get("usercss");
  29. if (B && YAHOO.util.Dom.isAncestor(B, D)) {
  30. this.menus[D].imgsrc = IMGDIR_MISC + "/black_downward_arrow.png"
  31. }
  32. this.menus[D].startup();
  33. return this.menus[D]
  34. };
  35. vB_Popup_Handler.prototype.register_suggest = function(B, A) {
  36. this.suggest = new vB_Popup_Suggest(B, A);
  37. return this.suggest
  38. };
  39. vB_Popup_Handler.prototype.hide = function() {
  40. if (this.activemenu != null) {
  41. this.menus[this.activemenu].hide()
  42. }
  43. if (this.suggest != null) {
  44. this.suggest.hide()
  45. }
  46. };
  47. var vBmenu = new vB_Popup_Handler();
  48.  
  49. function vbmenu_hide(A) {
  50. if (A && A.button && A.button != 1 && A.type == "click") {
  51. return true
  52. } else {
  53. vBmenu.hide()
  54. }
  55. }
  56.  
  57. function vB_Popup_Menu(C, A, B) {
  58. this.controlkey = C;
  59. this.noimage = A;
  60. this.noslide = B;
  61. this.menuname = this.controlkey.split(".")[0] + "_menu";
  62. this.imgsrc = IMGDIR_MISC + "/black_downward_arrow.png"
  63. }
  64. vB_Popup_Menu.prototype.startup = function() {
  65. this.init_control(this.noimage);
  66. if (fetch_object(this.menuname)) {
  67. this.init_menu()
  68. }
  69. this.slide_open = (this.noslide ? false : true);
  70. this.open_steps = vBmenu.open_steps;
  71. vBulletin.add_event("vBmenuShow_" + this.controlkey);
  72. vBulletin.add_event("vBmenuHide_" + this.controlkey)
  73. };
  74. vB_Popup_Menu.prototype.init_control = function(A) {
  75. this.controlobj = fetch_object(this.controlkey);
  76. this.controlobj.state = false;
  77. if (this.controlobj.firstChild && (this.controlobj.firstChild.tagName == "TEXTAREA" || this.controlobj.firstChild.tagName == "INPUT")) {} else {
  78. if (!A && !(is_mac && is_ie)) {
  79. var C = document.createTextNode(" ");
  80. this.controlobj.appendChild(C);
  81. var B = document.createElement("img");
  82. B.src = this.imgsrc;
  83. B.border = 0;
  84. B.title = "";
  85. B.alt = "";
  86. B.setAttribute("style", "vertical-align: middle");
  87. this.img = this.controlobj.appendChild(B)
  88. }
  89. this.controlobj.unselectable = true;
  90. if (!A) {
  91. this.controlobj.style.cursor = pointer_cursor
  92. }
  93. this.controlobj.onclick = vB_Popup_Events.prototype.controlobj_onclick;
  94. this.controlobj.onmouseover = vB_Popup_Events.prototype.controlobj_onmouseover
  95. }
  96. };
  97. vB_Popup_Menu.prototype.init_menu = function() {
  98. this.menuobj = fetch_object(this.menuname);
  99. this.select_handler = new vB_Select_Overlay_Handler(this.menuobj);
  100. if (this.menuobj && !this.menuobj.initialized) {
  101. this.menuobj.initialized = true;
  102. this.menuobj.onclick = e_by_gum;
  103. this.menuobj.style.position = "absolute";
  104. this.menuobj.style.zIndex = 50;
  105. if (is_ie && !is_mac) {
  106. if (YAHOO.env.ua.ie < 7) {
  107. this.menuobj.style.filter += "alpha(enabled=1,opacity=100)"
  108. } else {
  109. this.menuobj.style.minHeight = "1%"
  110. }
  111. }
  112. this.init_menu_contents()
  113. }
  114. };
  115. vB_Popup_Menu.prototype.init_menu_contents = function() {
  116. var E = new Array("td", "li");
  117. for (var D = 0; D < E.length; D++) {
  118. var H = fetch_tags(this.menuobj, E[D]);
  119. for (var F = 0; F < H.length; F++) {
  120. if (H[F].className == "vbmenu_option") {
  121. if (H[F].title && H[F].title == "nohilite") {
  122. H[F].title = ""
  123. } else {
  124. H[F].controlkey = this.controlkey;
  125. H[F].onmouseover = vB_Popup_Events.prototype.menuoption_onmouseover;
  126. H[F].onmouseout = vB_Popup_Events.prototype.menuoption_onmouseout;
  127. var C = fetch_tags(H[F], "a");
  128. if (C.length == 1) {
  129. H[F].className = H[F].className + " vbmenu_option_alink";
  130. H[F].islink = true;
  131. var B = C[0];
  132. var A = false;
  133. H[F].target = B.getAttribute("target");
  134. if (typeof B.onclick == "function") {
  135. H[F].ofunc = B.onclick;
  136. H[F].onclick = vB_Popup_Events.prototype.menuoption_onclick_function;
  137. A = true
  138. } else {
  139. if (typeof H[F].onclick == "function") {
  140. H[F].ofunc = H[F].onclick;
  141. H[F].onclick = vB_Popup_Events.prototype.menuoption_onclick_function;
  142. A = true
  143. } else {
  144. H[F].href = B.href;
  145. H[F].onclick = vB_Popup_Events.prototype.menuoption_onclick_link
  146. }
  147. }
  148. if (A) {
  149. var G = document.createElement("a");
  150. G.innerHTML = B.innerHTML;
  151. G.href = "#";
  152. G.onclick = function(I) {
  153. I = I ? I : window.event;
  154. I.returnValue = false;
  155. return false
  156. };
  157. H[F].insertBefore(G, B);
  158. H[F].removeChild(B)
  159. }
  160. } else {
  161. if (typeof H[F].onclick == "function") {
  162. H[F].ofunc = H[F].onclick;
  163. H[F].onclick = vB_Popup_Events.prototype.menuoption_onclick_function
  164. }
  165. }
  166. }
  167. }
  168. if (H[F].title == "nohilite") {
  169. H[F].title = ""
  170. }
  171. }
  172. }
  173. };
  174. vB_Popup_Menu.prototype.show = function(B, A) {
  175. if (!vBmenu.active) {
  176. return false
  177. } else {
  178. if (!this.menuobj) {
  179. this.init_menu()
  180. }
  181. }
  182. if (!this.menuobj || vBmenu.activemenu == this.controlkey) {
  183. return false
  184. }
  185. console.log("vBmenu :: Show '%s'", this.controlkey);
  186. if (vBmenu.activemenu != null && vBmenu.activemenu != this.controlkey) {
  187. vBmenu.menus[vBmenu.activemenu].hide()
  188. }
  189. if (vBmenu.suggest != null) {
  190. vBmenu.suggest.hide()
  191. }
  192. vBmenu.activemenu = this.controlkey;
  193. this.menuobj.style.display = "";
  194. if (this.slide_open) {
  195. this.menuobj.style.clip = "rect(auto, 0px, 0px, auto)"
  196. }
  197. this.set_menu_position(B);
  198. if (!A && this.slide_open) {
  199. this.intervalX = Math.ceil(this.menuobj.offsetWidth / this.open_steps);
  200. this.intervalY = Math.ceil(this.menuobj.offsetHeight / this.open_steps);
  201. this.slide((this.direction == "left" ? 0 : this.menuobj.offsetWidth), 0, 0)
  202. } else {
  203. if (this.menuobj.style.clip && this.slide_open) {
  204. this.menuobj.style.clip = "rect(auto, auto, auto, auto)"
  205. }
  206. }
  207. this.select_handler.hide();
  208. if (this.controlobj.editorid) {
  209. this.controlobj.state = true;
  210. vB_Editor[this.controlobj.editorid].menu_context(this.controlobj, "mousedown")
  211. }
  212. vBulletin.events["vBmenuShow_" + this.controlkey].fire(this.controlkey);
  213. vBulletin.events.vBmenuShow.fire(this.controlkey)
  214. };
  215. vB_Popup_Menu.prototype.set_menu_position = function(A) {
  216. var B = YAHOO.util.Dom.getXY(A);
  217. this.leftpx = B[0];
  218. this.toppx = B[1] + A.offsetHeight;
  219. if (((this.leftpx + this.menuobj.offsetWidth) >= document.body.clientWidth) && ((this.leftpx + A.offsetWidth - this.menuobj.offsetWidth) > 0)) {
  220. this.leftpx = this.leftpx + A.offsetWidth - this.menuobj.offsetWidth;
  221. this.direction = "right"
  222. } else {
  223. this.direction = "left"
  224. }
  225. if (this.controlkey.match(/^pagenav\.\d+$/)) {
  226. A.appendChild(this.menuobj)
  227. }
  228. YAHOO.util.Dom.setXY(this.menuobj, [this.leftpx, this.toppx])
  229. };
  230. vB_Popup_Menu.prototype.hide = function(A) {
  231. if (A && A.button && A.button != 1) {
  232. return true
  233. }
  234. console.log("vBmenu :: Hide '%s'", this.controlkey);
  235. this.stop_slide();
  236. this.menuobj.style.display = "none";
  237. this.select_handler.show();
  238. if (this.controlobj.editorid) {
  239. this.controlobj.state = false;
  240. vB_Editor[this.controlobj.editorid].menu_context(this.controlobj, "mouseout")
  241. }
  242. vBmenu.activemenu = null;
  243. vBulletin.events["vBmenuHide_" + this.controlkey].fire(this.controlkey);
  244. vBulletin.events.vBmenuHide.fire(this.controlkey)
  245. };
  246. vB_Popup_Menu.prototype.hover = function(A) {
  247. if (vBmenu.activemenu != null) {
  248. if (vBmenu.menus[vBmenu.activemenu].controlkey != this.id) {
  249. this.show(A, true)
  250. }
  251. }
  252. };
  253. vB_Popup_Menu.prototype.slide = function(C, B, A) {
  254. if (this.direction == "left" && (C < this.menuobj.offsetWidth || B < this.menuobj.offsetHeight)) {
  255. C += this.intervalX;
  256. B += this.intervalY;
  257. this.menuobj.style.clip = "rect(auto, " + C + "px, " + B + "px, auto)";
  258. this.slidetimer = setTimeout("vBmenu.menus[vBmenu.activemenu].slide(" + C + ", " + B + ", " + A + ");", 0)
  259. } else {
  260. if (this.direction == "right" && (C > 0 || B < this.menuobj.offsetHeight)) {
  261. C -= this.intervalX;
  262. B += this.intervalY;
  263. this.menuobj.style.clip = "rect(auto, " + this.menuobj.offsetWidth + "px, " + B + "px, " + C + "px)";
  264. this.slidetimer = setTimeout("vBmenu.menus[vBmenu.activemenu].slide(" + C + ", " + B + ", " + A + ");", 0)
  265. } else {
  266. this.stop_slide()
  267. }
  268. }
  269. };
  270. vB_Popup_Menu.prototype.stop_slide = function() {
  271. clearTimeout(this.slidetimer);
  272. this.menuobj.style.clip = "rect(auto, auto, auto, auto)"
  273. };
  274.  
  275. function vB_Popup_Events() {}
  276. vB_Popup_Events.prototype.controlobj_onclick = function(A) {
  277. if (typeof do_an_e == "function") {
  278. do_an_e(A);
  279. if (vBmenu.activemenu == null || vBmenu.menus[vBmenu.activemenu].controlkey != this.id) {
  280. vBmenu.menus[this.id].show(this)
  281. } else {
  282. vBmenu.menus[this.id].hide()
  283. }
  284. }
  285. };
  286. vB_Popup_Events.prototype.controlobj_onmouseover = function(A) {
  287. if (typeof do_an_e == "function") {
  288. do_an_e(A);
  289. vBmenu.menus[this.id].hover(this)
  290. }
  291. };
  292. vB_Popup_Events.prototype.menuoption_onclick_function = function(A) {
  293. this.ofunc(A);
  294. vBmenu.menus[this.controlkey].hide()
  295. };
  296. vB_Popup_Events.prototype.menuoption_onclick_link = function(A) {
  297. A = A ? A : window.event;
  298. A.cancelBubble = true;
  299. if (A.stopPropagation) {
  300. A.stopPropagation()
  301. }
  302. if (A.preventDefault) {
  303. A.preventDefault()
  304. }
  305. if (A.shiftKey || (this.target != null && this.target != "" && this.target.toLowerCase() != "_self")) {
  306. if (this.target != null && this.target.charAt(0) != "_") {
  307. window.open(this.href, this.target)
  308. } else {
  309. window.open(this.href)
  310. }
  311. } else {
  312. window.location = this.href
  313. }
  314. vBmenu.menus[this.controlkey].hide();
  315. return false
  316. };
  317. vB_Popup_Events.prototype.menuoption_onmouseover = function(A) {
  318. this.className = "vbmenu_hilite" + (this.islink ? " vbmenu_hilite_alink" : "");
  319. this.style.cursor = pointer_cursor
  320. };
  321. vB_Popup_Events.prototype.menuoption_onmouseout = function(A) {
  322. this.className = "vbmenu_option" + (this.islink ? " vbmenu_option_alink" : "");
  323. this.style.cursor = "default"
  324. };
  325.  
  326. function vB_Popup_Suggest(B, A) {
  327. this.controlkey = B;
  328. this.noslide = A;
  329. this.menuname = this.controlkey.split(".")[0] + "_menu";
  330. this.startup()
  331. }
  332. vB_Popup_Suggest.prototype.init_menu = vB_Popup_Menu.prototype.init_menu;
  333. vB_Popup_Suggest.prototype.set_menu_position = vB_Popup_Menu.prototype.set_menu_position;
  334. vB_Popup_Suggest.prototype.startup = function() {
  335. this.init_control(this.noimage);
  336. if (fetch_object(this.menuname)) {
  337. this.init_menu()
  338. }
  339. this.slide_open = (this.noslide ? false : true);
  340. this.open_steps = vBmenu.open_steps
  341. };
  342. vB_Popup_Suggest.prototype.init_control = function(A) {
  343. this.controlobj = fetch_object(this.controlkey);
  344. this.controlobj.state = false;
  345. this.controlobj.unselectable = true;
  346. YAHOO.util.Event.addListener(this.controlobj, "click", this.controlobj_onclick, this, true)
  347. };
  348. vB_Popup_Suggest.prototype.controlobj_onclick = function() {
  349. this.hide()
  350. };
  351. vB_Popup_Suggest.prototype.init_menu_contents = function() {
  352. var E = new Array("td", "li");
  353. for (var D = 0; D < E.length; D++) {
  354. var H = fetch_tags(this.menuobj, E[D]);
  355. for (var F = 0; F < H.length; F++) {
  356. if (H[F].className == "vbmenu_option" || H[F].className == "vbmenu_hilite") {
  357. if (H[F].title && H[F].title == "nohilite") {
  358. H[F].title = ""
  359. } else {
  360. H[F].controlkey = this.controlkey;
  361. var C = fetch_tags(H[F], "a");
  362. if (C.length == 1) {
  363. H[F].className = H[F].className + " vbmenu_option_alink";
  364. H[F].islink = true;
  365. var B = C[0];
  366. var A = false;
  367. H[F].target = B.getAttribute("target");
  368. if (typeof B.onclick == "function") {
  369. H[F].onclink = B.onclick;
  370. A = true
  371. }
  372. var G = document.createElement("a");
  373. G.innerHTML = B.innerHTML;
  374. G.href = "#";
  375. G.onclick = function(I) {
  376. I = I ? I : window.event;
  377. I.returnValue = false;
  378. return false
  379. };
  380. H[F].insertBefore(G, B);
  381. H[F].removeChild(B)
  382. }
  383. }
  384. }
  385. }
  386. }
  387. };
  388. vB_Popup_Suggest.prototype.show = function(B, A) {
  389. if (!vBmenu.active) {
  390. return false
  391. } else {
  392. if (!this.menuobj) {
  393. this.init_menu()
  394. }
  395. }
  396. if (!this.menuobj) {
  397. return false
  398. }
  399. vBmenu.suggest = this;
  400. console.log("vBSuggest :: Show '%s'", this.controlkey);
  401. this.menuobj.style.display = "";
  402. if (this.slide_open) {
  403. this.menuobj.style.clip = "rect(auto, 0px, 0px, auto)"
  404. }
  405. this.set_menu_position(B);
  406. if (!A && this.slide_open) {
  407. this.intervalX = Math.ceil(this.menuobj.offsetWidth / this.open_steps);
  408. this.intervalY = Math.ceil(this.menuobj.offsetHeight / this.open_steps);
  409. this.slide((this.direction == "left" ? 0 : this.menuobj.offsetWidth), 0, 0)
  410. } else {
  411. if (this.menuobj.style.clip && this.slide_open) {
  412. this.menuobj.style.clip = "rect(auto, auto, auto, auto)"
  413. }
  414. }
  415. this.select_handler.hide()
  416. };
  417. vB_Popup_Suggest.prototype.hide = function(A) {
  418. if (A && A.button && A.button != 1) {
  419. return true
  420. }
  421. console.log("vBSuggest :: Hide '%s'", this.controlkey);
  422. this.stop_slide();
  423. this.menuobj.style.display = "none";
  424. this.select_handler.show()
  425. };
  426. vB_Popup_Suggest.prototype.slide = function(C, B, A) {
  427. if (this.direction == "left" && (C < this.menuobj.offsetWidth || B < this.menuobj.offsetHeight)) {
  428. C += this.intervalX;
  429. B += this.intervalY;
  430. this.menuobj.style.clip = "rect(auto, " + C + "px, " + B + "px, auto)";
  431. this.slidetimer = setTimeout(this.slide_call(C, B, A), 0)
  432. } else {
  433. if (this.direction == "right" && (C > 0 || B < this.menuobj.offsetHeight)) {
  434. C -= this.intervalX;
  435. B += this.intervalY;
  436. this.menuobj.style.clip = "rect(auto, " + this.menuobj.offsetWidth + "px, " + B + "px, " + C + "px)";
  437. this.slidetimer = setTimeout(this.slide_call(C, B, A), 0)
  438. } else {
  439. this.stop_slide()
  440. }
  441. }
  442. };
  443. vB_Popup_Suggest.prototype.slide_call = function(C, B, A) {
  444. var D = this;
  445. return function() {
  446. return D.slide(C, B, A)
  447. }
  448. };
  449. vB_Popup_Suggest.prototype.stop_slide = function() {
  450. clearTimeout(this.slidetimer);
  451. delete this.slidetimer;
  452. this.menuobj.style.clip = "rect(auto, auto, auto, auto)"
  453. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement