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.
158 lines
6.3 KiB
158 lines
6.3 KiB
var EXPO = EXPO || {}; //isolated namespace
|
|
EXPO.exposition = EXPO.exposition || {};
|
|
if (EXPO.exposition.object){
|
|
console.warn('WARNING: EXPO.exposition.object is already defined!');
|
|
}else {
|
|
|
|
EXPO.exposition.object = (function () {
|
|
// dependencies
|
|
var com = EXPO.common,
|
|
$waiter;
|
|
// variables
|
|
|
|
var that = {};
|
|
that.opt = {}; //свойства по умолчанию
|
|
//private
|
|
$(function () {
|
|
$waiter = $('#wait-ajax:not(.absolute)').css({'z-index': '8031'});
|
|
});
|
|
|
|
// methods
|
|
//инициализация общих свойств
|
|
that.init = function (options) {
|
|
$.extend(this.opt, options);
|
|
var self = this,
|
|
$visitButtons = $('.'+this.opt.visit.activeClass+', .'+this.opt.visit.passiveClass);
|
|
|
|
com.opt.addCalendarText = this.opt.addCalendarText;
|
|
com.opt.removeCalendarText = this.opt.removeCalendarText;
|
|
/**
|
|
* visit buttons
|
|
*/
|
|
$visitButtons.off('click');
|
|
$visitButtons.on('click', function () {
|
|
if (!$(this).hasClass('no_auth')) {
|
|
if ($(this).hasClass(self.opt.visit.activeClass)) {
|
|
|
|
/**
|
|
* I plan to visit
|
|
*/
|
|
$('.' + self.opt.visit.activeClass).hide().siblings('.' + self.opt.visit.passiveClass).show();
|
|
|
|
$('#' + self.opt.visit.visitorsListId).append(self.opt.visit.currentHtml);
|
|
$('#' + self.opt.visit.somebodyId).removeClass("hidden");
|
|
$('#' + self.opt.visit.nobodyId).addClass("hidden");
|
|
|
|
|
|
} else {
|
|
/**
|
|
* refuse to visit
|
|
*/
|
|
$('.' + self.opt.visit.passiveClass).hide().siblings('.' + self.opt.visit.activeClass).show();
|
|
$('#' + self.opt.visit.visitorsListId).children(".current").remove();
|
|
|
|
if ($('#' + self.opt.visit.visitorsListId).children().length == 0) {
|
|
|
|
$('#' + self.opt.visit.somebodyId).addClass("hidden");
|
|
$('#' + self.opt.visit.nobodyId).removeClass("hidden");
|
|
}
|
|
|
|
}
|
|
}
|
|
return false;
|
|
});
|
|
/**
|
|
* advertise form validation
|
|
*/
|
|
$('#'+this.opt.advertise.id).on("submit", function () {
|
|
var formData = $(this).serialize(),
|
|
formUrl = $(this).attr("action"),
|
|
$form = $(this),
|
|
/**
|
|
* executes after AJAX get request is complete
|
|
* @param data - data recieved from server ex
|
|
*/
|
|
handler = function (data) {
|
|
var clearValue = function () {
|
|
$('.err',$form).removeClass("err");
|
|
$('.pwf-msg',$form).text('');
|
|
};
|
|
|
|
if (data.success !== true){
|
|
clearValue();
|
|
for (var k in data.errors){
|
|
if (data.errors.hasOwnProperty(k)) {
|
|
$('input[name="'+k+'"]',$form)
|
|
.closest(".required").addClass("err")
|
|
.siblings(".pwf-msg").text(data.errors[k]);
|
|
}
|
|
}
|
|
|
|
}else{
|
|
clearValue();
|
|
dataLayer.push({'event': 'advmemberform'});
|
|
$('input:text',$form).val('');
|
|
$.fancybox.close();
|
|
|
|
}
|
|
$waiter.hide();
|
|
};
|
|
$waiter.show();
|
|
com.postRequest(formData,formUrl,handler);
|
|
return false;
|
|
});
|
|
|
|
/**
|
|
* event news subscribe form validation
|
|
*/
|
|
$('#'+this.opt.event_news_subscribe.id).on("submit", function () {
|
|
var formData = $(this).serialize(),
|
|
formUrl = $(this).attr("action"),
|
|
$form = $(this),
|
|
/**
|
|
* executes after AJAX get request is complete
|
|
* @param data - data recieved from server ex
|
|
*/
|
|
handler = function (data) {
|
|
var clearValue = function () {
|
|
$('.err',$form).removeClass("err");
|
|
$('.pwf-msg',$form).text('');
|
|
};
|
|
if (data.success != true){
|
|
clearValue();
|
|
for (var k in data.errors){
|
|
console.log(data.errors.hasOwnProperty(k));
|
|
console.log(k);
|
|
if (data.errors.hasOwnProperty(k)) {
|
|
$('input[name="'+k+'"]',$form)
|
|
.closest(".required").addClass("err")
|
|
.siblings(".pwf-msg").text(data.errors[k]);
|
|
}
|
|
}
|
|
|
|
}else{
|
|
clearValue();
|
|
dataLayer.push({'event': 'event-news-subscribe-form'});
|
|
$('input:text',$form).val('');
|
|
$('p#success').show();
|
|
if (data.sent == true) {
|
|
window.location = data.redirect_url;
|
|
} else {
|
|
window.setTimeout(function () {
|
|
$.fancybox.close();
|
|
}, 1000);
|
|
}
|
|
|
|
|
|
}
|
|
$waiter.hide();
|
|
};
|
|
$waiter.show();
|
|
com.postRequest(formData,formUrl,handler);
|
|
return false;
|
|
});
|
|
|
|
};
|
|
return that;
|
|
}());
|
|
}
|
|
|