regression fix: quick search

This commit is contained in:
Gary Sharp
2025-02-27 13:16:37 +11:00
parent eb3ed7f819
commit 62a5da7513
3 changed files with 35 additions and 33 deletions
+17 -16
View File
@@ -58474,18 +58474,19 @@ jQuery.fn.DataTable.defaults.aLengthMenu = [[10, 20, 50, 100, 200, -1], [10, 20,
$(function () { $(function () {
// Search Functionality // Search Functionality
var quickSearchInited = false; let quickSearchInited = false;
$('#SearchQuery').watermark('Search').keypress(function (e) { $('#SearchQuery').keypress(function (e) {
if (e.keyCode == 13) { if (e.keyCode == 13) {
e.preventDefault();
$(this).closest('form').submit(); $(this).closest('form').submit();
return false; return false;
} }
}).focus(function () { }).focus(function () {
$this = $(this); const $this = $(this);
$this.select(); $this.select();
if (!quickSearchInited) { if (!quickSearchInited) {
var quickSearchUrl = $this.attr('data-quicksearchurl'); const quickSearchUrl = $this.attr('data-quicksearchurl');
if (quickSearchUrl) { if (quickSearchUrl) {
$this.autocomplete({ $this.autocomplete({
source: quickSearchUrl, source: quickSearchUrl,
@@ -58496,7 +58497,7 @@ jQuery.fn.DataTable.defaults.aLengthMenu = [[10, 20, 50, 100, 200, -1], [10, 20,
}, },
response: function (e, ui) { response: function (e, ui) {
for (var i = 0; i < ui.content.length; i++) { for (var i = 0; i < ui.content.length; i++) {
var item = ui.content[i]; const item = ui.content[i];
switch (item.Type) { switch (item.Type) {
case 'Device': case 'Device':
item.tag = '!' + item.Id; item.tag = '!' + item.Id;
@@ -58513,7 +58514,7 @@ jQuery.fn.DataTable.defaults.aLengthMenu = [[10, 20, 50, 100, 200, -1], [10, 20,
}).autocomplete("widget").attr('id', 'QuickSearchMenu'); }).autocomplete("widget").attr('id', 'QuickSearchMenu');
$this.data('ui-autocomplete')._renderItem = function (ul, item) { $this.data('ui-autocomplete')._renderItem = function (ul, item) {
var template; let template;
//"<a><strong>" + item.DisplayName + "</strong><br>" + item.Id + " (" + item.Type + ")</a>" //"<a><strong>" + item.DisplayName + "</strong><br>" + item.Id + " (" + item.Type + ")</a>"
@@ -58547,14 +58548,14 @@ jQuery.fn.DataTable.defaults.aLengthMenu = [[10, 20, 50, 100, 200, -1], [10, 20,
}); });
// Menu Functionality // Menu Functionality
var $menu = $('#menu'); const $menu = $('#menu');
if ($menu.length > 0) { if ($menu.length > 0) {
function subMenuShow() { function subMenuShow() {
var $this = $(this); const $this = $(this);
var $subMenu = $this.children('ul'); const $subMenu = $this.children('ul');
var hideToken = $this.data('menuHideToken'); const hideToken = $this.data('menuHideToken');
if (hideToken) if (hideToken)
window.clearTimeout(hideToken); window.clearTimeout(hideToken);
@@ -58563,8 +58564,8 @@ jQuery.fn.DataTable.defaults.aLengthMenu = [[10, 20, 50, 100, 200, -1], [10, 20,
$subMenu.show(); $subMenu.show();
} }
function subMenuHide() { function subMenuHide() {
var $this = $(this); const $this = $(this);
var $subMenu = $this.children('ul'); const $subMenu = $this.children('ul');
var hideToken = window.setTimeout(function () { var hideToken = window.setTimeout(function () {
$subMenu.hide(); $subMenu.hide();
@@ -58573,9 +58574,9 @@ jQuery.fn.DataTable.defaults.aLengthMenu = [[10, 20, 50, 100, 200, -1], [10, 20,
$this.data('menuHideToken', hideToken); $this.data('menuHideToken', hideToken);
} }
function subMenuTouchDown(e, preventClick) { function subMenuTouchDown(e, preventClick) {
var $this = $(this); const $this = $(this);
var $link = $this.children('a'); const $link = $this.children('a');
var $subMenu = $this.children('ul'); const $subMenu = $this.children('ul');
if (!$subMenu.is(':visible')) { if (!$subMenu.is(':visible')) {
@@ -58587,7 +58588,7 @@ jQuery.fn.DataTable.defaults.aLengthMenu = [[10, 20, 50, 100, 200, -1], [10, 20,
if (preventClick) { if (preventClick) {
// Stop Click Event // Stop Click Event
if ($link.length > 0) { if ($link.length > 0) {
var preventClick = function () { $link.off('click', preventClick); return false; } const preventClick = function () { $link.off('click', preventClick); return false; }
$link.on('click', preventClick); $link.on('click', preventClick);
} }
} }
File diff suppressed because one or more lines are too long
@@ -4,18 +4,19 @@
$(function () { $(function () {
// Search Functionality // Search Functionality
var quickSearchInited = false; let quickSearchInited = false;
$('#SearchQuery').watermark('Search').keypress(function (e) { $('#SearchQuery').keypress(function (e) {
if (e.keyCode == 13) { if (e.keyCode == 13) {
e.preventDefault();
$(this).closest('form').submit(); $(this).closest('form').submit();
return false; return false;
} }
}).focus(function () { }).focus(function () {
$this = $(this); const $this = $(this);
$this.select(); $this.select();
if (!quickSearchInited) { if (!quickSearchInited) {
var quickSearchUrl = $this.attr('data-quicksearchurl'); const quickSearchUrl = $this.attr('data-quicksearchurl');
if (quickSearchUrl) { if (quickSearchUrl) {
$this.autocomplete({ $this.autocomplete({
source: quickSearchUrl, source: quickSearchUrl,
@@ -26,7 +27,7 @@
}, },
response: function (e, ui) { response: function (e, ui) {
for (var i = 0; i < ui.content.length; i++) { for (var i = 0; i < ui.content.length; i++) {
var item = ui.content[i]; const item = ui.content[i];
switch (item.Type) { switch (item.Type) {
case 'Device': case 'Device':
item.tag = '!' + item.Id; item.tag = '!' + item.Id;
@@ -43,7 +44,7 @@
}).autocomplete("widget").attr('id', 'QuickSearchMenu'); }).autocomplete("widget").attr('id', 'QuickSearchMenu');
$this.data('ui-autocomplete')._renderItem = function (ul, item) { $this.data('ui-autocomplete')._renderItem = function (ul, item) {
var template; let template;
//"<a><strong>" + item.DisplayName + "</strong><br>" + item.Id + " (" + item.Type + ")</a>" //"<a><strong>" + item.DisplayName + "</strong><br>" + item.Id + " (" + item.Type + ")</a>"
@@ -77,14 +78,14 @@
}); });
// Menu Functionality // Menu Functionality
var $menu = $('#menu'); const $menu = $('#menu');
if ($menu.length > 0) { if ($menu.length > 0) {
function subMenuShow() { function subMenuShow() {
var $this = $(this); const $this = $(this);
var $subMenu = $this.children('ul'); const $subMenu = $this.children('ul');
var hideToken = $this.data('menuHideToken'); const hideToken = $this.data('menuHideToken');
if (hideToken) if (hideToken)
window.clearTimeout(hideToken); window.clearTimeout(hideToken);
@@ -93,8 +94,8 @@
$subMenu.show(); $subMenu.show();
} }
function subMenuHide() { function subMenuHide() {
var $this = $(this); const $this = $(this);
var $subMenu = $this.children('ul'); const $subMenu = $this.children('ul');
var hideToken = window.setTimeout(function () { var hideToken = window.setTimeout(function () {
$subMenu.hide(); $subMenu.hide();
@@ -103,9 +104,9 @@
$this.data('menuHideToken', hideToken); $this.data('menuHideToken', hideToken);
} }
function subMenuTouchDown(e, preventClick) { function subMenuTouchDown(e, preventClick) {
var $this = $(this); const $this = $(this);
var $link = $this.children('a'); const $link = $this.children('a');
var $subMenu = $this.children('ul'); const $subMenu = $this.children('ul');
if (!$subMenu.is(':visible')) { if (!$subMenu.is(':visible')) {
@@ -117,7 +118,7 @@
if (preventClick) { if (preventClick) {
// Stop Click Event // Stop Click Event
if ($link.length > 0) { if ($link.length > 0) {
var preventClick = function () { $link.off('click', preventClick); return false; } const preventClick = function () { $link.off('click', preventClick); return false; }
$link.on('click', preventClick); $link.on('click', preventClick);
} }
} }