$(document).ready(function () { $('.reviews-filter-search .input-clear-wrap > div').click(function () { $('.review-search-form').submit(); }); $('#add-review').click(function () { addReviewForm(false); return false; }); $('#add-review-mobile').click(function () { addReviewForm(true); return false; }); $('.reviews-offer .offer-1 .btn-mh').click(function () { addReviewForm(false); return false; }); $('.offer-1.offer-mobile .btn-mh').click(function () { addReviewForm(true); return false; }); $('.add-comment').click(function () { if ($(this).attr('data-review-id') && $(this).attr('data-review-type')) { addCommentForm({review_id: $(this).attr('data-review-id'), review_type: $(this).attr('data-review-type'), title_text: 'Добавить комментарий'}); } else { addCommentForm(); } }); $('.review-like i').click(function () { var el = $(this); var comment_id = el.attr('data-id'); $.ajax({ url: "/v2/likes/ajax_reviews_likes", type: "GET", dataType: "json", cache: false, data: { type: 'like', comment_id: comment_id }, success: function (data) { el.parent().children('span').text(data.likes); el.parent().children('i').toggleClass('liked'); }, error: function (data) { new_alert(data.responseText, 'error'); } }); }); $('.review-doctor-like i').click(function () { var el = $(this); var comment_id = el.attr('data-id'); $.ajax({ url: "/v2/likes/ajax_reviews_doctors_likes", type: "GET", dataType: "json", cache: false, data: {comment_id: comment_id}, success: function (data) { el.parent().children('span').text(data.likes); el.parent().children('i').toggleClass('liked'); }, error: function (data) { new_alert(data.responseText, 'error'); } }); }); $('.review-counter').each(function () { var el = $(this); var value = el.children().children().text(); if (value == 0) el.children().children().html('
Нет оценки
'); var deg = value * 72; var start_degree = 0; if (deg <= 180) { el.css('background-image', 'linear-gradient(' + (90 + deg) + 'deg, transparent 50%, #DDD 50%),linear-gradient(90deg, #DDD 50%, transparent 50%)'); } else { el.css('background-image', 'linear-gradient(' + (deg - 90) + 'deg, transparent 50%, #F80 50%),linear-gradient(90deg, #DDD 50%, transparent 50%)'); } el.css('transform', 'rotate(' + start_degree + 'deg)'); el.children('.review-counter-circle').css('transform', 'rotate(' + (-start_degree) + 'deg)'); }); $("a.fancybox").fancybox({ 'zoomSpeedIn': 300, 'zoomSpeedOut': 300, 'overlayShow': true, 'autoResize': true, 'padding': [15,15,15,15], 'type': 'image', 'scrolling': 'no', 'iframe': {'scrolling': 'no'} }); $("#reviews_filter_city").keyup(function() { city_popup_selector('reviews_filter_city', $("#reviews_filter_city"), 'reviews_filter_city_variants', $("#reviews_filter_city_variants"), $("#reviews_filter_city_errors"), 20); }); }); function addReviewForm(mobile) { try { if (banned) { new_alert('Вы забанены и не можете оставлять отзывы!', 'error'); return; } } catch (e) {} var sld_mh = $('.sld-mh'); sld_mh.attr('data-value', ''); if (arguments.length > 1) { var def_val = arguments[1]; if ((def_val >= 1) && (def_val <= 5)) { sld_mh.attr('data-value', def_val); } } var form = $('.review-add-review-form').html(); $('.add-review-mobile').text(''); $('#popup-window-add-review > .body').text(''); if (mobile) { $('.add-review-mobile').html(form).slideDown(200); $('.add-review-mobile .reviews-add .sld-mh').sld_mh(); } else { showAddReviewForm({body: form}); $('.body > .reviews-add .sld-mh').sld_mh(); } } function addCommentForm(params) { if (banned) { new_alert('Вы забанены и не можете оставлять комментарии!', 'error'); return; } var form = $('.review-add-comment-form').html(); var review_id = 0; var review_type = 0; var title_text = ''; if (params.review_id != undefined && params.review_type != undefined) { review_id = params.review_id; review_type = params.review_type; } if (params.title_text != undefined) { title_text = params.title_text; } showAddReviewForm({body: form, review_id: review_id, review_type: review_type, title_text: title_text}); $('.body > .reviews-add .sld-mh').sld_mh(); } function addMessageForm(params) { //if (banned) { // new_alert('Вы забанены и не можете оставлять комментарии!', 'error'); // return; //} var form = $('.review-add-message-form').html(); var title_text = ''; if (params.title_text != undefined) { title_text = params.title_text; } showAddReviewForm({body: form, title_text: title_text}); $('.body > .reviews-add .sld-mh').sld_mh(); } function upload_new_file(input) { var rawValue = input.val(); if(rawValue == '') { alert('Недопустимое имя файла'); return; } var name = getInputFileName(rawValue); if(name && getInputFileName(name)) { uploadFile(input, name); $('.own-files-note').addClass('active'); } } function getInputFileName(path) { if (path == '') return false; var maxFileNameLength = 100; var nameParts = path.split('/'); var name = nameParts[nameParts.length - 1]; nameParts = name.split('\\'); name = nameParts[nameParts.length - 1]; if (name.length > maxFileNameLength) { nameParts = name.split('.'); var ext = nameParts[nameParts.length - 1]; nameParts.length = nameParts.length - 1; name = (nameParts.join('.')).substr(0, maxFileNameLength - ext.length - 3) + '...' + ext; } name = name.replace(/\//g, '_'); name = name.replace(/\\/g, '_'); name = name.replace(/:/g, '_'); name = name.replace(/\*/g, '_'); name = name.replace(/"/g, '_'); name = name.replace(/\/g, '_'); name = name.replace(/\|/g, '_'); return name; } function uploadFile(input, fileName) { var uploadForm = $('[target="uploadIframe"]'); uploadForm.find('[name="data[title]"]').val(fileName); uploadForm.find('[name="data[photo_num]"]').val(input.attr('data-photo-num')); var inputClone = input.clone(); inputClone.insertAfter(input); uploadForm.append(input); uploadForm.submit(); input.remove(); } function fileUploaded(status, fileId, url, isImage, photo_num, identificator) { var uploadForm = $('[target="uploadIframe"]'); uploadForm.find('[type="file"]').remove(); if (status !== false) { if (isImage) { $('.review-add-photos > div#photo-' + photo_num).attr('rel', fileId).html(''); $('[rel="' + fileId + '"]').find('.filename').fancybox({ "padding": 20, "imageScale": true, "zoomOpacity": true, "zoomSpeedIn": 0, "zoomSpeedOut": 0, "zoomSpeedChange": 0, "frameWidth": 700, "frameHeight": 600, "overlayShow": true, "overlayOpacity": 0.9, "hideOnContentClick": false, "centerOnScroll": false }); } else { new_alert('Недопустимый тип файла!', 'error'); } if (identificator != undefined) { var fileIDS = $('[name="file_ids"]'); var oldIds = fileIDS.val(); fileIDS.val(identificator + ' ' + oldIds); } } $('[name="data[title]"]').val(''); } function deletePhoto(photo_num) { $('.review-add-photos > div#photo-' + photo_num).removeAttr('rel').html(''); event.stopPropagation(); } function addReview(that) { that.prop('disabled', true); var el = $('#popup-window-add-review').find('.reviews-add'); if (typeof el[0] === 'undefined') { el = $('.add-review-mobile').find('.reviews-add'); } var cid = el.find('#cid').val(), name = el.find('#name').val(), email = el.find('#email').val(), type = el.find('#type').val(), myaddress = el.find('.myaddress').val(), body = el.find('#body').val(), anon = el.find('#anon').is(':checked'), bonus = el.find('#bonus').is(':checked'), rating = [], photos = [], viewoid = el.find('#viewoid').val(); el.find('.review-add-rating > div').each(function (i) { var rating_value = $(this).attr('data-value'); if (rating_value != undefined) { rating.push(rating_value); } }); el.find('.review-add-photos > div').each(function (i) { var file_id = $(this).attr('rel'); if (file_id != undefined) { photos.push(file_id); } }); let re = new RegExp('^([0-9A-Za-zА-Яа-яЁё\\-\\s.,!?":;%#№()*\\[\\]\\\']*)$'); if ( ! re.test(body)) { new_alert('В отзыве обнаружены запрещенные символы!', 'error'); $('#add_review_btn').attr('disabled'); } else if (body.length < 40) { new_alert('Минимальная длина отзыва 40 символов!', 'error'); $('#add_review_btn').attr('disabled'); } else { $.ajax({ url: "/v2/reviews/add_review", type: "POST", data: { cid: cid, name: name, email: email, type: type, myaddress: myaddress, body: body, anon: +anon, bonus: +bonus, rating: rating, photos: photos, viewoid: viewoid }, success: function () { closeAddReviewForm(); new_alert('Ваш отзыв успешно отправлен. Он будет опубликован после проверки модератором.'); yaCounter19894666.reachGoal('clinic_review'); try { dataLayer.push({'event': 'clinic_review_create_tag'}); } catch (error) { console.log('google tag error') } }, error: function (data) { new_alert(data.responseText, 'error'); }, complete: function () { that.prop('disabled', false); } }); } } function addComment() { var el = $('.reviews-add'), rid = el.find('#rid').val(), rtype = el.find('#rtype').val(), as_clinic = el.find('#as-clinic').is(':checked'), cid = (as_clinic) ? el.find('#cid').val() : 0, myaddress = el.find('.myaddress').val(), email = el.find('#email').val(), body = el.find('#body').val(); $.ajax({ url: "/v2/reviews/add_comment", type: "POST", data: { rid: rid, rtype: rtype, cid: cid, myaddress: myaddress, email: email, body: body }, success: function () { closeAddReviewForm(); new_alert('Ваш комментарий успешно отправлен. Он будет опубликован после проверки модератором.'); }, error: function (data) { new_alert(data.responseText, 'error'); } }); } function addReviewDoctor(that) { that.prop('disabled', true); var el = $('.reviews-add'), did = el.find('#did').val(), name = el.find('#name').val(), email = el.find('#email').val(), type = el.find('#type').val(), myaddress = el.find('.myaddress').val(), body = el.find('#body').val(), anon = el.find('#anon').is(':checked'), rating = []; el.find('.review-add-rating > div').each(function (i) { var rating_value = $(this).attr('data-value'); if (rating_value != undefined) { rating.push(rating_value); } }); if (body.length < 40) { new_alert('Минимальная длина отзыва 40 символов!', 'error'); $('#add_review_btn').attr('disabled'); } else { $.ajax({ url: "/v2/reviewsdoctors/add_review", type: "POST", data: { did: did, name: name, email: email, type: type, myaddress: myaddress, body: body, rating: rating, anon: +anon }, success: function () { closeAddReviewForm(); new_alert('Ваш отзыв успешно отправлен. Он будет опубликован после проверки модератором.'); yaCounter19894666.reachGoal('doctor_review'); try {dataLayer.push({'event': 'doctor_review_create_tag'});} catch (error) {console.log('google tag error')} }, error: function (data) { new_alert(data.responseText, 'error'); }, complete: function () { that.prop('disabled', false); } }); } } function showAddReviewForm(params) { var el = $('#popup-window-add-review'); $('#hider-popup-add-review').show(); el.children('.body').html(params.body); if (params.review_id != undefined && params.review_type != undefined) { $('.reviews-add > #rid').val(params.review_id); $('.reviews-add > #rtype').val(params.review_type); } if (params.title_text != undefined) { el.children('div.title').children('span').text(params.title_text); } else { el.children('div.title').children('span').text('Добавление отзыва'); } el.show(); var h_title = el.children('.title').outerHeight(); var h_body = el.children('.body').outerHeight(); el.height(h_title + h_body); } function closeAddReviewForm() { $('#popup-window-add-review').hide(); $('#hider-popup-add-review').hide(); $('.add-review-mobile').slideUp(100); } function autocompleteClinic(el) { $('#cid').val(0); var keyword = el.val(); if (keyword.length >= 3) { $.ajax({ url: '/v2/ClinicReview/autocomplete', type: 'POST', dataType: 'json', data: {keyword: keyword}, success: function (data) { $('#results').html(''); $(data).each(function (key, value) { $('#results').append('
' + value.name + '
'); }); $('.item').click(function () { el.val($(this).html()); $('#cid').val($(this).attr('data-id')); }) }, error: function(xhr, status, error) { var err = eval('(' + xhr.responseText + ')'); alert(err.Message); } }); } else { $('#results').html(''); } el.blur(function () { $('#results').fadeOut(500); }).focus(function () { $("#results").show(); }); } function autocompleteDoctor(el) { $('#did').val(0); var keyword = el.val(); if (keyword.length >= 3) { $.ajax({ url: '/v2/DoctorReview/autocomplete', type: 'POST', dataType: 'json', data: {keyword: keyword}, success: function (data) { $('#results').html(''); $(data).each(function (key, value) { $('#results').append('
' + value.name + '
'); }); $('.item').click(function () { var doctor_id = $(this).attr('data-id'); el.val($(this).attr('data-name')); $('#did').val(doctor_id); $.ajax({ url: '/v2/ReviewsDoctors/get_partner_status', type: 'POST', data: {doctor_id: doctor_id}, success: function (data) { if (data) $('#bonus-for-partner').addClass('active'); else $('#bonus-for-partner').removeClass('active'); } }); }) }, error: function(xhr, status, error) { var err = eval('(' + xhr.responseText + ')'); alert(err.Message); } }); } else { $('#results').html(''); } el.blur(function () { $('#results').fadeOut(500); }).focus(function () { $("#results").show(); }); } function autocompleteText(el) { var text = el.val(); var container = $('#bonus-for-text'); $.ajax({ url: '/v2/ReviewsDoctors/get_text_length', type: 'POST', dataType: 'json', data: {text: text}, success: function (data) { if (data.result) container.removeClass('active').children('span').text(data.result); else container.addClass('active').children('span').text('Достаточно для получения бонусов'); if (data.body_length) $('#add_review_btn').removeAttr('disabled'); else $('#add_review_btn').attr('disabled', true); } }); }