Hormold

VK Change (#1378507503)

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