Hormold

VK Change (#1379086205)

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