Permalink
Browse files

Add delay to LocationSelector autocompletes to reduce unnecessary ser…

…ver load
  • Loading branch information...
1 parent d1da5e6 commit 81ec66a63f723448432d5b399cedc1523f1d16f2 @flavour flavour committed Oct 7, 2012
View
@@ -1 +1 @@
-f138390 (2012-10-04 19:26:09)
+d1da5e6 (2012-10-07 10:06:42)
@@ -11,7 +11,7 @@ $(function() {
});
function s3_gis_locationselector_jQuery_onReady() {
- if ( typeof(S3.gis.location_id) == 'undefined' ) {
+ if (typeof(S3.gis.location_id) == 'undefined') {
// This page doesn't include the Location Selector Widget
} else {
// Hide the Label row
@@ -170,6 +170,7 @@ function s3_gis_autocomplete(level) {
if (undefined != $('#gis_location_L' + level + '_ac').val()) {
$('#gis_location_L' + level + '_ac').autocomplete({
source: s3_gis_ac_set_source(level),
+ delay: 500,
minLength: 2,
search: function(event, ui) {
$( '#gis_location_L' + level + '_throbber' ).removeClass('hide').show();
@@ -211,6 +212,7 @@ function s3_gis_autocomplete_search() {
if (undefined != $('#gis_location_search_ac').val()) {
$('#gis_location_search_ac').autocomplete({
source: s3_gis_ac_set_search_source(),
+ delay: 500,
minLength: 2,
search: function(event, ui) {
$('#gis_location_search_throbber').removeClass('hide').show();
@@ -4,9 +4,9 @@ $("#gis_location_name").val(a)}});$("#gis_location_L0").change(function(){s3_gis
(s3_gis_hide_selector(),$("#gis_location_expand").addClass("expanded"),$("#gis_location_expand").removeClass("expand")):(s3_gis_show_tab("add"),$("#gis_location_expand").addClass("expand"),$("#gis_location_expand").removeClass("expanded"));a.preventDefault()});$("#gis_location_search_select-btn").click(function(a){s3_gis_select_search_result();a.preventDefault()});$("form").submit(function(){S3ClearNavigateAwayConfirm();return s3_gis_save_locations()?!0:!1})}}Ext.onReady(function(){s3_gis_locationselector_Ext_onReady()});
function s3_gis_locationselector_Ext_onReady(){var a=Ext.get("gis_location_map-btn");if(a)a.on("click",function(){S3.gis.mapWin.show();var a=$("#gis_location_lat").val(),c=$("#gis_location_lon").val();if(!a||!c)$(".olMapViewport").addClass("crosshair"),S3.gis.pointButton.control.activate()})}function s3_gis_locationselector_activate(){s3_gis_locationselector_jQuery_onReady();s3_gis_locationselector_Ext_onReady()}
function s3_gis_autocompletes(){s3_gis_autocomplete(1);s3_gis_autocomplete(2);s3_gis_autocomplete(3);s3_gis_autocomplete(4);s3_gis_autocomplete(5);s3_gis_autocomplete_search()}
-function s3_gis_autocomplete(a){void 0!=$("#gis_location_L"+a+"_ac").val()&&($("#gis_location_L"+a+"_ac").autocomplete({source:s3_gis_ac_set_source(a),minLength:2,search:function(){$("#gis_location_L"+a+"_throbber").removeClass("hide").show();$("#gis_location_L"+a).val("");return!0},response:function(b,c,f){$("#gis_location_L"+a+"_throbber").hide();return f},focus:function(b,c){$("#gis_location_L"+a+"_ac").val(c.item.name);return!1},select:function(b,c){$("#gis_location_L"+a+"_ac").val(c.item.name);
+function s3_gis_autocomplete(a){void 0!=$("#gis_location_L"+a+"_ac").val()&&($("#gis_location_L"+a+"_ac").autocomplete({source:s3_gis_ac_set_source(a),delay:500,minLength:2,search:function(){$("#gis_location_L"+a+"_throbber").removeClass("hide").show();$("#gis_location_L"+a).val("");return!0},response:function(b,c,f){$("#gis_location_L"+a+"_throbber").hide();return f},focus:function(b,c){$("#gis_location_L"+a+"_ac").val(c.item.name);return!1},select:function(b,c){$("#gis_location_L"+a+"_ac").val(c.item.name);
$("#gis_location_L"+a).val(c.item.id);"L1"==c.item.level&&c.item.parent&&""==$("#gis_location_L0").val()&&$("#gis_location_L0").val(c.item.parent);$("ul.ui-autocomplete").hide();s3_gis_autocomplete(parseInt(c.item.level.replace("L",""))+1);return!1}}).data("autocomplete")._renderItem=function(a,c){return $("<li></li>").data("item.autocomplete",c).append("<a>"+c.name+"</a>").appendTo(a)})}
-function s3_gis_autocomplete_search(){void 0!=$("#gis_location_search_ac").val()&&($("#gis_location_search_ac").autocomplete({source:s3_gis_ac_set_search_source(),minLength:2,search:function(){$("#gis_location_search_throbber").removeClass("hide").show();$("#gis_location_search_select-btn").hide();return!0},response:function(a,b,c){$("#gis_location_search_throbber").hide();return c},focus:function(a,b){$("#gis_location_search_ac").val(b.item.name);return!1},select:function(a,b){$("#gis_location_search_ac").val(b.item.name);
+function s3_gis_autocomplete_search(){void 0!=$("#gis_location_search_ac").val()&&($("#gis_location_search_ac").autocomplete({source:s3_gis_ac_set_search_source(),delay:500,minLength:2,search:function(){$("#gis_location_search_throbber").removeClass("hide").show();$("#gis_location_search_select-btn").hide();return!0},response:function(a,b,c){$("#gis_location_search_throbber").hide();return c},focus:function(a,b){$("#gis_location_search_ac").val(b.item.name);return!1},select:function(a,b){$("#gis_location_search_ac").val(b.item.name);
$("ul.ui-autocomplete").hide();s3_gis_ac_search_selected(b.item);return!1}}).data("autocomplete")._renderItem=function(a,b){var c=b.name&&b.addr_street?"<a>"+b.name+", "+b.addr_street.split(",")[0].split("\n")[0]+"</a>":b.name?"<a>"+b.name+"</a>":"<a>"+b.addr_street.split(",")[0].split("\n")[0]+"</a>";return $("<li></li>").data("item.autocomplete",b).append(c).appendTo(a)})}
function s3_gis_ac_set_source(a){var b=$("#gis_location_L"+(a-1)).val(),c;""==b&&1<a&&(c=$("#gis_location_L"+(a-2)).val(),""==c&&2<a&&(c=$("#gis_location_L"+(a-2)).val(),""==c&&3<a&&(c=$("#gis_location_L"+(a-3)).val(),""==c&&4<a&&(c=$("#gis_location_L"+(a-4)).val(),""==c&&5<a&&(c=$("#gis_location_L"+(a-5)).val())))));return b?S3.gis.url+"/search.json?filter=~&field=name&level=L"+a+"&parent="+b:c?S3.gis.url+"/search.json?filter=~&field=name&level=L"+a+"&children="+c:S3.gis.url+"/search.json?filter=~&field=name&level=L"+
a}function s3_gis_ac_set_search_source(){return S3.gis.url+"/search.json?filter=~&field=name&field2=addr_street&level=nullnone"}

0 comments on commit 81ec66a

Please sign in to comment.