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
@@ -4,18 +4,19 @@
$(function () {
// Search Functionality
var quickSearchInited = false;
$('#SearchQuery').watermark('Search').keypress(function (e) {
let quickSearchInited = false;
$('#SearchQuery').keypress(function (e) {
if (e.keyCode == 13) {
e.preventDefault();
$(this).closest('form').submit();
return false;
}
}).focus(function () {
$this = $(this);
const $this = $(this);
$this.select();
if (!quickSearchInited) {
var quickSearchUrl = $this.attr('data-quicksearchurl');
const quickSearchUrl = $this.attr('data-quicksearchurl');
if (quickSearchUrl) {
$this.autocomplete({
source: quickSearchUrl,
@@ -26,7 +27,7 @@
},
response: function (e, ui) {
for (var i = 0; i < ui.content.length; i++) {
var item = ui.content[i];
const item = ui.content[i];
switch (item.Type) {
case 'Device':
item.tag = '!' + item.Id;
@@ -43,7 +44,7 @@
}).autocomplete("widget").attr('id', 'QuickSearchMenu');
$this.data('ui-autocomplete')._renderItem = function (ul, item) {
var template;
let template;
//"<a><strong>" + item.DisplayName + "</strong><br>" + item.Id + " (" + item.Type + ")</a>"
@@ -77,14 +78,14 @@
});
// Menu Functionality
var $menu = $('#menu');
const $menu = $('#menu');
if ($menu.length > 0) {
function subMenuShow() {
var $this = $(this);
var $subMenu = $this.children('ul');
var hideToken = $this.data('menuHideToken');
const $this = $(this);
const $subMenu = $this.children('ul');
const hideToken = $this.data('menuHideToken');
if (hideToken)
window.clearTimeout(hideToken);
@@ -93,8 +94,8 @@
$subMenu.show();
}
function subMenuHide() {
var $this = $(this);
var $subMenu = $this.children('ul');
const $this = $(this);
const $subMenu = $this.children('ul');
var hideToken = window.setTimeout(function () {
$subMenu.hide();
@@ -103,9 +104,9 @@
$this.data('menuHideToken', hideToken);
}
function subMenuTouchDown(e, preventClick) {
var $this = $(this);
var $link = $this.children('a');
var $subMenu = $this.children('ul');
const $this = $(this);
const $link = $this.children('a');
const $subMenu = $this.children('ul');
if (!$subMenu.is(':visible')) {
@@ -117,7 +118,7 @@
if (preventClick) {
// Stop Click Event
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);
}
}