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.
153 lines
4.1 KiB
153 lines
4.1 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 = {},
|
|
Note = function (it, opt) {
|
|
this.opt = opt;
|
|
this.DOMthis = it;
|
|
this.DOMbutton = it.querySelector('.'+opt.buttonClass);
|
|
this.DOMinput = it.querySelector('.'+opt.inputClass);
|
|
this.inputName = this.DOMinput.getAttribute('name');
|
|
this.url = this.DOMbutton.getAttribute('href');
|
|
this._controller();
|
|
};
|
|
Note.prototype = {
|
|
_init: function () {
|
|
|
|
},
|
|
_controller: function () {
|
|
var self = this;
|
|
$(this.DOMinput).on('blur', function () {
|
|
self.send();
|
|
});
|
|
$(this.DOMbutton).on('click', function () {
|
|
return false;
|
|
});
|
|
},
|
|
send: function () {
|
|
var data = {},
|
|
response,
|
|
self = this,
|
|
handler = function (data) {
|
|
if (data.success){
|
|
console.log('ok');
|
|
$(self.DOMbutton).addClass('active');
|
|
}else{
|
|
console.log('data not send');
|
|
}
|
|
|
|
};
|
|
data[this.inputName] = this.DOMinput.value;
|
|
response = com.getRequest(data,this.url,handler);
|
|
}
|
|
};
|
|
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);
|
|
this.notes = [];
|
|
|
|
$('.'+this.opt.note.wrapClass).each(function () {
|
|
var note = new Note(this,self.opt.note);
|
|
self.notes.push(note);
|
|
});
|
|
$('.'+this.opt.note.wrapDisabledClass).on('click', function () {
|
|
$.fancybox.open('#pw-login');
|
|
return false;
|
|
});
|
|
com.opt.addCalendarText = this.opt.addCalendarText;
|
|
com.opt.removeCalendarText = this.opt.removeCalendarText;
|
|
/**
|
|
* visit buttons
|
|
*/
|
|
$visitButtons.off('click');
|
|
$visitButtons.on('click', function () {
|
|
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;
|
|
});
|
|
|
|
|
|
};
|
|
return that;
|
|
}());
|
|
}
|
|
|