Hormold

VK Change (#1381760103)

Oct 14th, 2013
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 15.30 KB | None | 0 0
  1. Файл - tooltips.js (Старый размер - 12550 | Новый - 0):
  2. 0.  - var tooltips = {
  3. 1.  -   show: function(el, options) {
  4. 2.  -     if (el.hidetimer) {
  5. 3.  -       if (el.hidetimer) clearTimeout(el.hidetimer);
  6. 4.  -       el.hidetimer = 0;
  7. 5.  -       return;
  8. 6.  -     }
  9. 7.  -     if (!el.tt) return;
  10. 8.  -     if (el.ttimer) clearTimeout(el.ttimer);
  11. 9.  -
  12. 10.  -     var opts = extend(el.tt.opts ? clone(el.tt.opts) : {}, options || {});
  13. 11.  -     if (!el.tt.el) {
  14. 12.  -       el.tt = 'show';
  15. 13.  -       el.ttimer = setTimeout(function() {
  16. 14.  -         if (el.tt.el) {
  17. 15.  -           opts.showdt = 0;
  18. 16.  -           tooltips.show(el, opts);
  19. 17.  -           return;
  20. 18.  -         }
  21. 19.  -         el.tt = 'shownow';
  22. 20.  -       }, opts.showdt || 0);
  23. 21.  -       return;
  24. 22.  -     }
  25. 23.  -     var canshow = opts.js ? (eval('(function(){return function(){var tip=this;' + opts.js + '};})()').apply(el.tt) !== false) : true;
  26. 24.  -     if (!canshow) {
  27. 25.  -       return;
  28. 26.  -     }
  29. 27.  -     if (isVisible(el.tt.container)) {
  30. 28.  -       if (!el.tt.showing) {
  31. 29.  -         animate(el.tt.container, {opacity: 1}, opts.showsp !== undefined ? opts.showsp : 200);
  32. 30.  -       }
  33. 31.  -       return;
  34. 32.  -     }
  35. 33.  -     el.ttimer = setTimeout(function() {
  36. 34.  -       var container = el.tt.container;
  37. 35.  -       if (isVisible(container)) return;
  38. 36.  -
  39. 37.  -       var fix = el.tt.isFixed || false, xy = opts.forcexy ? opts.forcexy : getXY(el, fix),
  40. 38.  -           elsize = opts.forcesize ? opts.forcesize : getSize(el),
  41. 39.  -           toup = opts.toup,
  42. 40.  -           asrtl = vk.rtl && !opts.asrtl || opts.asrtl && !vk.rtl;
  43. 41.  -       if (!elsize[0] && !elsize[1]) {
  44. 42.  -         hide(el.tt.container);
  45. 43.  -         return;
  46. 44.  -       }
  47. 45.  -
  48. 46.  -       container.style.opacity = 0;
  49. 47.  -       show(container);
  50. 48.  -       container.firstChild.className = 'toup' + (opts.toup ? 1 : '');
  51. 49.  -       var st = fix ? 0 : (bodyNode.scrollTop || htmlNode.scrollTop || 0), ttsize = getSize(container), needDown = (xy[1] - ttsize[1] - opts.shift[1]) < st, needUp = (xy[1] + elsize[1] + ttsize[1] + opts.shift[2] - lastWindowHeight) > st;
  52. 50.  -       if (browser.msie7) {
  53. 51.  -         setStyle(container, {width: ttsize[0]});
  54. 52.  -       }
  55. 53.  -
  56. 54.  -       var needLeft = (opts.black && lastWindowWidth && lastWindowWidth - (xy[0] + ttsize[0]) < 1);
  57. 55.  -
  58. 56.  -       if (toup && needDown) {
  59. 57.  -         toup = false;
  60. 58.  -       } else if (!toup && needUp && !needDown) {
  61. 59.  -         toup = true;
  62. 60.  -       }
  63. 61.  -       if (opts.forcetodown) toup = false;
  64. 62.  -       if (opts.forcetoup) toup = true;
  65. 63.  -       if (toup != opts.toup || needLeft) {
  66. 64.  -         container.firstChild.className = 'toup' + (toup ? 1 : '') + (needLeft ? ' toleft' : '');
  67. 65.  -         ttsize = getSize(container);
  68. 66.  -       }
  69. 67.  -       var newtop = xy[1] + (toup ? -(ttsize[1] + opts.shift[1]) : (elsize[1] + opts.shift[2]));
  70. 68.  -       var starttop = newtop + intval(opts.slide) * (toup ? -1 : 1);
  71. 69.  -       var newleft = xy[0] + (asrtl ? (opts.shift[0] + elsize[0] - ttsize[0]) : (toup ? -opts.shift[0] : -(opts.shift[3] || opts.shift[0])));
  72. 70.  -       if (needLeft) {
  73. 71.  -         newleft -= ttsize[0] - 39;
  74. 72.  -       }
  75. 73.  -
  76. 74.  -       if (opts.center && ttsize[0] != elsize[0]) {
  77. 75.  -         newleft -= (ttsize[0] - elsize[0]) / 2;
  78. 76.  -         var pointer = geByClass1(toup ? 'bottom_pointer' : 'top_pointer', container)
  79. 77.  -         if (pointer) {
  80. 78.  -           setStyle(pointer, {marginLeft: ((ttsize[0] - getSize(pointer)[0]) / 2 || 0) + 'px'});
  81. 79.  -         }
  82. 80.  -       }
  83. 81.  -
  84. 82.  -       var startleft = newleft + intval(opts.slideX);
  85. 83.  -
  86. 84.  -       el.tt.showing = true;
  87. 85.  -       setStyle(container, {top: starttop, left: startleft});
  88. 86.  -       animate(container, {top: newtop, left: newleft, opacity: 1}, opts.showsp !== undefined ? opts.showsp : 200, function() {
  89. 87.  -         el.tt && el.tt.showing && (el.tt.showing = false);
  90. 88.  -         if (opts.onShowEnd) opts.onShowEnd();
  91. 89.  -       });
  92. 90.  -       if (opts.onShowStart) opts.onShowStart(el.tt);
  93. 91.  -     }, opts.showdt || 0);
  94. 92.  -   },
  95. 93.  -   hide: function(el, options) {
  96. 94.  -     if ((options || {}).fasthide) {
  97. 95.  -       clearTimeout(el.hidetimer);
  98. 96.  -       clearTimeout(el.ttimer);
  99. 97.  -       el.hidetimer = 0;
  100. 98.  -       if (el.tt && el.tt.el) hide(el.tt.container);
  101. 99.  -       return;
  102. 100.  -     }
  103. 101.  -     if (el.hidetimer) return;
  104. 102.  -     el.hidetimer = setTimeout(function() {
  105. 103.  -       el.hidetimer = 0;
  106. 104.  -       clearTimeout(el.ttimer);
  107. 105.  -       if (!el.tt || el.tt == 'hide' || el.tt.el && !isVisible(el.tt.container)) return;
  108. 106.  -
  109. 107.  -       var opts = extend(el.tt.opts ? clone(el.tt.opts) : {}, options || {});
  110. 108.  -       if (!el.tt.el) {
  111. 109.  -         el.tt = 'hide';
  112. 110.  -         return;
  113. 111.  -       }
  114. 112.  -       el.ttimer = setTimeout(function() {
  115. 113.  -         if (!opts.hasover) {
  116. 114.  -           setStyle(el.tt.container, {pointerEvents: 'none'});
  117. 115.  -         }
  118. 116.  -         fadeOut(el.tt.container, opts.showsp !== undefined ? opts.showsp : 200, function() {
  119. 117.  -           if (el.tt && el.tt.container) {
  120. 118.  -             setStyle(el.tt.container, {pointerEvents: 'auto'});
  121. 119.  -           }
  122. 120.  -         });
  123. 121.  -         if (opts.onHide) {
  124. 122.  -           opts.onHide();
  125. 123.  -         }
  126. 124.  -       }, opts.hidedt || 0);
  127. 125.  -     }, 1);
  128. 126.  -   },
  129. 127.  -   hideAll: function() {
  130. 128.  -     if (!cur.tooltips) return;
  131. 129.  -     for (var i = 0; i < cur.tooltips.length; ++i) {
  132. 130.  -       if (cur.tooltips[i].el && cur.tooltips[i].el.ttimer) {
  133. 131.  -         clearTimeout(cur.tooltips[i].el.ttimer);
  134. 132.  -       }
  135. 133.  -       cur.tooltips[i].hide({fasthide: true});
  136. 134.  -     }
  137. 135.  -   },
  138. 136.  -   rePositionAll: function() {
  139. 137.  -     if (!cur.tooltips) return;
  140. 138.  -     for (var i = 0; i < cur.tooltips.length; ++i) {
  141. 139.  -       var opts = cur.tooltips[i].opts;
  142. 140.  -       if (!opts || !opts.nohideover && !opts.nohide) continue;
  143. 141.  -
  144. 142.  -       var el = cur.tooltips[i].el,
  145. 143.  -           tt = cur.tooltips[i],
  146. 144.  -           container = tt.container;
  147. 145.  -
  148. 146.  -       var fix = tt.isFixed || false, xy = getXY(el, fix),
  149. 147.  -           elsize = getSize(el),
  150. 148.  -           asrtl = vk.rtl && !opts.asrtl || opts.asrtl && !vk.rtl;
  151. 149.  -       if (!elsize[0] && !elsize[1]) continue;
  152. 150.  -
  153. 151.  -       var ttsize = getSize(container);
  154. 152.  -       var needLeft = (opts.black && lastWindowWidth && lastWindowWidth - (xy[0] + ttsize[0]) < 1);
  155. 153.  -       var toup = hasClass(container.firstChild, 'toup1');
  156. 154.  -       var newleft = xy[0] + (asrtl ? (opts.shift[0] + elsize[0] - ttsize[0]) : (toup ? -opts.shift[0] : -(opts.shift[3] || opts.shift[0])));
  157. 155.  -       if (needLeft) {
  158. 156.  -         newleft -= ttsize[0] - 39;
  159. 157.  -       }
  160. 158.  -       if (opts.center && ttsize[0] != elsize[0]) {
  161. 159.  -         newleft -= (ttsize[0] - elsize[0]) / 2;
  162. 160.  -       }
  163. 161.  -       var startleft = newleft + intval(opts.slideX);
  164. 162.  -       setStyle(container, {left: startleft});
  165. 163.  -     }
  166. 164.  -   },
  167. 165.  -   destroy: function(el) {
  168. 166.  -     if (!el) return;
  169. 167.  -
  170. 168.  -     clearTimeout(el.ttimer);
  171. 169.  -     clearTimeout(el.hidetimer);
  172. 170.  -
  173. 171.  -     if (el.tt && el.tt.el) {
  174. 172.  -       if (el.tt.onClean) el.tt.onClean();
  175. 173.  -
  176. 174.  -       cleanElems(el.tt.container);
  177. 175.  -       removeEvent(el, 'mouseout', el.tthide);
  178. 176.  -       if (el.tt.container) { // somehow ?? it can be undefined here
  179. 177.  -         bodyNode.removeChild(el.tt.container);
  180. 178.  -       }
  181. 179.  -
  182. 180.  -       el.tt.el = false;
  183. 181.  -     }
  184. 182.  -     removeAttr(el, 'tt', 'tthide', 'ttimer', 'hidetimer');
  185. 183.  -   },
  186. 184.  -   destroyAll: function(ancestor) {
  187. 185.  -     if (!cur.tooltips) return;
  188. 186.  -
  189. 187.  -     for (var i = 0; i < cur.tooltips.length; ++i) {
  190. 188.  -       if (ancestor && !isAncestor(cur.tooltips[i].el, ancestor)) {
  191. 189.  -         continue;
  192. 190.  -       }
  193. 191.  -       cur.tooltips[i].destroy();
  194. 192.  -     }
  195. 193.  -     if (!ancestor) {
  196. 194.  -       delete cur.tooltips;
  197. 195.  -     }
  198. 196.  -   },
  199. 197.  -
  200. 198.  -   create: function(el, options) {
  201. 199.  -     var opts = extend({
  202. 200.  -       shift: (options.black ? [11, 3, 3] : [2, 3, 3]), // [leftShift, toupTopShift, notToupTopShift]
  203. 201.  -       toup: true
  204. 202.  -     }, options);
  205. 203.  -     if (!el.tthide) {
  206. 204.  -       el.tthide = tooltips.hide.pbind(el);
  207. 205.  -       if (!options.nohide) addEvent(el, 'mouseout', el.tthide);
  208. 206.  -     }
  209. 207.  -     var no_shadow = opts.no_shadow ? ' no_shadow' : '';
  210. 208.  -     if (!opts.content) {
  211. 209.  -       if (el.tt && !opts.force) {
  212. 210.  -         if (el.hidetimer) {
  213. 211.  -           clearTimeout(el.hidetimer);
  214. 212.  -           el.hidetimer = 0;
  215. 213.  -           return;
  216. 214.  -         }
  217. 215.  -         return;
  218. 216.  -       }
  219. 217.  -       if (!opts.text) {
  220. 218.  -         if (!opts.url) return;
  221. 219.  -         clearTimeout(el.ttimer);
  222. 220.  -         el.ttimer = setTimeout(function() {
  223. 221.  -           el.tt = 'show';
  224. 222.  -           ajax.post(opts.url, opts.params || {}, {onDone: function(html, js) {
  225. 223.  -             var old = el.tt, options = clone(opts);
  226. 224.  -             extend(options, {content: html || ' ', js: js});
  227. 225.  -             tooltips.create(el, options);
  228. 226.  -             if (old == 'shownow') {
  229. 227.  -               tooltips.show(el, extend(options, {showdt: 0}));
  230. 228.  -             }
  231. 229.  -           }, onFail: function() { return true; }});
  232. 230.  -           tooltips.show(el, opts);
  233. 231.  -         }, opts.ajaxdt || 0);
  234. 232.  -         return;
  235. 233.  -       }
  236. 234.  -       opts.content = '<div class="tt_text">' + opts.text + '</div>';
  237. 235.  -     }
  238. 236.  -     var cls = (opts.black ? 'ttb ' : 'tt ') + (opts.className || '');
  239. 237.  -     if (el.tt && el.tt.el) {
  240. 238.  -       var cont = el.tt.container;
  241. 239.  -       if (el.tt.onClean) el.tt.onClean();
  242. 240.  -       geByClass1('wrapped', cont).innerHTML = opts.content;
  243. 241.  -       extend(el.tt, {
  244. 242.  -         opts: opts,
  245. 243.  -         show: tooltips.show.pbind(el, options)
  246. 244.  -       });
  247. 245.  -       cont.className = cls;
  248. 246.  -       hide(cont);
  249. 247.  -     } else {
  250. 248.  -       if (opts.black) {
  251. 249.  -         var c = ce('div', {
  252. 250.  -           innerHTML: '<div><div class="top_pointer"></div><div class="ttb_cont">'+opts.content+'</div><div class="bottom_pointer"></div></div>',
  253. 251.  -           className: cls
  254. 252.  -         }, {display: 'none'});
  255. 253.  -       } else {
  256. 254.  -         var c = ce('div', {
  257. 255.  -           innerHTML: '<table cellspacing="0" cellpadding="0">\
  258. 256.  -     <tr><td colspan="3" class="tt_top"><div class="top_pointer"></div></td></tr>\
  259. 257.  -     <tr>\
  260. 258.  -       <td class="side_sh"></td>\
  261. 259.  -       <td class="outer"><table cellspacing="0" cellpadding="0">\
  262. 260.  -         <tr><td class="side_sh"></td>\
  263. 261.  -           <td class="wrapped">' + opts.content + '</td>\
  264. 262.  -         <td class="side_sh"></td></tr>\
  265. 263.  -         <tr><td colspan="3"><div class="bottom_sh"></div></td></tr>\
  266. 264.  -       </table></td>\
  267. 265.  -       <td class="side_sh"></td>\
  268. 266.  -     </tr>\
  269. 267.  -     <tr><td colspan="3" class="tt_bottom"><div class="bottom_sh"></div><div class="bottom_pointer'+no_shadow+'"></div></td></tr>\
  270. 268.  -   </table>',
  271. 269.  -           className: cls
  272. 270.  -         }, {display: 'none'});
  273. 271.  -       }
  274. 272.  -       bodyNode.appendChild(c);
  275. 273.  -       var res = extend({
  276. 274.  -         el: el,
  277. 275.  -         opts: opts,
  278. 276.  -         show: tooltips.show.pbind(el, options),
  279. 277.  -         hide: el.tthide,
  280. 278.  -         destroy: tooltips.destroy.pbind(el),
  281. 279.  -         container: c
  282. 280.  -       }, opts.tip || {});
  283. 281.  -       if (!opts.nohideover && (!opts.text || opts.hasover)) {
  284. 282.  -         addEvent(c, 'mouseover', res.show);
  285. 283.  -         addEvent(c, 'mouseout' , res.hide);
  286. 284.  -       }
  287. 285.  -       var isFixed = false, pel = el;
  288. 286.  -       while (pel) {
  289. 287.  -         if (getStyle(pel, 'position') == 'fixed') {
  290. 288.  -           isFixed = true;
  291. 289.  -           break;
  292. 290.  -         }
  293. 291.  -         pel = pel.offsetParent;
  294. 292.  -       }
  295. 293.  -       if (isFixed) {
  296. 294.  -         addClass(res.container, 'fixed');
  297. 295.  -         setStyle(res.container, {position: 'fixed'});
  298. 296.  -       } else {
  299. 297.  -         removeClass(res.container, 'fixed');
  300. 298.  -         setStyle(res.container, {position: 'absolute'});
  301. 299.  -       }
  302. 300.  -       res.isFixed = isFixed;
  303. 301.  -       el.tt = res;
  304. 302.  -       if (!cur.tooltips) {
  305. 303.  -         cur.tooltips = [];
  306. 304.  -       }
  307. 305.  -       cur.tooltips.push(res);
  308. 306.  -     }
  309. 307.  -     if (opts.init) opts.init(res);
  310. 308.  -   },
  311. 309.  -   pollFastShare: function(post, url, hash, aid, poll_id) {
  312. 310.  -     ajax.post('widget_poll.php', {
  313. 311.  -       act: 'a_share',
  314. 312.  -       sid: post,
  315. 313.  -       url: url,
  316. 314.  -       hash: hash,
  317. 315.  -       app: aid,
  318. 316.  -       poll_id: poll_id,
  319. 317.  -       no_widget: 1
  320. 318.  -     }, {
  321. 319.  -       onDone: function(t) {
  322. 320.  -         el.innerHTML = t;
  323. 321.  -       },
  324. 322.  -       showProgress: function() {
  325. 323.  -         show(el.previousSibling);
  326. 324.  -         hide(el);
  327. 325.  -       },
  328. 326.  -       hideProgress: function() {
  329. 327.  -         hide(el.previousSibling);
  330. 328.  -         show(el);
  331. 329.  -       }
  332. 330.  -     });
  333. 331.  -   },
  334. 332.  -
  335. 333.  -   pollVote: function(post, option, attachI) {
  336. 334.  -     var pr = ge('poll_bottom' + post);
  337. 335.  -     ajax.post('widget_poll.php', {
  338. 336.  -       act: 'a_vote',
  339. 337.  -       option_id: option,
  340. 338.  -       hash: cur.polls[post].hash,
  341. 339.  -       app: cur.polls[post].aid,
  342. 340.  -       poll_id: cur.polls[post].id,
  343. 341.  -       no_widget: 1,
  344. 342.  -       url: cur.polls[post].url,
  345. 343.  -       sid: post,
  346. 344.  -       i: attachI
  347. 345.  -     }, {
  348. 346.  -       onDone: function(html, js) {
  349. 347.  -         var lnk = ge('post_media_lnk' + post + '_' + attachI), opts = extend(lnk.tt.opts, {
  350. 348.  -           className: 'wall_tt',
  351. 349.  -           content: html || ' ',
  352. 350.  -           showdt: 0,
  353. 351.  -           js: js
  354. 352.  -         });
  355. 353.  -         tooltips.create(lnk, opts);
  356. 354.  -         lnk.tt.show();
  357. 355.  -       },
  358. 356.  -       showProgress: function() {
  359. 357.  -         show(pr.nextSibling);
  360. 358.  -         hide(pr);
  361. 359.  -       },
  362. 360.  -       hideProgress: function() {
  363. 361.  -         show(pr);
  364. 362.  -         hide(pr.nextSibling);
  365. 363.  -       }
  366. 364.  -     });
  367. 365.  -   },
  368. 366.  -
  369. 367.  -   addAudio: function(el, oid, aid, hash) {
  370. 368.  -     ajax.post('audio.php', {
  371. 369.  -       act: 'a_add',
  372. 370.  -       oid: oid,
  373. 371.  -       aid: aid,
  374. 372.  -       hash: hash
  375. 373.  -     }, {
  376. 374.  -       onDone: function() {
  377. 375.  -         el.parentNode.replaceChild(ce('div', {className: 'fl_r add_audio_plus done'}), el);
  378. 376.  -       },
  379. 377.  -       onFail: function() {
  380. 378.  -         return true;
  381. 379.  -       },
  382. 380.  -       showProgress: function() {
  383. 381.  -         hide(el.nextSibling);
  384. 382.  -         show(el.previousSibling);
  385. 383.  -       },
  386. 384.  -       hideProgress: function() {
  387. 385.  -         hide(el.previousSibling);
  388. 386.  -         show(el.nextSibling);
  389. 387.  -       }
  390. 388.  -     });
  391. 389.  -   }
  392. 390.  - }
  393. 391.  -
  394. 392.  - try{stManager.done('tooltips.js');}catch(e){}
  395. ------
Advertisement
Add Comment
Please, Sign In to add comment