Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- createSubwayMarkers = function (array, sheme) {
- $.each(array, function (index, item) {
- var $marker = $('<div/>'),
- thisId = item.id,
- itemId = 'subway-station_' + thisId,
- // thisPopupClubsIds = wcMapLib.wcWorld.subwayList[item.id].clubList,
- thisPopupClubsIds = wcMapLib.wcWorld.subwayList[item.id] === undefined ? 288 : wcMapLib.wcWorld.subwayList[item.id].clubList,
- items = [],
- theClub,
- theItem;
- //console.log(item.id);
- if(thisPopupClubsIds instanceof Array) {
- for(var newID = 0; newID < thisPopupClubsIds.length; newID++){
- theClub = wcMapLib.wcWorld.clubList[thisPopupClubsIds[newID]];
- theItem = {};
- theItem.name = theClub.name;
- //theItem.desc = theClub.address + '<br/>' + theClub.phone;
- theItem.desc = theClub.address;
- theItem.url = theClub.url;
- theItem.id = theClub.id;
- items.push(theItem);
- }
- } else {
- for(var newID in thisPopupClubsIds) {
- //alert(thisPopupClubsIds);
- if(thisPopupClubsIds.hasOwnProperty(newID)) {
- theClub = wcMapLib.wcWorld.clubList[thisPopupClubsIds[newID]];
- theItem = {};
- theItem.name = theClub.name;
- theItem.desc = theClub.address;
- theItem.url = theClub.url;
- theItem.id = theClub.id;
- theItem.type = theClub.type;
- items.push(theItem);
- }
- }
- }
- var content = createInfoPopupItem(items, true, true, item.type);
- $marker
- .css(item.style)
- .addClass(item.className)
- .html(item.name)
- .append('<i/>')
- .attr('id', itemId)
- .find('i')
- .css(item.markerStyle)
- .append(content);
- // small content length = empty ballon => dont show baloon, new each iteration
- if (content.length < 300) { return true; }
- sheme.append($marker).on('click', '#' + itemId, function () {
- var el = $(this).find('.map-popup'),
- posL = el.width() / 2 - 9;
- //el_i = $(this).find('i');
- sheme.find('.map-popup').addClass('hidden');
- el.removeClass('hidden')
- .css({left: -posL + 'px'});
- });
- $(document).on('click', '.popup_close', function (e) {
- $(this).parents('.map-popup').addClass('hidden');
- });
- });
- };
- initAppendStation = function () {
- $('.scheme-mode-button').addClass('hidden');
- var elcity = $('.current-city').text(),
- elCityBox;
- switch (elcity) {
- case 'Москва' :
- elCityBox = $('#subway-map-moscow');
- $('.scheme-mode-button').removeClass('hidden');
- createSubwayMarkers(moscowSubwayMarkers, elCityBox);
- break;
- case 'Санкт-Петербург' :
- elCityBox = $('#subway-map-spb');
- $('.scheme-mode-button').removeClass('hidden');
- createSubwayMarkers(spbSubwayMarkers, elCityBox);
- break;
- case 'Екатеринбург' :
- elCityBox = $('#subway-map-ekt');
- $('.scheme-mode-button').removeClass('hidden');
- createSubwayMarkers(ektSubwayMarkers, elCityBox);
- break;
- }
- $(document).on('show_metro_map', function () {
- if (elCityBox){
- elCityBox.show();
- $('.map-overlay__input-block').addClass('hidden');
- $('.all-cities-map').addClass('hidden');
- }
- });
- $(document).on('hide_metro_map', function () {
- if (elCityBox){
- elCityBox.hide();
- $('.map-overlay__input-block').removeClass('hidden');
- }
- });
- };
- createInfoPopupItem = function (items, close, link, itemType) {
- var content_open = '<div class="map-popup hidden">' +
- '<div class="map-popup__container">';
- if (close) {
- content_open += '<div class="popup_close"></div>';
- }
- content_open += '<div class="map-popup__content">' +
- '<ul class="map-popup__ul">';
- var content_close = '</ul>' +
- '</div>' +
- '</div>' +
- '<i class="map-popup__bottom-tail"></i>' +
- '</div>',
- content = '';
- for (var index in items) {
- if (items.hasOwnProperty(index)){
- var item = items[index];
- var xcont;
- xcont = '<li><h6>';
- if (link) {
- xcont += '<a href="' + item.url + '"><span>' + item.name + '</span></a>';
- } else {
- xcont += item.name;
- }
- if(itemType == 'vinous') {
- xcont += '<br/><a class="popup__agree-1 bc__howto" data-popup="romanov" href="#">Как вступить в клуб</a>';
- } else {
- xcont += '</h6>' +
- '<p>' + item.desc + '</p>';
- if ($('.buy__card__step').length) {
- xcont += '<div style="margin: 1px 0px 1px 0px; border-top: 1px solid #ccc;"></div>' +
- '<div class="price-row" style="font-family: tornadocyr-regular;font-size:11px;color:#bdbdbd;">' +
- 'Стоимость месяца ' +
- '<span class="price-value">' + $('.bc__table__cost[data-id="' + item.id + '"]').text() + '</span>' +
- '</div>' +
- '<div class="price-row" style="font-family: tornadocyr-regular;font-size:11px;color:#bdbdbd;">' +
- 'Стоимость года ' +
- '<span class="price-value">' + $('.bc__table__ycost[data-id="' + item.id + '"]').text() + '</span>' +
- '</div>' +
- '<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>' +
- }
- xcont += '</li>';
- }
- var tRep = testReplic(item.id);
- if (!tRep) { xcont = ''; }
- //console.log(item.id + ' - ' + tRep + ' - ' + item.name);
- content = content + xcont;
- }
- }
- content = content_open + content + content_close;
- return content;
- };
Advertisement
Add Comment
Please, Sign In to add comment