Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Файл - profile_edit.js (Старый размер - 50893 | Новый - 0):
- 0. - var ProfileEditor = {
- 1. - go: function(el, ev) {
- 2. - if (ProfileEditor.checkChanges(1) === false) {
- 3. - cur.onContinueCb = ProfileEditor.go.pbind(el, false);
- 4. - return false;
- 5. - }
- 6. - var current = ProfileEditor.getsect();
- 7. - var result = checkEvent(ev);
- 8. - if (result === false) {
- 9. - current.className = '';
- 10. - el.parentNode.className = 'active_link';
- 11. - }
- 12. - if (ev === false) {
- 13. - location.href = el.href;
- 14. - }
- 15. - if (el.href.indexOf('edit') != -1) {
- 16. - return nav.go(el, ev);
- 17. - }
- 18. - },
- 19. - getsect: function() {
- 20. - var current = ge('pedit_filters').firstChild;
- 21. - for (; !hasClass(current, 'active_link');) {
- 22. - current = current.nextSibling;
- 23. - }
- 24. - return current;
- 25. - },
- 26. -
- 27. - showMsg: function (msg) {
- 28. - ge('pedit_result').innerHTML = '<div class="msg" id="pedit_msg">' + msg + '</div>';
- 29. - show('pedit_result');
- 30. - animate(ge('pedit_msg'), {backgroundColor: '#F9F6E7'}, 2000);
- 31. - scrollToTop(200);
- 32. - },
- 33. -
- 34. - initBeforeUnload: function () {
- 35. - cur.nav.push(function (changed, old, n, opts) {
- 36. - if (ProfileEditor.checkChanges(1) === false) {
- 37. - cur.onContinueCb = nav.go.pbind(n);
- 38. - return false;
- 39. - }
- 40. - });
- 41. - cur.prevBefUnload = window.onbeforeunload;
- 42. - window.onbeforeunload = ProfileEditor.checkChanges;
- 43. - cur.destroy.push(function () {
- 44. - window.onbeforeunload = cur.prevBefUnload;
- 45. - });
- 46. - },
- 47. -
- 48. - initGeneral: function () {
- 49. - cur.section = 'general';
- 50. - var peditData = cur.options;
- 51. -
- 52. - // Change name hint
- 53. - var ttEl = ge('pedit_name_tt_place');
- 54. - each([ge('pedit_first_name'), ge('pedit_last_name')], function () {
- 55. - if (!this || this == window || this.setTimeout) return;
- 56. - this.onfocus = function () {
- 57. - showTooltip(ttEl, {
- 58. - text: '<div class="pedit_side_tt_pointer pedit_name_pointer"></div>' + getLang('profileEdit_name_be_patient'),
- 59. - slideX: 15,
- 60. - className: 'pedit_side_name_tt',
- 61. - shift: [-12, -54, 3],
- 62. - onCreate: function () {
- 63. - removeEvent(ttEl, 'mouseout');
- 64. - }
- 65. - });
- 66. - };
- 67. - this.onblur = function () {
- 68. - if (!ttEl.tt) return;
- 69. - ttEl.tt.hide();
- 70. - }
- 71. - });
- 72. - each(['home_town', 'first_name', 'last_name', 'middle_name', 'maiden_name'], function (k, v) {
- 73. - peditData[v] = replaceEntities(peditData[v]);
- 74. - });
- 75. - toggle('pedit_maiden_row', peditData.sex == 1);
- 76. -
- 77. -
- 78. - cur.uiSex = new Dropdown(ge('pedit_sex'), peditData.sexes, {
- 79. - width: 220,
- 80. - multiselect: false,
- 81. - selectedItems: peditData.sex,
- 82. - onChange: function(value) {
- 83. - hide('pedit_status_ptitle', 'pedit_status_partner', 'pedit_status_detail');
- 84. - toggle('pedit_maiden_row', intval(value) == 1);
- 85. - cur.uiPartner.clear();
- 86. - cur.uiStatus.clear();
- 87. - if (intval(value)) {
- 88. - show('pedit_status_row');
- 89. - cur.uiStatus.setData(peditData.statuses[intval(value)]);
- 90. - } else {
- 91. - hide('pedit_status_row');
- 92. - }
- 93. - }
- 94. - });
- 95. -
- 96. - var onPartnerChangeCb = function (val) {
- 97. - if (val) {
- 98. - cur.uiPartner.selectItem(val);
- 99. - } else {
- 100. - cur.uiPartner.val(0);
- 101. - }
- 102. - if (cur.onPartnerGot) {
- 103. - cur.onPartnerGot();
- 104. - cur.onPartnerGot = false;
- 105. - }
- 106. - };
- 107. -
- 108. - var handlePartnerChange = function(value) {
- 109. - if (!cur.uiSex.val()) {
- 110. - onPartnerChangeCb(0);
- 111. - return;
- 112. - }
- 113. - var statusVal = cur.uiStatus.val();
- 114. - if (value == -1) {
- 115. - if (statusVal == 7) { // allow find lover by link
- 116. - var custom = val('pedit_partner_custom');
- 117. - if (custom == peditData.partners[0][1]) {
- 118. - onPartnerChangeCb(0);
- 119. - return;
- 120. - }
- 121. - ajax.post('al_profileEdit.php', {act: 'a_get_custom_partner', query: custom}, {
- 122. - onDone: function (item, isFriend, sex) {
- 123. - if (!item || !isFriend && statusVal != 7/* || sex == cur.uiSex.val()*/) { // disallow custom type for other types
- 124. - onPartnerChangeCb(0);
- 125. - } else {
- 126. - onPartnerChangeCb(item);
- 127. - }
- 128. - },
- 129. - onFail: function (msg) {
- 130. - onPartnerChangeCb(0);
- 131. - setTimeout(showFastBox(getLang('global_error'), msg).hide, 2000);
- 132. - return true;
- 133. - },
- 134. - showProgress: show.pbind('pedit_status_progress'),
- 135. - hideProgress: hide.pbind('pedit_status_progress')
- 136. - });
- 137. - } else {
- 138. - onPartnerChangeCb(0);
- 139. - }
- 140. - }
- 141. - if (intval(value) && statusVal > 1 && cur.uiStatus.val() < 6) {
- 142. - if (intval(value) == peditData.partner) {
- 143. - if (ge('pedit_status_detail_content').innerHTML) show('pedit_status_detail');
- 144. - } else {
- 145. - hide('pedit_status_detail');
- 146. - }
- 147. - } else {
- 148. - if (!intval(value)) {
- 149. - cur.uiPartner.clear();
- 150. - }
- 151. - hide('pedit_status_detail');
- 152. - }
- 153. - }
- 154. - if (peditData.status > 7 || peditData.status < 0) {
- 155. - peditData.status = 0;
- 156. - }
- 157. -
- 158. - cur.uiStatus = new Dropdown(ge('pedit_status'), peditData.statuses[peditData.sex], {
- 159. - width: 220,
- 160. - multiselect: false,
- 161. - selectedItems: peditData.status,
- 162. - onChange: function(value) {
- 163. - value = intval(value);
- 164. - if (value > 1 && value < 6 || value == 7) {
- 165. - ProfileEditor.updateFriendsList(function() {
- 166. - show('pedit_status_partner');
- 167. - if (peditData.ptitles[value][cur.uiSex.val()].length) {
- 168. - ge('pedit_status_ptitle').innerHTML = peditData.ptitles[value][cur.uiSex.val()] + ':' || ' ';
- 169. - show('pedit_status_ptitle');
- 170. - } else {
- 171. - hide('pedit_status_ptitle');
- 172. - }
- 173. - handlePartnerChange(cur.uiPartner.val());
- 174. - });
- 175. - } else {
- 176. - hide('pedit_status_partner', 'pedit_status_ptitle');
- 177. - handlePartnerChange(cur.uiPartner.val());
- 178. - }
- 179. - }
- 180. - });
- 181. -
- 182. - cur.uiPartner = new Selector(ge('pedit_partner'), peditData.partners, {
- 183. - width: 220,
- 184. - multiselect: false,
- 185. - autocomplete: true,
- 186. - enableCustom: true,
- 187. - placeholder: peditData.partners[0][1],
- 188. - placeholderColor: '#000',
- 189. - noResult: '',
- 190. - introText: '',
- 191. - selectedItems: peditData.partner,
- 192. - onChange: handlePartnerChange
- 193. - });
- 194. -
- 195. - var partnerInput = cur.uiPartner.input, partnerTtEl = ge('pedit_partner_tt_place'), partnerTtEl1 = ge('pedit_partner_tt_place1');
- 196. - addEvent(partnerInput, 'focus blur', function (e) {
- 197. - if (e.type == 'focus') {
- 198. - if (cur.uiStatus.val() == 7) {
- 199. - showTooltip(partnerTtEl, {
- 200. - text: '<div class="pedit_side_tt_pointer pedit_partner_pointer"></div>' + getLang('profileEdit_partner_hint'),
- 201. - slideX: 15,
- 202. - className: 'settings_side_tt pedit_side_pwd_tt',
- 203. - shift: [-12, -50, 3],
- 204. - onCreate: function () {
- 205. - removeEvent(partnerTtEl, 'mouseout');
- 206. - }
- 207. - });
- 208. - } else if (indexOf([2,3,4,5,7], cur.uiStatus.val()) != -1) {
- 209. - showTooltip(partnerTtEl1, {
- 210. - text: '<div class="pedit_side_tt_pointer pedit_partner_pointer1"></div>' + peditData.status_helps[3 - cur.uiSex.val()],
- 211. - slideX: 15,
- 212. - className: 'settings_side_tt pedit_side_pwd_tt',
- 213. - shift: [-12, -63, 3],
- 214. - onCreate: function () {
- 215. - removeEvent(partnerTtEl1, 'mouseout');
- 216. - }
- 217. - });
- 218. - }
- 219. - } else {
- 220. - partnerTtEl.tt && partnerTtEl.tt.hide && partnerTtEl.tt.hide();
- 221. - partnerTtEl1.tt && partnerTtEl1.tt.hide && partnerTtEl1.tt.hide();
- 222. - }
- 223. - });
- 224. -
- 225. - if (peditData.sex) {
- 226. - show('pedit_status_row');
- 227. - if (peditData.status > 1 && peditData.status != 6) {
- 228. - if (peditData.ptitles[peditData.status][peditData.sex].length) {
- 229. - ge('pedit_status_ptitle').innerHTML = peditData.ptitles[peditData.status][peditData.sex] + ':' || ' ';
- 230. - show('pedit_status_ptitle');
- 231. - }
- 232. - show('pedit_status_partner');
- 233. - }
- 234. - }
- 235. - if (peditData.partner) {
- 236. - if (ge('pedit_status_detail_content').innerHTML) show('pedit_status_detail');
- 237. - }
- 238. -
- 239. - cur.uiBday = new Dropdown(ge('pedit_bday'), ProfileEditor.generateDays(peditData.byear, peditData.bmonth).slice(intval(peditData.bday) ? 1 : 0), {
- 240. - width: 55,
- 241. - multiselect: false,
- 242. - selectedItems: peditData.bday
- 243. - });
- 244. -
- 245. - cur.uiBmonth = new Dropdown(ge('pedit_bmonth'), peditData.bmonths.slice(intval(peditData.bmonth) ? 1 : 0), {
- 246. - width: 95,
- 247. - multiselect: false,
- 248. - selectedItems: peditData.bmonth,
- 249. - onChange: function(value) {
- 250. - ProfileEditor.updateDays(cur.uiByear.val(), value);
- 251. - }
- 252. - });
- 253. -
- 254. - cur.uiByear = new Dropdown(ge('pedit_byear'), peditData.byears.slice(intval(peditData.byear) ? 1 : 0), {
- 255. - width: 60,
- 256. - multiselect: false,
- 257. - selectedItems: peditData.byear,
- 258. - onChange: function(value) {
- 259. - ProfileEditor.updateDays(value, cur.uiBmonth.val());
- 260. - }
- 261. - });
- 262. -
- 263. - cur.uiBdayVisibility = new Dropdown(ge('pedit_bday_visibility'), peditData.bday_visibilities, {
- 264. - width: 220,
- 265. - multiselect: false,
- 266. - selectedItems: peditData.bday_visibility
- 267. - });
- 268. -
- 269. - ge('pedit_home_town').value = peditData.home_town;
- 270. -
- 271. - cur.uiLangs = new Dropdown(ge('pedit_langs'), peditData.langs, {
- 272. - width: 220,
- 273. - multiselect: true,
- 274. - autocomplete: true,
- 275. - indexkeys: [1, 2],
- 276. - selectedItems: peditData.lang
- 277. - });
- 278. -
- 279. - cur.relations = [];
- 280. - cur.relGuid = 0;
- 281. - cur.relIds = {grandparent: 0, parent: 0, sibling: 0, child: 0, grandchild: 0};
- 282. - cur.relLimits = {grandparent: 4, parent: 2, sibling: 15, child: 15, grandchild: 15};
- 283. - cur.conts = {
- 284. - grandparent: 'pedit_grandparents',
- 285. - parent: 'pedit_parents',
- 286. - sibling: 'pedit_siblings',
- 287. - child: 'pedit_children',
- 288. - grandchild: 'pedit_grandchildren'
- 289. - };
- 290. - cur.placeholders = {
- 291. - grandparent: getLang('profileEdit_grandparent_placeholder'),
- 292. - parent: getLang('profileEdit_parent_placeholder'),
- 293. - sibling: getLang('profileEdit_sibling_placeholder'),
- 294. - child: getLang('profileEdit_child_placeholder'),
- 295. - grandchild: getLang('profileEdit_grandchild_placeholder')
- 296. - };
- 297. -
- 298. - ProfileEditor.updateFamily(peditData.family);
- 299. - ProfileEditor.initBeforeUnload();
- 300. - cur.module = 'profileEdit';
- 301. - },
- 302. -
- 303. - initContacts: function () {
- 304. - cur.section = 'contacts';
- 305. -
- 306. - selectsData.setCountries(cur.selectData.countries);
- 307. - selectsData.setCities(cur.selectData.country, cur.selectData.cities);
- 308. -
- 309. - cur.uiCity = new CitySelect(ge('pedit_city'), ge('pedit_city_row'), {
- 310. - width: 178,
- 311. - progressBar: ge('pedit_country_progress'),
- 312. - city: cur.selectData.city_val,
- 313. - country: cur.selectData.country,
- 314. - maxItemsShown: function(query_length) {
- 315. - return (query_length > 6) ? 500 : 350;
- 316. - }
- 317. - });
- 318. -
- 319. - cur.uiCountry = new CountrySelect(ge('pedit_country'), ge('pedit_country_row'), {
- 320. - width: 178,
- 321. - progressBar: ge('pedit_country_progress'),
- 322. - country: cur.selectData.country_val,
- 323. - citySelect: cur.uiCity
- 324. - });
- 325. -
- 326. - ge('pedit_email').value = cur.options.email;
- 327. - ge('pedit_mobile').value = cur.options.mobile;
- 328. - ge('pedit_home').value = cur.options.home;
- 329. - ge('pedit_website').value = cur.options.website;
- 330. - ge('pedit_skype').value = cur.options.skype;
- 331. -
- 332. - ProfileEditor.initBeforeUnload();
- 333. - },
- 334. -
- 335. - wereChanges: function (section) {
- 336. - switch (section) {
- 337. - case 'general':
- 338. - var peditData = cur.options;
- 339. - return val('pedit_sex') != peditData.sex || val('pedit_status') != peditData.status ||
- 340. - val('pedit_partner') != peditData.partner || val('pedit_bday') != peditData.bday ||
- 341. - val('pedit_bmonth') != peditData.bmonth || val('pedit_byear') != peditData.byear ||
- 342. - val('pedit_bday_visibility') != peditData.bday_visibility ||
- 343. - val('pedit_home_town') != peditData.home_town ||
- 344. - val('pedit_first_name') != peditData.first_name ||
- 345. - val('pedit_last_name') != peditData.last_name ||
- 346. - ge('pedit_middle_name') && val('pedit_middle_name') != peditData.middle_name ||
- 347. - val('pedit_maiden_name') != peditData.maiden_name||
- 348. - val('pedit_langs') != peditData.lang;
- 349. - break;
- 350. -
- 351. - case 'contacts':
- 352. - var peditData = cur.options;
- 353. - return ge('pedit_email').value != peditData.email
- 354. - || ge('pedit_mobile').value != peditData.mobile
- 355. - || ge('pedit_home').value != peditData.home
- 356. - || ge('pedit_website').value != peditData.website
- 357. - || ge('pedit_skype').value != (peditData.skype || '')
- 358. - || (parseInt(ge('pedit_country').value) || '') != (cur.selectData['country_val'][0] || '')
- 359. - || (parseInt(ge('pedit_city').value) || '') != (cur.selectData['city_val'][0] || '')
- 360. - return false;
- 361. -
- 362. - case 'interests':
- 363. - var result = false;
- 364. - each(['activities', 'interests', 'music', 'movies', 'tv', 'books', 'games', 'quotes', 'about'], function(k, field) {
- 365. - var el = ge('pedit_interests_' + field);
- 366. - result |= (cur.interests_data[field].replace(/\x0d/g, '') != val(el).replace(/\x0d/g, ''));
- 367. - });
- 368. - return result;
- 369. - break;
- 370. -
- 371. - case 'education':
- 372. - var school_change = false, uni_change = false;
- 373. - if (isVisible('primary_uni')) {
- 374. - if (ProfileEditorEdu.uniChanged(cur.primary_uni)) {
- 375. - uni_change = true;
- 376. - } else {
- 377. - for (var i = 0; i < cur.unis.length; ++i) {
- 378. - if (cur.unis[i].id > 0 && ProfileEditorEdu.uniChanged(cur.unis[i])) {
- 379. - uni_change = true;
- 380. - } else if (cur.unis[i].id < 0 && isVisible('uni_content' + cur.unis[i].id) && cur.unis[i].uiUniversity.val()) {
- 381. - uni_change = true;
- 382. - }
- 383. - }
- 384. - }
- 385. - }
- 386. - if (isVisible('schools')) {
- 387. - for (var i = 0; i < cur.schools.length; ++i) {
- 388. - if (cur.schools[i].id > 0 && ProfileEditorEdu.schoolChanged(cur.schools[i])) {
- 389. - school_change = true;
- 390. - } else if (cur.schools[i].id < 0 && isVisible('school_content' + cur.schools[i].id) && cur.schools[i].uiSchool.val()) {
- 391. - school_change = true;
- 392. - }
- 393. - }
- 394. - }
- 395. - return uni_change || school_change;
- 396. - break;
- 397. -
- 398. - case 'career':
- 399. - var work_change = false;
- 400. - for (var i = 0; i < cur.works.length; ++i) {
- 401. - var position = (cur.works[i].uiPosition.val_full() || [])[1] || '';
- 402. - if (cur.works[i].id > 0 && ProfileEditorJob.workChanged(cur.works[i])) {
- 403. - work_change = true;
- 404. - } else if (cur.works[i].id < 0 && isVisible('content' + cur.works[i].id) && (ge('company' + cur.works[i].id).value.length || position.length)) {
- 405. - work_change = true;
- 406. - }
- 407. - }
- 408. - return work_change;
- 409. - break;
- 410. -
- 411. - case 'military':
- 412. - var military_change = false;
- 413. - for (var i = 0; i < cur.militaries.length; ++i) {
- 414. - if (cur.militaries[i].id > 0 && ProfileEditorMil.militaryChanged(cur.militaries[i])) {
- 415. - military_change = true;
- 416. - } else if (cur.militaries[i].id < 0 && isVisible('content' + cur.militaries[i].id) && intval(ge('unit' + cur.militaries[i].id).value)) {
- 417. - military_change = true;
- 418. - }
- 419. - }
- 420. - return military_change;
- 421. - break;
- 422. -
- 423. - case 'personal':
- 424. - var peditData = cur.options;
- 425. - return cur.uiPolitical.val() != peditData.political ||
- 426. - (cur.uiReligion.val_full()[1].toLowerCase() != peditData.religion.toLowerCase() && (cur.uiReligion.val() || peditData.religion != '')) ||
- 427. - val('pedit_life') != peditData.life_priority ||
- 428. - val('pedit_people') != peditData.people_priority ||
- 429. - val('pedit_smoking') != peditData.smoking ||
- 430. - val('pedit_alcohol') != peditData.alcohol ||
- 431. - val('pedit_inspired_by') != peditData.inspired_by
- 432. - break;
- 433. - }
- 434. - },
- 435. -
- 436. - checkChanges: function(showBox) {
- 437. - if (cur.leaving) return;
- 438. - var message = false;
- 439. - if (ProfileEditor.wereChanges(cur.section)) {
- 440. - switch (cur.section) {
- 441. - case 'contacts':
- 442. - message = getLang('profileEdit_contacts_changed');
- 443. - break;
- 444. -
- 445. - case 'general':
- 446. - message = getLang('profileEdit_general_changed');
- 447. - break;
- 448. -
- 449. - case 'interests':
- 450. - message = getLang('profileEdit_interests_changed');
- 451. - break;
- 452. -
- 453. - case 'education':
- 454. - message = getLang('profileEdit_unis_schools_changed');
- 455. - break;
- 456. -
- 457. - case 'career':
- 458. - message = getLang('profileEdit_works_changed');
- 459. - break;
- 460. -
- 461. - case 'military':
- 462. - message = getLang('profileEdit_militaries_changed');
- 463. - break;
- 464. -
- 465. - case 'personal':
- 466. - message = getLang('profileEdit_personal_changed');
- 467. - break;
- 468. - }
- 469. - }
- 470. - if (showBox === 1) {
- 471. - if (!message) return true;
- 472. - var box = showFastBox(getLang('global_warning'), message, getLang('global_continue'), function () {
- 473. - cur.leaving = true;
- 474. - box.hide();
- 475. - if (cur.onContinueCb) {
- 476. - cur.onContinueCb();
- 477. - }
- 478. - }, getLang('global_cancel'), function () {
- 479. - box.hide();
- 480. - if (cur.onCancelCb) {
- 481. - cur.onCancelCb();
- 482. - }
- 483. - });
- 484. - return false;
- 485. - }
- 486. - if (message) {
- 487. - return winToUtf(message.replace(/<\/?b>/g, '').replace(/<br\s*\/?>/g, '\n'));
- 488. - }
- 489. - },
- 490. -
- 491. - getLastDay: function (year, month) {
- 492. - if (month == 2) {
- 493. - if (year % 4 == 0) {
- 494. - return 29;
- 495. - } else {
- 496. - return 28;
- 497. - }
- 498. - } else if (month > 0 && ((month < 8 && month % 2 == 0) || (month > 7 && month % 2 == 1))) {
- 499. - return 30;
- 500. - }
- 501. - return 31;
- 502. - },
- 503. -
- 504. - generateDays: function(year, month) {
- 505. - var result = [[0, getLang('profileEdit_main_sel_bday')+':']], last = ProfileEditor.getLastDay(year, month);
- 506. - for (var i = 1; i <= last; ++i) {
- 507. - result.push([i, i + '']);
- 508. - }
- 509. - return result;
- 510. - },
- 511. -
- 512. - updateDays: function (year, month) {
- 513. - if (cur.uiBday.val() > ProfileEditor.getLastDay(year, month)) {
- 514. - cur.uiBday.clear();
- 515. - }
- 516. - cur.uiBday.setData(ProfileEditor.generateDays(year, month).slice(intval(cur.options.bday) ? 1 : 0));
- 517. - if (cur.onUpdateDays) {
- 518. - cur.onUpdateDays(year, month);
- 519. - }
- 520. - },
- 521. -
- 522. - updateFriendsList: function (cb) {
- 523. - if (!cur.friendsFull) {
- 524. - ajax.post('al_profileEdit.php', {act: 'a_relations_friends'}, {
- 525. - onDone: function(friends) {
- 526. - cur.friendsFull = {1: {}, 2: {}};
- 527. - for (var i = 1; i <= 2; ++i) {
- 528. - var o = 3 - i, fr; // other sex
- 529. - for (var j in friends[i]) {
- 530. - var croppedArray = [], frs = clone(friends[i][j]), croppedFrs = [];
- 531. - for (var k = 1; k < frs.length; ++k) {
- 532. - fr = frs[k];
- 533. - croppedArray.push(fr);
- 534. - croppedFrs.push(fr);
- 535. - }
- 536. - for (var k = 1; k < friends[o][j].length; ++k) {
- 537. - fr = friends[o][j][k];
- 538. - frs.push(fr);
- 539. - croppedFrs.push(fr);
- 540. - }
- 541. - cur.friendsFull[i][j] = [friends[i][j], croppedArray, frs, croppedFrs];
- 542. - }
- 543. - }
- 544. - ProfileEditor.doUpdateFriendsList();
- 545. - cb();
- 546. - },
- 547. - showProgress: show.pbind('pedit_status_progress'),
- 548. - hideProgress: hide.pbind('pedit_status_progress')
- 549. - });
- 550. - } else {
- 551. - ProfileEditor.doUpdateFriendsList();
- 552. - cb();
- 553. - }
- 554. - },
- 555. - doUpdateFriendsList: function () {
- 556. - var status = cur.uiStatus.val(), sex = cur.uiSex.val();
- 557. - if (status < 2 || status == 6 || !sex) return;
- 558. - var data = cur.friendsFull[sex].Nom, gs = (status == 2 || status == 7 || status == 5) ? 2 : 0, p = cur.uiPartner.val(), found = false;
- 559. -
- 560. - for (var i in data[gs]) {
- 561. - if (data[gs][i][0] == p) {
- 562. - found = true;
- 563. - break;
- 564. - }
- 565. - }
- 566. - if (!found) p = 0;
- 567. -
- 568. - data[gs][0][1] = getLang((status == 5) ? 'profileEdit_main_sel_rel_with_m' : (gs ? 'profileEdit_main_sel_relat' : 'profileEdit_main_sel_rel_with_' + (sex == 1 ? 'm' : 'f')));
- 569. -
- 570. - cur.uiPartner.setData(data[gs + 1]);
- 571. - cur.uiPartner.setOptions({defaultItems: data[gs]});
- 572. - cur.uiPartner.setOptions({placeholder: data[gs][0][1]});
- 573. - cur.uiPartner.val(p, true);
- 574. - },
- 575. -
- 576. -
- 577. - updateFamily: function (family) {
- 578. - ge('pedit_grandparents').innerHTML = '';
- 579. - ge('pedit_parents').innerHTML = '';
- 580. - ge('pedit_siblings').innerHTML = '';
- 581. - ge('pedit_children').innerHTML = '';
- 582. - ge('pedit_grandchildren').innerHTML = '';
- 583. - cur.relGuid = 0;
- 584. - cur.relIds = {grandparent: 0, parent: 0, sibling: 0, child: 0, grandchild: 0};
- 585. - relations = [];
- 586. - if(!family) return;
- 587. - each(family || [], function(i,v){
- 588. - var guid = cur.relGuid;
- 589. - sel = v.id > 0 ? v.id : [v.id, v.name, '', v.birth];
- 590. - ProfileEditor.addRelation(v.type, sel);
- 591. - });
- 592. - },
- 593. -
- 594. - addRelation: function(type, selected) {
- 595. - if (!cur.friends) {
- 596. - ProfileEditor.loadFriends(type, selected);
- 597. - } else {
- 598. - ProfileEditor.onFriendsLoaded(type, selected);
- 599. - }
- 600. - },
- 601. -
- 602. - onFriendsLoaded: function(type, selected) {
- 603. - var peditData = cur.options;
- 604. - var wrap = ce('div', {id: 'pedit_wrap_' + type + cur.relGuid, className: 'pedit_wrap_relation clear_fix'});
- 605. - var withDate = (type == 'child' || type == 'grandchild') && (!selected || selected[0] < 0);
- 606. - var name = type + cur.relGuid, id = 'pedit_' + name;
- 607. - var html = '<div class="pedit_relation_input"><div class="fl_l"><input type="hidden" id="' + id + '" name="' + name + '"/></div><div class="fl_r" style="padding-top:3px;"><a href="" onclick="ProfileEditor.removeRelation(\'' + type + '\', ' + cur.relGuid + ');return false;">' + getLang('global_delete') + '</a></div>';
- 608. - var t = 0;
- 609. - if (withDate) {
- 610. - t = selected ? parseInt(selected[3]) : 0;
- 611. - html += '<div class="pedit_relation_date clear_fix clear"><input class="pedit_date_field" type="hidden" id="' + id + '_date" value="'+ t +'"><div class="pedit_bday fl_l"><input type="hidden" id="' + id + '_day"/></div><div class="pedit_bmonth fl_l"><input type="hidden" id="' + id + '_month"/></div><div class="pedit_byear fl_l"><input type="hidden" id="' + id + '_year"/></div></div>';
- 612. - }
- 613. - wrap.innerHTML = html;
- 614. - ge(cur.conts[type]).appendChild(wrap);
- 615. - if(cur.relIds[type] + 1 >= cur.relLimits[type]) {
- 616. - hide('pedit_add_' + type + '_link');
- 617. - } else {
- 618. - show('pedit_add_' + type + '_link');
- 619. - }
- 620. - var relDD = new Selector(ge(id), cur.friends, {
- 621. - width: 220,
- 622. - placeholder: cur.placeholders[type],
- 623. - introText: '',
- 624. - multiselect: false,
- 625. - enableCustom: true,
- 626. - defaultItems: cur.friends,
- 627. - selectedItems: selected?[selected]: [],
- 628. - onChange: function(v) {
- 629. - var dateEl = ge(id + '_date');
- 630. - if (!dateEl) return;
- 631. - toggle(dateEl.parentNode, v == -1);
- 632. - }
- 633. - });
- 634. - if (withDate) {
- 635. - var d = new Date(t * 1000);
- 636. -
- 637. - var years = [peditData.byears[0]];
- 638. - var min_year = 1910;
- 639. - if (parseInt(peditData.byear)) {
- 640. - min_year = Math.max(min_year, parseInt(peditData.byear) + 10);
- 641. - }
- 642. - for (var i = min_year; i <= (new Date()).getFullYear(); i++) {
- 643. - years.push([i,i]);
- 644. - }
- 645. -
- 646. - var onDateChange = function() {
- 647. - var t = 0, d = dayDD.val(), y = yearDD.val(), m = monthDD.val();
- 648. - if (d > ProfileEditor.getLastDay(y, m)) {
- 649. - dayDD.val(1);
- 650. - d = 1;
- 651. - }
- 652. - dayDD.setData(ProfileEditor.generateDays(y, m));
- 653. -
- 654. - if (y) {
- 655. - var date = new Date(y, Math.max(m - 1, 0), Math.max(d, 1));
- 656. - t = Math.floor(date.getTime() / 1000);
- 657. - }
- 658. - ge(id + '_date').value = t;
- 659. - }
- 660. -
- 661. - var dayDD = new Dropdown(ge(id + '_day'), ProfileEditor.generateDays(d.getFullYear(), d.getMonth() + 1), {width: 55, selectedItems: t ? d.getDate() : 0, onChange: onDateChange});
- 662. - var monthDD = new Dropdown(ge(id + '_month'), peditData.bmonths, {width: 95, selectedItems: t ? (d.getMonth()+1): 0, onChange: onDateChange});
- 663. - var yearDD = new Dropdown(ge(id + '_year'), years, {width: 60, selectedItems: t ? d.getFullYear() : 0, onChange: onDateChange});
- 664. - }
- 665. - cur.relIds[type]++;
- 666. - cur.relGuid++;
- 667. - },
- 668. -
- 669. - switchUnits: function () {
- 670. - var curMeasure = cur.options.measure = cur.options.measure == 1 ? 2 : 1,
- 671. - curW = cur.uiWeight.val(),
- 672. - curH = cur.uiHeight.val(),
- 673. - newWeightData = cur.options.weights[curMeasure],
- 674. - newHeightData = cur.options.heights[curMeasure],
- 675. - newW = curW,
- 676. - newH = curH;
- 677. -
- 678. - if (newH >= 140 && newH <= 220) each (newHeightData, function () {
- 679. - if (this[0] >= 140 && this[0] <= 220 && this[0] >= curH) {
- 680. - newH = this[0];
- 681. - return false;
- 682. - }
- 683. - });
- 684. - cur.uiHeight.setData(newHeightData);
- 685. - cur.uiHeight.val(newH);
- 686. -
- 687. - if (newW >= 40 && newW <= 140) each (newWeightData, function () {
- 688. - if (this[0] >= 40 && this[0] <= 140 && this[0] >= curW) {
- 689. - newW = this[0];
- 690. - return false;
- 691. - }
- 692. - });
- 693. - cur.uiWeight.setData(newWeightData);
- 694. - cur.uiWeight.val(newW);
- 695. - ge('pedit_units_toggler').innerHTML = curMeasure == 1 ? getLang('profileEdit_switch_to_meters') : getLang('profileEdit_switch_to_inches');
- 696. - ge('pedit_height_title').innerHTML = curMeasure == 1 ? getLang('profileEdit_height_in') : getLang('profileEdit_height_cm');
- 697. - ge('pedit_weight_title').innerHTML = curMeasure == 1 ? getLang('profileEdit_weight_lbs') : getLang('profileEdit_weight_kg');
- 698. - },
- 699. -
- 700. -
- 701. - removeRelation: function (type, id) {
- 702. - var wrap = ge('pedit_wrap_' + type + id);
- 703. - if(!wrap) return;
- 704. - wrap.parentNode.removeChild(wrap);
- 705. - var rel_id = type+id;
- 706. - if(cur.relIds[type] - 1 >= cur.relLimits[type]) {
- 707. - hide('pedit_add_'+type+'_link');
- 708. - } else {
- 709. - show('pedit_add_'+type+'_link');
- 710. - }
- 711. - cur.relIds[type]--;
- 712. - },
- 713. -
- 714. - loadFriends: function(type, selected) {
- 715. - if (cur.onFrLoaded) {
- 716. - return cur.onFrLoaded.push([type, selected]);
- 717. - }
- 718. - cur.onFrLoaded = [[type, selected]];
- 719. - ajax.post('friends_ajax.php', {act: 'custom', no_lists: 1}, {
- 720. - onDone: function(friends) {
- 721. - if (!cur.onFrLoaded) return;
- 722. -
- 723. - cur.friends = friends;
- 724. - for (var i = 0, l = cur.onFrLoaded.length; i < l; ++i) {
- 725. - ProfileEditor.onFriendsLoaded(cur.onFrLoaded[i][0], cur.onFrLoaded[i][1]);
- 726. - }
- 727. - }
- 728. - });
- 729. - },
- 730. -
- 731. - showLoversBox: function () {
- 732. - cur.lovers_box = showBox('al_profileEdit.php', {act: 'show_lovers_box'}, {params: {width: 495, bodyStyle: 'padding: 7px 5px 5px;'}});
- 733. - },
- 734. - getLoversPage: function (offset) {
- 735. - var box = cur.lovers_box;
- 736. - ajax.post('al_profileEdit.php', {act: 'show_lovers_box', offset: offset}, {
- 737. - onDone: function(title, html) {
- 738. - if (title) {
- 739. - box.setOptions({title: title});
- 740. - }
- 741. - if (html) {
- 742. - box.bodyNode.innerHTML = html;
- 743. - }
- 744. - },
- 745. - showProgress: box.showProgress,
- 746. - hideProgress: box.hideProgress,
- 747. - cache: 1
- 748. - });
- 749. - },
- 750. -
- 751. -
- 752. - saveGeneral: function (btn) {
- 753. - var fName = trim(val('pedit_first_name')),
- 754. - lName = trim(val('pedit_last_name')),
- 755. - mName = isVisible('pedit_maiden_row') ? trim(val('pedit_maiden_name')) : '',
- 756. - nName = trim(val('pedit_middle_name')),
- 757. - flmName, cleanFName, cleanLName, cleanMName,
- 758. - peditData = cur.options;
- 759. -
- 760. - if (!fName) {
- 761. - notaBene('pedit_first_name');
- 762. - return false;
- 763. - }
- 764. - if (!lName) {
- 765. - notaBene('pedit_last_name');
- 766. - return false;
- 767. - }
- 768. - flmName = cleanName(fName, lName, mName);
- 769. - if (peditData.first_name == fName && peditData.last_name == lName) {
- 770. - cleanFName = fName;
- 771. - cleanLName = lName;
- 772. - } else {
- 773. - cleanFName = flmName[0];
- 774. - cleanLName = flmName[1];
- 775. - }
- 776. - if (cleanFName.toLowerCase() != fName.toLowerCase()) {
- 777. - // val('pedit_first_name', cleanFName); // bad idea
- 778. - notaBene('pedit_first_name');
- 779. - return false;
- 780. - }
- 781. - if (cleanLName.toLowerCase() != lName.toLowerCase()) {
- 782. - // val('pedit_last_name', cleanLName); // bad idea
- 783. - notaBene('pedit_last_name');
- 784. - return false;
- 785. - }
- 786. - cleanMName = flmName[2];
- 787. - if (cleanMName.toLowerCase() != mName.toLowerCase() && (cleanMName || mName)) {
- 788. - // val('pedit_maiden_name', cleanMName); // bad idea
- 789. - notaBene('pedit_maiden_name');
- 790. - return false;
- 791. - }
- 792. -
- 793. - if (cur.uiPartner.val() == -1) {
- 794. - cur.onPartnerGot = ProfileEditor.saveGeneral.pbind(btn);
- 795. - cur.uiPartner.options.onChange();
- 796. - return;
- 797. - }
- 798. - if (!intval(cur.uiSex.val())) {
- 799. - cur.uiSex.showDefaultList();
- 800. - return;
- 801. - }
- 802. -
- 803. - var params = {
- 804. - act: 'a_save_general',
- 805. - hash: cur.options.hash,
- 806. - first_name: cleanFName,
- 807. - last_name: cleanLName,
- 808. - maiden_name: cleanMName,
- 809. - nickname: nName
- 810. - };
- 811. -
- 812. - each(['sex', 'status', 'partner', 'bday', 'bmonth', 'byear', 'bday_visibility'], function() {
- 813. - var value = intval(val('pedit_' + this));
- 814. - if (value) {
- 815. - params['' + this] = value;
- 816. - }
- 817. - });
- 818. - params.home_town = val('pedit_home_town');
- 819. - params.langs = cur.uiLangs.val();
- 820. -
- 821. - if (parseInt(cur.options.bday) && !intval(params.bday)) {
- 822. - notaBene(geByClass1('selector', cur.uiBday.container), false, true);
- 823. - notaBene(geByClass1('selector_input', cur.uiBday.container), false, true);
- 824. - return;
- 825. - }
- 826. - if (parseInt(cur.options.bmonth) && !intval(params.bmonth)) {
- 827. - notaBene(geByClass1('selector', cur.uiBmonth.container), false, true);
- 828. - notaBene(geByClass1('selector_input', cur.uiBmonth.container), false, true);
- 829. - return;
- 830. - }
- 831. - if (parseInt(cur.options.byear) && !intval(params.byear)) {
- 832. - notaBene(geByClass1('selector', cur.uiByear.container), false, true);
- 833. - notaBene(geByClass1('selector_input', cur.uiByear.container), false, true);
- 834. - return;
- 835. - }
- 836. -
- 837. - var i = 1;
- 838. - each(geByClass('pedit_relation_input', ge('pedit_grandparents')), function() {
- 839. - params['grandparents['+i+']'] = geByClass('resultField', this)[0].value;
- 840. - params['grandparents_custom['+i+']'] = geByClass('customField', this)[0].value;
- 841. - if (params['grandparents['+i+']'] == -1 && params['grandparents_custom['+i+']']) {
- 842. - var name = params['grandparents_custom['+i+']'];
- 843. - var n = name.split(/\s+/);
- 844. - params['grandparents_custom['+i+']'] = cleanName(n[0] || '', n[1] || '').join(' ');
- 845. - }
- 846. - i++;
- 847. - });
- 848. - i = 1;
- 849. - each(geByClass('pedit_relation_input', ge('pedit_parents')), function() {
- 850. - params['parents['+i+']'] = geByClass('resultField', this)[0].value;
- 851. - params['parents_custom['+i+']'] = geByClass('customField', this)[0].value;
- 852. - if(params['parents['+i+']'] == -1 && params['parents_custom['+i+']']) {
- 853. - var name = params['parents_custom['+i+']'];
- 854. - var n = name.split(/\s+/);
- 855. - params['parents_custom['+i+']'] = cleanName(n[0] || '', n[1] || '').join(' ');
- 856. - }
- 857. - i++;
- 858. - });
- 859. - i = 1;
- 860. - each(geByClass('pedit_relation_input', ge('pedit_siblings')), function() {
- 861. - params['siblings['+i+']'] = geByClass('resultField', this)[0].value;
- 862. - params['siblings_custom['+i+']'] = geByClass('customField', this)[0].value;
- 863. - if(params['siblings['+i+']'] == -1 && params['siblings_custom['+i+']']) {
- 864. - var name = params['siblings_custom['+i+']'];
- 865. - var n = name.split(/\s+/);
- 866. - params['siblings_custom['+i+']'] = cleanName(n[0] || '', n[1] || '').join(' ');
- 867. - }
- 868. - i++;
- 869. - });
- 870. - i = 1;
- 871. - each(geByClass('pedit_relation_input', ge('pedit_children')), function() {
- 872. - params['children['+i+']'] = geByClass('resultField', this)[0].value;
- 873. - params['children_custom['+i+']'] = geByClass('customField', this)[0].value;
- 874. - params['children_date['+i+']'] = (geByClass('pedit_date_field', this)[0]||{value:0}).value;
- 875. - if (params['children['+i+']'] == -1 && params['children_custom['+i+']']) {
- 876. - var name = params['children_custom['+i+']'];
- 877. - var n = name.split(/\s+/);
- 878. - params['children_custom['+i+']'] = cleanName(n[0] || '', n[1] || '').join(' ');
- 879. - }
- 880. - i++;
- 881. - });
- 882. - i = 1;
- 883. - each(geByClass('pedit_relation_input', ge('pedit_grandchildren')), function() {
- 884. - params['grandchildren['+i+']'] = geByClass('resultField', this)[0].value;
- 885. - params['grandchildren_custom['+i+']'] = geByClass('customField', this)[0].value;
- 886. - params['grandchildren_date['+i+']'] = (geByClass('pedit_date_field', this)[0]||{value:0}).value;
- 887. - if (params['grandchildren['+i+']'] == -1 && params['grandchildren_custom['+i+']']) {
- 888. - var name = params['grandchildren_custom['+i+']'];
- 889. - var n = name.split(/\s+/);
- 890. - params['grandchildren_custom['+i+']'] = cleanName(n[0] || '', n[1] || '').join(' ');
- 891. - }
- 892. - i++;
- 893. - });
- 894. - // debugLog(params);
- 895. - if (cur.onProfileEditSave) {
- 896. - cur.onProfileEditSave();
- 897. - }
- 898. - ajax.post('al_profileEdit.php', params, {
- 899. - onDone: function(response, introScript) {
- 900. - if (response.only_name) {
- 901. - ProfileEditor.showMsg(response.name_response);
- 902. - return;
- 903. - }
- 904. -
- 905. - var peditData = cur.options;
- 906. - peditData.sex = cur.uiSex.val();
- 907. - peditData.status = response.status;
- 908. - peditData.partner = response.partner;
- 909. - peditData.bday = cur.uiBday.val();
- 910. - peditData.bmonth = cur.uiBmonth.val();
- 911. - peditData.byear = cur.uiByear.val();
- 912. - peditData.bday_visibility = cur.uiBdayVisibility.val();
- 913. - peditData.lang = cur.uiLangs.val();
- 914. - peditData.home_town = val('pedit_home_town');
- 915. - peditData.first_name = val('pedit_first_name');
- 916. - peditData.last_name = val('pedit_last_name');
- 917. - peditData.middle_name = val('pedit_middle_name');
- 918. - peditData.maiden_name = val('pedit_maiden_name');
- 919. - peditData.family = response.family;
- 920. -
- 921. - cur.uiStatus.val(response.status, true);
- 922. - if (cur.uiPartner.val() != response.partner)
- 923. - cur.uiPartner.val(response.partner, true);
- 924. -
- 925. - ProfileEditor.updateFamily(peditData.family);
- 926. -
- 927. - val('pedit_status_detail_content', response.relation_text);
- 928. - if (peditData.partner) {
- 929. - if (val('pedit_status_detail_content')) show('pedit_status_detail');
- 930. - } else {
- 931. - hide('pedit_status_detail');
- 932. - }
- 933. - hide('pedit_name_request', 'status_help_wrap');
- 934. -
- 935. - ProfileEditor.showMsg(response.name_response || getLang('profileEdit_general_changes_saved'));
- 936. -
- 937. - if (introScript) {
- 938. - setTimeout(function() {
- 939. - eval(introScript);
- 940. - }, 3000);
- 941. - }
- 942. - },
- 943. - showProgress: lockButton.pbind(btn),
- 944. - hideProgress: unlockButton.pbind(btn)
- 945. - });
- 946. - return false;
- 947. - },
- 948. - nameRequestCancel: function (link, reqId, hash) {
- 949. - var progress = ce('div', {className: 'progress'}, {display: 'block'});
- 950. - ajax.post('al_settings.php', {act: 'a_cancel_name', request_id: reqId, hash: hash}, {
- 951. - onDone: function (msg) {
- 952. - hide('pedit_name_request');
- 953. - ProfileEditor.showMsg(msg);
- 954. - },
- 955. - onFail: function (msg) {
- 956. - ProfileEditor.showError(msg, 'name');
- 957. - },
- 958. - showProgress: function () {
- 959. - link.parentNode.replaceChild(progress, link);
- 960. - },
- 961. - hideProgress: function () {
- 962. - progress.parentNode.replaceChild(link, progress);
- 963. - }
- 964. - });
- 965. - },
- 966. - nameChangeCancel: function(obj, hash) {
- 967. - if (cur.nameChangeCancelText) {
- 968. - return;
- 969. - }
- 970. - cur.nameChangeCancelText = obj.innerHTML;
- 971. - obj.innerHTML = '<div style="padding-top: 3px;"><img src="/images/upload.gif" /></div>';
- 972. - ajax.post('al_settings.php', {act: 'a_change_cancel', hash: hash}, {
- 973. - onDone: function() {
- 974. - obj.innerHTML = cur.nameChangeCancelText;
- 975. - cur.nameChangeCancelText = false;
- 976. - }
- 977. - });
- 978. - },
- 979. -
- 980. - saveContacts: function(btn) {
- 981. -
- 982. - var params = {
- 983. - act: 'a_save_contacts',
- 984. - hash: cur.saveHash
- 985. - }
- 986. -
- 987. - var fields = ['email', 'mobile', 'home', 'website', 'skype', 'country', 'city'];
- 988. - for (var i in fields) {
- 989. - params[fields[i]] = ge('pedit_'+fields[i]).value;
- 990. - }
- 991. -
- 992. - fields = ['email', 'mobile', 'home'];
- 993. - for (var i in fields) {
- 994. - params['privacy_'+fields[i]] = Privacy.getValue(fields[i]);
- 995. - }
- 996. -
- 997. - ajax.post('al_profileEdit.php', params, {
- 998. - onDone: function(data, text) {
- 999. - if (data) {
- 1000. - for (var i in data) {
- 1001. - cur.options[i] = data[i];
- 1002. - ge('pedit_'+i).value = data[i] || '';
- 1003. - }
- 1004. - cur.selectData['country_val'][0] = parseInt(data['country']);
- 1005. - cur.selectData['city_val'][0] = parseInt(data['city']);
- 1006. - }
- 1007. - if (text) {
- 1008. - ProfileEditor.showMsg(text);
- 1009. - }
- 1010. - },
- 1011. - showProgress: lockButton.pbind(btn),
- 1012. - hideProgress: unlockButton.pbind(btn)
- 1013. - });
- 1014. -
- 1015. - },
- 1016. -
- 1017. - showSocial: function() {
- 1018. - hide('pedit_show_social');
- 1019. - show('pedit_social_options');
- 1020. - },
- 1021. -
- 1022. - setUpTwitter: function() {
- 1023. - showBox('al_profileEdit.php', {act: 'twitter_settings_box'}, {dark: 1, params: {width: 460}});
- 1024. - },
- 1025. -
- 1026. - setUpFacebook: function(app_id, redir, authorized) {
- 1027. - if (authorized && !cur.disableFbExport) {
- 1028. - return showBox('al_profileEdit.php', {act: 'facebook_settings_box'});
- 1029. - }
- 1030. - var url = 'https://graph.facebook.com/oauth/authorize?client_id=' + app_id + '&redirect_uri=' + redir + '&scope=offline_access,publish_stream&display=popup';
- 1031. - var params = 'scrollbars=0,resizable=1,menubar=0,location=0,left='+(Math.floor(screen.width / 2) - 300)+',top='+(Math.floor(screen.height / 2) - 240)+',width=600,height=400,toolbar=0,status=0';
- 1032. - var win = window.open(url, 'fb', params);
- 1033. - try {
- 1034. - win.focus();
- 1035. - } catch(e) { }
- 1036. - window.socialCallback = function(data) {
- 1037. - ge('export_service_3').innerHTML = '<img src="/images/upload.gif" />';
- 1038. - ProfileEditor.fetchServiceName(3);
- 1039. - }
- 1040. - return;
- 1041. - },
- 1042. -
- 1043. - fetchServiceName: function(service) {
- 1044. - cur['nameService'+service] = setInterval(function() {
- 1045. - ajax.post('/al_profileEdit.php', {act: 'a_get_service_name', service: service}, {
- 1046. - onDone: function(result) {
- 1047. - if (result.msg) {
- 1048. - clearInterval(cur['nameService'+service]);
- 1049. - ge('export_service_'+service).innerHTML = (result.msg_sett) ? result.msg_sett : result.msg;
- 1050. - var boxStr = ge('export_box_service_'+service);
- 1051. - if (boxStr) {
- 1052. - boxStr.innerHTML = result.msg;
- 1053. - cur.showIntegrationSaveBtns();
- 1054. - }
- 1055. - }
- 1056. - }
- 1057. - });
- 1058. - }, 1000);
- 1059. - },
- 1060. -
- 1061. - setUpLiveJournal: function() {
- 1062. - showBox('al_profileEdit.php', {act: 'lj_settings_box'});
- 1063. - },
- 1064. -
- 1065. - setUpInstagram: function(redirectUrl) {
- 1066. - var clientId = '1fdcd1b154d54990892368072ab4d303';
- 1067. - var url = 'https://api.instagram.com/oauth/authorize/?client_id='+clientId+'&redirect_uri='+redirectUrl+'&response_type=code';
- 1068. - var params = 'scrollbars=0,resizable=1,menubar=0,location=0,left='+(Math.floor(screen.width / 2) - 300)+',top='+(Math.floor(screen.height / 2) - 240)+',width=600,height=400,toolbar=0,status=0';
- 1069. - var win = window.open(url, 'instagram', params);
- 1070. - try {
- 1071. - win.focus();
- 1072. - } catch(e) { }
- 1073. - window.socialCallback = function(data) {
- 1074. - showBox('al_profileEdit.php', {act: 'instagram_settings_box'}, {dark: true, params: {width: 460}});
- 1075. - //ge('export_service_4').innerHTML = '<div class="progress_inline"></div>';
- 1076. - //ProfileEditor.fetchServiceName(4);
- 1077. - }
- 1078. - return;
- 1079. - },
- 1080. -
- 1081. - getLiveJournalName: function(box) {
- 1082. - var nameService2 = setInterval(function() {
- 1083. - ajax.post('/al_profileEdit.php', {act: 'a_get_livejournal_name'}, {
- 1084. - onDone: function(result) {
- 1085. - if (!result || result.error == undefined) return;
- 1086. - clearInterval(nameService2);
- 1087. - if (result.msg) {
- 1088. - box.hide();
- 1089. - ge('export_service_2').innerHTML = result.msg;
- 1090. - return;
- 1091. - } else {
- 1092. - if (box) {
- 1093. - box.hideProgress();
- 1094. - }
- 1095. -
- 1096. - if (result.error == 1) {
- 1097. - ge('pedit_lj_error').innerHTML = 'Server error.';
- 1098. - show('pedit_lj_error');
- 1099. - } else if (result.error == 2) {
- 1100. - ge('pedit_lj_error').innerHTML = cur.lang['settings_lj_wrong_password'];
- 1101. - show('pedit_lj_error');
- 1102. - }
- 1103. - }
- 1104. - }
- 1105. - });
- 1106. - }, 1000);
- 1107. - },
- 1108. -
- 1109. - clearSocialExport: function(service) {
- 1110. - var title, msg;
- 1111. - switch (service) {
- 1112. - case 1: title = 'settings_status_export'; msg = 'settings_status_confirm'; break;
- 1113. - case 2: title = 'settings_notes_export'; msg = 'settings_livejournal_confirm'; break;
- 1114. - case 3: title = 'settings_status_export'; msg = 'settings_facebook_confirm'; break;
- 1115. - case 4: title = 'settings_status_import_photo'; msg = 'settings_instagram_confirm'; break;
- 1116. - }
- 1117. - var msg = '<center>'+getLang(msg)+'</center>';
- 1118. - var clrBox = showFastBox(getLang(title), msg, getLang('global_continue'), function() {
- 1119. - ajax.post('/al_profileEdit.php', {act: 'a_clear_social_export', service: service, hash: cur.saveHash}, {onDone: function(result) {
- 1120. - if (!result || !result.msg) return;
- 1121. - clrBox.hide();
- 1122. - ge('export_service_'+service).innerHTML = result.msg;
- 1123. - setTimeout(scrollToTop, 300);
- 1124. - var settBox = curBox();
- 1125. - if (settBox) {
- 1126. - settBox.hide();
- 1127. - }
- 1128. - }});
- 1129. - clrBox.showProgress();
- 1130. - }, getLang('global_cancel'));
- 1131. - },
- 1132. -
- 1133. - slideShow: function(elem, speed) {
- 1134. - if (!isVisible(elem)) slideDown(elem, speed || 150);
- 1135. - },
- 1136. - slideHide: function(elem, speed) {
- 1137. - if (isVisible(elem)) slideUp(elem, speed || 150);
- 1138. - },
- 1139. -
- 1140. - initInterests: function () {
- 1141. - cur.interests_data = {};
- 1142. - cur.section = 'interests';
- 1143. - each(['activities', 'interests', 'music', 'movies', 'tv', 'books', 'games', 'quotes', 'about'], function (k, field) {
- 1144. - var el = ge('pedit_interests_' + field);
- 1145. - cur.interests_data[field] = val(el);
- 1146. - autosizeSetup(el, {minHeight: 80, height: 80});
- 1147. - });
- 1148. - ProfileEditor.initBeforeUnload();
- 1149. - },
- 1150. -
- 1151. - saveInterests: function (btn) {
- 1152. - var params = {act: 'a_save_interests', hash: cur.options.hash};
- 1153. - each(['activities', 'interests', 'music', 'movies', 'tv', 'books', 'games', 'quotes', 'about'], function (k, field) {
- 1154. - params[field] = val('pedit_interests_' + field);
- 1155. - });
- 1156. - ajax.post('al_profileEdit.php', params, {
- 1157. - onDone: function (interests_data) {
- 1158. - each(['activities', 'interests', 'music', 'movies', 'tv', 'books', 'games', 'quotes', 'about'], function(k, field) {
- 1159. - var el = ge('pedit_interests_' + field);
- 1160. - val(el, cur.interests_data[field] = winToUtf(interests_data[field]));
- 1161. - el.autosize.update();
- 1162. - });
- 1163. - ProfileEditor.showMsg(getLang('profileEdit_interests_saved'));
- 1164. - },
- 1165. - showProgress: lockButton.pbind(btn),
- 1166. - hideProgress: unlockButton.pbind(btn)
- 1167. - });
- 1168. - return false;
- 1169. - },
- 1170. -
- 1171. - initEducation: function () {
- 1172. - cur.section = 'education';
- 1173. -
- 1174. - cur.nav.push(function(changed, old, n) {
- 1175. - if (old[0] != 'edit' || changed[0]) return true;
- 1176. -
- 1177. - if ((old['act'] == 'education' || old['act'] == 'higher_education') && (n['act'] == 'education' || n['act'] == 'higher_education')) {
- 1178. - ProfileEditor.selectEduTab(changed['act']);
- 1179. - return false;
- 1180. - } else {
- 1181. - return true;
- 1182. - }
- 1183. - });
- 1184. - cur.onCancelCb = function() {
- 1185. - if (cur.section != 'education') return;
- 1186. -
- 1187. - var school_change = false, uni_change = false;
- 1188. - if (isVisible('primary_uni')) {
- 1189. - if (ProfileEditorEdu.uniChanged(cur.primary_uni)) {
- 1190. - uni_change = true;
- 1191. - } else {
- 1192. - for (var i = 0; i < cur.unis.length; ++i) {
- 1193. - if (cur.unis[i].id > 0 && ProfileEditorEdu.uniChanged(cur.unis[i])) {
- 1194. - uni_change = true;
- 1195. - } else if (cur.unis[i].id < 0 && isVisible('uni_content' + cur.unis[i].id) && cur.unis[i].uiUniversity.val()) {
- 1196. - uni_change = true;
- 1197. - }
- 1198. - }
- 1199. - }
- 1200. - }
- 1201. - if (isVisible('schools')) {
- 1202. - for (var i = 0; i < cur.schools.length; ++i) {
- 1203. - if (cur.schools[i].id > 0 && ProfileEditorEdu.schoolChanged(cur.schools[i])) {
- 1204. - school_change = true;
- 1205. - } else if (cur.schools[i].id < 0 && isVisible('school_content' + cur.schools[i].id) && cur.schools[i].uiSchool.val()) {
- 1206. - school_change = true;
- 1207. - }
- 1208. - }
- 1209. - }
- 1210. - if (cur.filter_uni && !uni_change && school_change) {
- 1211. - ProfileEditor.selectEduTab('education');
- 1212. - } else if (!cur.filter_uni && !school_change && uni_change) {
- 1213. - ProfileEditor.selectEduTab('higher_education');
- 1214. - }
- 1215. - };
- 1216. -
- 1217. - if (!cur.demo) {
- 1218. - selectsData.setCountries(cur.selData.countries_list);
- 1219. - for (var i in cur.selData.countries) {
- 1220. - selectsData.setCountryInfo(i, cur.selData.countries[i]);
- 1221. - }
- 1222. - for (var i in cur.selData.cities) {
- 1223. - selectsData.setCityInfo(i, cur.selData.cities[i]);
- 1224. - }
- 1225. - for (var i in cur.selData.universities) {
- 1226. - selectsData.setUniversityInfo(i, cur.selData.universities[i]);
- 1227. - }
- 1228. - for (var i in cur.selData.faculties) {
- 1229. - selectsData.setFacultyInfo(i, cur.selData.faculties[i]);
- 1230. - }
- 1231. - }
- 1232. -
- 1233. - ProfileEditorEdu.init();
- 1234. - ProfileEditor.initBeforeUnload();
- 1235. -
- 1236. - this.selectEduTab(cur.filter_uni ? 'higher_education' : 'education');
- 1237. - },
- 1238. -
- 1239. - selectEduTab: function (tab, ev) {
- 1240. - if (ev && checkEvent(ev)) return false;
- 1241. - if (tab == 'education') {
- 1242. - cur.filter_uni = 0;
- 1243. - removeClass(ge('sum_tab_schools').parentNode, 'summary_tab');
- 1244. - addClass(ge('sum_tab_schools').parentNode, 'summary_tab_sel');
- 1245. - removeClass(ge('sum_tab_unis').parentNode, 'summary_tab_sel');
- 1246. - addClass(ge('sum_tab_unis').parentNode, 'summary_tab');
- 1247. - show('school');
- 1248. - hide('uni');
- 1249. - hide('pedit_result');
- 1250. -
- 1251. - ge('summary').innerHTML = getLang('profileEdit_can_edit_schools');
- 1252. -
- 1253. - if (!isVisible('schools')) {
- 1254. - cur.schoolsCount = cur.schools.length;
- 1255. - if (cur.schoolsCount) {
- 1256. - for (var i = 0; i < cur.schools.length; ++i) {
- 1257. - ge('schools').appendChild(ProfileEditorEdu.genSchoolRow(cur.schools[i].id));
- 1258. - cur.schools[i] = ProfileEditorEdu.initSchoolRow(cur.schools[i]);
- 1259. - }
- 1260. - } else {
- 1261. - ProfileEditorEdu.addSchool();
- 1262. - }
- 1263. - show('schools');
- 1264. - }
- 1265. -
- 1266. - if (cur.schoolsCount >= 7) {
- 1267. - hide('add_school_link');
- 1268. - } else {
- 1269. - show('add_school_link');
- 1270. - }
- 1271. - nav.setLoc({0: 'edit', 'act': tab});
- 1272. - } else if (tab == 'higher_education') {
- 1273. - cur.filter_uni = 1;
- 1274. - removeClass(ge('sum_tab_unis').parentNode, 'summary_tab');
- 1275. - addClass(ge('sum_tab_unis').parentNode, 'summary_tab_sel');
- 1276. - removeClass(ge('sum_tab_schools').parentNode, 'summary_tab_sel');
- 1277. - addClass(ge('sum_tab_schools').parentNode, 'summary_tab');
- 1278. - show('uni');
- 1279. - hide('school');
- 1280. - hide('pedit_result');
- 1281. -
- 1282. - ge('summary').innerHTML = getLang('profileEdit_can_edit_unis');
- 1283. -
- 1284. - if (!isVisible('primary_uni')) {
- 1285. - ge('primary_uni').appendChild(ProfileEditorEdu.genUniRow(cur.primary_uni.id, true));
- 1286. - cur.primary_uni = ProfileEditorEdu.initUniRow(cur.primary_uni);
- 1287. - show('primary_uni');
- 1288. - cur.unisCount = cur.unis.length;
- 1289. - if (cur.unisCount) {
- 1290. - for (var i = 0; i < cur.unis.length; ++i) {
- 1291. - ge('unis').appendChild(ProfileEditorEdu.genUniRow(cur.unis[i].id));
- 1292. - cur.unis[i] = ProfileEditorEdu.initUniRow(cur.unis[i]);
- 1293. - }
- 1294. - show('unis');
- 1295. - }
- 1296. - }
- 1297. -
- 1298. - if (cur.unisCount >= 9) {
- 1299. - hide('add_uni_link');
- 1300. - } else {
- 1301. - show('add_uni_link');
- 1302. - }
- 1303. - nav.setLoc({0: 'edit', 'act': tab});
- 1304. - }
- 1305. - },
- 1306. -
- 1307. - initCareer: function () {
- 1308. - cur.section = 'career';
- 1309. -
- 1310. - ProfileEditorJob.init();
- 1311. - ProfileEditor.initBeforeUnload();
- 1312. - },
- 1313. -
- 1314. - initMilitary: function () {
- 1315. - cur.section = 'military';
- 1316. -
- 1317. - ProfileEditorMil.init();
- 1318. - ProfileEditor.initBeforeUnload();
- 1319. - },
- 1320. -
- 1321. - initPersonal: function () {
- 1322. - var peditData = cur.options;
- 1323. - cur.section = 'personal';
- 1324. -
- 1325. - cur.uiLife = new Dropdown(ge('pedit_life'), peditData.life_priorities, {
- 1326. - width: 220,
- 1327. - multiselect: false,
- 1328. - selectedItems: peditData.life_priority
- 1329. - });
- 1330. -
- 1331. - cur.uiPeople = new Dropdown(ge('pedit_people'), peditData.people_priorities, {
- 1332. - width: 220,
- 1333. - multiselect: false,
- 1334. - selectedItems: peditData.people_priority
- 1335. - });
- 1336. -
- 1337. - cur.uiSmoking = new Dropdown(ge('pedit_smoking'), peditData.smoking_types, {
- 1338. - width: 220,
- 1339. - multiselect: false,
- 1340. - selectedItems: peditData.smoking
- 1341. - });
- 1342. -
- 1343. - cur.uiAlcohol = new Dropdown(ge('pedit_alcohol'), peditData.alcohol_types, {
- 1344. - width: 220,
- 1345. - multiselect: false,
- 1346. - selectedItems: peditData.alcohol
- 1347. - });
- 1348. -
- 1349. - cur.uiPolitical = new Dropdown(ge('pedit_political'), peditData.political_views, {
- 1350. - width: 220,
- 1351. - multiselect: false,
- 1352. - selectedItems: peditData.political
- 1353. - });
- 1354. -
- 1355. - cur.uiReligion = new Selector(ge('pedit_religion'), '', {
- 1356. - width: 220,
- 1357. - dropdown: false,
- 1358. - multiselect: false,
- 1359. - enableCustom: true,
- 1360. - introText: '',
- 1361. - noResult: '',
- 1362. - placeholder: getLang('profileEdit_main_sel_relig'),
- 1363. - placeholderColor: '#000',
- 1364. - onChange: function(value) {
- 1365. - if (!intval(value)) {
- 1366. - cur.uiReligion.clear();
- 1367. - }
- 1368. - }
- 1369. - });
- 1370. - cur.uiReligion.setData(peditData.religions);
- 1371. - if (peditData.religion_id > 0) {
- 1372. - cur.uiReligion.val(peditData.religion_id, true);
- 1373. - } else if (peditData.religion.length) {
- 1374. - cur.uiReligion.customVal(peditData.religion);
- 1375. - }
- 1376. -
- 1377. - ProfileEditor.initBeforeUnload();
- 1378. - },
- 1379. -
- 1380. - savePersonal: function (btn) {
- 1381. - var params = {act: 'a_save_personal', hash: cur.options.hash}, data = {
- 1382. - religion: cur.uiReligion.val(),
- 1383. - religion_custom: val('pedit_religion_custom'),
- 1384. - political: cur.uiPolitical.val(),
- 1385. - life_priority: cur.uiLife.val(),
- 1386. - people_priority: cur.uiPeople.val(),
- 1387. - smoking: cur.uiSmoking.val(),
- 1388. - alcohol: cur.uiAlcohol.val(),
- 1389. - inspired_by: val('pedit_inspired_by')
- 1390. - };
- 1391. - extend(params, data);
- 1392. - ajax.post('al_profileEdit.php', params, {
- 1393. - onDone: function (personal_data) {
- 1394. - cur.options.religion_id = data.religion;
- 1395. - cur.options.religion = data.religion_custom || cur.uiReligion.val_full()[1];
- 1396. - delete data.religion_custom;
- 1397. - delete data.religion;
- 1398. - extend(cur.options, data);
- 1399. - each(['inspired_by'], function(k, field) {
- 1400. - val('pedit_' + field, cur.options[field] = winToUtf(personal_data[field] || ''));
- 1401. - });
- 1402. - ProfileEditor.showMsg(getLang('profileEdit_personal_saved'));
- 1403. - },
- 1404. - showProgress: lockButton.pbind(btn),
- 1405. - hideProgress: unlockButton.pbind(btn)
- 1406. - });
- 1407. - return false;
- 1408. - },
- 1409. -
- 1410. - editHome: function(placeId) {
- 1411. - showBox('edit', {act: 'edit_home', place_id: cur.editAddrId || placeId});
- 1412. - }
- 1413. - }
- 1414. -
- 1415. - try{stManager.done('profile_edit.js');}catch(e){}
- ------
Advertisement
Add Comment
Please, Sign In to add comment