var JQ = $.noConflict(); JQ(document).ready(function(){ JQ('#menu-icon').click(function(){ JQ('.menu-mobile').fadeToggle(); JQ(this).toggleClass("open"); }); JQ('.dropdown').hover(function(e) { clearTimeout(JQ.data(this,'timer')); JQ(this).find('.dropdown-menu').stop(true, true).delay(100).fadeIn(200); }, function(e) { JQ.data(this,'timer', setTimeout(JQ.proxy(function() { JQ(this).find('.dropdown-menu').stop(true, true).delay(100).fadeOut(200); }, this), 100)); }); JQ(".user__btn").click(function() { JQ("#auth").modal('show'); }); JQ("#authSend").on('click', function(){ }); JQ('[data-scroll]').on('click', function(){ JQ('html, body').animate({ scrollTop: JQ( JQ.attr(this, 'data-scroll') ).offset().top }, 2000); event.preventDefault(); }); JQ(".reviews__btn").click(function() { JQ(".popup-review").modal('show'); }); JQ(".header__contacts-btn").click(function() { JQ("#myModal").modal('show'); }); JQ("span[id^='author_bio_']").on("click", function(){ var spanid=this.id; var id=spanid.replace('author_bio_',''); JQ("[id^='bio']").each(function() { if(this.id!="bio"+id){ JQ(this).hide(); } }); JQ("span[id^='author_bio_']").each(function() { if(this.id!=spanid){ JQ(this).removeClass("links-block__link-active"); JQ(this).addClass("links-block__link"); } }); JQ(this).toggleClass("links-block__link-active"); JQ("#bio"+id).toggle(); }); JQ('#div_enter_button').on("click",function(){ var mempass=0; JQ("#message").hide(); var td_button =JQ("#div_enter_button").html(); var login=JQ('input[name=login]').val(); var password=JQ('input[name=passw]').val(); if(JQ('input[name=remember]').is(':checked')) { mempass=1; } console.log ( login+','+password+','+ mempass); JQ("#div_enter_button").html(""); JQ.ajax({ url: "/ajax_enter.asp", cache: false, type: "POST", data: "login="+login+"&password="+password+"&mempass="+mempass , success: function(otvet){ //console.log(otvet); if (otvet.indexOf('done') + 1) { location.reload(); } else{ JQ("#message").show(); //$("#message").html(otvet); JQ("#message").html("Неверные логин и пароль"); JQ("#div_enter_button").html(td_button); } } }); }); JQ(".popover_profile").popover({ "html": true, "content": function(){ var div_id = "tmp-id-" + JQ.now(); return details_in_popup(JQ(this).attr('data-load'), div_id); } }); JQ(document).on("click", "button[id^='upProfile']", function(){ var buttonId = this.id; var textId = buttonId.replace('upProfile',''); JQ.ajax({ url: "/profile_update.php", cache: false, type: "POST", data: JQ("form#updateProfile_"+textId).serialize(), success: function(data){ //console.log(data); JQ('#res_'+textId).html("Изменения в Ваш Профиль добавлены!"); } }); }); JQ(document).on("click", "button[id^='resetProfile']", function(){ var buttonId = this.id; var textId = buttonId.replace('resetProfile',''); //console.log(textId); JQ("form#updateProfile_"+textId).trigger("reset"); }); JQ(document).on("click", "button[id^='closeProfile']", function(){ JQ(this).offsetParent().popover('hide'); }); JQ("div[id^='icon']").popover({ "html": true, "content": function(){ var div_id = "tmp-id-" + JQ.now(); var iconId = this.id; var d_d = iconId.replace('icon',''); var splitDD = d_d.split("_"); return links_in_popup(splitDD, div_id); } }); JQ("#sendTextReview").on("click", function(){ if(validateRequiredFields(this.form.id)){ this.form.submit(); }else{ //console.log("ERR"); } }); JQ('#uModal').on('show.bs.modal', function (e) { if(e.target.id=="uModal"){ var param = JQ(e.relatedTarget).attr('data-param'); var url ='/'+param+'.asp'; var title = JQ(e.relatedTarget).attr('data-title'); var id = JQ(e.relatedTarget).attr('data-id'); JQ('#uModal .modal-title').html(title); JQ.ajax({ url: url, type: "POST", data: 'id='+id, success: function(response){ JQ("#uModal .modal-body").html(response); } }); } }); JQ(document).on("click", "button[id^='sendSerialReview']", function(){ //console.log(this.form.id); var formID = this.form.id; if(validateRequiredFields(formID)){ JQ("#div_serial_review_button").html(""); JQ.ajax({ url: "/addreview_serial.php", cache: false, type: "POST", data: JQ("form#"+formID).serialize(), success: function(data){ //console.log(data); JQ("#div_serial_review_button").html("Спасибо за Ваш отзыв!"); } }); } }); JQ(document).on("click", "button[id^='sendReview']", function(){ //console.log(this.form.id); var formID = this.form.id; if(validateRequiredFields(formID)){ JQ("#div_review_button").html(""); JQ.ajax({ url: "/addreview.php", cache: false, type: "POST", data: JQ("form#"+formID).serialize(), success: function(data){ //console.log(data); JQ("#div_review_button").html("Спасибо за Ваш отзыв!"); } }); } }); JQ("#sendProfileAuth").on("click", function(){ if(validateRequiredFields(this.form.id)){ this.form.submit(); } }); JQ("#sendNews").on("click", function(){ if(validateRequiredFields(this.form.id)){ this.form.submit(); } }); JQ("#sendNewsComment").on("click", function(){ if(validateRequiredFields(this.form.id)){ this.form.submit(); } }); JQ(document).on("click", "button[id^='confirmCancel']", function(){ JQ(this).offsetParent().popover('hide'); }); JQ(document).on("click", "button[id^='confirmDel']", function(){ var buttonId = this.id; var textId = buttonId.replace('confirmDel',''); var delType = JQ(this).attr('data-type'); JQ.ajax({ url: "/profile_delete.asp", cache: false, type: "POST", data: "textid="+textId+"&del="+delType, success: function(data){ location.reload(true); //console.log(data); } }); }); JQ("#profileCompare").on("click", function(){ var n = JQ('input[name="members"]:checked').length; if(n>0){ this.form.submit(); }else{ JQ("div#errCompare").toggleClass("d-block"); } }); JQ(document).on("click", "button[id^='pwdSend']", function(){ //console.log(this.form.id); var formID = this.form.id; if(validateRequiredFields(formID)){ JQ("#div_button").html(""); JQ.ajax({ url: "/ajax_remind.asp", cache: false, type: "POST", data: JQ("form#"+formID).serialize(), success: function(data){ //console.log(data); JQ("#div_button").html(data); } }); } }); JQ(document).on("click", "button[id^='sendFilmReview']", function(){ //console.log(this.form.id); var formID = this.form.id; if(validateRequiredFields(formID)){ JQ("#div_review_button").html(""); JQ.ajax({ url: "/addfilmreview.php", cache: false, type: "POST", data: JQ("form#"+formID).serialize(), success: function(data){ //console.log(data); JQ("#div_review_button").html("Спасибо за Ваш отзыв!"); } }); } }); JQ('.image-popup').magnificPopup({ type: 'image', delegate: 'a', closeOnContentClick: true, closeBtnInside: false, fixedContentPos: true, mainClass: 'mfp-no-margins mfp-with-zoom', // class to remove default margin from left and right side gallery: { enabled: true, navigateByImgClick: true, preload: [0,1] // Will preload 0 - before current, and 1 after the current image }, image: { verticalFit: true }, zoom: { enabled: true, duration: 300 // don't foget to change the duration also in CSS } }); JQ('.popup-gallery').each(function() { JQ(this).magnificPopup({ type: 'image', delegate: 'a', closeOnContentClick: true, closeBtnInside: false, fixedContentPos: true, mainClass: 'mfp-no-margins mfp-with-zoom', // class to remove default margin from left and right side gallery: { enabled: true, navigateByImgClick: true, preload: [0,1] // Will preload 0 - before current, and 1 after the current image }, image: { verticalFit: true }, zoom: { enabled: true, duration: 300 // don't foget to change the duration also in CSS } }); }); JQ(document).on("click", "button[id^='sendGuest']", function(){ var formID = this.form.id; var message = JQ("textarea#message").val().toLowerCase(); if(message.indexOf("href")!= -1){ JQ("textarea#message").removeClass("is-valid").addClass("is-invalid"); JQ(".invalid-feedback").show(); }else{ if(validateRequiredFields(formID)){ JQ("#div_review_button").html(""); JQ.ajax({ url: "/addguest.php", cache: false, type: "POST", data: JQ("form#"+formID).serialize(), success: function(data){ //console.log(data); JQ("#div_review_button").html("Спасибо за Ваш отзыв!"); } }); } } }); }); function details_in_popup(link, div_id){ JQ.ajax({ url: link, success: function(response){ JQ('#'+div_id).html(response); } }); return '
Загрузка...
'; } function links_in_popup(splitDD, div_id){ JQ.ajax({ url: "/show_textlinks.asp", type: "POST", data: 'textid='+splitDD[0]+'&linktypeid='+splitDD[1], success: function(response){ JQ('#'+div_id).html(response); } }); return '
Загрузка...
'; } function validateRequiredField(field){ var err = 0; if( field.value.trim() === '' ) { err++; JQ(field).removeClass("is-valid").addClass("is-invalid"); }else{ JQ(field).removeClass("is-invalid").addClass("is-valid"); } if(field.type=='email'){ if(!isValidEmailAddress(field.value)){ err++; JQ(field).removeClass("is-valid").addClass("is-invalid"); }else{ JQ(field).removeClass("is-invalid").addClass("is-valid"); } } if(field.name=='code'){ if(field.value!=JQ('form#'+field.form.id+' input[name=parametr]').val()){ err++; JQ(field).removeClass("is-valid").addClass("is-invalid"); }else{ JQ(field).removeClass("is-invalid").addClass("is-valid"); } } if(err>0){ return false;}else{return true;} } function validateRequiredFields(formID){ var err = 0; JQ('form#'+formID+' [required]').each( function () { if(!validateRequiredField(this)){ err++; } }); if(err>0){ return false;}else{return true;} } function filmRating(mylist,filmid){ var myrate = JQ("#Rating"+filmid).val(); // console.log(myrate); JQ.ajax({ url: "/filmrate2.asp", type: "POST", data: 'filmid='+filmid+'&rate='+myrate, success: function(otvet){ JQ('#golos'+filmid).css({"padding-left": "20px", "padding-bottom": "5px"}); if(otvet=="done"){ JQ('#golos'+filmid).html("Ваш голос учтен!"); }else{ JQ('#golos'+filmid).html("Вы оценивали это произведение!"); } } }); } function isValidEmailAddress(emailAddress) { var pattern = new RegExp(/^(("[\w-\s]+")|([\w-]+(?:\.[\w-]+)*)|("[\w-\s]+")([\w-]+(?:\.[\w-]+)*))(@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$)|(@\[?((25[0-5]\.|2[0-4][0-9]\.|1[0-9]{2}\.|[0-9]{1,2}\.))((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\.){2}(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[0-9]{1,2})\]?$)/i); return pattern.test(emailAddress); }