Hormold

VK Change (#1377861303)

Aug 30th, 2013
333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 31.96 KB | None | 0 0
  1. Файл - maps.js (Старый размер - 0 | Новый - 0):
  2. ------
  3. Файл - places.js (Старый размер - 25722 | Новый - 0):
  4. 0.  - var Places = {
  5. 1.  -
  6. 2.  - initPhotoMap: function(opts) {
  7. 3.  -   var map, isMapbox, isGoogle, CustomMarker, createMarker;
  8. 4.  -   if (!cur.iconLastNum) {
  9. 5.  -     cur.iconLastNum = 0;
  10. 6.  -   }
  11. 7.  -   if (opts.provider == 'mapbox') {
  12. 8.  -     isMapbox = 1;
  13. 9.  -     if (!window.L || !window.L.mapbox) {
  14. 10.  -       var stat = ['mapbox.css', 'mapbox.js'];
  15. 11.  -       if (browser.msie && browser.version < 8) {
  16. 12.  -         stat.push('mapbox_ie.css');
  17. 13.  -       }
  18. 14.  -       stManager.add(stat, function() {
  19. 15.  -         Places.initPhotoMap(opts);
  20. 16.  -       });
  21. 17.  -       return false;
  22. 18.  -     }
  23. 19.  -   } else {
  24. 20.  -     isGoogle = 1;
  25. 21.  -     if (!window.google || !google.maps.OverlayView) {
  26. 22.  -       if (!opts.googleAttaced) {
  27. 23.  -         headNode.appendChild(ce('script', {
  28. 24.  -           type: 'text/javascript',
  29. 25.  -           src: (window.locProtocol || 'http:') + '//maps.google.com/maps/api/js?sensor=false&callback=gMapsInit&language='+(cur.vkLngCode || 'en')
  30. 26.  -         }));
  31. 27.  -       }
  32. 28.  -       window.gMapsInit = function() {
  33. 29.  -         Places.initPhotoMap(opts);
  34. 30.  -         delete window.gMapsInit;
  35. 31.  -       }
  36. 32.  -       return false;
  37. 33.  -     }
  38. 34.  -   }
  39. 35.  -   cur.photoMapOpts = opts;
  40. 36.  -
  41. 37.  -   function unexpandPoint(point, sub) {
  42. 38.  -     if (!point.expanded) {
  43. 39.  -       return false;
  44. 40.  -     }
  45. 41.  -     if (!sub) {
  46. 42.  -       if (isMapbox) {
  47. 43.  -         map.addLayer(point.overlay);
  48. 44.  -       } else {
  49. 45.  -         point.overlay.setMap(map);
  50. 46.  -       }
  51. 47.  -     }
  52. 48.  -     point.expanded = false;
  53. 49.  -     var p = point.points;
  54. 50.  -     if (p) {
  55. 51.  -       for (i in p) {
  56. 52.  -         var subPoint = p[i];
  57. 53.  -         if (subPoint.overlay) {
  58. 54.  -           if (isMapbox) {
  59. 55.  -             map.removeLayer(subPoint.overlay);
  60. 56.  -           } else {
  61. 57.  -             subPoint.overlay.setMap(null);
  62. 58.  -           }
  63. 59.  -           unexpandPoint(subPoint, true)
  64. 60.  -         }
  65. 61.  -       }
  66. 62.  -     }
  67. 63.  -   }
  68. 64.  -
  69. 65.  -   function expandPoint(point, possive) {
  70. 66.  -     if (point.diff && point.diff < 0.00002) {
  71. 67.  -       return false;
  72. 68.  -     }
  73. 69.  -     if (point.diff && point.diff <= (point.count + 1) * 0.000001) {
  74. 70.  -       return false;
  75. 71.  -     }
  76. 72.  -     var p = point.points;
  77. 73.  -     if (p) {
  78. 74.  -       if (point.expanded || possive) {
  79. 75.  -         return false;
  80. 76.  -       }
  81. 77.  -       var len = p.length;
  82. 78.  -       while (len--) {
  83. 79.  -         var subPoint = p[len];
  84. 80.  -         if (subPoint.overlay) {
  85. 81.  -           if (isMapbox) {
  86. 82.  -             map.addLayer(subPoint.overlay);
  87. 83.  -           } else {
  88. 84.  -             subPoint.overlay.setMap(map);
  89. 85.  -           }
  90. 86.  -         } else {
  91. 87.  -           if (isMapbox) {
  92. 88.  -             var pt = new L.LatLng(subPoint.lat, subPoint.lng);
  93. 89.  -             subPoint.overlay = createMarker(pt, map, subPoint.src, subPoint.count, subPoint.diff);
  94. 90.  -             subPoint.overlay.on('click', (pointClick).pbind(subPoint));
  95. 91.  -           } else {
  96. 92.  -             var pt = new google.maps.LatLng(subPoint.lat, subPoint.lng);
  97. 93.  -             subPoint.overlay = new CustomMarker(pt, map, subPoint.src, subPoint.count, subPoint.diff);
  98. 94.  -             google.maps.event.addListener(subPoint.overlay, 'click', (pointClick).pbind(subPoint));
  99. 95.  -           }
  100. 96.  -         }
  101. 97.  -       }
  102. 98.  -       if (isMapbox) {
  103. 99.  -         map.removeLayer(point.overlay);
  104. 100.  -       } else {
  105. 101.  -         point.overlay.setMap(null);
  106. 102.  -       }
  107. 103.  -       point.expanded = true;
  108. 104.  -     } else if (!point.loading) {
  109. 105.  -       point.loading = true;
  110. 106.  -       ajax.post('al_places.php', {
  111. 107.  -         act: 'a_get_points',
  112. 108.  -         diff: point.diff || opts.diffZone,
  113. 109.  -         lat: point.lat,
  114. 110.  -         lng: point.lng,
  115. 111.  -         uid: opts.uid
  116. 112.  -       }, {
  117. 113.  -         onDone: function(points) {
  118. 114.  -           point.points = points;
  119. 115.  -           expandPoint(point, possive);
  120. 116.  -         },
  121. 117.  -         onFail: function() {
  122. 118.  -           point.loading = false;
  123. 119.  -         }
  124. 120.  -       })
  125. 121.  -     }
  126. 122.  -   }
  127. 123.  -
  128. 124.  -   function checkPointsReq(points, mapBounds) {
  129. 125.  -     if (!points) {
  130. 126.  -       return false;
  131. 127.  -     }
  132. 128.  -     for (i in points) {
  133. 129.  -       var point = points[i];
  134. 130.  -       if (point.count <= 1) {
  135. 131.  -         continue;
  136. 132.  -       }
  137. 133.  -       var diff = (point.diff * 15) || opts.diffZone;
  138. 134.  -       var inside = (point.lat + diff > mapBounds.neLat && point.lat - diff < mapBounds.swLat && point.lng + diff > mapBounds.neLng && point.lng - diff < mapBounds.swLng);
  139. 135.  -
  140. 136.  -       if (!inside) {
  141. 137.  -         if (point.expanded) {
  142. 138.  -           unexpandPoint(point);
  143. 139.  -         }
  144. 140.  -         continue;
  145. 141.  -       }
  146. 142.  -       if (point.expanded) {
  147. 143.  -         checkPointsReq(point.points, mapBounds);
  148. 144.  -       } else if (inside) {
  149. 145.  -         expandPoint(point);
  150. 146.  -       } else if (point.expanded) {
  151. 147.  -         unexpandPoint(point);
  152. 148.  -       }
  153. 149.  -     }
  154. 150.  -   }
  155. 151.  -
  156. 152.  -   function updateMapPoints() {
  157. 153.  -     checkPointsReq(opts.points, getMapBounds());
  158. 154.  -   }
  159. 155.  -
  160. 156.  -   function zoomToPoint(point) {
  161. 157.  -     var mapBounds = map.getBounds();
  162. 158.  -     var ne = mapBounds.getNorthEast();
  163. 159.  -     var sw = mapBounds.getSouthWest();
  164. 160.  -     var zoom =  map.getZoom();
  165. 161.  -     if (point.diff) {
  166. 162.  -       var needZoom = ((ne.lat() - sw.lat()) * 0.9) > point.diff * 2;
  167. 163.  -     } else {
  168. 164.  -       var needZoom = zoom < 17;
  169. 165.  -     }
  170. 166.  -     if (needZoom) {
  171. 167.  -       map.setZoom(zoom + 1)
  172. 168.  -       //zoomToPoint(point);
  173. 169.  -       setTimeout(zoomToPoint.pbind(point), 0)
  174. 170.  -     } else {
  175. 171.  -       updateMapPoints();
  176. 172.  -     }
  177. 173.  -   }
  178. 174.  -
  179. 175.  -   function pointClick(point) {
  180. 176.  -     if (!opts.box) {
  181. 177.  -       showBox('al_places.php', {
  182. 178.  -         act: 'photos_box',
  183. 179.  -         lat: point.lat,
  184. 180.  -         lng: point.lng,
  185. 181.  -         diff: opts.diffZone,
  186. 182.  -         uid: opts.uid
  187. 183.  -       }, {
  188. 184.  -         stat: ['maps.js', 'places.js', 'places.css', 'ui_controls.js', 'ui_controls.css']
  189. 185.  -       });
  190. 186.  -       return false;
  191. 187.  -     }
  192. 188.  -     if (point.count == 1/* || point.diff < 0.0001*/ || true) {
  193. 189.  -       var photo = point.photo.split('_');
  194. 190.  -       if (point.overlay) {
  195. 191.  -         var elCont = ge('profile_map_icon_'+point.overlay.iconNum);
  196. 192.  -         var el = geByClass1('profile_map_first', elCont) || elCont;
  197. 193.  -         var cnt = geByClass1('profile_map_photo_count', el);
  198. 194.  -         if (cnt) {
  199. 195.  -           hide(cnt);
  200. 196.  -         }
  201. 197.  -         re('profile_map_photo_loader');
  202. 198.  -         var loader = ce('div', {id: 'profile_map_photo_loader'});
  203. 199.  -         el.appendChild(loader);
  204. 200.  -       }
  205. 201.  -       var diff = (point.diff || 0.000001);
  206. 202.  -       var list = 'map'+opts.uid+'_'+(point.lat - diff)+'_'+(point.lng - diff)+'_'+(point.lat + diff)+'_'+(point.lng + diff);
  207. 203.  -       return opts.showPlacePhoto(point.photo, list, {});
  208. 204.  -     }/* else if (opts.box) {
  209. 205.  -       map.panTo(new google.maps.LatLng(point.lat, point.lng));
  210. 206.  -       zoomToPoint(point);
  211. 207.  -       expandPoint(point, true);
  212. 208.  -     }*/
  213. 209.  -     return false;
  214. 210.  -   }
  215. 211.  -
  216. 212.  -   function getMapBounds() {
  217. 213.  -     var mapBounds = map.getBounds();
  218. 214.  -     var ne = mapBounds.getNorthEast();
  219. 215.  -     var sw = mapBounds.getSouthWest();
  220. 216.  -     var zoom = map.getZoom();
  221. 217.  -     if (zoom < 3) {
  222. 218.  -       var res = {
  223. 219.  -         swLat: -90,
  224. 220.  -         swLng: -90,
  225. 221.  -         neLat: 90,
  226. 222.  -         neLng: 90
  227. 223.  -       };
  228. 224.  -     } else {
  229. 225.  -       if (isMapbox) {
  230. 226.  -         var res = {
  231. 227.  -           swLat: sw.lat,
  232. 228.  -           swLng: sw.lng,
  233. 229.  -           neLat: ne.lat,
  234. 230.  -           neLng: ne.lng
  235. 231.  -         };
  236. 232.  -       } else {
  237. 233.  -         var res = {
  238. 234.  -           swLat: sw.lat(),
  239. 235.  -           swLng: sw.lng(),
  240. 236.  -           neLat: ne.lat(),
  241. 237.  -           neLng: ne.lng()
  242. 238.  -         };
  243. 239.  -       }
  244. 240.  -     }
  245. 241.  -     return res;
  246. 242.  -   }
  247. 243.  -
  248. 244.  -   function updatePhotosList() {
  249. 245.  -     var mapBounds = getMapBounds();
  250. 246.  -     ajax.post('al_places.php', {
  251. 247.  -       act: 'update_photos_list',
  252. 248.  -       uid: opts.uid,
  253. 249.  -       sw_lat: mapBounds.swLat,
  254. 250.  -       sw_lng: mapBounds.swLng,
  255. 251.  -       ne_lat: mapBounds.neLat,
  256. 252.  -       ne_lng: mapBounds.neLng
  257. 253.  -     }, {
  258. 254.  -       onDone: function(html) {
  259. 255.  -         ge('place_map_other').innerHTML = html;
  260. 256.  -       }
  261. 257.  -     })
  262. 258.  -     checkPointsReq(opts.points, mapBounds);
  263. 259.  -   }
  264. 260.  -
  265. 261.  -   function setMapOpts(map) {
  266. 262.  -     if (opts.box) {
  267. 263.  -       cur.placeBoxMap = map;
  268. 264.  -       cur.placeBoxOpts = opts;
  269. 265.  -     } else {
  270. 266.  -       cur.placesPhotoMap = map;
  271. 267.  -       cur.placesPhotoOpts = opts;
  272. 268.  -     }
  273. 269.  -   }
  274. 270.  -
  275. 271.  -   function onBoundsChanged(fast) {
  276. 272.  -     if (cur.editPhotosPlace) {
  277. 273.  -       fadeOut(ge('places_photo_hint_cont'), 200);
  278. 274.  -     }
  279. 275.  -     if (cur.mapMoveTimeout) {
  280. 276.  -       clearTimeout(cur.mapMoveTimeout);
  281. 277.  -     }
  282. 278.  -     cur.mapMoveTimeout = setTimeout(updateMapPoints, fast ? 0 : 200)
  283. 279.  -     if (firstTimeout) {
  284. 280.  -       firstTimeout = false;
  285. 281.  -       return false;
  286. 282.  -     }
  287. 283.  -     if (opts.box) {
  288. 284.  -       if (cur.mapMoveServerTimeout) {
  289. 285.  -         clearTimeout(cur.mapMoveServerTimeout);
  290. 286.  -       }
  291. 287.  -       cur.mapMoveServerTimeout = setTimeout(updatePhotosList, 500)
  292. 288.  -     }
  293. 289.  -   }
  294. 290.  -
  295. 291.  -   function getIconHtml(imgSrc, cnt, diff, iconNum) {
  296. 292.  -     var html = '';
  297. 293.  -     if (cnt > 1 && diff) {
  298. 294.  -       html = '<span class="profile_map_photo_count">'+(cnt > 99 ? '99+' : cnt)+'</span>';
  299. 295.  -     }
  300. 296.  -     var len = Math.min(cnt - 1, 3);
  301. 297.  -     html = '<div'+(len ? '' : ' id="profile_map_icon_'+iconNum+'"')+' class="profile_map_photo profile_map_first" style="background: url('+imgSrc+') center center no-repeat;'+(len ? ' margin-left: -2px; margin-top: -4px;' : '')+'">'+html+'</div>';
  302. 298.  -     while(len--) {
  303. 299.  -       html = '<div'+(len ? '' : ' id="profile_map_icon_'+iconNum+'"')+' class="profile_map_photo"'+(len ? ' style="margin-left: -2px; margin-top: -4px;"' : '')+'>'+html+'</div>';
  304. 300.  -     }
  305. 301.  -     return html;
  306. 302.  -   }
  307. 303.  -
  308. 304.  -   cur.editPhotosPlace = false;
  309. 305.  -
  310. 306.  -   var firstTimeout = true;
  311. 307.  -   if (isMapbox) {
  312. 308.  -     createMarker = function(latlng, addToMap, src, count, diff) {
  313. 309.  -       var icon = new L.HtmlIcon({
  314. 310.  -          html: getIconHtml(src, count, diff, cur.iconLastNum)
  315. 311.  -       });
  316. 312.  -       cur.icon = icon;
  317. 313.  -       var m = new L.Marker(latlng, {
  318. 314.  -         draggable: false,
  319. 315.  -         icon: icon
  320. 316.  -       });
  321. 317.  -       if (addToMap) {
  322. 318.  -         map.addLayer(m);
  323. 319.  -       } else {
  324. 320.  -         map.removeLayer(m);
  325. 321.  -       }
  326. 322.  -       m.iconNum = cur.iconLastNum++;
  327. 323.  -       return m;
  328. 324.  -     }
  329. 325.  -     var mapboxApiId = 'vkmaps.map-an1xcr4f';
  330. 326.  -     map = opts.map || L.mapbox.map(opts.cont, mapboxApiId, {zoomControl: false, scrollWheelZoom: false, touchZoom: false, detectRetina: true, retinaVersion: mapboxApiId});
  331. 327.  -     setMapOpts(map);
  332. 328.  -
  333. 329.  -     if (opts.bounds) {
  334. 330.  -       map.fitBounds([[opts.bounds.swlat, opts.bounds.swlng], [opts.bounds.nelat, opts.bounds.nelng]]);
  335. 331.  -     } else {
  336. 332.  -       if (!opts.lat && !opts.lng) {
  337. 333.  -         opts.lat = 30;
  338. 334.  -       }
  339. 335.  -       map.setView([opts.lat, opts.lng], 1)
  340. 336.  -     }
  341. 337.  -     if (!opts.nowheel) {
  342. 338.  -       map.on('moveend', onBoundsChanged.pbind(true));
  343. 339.  -       map.on('zoomend', onBoundsChanged.pbind(true));
  344. 340.  -     }
  345. 341.  -
  346. 342.  -     if (opts.points) {
  347. 343.  -       var len = opts.points.length;
  348. 344.  -       while(len--) {
  349. 345.  -         var point = opts.points[len];
  350. 346.  -         var p = new L.LatLng(point.lat, point.lng);
  351. 347.  -         point.overlay = createMarker(p, point.points ? false : true, point.src, point.count, point.diff);
  352. 348.  -         point.overlay.on('click', (pointClick).pbind(point));
  353. 349.  -         if (point.points) {
  354. 350.  -           expandPoint(point);
  355. 351.  -         }
  356. 352.  -       }
  357. 353.  -     }
  358. 354.  -
  359. 355.  -     map.on('click', (function(point) {
  360. 356.  -       if (!opts.box) {
  361. 357.  -         Places.showProfileBox(opts.uid);
  362. 358.  -       }
  363. 359.  -     }).bind(this));
  364. 360.  -   } else {
  365. 361.  -     CustomMarker = function(latlng, map, src, count, diff) {
  366. 362.  -       this.latlng = latlng;
  367. 363.  -       this.photoSrc = src;
  368. 364.  -       this.photoCount = count;
  369. 365.  -       this.photoDiff = diff;
  370. 366.  -       this.setMap(map);
  371. 367.  -     }
  372. 368.  -
  373. 369.  -     CustomMarker.prototype = new google.maps.OverlayView();
  374. 370.  -
  375. 371.  -     CustomMarker.prototype.draw = function() {
  376. 372.  -       var div = this.photoDiv;
  377. 373.  -       if (!div) {
  378. 374.  -
  379. 375.  -         var div = se(getIconHtml(this.photoSrc, this.photoCount, this.photoDiff, cur.iconLastNum));
  380. 376.  -         this.photoDiv = div;
  381. 377.  -         this.iconNum = cur.iconLastNum++;
  382. 378.  -
  383. 379.  -         google.maps.event.addDomListener(div, 'click', (function(event) {
  384. 380.  -           google.maps.event.trigger(this, 'click');
  385. 381.  -           return cancelEvent(event);
  386. 382.  -         }).bind(this));
  387. 383.  -
  388. 384.  -         var panes = this.getPanes();
  389. 385.  -         panes.overlayImage.appendChild(div);
  390. 386.  -       }
  391. 387.  -
  392. 388.  -       var point = this.getProjection().fromLatLngToDivPixel(this.latlng);
  393. 389.  -       if (point) {
  394. 390.  -         div.style.left = point.x + 'px';
  395. 391.  -         div.style.top = point.y + 'px';
  396. 392.  -       }
  397. 393.  -     };
  398. 394.  -
  399. 395.  -     CustomMarker.prototype.remove = function() {
  400. 396.  -       if (this.photoDiv) {
  401. 397.  -         this.photoDiv.parentNode.removeChild(this.photoDiv);
  402. 398.  -         this.photoDiv = null;
  403. 399.  -       }
  404. 400.  -     };
  405. 401.  -
  406. 402.  -     CustomMarker.prototype.getPosition = function() {
  407. 403.  -      return this.latlng;
  408. 404.  -     };
  409. 405.  -
  410. 406.  -
  411. 407.  -     var mapOpts = {
  412. 408.  -       center: new google.maps.LatLng(opts.lat, opts.lng),
  413. 409.  -       mapTypeId: google.maps.MapTypeId.ROADMAP,
  414. 410.  -       disableDefaultUI: true
  415. 411.  -     }
  416. 412.  -     if (opts.nowheel) {
  417. 413.  -       mapOpts.scrollwheel = false;
  418. 414.  -       mapOpts.disableDoubleClickZoom = true;
  419. 415.  -     }
  420. 416.  -     if (opts.map) {
  421. 417.  -       map = opts.map;
  422. 418.  -     } else {
  423. 419.  -       map = new google.maps.Map(ge(opts.cont), mapOpts);
  424. 420.  -     }
  425. 421.  -     setMapOpts(map);
  426. 422.  -
  427. 423.  -     if (opts.bounds) {
  428. 424.  -       var sw = new google.maps.LatLng(opts.bounds.swlat, opts.bounds.swlng);
  429. 425.  -       var ne = new google.maps.LatLng(opts.bounds.nelat, opts.bounds.nelng);
  430. 426.  -       map.fitBounds(new google.maps.LatLngBounds(sw, ne));
  431. 427.  -     } else {
  432. 428.  -       if (!opts.lat && !opts.lng) {
  433. 429.  -         opts.lat = 30;
  434. 430.  -       }
  435. 431.  -       map.setCenter(new google.maps.LatLng(opts.lat, opts.lng));
  436. 432.  -       map.setZoom(1);
  437. 433.  -     }
  438. 434.  -
  439. 435.  -     if (!opts.nowheel) {
  440. 436.  -       google.maps.event.addListener(map, 'bounds_changed', onBoundsChanged.pbind(false));
  441. 437.  -     }
  442. 438.  -
  443. 439.  -     if (opts.points) {
  444. 440.  -       var len = opts.points.length;
  445. 441.  -       while(len--) {
  446. 442.  -         var point = opts.points[len];
  447. 443.  -         var p = new google.maps.LatLng(point.lat, point.lng);
  448. 444.  -         point.overlay = new CustomMarker(p, point.points ? null : map, point.src, point.count, point.diff);
  449. 445.  -         google.maps.event.addListener(point.overlay, 'click', (pointClick).pbind(point));
  450. 446.  -         if (point.points) {
  451. 447.  -           expandPoint(point);
  452. 448.  -         }
  453. 449.  -       }
  454. 450.  -     }
  455. 451.  -
  456. 452.  -     google.maps.event.addDomListener(map, 'click', (function(point) {
  457. 453.  -       if (!opts.box) {
  458. 454.  -         Places.showProfileBox(opts.uid);
  459. 455.  -       }
  460. 456.  -     }).bind(this));
  461. 457.  -   }
  462. 458.  - },
  463. 459.  -
  464. 460.  - showProfileBox: function(uid) {
  465. 461.  -   showBox('al_places.php', {
  466. 462.  -     act: 'photos_box',
  467. 463.  -     uid: uid
  468. 464.  -   }, {
  469. 465.  -     stat: ['maps.js', 'places.js', 'places.css', 'ui_controls.js', 'ui_controls.css']
  470. 466.  -   });
  471. 467.  -   return false;
  472. 468.  - },
  473. 469.  -
  474. 470.  - setMarker: function(map, point) {
  475. 471.  -   cur.placeMarker = new vkMaps.Marker(point);
  476. 472.  -   cur.placeMarker.mousedown.addHandler(function() {
  477. 473.  -   });
  478. 474.  -   cur.placeMarker.dragend.addHandler(function(type, marker) {
  479. 475.  -     marker.update();
  480. 476.  -     Places.setPlaceStr(marker.location);
  481. 477.  -   });
  482. 478.  -   map.addMarkerWithData(cur.placeMarker, {
  483. 479.  -     draggable: true,
  484. 480.  -     icon: '/images/map/move.png',
  485. 481.  -     icon2x: '/images/map/move_2x.png',
  486. 482.  -     iconSize: [33, 32],
  487. 483.  -     iconAnchor: [16, 32],
  488. 484.  -     infoBubble: ''
  489. 485.  -   });
  490. 486.  - },
  491. 487.  -
  492. 488.  - showMorePhotos: function(uid) {
  493. 489.  -   if (!cur.addPhotosOffset || cur.PlacesPhotosMoreBack) {
  494. 490.  -     return false;
  495. 491.  -   }
  496. 492.  -   var cont = ge('places_photo_more');
  497. 493.  -   cur.PlacesPhotosMoreBack = cont.innerHTML;
  498. 494.  -   ajax.post('al_places.php', {act: 'a_edit_photos', uid: uid, offset: cur.addPhotosOffset}, {
  499. 495.  -     onDone: function(html, offset, showmore) {
  500. 496.  -       cur.addPhotosOffset = offset;
  501. 497.  -       if (!showmore) {
  502. 498.  -         hide('places_photo_more');
  503. 499.  -       }
  504. 500.  -       var elsCont = ge('places_map_add_list');
  505. 501.  -       elsCont.appendChild(cf(html));
  506. 502.  -       cur.PlacesPhotosMoreBack = false;
  507. 503.  -     },
  508. 504.  -     showProgress: function() {
  509. 505.  -       cont.innerHTML = '<img src="/images/upload.gif">';
  510. 506.  -     },
  511. 507.  -     hideProgress: function() {
  512. 508.  -       cont.innerHTML = cur.PlacesPhotosMoreBack;
  513. 509.  -     }
  514. 510.  -   }, {stat: ['upload.js']})
  515. 511.  - },
  516. 512.  -
  517. 513.  - addPhotos: function(obj, uid) {
  518. 514.  -   ajax.post('al_places.php', {act: 'a_edit_photos', uid: uid}, {
  519. 515.  -     onDone: function(html, js, offset) {
  520. 516.  -       hide('places_edit_step_0');
  521. 517.  -       show('places_edit_step_1');
  522. 518.  -       hide('places_edit_step_2');
  523. 519.  -       hide('places_edit_step_3');
  524. 520.  -       hide('place_map_cont');
  525. 521.  -       cur.addPhotosOffset = offset;
  526. 522.  -       cur.editPhotosPlace = true;
  527. 523.  -       cur.placesFixedBottom = false;
  528. 524.  -       var editCont = ge('place_map_edit');
  529. 525.  -       editCont.innerHTML = html;
  530. 526.  -       show(editCont);
  531. 527.  -       hide('place_map_other');
  532. 528.  -
  533. 529.  -       /*var tt = ge('places_photo_hint_cont');
  534. 530.  -       if (tt) {
  535. 531.  -         fadeIn(tt, 100);
  536. 532.  -       } else {
  537. 533.  -         var mapCont = ge('place_map_cont');
  538. 534.  -         var tt = ce('div', {
  539. 535.  -           innerHTML: '<div class="places_photo_hint">'+getLang('places_select_position')+'</div><div id="places_photo_pointer"></div>',
  540. 536.  -           className: 'places_photo_hint_cont',
  541. 537.  -           id: 'places_photo_hint_cont'
  542. 538.  -         });
  543. 539.  -         mapCont.parentNode.insertBefore(tt, mapCont);
  544. 540.  -         var w = getSize(tt)[0];
  545. 541.  -         tt.style.marginLeft = intval((666 - w) / 2) + 'px';
  546. 542.  -         ge('places_photo_pointer').style.marginLeft = intval((w/2) - 10)+ 'px';
  547. 543.  -       }
  548. 544.  -       show('places_photos_save_panel');
  549. 545.  -       Places.setMarker(cur.vkmap.getCenter());*/
  550. 546.  -       cur.onPlaceScroll();
  551. 547.  -       if (js) {
  552. 548.  -         eval('(function() {'+js+'})();')
  553. 549.  -       }
  554. 550.  -     },
  555. 551.  -     showProgress: function() {
  556. 552.  -       lockButton(obj);
  557. 553.  -     },
  558. 554.  -     hideProgress: function() {
  559. 555.  -       unlockButton(obj);
  560. 556.  -     }
  561. 557.  -   })
  562. 558.  - },
  563. 559.  -
  564. 560.  - step2: function() {
  565. 561.  -   hide('places_edit_step_0');
  566. 562.  -   show('places_edit_step_1');
  567. 563.  -   hide('places_edit_step_2');
  568. 564.  -   hide('places_edit_step_3');
  569. 565.  -   hide('place_map_cont');
  570. 566.  -   show('place_map_edit');
  571. 567.  -   hide('place_map_point');
  572. 568.  -   hide('place_map_other');
  573. 569.  -   cur.vkmap.removeMarker(cur.placeMarker);
  574. 570.  - },
  575. 571.  -
  576. 572.  - cancelAdd: function() {
  577. 573.  -   cur.editPhotosPlace = false;
  578. 574.  -   show('places_edit_step_0');
  579. 575.  -   hide('places_edit_step_1');
  580. 576.  -   hide('places_edit_step_2');
  581. 577.  -   hide('places_edit_step_3');
  582. 578.  -   show('place_map_cont');
  583. 579.  -   hide('place_map_edit');
  584. 580.  -   hide('place_map_point');
  585. 581.  -   show('place_map_other');
  586. 582.  -   cur.vkmap.removeMarker(cur.placeMarker);
  587. 583.  - },
  588. 584.  -
  589. 585.  - selectPhoto: function(pids, photoSrc, lat, lng) {
  590. 586.  -   cur.mapPids = pids;
  591. 587.  -   hide('places_edit_step_0');
  592. 588.  -   hide('places_edit_step_1');
  593. 589.  -   show('places_edit_step_2');
  594. 590.  -   hide('places_edit_step_3');
  595. 591.  -   hide('place_map_edit');
  596. 592.  -   show('place_map_point');
  597. 593.  -   var mapChoose = new vkMaps.VKMap('place_map_point_cont', {
  598. 594.  -     provider: 'google',
  599. 595.  -     providerId: 2,
  600. 596.  -     lngcode: cur.vkLngCode,
  601. 597.  -   });
  602. 598.  -   cur.placesChooseMap = mapChoose;
  603. 599.  -   placeholderSetup(ge('place_map_point_search'), {back: true});
  604. 600.  -   var pCont = ge('place_map_point');
  605. 601.  -   var els = geByClass('places_map_preview', pCont);
  606. 602.  -   for (var i in els) {
  607. 603.  -     re(els[i]);
  608. 604.  -   }
  609. 605.  -   pCont.appendChild(ce('div', {
  610. 606.  -     innerHTML: '<div class="places_map_preview_cont"><img src="'+photoSrc+'" class="places_map_preview_img" align="center" /></div>',
  611. 607.  -     className: 'places_map_preview'
  612. 608.  -   }));
  613. 609.  -
  614. 610.  -   mapChoose.addMapTypeControls();
  615. 611.  -   mapChoose.addControls({zoom: 'large', pan: false});
  616. 612.  -   if (!cur.lastSelectLat && !cur.lastSelectLng) {
  617. 613.  -     var lastPos = ls.get('last_map_pos');
  618. 614.  -     if (lastPos) {
  619. 615.  -       cur.lastSelectLat = lastPos[0];
  620. 616.  -       cur.lastSelectLng = lastPos[1];
  621. 617.  -       cur.lastSelectZoom = lastPos[2];
  622. 618.  -     }
  623. 619.  -   }
  624. 620.  -
  625. 621.  -   var loc = cur.vkmap.getCenter();
  626. 622.  -   if (lat || lng) {
  627. 623.  -     var point = new vkMaps.LatLonPoint(lat, lng);
  628. 624.  -     mapChoose.setCenterAndZoom(point, 14);
  629. 625.  -     Places.setMarker(mapChoose, point);
  630. 626.  -     Places.setPlaceStr(point, true);
  631. 627.  -   } else {
  632. 628.  -     var point = new vkMaps.LatLonPoint(cur.lastSelectLat || loc.lat, cur.lastSelectLng || loc.lon);
  633. 629.  -     mapChoose.setCenterAndZoom(point, cur.lastSelectZoom || cur.vkmap.getZoom());
  634. 630.  -   }
  635. 631.  -
  636. 632.  -   mapChoose.click.addHandler((function(eventType, map, place) {
  637. 633.  -     mapChoose.removeMarker(cur.placeMarker);
  638. 634.  -     Places.setMarker(mapChoose, place.location);
  639. 635.  -     Places.setPlaceStr(place.location);
  640. 636.  -
  641. 637.  -       //fadeOut(ge('places_photo_hint_cont'), 200);
  642. 638.  -   }).bind(this));
  643. 639.  - },
  644. 640.  -
  645. 641.  - setPlaceStr: function(loc, noRemember) {
  646. 642.  -   if (!noRemember) {
  647. 643.  -     cur.lastSelectLat = loc.lat;
  648. 644.  -     cur.lastSelectLng = loc.lon;
  649. 645.  -     cur.lastSelectZoom = Math.min(16, cur.placesChooseMap.getZoom());
  650. 646.  -     ls.set('last_map_pos', [cur.lastSelectLat, cur.lastSelectLng, cur.lastSelectZoom]);
  651. 647.  -   }
  652. 648.  -   var geocoder = new vkMaps.Geocoder('google', function(place) {
  653. 649.  -     hide('places_edit_step_0');
  654. 650.  -     hide('places_edit_step_1');
  655. 651.  -     hide('places_edit_step_2');
  656. 652.  -     show('places_edit_step_3');
  657. 653.  -     cur.lastSelectedPlace = place;
  658. 654.  -     var placeInfo = [];
  659. 655.  -
  660. 656.  -     if (place.place) {
  661. 657.  -       placeInfo.push(place.place);
  662. 658.  -     } else if (place.street) {
  663. 659.  -       placeInfo.push(place.street);
  664. 660.  -     } else if (place.region) {
  665. 661.  -       placeInfo.push(place.region);
  666. 662.  -     }
  667. 663.  -     if (place.locality) {
  668. 664.  -       placeInfo.push(place.locality);
  669. 665.  -     } else if (place.country) {
  670. 666.  -       placeInfo.push(place.country);
  671. 667.  -     }
  672. 668.  -     for (var i in placeInfo) {
  673. 669.  -       if (placeInfo[i].length > 26) {
  674. 670.  -         placeInfo[i] = placeInfo[i].substr(0, 24)+'..';
  675. 671.  -       }
  676. 672.  -     }
  677. 673.  -     var str = placeInfo.join(', ');
  678. 674.  -     ge('place_map_edit_add').innerHTML = getLang('places_add_to_point').replace('%s', str);
  679. 675.  -   })
  680. 676.  -   geocoder.geocode({location: new google.maps.LatLng(loc.lat, loc.lon), language: cur.vkLngCode})
  681. 677.  - },
  682. 678.  -
  683. 679.  - searchPhotoPlace: function() {
  684. 680.  -   var str = val(ge('place_map_point_search'));
  685. 681.  -
  686. 682.  -   var geocoder = new vkMaps.Geocoder('google', function(place) {
  687. 683.  -     cur.placesChooseMap.setBounds(place.bounds)
  688. 684.  -     cur.placesChooseMap.removeMarker(cur.placeMarker);
  689. 685.  -     Places.setPlaceStr(place.point);
  690. 686.  -     Places.setMarker(cur.placesChooseMap, place.point);
  691. 687.  -   }, function() {
  692. 688.  -     notaBene('place_map_point_search');
  693. 689.  -   })
  694. 690.  -   geocoder.geocode({address: str, language: cur.vkLngCode})
  695. 691.  - },
  696. 692.  -
  697. 693.  - onEditScroll: function(resize) {
  698. 694.  -   var y = boxLayerWrap.scrollTop;
  699. 695.  -   var panel = ge('places_photos_save_buttons');
  700. 696.  -   if (!panel) return;
  701. 697.  -   var py = getXY(ge('places_photos_save_panel'), true)[1];
  702. 698.  -   if (!cur.boxPhotosBottomSize) {
  703. 699.  -     cur.boxPhotosBottomSize = getSize(panel);
  704. 700.  -   }
  705. 701.  -
  706. 702.  -   var ph = cur.boxPhotosBottomSize[1];
  707. 703.  -
  708. 704.  -   var wndHeight = window.innerHeight || document.documentElement.clientHeight;
  709. 705.  -
  710. 706.  -   if (resize && !cur.placesFixedBottom && wndHeight - ph < py + 20) {
  711. 707.  -     boxLayerWrap.scrollTop += py + 20 - (wndHeight - ph);
  712. 708.  -   } else if (wndHeight - ph < py) {
  713. 709.  -     if (!cur.placesFixedBottom || resize) {
  714. 710.  -       cur.placesFixedBottom = true;
  715. 711.  -       setStyle(panel, {
  716. 712.  -         position: 'fixed',
  717. 713.  -         top: (wndHeight - ph) + 'px'
  718. 714.  -       });
  719. 715.  -       addClass(panel, 'places_panel_fixed');
  720. 716.  -     }
  721. 717.  -   } else {
  722. 718.  -     if (cur.placesFixedBottom || resize) {
  723. 719.  -       cur.placesFixedBottom = false;
  724. 720.  -       setStyle(panel, {
  725. 721.  -         position: 'static',
  726. 722.  -         top: '0px'
  727. 723.  -       });
  728. 724.  -       removeClass(panel, 'places_panel_fixed');
  729. 725.  -     }
  730. 726.  -   }
  731. 727.  -
  732. 728.  -   if (resize && cur.placesFixedBottom) {
  733. 729.  -     setStyle(panel, {left: (getXY(curBox().bodyNode)[0] + 1)+'px'})
  734. 730.  -   }
  735. 731.  - },
  736. 732.  -
  737. 733.  - savePhotos: function(btn, hash) {
  738. 734.  -   var loc = cur.placeMarker.location;
  739. 735.  -   var params = {act: 'save_photos_places', pids: cur.mapPids, lat: loc.lat, lng: loc.lon, hash: hash};
  740. 736.  -   if (cur.lastSelectedPlace) {
  741. 737.  -     var place = cur.lastSelectedPlace;
  742. 738.  -     extend(params, {
  743. 739.  -       geo_country: place.country,
  744. 740.  -       geo_locality: place.locality,
  745. 741.  -       geo_region: place.region,
  746. 742.  -       geo_street: place.street,
  747. 743.  -       geo_place: place.place,
  748. 744.  -       geo_lang: cur.vkLngCode,
  749. 745.  -       geo_code: place.countryCode
  750. 746.  -     });
  751. 747.  -   }
  752. 748.  -   ajax.post('al_places.php', params, {
  753. 749.  -     onDone: function() {
  754. 750.  -       //Places.cancelAdd();
  755. 751.  -       Places.updateBox();
  756. 752.  -     },
  757. 753.  -     showProgress: function() {
  758. 754.  -       lockButton(btn);
  759. 755.  -     },
  760. 756.  -     hideProgress: function() {
  761. 757.  -       unlockButton(btn);
  762. 758.  -     }
  763. 759.  -   })
  764. 760.  - },
  765. 761.  -
  766. 762.  - updateBox: function() {
  767. 763.  -   var box = curBox();
  768. 764.  -   box.hide();
  769. 765.  -   showBox('al_places.php', {
  770. 766.  -     act: 'photos_box',
  771. 767.  -     add_more: '1',
  772. 768.  -     lat: cur.placeBoxOpts.lat,
  773. 769.  -     lng: cur.placeBoxOpts.lng,
  774. 770.  -     diff: cur.placeBoxOpts.diffZone,
  775. 771.  -     uid: cur.placeBoxOpts.uid
  776. 772.  -   });
  777. 773.  - },
  778. 774.  -
  779. 775.  - checkHtml5Uploader: function() {
  780. 776.  -   return (window.XMLHttpRequest || window.XDomainRequest) && (window.FormData || window.FileReader && (window.XMLHttpRequest && XMLHttpRequest.sendAsBinary ||  window.ArrayBuffer && window.Uint8Array && (window.MozBlobBuilder || window.WebKitBlobBuilder || window.BlobBuilder)));
  781. 777.  - },
  782. 778.  -
  783. 779.  - uploadPhotos: function(obj, ev) {
  784. 780.  -   if (ev && (ev.button == 2 || ev.ctrlKey)) {
  785. 781.  -     if (photos.checkHtml5Uploader()) {
  786. 782.  -       obj.href += '&html5=1';
  787. 783.  -     }
  788. 784.  -     return true;
  789. 785.  -   }
  790. 786.  -   if (cur.uplId !== undefined && window.Upload && Upload.checked && Upload.checked[cur.uplId] && Places.checkHtml5Uploader()) {
  791. 787.  -     ge('photos_upload_input').click();
  792. 788.  -     return false;
  793. 789.  -   }
  794. 790.  -   return true;
  795. 791.  - },
  796. 792.  -
  797. 793.  - onPhotoUploadStart: function(info, res) {
  798. 794.  -   var label = ge('places_photo_upload_area_label');
  799. 795.  -   setStyle(label, {background: 'none', paddingLeft: '0px'});
  800. 796.  -   label.innerHTML = '<div id="places_ph_add_progress"><div id="places_add_p_line"><div id="places_add_p_inner"></div></div><div id="places_add_p_str"></div></div>';
  801. 797.  -   if (info.num === undefined) {
  802. 798.  -     info = res;
  803. 799.  -   }
  804. 800.  -   if (info.totalCount > 1) {
  805. 801.  -     ge('places_add_p_str').innerHTML = langNumeric(info.num ? info.num + 1 : 1, cur.lang['photos_add_uploading_num_X']).replace('{count}', info.totalCount);
  806. 802.  -   } else {
  807. 803.  -     ge('places_add_p_str').innerHTML = getLang('photos_add_uploading');
  808. 804.  -   }
  809. 805.  - },
  810. 806.  -
  811. 807.  - onPhotoUploadProgress: function(ind, upl, need) {
  812. 808.  -   var inner = ge('places_add_p_inner');
  813. 809.  -   var w = (upl / need) * 175;
  814. 810.  -   var oldWidth = intval(inner.style.width);
  815. 811.  -   if (ind.totalCount > 1) {
  816. 812.  -     ge('places_add_p_str').innerHTML = langNumeric(ind.num + 1, cur.lang['photos_add_uploading_num_X']).replace('{count}', ind.totalCount);
  817. 813.  -   }
  818. 814.  -   if (w > oldWidth) {
  819. 815.  -     animate(inner, {width: w}, 200);
  820. 816.  -   }
  821. 817.  - },
  822. 818.  -
  823. 819.  - onPhotoUploadComplete: function(info, res) {
  824. 820.  -   var params, i = info.ind !== undefined ? info.ind : info;
  825. 821.  -   try {
  826. 822.  -     params = eval('(' + res + ')');
  827. 823.  -   } catch(e) {
  828. 824.  -     params = q2ajx(res);
  829. 825.  -   }
  830. 826.  -   cur.savedPhotos = cur.savedPhotos || {mid: params.mid, gid: params.gid, aid: params.aid, server: params.server};
  831. 827.  -   cur.savedPhotos.photos = cur.savedPhotos.photos || [];
  832. 828.  -   cur.savedPhotos.photos.push({photo: params.photos, hash: params.hash});
  833. 829.  -   return;
  834. 830.  - },
  835. 831.  -
  836. 832.  - onPhotoUploadCompleteAll: function(info) {
  837. 833.  -   var query = {act: 'done_add', context: 1, from: 'profile_map'}, k = 1;
  838. 834.  -
  839. 835.  -   if (!cur.savedPhotos.photos) {
  840. 836.  -     return;
  841. 837.  -   }
  842. 838.  -   for (var j in (cur.savedPhotos.photos || [])) {
  843. 839.  -     query['photo'+k] = cur.savedPhotos.photos[j].photo;
  844. 840.  -     query['hash'+k] = cur.savedPhotos.photos[j].hash;
  845. 841.  -     k++;
  846. 842.  -   }
  847. 843.  -   delete cur.savedPhotos.photos;
  848. 844.  -   query = extend(query, cur.savedPhotos);
  849. 845.  -   ajax.post('/al_photos.php', query, {
  850. 846.  -     onDone: function(photos, hash, oid, photoPreview) {
  851. 847.  -       Places.selectPhoto(photos, photoPreview);
  852. 848.  -     },
  853. 849.  -     onFail: function(text) {
  854. 850.  -       setTimeout(showFastBox(getLang('global_error'), text).hide, __debugMode ? 30000 : 3000);
  855. 851.  -     }
  856. 852.  -   })
  857. 853.  - },
  858. 854.  -
  859. 855.  - showPlaceTT: function(obj, text) {
  860. 856.  -   showTooltip(obj, {black: 1, text: text, center:1, shift:[0, 4, 0]});
  861. 857.  - },
  862. 858.  -
  863. 859.  - showPhotoPlace: function(lat, lng) {
  864. 860.  -   var map = cur.placeBoxMap;
  865. 861.  -   map.setCenter(new google.maps.LatLng(lat, lng));
  866. 862.  -   map.setZoom(16);
  867. 863.  -   animate(boxLayerWrap, {scrollTop: 0}, 200);
  868. 864.  - }
  869. 865.  -
  870. 866.  - }
  871. 867.  -
  872. 868.  - try{stManager.done('places.js');}catch(e){}
  873. ------
Advertisement
Add Comment
Please, Sign In to add comment