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