Hormold

VK Change (#1384439404)

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