Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Файл - profile.js (Старый размер - 34731 | Новый - 0):
- 0. - var Profile = {
- 1. - showFull: function(uid, geolang, newMap) {
- 2. - if (!cur.vkLngCode) {
- 3. - cur.vkLngCode = geolang;
- 4. - }
- 5. -
- 6. - var lnk = ge('profile_full_link');
- 7. - if (lnk) {
- 8. - lnk.innerHTML = getLang('hide_full');
- 9. - lnk.onclick = Profile.hideFull;
- 10. - }
- 11. - ge('profile_short').innerHTML = cur.options.info[1];
- 12. - show('profile_full_info');
- 13. - if (ge('profile_map')) {
- 14. - if (!newMap && !window.google) {
- 15. - headNode.appendChild(ce('script', {
- 16. - type: 'text/javascript',
- 17. - src: (window.locProtocol || 'http:') + '//maps.google.com/maps/api/js?sensor=false&callback=gMapsInit&language='+(cur.vkLngCode || 'en')
- 18. - }));
- 19. - window.gMapsInit = function() {}
- 20. - }
- 21. - var params = {act: 'profile_map', uid: uid};
- 22. - if (nav.objLoc.as) {
- 23. - params.as = nav.objLoc.as;
- 24. - }
- 25. - ajax.post('al_places.php', params, {
- 26. - onDone: function(html, js) {
- 27. - if (html) {
- 28. - ge('profile_map').innerHTML = html;
- 29. - eval('(function () {' + js + '})();');
- 30. - } else {
- 31. - re('profile_map');
- 32. - }
- 33. - },
- 34. - stat: newMap ? ['places.js', 'mapbox.js', 'mapbox.css'] : ['places.js']
- 35. - });
- 36. - }
- 37. - },
- 38. - hideFull: function() {
- 39. - var lnk = ge('profile_full_link');
- 40. - if (lnk) {
- 41. - lnk.innerHTML = getLang('show_full');
- 42. - lnk.onclick = Profile.showFull;
- 43. - }
- 44. - ge('profile_short').innerHTML = cur.options.info[0];
- 45. - hide('profile_full_info', 'profile_class_hint');
- 46. - },
- 47. - showGroups: function(e) {
- 48. - if (checkEvent(e) !== false) return;
- 49. - var lnk = ge('profile_groups_link');
- 50. - lnk.oldText = val(lnk);
- 51. - ajax.post('al_profile.php', {act: 'groups', id: cur.oid}, {onDone: function(label, text) {
- 52. - if (text) {
- 53. - val(lnk, label);
- 54. - lnk.onclick = Profile.hideGroups;
- 55. - var pag = ge('profile_all_groups');
- 56. - val(pag, text);
- 57. - show(pag.parentNode);
- 58. - } else {
- 59. - hide(lnk);
- 60. - }
- 61. - }, showProgress: function() {
- 62. - val(lnk, '<div class="progress" id="profile_groups_prg"></div>');
- 63. - }, hideProgress: function() {
- 64. - val(lnk, lnk.oldText);
- 65. - }, cache: 1});
- 66. - return cancelEvent(e);
- 67. - },
- 68. - hideGroups: function(e) {
- 69. - if (checkEvent(e) !== false) return;
- 70. - var lnk = ge('profile_groups_link');
- 71. - val(lnk, lnk.oldText);
- 72. - lnk.onclick = Profile.showGroups;
- 73. - hide(ge('profile_all_groups').parentNode);
- 74. - return cancelEvent(e);
- 75. - },
- 76. - photoRemoveTip: function(lnk) {
- 77. - if (!((cur || {}).lang || {}).profile_photo_hide) return;
- 78. - showTooltip(lnk, {
- 79. - text: getLang('profile_photo_hide'),
- 80. - shift: [13, 1, 1],
- 81. - black: 1
- 82. - });
- 83. - },
- 84. - photoRemove: function(lnk, photo_id, ev) {
- 85. - if (cur.viewAsBox) {
- 86. - cur.viewAsBox();
- 87. - return cancelEvent(ev);
- 88. - }
- 89. - if (!cur.hidingPh) cur.hidingPh = {};
- 90. - if (cur.hidingPh[photo_id]) return cancelEvent(ev);
- 91. -
- 92. - ajax.post('al_profile.php', {act: 'remove_photo', photo_id: photo_id, hash: cur.options.profph_hash}, {
- 93. - onDone: function(about, photos) {
- 94. - val(ge('profile_photos_about') || ge('profile_photos_module').appendChild(ce('div', {className: 'msg', id: 'profile_photos_about'})), about);
- 95. - each(geByClass('profile_photo_hide_wrap', ge('profile_photos')), function() {
- 96. - if (this.tt && this.tt.destroy) {
- 97. - this.tt.destroy();
- 98. - }
- 99. - });
- 100. - val('profile_photos', photos);
- 101. - if (!photos) {
- 102. - hide('profile_photos_module');
- 103. - }
- 104. - },
- 105. - showProgress: function() {
- 106. - cur.hidingPh[photo_id] = 1;
- 107. - },
- 108. - hideProgress: function() {
- 109. - cur.hidingPh[photo_id] = 0;
- 110. - }
- 111. - });
- 112. - return cancelEvent(ev);
- 113. - },
- 114. - photoReturn: function(lnk, photo_id) {
- 115. - if (cur.viewAsBox) return cur.viewAsBox();
- 116. -
- 117. - ajax.post('al_profile.php', {act: 'return_photo', photo_id: photo_id, hash: cur.options.profph_hash}, {
- 118. - onDone: function(photos) {
- 119. - each(geByClass('profile_photo_hide_wrap', ge('profile_photos')), function() {
- 120. - if (this.tt && this.tt.destroy) {
- 121. - this.tt.destroy();
- 122. - }
- 123. - });
- 124. - val('profile_photos', photos);
- 125. - re('profile_photos_about');
- 126. - },
- 127. - showProgress: function() {
- 128. - hide(lnk);
- 129. - lnk.nextSibling.style.display = 'inline';
- 130. - },
- 131. - hideProgress: function() {
- 132. - hide(lnk.nextSibling);
- 133. - show(lnk);
- 134. - }
- 135. - });
- 136. - },
- 137. -
- 138. - otherActs: function(el) {
- 139. - clearTimeout(cur.hideOtherTimer);
- 140. - if (!el) return false;
- 141. - el.blur();
- 142. - var acts = ge('profile_other_acts');
- 143. - if (isVisible(acts)) {
- 144. - fadeIn(acts, 0);
- 145. - return false;
- 146. - }
- 147. - setTimeout(addEvent.pbind(document, 'click', Profile.hideOther), 1);
- 148. - acts.style.marginLeft = '-1px';
- 149. - acts.style.marginTop = '-21px';
- 150. - show(acts);
- 151. - return false;
- 152. - },
- 153. - hideOther: function(timeout) {
- 154. - if (timeout > 0) {
- 155. - cur.hideOtherTimer = setTimeout(Profile.hideOther.pbind(0), timeout);
- 156. - return;
- 157. - }
- 158. - var acts = ge('profile_other_acts');
- 159. - if (!acts) return;
- 160. - if (timeout == -1) {
- 161. - hide(acts);
- 162. - } else {
- 163. - fadeOut(acts, 200);
- 164. - }
- 165. - removeEvent(document, 'click', Profile.hideOther);
- 166. - },
- 167. -
- 168. - editPhoto: function(newph) {
- 169. - Profile.hideOther(-1);
- 170. - if (cur.viewAsBox) return cur.viewAsBox();
- 171. -
- 172. - showBox('/al_profile.php', extend(newph || {}, {act: 'edit_photo'}), {
- 173. - params: {bodyStyle: 'padding: 16px 7px'},
- 174. - stat: ['tagger.js', 'tagger.css']
- 175. - });
- 176. - },
- 177. - deletePhoto: function() {
- 178. - Profile.hideOther(-1);
- 179. - if (cur.viewAsBox) return cur.viewAsBox();
- 180. -
- 181. - showBox('al_profile.php', {act: 'delete_photo_box'});
- 182. - },
- 183. -
- 184. - setupSMS: function(hash) {
- 185. - Profile.hideOther(-1);
- 186. - if (cur.viewAsBox) return cur.viewAsBox();
- 187. -
- 188. - showBox('al_mobile.php', {act: 'configure_sms_notifications', mid: cur.oid, hash: hash});
- 189. - },
- 190. - toggleFan: function(btn, hash, act, ev) {
- 191. - if (cur.viewAsBox) {
- 192. - Profile.hideOther(-1);
- 193. - return cur.viewAsBox();
- 194. - }
- 195. -
- 196. - if (cur.toggleFanAct != undefined) {
- 197. - act = cur.toggleFanAct;
- 198. - }
- 199. - ajax.post('al_fans.php', {act: act ? 'be_fan' : 'not_fan', mid: cur.oid, hash: hash}, {onDone: function(text) {
- 200. - btn.firstChild.nextSibling.innerHTML = text;
- 201. - cur.toggleFanAct = !act;
- 202. - }, progress: btn.firstChild});
- 203. - cancelEvent(ev);
- 204. - },
- 205. - toggleFave: function(btn, hash, act, ev) {
- 206. - if (cur.viewAsBox) {
- 207. - Profile.hideOther(-1);
- 208. - return cur.viewAsBox();
- 209. - }
- 210. -
- 211. - if (cur.toggleFaveAct != undefined) {
- 212. - act = cur.toggleFaveAct;
- 213. - }
- 214. - ajax.post('fave.php', {act: act ? 'addPerson' : 'deletePerson', mid: cur.oid, hash: hash}, {onDone: function(text) {
- 215. - btn.firstChild.nextSibling.innerHTML = text;
- 216. - cur.toggleFaveAct = !act;
- 217. - }, progress: btn.firstChild});
- 218. - cancelEvent(ev);
- 219. - },
- 220. - toggleFriend: function(btn, hash, act, ev, sure) {
- 221. - if (cur.viewAsBox) {
- 222. - Profile.hideOther(-1);
- 223. - return cur.viewAsBox();
- 224. - }
- 225. -
- 226. - if (act) {
- 227. - if (sure !== true && cur.options.bannedhim) {
- 228. - showBox('al_profile.php', {act: 'banned_him', action: 'friend', mid: cur.oid}).onContinue = Profile.toggleFriend.pbind(btn, hash, act, false, true);
- 229. - return cancelEvent(ev);
- 230. - }
- 231. - stManager.add(['tooltips.css', 'tooltips.js']);
- 232. - }
- 233. -
- 234. - ajax.post('al_friends.php', {act: act ? 'add' : 'remove', mid: cur.oid, hash: hash, from: 'profile'}, {
- 235. - onDone: function(text, vis, ttText, ttScript, doReload) {
- 236. - if (act && cur.onFreindAdd) {
- 237. - cur.onFreindAdd();
- 238. - }
- 239. - if (!text) return nav.reload();
- 240. - var tt = (ge('profile_am_subscribed') || {}).tt;
- 241. - if (tt) {
- 242. - tt.hide({fasthide: 1});
- 243. - tt.destroy();
- 244. - }
- 245. - Profile.hideOther(-1);
- 246. - var fs = ge('friend_status');
- 247. - cleanElems(fs.firstChild);
- 248. - if (text) {
- 249. - show(fs);
- 250. - val(fs, text);
- 251. - } else {
- 252. - hide(fs);
- 253. - }
- 254. - (vis ? show : hide)('friend_remove');
- 255. - if (doReload || cur.options.bannedhim) {
- 256. - nav.reload();
- 257. - } else if (ttText) {
- 258. - ajax.preload('al_friends.php', {act: 'friend_tt', mid: cur.oid}, [ttText, ttScript])
- 259. - setTimeout(Profile.friendTooltip, 0);
- 260. - }
- 261. - },
- 262. - showProgress: btn.tagName == 'BUTTON' ? lockButton.pbind(btn) : show.pbind(btn.firstChild),
- 263. - hideProgress: btn.tagName == 'BUTTON' ? unlockButton.pbind(btn) : hide.pbind(btn.firstChild),
- 264. - onFail: function(text) {
- 265. - if (!text) return;
- 266. -
- 267. - showFastBox(getLang('global_error'), text);
- 268. - return true;
- 269. - }
- 270. - });
- 271. - cancelEvent(ev);
- 272. - },
- 273. - friendTTHide: function(e) {
- 274. - var tt = (ge('profile_am_subscribed') || {}).tt;
- 275. - if (e) {
- 276. - for (var el = e.target; el; el = domPN(el)) {
- 277. - if (el.tagName && hasClass(el, 'preq_tt')) {
- 278. - return;
- 279. - }
- 280. - }
- 281. - }
- 282. - if (tt && tt.hide) tt.hide({fasthide: 1});
- 283. - removeEvent(document, 'click', Profile.friendTTHide);
- 284. - },
- 285. - friendTooltip: function() {
- 286. - if (cur.viewAsBox) {
- 287. - return;
- 288. - }
- 289. -
- 290. - setTimeout(function() {
- 291. - removeEvent(document, 'click', Profile.friendTTHide);
- 292. - addEvent(document, 'click', Profile.friendTTHide);
- 293. - }, 0);
- 294. - return showTooltip(ge('profile_am_subscribed'), {
- 295. - url: 'al_friends.php',
- 296. - params: {act: 'friend_tt', mid: cur.oid},
- 297. - slide: 15,
- 298. - hidedt: 500,
- 299. - shift: [23, -1, -10],
- 300. - className: 'preq_tt',
- 301. - forcetodown: true
- 302. - });
- 303. - },
- 304. - submitReqText: function() {
- 305. - var msg = trim(val('preq_input'));
- 306. - if (!msg) return elfocus('preq_input');
- 307. -
- 308. - var oid = cur.mfid ? cur.mfid : cur.oid;
- 309. - ajax.post('al_friends.php', {act: 'request_text', mid: oid, message: msg, hash: cur.reqHash}, {onDone: function(text) {
- 310. - if (!text) return;
- 311. -
- 312. - var t = ge('preq_text');
- 313. - val(t, text);
- 314. - show(t.parentNode);
- 315. - hide(ge('preq_input').parentNode);
- 316. - }, showProgress: lockButton.pbind('preq_submit'), hideProgress: unlockButton.pbind('preq_submit')});
- 317. - },
- 318. - reqTextChanged: function(ev) {
- 319. - onCtrlEnter(ev, Profile.submitReqText);
- 320. - var field = ge('preq_input');
- 321. - var v = trim(val(field)).replace(/\n\n\n+/g, '\n\n');
- 322. - if (field.lastLen === v.length) return;
- 323. - field.lastLen = v.length;
- 324. - var countRealLen = function(text, max, maxbr) {
- 325. - var spec = {'&': 5, '<': 4, '>': 4, '"': 6, "\n": 4, "\r": 0, '!': 5, "'": 5};
- 326. - var res = 0, brs = 0, good = false;
- 327. - for (var i = 0, l = text.length; i < l; i++) {
- 328. - var k = spec[text.charAt(i)], c = text.charCodeAt(i);
- 329. - if (c == 10) ++brs;
- 330. - if (k !== undefined) res += k;
- 331. - else if ((c > 0x80 && c < 0xC0) || c > 0x500) res += ('&#' + c + ';').length;
- 332. - else res += 1;
- 333. - if (good === false && (max && res > max || maxbr && brs > maxbr)) good = i ? text.substr(0, i) : '';
- 334. - }
- 335. - return [res, brs, (good === false) ? text : good];
- 336. - }
- 337. - var maxLen = 240, maxBrs = 4, r = countRealLen(v, maxLen, maxBrs), realLen = r[0], brCount = r[1];
- 338. - var warn = ge('preq_warn');
- 339. - if (r[2] !== v) {
- 340. - if (realLen > maxLen) {
- 341. - realLen = maxLen;
- 342. - } else if (brCount > 4) {
- 343. - brCount = 4;
- 344. - }
- 345. - val(field, r[2]);
- 346. - field.lastLen = trim(r[2]).length;
- 347. - }
- 348. - if (realLen > maxLen - 40 || brCount > maxBrs) {
- 349. - if (realLen > maxLen) {
- 350. - warn.innerHTML = getLang('friends_exceeds_symbol_limit', realLen - maxLen);
- 351. - } else if (brCount > 4) {
- 352. - warn.innerHTML = getLang('friends_exceeds_lines_limit', brCount - 4);
- 353. - } else {
- 354. - warn.innerHTML = getLang('text_N_symbols_remain', maxLen - realLen);
- 355. - }
- 356. - show(warn);
- 357. - } else {
- 358. - hide(warn);
- 359. - }
- 360. - },
- 361. - toggleBlacklist: function(btn, hash, ev) {
- 362. - if (cur.viewAsBox) {
- 363. - Profile.hideOther(-1);
- 364. - return cur.viewAsBox();
- 365. - }
- 366. -
- 367. - ajax.post('al_settings.php', {act: cur.options.bannedhim ? 'a_del_from_bl' : 'a_add_to_bl', id: cur.oid, hash: hash, from: 'profile'}, {onDone: function(text) {
- 368. - domNS(domFC(btn)).innerHTML = text;
- 369. - cur.options.bannedhim = !cur.options.bannedhim;
- 370. - }, progress: domFC(btn)});
- 371. - cancelEvent(ev);
- 372. - },
- 373. - toggleFeedIgnored: function(btn, hash, ev) {
- 374. - if (cur.viewAsBox) {
- 375. - Profile.hideOther(-1);
- 376. - return cur.viewAsBox();
- 377. - }
- 378. -
- 379. - ajax.post('al_feed.php', {act: cur.options.ignoredhim ? 'a_unignore_owner' : 'a_ignore_owner', owner_id: cur.oid, hash: hash, from: 'profile'}, {onDone: function(text) {
- 380. - domNS(domFC(btn)).innerHTML = text;
- 381. - cur.options.ignoredhim = !cur.options.ignoredhim;
- 382. - }, progress: domFC(btn)});
- 383. - cancelEvent(ev);
- 384. - },
- 385. - showGiftBox: function(mid, ev) {
- 386. - Profile.hideOther(-1);
- 387. - cur.gftbxWasScroll = boxLayerWrap.scrollTop;
- 388. - boxLayerWrap.scrollTop = 0;
- 389. - if (cur.viewAsBox) return cur.viewAsBox();
- 390. -
- 391. - return !showBox('al_gifts.php', {act: 'get_gift_box', mid: mid, fr: (mid == vk.id ? 1 : 0)}, {stat: ['gifts.css', 'wide_dd.js', 'wide_dd.css'], cache: 1}, ev);
- 392. - },
- 393. - showHideGiftsBox: function(ev) {
- 394. - Profile.hideOther(-1);
- 395. - if (cur.viewAsBox) return cur.viewAsBox();
- 396. - var msg = getLang('profile_sure_hide_gifts').replace('{link}', '<a href="/settings">').replace('{/link}', '</a>').replace('{link1}', '<a href="/settings?act=privacy">').replace('{/link1}', '</a>');
- 397. -
- 398. - var box = showFastBox({title: getLang('global_warning'), bodyStyle: 'line-height: 140%;', width: 350}, msg, getLang('profile_gifts_hide_button'), function() {
- 399. - ajax.post('al_profile.php', {
- 400. - act: 'hide_gifts',
- 401. - hash: cur.options.gifts_hash
- 402. - }, {
- 403. - onDone: function() {
- 404. - slideUp('profile_gifts', 200);
- 405. - box.hide();
- 406. - },
- 407. - progress: box.progress
- 408. - });
- 409. - }, getLang('global_cancel'));
- 410. - cancelEvent(ev);
- 411. - return false;
- 412. - },
- 413. - showNewGift: function(giftId) {
- 414. - var gifts = ge('profile_gifts');
- 415. - if (!gifts || !giftId) return;
- 416. - var images = geByTag('img', geByClass1('module_body', gifts)), pic = vkImage();
- 417. - pic.src = '/images/gifts/'+(window.devicePixelRatio >= 2 ?'96':'48')+'/'+giftId+'.png';
- 418. - var onload = function() {
- 419. - var firstPic = images[0], a = firstPic.parentNode, imgCount = images.length;
- 420. - if (firstPic) {
- 421. - addClass(pic, 'giftImg');
- 422. - setStyle(a, {marginLeft: -pic.width+'px'});
- 423. - firstPic.parentNode.insertBefore(pic, firstPic);
- 424. - animate(a, {marginLeft: '0px'}, 200, function() {
- 425. - if (imgCount >= 4) re(images[images.length - 1]);
- 426. - })
- 427. - }
- 428. - };
- 429. - if (!pic.width) {
- 430. - addEvent(pic, 'load', onload);
- 431. - } else {
- 432. - onload();
- 433. - }
- 434. - },
- 435. - declineFriend: function(hash) {
- 436. - if (cur.viewAsBox) return cur.viewAsBox();
- 437. - ajax.post('al_friends.php', {act: 'remove', mid: cur.oid, hash: hash}, {onDone: function(text) {
- 438. - hide('friend_request_actions');
- 439. - }});
- 440. - },
- 441. - showWishesBox: function(ev) {
- 442. - return true;
- 443. - //return !showTabbedBox('al_gifts.php', {act: 'wishlist_box', mid: cur.oid}, {stat: ['gifts.css'], cache: 1}, ev);
- 444. - },
- 445. - processRelation: function(el, mid, hash, accept) {
- 446. - if (cur.viewAsBox) return cur.viewAsBox();
- 447. -
- 448. - var pos = getXY(el), parpos = getXY(el.parentNode);
- 449. - var pr = ge('relation_progress' + mid), lnk = ge('profile_full_link');
- 450. - ajax.post('al_profile.php', {
- 451. - act: 'process_relation',
- 452. - mid: mid,
- 453. - accept: accept ? 1 : '',
- 454. - full_shown: lnk ? 1 : '',
- 455. - hash: hash
- 456. - }, {
- 457. - onDone: function(short_info, long_info) {
- 458. - cur.options.info = [short_info, long_info];
- 459. - if (isVisible('profile_full_info')) {
- 460. - Profile.showFull();
- 461. - } else {
- 462. - Profile.hideFull();
- 463. - }
- 464. - },
- 465. - showProgress: function() {
- 466. - pr.style.left = (el.offsetLeft + Math.floor((el.offsetWidth - 32) / 2)) + 'px';
- 467. - show(pr);
- 468. - el.style.visibility = 'hidden';
- 469. - },
- 470. - hideProgress: function() {
- 471. - el.style.visibility = 'visible';
- 472. - hide(pr);
- 473. - }
- 474. - });
- 475. - },
- 476. - showFans: function(ev) {
- 477. - if (cur.viewAsBox) return cur.viewAsBox();
- 478. -
- 479. - return !showTabbedBox('al_fans.php', {act: 'show_fans_box', oid: cur.oid}, {cache: 1}, ev);
- 480. - },
- 481. - showIdols: function(ev) {
- 482. - if (cur.viewAsBox) return cur.viewAsBox();
- 483. -
- 484. - return !showTabbedBox('al_fans.php', {act: 'show_idols_box', oid: cur.oid}, {cache: 1}, ev);
- 485. - },
- 486. - showPublics: function(ev) {
- 487. - if (cur.viewAsBox) return cur.viewAsBox();
- 488. -
- 489. - return !showTabbedBox('al_fans.php', {act: 'show_publics_box', oid: cur.oid}, {cache: 1}, ev);
- 490. - },
- 491. - fansBox: function(oid, ev, tab) {
- 492. - if (cur.viewAsBox) return cur.viewAsBox();
- 493. - return !showBox('al_fans.php', {act: 'box', tab: tab || 'fans', oid: oid}, {cache: 1, stat: ['page_help.css', 'fansbox.js']}, ev);
- 494. - },
- 495. - giftsBox: function(mid, ev, tab) {
- 496. - if (cur.viewAsBox) return cur.viewAsBox();
- 497. - return !showBox('al_gifts.php', {act: 'box', tab: tab || 'received', mid: mid}, {cache: 1, stat: ['gifts.css', 'gifts.js']}, ev);
- 498. - },
- 499. - idolsBox: function(oid, ev) {
- 500. - return Profile.fansBox(oid, ev, 'idols');
- 501. - },
- 502. - showClassHint: function(text) {
- 503. - var cl = ge('profile_class');
- 504. - if (!cl) return;
- 505. -
- 506. - var hint = cur.classhint = bodyNode.appendChild(ce('div', {id: 'profile_class_hint', innerHTML: '\
- 507. - <table cellspacing="0" cellpadding="0">\
- 508. - <tr>\
- 509. - <td rowspan="2"><div class="pointer"></div></td>\
- 510. - <td><div class="content">' + text + '</div></td>\
- 511. - </tr>\
- 512. - <tr><td><div class="bottom"></div></td></tr>\
- 513. - </table>'}, {display: 'none'}));
- 514. -
- 515. - var xy = getXY(cl), elsize = getSize(cl);
- 516. -
- 517. - hint.style.opacity = 0;
- 518. - show(hint);
- 519. - var size = getSize(hint);
- 520. -
- 521. - var top = xy[1] - Math.floor((size[1] - elsize[1]) / 2);
- 522. - var newleft = xy[0] + (vk.rtl ? -(size[0] + 10) : (elsize[0] + 10));
- 523. - hint.style.left = (newleft + (vk.rtl ? -10 : 10)) + 'px';
- 524. - hint.style.top = top + 'px';
- 525. -
- 526. - var showhint = animate.pbind(hint, {left: newleft, opacity: 1}, 500, false), img = vkImage();
- 527. - img.onload = showhint;
- 528. - img.src = '/images/classhint.gif';
- 529. -
- 530. - cur.destroy.push(function(c) {
- 531. - if (c.classhint && c.classhint.parentNode) {
- 532. - c.classhint.parentNode.removeChild(c.classhint);
- 533. - c.classhint = false;
- 534. - }
- 535. - });
- 536. - if (cur._back) {
- 537. - cur._back.hide.push(function() {
- 538. - if (cur.classhint && cur.classhint.parentNode) {
- 539. - cur.classhint.parentNode.removeChild(cur.classhint);
- 540. - cur.classhint = false;
- 541. - }
- 542. - });
- 543. - }
- 544. - },
- 545. - init: function(opts) {
- 546. - extend(cur, {
- 547. - module: 'profile',
- 548. - hideOther: Profile.hideOther,
- 549. - options: opts,
- 550. - oid: opts.user_id,
- 551. - postTo: opts.user_id,
- 552. - editing: false,
- 553. - viewAsWarn: opts.view_as_warn,
- 554. - viewAsBox: opts.view_as ? function() {
- 555. - setTimeout(showFastBox(getLang('global_warning'), cur.options.view_as).hide, 2000);
- 556. - return false;
- 557. - } : false,
- 558. - _back: opts.view_as ? false : {loc: opts.loc, show: [], hide: [], text: opts.back}
- 559. - });
- 560. - if (opts.view_as) {
- 561. - cur.nav.push(function(changed, old, n, opts) {
- 562. - if (cur._leave) {
- 563. - cur._leave = false;
- 564. - return;
- 565. - }
- 566. - showFastBox(getLang('global_warning'), cur.viewAsWarn, getLang('global_continue'), function() {
- 567. - cur._leave = true;
- 568. - nav.go(n);
- 569. - }, getLang('global_cancel'));
- 570. - return false;
- 571. - });
- 572. - }
- 573. - if (opts.mail_cache) {
- 574. - ajax.preload('al_mail.php', {act: 'write_box', to: cur.oid}, opts.mail_cache)
- 575. - }
- 576. - if (ge('profile_wall')) {
- 577. - wall.init(extend(opts, {automore: 1}));
- 578. - }
- 579. - if (opts.class_hint) {
- 580. - cur.clHintTimer = setTimeout(Profile.showClassHint.pbind(opts.class_hint), 1000);
- 581. - }
- 582. - if (opts.invite_hint) {
- 583. - cur.invHintTimer = setTimeout(function() {
- 584. - var hint = ge('top_invite_hint');
- 585. - showTooltip(hint, {
- 586. - text: opts.invite_hint,
- 587. - slide: 30,
- 588. - shift: [vk.rtl ? -220 : 0, 0, 0],
- 589. - showdt: 0,
- 590. - showsp: 500,
- 591. - forcetodown: true,
- 592. - className: 'invite_tt'
- 593. - });
- 594. - cur.tsUpdated = Profile.inviteHintUpdate;
- 595. - stManager.add(['tooltips.css', 'tooltips.js'], cur.tsUpdated);
- 596. - }, 1000);
- 597. - }
- 598. - (cur._back ? cur._back.hide : cur.destroy).push(function(c) {
- 599. - clearTimeout((c || cur).clHintTimer);
- 600. - clearTimeout((c || cur).invHintTimer);
- 601. - Profile.hideOther(-1);
- 602. - Profile.friendTTHide(true);
- 603. - });
- 604. - if (nav.objLoc.suggest) {
- 605. - delete nav.objLoc.suggest;
- 606. - Profile.suggestFriends();
- 607. - }
- 608. -
- 609. - setTimeout(function () {
- 610. - if (window.FastChat && (window.curFastChat && curFastChat.inited || window.curNotifier && curNotifier.fc !== undefined)) {
- 611. - show('profile_fast_chat');
- 612. - }
- 613. - }, 100);
- 614. - var _a = window.audioPlayer, aid = currentAudioId();
- 615. - if (_a && aid && _a.showCurrentTrack) _a.showCurrentTrack();
- 616. -
- 617. - if (opts.photos_upload) {
- 618. - stManager.add(['upload.js'], Profile.initPhotosUpload);
- 619. - }
- 620. -
- 621. - cur.onPeerStatusChanged = function(peer, evType, evData) {
- 622. - if (peer == cur.oid) {
- 623. - var lv = ge('profile_online_lv');
- 624. - if (evType == 'online') {
- 625. - evData = intval(evData);
- 626. - setStyle('profile_mobile_online', {display: (evData && evData != 1) ? 'inline' : 'none'});
- 627. - if (!isVisible(lv)) {
- 628. - hide('profile_time_lv');
- 629. - setStyle(lv, {overflow: 'hidden', display: 'block', height: 0, paddingTop: 12, opacity: 0});
- 630. - show(lv);
- 631. - animate(lv, {paddingTop: 0, height: 12, opacity: 1}, 200, function() {
- 632. - setStyle(lv, {overflow: 'auto', height: 'auto'});
- 633. - });
- 634. - ajax.post('al_profile.php', {act: 'a_get_online_info', uid: cur.oid}, {
- 635. - onDone: function(cl) {
- 636. - var btn = ge('profile_message_send');
- 637. - if (hasClass(btn, cl)) return;
- 638. - animate(btn, {opacity: 0}, 200, function() {
- 639. - btn.className = 'profile_action_btn ' + cl;
- 640. - animate(btn, {opacity: 1}, 200)
- 641. - })
- 642. - }
- 643. - });
- 644. - }
- 645. - } else if (evType == 'offline') {
- 646. - setStyle(lv, {overflow: 'hidden', display: 'block', height: 12, paddingTop: 0, opacity: 1});
- 647. - animate(lv, {paddingTop: 12, height: 0, opacity: 0}, 200, function() {
- 648. - hide(lv);
- 649. - });
- 650. - var btn = ge('profile_message_send');
- 651. - if (hasClass(btn, 'profile_msg_call')) {
- 652. - var cl = 'profile_msg_none';
- 653. - } else if (hasClass(btn, 'profile_msg_split')) {
- 654. - var cl = 'profile_msg_msg';
- 655. - }
- 656. - if (cl) {
- 657. - animate(btn, {opacity: 0}, 200, function() {
- 658. - btn.className = 'profile_action_btn ' + cl;
- 659. - animate(btn, {opacity: 1}, 200)
- 660. - })
- 661. - }
- 662. - }
- 663. - }
- 664. - }
- 665. - },
- 666. - inviteHintUpdate: function() {
- 667. - var hint = ge('top_invite_hint');
- 668. - if (!hint || !hint.tt || !hint.tt.container) return;
- 669. - var lnk = isVisible('ts_wrap') ? ge('ts_settings') : ge('top_invite_link'), l = 0, r = 0;
- 670. - if (vk.rtl) {
- 671. - r = (413 - lnk.parentNode.parentNode.offsetLeft - (lnk.offsetWidth / 2)) + 'px';
- 672. - } else {
- 673. - l = (lnk.parentNode.parentNode.offsetLeft + (lnk.offsetWidth / 2) - 370) + 'px';
- 674. - }
- 675. - geByClass1('top_pointer', hint.tt.container).style.margin = '0px ' + r + ' 0px ' + l;
- 676. - },
- 677. - appStatusUpdate: function(hash) {
- 678. - if (!cur.ciApp) return;
- 679. -
- 680. - var exp = isChecked('currinfo_app');
- 681. - ajax.post('al_apps.php', {act: 'toggle_currinfo', hash: hash, exp: exp, id: cur.ciApp}, {onDone: function(text) {
- 682. - if (vk.id != cur.oid || !text) return;
- 683. - val('current_info', text);
- 684. - }})
- 685. - },
- 686. - suggestFriends: function() {
- 687. - if (cur.viewAsBox) return cur.viewAsBox();
- 688. -
- 689. - var box = showBox('al_friends.php', {
- 690. - act: 'select_friends_box',
- 691. - from: 'suggest_friends',
- 692. - friend_id: cur.oid
- 693. - }, {stat: ['privacy.js', 'privacy.css', 'indexer.js']});
- 694. - box.leaveOnSave = true;
- 695. - cur.onFlistSave = function(ids, list, hash) {
- 696. - //if (!ids || !ids.length) return;
- 697. - ajax.post('al_friends.php', {
- 698. - act: 'a_suggest_friends',
- 699. - mid: cur.oid,
- 700. - ids: ids.join(','),
- 701. - hash: hash
- 702. - }, {
- 703. - onDone: function(text) {
- 704. - box.hide();
- 705. - showDoneBox(text);
- 706. - },
- 707. - showProgress: box.showProgress,
- 708. - hideProgress: box.hideProgress
- 709. - });
- 710. - }
- 711. - },
- 712. - giftTooltip: function(obj, event, mid) {
- 713. - if (checkEvent(event)) return true;
- 714. - if (cur.hideGifts && !cur.giftsHidden) {
- 715. - return cur.hideGifts(event);
- 716. - }
- 717. - var is_module = hasClass(obj, 'module_header');
- 718. - addClass(obj, is_module ? 'module_inverted' : 'gifts_inverted');
- 719. - if (cur.giftsPrepare || !cur.votesBox) {
- 720. - if (!cur.giftsPrepare) {
- 721. - Profile.prepareGiftTooltip();
- 722. - }
- 723. - addClass(obj, is_module ? 'module_inverted_loading' : 'gifts_inverted_loading');
- 724. - cur.onGiftsLoad = Profile.giftTooltip.pbind(obj, event, mid);
- 725. - return cancelEvent(event);
- 726. - }
- 727. - removeClass(obj, is_module ? 'module_inverted_loading' : 'gifts_inverted_loading');
- 728. - if (!cur.votesBox) {
- 729. - return false;
- 730. - }
- 731. - if (Pads && Pads.hide) {
- 732. - Pads.hide();
- 733. - }
- 734. - var html = cur.votesBox[0];
- 735. - var js = cur.votesBox[1];
- 736. -
- 737. - eval('(function(){' + js + ';})()');
- 738. - if (obj.tt && obj.tt.container && !cur.giftsTooltipEl) {
- 739. - cur.giftsTooltipEl = re(geByClass1('gifts_profile_block', obj.tt.container));
- 740. - }
- 741. - cur.giftsHidden = false;
- 742. - addEvent(document, 'click', cur.hideGifts);
- 743. - addEvent(document, 'keydown', cur.hideGiftsOnEsc);
- 744. - return cancelEvent(event);
- 745. - },
- 746. - prepareGiftTooltip: function(event, mid) {
- 747. - if (!cur.votesBox && !cur.giftsPrepare) {
- 748. - cur.giftsPrepare = true;
- 749. - ajax.post('/al_gifts.php', {act: 'new_gift_box', mid: mid}, {
- 750. - onDone: function() {
- 751. - var args = Array.prototype.slice.call(arguments),
- 752. - div = ce('div', {innerHTML: args[0]}); // preload imgs
- 753. - cur.votesBox = args;
- 754. - cur.giftsPrepare = false;
- 755. - if (cur.onGiftsLoad) {
- 756. - cur.onGiftsLoad();
- 757. - }
- 758. - },
- 759. - stat: ['gifts.css', 'tooltips.js', 'tooltips.css', 'notifier.js']
- 760. - })
- 761. - }
- 762. - },
- 763. - giftSend: function() {
- 764. - var uid = cur.oid, num = ge('gifts_selected_num').value;
- 765. - lockButton('gifts_submit');
- 766. - ajax.post('al_gifts.php', {
- 767. - act: 'do_send',
- 768. - mids: uid,
- 769. - type: isChecked('receiver_only') ? 1 : 0,
- 770. - number: num,
- 771. - text: ge('gifts_message').value,
- 772. - hash: ge('gifts_hash').value,
- 773. - from: 'profile',
- 774. - need_module: ge('profile_gifts') ? 0 : 1,
- 775. - old: 1
- 776. - }, {
- 777. - onDone: function(data, text, giftsCnt, giftsModule) {
- 778. - updateMoney(data);
- 779. - ge('gifts_message').value = '';
- 780. - checkbox('receiver_only', false);
- 781. - unlockButton('gifts_submit');
- 782. - cur.hideGifts && cur.hideGifts();
- 783. - if (cur.clearGiftTt) {
- 784. - if (cur.clearGiftTt.tt) cur.clearGiftTt.tt.destroy();
- 785. - cur.votesBox = cur.giftsPrepare = cur.onGiftsLoad = cur.clearGiftTt = false;
- 786. - }
- 787. - text = text.replace('<b>', '<div class="top_result_header">').replace('</b><br>', '</div>');
- 788. - showDoneBox(text, {out: 1500});
- 789. - cur.ignoreBoxCache = true;
- 790. - if (cur.module == 'profile' && cur.oid == uid && window.Profile) {
- 791. - if (ge('gifts_module_count') && giftsCnt) {
- 792. - ge('gifts_module_count').innerHTML = giftsCnt;
- 793. - Profile.showNewGift(num);
- 794. - } else if (!ge('profile_gifts') && giftsModule) {
- 795. - hide('gifts_count_module');
- 796. - var firstModule = geByClass1('module', ge('profile_narrow'));
- 797. - if (firstModule) {
- 798. - firstModule.parentNode.insertBefore(se(giftsModule), firstModule);
- 799. - }
- 800. - }
- 801. - }
- 802. - },
- 803. - onFail: function(text) {
- 804. - unlockButton('gifts_submit');
- 805. - cur.hideGifts && cur.hideGifts();
- 806. - text && topError(text);
- 807. - return true;
- 808. - }
- 809. - });
- 810. - },
- 811. - publishPhotos: function(photos) {
- 812. - var query = {
- 813. - act: 'post',
- 814. - type: 'photos_upload',
- 815. - to_id: vk.id,
- 816. - attach1_type: 'photos_list',
- 817. - attach1: photos,
- 818. - hash: cur.options.photos_post_hash || ''
- 819. - }
- 820. - if (!window.Notifier || !window.curFastChat || !curFastChat.ready) {
- 821. - query.need_wall = 1;
- 822. - }
- 823. - ajax.post('/al_wall.php', query, {
- 824. - onDone: function(wall) {
- 825. - cur.photoUploadBox.hide();
- 826. - delete cur.photoUploadBox;
- 827. - delete cur.savedPhotos;
- 828. - showDoneBox('<div style="font-weight: bold">' + getLang('profile_photos_published') + '</div>', {w: 320});
- 829. - if (query.need_wall && wall && ge('page_wall_posts')) {
- 830. - ge('page_wall_posts').innerHTML = wall;
- 831. - }
- 832. - },
- 833. - onFail: function() {
- 834. - cur.photoUploadBox.hide();
- 835. - delete cur.photoUploadBox;
- 836. - delete cur.savedPhotos;
- 837. - }
- 838. - });
- 839. - return false;
- 840. - },
- 841. - initPhotosUploadBox: function() {
- 842. - if (cur.photoUploadBox) return;
- 843. - cur.photoUploadBox = showFastBox({title: getLang('profile_photo_upload_title'), width: 410, onHide: function() {
- 844. - Upload.embed(cur.phUplInd || 0);
- 845. - delete cur.photoUploadBox;
- 846. - delete cur.savedPhotos;
- 847. - }}, '<div class="profile_photo_upload_box"><div>' + getLang('profile_photos_uploading') + '</div><div id="profile_photo_upload_label"></div><div class="profile_progress_wrap"><div id="profile_photo_progress" class="profile_progress" style="width: 0%;"></div></div></div>', getLang('global_cancel'), function() {
- 848. - cur.photoUploadBox.hide();
- 849. - delete cur.photoUploadBox;
- 850. - delete cur.savedPhotos;
- 851. - });
- 852. - cur.photoUploadBox.changed = 1;
- 853. - },
- 854. - initPhotosUpload: function() {
- 855. - if (browser.flash <= 9) return false;
- 856. - var photos_data = (cur.options || {}).photos_upload,
- 857. - area = ge('profile_photos_upload') || ge('profile_photos_extra_link'), el = se('<div id="profile_photo_uploader" onclick="cancelEvent(event); return false;" style="position: absolute; height: 100%; width: 100%; cursor: pointer;"></div>');
- 858. - if (!photos_data || !area) return false;
- 859. -
- 860. - area.parentNode.insertBefore(el, area);
- 861. - cur.lang = extend(cur.lang || {}, photos_data.opts.lang);
- 862. - cur.phUplInd = Upload.init('profile_photo_uploader', photos_data.url, photos_data.params, {
- 863. - file_name: 'photo',
- 864. - file_size_limit: 1024 * 1024 * 5, // 5Mb
- 865. - file_types_description: 'Image files (*.jpg, *.jpeg, *.png, *.gif)',
- 866. - file_types: '*.jpg;*.JPG;*.jpeg;*.JPEG;*.png;*.PNG;*.gif;*.GIF',
- 867. - accept: 'image/jpeg,image/png,image/gif',
- 868. - file_match: photos_data.opts.ext_re,
- 869. - lang: {},
- 870. -
- 871. - onUploadStart: function(info, res) {
- 872. - Profile.initPhotosUploadBox();
- 873. - var txt;
- 874. - if (info.num == undefined) {
- 875. - info = res;
- 876. - }
- 877. - if (info.num === 0) {
- 878. - txt = (info.totalCount > 1) ? getLang('profile_photos_uploading_x').replace('%s', info.totalCount) : getLang('profile_photo_uploading');
- 879. - } else {
- 880. - txt = getLang('profile_photos_uploaded_x', info.num).replace('{count}', info.totalCount);
- 881. - }
- 882. - ge('profile_photo_upload_label').innerHTML = txt;
- 883. - },
- 884. - onUploadComplete: function(info, res) {
- 885. - if (info.totalCount > 1 && info.totalCount == info.num + 1) {
- 886. - ge('profile_photo_upload_label').innerHTML = getLang('profile_photos_uploaded_x', info.totalCount).replace('{count}', info.totalCount);
- 887. - }
- 888. - var params, i = info.ind !== undefined ? info.ind : info;
- 889. - try {
- 890. - params = eval('(' + res + ')');
- 891. - } catch(e) {
- 892. - params = q2ajx(res);
- 893. - }
- 894. - if (params.photos) {
- 895. - cur.savedPhotos = cur.savedPhotos || {mid: params.mid, gid: params.gid, aid: params.aid, server: params.server};
- 896. - cur.savedPhotos.photos = cur.savedPhotos.photos || [];
- 897. - cur.savedPhotos.photos.push({photo: params.photos, hash: params.hash});
- 898. - return;
- 899. - }
- 900. - },
- 901. - onUploadProgress: function(info, bytesLoaded, bytesTotal) {
- 902. - Profile.initPhotosUploadBox();
- 903. - var newWidth = intval(bytesLoaded / bytesTotal * 250);
- 904. - animate(ge('profile_photo_progress'), {width: newWidth + 'px'}, 200);
- 905. - },
- 906. - onUploadCompleteAll: function (i) {
- 907. - if (cur.photoUploadBox) {
- 908. - if (cur.savedPhotos) {
- 909. - var query = {act: 'done_add', context: 1, from: 'profile_block'}, k = 1;
- 910. - for (var j in (cur.savedPhotos.photos || [])) {
- 911. - query['photo'+k] = cur.savedPhotos.photos[j].photo;
- 912. - query['hash'+k] = cur.savedPhotos.photos[j].hash;
- 913. - k++;
- 914. - }
- 915. - delete cur.savedPhotos.photos;
- 916. - query = extend(query, cur.savedPhotos);
- 917. - ajax.post('/al_photos.php', query, {
- 918. - onDone: function(saved_photos, html, script) {
- 919. - if (ge('profile_photos_module')) {
- 920. - ge('profile_photos_module').innerHTML = se(html).innerHTML;
- 921. - if (script) eval(script);
- 922. - }
- 923. - if (saved_photos) Profile.publishPhotos(saved_photos);
- 924. - },
- 925. - onFail: function() {
- 926. - cur.photoUploadBox.hide();
- 927. - delete cur.photoUploadBox;
- 928. - delete cur.savedPhotos;
- 929. - Upload.embed(cur.phUplInd || 0);
- 930. - }
- 931. - })
- 932. - } else {
- 933. - cur.photoUploadBox.hide();
- 934. - delete cur.photoUploadBox;
- 935. - delete cur.savedPhotos;
- 936. - }
- 937. - show(cur.photoUploadBox.progress);
- 938. - }
- 939. - },
- 940. - onUploadError: function(i) {
- 941. - debugLog('error', arguments); return;
- 942. - },
- 943. - onSelectClick: function(i) {
- 944. - if (!Upload.checked || !Upload.checked[i]) {
- 945. - Upload.check(i);
- 946. - }
- 947. - },
- 948. - onCheckComplete: function(i) {
- 949. - try {
- 950. - var postData = [], vars = Upload.vars[i];
- 951. - for (var k in vars) {
- 952. - postData.push(k+'='+vars[k]);
- 953. - }
- 954. - if (!vars['ajx']) {
- 955. - postData.push('ajx=1');
- 956. - }
- 957. - ge('uploader_lite'+i).configureServer(Upload.uploadUrls[i], escape(postData.join('&')));
- 958. - } catch (e) {debugLog(e);}
- 959. - },
- 960. - onDebug: debugLog,
- 961. -
- 962. - flashPath: '/swf/photo_uploader_lite.swf',
- 963. - hoverEl: ge('profile_photos_upload') || ge('profile_photos_extra_link'),
- 964. - flash_lite: 1,
- 965. - noCheck: 1,
- 966. - noForm: 1,
- 967. - flashHeight: getSize(area)[1],
- 968. - forceFlash: 1,
- 969. - multiple: 1,
- 970. - multi_progress: 1,
- 971. - max_files: 50,
- 972. - clear: 1,
- 973. - type: 'photo',
- 974. - max_attempts: 3,
- 975. - server: photos_data.opts.server,
- 976. - error: photos_data.opts.default_error,
- 977. - error_hash: photos_data.opts.error_hash,
- 978. - label: photos_data.opts.label,
- 979. - dragEl: bodyNode
- 980. - });
- 981. - }
- 982. - }, profile = Profile;
- 983. -
- 984. - try{stManager.done('profile.js');}catch(e){}
- ------
Advertisement
Add Comment
Please, Sign In to add comment