/*global $, jQuery, ajaxcalls_vars, document, control_vars, window, control_vars,Modernizr,mapfunctions_vars,wpestate_open_menu,grecaptcha,wpestate_show_no_results,wpestate_load_on_demand_pins,get_custom_value,wpestate_enable_half_map_pin_action,wpestate_lazy_load_carousel_property_unit,Chart,widgetId1,widgetId2,widgetId3,widgetId4,wpestate_get_custom_value_tab_search*/ /////////////////////////////////////////////////////////////////////////////////////////// function wpestate_load_stats_tabs(listing_id) { "use strict"; var ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; var nonce = jQuery('#wpestate_tab_stats').val(); jQuery.ajax({ type: 'POST', url: ajaxurl, dataType: 'json', data: { 'action': 'wpestate_load_stats_property', 'postid': listing_id, 'security': nonce, }, success: function (data) { wpestate_show_prop_stat_graph_tab(data.array_values, data.labels, listing_id); }, error: function (errorThrown) {} });//end ajax } function wpestate_show_prop_stat_graph_tab(values, labels, listing_id) { if (!document.getElementById('myChart')) { return; } var ctx = jQuery("#myChart").get(0).getContext("2d"); var myNewChart = new Chart(ctx); // var labels = ''; var traffic_data = ' '; // labels = jQuery.parseJSON ( wpestate_property_vars.singular_label); traffic_data = values; var data = { labels: labels, datasets: [ { label: ajaxcalls_vars.property_views, fillColor: "rgba(220,220,220,0.5)", strokeColor: "rgba(220,220,220,0.8)", highlightFill: "rgba(220,220,220,0.75)", highlightStroke: "rgba(220,220,220,1)", data: traffic_data }, ] }; var options = { title: 'page views', //Boolean - Whether the scale should start at zero, or an order of magnitude down from the lowest value scaleBeginAtZero: true, //Boolean - Whether grid lines are shown across the chart scaleShowGridLines: true, //String - Colour of the grid lines scaleGridLineColor: "rgba(0,0,0,.05)", //Number - Width of the grid lines scaleGridLineWidth: 1, //Boolean - Whether to show horizontal lines (except X axis) scaleShowHorizontalLines: true, //Boolean - Whether to show vertical lines (except Y axis) scaleShowVerticalLines: true, //Boolean - If there is a stroke on each bar barShowStroke: true, //Number - Pixel width of the bar stroke barStrokeWidth: 2, //Number - Spacing between each of the X value sets barValueSpacing: 5, //Number - Spacing between data sets within X values barDatasetSpacing: 1, //String - A legend template legendTemplate: "" }; // var myBarChart = new Chart(ctx).Bar(data, options); var myBarChart = new Chart(ctx, { type: 'bar', data: data, options: options }); } function wpestate_load_stats(listing_id) { "use strict"; var ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; var nonce = jQuery('#wpestate_tab_stats').val(); jQuery.ajax({ type: 'POST', url: ajaxurl, dataType: 'json', data: { 'action': 'wpestate_load_stats_property', 'postid': listing_id, 'security': nonce, }, success: function (data) { wpestate_show_prop_stat_graph(data.array_values, data.labels, listing_id); }, error: function (errorThrown) {} });//end ajax } function wpestate_show_prop_stat_graph(values, labels, listing_id) { "use strict"; var ctx = jQuery("#myChart_" + listing_id).get(0).getContext('2d'); var myNewChart = new Chart(ctx); var data = { labels: labels, datasets: [ { label: ajaxcalls_vars.property_views, fillColor: "rgba(220,220,220,0.5)", strokeColor: "rgba(220,220,220,0.8)", highlightFill: "rgba(220,220,220,0.75)", highlightStroke: "rgba(220,220,220,1)", data: values }, ] }; var options = { scaleBeginAtZero: true, scaleShowGridLines: true, scaleGridLineColor: "rgba(0,0,0,.05)", scaleGridLineWidth: 1, scaleShowHorizontalLines: true, scaleShowVerticalLines: true, barShowStroke: true, barStrokeWidth: 2, barValueSpacing: 5, barDatasetSpacing: 1, legendTemplate: "" }; // var myBarChart = new Chart(ctx).Bar(data, options); var myBarChart = new Chart(ctx, { type: 'bar', data: data, options: options }); } ////////////////////////////////////////////////////////////////////////////////////////////// /// ajax filtering on header search ; jslint checked //////////////////////////////////////////////////////////////////////////////////////////// function wpestate_start_filtering_ajax(newpage) { "use strict"; var action, category, city, area, rooms, baths, min_price, price_max, ajaxurl, postid, halfmap, all_checkers; action = jQuery('#adv_actions').attr('data-value'); category = jQuery('#adv_categ').attr('data-value'); city = jQuery('#advanced_city').attr('data-value'); area = jQuery('#advanced_area').attr('data-value'); rooms = parseFloat(jQuery('#adv_rooms').val(), 10); baths = parseFloat(jQuery('#adv_bath').val(), 10); min_price = parseFloat(jQuery('#price_low').val(), 10); price_max = parseFloat(jQuery('#price_max').val(), 10); postid = parseFloat(jQuery('#adv-search-1').attr('data-postid'), 10); ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; var order = jQuery('#a_filter_order').attr('data-value'); halfmap = 0; var nonce = jQuery('#wpestate_ajax_filtering').val(); if (jQuery('#google_map_prop_list_sidebar').length) { halfmap = 1; } postid = 1; if (document.getElementById('search_wrapper')) { postid = parseInt(jQuery('#search_wrapper').attr('data-postid'), 10); } all_checkers = ''; jQuery('.search_wrapper .extended_search_check_wrapper input[type="checkbox"]').each(function () { if (jQuery(this).is(":checked")) { all_checkers = all_checkers + "," + jQuery(this).attr("name-title"); } }); halfmap = 0; if (jQuery('#google_map_prop_list_sidebar').length) { halfmap = 1; } var geo_lat = ''; var geo_long = ''; var geo_rad = ''; if (jQuery("#geolocation_search").length > 0) { geo_lat = jQuery('#geolocation_lat').val(); geo_long = jQuery('#geolocation_long').val(); geo_rad = jQuery('#geolocation_radius').val(); } jQuery('#listing_ajax_container').empty(); jQuery('#listing_loader').show(); jQuery.ajax({ type: 'POST', url: ajaxurl, dataType: 'json', data: { 'action': 'wpestate_ajax_filter_listings_search', 'action_values': action, 'category_values': category, 'city': city, 'area': area, 'advanced_rooms': rooms, 'advanced_bath': baths, 'price_low': min_price, 'price_max': price_max, 'newpage': newpage, 'postid': postid, 'halfmap': halfmap, 'all_checkers': all_checkers, 'geo_lat': geo_lat, 'geo_long': geo_long, 'geo_rad': geo_rad, 'order': order, 'security': nonce }, success: function (data) { jQuery('#listing_loader').hide(); jQuery('.listing_loader_title').show(); jQuery('.pagination_nojax').hide(); //jQuery('#listing_ajax_container').empty().append(data); jQuery('.entry-title.title_prop').addClass('half_results').text(data.no_founs); jQuery('#listing_ajax_container').empty().append(data.cards); wpestate_restart_js_after_ajax(); }, error: function (errorThrown) {} });//end ajax } ////////////////////////////////////////////////////////////////////////////////////////////// /// ajax filtering on header search ; jslint checked //////////////////////////////////////////////////////////////////////////////////////////// function wpestate_custom_search_start_filtering_ajax(newpage) { "use strict"; var initial_array_last_item, temp_val, array_last_item, how_holder, slug_holder, val_holder, ajaxurl, postid, slider_min, slider_max, halfmap, all_checkers, term_id; array_last_item = parseInt(mapfunctions_vars.fields_no, 10); initial_array_last_item = array_last_item; val_holder = []; slug_holder = []; how_holder = []; //slug_holder = mapfunctions_vars.slugs; slug_holder = JSON.parse(JSON.stringify(mapfunctions_vars.slugs)); // how_holder = mapfunctions_vars.hows; how_holder = JSON.parse(JSON.stringify(mapfunctions_vars.hows)); var term_counter = 0; if (mapfunctions_vars.slider_price === 'yes') { slider_min = jQuery('#price_low').val(); slider_max = jQuery('#price_max').val(); } term_counter = jQuery('.tab-pane.active').find('.term_counter').val(); if ((mapfunctions_vars.adv_search_type === '6' || mapfunctions_vars.adv_search_type === '7')) { // && !jQuery('.halfsearch')[0] term_id = jQuery('.tab-pane.active .term_id_class').val(); if (mapfunctions_vars.slider_price === 'yes') { slider_min = jQuery('#price_low_' + term_id).val(); slider_max = jQuery('#price_max_' + term_id).val(); } var start_counter = term_counter * mapfunctions_vars.fields_no; if (term_counter > 0) { array_last_item = (array_last_item * term_counter) + array_last_item; } for (var i = start_counter; i < array_last_item; i++) { if (how_holder[i] == 'date bigger' || how_holder[i] == 'date smaller') { temp_val = wpestate_get_custom_value_tab_search(term_id + slug_holder[i]); } else { temp_val = wpestate_get_custom_value_tab_search(slug_holder[i]); } if (typeof (temp_val) === 'undefined') { temp_val = ''; } val_holder.push(temp_val); } } else { for (var i = 0; i < array_last_item; i++) { temp_val = wpestate_get_custom_value(slug_holder[i]); if (typeof (temp_val) === 'undefined') { temp_val = ''; } val_holder.push(temp_val); } } if ((mapfunctions_vars.adv_search_type === '6' || mapfunctions_vars.adv_search_type === '7' || mapfunctions_vars.adv_search_type === '8' || mapfunctions_vars.adv_search_type === '9')) { var tab_tax = jQuery('.adv_search_tab_item.active').attr('data-tax'); if (jQuery('.halfsearch')[0]) { tab_tax = jQuery('.halfsearch').attr('data-tax'); } if (tab_tax === 'property_category') { slug_holder[array_last_item] = 'adv_categ'; } else if (tab_tax === 'property_action_category') { slug_holder[array_last_item] = 'adv_actions'; } else if (tab_tax === 'property_city') { slug_holder[array_last_item] = 'advanced_city'; } else if (tab_tax === 'property_area') { slug_holder[array_last_item] = 'advanced_area'; } else if (tab_tax === 'property_county_state') { slug_holder[array_last_item] = 'county-state'; } how_holder[array_last_item] = 'like'; if (jQuery('.halfsearch')[0] && mapfunctions_vars.adv_search_type === '8') { val_holder[array_last_item] = jQuery('#' + slug_holder[array_last_item]).parent().find('input:hidden').val(); } else { val_holder[initial_array_last_item] = jQuery('.adv_search_tab_item.active').attr('data-term'); } } all_checkers = ''; if (mapfunctions_vars.adv_search_type === '6') { jQuery('.tab-pane.active .extended_search_check_wrapper input[type="checkbox"]').each(function () { if (jQuery(this).is(":checked")) { all_checkers = all_checkers + "," + jQuery(this).attr("name-title"); } }); } else { jQuery('.search_wrapper .extended_search_check_wrapper input[type="checkbox"]').each(function () { if (jQuery(this).is(":checked")) { all_checkers = all_checkers + "," + jQuery(this).attr("name-title"); } }); } halfmap = 0; if (jQuery('#google_map_prop_list_sidebar').length) { halfmap = 1; } postid = 1; if (document.getElementById('search_wrapper')) { postid = parseInt(jQuery('#search_wrapper').attr('data-postid'), 10); } ajaxurl = ajaxcalls_vars.wpestate_ajax; var filter_search_action10 = ''; var adv_location10 = ''; if (mapfunctions_vars.adv_search_type === '10') { filter_search_action10 = jQuery('#adv_actions').attr('data-value'); adv_location10 = jQuery('#adv_location').val(); } var filter_search_action11 = ''; var filter_search_categ11 = ''; var keyword_search = ''; keyword_search = jQuery('#keyword').val(); if (mapfunctions_vars.adv_search_type === '11') { filter_search_action11 = jQuery('#adv_actions').attr('data-value'); filter_search_categ11 = jQuery('#adv_categ').attr('data-value'); keyword_search = jQuery('#keyword_search').val(); } var geo_lat = ''; var geo_long = ''; var geo_rad = ''; if (jQuery("#geolocation_search").length > 0) { geo_lat = jQuery('#geolocation_lat').val(); geo_long = jQuery('#geolocation_long').val(); geo_rad = jQuery('#geolocation_radius').val(); } if (jQuery('.tab-pane.active .geolocation_search_item').length>0){ geo_lat = jQuery('.tab-pane.active .geolocation_lat').val(); geo_long = jQuery('.tab-pane.active .geolocation_long').val(); geo_rad = jQuery('.tab-pane.active #geolocation_radius').val(); } var nonce = jQuery('#wpestate_ajax_filtering').val(); var order = jQuery('#a_filter_order').attr('data-value'); jQuery('#listing_ajax_container').empty(); jQuery('#listing_loader').show(); jQuery.ajax({ type: 'POST', url: ajaxurl, dataType: 'json', data: { 'action': 'wpestate_custom_adv_ajax_filter_listings_search', 'val_holder': val_holder, 'newpage': newpage, 'postid': postid, 'slider_min': slider_min, 'slider_max': slider_max, 'halfmap': halfmap, 'all_checkers': all_checkers, 'filter_search_action10': filter_search_action10, 'adv_location10': adv_location10, 'filter_search_action11': filter_search_action11, 'filter_search_categ11': filter_search_categ11, 'keyword_search': keyword_search, 'geo_lat': geo_lat, 'geo_long': geo_long, 'geo_rad': geo_rad, 'order': order, 'term_counter': term_counter, 'security': nonce, }, success: function (data) { jQuery('#listing_loader').hide(); jQuery('.listing_loader_title').show(); jQuery('.entry-title.title_prop').addClass('half_results').text(data.no_founs); jQuery('#listing_ajax_container').empty().append(data.cards); wpestate_restart_js_after_ajax(); jQuery('.col-md-12.listing_wrapper .property_unit_custom_element.image').each(function () { jQuery(this).parent().addClass('wrap_custom_image'); }); }, error: function (errorThrown) { } });//end ajax } function wpestate_js_pagination_ajax(){ "use strict"; jQuery('.pagination_ajax a').on('click', function (event) { event.preventDefault(); var newpage = parseInt(jQuery(this).attr('data-future'), 10); wpestate_start_filtering(newpage); }); } //////////////////////////////////////////////////////////////////////////////////////////// /// redo js after ajax calls - jslint checked //////////////////////////////////////////////////////////////////////////////////////////// function wpestate_restart_js_after_ajax() { "use strict"; wpestate_lazy_load_carousel_property_unit(); wpestate_card_unit_contact_actions(); // wpestate_enable_half_map_pin_action(); if (typeof wpestate_enable_half_map_pin_action == 'function') { wpestate_enable_half_map_pin_action(); } var newpage, post_id, post_image, to_add, icon; jQuery('.pagination_ajax_search a').on('click', function (event) { event.preventDefault(); newpage = parseInt(jQuery(this).attr('data-future'), 10); document.getElementById('scrollhere').scrollIntoView(); if (mapfunctions_vars.custom_search === 'yes') { wpestate_custom_search_start_filtering_ajax(newpage); // should be custom } else { wpestate_start_filtering_ajax(newpage);// } }); jQuery('.pagination_ajax a').on('click', function (event) { event.preventDefault(); newpage = parseInt(jQuery(this).attr('data-future'), 10); document.getElementById('scrollhere').scrollIntoView(); wpestate_start_filtering(newpage); }); jQuery('.property_listing').on('click', function (event) { if (event.target.classList.contains('demo-icon')) { return; } if (control_vars.property_modal === '1' && !Modernizr.mq('only all and (max-width: 1024px)')) { event.preventDefault(); event.stopPropagation(); scroll_modal_save = scroll_modal; var listing_id = jQuery(this).parent().attr('data-listid'); var main_img_url = jQuery(this).parent().attr('data-main-modal'); var main_title = jQuery(this).parent().attr('data-modal-title'); var link = jQuery(this).parent().attr('data-modal-link'); wpestate_enable_property_modal(listing_id, main_img_url, main_title, link); } else { if (control_vars.new_page_link === '_blank') { return; } var link; link = jQuery(this).attr('data-link'); window.open(link, '_self'); } }); jQuery('.share_unit').on('click', function (event) { event.stopPropagation(); }); var already_in = []; jQuery('.compare-action').unbind('click'); jQuery('.compare-action').on('click', function (event) { event.stopPropagation(); jQuery('.prop-compare').animate({ right: "0px" }); post_id = jQuery(this).attr('data-pid'); for (var i = 0; i < already_in.length; i++) { if (already_in[i] === post_id) { return; } } already_in.push(post_id); post_image = jQuery(this).attr('data-pimage'); to_add = ''; jQuery('div.items_compare:first-child').css('background', 'red'); if (parseInt(jQuery('.items_compare').length, 10) > 3) { jQuery('.items_compare:first').remove(); } jQuery('#submit_compare').before(to_add); jQuery('.items_compare').fadeIn(800); }); jQuery('#submit_compare').unbind('click'); jQuery('#submit_compare').on('click', function (event) { jQuery('#form_compare').trigger('submit'); }); jQuery('.icon-fav').on('click', function (event) { event.stopPropagation(); icon = jQuery(this); wpestate_add_remove_favorite(icon); }); jQuery(".share_list, .icon-fav, .compare-action,.property_listing_details_v7_item").on('mouseenter', function () { jQuery(this).tooltip('show'); }) .on('mouseleave', function () { jQuery(this).tooltip('hide'); }); jQuery('.share_list').on('click', function (event) { event.stopPropagation(); var sharediv = jQuery(this).parent().find('.share_unit'); sharediv.toggle(); jQuery(this).toggleClass('share_on'); }); wpestate_grid_list_controls(); wpestate_enable_share_unit(); wpestate_enable_not_logged_favorites(); } /* * * Remove/Add to favorites(property page) when login is not required * */ function wpestate_add_remove_favorite_local_storage_single(icon,post_id){ var current_favorites = window.localStorage.getItem('wpestate_favorites'); post_id=parseInt(post_id); if(icon.hasClass('isnotfavorite')){ if ( current_favorites ) { current_favorites=current_favorites + ',' + post_id; window.localStorage.setItem('wpestate_favorites',current_favorites ); } else { current_favorites=post_id; window.localStorage.setItem('wpestate_favorites', current_favorites); } setCookie('wpestate_favorites',current_favorites,10); jQuery('#add_favorites').removeClass('isnotfavorite').addClass('isfavorite').attr('data-original-title', ajaxcalls_vars.remove_favorite); jQuery('#add_favorites').html('' + ajaxcalls_vars.favorite); }else{ var prop_ids = jQuery.map(current_favorites.split(','), function(value){ return parseInt(value); }); const index = prop_ids.indexOf( post_id ); if (index > -1) { prop_ids.splice(index, 1); window.localStorage.setItem('wpestate_favorites', prop_ids); setCookie('wpestate_favorites',prop_ids,10); } jQuery('#add_favorites').removeClass('isfavorite').addClass('isnotfavorite').attr('data-original-title', ajaxcalls_vars.add_favorite); jQuery('#add_favorites').html('' + ajaxcalls_vars.favorite); } current_favorites = window.localStorage.getItem('wpestate_favorites'); } /* * * Remove/Add to favorites when login is not required * */ function wpestate_add_remove_favorite_local_storage(icon,post_id){ var current_favorites = window.localStorage.getItem('wpestate_favorites'); post_id=parseInt(post_id); if(icon.hasClass('icon-fav-off')){ if ( current_favorites ) { current_favorites=current_favorites+','+post_id; window.localStorage.setItem('wpestate_favorites', current_favorites); } else { current_favorites=post_id; window.localStorage.setItem('wpestate_favorites', current_favorites); } setCookie('wpestate_favorites',current_favorites,10); icon.removeClass('icon-fav-off').addClass('icon-fav-on'); icon.attr('data-original-title', ajaxcalls_vars.remove_fav); }else{ var prop_ids = jQuery.map(current_favorites.split(','), function(value){ return parseInt(value); }); const index = prop_ids.indexOf( post_id ); if (index > -1) { prop_ids.splice(index, 1); window.localStorage.setItem('wpestate_favorites', prop_ids); setCookie('wpestate_favorites',prop_ids,10); } if (icon.hasClass('remove_fav_dash')) { icon.parents('.property_wrapper_dash').remove(); icon.parents('.listing_wrapper').remove(); } icon.removeClass('icon-fav-on').addClass('icon-fav-off'); icon.attr('data-original-title', ajaxcalls_vars.add_favorite); } current_favorites = window.localStorage.getItem('wpestate_favorites'); } /* * * Remove/Add to favorites * */ function wpestate_add_remove_favorite(icon) { "use strict"; var post_id, securitypass, ajaxurl; post_id = icon.attr('data-postid'); securitypass = jQuery('#security-pass').val(); ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; var nonce = jQuery('#wpestate_ajax_filtering').val(); var use_favorite_login = ajaxcalls_vars.favorites_login; if(use_favorite_login=="no"){ wpestate_add_remove_favorite_local_storage(icon,post_id); return; } if (parseInt(ajaxcalls_vars.userid, 10) === 0) { if (!Modernizr.mq('only all and (max-width: 768px)')) { jQuery('.login-links').show(); jQuery('#modal_login_wrapper').show(); jQuery('#modal_login_wrapper').find('[autofocus]').focus(); jQuery('#loginpop').val('1'); } else { jQuery('.mobile-trigger-user').trigger('click'); } } else { icon.toggleClass('icon-fav-off'); icon.toggleClass('icon-fav-on'); jQuery.ajax({ type: 'POST', url: ajaxurl, dataType: 'json', data: { 'action': 'wpestate_ajax_add_fav', 'post_id': post_id, 'security': nonce }, success: function (data) { if (data.added) { icon.removeClass('icon-fav-off').addClass('icon-fav-on'); icon.attr('data-original-title', ajaxcalls_vars.remove_fav); } else { if (icon.hasClass('remove_fav_dash')) { icon.parents('.property_wrapper_dash').remove(); } icon.removeClass('icon-fav-on').addClass('icon-fav-off'); icon.attr('data-original-title', ajaxcalls_vars.add_favorite); } }, error: function (errorThrown) { } });//end ajax }// end login use } //////////////////////////////////////////////////////////////////////////////////////////// /// resend listing for approval-jslint checked //////////////////////////////////////////////////////////////////////////////////////////// function wpestate_resend_for_approval(prop_id, selected_div) { "use strict"; var ajaxurl, normal_list_no; ajaxurl = control_vars.admin_url + 'admin-ajax.php'; var nonce = jQuery('#wpestate_property_actions').val(); jQuery.ajax({ type: 'POST', url: ajaxurl, data: { 'action': 'wpestate_ajax_resend_for_approval', 'propid': prop_id, 'security': nonce }, success: function (data) { if (data === 'pending') { selected_div.parent().empty().append('Sent for approval'); normal_list_no = parseInt(jQuery('#normal_list_no').text(), 10); jQuery('#normal_list_no').text(normal_list_no - 1); } else { selected_div.removeClass('resend_pending').html(data); } }, error: function (errorThrown) { } });//end ajax } //////////////////////////////////////////////////////////////////////////////////////////// /// make property featured-jslint checked //////////////////////////////////////////////////////////////////////////////////////////// function wpestate_make_prop_featured(prop_id, selectedspan) { "use strict"; var ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; var nonce = jQuery('#wpestate_property_actions').val(); jQuery.ajax({ type: 'POST', url: ajaxurl, data: { 'action': 'wpestate_ajax_make_prop_featured', 'propid': prop_id, 'security': nonce }, success: function (data) { if (data.trim() === 'done') { selectedspan.empty().html('' + ajaxcalls_vars.prop_featured + ''); var featured_list_no = parseInt(jQuery('#featured_list_no').text(), 10); jQuery('#featured_list_no').text(featured_list_no - 1); } else { selectedspan.empty().removeClass('make_featured').addClass('featured_exp').text(ajaxcalls_vars.no_prop_featured); } }, error: function (errorThrown) { } });//end ajax } //////////////////////////////////////////////////////////////////////////////////////////// /// pay package via paypal recuring-jslint checked //////////////////////////////////////////////////////////////////////////////////////////// function wpestate_recuring_pay_pack_via_paypal() { "use strict"; var ajaxurl, packName, packId; ajaxurl = control_vars.admin_url + 'admin-ajax.php'; packName = jQuery('.package_selected .pack-listing-title').text(); packId = jQuery('.package_selected .pack-listing-title').attr('data-packid'); var nonce = jQuery('#wpestate_payments_nonce').val(); jQuery.ajax({ type: 'POST', url: ajaxurl, data: { 'action': 'wpestate_ajax_paypal_pack_recuring_generation_rest_api', 'packName': packName, 'packId': packId, 'security': nonce }, success: function (data) { window.location.href = data; }, error: function (errorThrown) { } });//end ajax } jQuery(".buypackage").click(function () { "use strict"; var stripe_pack_id, stripetitle2, stripetitle, stripepay; jQuery(".pack-listing").removeClass("package_selected"); jQuery(".pack-listing input").prop('checked', false); jQuery(this).find('.input_pak_check').prop('checked', true); jQuery(this).parent().addClass("package_selected"); stripetitle = jQuery(this).parent().find('.pack-listing-title').attr('data-stripetitle'); stripetitle2 = jQuery(this).parent().find('.pack-listing-title').attr('data-stripetitle2'); stripepay = jQuery(this).parent().find('.pack-listing-title').attr('data-stripepay'); stripe_pack_id = jQuery(this).parent().find('.pack-listing-title').attr('data-packid'); jQuery('.stripe_buttons').attr("id", stripetitle2); jQuery('#stripe_script').attr("data-amount", stripepay); jQuery('#stripe_script').attr("data-description", stripetitle); jQuery('#pack_id').val(stripe_pack_id); jQuery('#pack_title').val(stripetitle2); jQuery('#pay_ammout').val(stripepay); jQuery('#stripe_form').attr('data-amount', stripepay); jQuery('.wpestate_stripe_pay_desc').html(control_vars.stripe_pay_for + " " + stripetitle2); jQuery('#wpestate_stripe_form_button_sumit').html(control_vars.stripe_pay + " " + stripepay / 100 + " " + control_vars.submission_curency); // enable stripe code }); //////////////////////////////////////////////////////////////////////////////////////////// /// pay package via paypal-jslint checked //////////////////////////////////////////////////////////////////////////////////////////// function wpestate_pay_pack_via_paypal() { "use strict"; var ajaxurl, packName, packId; ajaxurl = control_vars.admin_url + 'admin-ajax.php'; packName = jQuery('.package_selected .pack-listing-title').text(); packId = jQuery('.package_selected .pack-listing-title').attr('data-packid'); var nonce = jQuery('#wpestate_payments_nonce').val(); jQuery.ajax({ type: 'POST', url: ajaxurl, data: { 'action': 'wpestate_ajax_paypal_pack_generation', 'packName': packName, 'packId': packId, 'security': nonce }, success: function (data) { window.location.href = data; }, error: function (errorThrown) { } });//end ajax } //////////////////////////////////////////////////////////////////////////////////////////// /// listing pay -jslint checked //////////////////////////////////////////////////////////////////////////////////////////// function wpestate_listing_pay(prop_id, selected_div, is_featured, is_upgrade) { "use strict"; var ajaxurl = control_vars.admin_url + 'admin-ajax.php'; var nonce = jQuery('#wpestate_payments_nonce').val(); jQuery.ajax({ type: 'POST', url: ajaxurl, data: { 'action': 'wpestate_ajax_listing_pay', 'propid': prop_id, 'is_featured': is_featured, 'is_upgrade': is_upgrade, 'security': nonce }, success: function (data) { window.location.href = data; }, error: function (errorThrown) { } });//end ajax } //////////////////////////////////////////////////////////////////////////////////////////// /// start filtering -jslint checked //////////////////////////////////////////////////////////////////////////////////////////// function wpestate_start_filtering(newpage) { "use strict"; jQuery('#gmap-loading').show(); jQuery('#grid_view').addClass('icon_selected'); jQuery('#list_view').removeClass('icon_selected'); var action, category, county, city, area, order, ajaxurl, page_id; // get action vars action = jQuery('#a_filter_action').attr('data-value'); // get category category = jQuery('#a_filter_categ').attr('data-value'); // get county county = jQuery('#a_filter_county').attr('data-value'); // get city city = jQuery('#a_filter_cities').attr('data-value'); // get area area = jQuery('#a_filter_areas').attr('data-value'); // get order order = jQuery('#a_filter_order').attr('data-value'); ajaxurl = ajaxcalls_vars.wpestate_ajax; page_id = jQuery('#page_idx').val(); var card_version = jQuery('.wpestate_filter_list_properties_wrapper').attr('data-card_version'); var rownumber = jQuery('.wpestate_filter_list_properties_wrapper').attr('data-rownumber'); var ishortcode = jQuery('.wpestate_filter_list_properties_wrapper').attr('data-ishortcode'); var number = jQuery('.wpestate_filter_list_properties_wrapper').attr('data-number'); var align = ''; if (jQuery('.wpestate_filter_list_properties_wrapper').length > 0) { jQuery('.wpestate_filter_list_properties_wrapper .listing_wrapper').remove(); jQuery('.wpestate_filter_list_properties_wrapper .pagination_ajax').remove(); jQuery('.wpestate_filter_list_properties_wrapper .no_results').remove(); align = jQuery('.wpestate_filter_list_properties_wrapper').attr('data-align'); jQuery('#listing_loader2').show(); } else { jQuery('#listing_ajax_container').empty(); jQuery('#listing_loader').show(); } var nonce = jQuery('#wpestate_ajax_filtering').val(); jQuery.ajax({ type: 'POST', url: ajaxurl, dataType: 'json', data: { 'action': 'wpestate_ajax_filter_listings', 'action_values': action, 'category_values': category, 'county': county, 'city': city, 'area': area, 'order': order, 'newpage': newpage, 'page_id': page_id, 'align': align, 'card_version': card_version, 'rownumber': rownumber, 'ishortcode': ishortcode, 'number':number, 'security': nonce }, success: function (data) { jQuery('#listing_loader').hide(); if (jQuery('.wpestate_filter_list_properties_wrapper').length > 0) { jQuery('#listing_loader2').hide(); jQuery('.wpestate_filter_list_properties_wrapper').append(data.to_show); } else { jQuery('#listing_ajax_container').empty().append(data.to_show); } jQuery('.pagination_nojax').hide(); wpestate_restart_js_after_ajax(); // map update var no_results = parseInt(data.no_results); if (no_results !== 0) { wpestate_load_on_demand_pins(data.markers, no_results, 0); } else { wpestate_show_no_results(); } jQuery('.col-md-12.listing_wrapper .property_unit_custom_element.image').each(function () { jQuery(this).parent().addClass('wrap_custom_image'); }); jQuery('#gmap-loading').hide(); }, error: function (errorThrown) { } });//end ajax } //////////////////////////////////////////////////////////////////////////////////////////// /// change pass on profile-jslint checked //////////////////////////////////////////////////////////////////////////////////////////// function wpestate_change_pass_profile() { "use strict"; var oldpass, newpass, renewpass, securitypass, ajaxurl; oldpass = jQuery('#oldpass').val(); newpass = jQuery('#newpass').val(); renewpass = jQuery('#renewpass').val(); securitypass = jQuery('#security-pass').val(); ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; jQuery.ajax({ type: 'POST', url: ajaxurl, data: { 'action': 'wpestate_ajax_update_pass', 'oldpass': oldpass, 'newpass': newpass, 'renewpass': renewpass, 'security-pass': securitypass }, success: function (data) { jQuery('#profile_pass').empty().append('
' + data + '
'); jQuery('#oldpass, #newpass, #renewpass').val(''); }, error: function (errorThrown) { } }); } //////////////////////////////////////////////////////////////////////////////////////////// /// user register -jslint checked //////////////////////////////////////////////////////////////////////////////////////////// function wpestate_register_user(type) { "use strict"; var capthca, user_login_register, user_email_register, user_pass, user_pass_retype, nonce, ajaxurl, new_user_type; /* 1- topbar * 2- widget * 3- shortcode * 4- modal !? * 5 -mobile */ capthca = ''; ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; jQuery('#register_message_area_topbar').empty().append(''); if (type === 1) { if (control_vars.usecaptcha === 'yes') { capthca = grecaptcha.getResponse( widgetId1 ); } user_login_register = jQuery('#user_login_register_topbar').val(); user_email_register = jQuery('#user_email_register_topbar').val(); nonce = jQuery('#security-register-topbar').val(); if (ajaxcalls_vars.userpass === 'yes') { user_pass = jQuery('#user_password_topbar').val(); user_pass_retype = jQuery('#user_password_topbar_retype').val(); } new_user_type = jQuery('#new_user_type_topbar').val(); if (!jQuery('#user_terms_register_topbar').is(":checked")) { jQuery('#register_message_area_topbar').empty().append(''); return; } if(jQuery('#new_user_type_topbar').length>0 ){ var user_type_value= parseInt (jQuery('#new_user_type_topbar').val(),10); if( user_type_value===0 ){ jQuery('#register_message_area_topbar').empty().append(''); return; } } } else if (type === 2) { if (control_vars.usecaptcha === 'yes') { capthca = grecaptcha.getResponse( widgetId3 ); } user_login_register = jQuery('#user_login_register_wd').val(); user_email_register = jQuery('#user_email_register_wd').val(); nonce = jQuery('#security-register').val(); if (ajaxcalls_vars.userpass === 'yes') { user_pass = jQuery('#user_password_wd').val(); user_pass_retype = jQuery('#user_password_wd_retype').val(); } new_user_type = jQuery('#new_user_type_wd').val(); if (!jQuery('#user_terms_register_wd').is(":checked")) { jQuery('#register_message_area_wd').empty().append(''); return; } if(jQuery('#new_user_type_wd').length>0 ){ var user_type_value= parseInt (jQuery('#new_user_type_wd').val(),10); if( user_type_value===0 ){ jQuery('#register_message_area_wd').empty().append(''); return; } } } else if (type === 3) { if (control_vars.usecaptcha === 'yes') { capthca = grecaptcha.getResponse( widgetId4 ); } user_login_register = jQuery('#user_login_register').val(); user_email_register = jQuery('#user_email_register').val(); nonce = jQuery('#security-register').val(); if (ajaxcalls_vars.userpass === 'yes') { user_pass = jQuery('#user_password').val(); user_pass_retype = jQuery('#user_password_retype').val(); } new_user_type = jQuery('#new_user_type').val(); if (!jQuery('#user_terms_register_sh').is(":checked")) { jQuery('#register_message_area').empty().append(''); return; } if(jQuery('#new_user_type').length>0 ){ var user_type_value= parseInt (jQuery('#new_user_type').val(),10); if( user_type_value===0 ){ jQuery('#register_message_area').empty().append(''); return; } } } else if (type === 5) { if (control_vars.usecaptcha === 'yes') { capthca = grecaptcha.getResponse( widgetId2 ); } user_login_register = jQuery('#user_login_register_mobile').val(); user_email_register = jQuery('#user_email_register_mobile').val(); nonce = jQuery('#security-register-mobile').val(); if (ajaxcalls_vars.userpass === 'yes') { user_pass = jQuery('#user_password_mobile').val(); user_pass_retype = jQuery('#user_password_mobile_retype').val(); } new_user_type = jQuery('#new_user_type_mobile').val(); if (!jQuery('#user_terms_register_mobile').is(":checked")) { jQuery('#register_message_area_mobile').empty().append(''); return; } if(jQuery('#new_user_type_mobile').length>0 ){ var user_type_value= parseInt (jQuery('#new_user_type_mobile').val(),10); if( user_type_value===0 ){ jQuery('#register_message_area_mobile').empty().append(''); return; } } } var nonce = jQuery('#wpestate_ajax_log_reg').val(); jQuery.ajax({ type: 'POST', dataType: 'json', url: ajaxurl, data: { 'action': 'wpestate_ajax_register_user', 'user_login_register': user_login_register, 'user_email_register': user_email_register, 'user_pass': user_pass, 'user_pass_retype': user_pass_retype, 'type': type, 'security': nonce, 'capthca': capthca, 'new_user_type': new_user_type }, success: function (data) { // This outputs the result of the ajax request if (type === 1) { jQuery('#register_message_area_topbar').empty().append(''); jQuery('#user_login_register_topbar').val(''); jQuery('#user_email_register_topbar').val(''); jQuery('#user_password_topbar').val(''); jQuery('#user_password_topbar_retype').val(''); jQuery('#new_user_type_topbar').val('0'); if(data.register==true ){ setTimeout(function(){ jQuery('#widget_login_topbar').trigger('click') }, 1500); } } else if (type === 2) { jQuery('#register_message_area_wd').empty().append(''); jQuery('#user_login_register_wd').val(''); jQuery('#user_email_register_wd').val(''); jQuery('#user_password_wd').val(''); jQuery('#user_password_wd_retype').val(''); jQuery('#new_user_type_wd').val('0'); if(data.register==true ){ setTimeout(function(){ jQuery('#widget_login_sw').trigger('click') }, 1500); } } else if (type === 3) { jQuery('#register_message_area').empty().append(''); jQuery('#user_login_register').val(''); jQuery('#user_email_register').val(''); jQuery('#user_password').val(''); jQuery('#user_password_retype').val(''); jQuery('#new_user_type').val('0'); } else if (type === 5) { jQuery('#register_message_area_mobile').empty().append(''); jQuery('#user_login_register_mobile').val(''); jQuery('#user_email_register_mobile').val(''); jQuery('#user_password_mobile').val(''); jQuery('#user_password_mobile_retype').val(''); jQuery('#new_user_type_mobile').val('0'); if(data.register==true ){ setTimeout(function(){ jQuery('#widget_login_mobile').trigger('click') }, 1500); } } }, error: function (errorThrown) { } }); } //////////////////////////////////////////////////////////////////////////////////////////// /// on ready -jslint checked //////////////////////////////////////////////////////////////////////////////////////////// function wpestate_forgot(type) { "use strict"; var forgot_email, securityforgot, postid, ajaxurl; postid = jQuery('#postid').val(); if (type === 1) { forgot_email = jQuery('#forgot_email').val(); securityforgot = jQuery('#security-forgot').val(); } if (type === 2) { forgot_email = jQuery('#forgot_email_topbar').val(); securityforgot = jQuery('#security-forgot-topbar').val(); } if (type === 3) { forgot_email = jQuery('#forgot_email_shortcode').val(); securityforgot = jQuery('#security-login-forgot_wd').val(); } if (type === 5) { forgot_email = jQuery('#forgot_email_mobile').val(); securityforgot = jQuery('#security-forgot-mobile').val(); postid = jQuery('#postid-mobile').val(); } postid = jQuery('#postid').val(); ajaxurl = ajaxcalls_vars.admin_url + 'admin-ajax.php'; var nonce = jQuery('#wpestate_ajax_log_reg').val(); jQuery.ajax({ type: 'POST', url: ajaxurl, data: { 'action': 'wpestate_ajax_forgot_pass', 'forgot_email': forgot_email, 'security': nonce, 'postid': postid, 'type': type, 'security': nonce }, success: function (data) { if (type === 1) { jQuery('#forgot_email').val(''); jQuery('#forgot_pass_area').empty().append('