function facebook_login(action, login_type) { $.blockUI(); FB.login(function(response) { console.log(response); if (response.status == 'connected') { // if (response.scope) { // user is logged in and granted some // permissions.perms is a comma separated list of granted // permissions $.post(action, { type : login_type }, function(data) { if (data == true) { refresh_login_status(); $.unblockUI(); $.fancybox.close(); return true; } else { $.unblockUI(); facebook_login_error(); return false; } }, 'json'); } /* * else { // user is logged in, but did not grant any permissions * $.unblockUI(); facebook_login_error(); return false; } } */ else { // user is not logged in $.unblockUI(); facebook_login_error(); return false; } }, { scope : "publish_stream,email,offline_access" }); } function facebook_login_error() { $.fancybox($("#facebook_login_error").html(), { // 'title' : 'Ошибка', 'autoDimensions' : false, 'width' : 350, 'height' : 200 }); } function login_error() { $.fancybox($("#login_error").html(), { // 'title' : 'Ошибка', 'autoDimensions' : false, 'width' : 350, 'height' : 200 }); } function confirm_code_error() { $.fancybox($("#confirm_code_error").html(), { // 'title' : 'Ошибка', 'autoDimensions' : false, 'width' : 350, 'height' : 200 }); } function restore_password_message(result) { $.fancybox(result == true ? $("#restore_password_message_success").html() : $("#restore_password_message_error").html(), { // 'title' : 'Ошибка', 'autoDimensions' : false, 'width' : 350, 'height' : 200 }); } function registration_complete() { $.fancybox($("#registration_complete").html(), { // 'title' : 'Ошибка', 'autoDimensions' : false, 'width' : 350, 'height' : 200 }); } function form_agency_message() { $.fancybox($("#form_agency_message").html(), { // 'title' : 'Ошибка', 'autoDimensions' : false, 'width' : 350, 'height' : 200 }); } function logout() { $.unblockUI(); $.get(logout_url, {}, function() { window.location.reload(); }); } function refresh_login_status() { $("#login_status").load(get_login_status_url, function() { iuser_init(); var step = rgstr_list.getCurrentSlide(); $('#ordering_form_auth').remove(); rgstr_list.reloadShow(); // $('.rgstr').HideAllBubblePopups(); if (step == 1) rgstr_list.goToLastSlide(); // alert(rgstr_list.getSlideCount()); } ); } function get_cities(country_id, element_id) { $("#" + element_id).block({ message : null }); $.getJSON(get_cities_url, { country_id : country_id }, function(data) { var element = "#" + element_id; var select = $(element).empty().val(''); select.append(''); $.each(data, function(index, value) { select.append(''); }); $(element + " option:first").attr('selected', 'selected'); $(element).unblock(); $.uniform.update(element); }); return true; } function get_cities_for_region(region_id, element_id, city_id) { $("#" + element_id).block({ message : null }); $.getJSON(get_cities_for_region_url, { region_id : region_id }, function(data) { var element = "#" + element_id; var select = $(element).empty().val(''); select.append(''); $.each(data, function(index, value) { select.append(''); }); // alert(city_id); if (city_id > 0) { $(element + " option[value='" + city_id + "']").prop("selected", true); // alert($(element).val()); } else { $(element + " option:first").prop('selected', true); } $(element).unblock(); $.uniform.update(element); }); return true; } function form_get_areas_for_city(city_id) { var element_exist = $('#form_request_area_id_' + city_id).length; // alert(city_id); $('.form_request_area_id').hide('fast').prop('disabled', true); $('div[id*=uniform-form_request_area_id_]').hide(0); $('.form_request_area_prefix').hide(0); // $.uniform.update('.form_request_area_id'); if (element_exist) { $('.form_request_area_id_' + city_id).show(0).prop('disabled', false); $('.form_request_area_prefix').show(0); // $.uniform.update('.form_request_area_id_'+city_id); $('div.bx-wrapper #uniform-form_request_area_id_' + city_id).show(0); // $('div.uniform-form_request_area_id_'+city_id).show('fast'); } } function get_areas_for_city(city_id, obj ,area_element_id, area_container_id,area_id, custom_msg) { var element = "#" + area_element_id; var container = area_container_id ? $("#" + area_container_id) : false; var area_id = area_id || 0; var msg = custom_msg || '- выберите район -'; // $("#"+area_element_id).block({ message: null }); // $("#"+area_container_id).hide(); // $(element).block({ message: null }).prop('disabled',true); $(element).prop('disabled', true); if (city_id == '' || city_id == 0) { $('.selectList').html(''); } else { $.getJSON(get_areas_for_city_url, { city_id : city_id }, function(data) { var select = $('.selectList'); // var select=$("."+area_element_id).empty().val(''); // select.append(''); // console.log(typeof data); var city = $(obj).find('option[value='+city_id+']').text(); var total = 0; var uniId = 'uni'+city_id; var checkUni = select.find('#'+uniId).html(); var optionArr = '