Hormold

VK Change (#1377784805)

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