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