View
Normal
Midnight
Family Fest
Open dark
Riverside
Ozan
My Location
Fullscreen
Advanced Search (10)
Featured
Compact ,Premium $100.00 $50.00 /day
Compact ,Premium $45.00 /day
Compact ,Premium $45.00 /day
Premium $400.00 $200.00 /day
Premium $90.00 $45.00 /day
" +
"" +
"" +
"" +
"" +
"" +
"" +
"");
gdlm_ls_init_suggestions($input);
gdlm_ls_current_location_suggestion($input);
}
// resize
gdls_ls_resize_suggestions();
// set if is search near
if(jQuery('.gdlm-location-suggestions:visible').prev().hasClass('snear') || jQuery($input).hasClass('snear')){
gdlmls_is_search = true;
}else{
gdlmls_is_search = false;
}
}
function gdlm_ls_focus_out($input) {
setTimeout(function() {
_ua = navigator.userAgent.toLowerCase();
isChrome = /chrome/.test(_ua);
isWin10 = /windows nt 10.0/.test(_ua);
if (!gdlmls_do_not_close) {
jQuery($input).parent().find(".gdlm-location-suggestions").hide(); }
}, 200);
}
/**
* Set the max height for the suggestion div so to never scroll past the bottom of the page.
*/
function gdls_ls_resize_suggestions() {
setTimeout(function() {
if (jQuery('.gdlm-location-suggestions:visible').length) {
var offset = jQuery('.gdlm-location-suggestions:visible').offset().top;
var windowHeight = jQuery(window).height();
var maxHeight = windowHeight - (offset - jQuery(window).scrollTop());
if (jQuery('.gdlm-location-suggestions:visible').prev().hasClass('snear')) {
jQuery('.gdlm-location-suggestions:visible').css('max-height', windowHeight - 40);
} else {
jQuery('.gdlm-location-suggestions:visible').css('max-height', maxHeight);
}
}
}, 50);
}
function gdlm_ls_init_suggestions($input) {
setTimeout(function() {
gdls_ls_resize_suggestions();
}, 250);
jQuery($input).keyup(function($input) {
gdlmls_doing_search = 3; // city, region, country
if (gdlmls_keyup_timeout != null) clearTimeout(gdlmls_keyup_timeout);
gdlmls_keyup_timeout = setTimeout(gdlm_ls_maybe_fire_suggestions, 500);
});
}
function gdlm_ls_maybe_fire_suggestions(){
// reset timer
gdlmls_keyup_timeout = null;
// do suggestions
gdlm_ls_current_location_suggestion();
_value = gdlmls_selected ? jQuery(gdlmls_selected).val() : '';
_chars = parseInt( geodir_location_params.autocompleter_min_chars );
if ( ! _value || _chars < 1 || ( _chars > 0 && _value && parseInt( _value.length ) >= _chars ) ) {
gdlm_ls_city_suggestion();
gdlm_ls_region_suggestion(); gdlm_ls_country_suggestion(); }
}
function gdlm_ls_maybe_suggest_more() {
if (
gdlmls_doing_search == 0 &&
gdlmls_country.length == 0 &&
gdlmls_region.length == 0 &&
gdlmls_city.length == 0 &&
gdlmls_neighbourhood.length == 0
) {
$input = jQuery(gdlmls_selected).val();
if ($input) {
if ((typeof google !== 'undefined' && typeof google.maps !== 'undefined')) {
gdlm_ls_google_suggestions($input);
}
} else {
jQuery(gdlmls_selected).parent().find("ul.gdlmls-more").empty();
}
}
}
function gdlm_ls_neighbourhood_suggestion() {
var $search = jQuery(gdlmls_selected).val();
if ($search) {
jQuery.ajax({
type: "GET",
url: geodir_params.api_url + "locations/neighbourhoods/?search=" + $search,
success: function(data) {
gdlmls_neighbourhood = data;
gdlmls_doing_search--;
gdlm_ls_maybe_suggest_more();
html = '';
jQuery.each(gdlmls_neighbourhood, function(index, value) {
html = html + gdlm_ls_create_li('neighbourhood', value);
});
jQuery(gdlmls_selected).parent().find("ul.gdlmls-neighbourhood").empty().append(html);
},
error: function(xhr, textStatus, errorThrown) {
console.log(errorThrown);
}
});
} else {
gdlmls_neighbourhood = [];
gdlmls_doing_search--;
gdlm_ls_maybe_suggest_more();
jQuery(gdlmls_selected).parent().find("ul.gdlmls-city").empty();
}
}
function gdlm_ls_city_suggestion() {
var $search = jQuery(gdlmls_selected).val();
if ($search) {
jQuery.ajax({
type: "GET",
url: geodir_params.api_url + "locations/cities/?search=" + $search,
success: function(data) {
gdlmls_city = data;
gdlmls_doing_search--;
gdlm_ls_maybe_suggest_more();
html = '';
jQuery.each(gdlmls_city, function(index, value) {
html = html + gdlm_ls_create_li('city', value);
});
jQuery(gdlmls_selected).parent().find("ul.gdlmls-city").empty().append(html);
},
error: function(xhr, textStatus, errorThrown) {
console.log(errorThrown);
}
});
} else {
gdlmls_city = [];
gdlmls_doing_search--;
gdlm_ls_maybe_suggest_more();
jQuery(gdlmls_selected).parent().find("ul.gdlmls-city").empty();
}
}
function gdlm_ls_region_suggestion() {
var $search = jQuery(gdlmls_selected).val();
if ($search) {
jQuery.ajax({
type: "GET",
url: geodir_params.api_url + "locations/regions/?search=" + $search,
success: function(data) {
gdlmls_region = data;
gdlmls_doing_search--;
gdlm_ls_maybe_suggest_more();
html = '';
jQuery.each(gdlmls_region, function(index, value) {
html = html + gdlm_ls_create_li('region', value);
});
jQuery(gdlmls_selected).parent().find("ul.gdlmls-region").empty().append(html);
},
error: function(xhr, textStatus, errorThrown) {
console.log(errorThrown);
}
});
} else {
gdlmls_region = [];
gdlmls_doing_search--;
gdlm_ls_maybe_suggest_more();
jQuery(gdlmls_selected).parent().find("ul.gdlmls-region").empty();
}
}
function gdlm_ls_country_suggestion() {
var $search = jQuery(gdlmls_selected).val();
if ($search) {
jQuery.ajax({
type: "GET",
url: geodir_params.api_url + "locations/countries/?search=" + $search,
success: function(data) {
gdlmls_country = data;
gdlmls_doing_search--;
gdlm_ls_maybe_suggest_more();
html = '';
jQuery.each(gdlmls_country, function(index, value) {
html = html + gdlm_ls_create_li('country', value);
});
jQuery(gdlmls_selected).parent().find("ul.gdlmls-country").empty().append(html);
},
error: function(xhr, textStatus, errorThrown) {
console.log(errorThrown);
}
});
} else {
gdlmls_country = [];
gdlmls_doing_search--;
gdlm_ls_maybe_suggest_more();
jQuery(gdlmls_selected).parent().find("ul.gdlmls-country").empty();
}
}
function gdlm_ls_current_location_suggestion() {
jQuery(gdlmls_selected).parent().find("ul.gdlmls-near").empty();
// Near me
jQuery(gdlmls_selected).parent().find("ul.gdlmls-near").empty().append(gdlm_ls_create_li('near', {
type: "near",
slug: "me",
title: geodir_params.txt_form_my_location
}));
if (jQuery(gdlmls_selected).val() == '') {
var $search_history = JSON.parse(gdlm_ls_get_location_history());
if ($search_history) {
jQuery.each($search_history, function(index, value) {
jQuery(gdlmls_selected).parent().find("ul.gdlmls-near").append(gdlm_ls_create_li(value.type, value));
});
}
if ( ! geodir_location_params.disable_nearest_cities ) {
// Add near cities from ip
gdlm_ls_nearest_cities();
}
}
console.log(JSON.parse(gdlm_ls_get_location_history()));
}
function gdlm_ls_nearest_cities() {
if(!gdlmls_doing_nearest){
gdlmls_doing_nearest = true;
jQuery.ajax({
type: "GET",
url: geodir_params.api_url + "locations/cities/?orderby=ip",
success: function(data) {
if (data) {
jQuery.each(data, function(index, value) {
jQuery(gdlmls_selected).parent().find("ul.gdlmls-near").append(gdlm_ls_create_li('city', value));
});
}
gdlmls_doing_nearest = false;
},
error: function(xhr, textStatus, errorThrown) {
console.log(errorThrown);
gdlmls_doing_nearest = false;
}
});
}
}
function gdlm_ls_create_li($type,$data){
var output;
var history = '';
var $delete = '';
var $common_class = '';
if($data.history){
history = '
';
$delete = '
';
}else if($type == 'neighbourhood' || $type == 'city' || $type == 'region' || $type == 'country'){
history = '
';
}
console.log($data);
if($type=='neighbourhood'){
if($data.area){$data.city = $data.area;}
output = '
'+history+'In: '+ $data.title + ', '+ $data.city + ' (Neighbourhood)'+$delete+'';
}else if($type=='city'){
if($data.area){$data.region = $data.area;}
output = '
'+history+'In: '+ $data.title + ', '+$data.region+' (City)'+$delete+'';
}else if($type=='region'){
if($data.area){$data.country = $data.area;}
output = '
'+history+'In: '+ $data.title + ', '+$data.country+' (Region)'+$delete+'';
}else if($type=='country'){
output = '
'+history+'In: '+ $data.title + ' (Country)'+$delete+'';
}else if($type=='near'){
output = '
Near: '+ $data.title + '';
}else if($type=='near-search'){
output = '
Near: '+ $data.description + '';
}
return output;
}
function gdlm_click_action($type,$title,$area,$country_slug,$region_slug,$city_slug,$hood_slug){
if(gdlmls_is_search){
if($type=='neighbourhood' || $type=='city' || $type=='region' || $type=='country'){
$slug = '';
if($type=='neighbourhood'){$slug = $hood_slug;}
else if($type=='city'){$slug = $city_slug;}
else if($type=='region'){$slug = $region_slug;}
else if($type=='country'){$slug = $country_slug;}
gdlm_search_fill_location($type,$slug,$title);
}else if($type=='near-search'){
gdlm_search_fill_location($type,'',$title);
}else if($type=='near'){
gd_get_user_position(gdlm_search_near_me);
}
}else{
if($type=='neighbourhood' || $type=='city' || $type=='region' || $type=='country'){
gdlm_go_location($type,$title,$area,$country_slug,$region_slug,$city_slug,$hood_slug);
}else if($type=='near-search'){
gdlm_go_search($title);
}else if($type=='near'){
gd_get_user_position(gdlm_ls_near_me);
}
}
setTimeout(function() {
_ua = navigator.userAgent.toLowerCase();
isChrome = /chrome/.test(_ua);
isWin10 = /windows nt 10.0/.test(_ua);
if (isChrome && isWin10) {
jQuery(".gdlm-location-suggestions").hide();
}
},200);
}
function gdlm_ls_near_me($lat,$lon){
window.location = geodir_params.location_base_url+"near/me/"+$lat+","+$lon+"/";
}
function gdlm_ls_near_gps($lat,$lon){
window.location = geodir_params.location_base_url+"near/gps/"+$lat+","+$lon+"/";
}
function gdlm_search_near_me($lat,$lon){
gdlm_search_fill_location('near','me',"Near: "+geodir_params.txt_form_my_location,$lat,$lon)
}
function gdlm_search_fill_location($type,$slug,$title,$lat,$lon){
if($type=='near'){
}else if($type=='near-search'){
$type='';
}else{
var txtType;
if ($type == 'country') {
txtType = '(Country)';
} else if ($type == 'region') {
txtType = '(Region)';
} else if ($type == 'city') {
txtType = '(City)';
} else if ($type == 'neighbourhood') {
txtType = '(Neighbourhood)';
} else {
txtType = "("+$type+")";
}
$title = "In: "+$title+" "+txtType;
}
jQuery('.geodir-location-search-type').val($slug).attr('name', $type);
jQuery('.sgeo_lat').val($lat);
jQuery('.sgeo_lon').val($lon);
jQuery('.snear').val($title).trigger('change'); // fire change event so we can check if we need to add in-location class
//gdlm_set_is_location();
}
function gdlm_go_search($text){
//alert($text);
if (window.gdMaps === 'google') {
var geocoder = new google.maps.Geocoder();
geocoder.geocode({'address': $text},
function (results, status) {
if (status == 'OK') {
// console.log(results);
$lat = results[0].geometry.location.lat();
$lon = results[0].geometry.location.lng();
gdlm_ls_near_gps($lat,$lon);
} else {
alert("Search was not successful for the following reason :" + status);
}
});
} else if (window.gdMaps === 'osm') {
geocodePositionOSM(false, $text, false, false,
function(geo) {
if (typeof geo !== 'undefined' && geo.lat && geo.lon) {
console.log(results);
} else {
alert("Search was not successful for the requested address.");
}
});
}
}
function gdlm_ls_search_location($type,$term){
jQuery.ajax({
type: "GET",
url: geodir_params.api_url+$type+"/?search="+$term,
success: function(data) {
console.log(data);
return data;
//jQuery('#' + map_canvas_var + '_loading_div').hide();
//parse_marker_jason(data, map_canvas_var);
},
error: function(xhr, textStatus, errorThrown) {
console.log(errorThrown);
}
});
}
function gdlm_go_location($type,$title,$area,$country_slug,$region_slug,$city_slug,$hood_slug){
// save search history before redirect
gdlm_ls_set_location_history($type,$title,$area,$country_slug,$region_slug,$city_slug,$hood_slug);
window.location = gdlm_ls_location_url($country_slug,$region_slug,$city_slug,$hood_slug);
// console.log( gdlm_ls_location_url($country_slug,$region_slug,$city_slug,$hood_slug));
}
function gdlm_ls_location_url($country_slug,$region_slug,$city_slug,$hood_slug){
//$url = geodir_params.location_url.slice(0, -1); // get location url without the ending slash
$url = geodir_params.location_base_url; // get location url without the ending slash
var show_country = 1;
var show_region = 1;
var show_city = 1;
var show_hood = 0;
if(show_country && $country_slug){
$url += ""+$country_slug+"/";
}
if(show_region && $region_slug){
$url += ""+$region_slug+"/";
}
if(show_city && $city_slug){
$url += ""+$city_slug+"/";
}
if(show_hood && $hood_slug){
$url += ""+$hood_slug+"/";
}
return $url;
}
function gdlm_ls_get_location_history(){
if (geodir_is_localstorage() === true) {
return gdlm_ls_history = localStorage.getItem("gdlm_ls_history");
}else{
return '';
}
}
function gdlm_ls_del_location_history($slug){
gdlmls_do_not_close = true;
if (geodir_is_localstorage() === true) {
gdlm_ls_history = JSON.parse(localStorage.getItem("gdlm_ls_history"));
var found = '';
console.log(gdlm_ls_history);
jQuery.each(gdlm_ls_history, function(index, value) {
if($slug && $slug==value.slug){
// its already in the list so bail.
//gdlm_ls_history.splice(index, 1);
found = index;
}
});
if(found!==''){
gdlm_ls_history.splice(found, 1);
// store the user selection
localStorage.setItem("gdlm_ls_history", JSON.stringify(gdlm_ls_history));
}
}
setTimeout(function(){gdlmls_do_not_close = false;}, 200);
}
function gdlm_ls_set_location_history($type,$title,$area,$country_slug,$region_slug,$city_slug,$hood_slug){
// set a searched location
if (geodir_is_localstorage() === true) {
var gdlm_ls_history = localStorage.getItem("gdlm_ls_history");
var $exists = false;
if (!gdlm_ls_history || gdlm_ls_history === undefined) {
gdlm_ls_history = []
}else{
gdlm_ls_history = JSON.parse(gdlm_ls_history);
jQuery.each(gdlm_ls_history, function(index, value) {
console.log(value);
if(value.type == $type && value.title==$title){
// its already in the list so bail.
$exists = true;
}
});
}
if(!$exists){
$slug = $city_slug;
if($type=='neighbourhood'){
$slug = $hood_slug;
}if($type=='city'){
$slug = $city_slug;
}else if($type=='region'){
$slug = $region_slug;
}else if($type=='country'){
$slug = $country_slug;
}
var $location = {
history:true, // set it as historical
type:$type,
title:$title,
country_slug:$country_slug,
region_slug:$region_slug,
city_slug:$city_slug,
hood_slug:$hood_slug,
slug:$slug,
area:$area
};
console.log(gdlm_ls_history);
console.log($location);
gdlm_ls_history.unshift($location);
// gdlm_ls_history = $location;
// only keep latest 5 searches
if(gdlm_ls_history.length > 5){
gdlm_ls_history.pop();
}
}
// store the user selection
localStorage.setItem("gdlm_ls_history", JSON.stringify(gdlm_ls_history));
}
}
function gdlm_ls_google_suggestions($search){
// Create a new session token.
if(!gdlmls_google_sessionToken){
gdlmls_google_sessionToken = new google.maps.places.AutocompleteSessionToken();
}
// display function
var displaySuggestions = function(predictions, status) {
if (status != google.maps.places.PlacesServiceStatus.OK) {
return;
}
console.log(predictions);
html = '';
predictions.forEach(function(prediction) {
html = html + gdlm_ls_create_li('near-search', prediction);
});
jQuery(gdlmls_selected).parent().find("ul.gdlmls-more").empty().append(html);
};
if(!gdlmls_google_service){
gdlmls_google_service = new google.maps.places.AutocompleteService();
}
gdlmls_google_service.getPlacePredictions({
input: $search,
sessionToken: gdlmls_google_sessionToken,
types: ['geocode'] // restrict to locations not establishments
//@todo implement country restrictions: https://developers.google.com/maps/documentation/javascript/reference/3/places-widget#ComponentRestrictions
}, displaySuggestions);
}
function gdlm_ls_slashit(str) {
if (str) {
str = str.replace(/'/g, "\\'");
}
return str;
}
/**
* Open the location switcher
*/
function geodir_lm_setup_switcher_trigger(){
var no_show = false;
// Clear the location and redirect to the base location page
jQuery(".gdlmls-menu-icon").click(function(event){
no_show = true;
event.preventDefault();
window.location = geodir_params.location_base_url;
});
// detect the menu item location switcher click
jQuery('a[href$="#location-switcher"]').click(function(event){
// prevent the hash being added to the url
event.preventDefault();
// only fire if the click is not the clear location button.
if(!no_show){
// init the lightbox
$lightbox = lity('.geodir-location-search-wrap');
// add class so we can position
jQuery($lightbox.element()).addClass('geodir-location-switcher-lightbox');
// set the focus on the input so it auto loads the nearest cities
jQuery('.lity-content .geodir-location-search').focus();
}
});
}
jQuery(document).ready(function() {geodir_lm_setup_switcher_trigger()});