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.
1969 lines
60 KiB
1969 lines
60 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
|
|
};
|
|
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 ($) {
|
|
|
|
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 () {
|
|
$('.search_form').on('submit', function(e){
|
|
e.preventDefault();
|
|
var action = $(this).attr('action');
|
|
var formData = ''
|
|
$('.search_form').each(function(i){
|
|
if (i==0){
|
|
formData = formData+$(this).serialize();
|
|
}
|
|
else{
|
|
formData = formData+'&'+$(this).serialize() ;
|
|
}
|
|
});
|
|
var url = action+'?'+formData.replace(/[^&]+=\.?(?:&|$)/g, '')
|
|
|
|
//console.log(action+'?'+formData.replace(/[^&]+=\.?(?:&|$)/g, ''));
|
|
//console.log(url)
|
|
window.location = url
|
|
|
|
|
|
//var formData = $(this).serialize()
|
|
|
|
//alert(window.location+formData);
|
|
});
|
|
$('#callback-form').on('submit', function(e){
|
|
e.preventDefault();
|
|
var $form = $(this);
|
|
var url = $form.attr('action');
|
|
var formData = $(this).serialize();
|
|
|
|
$.get(url, formData, function(data){
|
|
if (data.success){
|
|
$.fancybox.close();
|
|
}
|
|
else{
|
|
// delete prvious error
|
|
$("#callback-form .error").remove();
|
|
|
|
var $input = $('#id_callback_phone')
|
|
// generate new error
|
|
var $error = $("<div>").attr("class", "error").append(data.errors['callback_phone']);
|
|
$input.parent().prepend($error)
|
|
console.log(data.errors)
|
|
}
|
|
});
|
|
//alert(123);
|
|
});
|
|
$('#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()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
$('.addcalendar, .removecalendar').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('addcalendar')){
|
|
$this.hide();
|
|
$this.siblings('.removecalendar').show()
|
|
}
|
|
}
|
|
else{
|
|
if($this.hasClass('removecalendar')){
|
|
$this.hide();
|
|
$this.siblings('.addcalendar').show()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
|
|
});
|
|
|
|
$('#reg_form').on('submit', function(event){
|
|
event.preventDefault();
|
|
var formData = $(this).serialize();
|
|
var url = '/register/';
|
|
|
|
$.post(url, formData, function(data){
|
|
if(data.success){
|
|
//register success
|
|
|
|
// remove input values
|
|
$('#reg_form input').each(function(i){
|
|
$(this).val("");
|
|
});
|
|
// close popup
|
|
$.fancybox.close();
|
|
|
|
}
|
|
else{
|
|
// 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:{
|
|
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])").customSelect();
|
|
|
|
/* Нестандартное оформление для поля checkbox */
|
|
$.fn.customRadioCheck = function () {
|
|
return $(this).each(function () {
|
|
var $el = $(this);
|
|
var type = $el.attr("type");
|
|
var $label = $el.closest("label");
|
|
var $customCheckbox = $el.wrap("<span class='custom-"+ type +"' />").parent();
|
|
$label.addClass("custom-radio-check");
|
|
function setState () {
|
|
if (type == 'radio') {
|
|
var name = $el.attr('name');
|
|
var $radios = $('input[type="radio"]').filter('[name="' + name + '"]');
|
|
$radios.each(function () {
|
|
var $container = $(this).closest('.custom-radio');
|
|
$container.removeClass('checked');
|
|
if ($(this).is(':checked')) {
|
|
$container.addClass('checked');
|
|
}
|
|
});
|
|
} else {
|
|
if ($el.prop("checked")) {
|
|
$customCheckbox.addClass("checked");
|
|
} else {
|
|
$customCheckbox.removeClass("checked");
|
|
}
|
|
}
|
|
$el.trigger('blur');
|
|
}
|
|
setState();
|
|
$el.on("change", setState);
|
|
});
|
|
};
|
|
|
|
$("input[type='checkbox'], input[type='radio']").customRadioCheck();
|
|
|
|
/* Обработка autocomplete в полях поиска
|
|
* используется jQuery UI Autocomplete
|
|
* */
|
|
$('input.topicChecks').each(function() {
|
|
|
|
if ($(this).prop('checked')==false) {
|
|
|
|
$('li.level1.'+$(this).val()+'').each(function() {
|
|
$(this).find('>label.active').first().trigger('click');
|
|
$(this).find('ul li label.active').trigger('click');
|
|
$(this).hide().addClass('noAC').find('li').each(function() {
|
|
$(this).addClass('noAC');
|
|
});
|
|
})
|
|
}
|
|
else {
|
|
$('li.level1.'+$(this).val()+'').each(function() {
|
|
$(this).fadeIn();
|
|
$(this).removeClass('noAC').find('.noAC').each(function() {
|
|
$(this).removeClass('noAC');
|
|
});
|
|
|
|
});
|
|
};
|
|
});
|
|
|
|
var data=[];
|
|
function rebuildTopicsAC() {
|
|
data=[];
|
|
$('.topics-list').find('li:not(.noAC)').each(
|
|
function() {
|
|
if ($(this).find('a').text().length>0) {
|
|
data.push({sid: $(this).find('>label span input').attr('value'),type: $(this).attr('data-type'), category: '', label: $(this).find('>a').text()});
|
|
}
|
|
else {
|
|
data.push({sid: $(this).find('>label span input').attr('value'),type: $(this).attr('data-type'), category: $(this).parents().eq(1).find('>a').text()+':', label: $(this).text() });
|
|
}
|
|
|
|
}
|
|
);
|
|
|
|
$('input[type="text"].topicAC').each(function () {
|
|
var $input = $(this);
|
|
var $iWrap = $($input.parent());
|
|
var $acWrap = $('<div class="sf-autocomplete"><div class="sfa-wrap"></div></div>');
|
|
var $acSect = $acWrap.find('.sfa-wrap');
|
|
$iWrap.parent().append('<input id="top_ac_hidden" style="display:none;">');
|
|
$acWrap.appendTo($iWrap);
|
|
|
|
$input.catcomplete({
|
|
appendTo: $acSect,
|
|
delay: 0,
|
|
source: data,
|
|
open: function () {
|
|
$acSect.addClass('show').parent().addClass('show');
|
|
},
|
|
close: function () {
|
|
$acSect.removeClass('show').parent().removeClass('show');
|
|
},
|
|
select: function( event, ui ) {
|
|
//var item_to_select=ui.item.label;
|
|
var input_ID=ui.item.sid;
|
|
$('#top_ac_hidden').val(ui.item.id);
|
|
if ($('input[value="'+input_ID+'"]').parents().eq(1).hasClass('active')) {
|
|
$('#ac_animes_t').css({'opacity':0,'display':'block'}).animate({opacity:1}, 500, function() {
|
|
setTimeout(function() {
|
|
$('#ac_animes_t').stop().animate({opacity:0}, 500, function() {
|
|
$('#ac_animes_t').css({'display':'none'})
|
|
});
|
|
}, 1000);
|
|
});
|
|
}
|
|
else {
|
|
$('input[value="'+input_ID+'"]').parents().eq(1).trigger('click');
|
|
}
|
|
$(this).val('');
|
|
return false;
|
|
}
|
|
}).data( 'customCatcomplete' )._renderItem = function( ul, item ) {
|
|
var descr = item.type != '' ? ' <i>(' + item.type + ')</i>' : '';
|
|
return $( '<li>' )
|
|
.append( '<a>' + item.label + descr + '</a>' )
|
|
.appendTo( ul );
|
|
};
|
|
});
|
|
};
|
|
rebuildTopicsAC();
|
|
/*
|
|
$('input[type="text"].autocomplete').each(function () {
|
|
var $input = $(this);
|
|
var $iWrap = $input.closest('.sf-field-wrap');
|
|
var $acWrap = $('<div class="sf-autocomplete"><div class="sfa-wrap"></div></div>');
|
|
var $acSect = $acWrap.find('.sfa-wrap');
|
|
|
|
$acWrap.appendTo($iWrap);
|
|
|
|
$input.catcomplete({
|
|
appendTo: $acSect,
|
|
delay: 0,
|
|
source: data,
|
|
open: function () {
|
|
$acSect.addClass('show');
|
|
},
|
|
close: function () {
|
|
$acSect.removeClass('show');
|
|
},
|
|
select: function( event, ui ) {
|
|
var type = ui.item.type != '' ? ' (' + ui.item.type + ')' : '';
|
|
ui.item.value = ui.item.label + type;
|
|
}
|
|
}).data( 'customCatcomplete' )._renderItem = function( ul, item ) {
|
|
var descr = item.type != '' ? ' <i>(' + item.type + ')</i>' : '';
|
|
return $( '<li>' )
|
|
.append( '<a>' + item.label + descr + '</a>' )
|
|
.appendTo( ul );
|
|
};
|
|
});
|
|
*/
|
|
/* Галереи-слайдеры на главной
|
|
* использован плагин 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');
|
|
var $recPrev = $reControls.children('a.prev');
|
|
var $recNext = $reControls.children('a.next');
|
|
|
|
if ($reSwipeItems.length > 1) {
|
|
$reControls.addClass('enabled');
|
|
$reSwipeItems.css({
|
|
display: 'block'
|
|
});
|
|
$reContainer.height($reSwipeItems.eq(0).height());
|
|
var $reSwiper = $reContainer.swiper({
|
|
speed: 500,
|
|
mode:'horizontal',
|
|
loop: false,
|
|
simulateTouch: false,
|
|
onInit: function () {
|
|
$recPrev.addClass('disabled');
|
|
},
|
|
onSlideChangeStart: function (swiper) {
|
|
$reContainer.animate({
|
|
height: $reSwipeItems.eq(swiper.activeIndex).children('div.re-body').height()
|
|
}, 300);
|
|
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;
|
|
});
|
|
}
|
|
|
|
});
|
|
|
|
$('#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')) {
|
|
$help.fadeOut(300);
|
|
}
|
|
});
|
|
|
|
/* jQueri UI Datepicker */
|
|
$.datepicker.setDefaults($.datepicker.regional["ru"]);
|
|
|
|
$( "#dateFrom" ).datepicker({
|
|
dateFormat: 'dd.mm.yy',
|
|
showOn: 'button',
|
|
showOtherMonths: true,
|
|
constrainInput: true,
|
|
onClose: function( selectedDate ) {
|
|
$( "#dateTo" ).datepicker( "option", "minDate", selectedDate );
|
|
}
|
|
});
|
|
$( "#dateTo" ).datepicker({
|
|
dateFormat: 'dd.mm.yy',
|
|
showOn: 'button',
|
|
showOtherMonths: true,
|
|
constrainInput: true,
|
|
onClose: function( selectedDate ) {
|
|
$( "#dateFrom" ).datepicker( "option", "maxDate", selectedDate );
|
|
}
|
|
});
|
|
|
|
$( "input.dateFrom" ).datepicker({
|
|
dateFormat: 'dd.mm.yy',
|
|
showOn: 'button',
|
|
showOtherMonths: true,
|
|
constrainInput: true,
|
|
onClose: function( selectedDate ) {
|
|
var $dateTo = $(this).closest('.period').find('input.dateTo');
|
|
$dateTo.datepicker( "option", "minDate", selectedDate );
|
|
}
|
|
});
|
|
$( "input.dateTo" ).datepicker({
|
|
dateFormat: 'dd.mm.yy',
|
|
showOn: 'button',
|
|
showOtherMonths: true,
|
|
constrainInput: true,
|
|
onClose: function( selectedDate ) {
|
|
var $dateFrom = $(this).closest('.period').find('input.dateFrom');
|
|
$dateFrom.datepicker( "option", "maxDate", selectedDate );
|
|
}
|
|
});
|
|
|
|
/* 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.topicChecks').change(function() {
|
|
|
|
if ($(this).prop('checked')==false) {
|
|
|
|
$('li.level1.'+$(this).val()+'').each(function() {
|
|
var s_ID='s'+$(this).find('>label span input').attr('value');
|
|
$('.csb-selected.show div#'+s_ID).parent().removeClass('show');
|
|
$(this).find('>label.active').first().trigger('click');
|
|
$(this).find('ul li label.active').trigger('click');
|
|
$(this).hide().addClass('noAC').find('li').each(function() {
|
|
$(this).addClass('noAC');
|
|
});
|
|
rebuildTopicsAC();
|
|
})
|
|
}
|
|
else {
|
|
$('li.level1.'+$(this).val()+'').each(function() {
|
|
$(this).fadeIn();
|
|
$(this).removeClass('noAC').find('.noAC').each(function() {
|
|
$(this).removeClass('noAC');
|
|
});
|
|
|
|
});
|
|
rebuildTopicsAC();
|
|
};
|
|
|
|
});
|
|
|
|
$('div.c-select-box').each(function () {
|
|
var $sb = $(this);
|
|
var $showContainer = $sb.children('div.csb-selected-items');
|
|
var $selected = $('<div class="csb-selected"><div class="csbs-text"></div><a class="csbs-del" href="#">x</a></div>');
|
|
var $checks = $sb.find('input[type="checkbox"]');
|
|
var $qSelClear = $sb.find('div.q-sel > a.clear');
|
|
var $smSwitchers = $sb.find('.places-list li > a, .places-list ul li ul li label a, .topics-list li > a, .topics-list ul li ul li label a');
|
|
|
|
if (!$sb.hasClass('disabled')) {
|
|
$checks
|
|
.each(function () {
|
|
var $el = $(this);
|
|
var index = $checks.index(this);
|
|
var $label = $el.closest('label');
|
|
var labelText = $label.text();
|
|
var $elShow = $selected.clone();
|
|
var $elText = $elShow.find('div.csbs-text');
|
|
var $clear = $elShow.find('a.csbs-del');
|
|
|
|
$elText.text(labelText);
|
|
$elShow.find('>div').prop('id','s'+$label.find('input').prop('value'));
|
|
$clear.on('click', function () {
|
|
|
|
$elShow.removeClass('show');
|
|
if ($showContainer.children('.show').length < 1 ) {
|
|
$showContainer.removeClass('show');
|
|
}
|
|
var li_ID=$(this).parent().find('div').attr('id').substring(1);
|
|
$('.places-list, .topics-list').find('label:contains("'+$(this).parent().find('.csbs-text').text()+'")').each(function() {
|
|
if ($(this).find('input').attr('value')==li_ID) {
|
|
$(this).trigger('click');
|
|
}
|
|
});
|
|
|
|
return false;
|
|
});
|
|
$showContainer.append($elShow);
|
|
if ($el.is(':checked')) {
|
|
$label.addClass('active');
|
|
|
|
}
|
|
if (!$showContainer.hasClass('show') && $showContainer.children('.show').length > 0) {
|
|
$showContainer.addClass('show');
|
|
}
|
|
})
|
|
.on('change', function () {
|
|
var $el = $(this);
|
|
var $label = $el.closest('label');
|
|
var $showEls = $showContainer.children();
|
|
|
|
console.log('#s'+$label.find('span input').attr('value'));
|
|
var index = $checks.index(this);
|
|
$el.trigger('blur');
|
|
|
|
|
|
if ($el.is(':checked')) {
|
|
$label.addClass('active');
|
|
$showEls.eq(index).addClass('show');
|
|
|
|
} else {
|
|
$label.removeClass('active');
|
|
$el.prop('checked', false);
|
|
|
|
$showEls.eq(index).removeClass('show');
|
|
}
|
|
if ($showContainer.children('.show').length > 0) {
|
|
|
|
$showContainer.addClass('show');
|
|
} else {
|
|
$showContainer.removeClass('show');
|
|
}
|
|
// Если сменился чекбокс области
|
|
if ($el.parents().eq(2).is('.level2')) {
|
|
// Выделяем все города
|
|
if ($el.is(':checked')) {
|
|
$el.parents().eq(2).addClass('full');
|
|
$el.parents().eq(2).find('ul li label').each(
|
|
function() {
|
|
$(this).addClass('active');
|
|
$(this).find('input[type="checkbox"]').prop('checked', true);
|
|
var s_ID='s'+$(this).find('span input').first().attr('value');
|
|
$showContainer.find('#'+s_ID).parent().removeClass('show');
|
|
}
|
|
);
|
|
} else {
|
|
// Если сняли метку с области - снимаем метки с городов области
|
|
|
|
$el.parents().eq(2).removeClass('full');
|
|
$el.parents().eq(4).find('input[type="checkbox"]').first().prop('checked', false);
|
|
$el.parents().eq(4).find('.custom-radio-check').first().removeClass('active');
|
|
|
|
$el.parents().eq(3).find('li.level2.full').each(function () {
|
|
var s_ID='s'+$(this).find('label span input').first().attr('value');
|
|
$showContainer.find('#'+s_ID).parent().addClass('show');
|
|
}
|
|
);
|
|
var s_ID='s'+$el.parents().eq(4).find('label span input').first().attr('value');
|
|
$showContainer.find('#'+s_ID).parent().removeClass('show');
|
|
console.log('n222');
|
|
$el.parents().eq(4).find('label').first().removeClass('active');
|
|
$el.parents().eq(4).find('label span input[type="checkbox"]').first().prop('checked', false);
|
|
$el.parents().eq(2).find('ul li label.active').each(
|
|
function() {
|
|
$(this).removeClass('active');
|
|
$(this).find('input[type="checkbox"]').prop('checked', false);
|
|
}
|
|
);
|
|
}
|
|
}
|
|
else {
|
|
// Если сменился чекбокс страны
|
|
if ($el.parents().eq(2).is('.level1')) {
|
|
// Поставили метку - отмечаем все обласи
|
|
if ($el.is(':checked')) {
|
|
if ((($label.parents().eq(1).find('li .custom-radio-check.active').length)>=($label.parents().eq(1).find('li .custom-radio-check').length))) {
|
|
$label.parents().eq(2).find('label').addClass('active');
|
|
$label.parents().eq(2).find('label span input[type="checkbox"]').prop('checked', true);
|
|
} else {};
|
|
// И все города в областях
|
|
$el.parents().eq(2).find('ul li.level2').addClass('full');
|
|
if ($el.parents().eq(2).find('ul li.level2').length>0) {
|
|
$el.parents().eq(2).find('ul li.level2 label').each(
|
|
function() {
|
|
$(this).addClass('active');
|
|
$(this).find('input[type="checkbox"]').prop('checked', true);
|
|
var s_ID='s'+$(this).find('span input').first().attr('value');
|
|
$showContainer.find('#'+s_ID).parent().removeClass('show');
|
|
}
|
|
);
|
|
} else {
|
|
$el.parents().eq(2).find('li label').each(
|
|
function() {
|
|
$(this).addClass('active');
|
|
$(this).find('input[type="checkbox"]').prop('checked', true);
|
|
var s_ID='s'+$(this).find('span input').first().attr('value');
|
|
$showContainer.find('#'+s_ID).parent().removeClass('show');
|
|
|
|
}
|
|
);
|
|
}
|
|
} else {
|
|
// Сняли метку - снимаем метки дочерних элементов
|
|
$el.parents().eq(2).find('ul li.level2').removeClass('full');
|
|
if ((($label.parents().eq(1).find('li .custom-radio-check.active').length)<($label.parents().eq(1).find('li .custom-radio-check').length))) {
|
|
$label.removeClass('active');
|
|
$label.find('span input[type="checkbox"]').prop('checked', false);
|
|
} else {};
|
|
if ($el.parents().eq(2).find('ul li.level2').length>0) {
|
|
$el.parents().eq(2).find('ul li.level2 label.active').each(
|
|
function() {
|
|
$(this).removeClass('active');
|
|
$(this).find('input[type="checkbox"]').prop('checked', false);
|
|
}
|
|
); } else {
|
|
$el.parents().eq(2).find('li label.active').each(
|
|
function() {
|
|
$(this).removeClass('active');
|
|
$(this).find('input[type="checkbox"]').prop('checked', false);
|
|
}
|
|
);
|
|
|
|
}
|
|
}
|
|
}
|
|
else {
|
|
// Если сменился чекбокс последнего города и область не отмечена - выделить всю область
|
|
if ((($label.parents().eq(1).find('li .custom-radio-check.active').length)>=($label.parents().eq(1).find('li .custom-radio-check').length))&&($el.not(':checked'))) {
|
|
$label.parents().eq(2).find('input[type="checkbox"]').first().parents().eq(1).addClass('active');
|
|
$label.parents().eq(2).find('input[type="checkbox"]').first().parents().eq(2).addClass('full');
|
|
$label.parents().eq(2).find('input[type="checkbox"]').first().prop('checked', true);
|
|
var s_ID='s'+$label.parents().eq(2).find('input[type="checkbox"]').first().attr('value');
|
|
$showContainer.find('#'+s_ID).parent().addClass('show');
|
|
|
|
$label.parents().eq(1).find('.custom-radio-check').each(function () {
|
|
$(this).addClass('active');
|
|
var s_ID='s'+$(this).find('span input').first().attr('value');
|
|
console.log('ttt');
|
|
$showContainer.find('#'+s_ID).parent().removeClass('show');
|
|
});
|
|
|
|
} else {
|
|
// Область была отмечена, сняли метку города - снимаем метку области
|
|
$label.parents().eq(2).find('label').first().removeClass('active');
|
|
if ($label.parents().eq(2).hasClass('level2')) {
|
|
$el.parents().eq(6).find('input[type="checkbox"]').first().prop('checked', false);
|
|
$el.parents().eq(6).find('.custom-radio-check').first().removeClass('active');
|
|
} else {};
|
|
|
|
$label.parents().eq(2).find('input[type="checkbox"]').first().parents().eq(2).removeClass('full');
|
|
$label.parents().eq(2).find('input[type="checkbox"]').first().prop('checked', false);
|
|
var s_ID='s'+$label.parents().eq(2).find('input[type="checkbox"]').first().attr('value');
|
|
$showContainer.find('#'+s_ID).parent().removeClass('show');
|
|
|
|
|
|
|
|
$label.parents().eq(1).find('.custom-radio-check.active').each(function () {
|
|
var s_ID='s'+$(this).find('span input').attr('value');
|
|
$showContainer.find('#'+s_ID).parent().addClass('show');
|
|
|
|
console.log('1');
|
|
});
|
|
if ($label.parents().eq(4).hasClass('level1')) {
|
|
$label.parents().eq(3).find('li.level2.full').each(function () {
|
|
var s_ID='s'+$(this).find('label span input').first().attr('value');
|
|
$showContainer.find('#'+s_ID).parent().addClass('show');
|
|
console.log('2');
|
|
});
|
|
var s_ID='s'+$label.parents().eq(4).find('label span input').first().attr('value');
|
|
$showContainer.find('#'+s_ID).parent().removeClass('show');
|
|
} else {};
|
|
|
|
};
|
|
};
|
|
};
|
|
if ($label.parents().eq(2).hasClass('level1')) {
|
|
// Для областей/городов, чей родитель - страна
|
|
$label.parents().eq(2).find('>ul').each(function () {
|
|
// Если есть области и они все уже выделены - сокращаем список тегов областей до тега страны
|
|
if ((($(this).find('li.level2.full').length)>=($(this).find('li.level2').length))&&($(this).find('li.level2').length>0)) {
|
|
$el.parents().eq(4).find('input[type="checkbox"]').first().prop('checked', true);
|
|
$el.parents().eq(4).find('.custom-radio-check').first().addClass('active');
|
|
$(this).find('li.level2.full').each(function () {
|
|
var s_ID='s'+$(this).find('label span input').first().attr('value');
|
|
$showContainer.find('#'+s_ID).parent().removeClass('show');
|
|
console.log('3');
|
|
}
|
|
);
|
|
var s_ID='s'+$label.parents().eq(3).find('li.level1 label span input').first().attr('value');
|
|
$showContainer.find('#'+s_ID).parent().addClass('show');
|
|
console.log('4');
|
|
|
|
} else {};
|
|
});
|
|
} else {
|
|
// То же самое только для городов, чей родитель область, а затем страна
|
|
if ($label.parents().eq(4).hasClass('level1')) {
|
|
$label.parents().eq(4).find('>ul').each(function() {
|
|
if ((($(this).find('li.level2.full').length)>=($(this).find('li.level2').length))&&($(this).find('li.level2').length>0)) {
|
|
$el.parents().eq(6).find('input[type="checkbox"]').first().prop('checked', true);
|
|
$el.parents().eq(6).find('.custom-radio-check').first().addClass('active');
|
|
$(this).find('li.level2.full').each(function () {
|
|
var s_ID='s'+$(this).find('label span input').first().attr('value');
|
|
$showContainer.find('#'+s_ID).parent().removeClass('show');
|
|
}
|
|
);
|
|
var s_ID='s'+$label.parents().eq(5).find('li.level1 label span input').first().attr('value');
|
|
$showContainer.find('#'+s_ID).parent().addClass('show');
|
|
console.log('5');
|
|
} else {};
|
|
});
|
|
} else {};
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
});
|
|
}
|
|
|
|
$qSelClear.on('click', function () {
|
|
$checks.prop('checked', false).trigger('change');
|
|
return false;
|
|
});
|
|
|
|
$smSwitchers.on('click', function () {
|
|
var $switcher = $(this);
|
|
var $pContainer = $switcher.closest('li');
|
|
var $submenu = $pContainer.children('ul');
|
|
|
|
if ($pContainer.hasClass('active')) {
|
|
$submenu
|
|
.stop(true, true)
|
|
.animate({
|
|
opacity: 'hide',
|
|
height: 'hide'
|
|
}, 300, function () {
|
|
$pContainer.removeClass('active');
|
|
});
|
|
} else {
|
|
$submenu
|
|
.stop(true, true)
|
|
.animate({
|
|
opacity: 'show',
|
|
height: 'show'
|
|
}, 300, function () {
|
|
$pContainer.addClass('active');
|
|
});
|
|
}
|
|
|
|
return false;
|
|
})
|
|
});
|
|
|
|
$('div.c-select-box.select div.csb-selected-items').on('click', function () {
|
|
var $el = $(this);
|
|
var $cont = $el.closest('.c-select-box');
|
|
var $menuWrap = $cont.children('.csb-menu-wrap');
|
|
var $sbMenus = $('div.c-select-box').children('.csb-menu-wrap');
|
|
|
|
|
|
$sbMenus.each(function () {
|
|
var $sbMenu = $(this);
|
|
if ($sbMenu.is(':visible')) {
|
|
$sbMenu
|
|
.stop(true, true)
|
|
.animate({
|
|
height: 'hide',
|
|
opacity: 'hide'
|
|
}, 300);
|
|
}
|
|
});
|
|
|
|
if ($menuWrap.is(':hidden') && !$cont.hasClass('disabled')) {
|
|
$menuWrap
|
|
.stop(true, true)
|
|
.animate({
|
|
height: 'show',
|
|
opacity: 'show'
|
|
}, 300);
|
|
}
|
|
});
|
|
|
|
function closeSelectBox() {
|
|
var selBoxMenu = $('div.c-select-box.select div.csb-menu-wrap');
|
|
selBoxMenu.stop(true, true)
|
|
.animate({
|
|
height: 'hide',
|
|
opacity: 'hide'
|
|
}, 300);
|
|
}
|
|
|
|
$doc.on('click', function (event) {
|
|
var targetObj = $(event.target);
|
|
if (targetObj.parents().filter('.c-select-box.select').length < 1) {
|
|
closeSelectBox();
|
|
}
|
|
});
|
|
|
|
$('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');
|
|
});
|
|
|
|
/* Открыть увеличенную фотографию
|
|
* загружать текущую и картинки по нажатию стрелок наверное при помощи ajax
|
|
* */
|
|
$('a.open-photo').on('click', function () {
|
|
var $popupGallery = $('#pw-gallery');
|
|
// configure image
|
|
var $img = $(this).find('img').clone();
|
|
$img.addClass('photoTag');
|
|
//$img.attr('width', '730');
|
|
//$img.attr('height', '533');
|
|
|
|
$img_block = $popupGallery.find('.pg-photos');
|
|
$img_block.html($img);
|
|
|
|
// add id for image description
|
|
var id = 'imgid'+$img.attr('data-image-id')
|
|
$popupGallery.find('.pg-photo-descr').attr('id', id);
|
|
$popupGallery.find('.pg-photo-descr ul').remove();
|
|
|
|
$popupGallery.find('.pg-photo-title').html($img.attr('data-image-name'))
|
|
$popupGallery.find('.pg-photo-text').html($img.attr('data-image-description'))
|
|
|
|
// Список людей для автокомплита:
|
|
|
|
$.getJSON('/accounts/get-tag-users/',function(json){
|
|
window.photoTagData = json;
|
|
});
|
|
|
|
|
|
|
|
// отметки
|
|
$('.photoTag').photoTag({
|
|
externalAddTagLinks: {
|
|
bind: true,
|
|
selector: ".addTag"
|
|
},
|
|
requestTagsUrl: '/photo/existing-tags/',
|
|
deleteTagsUrl: '/photo/delete-tag/',
|
|
addTagUrl: '/photo/add-tag/',
|
|
parametersForNewTag: {
|
|
name: {
|
|
parameterKey: 'name',
|
|
isAutocomplete: true,
|
|
label: 'Введите имя:'
|
|
}
|
|
}
|
|
});
|
|
// ---------------------------------------
|
|
|
|
var $popupOuter = $('div.popup-gallery-outer', $popupGallery);
|
|
var $closePopup = $('a.pg-close', $popupGallery);
|
|
var $prevSlide = $('a.pgpc-prev', $popupGallery);
|
|
var $nextSlide = $('a.pgpc-next', $popupGallery);
|
|
|
|
|
|
function closeGallery() {
|
|
$popupGallery.fadeOut(300, function () {
|
|
$body.removeClass('no-scroll');
|
|
});
|
|
return false;
|
|
}
|
|
|
|
$closePopup.on('click', closeGallery);
|
|
$popupOuter.on('click', function (event) {
|
|
var targetObj = $(event.target);
|
|
if (targetObj.parents().filter('.popup-gallery').length < 1) {
|
|
closeGallery()
|
|
}
|
|
});
|
|
|
|
$prevSlide.on('click', function () {
|
|
return false;
|
|
});
|
|
|
|
$nextSlide.on('click', function () {
|
|
return false;
|
|
});
|
|
|
|
$body.addClass('no-scroll');
|
|
$popupGallery.fadeIn(300);
|
|
|
|
return false;
|
|
});
|
|
|
|
$('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;
|
|
});
|
|
|
|
$('a.e-btn').on('click', function () {
|
|
var $switch = $(this);
|
|
var $wrapper = $switch.closest('.edit-wrap');
|
|
var $container = $switch.closest('.p-editable');
|
|
var $pForm = $wrapper.children('.e-form');
|
|
var $closeBtn = $pForm.find('a.ef-close');
|
|
var $eContainers = $('.p-editable.pe-current').not($container);
|
|
|
|
$eContainers.each(function() {
|
|
$(this).removeClass('pe-current');
|
|
});
|
|
$container.toggleClass('pe-current');
|
|
|
|
$closeBtn.one('click', function() {
|
|
$container.removeClass('pe-current');
|
|
return false;
|
|
});
|
|
|
|
$(document).one('click', function(event) {
|
|
var targetObj = $(event.target);
|
|
if (targetObj.parents().filter('.e-form').length < 1) {
|
|
$container.removeClass('pe-current');
|
|
}
|
|
});
|
|
|
|
return false;
|
|
});
|
|
|
|
$('a.eps-open').on('click', function () {
|
|
var $switch = $(this);
|
|
var $sect = $switch.closest('.ep-sect');
|
|
var $sectBody = $sect.children('div.ep-sect-body');
|
|
|
|
if ($sect.hasClass('eps-opened')) {
|
|
$sectBody
|
|
.stop()
|
|
.animate({
|
|
height: 'hide',
|
|
opacity: 'hide'
|
|
}, 300, function () {
|
|
$sect.removeClass('eps-opened');
|
|
});
|
|
} else {
|
|
$sectBody
|
|
.stop()
|
|
.animate({
|
|
height: 'show',
|
|
opacity: 'show'
|
|
}, 300, function () {
|
|
$sect.addClass('eps-opened');
|
|
});
|
|
}
|
|
|
|
return false;
|
|
});
|
|
|
|
/* Custom scroll для календаря*/
|
|
$('div.calendar-container').each(function () {
|
|
var $scrollContainer = $(this);
|
|
var calScrollOptions = $.extend(customScrollOptions, { horizontalScroll: true });
|
|
$scrollContainer.mCustomScrollbar(calScrollOptions);
|
|
});
|
|
|
|
/* Временная функция для указания файла */
|
|
$('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 > div.afs-type').each(function () {
|
|
var $radsCont = $(this);
|
|
var $rads = $radsCont.find('input[type="radio"]');
|
|
var $formBody = $rads.closest('form').children('div.adm-form-body');
|
|
|
|
function formState () {
|
|
var radsChecked = $rads.filter(':checked').length > 0;
|
|
var $inputs = $formBody.find('input, select, textarea, button');
|
|
var $selectBox = $formBody.find('div.c-select-box');
|
|
|
|
if (radsChecked) {
|
|
$formBody.removeClass('disabled');
|
|
$selectBox.removeClass('disabled');
|
|
$inputs.prop('disabled', false);
|
|
} else {
|
|
$formBody.addClass('disabled');
|
|
$selectBox.addClass('disabled');
|
|
$inputs.prop('disabled', true);
|
|
}
|
|
}
|
|
|
|
formState();
|
|
$rads.on('change', formState);
|
|
});
|
|
|
|
/* Добавление секций "Статистика за" на нажатие кнопки "добавить данные за другой период" */
|
|
$('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');
|
|
var $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('disabled', true);
|
|
}
|
|
}
|
|
|
|
checkState();
|
|
$check.on('change', checkState);
|
|
});
|
|
|
|
|
|
//--------------------------------------------
|
|
$('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);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|