diff options
author | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-02-20 16:50:35 +0100 |
---|---|---|
committer | Étienne Loks <etienne.loks@iggdrasil.net> | 2019-04-24 19:38:57 +0200 |
commit | 579fa06f40218802184d3cf78df457b0c504bb67 (patch) | |
tree | ca03cf2e0f91d8024650148af782eeef245344c3 /ishtar_common/static | |
parent | e421fcb5c868eb02cb40988ab73f7a83c1cda652 (diff) | |
download | Ishtar-579fa06f40218802184d3cf78df457b0c504bb67.tar.bz2 Ishtar-579fa06f40218802184d3cf78df457b0c504bb67.zip |
Map: manage a default limit to items displayed
Diffstat (limited to 'ishtar_common/static')
-rw-r--r-- | ishtar_common/static/js/ishtar.js | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/ishtar_common/static/js/ishtar.js b/ishtar_common/static/js/ishtar.js index e7ec6850c..e8652720a 100644 --- a/ishtar_common/static/js/ishtar.js +++ b/ishtar_common/static/js/ishtar.js @@ -29,6 +29,17 @@ if (typeof String.prototype.endsWith !== 'function') { }; } +if (typeof String.prototype.format !== 'function') { + String.prototype.format = function() { + var formatted = this; + for (var arg in arguments) { + formatted = formatted.replace("{" + arg + "}", arguments[arg]); + } + return formatted; + }; +} + + function manage_async_link(event){ event.preventDefault(); var url = $(this).attr('href'); @@ -1250,16 +1261,39 @@ var render_map_list_modal = function(map_id){ return html; }; -var render_map = function(map_id){ +var limit_map_msg = "Limit to {0} items"; +var limit_map_help_msg = "Unchecking this limit on a poorly performing device may result in web browser freeze"; +var limit_map_nb = 50000; +var current_map_limit = limit_map_nb; + +var render_map = function(map_id, use_map_limit){ var html = ""; + html += "<div class='ishtar-map-top row'>"; + html += "<div class='ishtar-map-info col-sm' id='ishtar-map-info-" + map_id + "'></div>"; + html += "<div class='ishtar-map-limit col-sm form-check'>"; + html += "<input class='form-check-input' type='checkbox' id='ishtar-map-limit-" + map_id + "' "; + if (use_map_limit) html += " checked='checked'"; + html += "/> "; + html += "<label class='form-check-label' for='ishtar-map-limit-" + map_id + "'>" + limit_map_msg.format(limit_map_nb); + html += " <i class='fa fa-question-circle' title=\""+ limit_map_help_msg +"\" aria-hidden='true'></i></label>"; + html += "</div></div>"; html += "<div class='ishtar-table-map' id='" + map_id + "'></div>"; html += "<div class='ishtar-map-popup' id='ishtar-map-popup-" + map_id + "'></div>"; html += render_map_list_modal(map_id); + current_map_limit = limit_map_nb; return html; }; var register_map = function(map_id, points){ display_map(map_id, points); + $('#ishtar-map-limit-' + map_id).change(function() { + if ($(this).prop('checked')) { + current_map_limit = limit_map_nb; + } else { + current_map_limit = 0; + } + $(".search_button").click(); + }); }; var main_submit_search = function(){ @@ -1295,5 +1329,9 @@ var search_get_query_data = function(query_vars, table_name){ if (data) data += "&"; data += "start=" + ((current_image_page - 1) * $(id_select).val()); } + if (current_tab == "map" && !current_map_limit){ + if (data) data += "&"; + data += "no_limit=true"; + } return data; }; |