Guest User

Untitled

a guest
Jun 5th, 2014
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.54 KB | None | 0 0
  1. createSubwayMarkers = function (array, sheme) {
  2. $.each(array, function (index, item) {
  3. var $marker = $('<div/>'),
  4. thisId = item.id,
  5. itemId = 'subway-station_' + thisId,
  6. // thisPopupClubsIds = wcMapLib.wcWorld.subwayList[item.id].clubList,
  7. thisPopupClubsIds = wcMapLib.wcWorld.subwayList[item.id] === undefined ? 288 : wcMapLib.wcWorld.subwayList[item.id].clubList,
  8. items = [],
  9. theClub,
  10. theItem;
  11.  
  12. //console.log(item.id);
  13.  
  14. if(thisPopupClubsIds instanceof Array) {
  15. for(var newID = 0; newID < thisPopupClubsIds.length; newID++){
  16. theClub = wcMapLib.wcWorld.clubList[thisPopupClubsIds[newID]];
  17. theItem = {};
  18. theItem.name = theClub.name;
  19. //theItem.desc = theClub.address + '<br/>' + theClub.phone;
  20. theItem.desc = theClub.address;
  21. theItem.url = theClub.url;
  22. theItem.id = theClub.id;
  23. items.push(theItem);
  24.  
  25. }
  26.  
  27. } else {
  28.  
  29.  
  30.  
  31. for(var newID in thisPopupClubsIds) {
  32.  
  33. //alert(thisPopupClubsIds);
  34.  
  35. if(thisPopupClubsIds.hasOwnProperty(newID)) {
  36. theClub = wcMapLib.wcWorld.clubList[thisPopupClubsIds[newID]];
  37. theItem = {};
  38. theItem.name = theClub.name;
  39. theItem.desc = theClub.address;
  40. theItem.url = theClub.url;
  41. theItem.id = theClub.id;
  42. theItem.type = theClub.type;
  43. items.push(theItem);
  44.  
  45.  
  46. }
  47. }
  48. }
  49.  
  50.  
  51. var content = createInfoPopupItem(items, true, true, item.type);
  52.  
  53.  
  54. $marker
  55. .css(item.style)
  56. .addClass(item.className)
  57. .html(item.name)
  58. .append('<i/>')
  59. .attr('id', itemId)
  60. .find('i')
  61. .css(item.markerStyle)
  62. .append(content);
  63.  
  64. // small content length = empty ballon => dont show baloon, new each iteration
  65. if (content.length < 300) { return true; }
  66.  
  67. sheme.append($marker).on('click', '#' + itemId, function () {
  68. var el = $(this).find('.map-popup'),
  69. posL = el.width() / 2 - 9;
  70. //el_i = $(this).find('i');
  71.  
  72. sheme.find('.map-popup').addClass('hidden');
  73.  
  74. el.removeClass('hidden')
  75. .css({left: -posL + 'px'});
  76. });
  77.  
  78. $(document).on('click', '.popup_close', function (e) {
  79. $(this).parents('.map-popup').addClass('hidden');
  80. });
  81. });
  82. };
  83.  
  84. initAppendStation = function () {
  85. $('.scheme-mode-button').addClass('hidden');
  86. var elcity = $('.current-city').text(),
  87. elCityBox;
  88.  
  89. switch (elcity) {
  90. case 'Москва' :
  91. elCityBox = $('#subway-map-moscow');
  92. $('.scheme-mode-button').removeClass('hidden');
  93. createSubwayMarkers(moscowSubwayMarkers, elCityBox);
  94.  
  95. break;
  96. case 'Санкт-Петербург' :
  97. elCityBox = $('#subway-map-spb');
  98. $('.scheme-mode-button').removeClass('hidden');
  99. createSubwayMarkers(spbSubwayMarkers, elCityBox);
  100. break;
  101. case 'Екатеринбург' :
  102. elCityBox = $('#subway-map-ekt');
  103. $('.scheme-mode-button').removeClass('hidden');
  104. createSubwayMarkers(ektSubwayMarkers, elCityBox);
  105. break;
  106. }
  107. $(document).on('show_metro_map', function () {
  108. if (elCityBox){
  109. elCityBox.show();
  110. $('.map-overlay__input-block').addClass('hidden');
  111. $('.all-cities-map').addClass('hidden');
  112. }
  113. });
  114. $(document).on('hide_metro_map', function () {
  115. if (elCityBox){
  116. elCityBox.hide();
  117. $('.map-overlay__input-block').removeClass('hidden');
  118. }
  119. });
  120. };
  121.  
  122. createInfoPopupItem = function (items, close, link, itemType) {
  123.  
  124.  
  125.  
  126.  
  127. var content_open = '<div class="map-popup hidden">' +
  128. '<div class="map-popup__container">';
  129. if (close) {
  130. content_open += '<div class="popup_close"></div>';
  131. }
  132. content_open += '<div class="map-popup__content">' +
  133. '<ul class="map-popup__ul">';
  134. var content_close = '</ul>' +
  135. '</div>' +
  136. '</div>' +
  137. '<i class="map-popup__bottom-tail"></i>' +
  138. '</div>',
  139. content = '';
  140.  
  141. for (var index in items) {
  142. if (items.hasOwnProperty(index)){
  143. var item = items[index];
  144.  
  145. var xcont;
  146.  
  147.  
  148.  
  149.  
  150. xcont = '<li><h6>';
  151. if (link) {
  152. xcont += '<a href="' + item.url + '"><span>' + item.name + '</span></a>';
  153. } else {
  154. xcont += item.name;
  155. }
  156.  
  157. if(itemType == 'vinous') {
  158. xcont += '<br/><a class="popup__agree-1 bc__howto" data-popup="romanov" href="#">Как вступить в клуб</a>';
  159. } else {
  160.  
  161. xcont += '</h6>' +
  162. '<p>' + item.desc + '</p>';
  163.  
  164. if ($('.buy__card__step').length) {
  165. xcont += '<div style="margin: 1px 0px 1px 0px; border-top: 1px solid #ccc;"></div>' +
  166. '<div class="price-row" style="font-family: tornadocyr-regular;font-size:11px;color:#bdbdbd;">' +
  167. 'Стоимость месяца ' +
  168. '<span class="price-value">' + $('.bc__table__cost[data-id="' + item.id + '"]').text() + '</span>' +
  169. '</div>' +
  170. '<div class="price-row" style="font-family: tornadocyr-regular;font-size:11px;color:#bdbdbd;">' +
  171. 'Стоимость года ' +
  172. '<span class="price-value">' + $('.bc__table__ycost[data-id="' + item.id + '"]').text() + '</span>' +
  173. '</div>' +
  174. '<div style="text-align:center;margin-top: 20px; font-style: normal; text-shadow: none;"><a class="btn__bc__black" href="choose/?id=' + item.id + '">Купить карту</a></div>' +
  175. }
  176. xcont += '</li>';
  177. }
  178.  
  179. var tRep = testReplic(item.id);
  180. if (!tRep) { xcont = ''; }
  181.  
  182. //console.log(item.id + ' - ' + tRep + ' - ' + item.name);
  183.  
  184. content = content + xcont;
  185.  
  186. }
  187.  
  188. }
  189.  
  190.  
  191.  
  192.  
  193.  
  194. content = content_open + content + content_close;
  195. return content;
  196. };
Advertisement
Add Comment
Please, Sign In to add comment