// loading spinner var opts = { lines: 13, // The number of lines to draw length: 9, // The length of each line width: 9, // The line thickness radius: 27, // The radius of the inner circle corners: 1, // Corner roundness (0..1) rotate: 0, // The rotation offset color: '#FFF', // #rgb or #rrggbb speed: 1.8, // Rounds per second trail: 81, // Afterglow percentage shadow: true, // Whether to render a shadow hwaccel: false, // Whether to use hardware acceleration className: 'spinner', // The CSS class to assign to the spinner zIndex: 2e9, // The z-index (defaults to 2000000000) top: 'auto', // Top position relative to parent in px left: 'auto' // Left position relative to parent in px }; var target = document.getElementById('directory-main-bar'), spinner = new Spinner(opts).spin(target), spinnerDiv = mapDiv.find('.spinner'); var search = $('#directory-search'), searchInput = $('#dir-searchinput-text'), searchSubmit = $('#dir-searchsubmit'), categoryInput = $('#dir-searchinput-category'), locationInput = $('#dir-searchinput-location'), geoInput = $('#dir-searchinput-geo'), geoInputRadius = $('#dir-searchinput-geo-radius'), geoInputLat = $('#dir-searchinput-geo-lat'), geoInputLng = $('#dir-searchinput-geo-lng'); function showLoading(disableSubmit) { var topPosition = mapDiv.height() / 2; spinnerDiv.css('top',topPosition+'px').fadeIn(); if (disableSubmit) { searchSubmit.attr('disabled', true); } } function hideLoading() { spinnerDiv.fadeOut(); searchSubmit.attr('disabled', false); } // set interactive search if(search.data('interactive') == 'yes'){ searchInput.typeWatch({ callback: function() { ajaxGetMarkers(true,false); }, wait: 500, highlight: false, captureLength: 0 }); categoryInput.on("autocompleteselect", function( event, ui ) { ajaxGetMarkers(true,false,ui.item.value,false); }); locationInput.on("autocompleteselect", function( event, ui ) { ajaxGetMarkers(true,false,false,ui.item.value); }); categoryInput.on("autocompleteclose", function( event, ui ) { if($('#dir-searchinput-category-id').val() == '0'){ ajaxGetMarkers(true,false); } }); locationInput.on("autocompleteclose", function( event, ui ) { if($('#dir-searchinput-location-id').val() == '0'){ ajaxGetMarkers(true,false); } }); } $('#dir-searchinput-settings .icon').click(function() { $('#dir-search-advanced').toggle(); }); $('#dir-search-advanced-close').click(function() { $('#dir-search-advanced').hide(); }); $('#dir-search-advanced .value-slider').slider({ value: geoInputRadius.val(), min: {ifset $themeOptions->search->advancedSearchMinValue}{$themeOptions->search->advancedSearchMinValue}{else}5{/ifset}, max: {ifset $themeOptions->search->advancedSearchMaxValue}{$themeOptions->search->advancedSearchMaxValue}{else}2000{/ifset}, step: {ifset $themeOptions->search->advancedSearchStepValue}{$themeOptions->search->advancedSearchStepValue}{else}5{/ifset}, change: function(event, ui) { if(search.data('interactive') == 'yes' && geoInput.is(':checked')){ ajaxGetMarkers(true,false); } }, slide: function(event, ui) { geoInputRadius.val(ui.value); } }); // Geolocation geoInput.FancyCheckbox(); function enableGeo() { geoInput.attr('checked', true); geoInput.next().removeClass('off').addClass('on'); } function disableGeo() { geoInput.attr('checked', false); geoInput.next().removeClass('on').addClass('off'); } {if isset($isGeolocation, $_GET['geo-lat'], $_GET['geo-lng'], $_GET['geo-radius'])} generateOnlyGeo({$_GET['geo-lat']},{$_GET['geo-lng']},{$_GET['geo-radius']}); {else} if(geoInput.is(":checked")) { // enable after user allow geolocation disableGeo(); showLoading(true); if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { geoInputLat.val(position.coords.latitude); geoInputLng.val(position.coords.longitude); enableGeo(); ajaxGetMarkers(true,false); }, function(error){ disableGeo(); hideLoading(); }); } else { disableGeo(); hideLoading(); } } {/if} geoInput.on("change",function(event) { if(geoInput.is(":checked")) { // enable after user allow geolocation disableGeo(); showLoading(true); if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { geoInputLat.val(position.coords.latitude); geoInputLng.val(position.coords.longitude); enableGeo(); if(search.data('interactive') == 'yes'){ ajaxGetMarkers(true,false); } else { hideLoading(); } }, function(error){ disableGeo(); hideLoading(); }); } else { disableGeo(); hideLoading(); } } else { if(search.data('interactive') == 'yes'){ ajaxGetMarkers(true,false); } } }); function ajaxGetMarkers(ajax,geoloc,rewriteCategory,rewriteLocation,reset) { showLoading(); radius = new Array(); var category = 0; var location = 0; var search = ''; var locale = '