You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1181 lines
31 KiB
1181 lines
31 KiB
var map;
|
|
|
|
function mapInit() {
|
|
var canvas = document.getElementById('map-canvas');
|
|
var coords = canvas.getAttribute('data-coords');
|
|
var commaPos = coords.indexOf(',');
|
|
var lat = parseFloat(coords.substring(0, commaPos));
|
|
var lng = parseFloat(coords.substring(commaPos + 1, coords.length));
|
|
var myLatlng = new google.maps.LatLng(lat, lng);
|
|
var mapOptions = {
|
|
zoom: 15,
|
|
center: myLatlng,
|
|
scrollwheel: false
|
|
};
|
|
map = new google.maps.Map(canvas, mapOptions);
|
|
|
|
var marker = new google.maps.Marker({
|
|
position: myLatlng,
|
|
map: map
|
|
});
|
|
}
|
|
/* */
|
|
function addError(inputId, msg){
|
|
var $input = $('#reg_form '+ inputId);
|
|
var $error = $("<div>").attr("class", "pwf-msg").append(
|
|
$("<div>").attr("class", "msg-error").append(msg)
|
|
);
|
|
|
|
$input.parent().parent().append($error)
|
|
|
|
}
|
|
|
|
function placeInput(width){
|
|
$('#id_country').val('159').select2({
|
|
placeholder: "Ваша страна",
|
|
width: width
|
|
});
|
|
|
|
$('#id_city').select2({
|
|
placeholder: "Ваш город",
|
|
width: width,
|
|
ajax: {
|
|
|
|
url: "/city/get-city/",
|
|
dataType: "json",
|
|
quietMillis: 200,
|
|
|
|
data: function(term, page, country){
|
|
var country = $('#id_country').val()
|
|
return {term: term,
|
|
page: page,
|
|
country: country};
|
|
},
|
|
|
|
results: function (data) {
|
|
var results = [];
|
|
$.each(data, function(index, item){
|
|
results.push({
|
|
id: item.id,
|
|
text: item.label
|
|
});
|
|
});
|
|
return {results: results};
|
|
}
|
|
},
|
|
initSelection : function(element, callback) {
|
|
var id= $(element).val();
|
|
var text = $(element).attr('data-init-text');
|
|
callback({id: id, text:text});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
!function ($) {
|
|
|
|
var $win = $(window);
|
|
var $html = $('html');
|
|
var $body = $('body');
|
|
var $doc = $(document);
|
|
|
|
|
|
$.widget( "custom.catcomplete", $.ui.autocomplete, {
|
|
_renderMenu: function( ul, items ) {
|
|
var that = this,
|
|
currentCategory = "";
|
|
$.each( items, function( index, item ) {
|
|
if ( item.category != currentCategory ) {
|
|
ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" );
|
|
currentCategory = item.category;
|
|
}
|
|
that._renderItemData( ul, item );
|
|
});
|
|
}
|
|
});
|
|
|
|
/* submiting registration form */
|
|
$(function () {
|
|
|
|
|
|
$('#send_message_form').on('submit', function(event){
|
|
event.preventDefault();
|
|
$this = $(this);
|
|
var formData = $this.serialize();
|
|
var url = $this.attr('action')
|
|
$.post(url, formData, function(data){
|
|
if (data.success){
|
|
$.fancybox.close();
|
|
$this.find('#id_body').val('')
|
|
}
|
|
});
|
|
});
|
|
$('#reply_form').on('submit', function(event){
|
|
event.preventDefault();
|
|
$this = $(this);
|
|
var formData = $this.serialize();
|
|
var reply_message = $('#reply_message').val()
|
|
var url = '/profile/messages/reply/'+reply_message+'/'
|
|
|
|
$.post(url, formData, function(data){
|
|
if (data.success){
|
|
$.fancybox.close();
|
|
$this.find('#id_recipient').val('')
|
|
$this.find('#id_body').val('')
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
$('.visit, .unvisit').on('click', function(event){
|
|
event.preventDefault();
|
|
var $this = $(this);
|
|
var url = $(this).attr('href');
|
|
$.get(url, function(data){
|
|
if (data.not_authorized){
|
|
$.fancybox.open('#pw-login');
|
|
}
|
|
else{
|
|
if(data.success){
|
|
if(data.in){
|
|
if($this.hasClass('visit')){
|
|
$this.hide();
|
|
$this.siblings('.unvisit').show()
|
|
}
|
|
}
|
|
else{
|
|
if($this.hasClass('unvisit')){
|
|
$this.hide();
|
|
$this.siblings('.visit').show()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
|
|
/*
|
|
$('#reg_form').on('submit', function(event){
|
|
event.preventDefault();
|
|
var formData = $(this).serialize();
|
|
var url = '/register/';
|
|
console.log(url);
|
|
|
|
|
|
$.post(url, formData, function(data){
|
|
if(data.success){
|
|
//register success
|
|
|
|
// remove input values
|
|
$('#reg_form input').each(function(i){
|
|
$(this).val("");
|
|
});
|
|
// close popup
|
|
$.fancybox.open('#pw-reg-complete');
|
|
//$.fancybox.close();
|
|
|
|
}
|
|
else{
|
|
console.log(data);
|
|
// hide help messages
|
|
$("#reg_form .msg-help:visible").hide();
|
|
// delete previous errors
|
|
$("#reg_form .msg-error").parent().remove();
|
|
|
|
// generate new errors
|
|
var form_inputs = ['first_name', 'last_name', 'email', 'password1', 'password2']
|
|
for(var i= 0; i < form_inputs.length; i++){
|
|
if(form_inputs[i] in data){
|
|
var input_id = '#id_'+form_inputs[i];
|
|
addError(input_id, data[form_inputs[i]])
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
});
|
|
*/
|
|
/* submiting change password form */
|
|
$('#paswd_change').on('submit', function(event){
|
|
event.preventDefault();
|
|
var formData = $(this).serialize();
|
|
var url = '/profile/change-password/';
|
|
var $form = $(this);
|
|
$.post(url, formData, function(data){
|
|
if (data.success){
|
|
$('#paswd_change .mf-success').fadeIn(300);
|
|
setTimeout(function(){
|
|
$('#paswd_change .mf-success').fadeOut(300);
|
|
}, 3000);
|
|
$form.find('#id_old password').val('')
|
|
|
|
}
|
|
else{
|
|
// remove previous error
|
|
$('#paswd_change .mf-error').parent().remove();
|
|
// add new error
|
|
var $element = $("<div>").attr("class", "mf-line").append(
|
|
$("<div>").attr("class", "mf-error").append(data.errors[0]))
|
|
$form.find('.mf-buttons-line').before($element);
|
|
}
|
|
});
|
|
});
|
|
$('.reg').on('click', function(event){
|
|
event.preventDefault();
|
|
$('.register').click();
|
|
});
|
|
|
|
|
|
/* *******************************************
|
|
* Нестандартное оформление для поля select
|
|
* Изменено 24.04.2014
|
|
* */
|
|
$.fn.customSelect = function () {
|
|
return $(this).each(function() {
|
|
|
|
var $this = $(this);
|
|
var $options = $this.children('option');
|
|
var numberOfOptions = $this.children('option').length;
|
|
var $selected = $(":selected", $this);
|
|
|
|
$this.addClass('s-hidden');
|
|
|
|
$this.wrap('<div class="custom-select"></div>');
|
|
$this.after('<div class="custom-select-wrap"><div class="custom-select-text"></div></div>');
|
|
|
|
var $styledSelect = $this.next('div.custom-select-wrap');
|
|
var $styledSelectText = $styledSelect.children('.custom-select-text');
|
|
var soText = $selected.length != 0 ? $selected.text() : $this.children('option').eq(0).text();
|
|
|
|
$styledSelectText.text(soText);
|
|
|
|
if ( $options.index($selected) == 0 && (!$this.children('option').eq(0).val() || !$this.children('option').eq(0).attr('value')) ) {
|
|
$styledSelectText.addClass('placeholder');
|
|
}
|
|
|
|
var $menu = $('<div class="cs-menu-wrap options"><div class="cs-scroll-container"><div class="scroll-content clearfix"></div></div></div>').insertAfter($styledSelect);
|
|
var $optionsWrap = $menu.find('.scroll-content');
|
|
|
|
var $list = $('<ul />').appendTo($optionsWrap);
|
|
|
|
for (var i = 0; i < numberOfOptions; i++) {
|
|
var oText = ($this.children('option').eq(i).text() != '') ? $this.children('option').eq(i).html() : ' ';
|
|
$('<li />', {
|
|
html: oText,
|
|
'data-value': $this.children('option').eq(i).val()
|
|
}).appendTo($list);
|
|
}
|
|
|
|
var $listItems = $list.children('li');
|
|
|
|
$styledSelect.on('click', function(e) {
|
|
e.stopPropagation();
|
|
$('div.custom-select-wrap.active').not(this).each(function() {
|
|
$(this).removeClass('active').next('.options').hide();
|
|
});
|
|
if (!$this.prop('disabled')) {
|
|
$(this).toggleClass('active').next('.options').toggle();
|
|
}
|
|
});
|
|
|
|
$listItems.on('click', function(e) {
|
|
var $el = $(this);
|
|
e.stopPropagation();
|
|
$styledSelectText.text($el.text());
|
|
$styledSelect.removeClass('active');
|
|
$this.val($el.data('value'));
|
|
if ( $el.index() == 0 && (!$this.children('option').eq(0).val() || !$this.children('option').eq(0).attr('value')) ) {
|
|
$styledSelectText.addClass('placeholder');
|
|
} else {
|
|
$styledSelectText.removeClass('placeholder');
|
|
}
|
|
$menu.hide();
|
|
});
|
|
|
|
if ($.fn.mCustomScrollbar) {
|
|
var customSelectScrollOptions = {
|
|
scrollInertia: 200,
|
|
contentTouchScroll: true,
|
|
scrollButtons: {
|
|
enable: false
|
|
},
|
|
advanced:{
|
|
autoScrollOnFocus:false,
|
|
updateOnContentResize: true
|
|
}
|
|
};
|
|
|
|
var $scrollContainer = $menu.find('div.cs-scroll-container');
|
|
$scrollContainer.mCustomScrollbar(customSelectScrollOptions);
|
|
}
|
|
|
|
$(document).on('click', function() {
|
|
$styledSelect.removeClass('active');
|
|
$menu.hide();
|
|
});
|
|
|
|
$this.on('change', function () {
|
|
var $cThis = $(this);
|
|
var selectedIndex = $cThis.prop('selectedIndex');
|
|
var Text = $cThis.children('option').eq(selectedIndex).text();
|
|
$styledSelectText.text(Text);
|
|
if ( selectedIndex == 0 && (!$this.children('option').eq(0).val() || !$this.children('option').eq(0).attr('value')) ) {
|
|
$styledSelectText.addClass('placeholder');
|
|
} else {
|
|
$styledSelectText.removeClass('placeholder');
|
|
}
|
|
});
|
|
|
|
});
|
|
};
|
|
$("select:not([multiple])").each(function () {
|
|
var $el = $(this);
|
|
if (!$el.hasClass('select2')) {
|
|
$el.customSelect();
|
|
}
|
|
});
|
|
|
|
|
|
|
|
/* Обработка autocomplete в полях поиска
|
|
* используется jQuery UI Autocomplete
|
|
* */
|
|
/* Галереи-слайдеры на главной
|
|
* использован плагин Swiper
|
|
* http://www.idangero.us/sliders/swiper/api.php
|
|
* */
|
|
$('#mp-recent-expo').each(function () {
|
|
var $reContainer = $(this);
|
|
var $reSwipeWrap = $reContainer.children('ul');
|
|
var $reSwipeItems = $reSwipeWrap.children('li');
|
|
var $reControls = $reContainer.children('div.re-controls');
|
|
|
|
if ($reSwipeItems.length > 1) {
|
|
$reControls.addClass('enabled');
|
|
}
|
|
});
|
|
|
|
$('#mp-photo-gallery').each(function () {
|
|
var $reContainer = $(this);
|
|
var $reSwipeWrap = $reContainer.children('ul');
|
|
var $reSwipeItems = $reSwipeWrap.children('li');
|
|
var $reControls = $reContainer.children('div.re-controls');
|
|
var $recPrev = $reControls.children('a.prev');
|
|
var $recNext = $reControls.children('a.next');
|
|
|
|
if ($reSwipeItems.length > 1) {
|
|
$reControls.addClass('enabled');
|
|
var $reSwiper = $reContainer.swiper({
|
|
speed: 500,
|
|
mode:'horizontal',
|
|
loop: false,
|
|
simulateTouch: false,
|
|
onInit: function (swiper) {
|
|
$recPrev.addClass('disabled');
|
|
},
|
|
onSlideChangeStart: function (swiper) {
|
|
var $descrs = $reSwipeItems.find('div.pgi-descr');
|
|
$descrs.animate({
|
|
height: 'hide',
|
|
opacity: 'hide'
|
|
}, 500);
|
|
if (swiper.activeIndex == 0) {
|
|
if (!$recPrev.hasClass('disabled')) {
|
|
$recPrev.addClass('disabled');
|
|
}
|
|
if ($recNext.hasClass('disabled')) {
|
|
$recNext.removeClass('disabled');
|
|
}
|
|
} else if (swiper.activeIndex == swiper.slides.length-1) {
|
|
if (!$recNext.hasClass('disabled')) {
|
|
$recNext.addClass('disabled');
|
|
}
|
|
if ($recPrev.hasClass('disabled')) {
|
|
$recPrev.removeClass('disabled');
|
|
}
|
|
} else {
|
|
if ($recPrev.hasClass('disabled')) {
|
|
$recPrev.removeClass('disabled');
|
|
}
|
|
if ($recNext.hasClass('disabled')) {
|
|
$recNext.removeClass('disabled');
|
|
}
|
|
}
|
|
},
|
|
onSlideChangeEnd: function (swiper) {
|
|
var $descrs = $reSwipeItems.find('div.pgi-descr');
|
|
$descrs.eq(swiper.activeIndex).slideDown(250);
|
|
}
|
|
});
|
|
|
|
$recPrev.on('click', function () {
|
|
if (!$(this).hasClass('disabled')) {
|
|
$reSwiper.swipePrev();
|
|
}
|
|
return false;
|
|
});
|
|
$recNext.on('click', function () {
|
|
if (!$(this).hasClass('disabled')) {
|
|
$reSwiper.swipeNext();
|
|
}
|
|
return false;
|
|
});
|
|
}
|
|
});
|
|
|
|
$('#ps-photo-gallery').each(function () {
|
|
var $reContainer = $(this);
|
|
var $reSwipeWrap = $reContainer.children('ul');
|
|
var $reSwipeItems = $reSwipeWrap.children('li');
|
|
var $reControls = $reContainer.children('div.re-controls');
|
|
var $recPrev = $reControls.children('a.prev');
|
|
var $recNext = $reControls.children('a.next');
|
|
|
|
if ($reSwipeItems.length > 1) {
|
|
$reControls.addClass('enabled');
|
|
$reSwipeItems.css({
|
|
display: 'block'
|
|
});
|
|
var $reSwiper = $reContainer.swiper({
|
|
speed: 500,
|
|
mode:'horizontal',
|
|
calculateHeight: true,
|
|
loop: false,
|
|
simulateTouch: false,
|
|
onInit: function (swiper) {
|
|
$recPrev.addClass('disabled');
|
|
},
|
|
onSlideChangeStart: function (swiper) {
|
|
if (swiper.activeIndex == 0) {
|
|
if (!$recPrev.hasClass('disabled')) {
|
|
$recPrev.addClass('disabled');
|
|
}
|
|
if ($recNext.hasClass('disabled')) {
|
|
$recNext.removeClass('disabled');
|
|
}
|
|
} else if (swiper.activeIndex == swiper.slides.length-1) {
|
|
if (!$recNext.hasClass('disabled')) {
|
|
$recNext.addClass('disabled');
|
|
}
|
|
if ($recPrev.hasClass('disabled')) {
|
|
$recPrev.removeClass('disabled');
|
|
}
|
|
} else {
|
|
if ($recPrev.hasClass('disabled')) {
|
|
$recPrev.removeClass('disabled');
|
|
}
|
|
if ($recNext.hasClass('disabled')) {
|
|
$recNext.removeClass('disabled');
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
$recPrev.on('click', function () {
|
|
if (!$(this).hasClass('disabled')) {
|
|
$reSwiper.swipePrev();
|
|
}
|
|
return false;
|
|
});
|
|
$recNext.on('click', function () {
|
|
if (!$(this).hasClass('disabled')) {
|
|
$reSwiper.swipeNext();
|
|
}
|
|
return false;
|
|
});
|
|
}
|
|
|
|
});
|
|
|
|
$('#s-slide-gallery').each(function () {
|
|
var $reContainer = $(this);
|
|
var $reSwipeWrap = $reContainer.children('ul');
|
|
var $reSwipeItems = $reSwipeWrap.children('li');
|
|
var $reControls = $reContainer.children('div.re-controls');
|
|
var $recPrev = $reControls.children('a.prev');
|
|
var $recNext = $reControls.children('a.next');
|
|
|
|
if ($reSwipeItems.length > 4) {
|
|
$reControls.addClass('enabled');
|
|
$reSwipeItems.css({
|
|
display: 'block'
|
|
});
|
|
|
|
$win.on('resize', function () {
|
|
$reContainer.height($reSwipeItems.eq(0).height());
|
|
}).trigger('resize');
|
|
|
|
var $reSwiper = $reContainer.swiper({
|
|
slidesPerView: 4,
|
|
slidesPerGroup: 4,
|
|
speed: 500,
|
|
mode:'horizontal',
|
|
calculateHeight: true,
|
|
loop: false,
|
|
simulateTouch: false,
|
|
onInit: function (swiper) {
|
|
$recPrev.addClass('disabled');
|
|
},
|
|
onSlideChangeStart: function (swiper) {
|
|
if (swiper.activeIndex == 0) {
|
|
if (!$recPrev.hasClass('disabled')) {
|
|
$recPrev.addClass('disabled');
|
|
}
|
|
if ($recNext.hasClass('disabled')) {
|
|
$recNext.removeClass('disabled');
|
|
}
|
|
} else if (swiper.activeIndex == swiper.slides.length-4) {
|
|
if (!$recNext.hasClass('disabled')) {
|
|
$recNext.addClass('disabled');
|
|
}
|
|
if ($recPrev.hasClass('disabled')) {
|
|
$recPrev.removeClass('disabled');
|
|
}
|
|
} else {
|
|
if ($recPrev.hasClass('disabled')) {
|
|
$recPrev.removeClass('disabled');
|
|
}
|
|
if ($recNext.hasClass('disabled')) {
|
|
$recNext.removeClass('disabled');
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
$recPrev.on('click', function () {
|
|
if (!$(this).hasClass('disabled')) {
|
|
$reSwiper.swipePrev();
|
|
}
|
|
return false;
|
|
});
|
|
$recNext.on('click', function () {
|
|
if (!$(this).hasClass('disabled')) {
|
|
$reSwiper.swipeNext();
|
|
}
|
|
return false;
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
$('.sli-slides').each(function () {
|
|
var $reContainer = $(this);
|
|
var $reSwipeWrap = $reContainer.children('ul');
|
|
var $reSwipeItems = $reSwipeWrap.children('li');
|
|
var $reControls = $reContainer.children('div.re-controls');
|
|
var $recPrev = $reControls.children('a.prev');
|
|
var $recNext = $reControls.children('a.next');
|
|
|
|
if ($reSwipeItems.length > 4) {
|
|
$reControls.addClass('enabled');
|
|
$reSwipeItems.css({
|
|
display: 'block'
|
|
});
|
|
|
|
$win.on('resize', function () {
|
|
$reContainer.css({
|
|
height: $reSwipeItems.eq(0).height()
|
|
});
|
|
}).trigger('resize');
|
|
|
|
var $reSwiper = $reContainer.swiper({
|
|
slidesPerView: 4,
|
|
slidesPerGroup: 4,
|
|
calculateHeight: true,
|
|
speed: 500,
|
|
mode:'horizontal',
|
|
loop: false,
|
|
simulateTouch: false,
|
|
onInit: function (swiper) {
|
|
$recPrev.addClass('disabled');
|
|
},
|
|
onSlideChangeStart: function (swiper) {
|
|
if (swiper.activeIndex == 0) {
|
|
if (!$recPrev.hasClass('disabled')) {
|
|
$recPrev.addClass('disabled');
|
|
}
|
|
if ($recNext.hasClass('disabled')) {
|
|
$recNext.removeClass('disabled');
|
|
}
|
|
} else if (swiper.activeIndex == swiper.slides.length-4) {
|
|
if (!$recNext.hasClass('disabled')) {
|
|
$recNext.addClass('disabled');
|
|
}
|
|
if ($recPrev.hasClass('disabled')) {
|
|
$recPrev.removeClass('disabled');
|
|
}
|
|
} else {
|
|
if ($recPrev.hasClass('disabled')) {
|
|
$recPrev.removeClass('disabled');
|
|
}
|
|
if ($recNext.hasClass('disabled')) {
|
|
$recNext.removeClass('disabled');
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
$recPrev.on('click', function () {
|
|
if (!$(this).hasClass('disabled')) {
|
|
$reSwiper.swipePrev();
|
|
}
|
|
return false;
|
|
});
|
|
$recNext.on('click', function () {
|
|
if (!$(this).hasClass('disabled')) {
|
|
$reSwiper.swipeNext();
|
|
}
|
|
return false;
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
/* Открытие popup диалогов */
|
|
var fbPopupOptions = {
|
|
padding: 0,
|
|
fitToView: false
|
|
};
|
|
|
|
$('a.pw-open').fancybox(fbPopupOptions);
|
|
|
|
/* Обработка placeholder для старых браузеров */
|
|
$('input[placeholder], textarea[placeholder]').placeholder();
|
|
|
|
/* показ сообщений помощи в полях диалогов*/
|
|
$doc.on('focus', 'form.pw-form input[type="text"], form.pw-form input[type="password"]', function (event) {
|
|
var $input = $(this);
|
|
var $fLine = $input.closest(".pwf-line");
|
|
var $help = $fLine.find('div.msg-help');
|
|
var $error = $fLine.find('div.msg-error');
|
|
var $error2 = $(this).parent().parent().parent().find('.mf-error');
|
|
$error.parent().remove();
|
|
$error2.parent().remove();
|
|
|
|
if ($help.is(':hidden')) {
|
|
$help.fadeIn(300);
|
|
}
|
|
});
|
|
|
|
$doc.on('blur', 'form.pw-form input[type="text"], form.pw-form input[type="password"]', function (event) {
|
|
var $input = $(this);
|
|
var $fLine = $input.closest(".pwf-line");
|
|
var $help = $fLine.find('div.msg-help');
|
|
if ($help.is(':visible') && !$fLine.hasClass('has_error')) {
|
|
$help.fadeOut(300);
|
|
}
|
|
});
|
|
|
|
|
|
/* Custom scroll
|
|
* использован плагин malihu-custom-scrollbar-plugin
|
|
* http://manos.malihu.gr/jquery-custom-content-scroller/
|
|
* */
|
|
var customScrollOptions = {
|
|
scrollInertia: 200,
|
|
contentTouchScroll: true,
|
|
scrollButtons: {
|
|
enable: false
|
|
},
|
|
advanced:{
|
|
updateOnContentResize: true
|
|
}
|
|
};
|
|
|
|
|
|
$('div.scroll-container').each(function () {
|
|
var $scrollContainer = $(this);
|
|
$scrollContainer.mCustomScrollbar(customScrollOptions);
|
|
});
|
|
|
|
/* Открыть диалог подписки на нужной вкладке */
|
|
$('#subscribe-sm').each(function () {
|
|
var $container = $(this);
|
|
var $links = $container.find('a');
|
|
|
|
$links.on('click', function () {
|
|
var $link = $(this);
|
|
var index = $links.index(this);
|
|
var popupSubscribe = $('#pw-subscribe');
|
|
|
|
$.fancybox(popupSubscribe, fbPopupOptions);
|
|
var $tabs = popupSubscribe.find('ul.tabs > li');
|
|
$tabs.eq(index).trigger('click');
|
|
return false;
|
|
});
|
|
});
|
|
|
|
/* Обработка поведения вкладок */
|
|
$("ul.tabs > li").on('click', function () {
|
|
var $curTab = $(this);
|
|
var $parentUl = $curTab.closest('ul');
|
|
var index = $parentUl.children('li').index(this);
|
|
var $contentUl = $parentUl.siblings('.tabs-content');
|
|
var $link = $curTab.find("a");
|
|
var $popupSubscr = $curTab.closest('#pw-subscribe');
|
|
|
|
if (!$curTab.hasClass('active')) {
|
|
if ($popupSubscr.length) {
|
|
$contentUl = $popupSubscr.find('.tabs-content');
|
|
}
|
|
var $activeTab = $parentUl.children('li.active');
|
|
var $activeTContent = $contentUl.find('li.active');
|
|
var $currentTContent = $contentUl.children('li').eq(index);
|
|
|
|
$activeTab.removeClass("active");
|
|
$activeTContent.removeClass("active");
|
|
$curTab.addClass("active");
|
|
$currentTContent.addClass("active");
|
|
}
|
|
|
|
$link.blur();
|
|
closeSelectBox();
|
|
return false;
|
|
});
|
|
|
|
/* Показ подписей картинок в деталях фото галерей */
|
|
$('#cli-pg').each(function () {
|
|
var $wrap = $(this);
|
|
var $link = $wrap.find('a');
|
|
$link.on({
|
|
mouseenter: function () {
|
|
var $el = $(this);
|
|
var $title = $el.find('.pg-title');
|
|
|
|
$title
|
|
.stop(true, true)
|
|
.slideDown(300, function () {
|
|
$title.css({
|
|
display: 'block'
|
|
});
|
|
});
|
|
},
|
|
mouseleave: function () {
|
|
var $el = $(this);
|
|
var $title = $el.find('.pg-title');
|
|
|
|
$title
|
|
.stop(true, true)
|
|
.slideUp(300);
|
|
}
|
|
});
|
|
});
|
|
|
|
$('#map-canvas').each(function () {
|
|
var $mapCanvas = $(this);
|
|
if(!$mapCanvas.is(':hidden')) {
|
|
google.maps.event.addDomListener(window, 'load', mapInit);
|
|
$mapCanvas.data('init', true);
|
|
}
|
|
});
|
|
|
|
$('a.toggle-map').on({
|
|
click: function () {
|
|
var $tLink = $(this);
|
|
var $tContainer = $tLink.closest('.i-address');
|
|
var $mapWrap = $tContainer.children('.i-map');
|
|
var $mapCanvas = $('#map-canvas');
|
|
var $hlink = $tContainer.find('header a.toggle-map');
|
|
|
|
if ($mapWrap.is(':hidden')) {
|
|
$mapWrap
|
|
.stop(true, true)
|
|
.animate({
|
|
opacity: 'show',
|
|
height: 'show'
|
|
}, 300, function () {
|
|
if(!$mapCanvas.data('init')) {
|
|
mapInit();
|
|
$mapCanvas.data('init', true);
|
|
}
|
|
$tContainer.addClass('map-opened');
|
|
});
|
|
} else {
|
|
$mapWrap
|
|
.stop(true, true)
|
|
.animate({
|
|
opacity: 'hide',
|
|
height: 'hide'
|
|
}, 300, function () {
|
|
$tContainer.removeClass('map-opened');
|
|
});
|
|
}
|
|
return false;
|
|
}
|
|
});
|
|
|
|
$('ul.messages-list').each(function () {
|
|
var $mList = $(this);
|
|
var $mItems = $mList.children('li');
|
|
|
|
$mItems.on({
|
|
mouseenter: function () {
|
|
var $item = $(this);
|
|
var $mButtons = $item.find('div.mi-buttons');
|
|
|
|
$mButtons
|
|
.stop(true, true)
|
|
.animate({
|
|
opacity: 'show',
|
|
height: 'show'
|
|
}, 250);
|
|
},
|
|
mouseleave: function () {
|
|
var $item = $(this);
|
|
var $mButtons = $item.find('div.mi-buttons');
|
|
|
|
$mButtons
|
|
.stop(true, true)
|
|
.animate({
|
|
opacity: 'hide',
|
|
height: 'hide'
|
|
}, 250);
|
|
}
|
|
});
|
|
});
|
|
|
|
$('.set-sect > header').on('click', function () {
|
|
var $trigger = $(this);
|
|
var $container = $trigger.closest('.set-sect');
|
|
var $fBody = $container.children('div.set-sect-body');
|
|
|
|
if ($fBody.is(':visible')) {
|
|
$fBody
|
|
.stop(true, true)
|
|
.animate({
|
|
height: 'hide',
|
|
opacity: 'hide'
|
|
}, 300, function () {
|
|
$container.addClass('closed')
|
|
});
|
|
} else {
|
|
$fBody
|
|
.stop(true, true)
|
|
.animate({
|
|
height: 'show',
|
|
opacity: 'show'
|
|
}, 300, function () {
|
|
$container.removeClass('closed')
|
|
});
|
|
}
|
|
});
|
|
|
|
|
|
$('input[type="checkbox"].annoncesFlag').each(function () {
|
|
var $check = $(this);
|
|
|
|
$check.on('change', function () {
|
|
var $aInputsWrap = $check.closest('div.mf-announces').children('div.mf-announces-body');
|
|
var $inputs = $aInputsWrap.find('input, select, textarea');
|
|
var $selectBox = $aInputsWrap.find('div.c-select-box');
|
|
|
|
if ($check.prop('checked')) {
|
|
$aInputsWrap.removeClass('disabled');
|
|
$selectBox.removeClass('disabled');
|
|
$inputs.prop('disabled', false);
|
|
} else {
|
|
$aInputsWrap.addClass('disabled');
|
|
$selectBox.addClass('disabled');
|
|
$inputs.prop('disabled', true);
|
|
}
|
|
}).trigger('change');
|
|
});
|
|
$('a.icb-edit-profile').on('click', function () {
|
|
var $editBtn = $(this);
|
|
var $exitBtn = $editBtn.next('a.icb-exit-edit');
|
|
var $editable = $('div.p-editable');
|
|
|
|
$editBtn.css({
|
|
display: 'none'
|
|
});
|
|
$exitBtn.css({
|
|
display: 'inline-block'
|
|
});
|
|
$editable.addClass('pe-active');
|
|
|
|
return false;
|
|
});
|
|
|
|
$('a.icb-exit-edit').on('click', function () {
|
|
var $exitBtn = $(this);
|
|
var $editBtn = $exitBtn.prev('a.icb-edit-profile');
|
|
var $editable = $('div.p-editable');
|
|
|
|
$editBtn.css({
|
|
display: 'inline-block'
|
|
});
|
|
$exitBtn.css({
|
|
display: 'none'
|
|
});
|
|
$editable.removeClass('pe-active');
|
|
|
|
return false;
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/* Временная функция для указания файла */
|
|
$('input[type="file"]').each(function () {
|
|
var $iFile = $(this);
|
|
var $ifContainer = $iFile.closest('.input-file');
|
|
var $inpText = $ifContainer.children('.file-text');
|
|
|
|
if ($iFile.val() != "") {
|
|
$inpText.text($iFile.val());
|
|
$inpText.removeClass('placeholder');
|
|
} else {
|
|
$inpText.text($inpText.data('placeholder'));
|
|
$inpText.addClass('placeholder');
|
|
}
|
|
|
|
$iFile.on({
|
|
change: function () {
|
|
if ($iFile.val() != "") {
|
|
$inpText.text($iFile.val());
|
|
$inpText.removeClass('placeholder');
|
|
} else {
|
|
$inpText.text($inpText.data('placeholder'));
|
|
$inpText.addClass('placeholder');
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
|
|
/* Добавление секций "Статистика за" на нажатие кнопки "добавить данные за другой период" */
|
|
$('form.af-statistic div.mf-stat').each(function () {
|
|
var $statWrap = $(this);
|
|
var $addButtonWrap = $statWrap.children('.mf-stat-add-button');
|
|
var $addButton = $addButtonWrap.find('a.icon-add');
|
|
|
|
$addButton.on('click', function () {
|
|
var $statItem = $statWrap.children('.mf-stat-item');
|
|
var numItems = $statItem.length;
|
|
var numYears = $statItem.eq(0).find('select').eq(0).find('option').length-1;
|
|
|
|
var $cloneItem = $statItem.eq(0).clone();
|
|
var $selects = $cloneItem.find('select');
|
|
var $inputs = $cloneItem.find('input');
|
|
|
|
$inputs.val('');
|
|
$selects.each(function () {
|
|
var $el = $(this);
|
|
var $cWrap = $el.closest('.custom-select');
|
|
var $cloneSel = $el.clone();
|
|
$cloneSel.insertAfter($cWrap);
|
|
$cloneSel.customSelect();
|
|
$cWrap.remove();
|
|
});
|
|
|
|
$cloneItem.insertBefore($addButtonWrap);
|
|
|
|
if (numItems == numYears - 1){
|
|
$addButtonWrap.hide();
|
|
}
|
|
return false;
|
|
})
|
|
});
|
|
|
|
|
|
/*
|
|
* Управление расписанием проведения выставки
|
|
* */
|
|
|
|
/* Пeреключение между общим временем для всех дней и уникальным для каждого дня */
|
|
$('input[type="checkbox"].w-time-switcher').each(function () {
|
|
var $switch = $(this);
|
|
var $wTimeContainer = $switch.closest('.mf-field');
|
|
|
|
function checkSwitch () {
|
|
var $tLines = $wTimeContainer.find('div.w-time');
|
|
var $firstTimeLine = $tLines.eq(0);
|
|
var $ftlSelects = $firstTimeLine.find('select');
|
|
|
|
$tLines.each(function (index) {
|
|
var $timeLine = $(this);
|
|
if (index != 0) {
|
|
var $selects = $timeLine.find('select');
|
|
|
|
for (var i = 1; i < $selects.length; i++ ) {
|
|
$selects.eq(i).prop('selectedIndex', $ftlSelects.eq(i).prop('selectedIndex')).trigger('change');
|
|
}
|
|
}
|
|
});
|
|
|
|
if ($switch.prop('checked')) {
|
|
$tLines.removeClass('show');
|
|
} else {
|
|
$tLines.addClass('show');
|
|
}
|
|
}
|
|
|
|
checkSwitch();
|
|
$switch.on('change', checkSwitch);
|
|
});
|
|
|
|
function getDateStr(date) {
|
|
return (date.getDate() < 10 ? '0' : '') + date.getDate() + '.' + (date.getMonth() < 9 ? '0' : '') + (date.getMonth() + 1) + '.' + date.getFullYear();
|
|
}
|
|
|
|
/* Построение сетки расписания в зависимости от выбранного диапазона дат */
|
|
$('#dates-range').each(function () {
|
|
var $dRange = $(this);
|
|
var $dateFrom = $dRange.find('input.dateFrom');
|
|
var $dateTo = $dRange.find('input.dateTo');
|
|
var startDay = new Date();
|
|
var endDay = new Date();
|
|
var $wtSchedule = $('#work-time');
|
|
|
|
function numScheduleDays() {
|
|
return (endDay - startDay)/(1000*60*60*24) + 1;
|
|
}
|
|
|
|
function drawSchedule() {
|
|
var $timeLines = $wtSchedule.children('.w-time');
|
|
var $timeLine = $timeLines.eq(0);
|
|
var $datesSelect = $timeLine.find('select').eq(0);
|
|
var $switch = $timeLine.find('input[type="checkbox"].w-time-switcher');
|
|
|
|
startDay = $dateFrom.datepicker('getDate') ? $dateFrom.datepicker('getDate') : new Date();
|
|
endDay = $dateTo.datepicker('getDate') ? $dateTo.datepicker('getDate') : new Date();
|
|
var numDays = numScheduleDays();
|
|
|
|
var $selects = $timeLine.find('select');
|
|
$timeLines.filter(':not(:first)').remove();
|
|
|
|
$datesSelect.each(function () {
|
|
var date = startDay;
|
|
var $select = $(this);
|
|
var $cWrap = $select.closest('.custom-select');
|
|
var $option = $('<option />');
|
|
$option.val(getDateStr(date)).text(getDateStr(date));
|
|
$select.html($option);
|
|
|
|
for ( var i = 1; i < numDays; i++ ) {
|
|
var $opt = $option.clone();
|
|
date.setDate(date.getDate() + 1);
|
|
$opt.val(getDateStr(date)).text(getDateStr(date));
|
|
$select.append($opt);
|
|
}
|
|
$select.prop('selectedIndex', 0);
|
|
|
|
if ($cWrap.length) {
|
|
$select.insertAfter($cWrap);
|
|
$cWrap.remove();
|
|
}
|
|
$select.customSelect();
|
|
});
|
|
|
|
var date = startDay;
|
|
for ( var i = 1; i < numDays; i++ ) {
|
|
var $tlClone = $timeLine.clone();
|
|
var $tlcSelects = $tlClone.find('select');
|
|
|
|
$tlClone.children('label.check').remove();
|
|
$tlcSelects.each(function (index) {
|
|
var $el = $(this);
|
|
var $cWrap = $el.closest('.custom-select');
|
|
$el.insertAfter($cWrap);
|
|
if (index == 0 ) {
|
|
$el.prop('selectedIndex', i);
|
|
} else if ($switch.prop('checked')) {
|
|
$el.prop('selectedIndex', $selects.eq(index).prop('selectedIndex'));
|
|
}
|
|
$cWrap.remove();
|
|
$el.customSelect();
|
|
});
|
|
$wtSchedule.append($tlClone);
|
|
}
|
|
}
|
|
|
|
$dateFrom.on('change', function () {
|
|
drawSchedule();
|
|
});
|
|
|
|
$dateTo.on('change', function () {
|
|
drawSchedule();
|
|
});
|
|
|
|
drawSchedule();
|
|
|
|
});
|
|
|
|
|
|
|
|
$('div.request-form').each(function () {
|
|
var $mContainer = $(this);
|
|
var $switchContainer = $mContainer.find('div.rq-btn-to-hide');
|
|
var $switchBtn = $switchContainer.find('a');
|
|
var $formContainer = $mContainer.find('div.rq-form');
|
|
var $hideData = $mContainer.find('div.rq-to-hide');
|
|
var $formBtnContainer = $formContainer.find('div.rq-btn-wrap');
|
|
|
|
$switchBtn.on('click', function () {
|
|
$hideData.hide();
|
|
$formContainer.animate({
|
|
height: 'show',
|
|
opacity: 'show'
|
|
}, 300, function () {
|
|
$mContainer.addClass('rqf-opened');
|
|
});
|
|
return false;
|
|
});
|
|
});
|
|
|
|
$('form div.rq-switch').each(function () {
|
|
var $swContainer = $(this);
|
|
var $check = $swContainer.find('input[type="checkbox"]');
|
|
var $sSect = $swContainer.closest('.rq-sub-sect');
|
|
var $fieldsContainer = $sSect.children('.rq-sub-sect-body');
|
|
|
|
function checkState () {
|
|
var $inputs = $fieldsContainer.find('input, select'),
|
|
$selectBox = $fieldsContainer.find('div.c-select-box');
|
|
|
|
if ($check.prop('checked')) {
|
|
$fieldsContainer.removeClass('disabled');
|
|
$selectBox.removeClass('disabled');
|
|
$inputs.prop('disabled', false);
|
|
} else {
|
|
$fieldsContainer.addClass('disabled');
|
|
$selectBox.addClass('disabled');
|
|
$inputs.prop("checked",false).prop('disabled', true);
|
|
$inputs.trigger("change");
|
|
}
|
|
}
|
|
|
|
checkState();
|
|
$check.on('change', checkState);
|
|
});
|
|
|
|
//$('select.select2').select2();
|
|
|
|
|
|
//--------------------------------------------
|
|
$('a.reply-msg').on('click', function () {
|
|
var sender = $(this).attr('data-sender');
|
|
var reply_message = $(this).attr('data-reply-message');
|
|
var $reply = $('#pw-reply');
|
|
$reply.find('#id_recipient').val(sender)
|
|
$reply.find('#reply_message').val(reply_message)
|
|
});
|
|
|
|
|
|
});
|
|
|
|
}(jQuery);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|