From 329e3023e8fa22ddee71f554a1076cacbd8ad170 Mon Sep 17 00:00:00 2001 From: azhar bhat Date: Mon, 17 Aug 2026 20:43:43 +0530 Subject: [PATCH] fix: code optimization --- admin/themes/default/js/modernizr-loads.js | 8 +- .../default/template/helpers/tooltip.tpl | 10 +- .../views/js/admin/hotel_rooms_booking.js | 126 +++++++++--------- 3 files changed, 73 insertions(+), 71 deletions(-) diff --git a/admin/themes/default/js/modernizr-loads.js b/admin/themes/default/js/modernizr-loads.js index aa738e542..2009122da 100644 --- a/admin/themes/default/js/modernizr-loads.js +++ b/admin/themes/default/js/modernizr-loads.js @@ -3,6 +3,10 @@ Modernizr.load([ test: window.matchMedia, nope: ["themes/default/js/vendor/matchMedia.js", "themes/default/js/vendor/matchMedia.addListener.js"] }, - "themes/default/js/vendor/enquire.min.js", - "themes/default/js/admin-theme.js", + { + load: ["themes/default/js/vendor/enquire.min.js", "themes/default/js/admin-theme.js"], + complete: function() { + $(document).trigger('QloApps:adminThemeReady'); + } + } ]); \ No newline at end of file diff --git a/admin/themes/default/template/helpers/tooltip.tpl b/admin/themes/default/template/helpers/tooltip.tpl index 2f5571204..dde9e5866 100644 --- a/admin/themes/default/template/helpers/tooltip.tpl +++ b/admin/themes/default/template/helpers/tooltip.tpl @@ -21,14 +21,8 @@ *} - {if isset($tooltip_trigger_html) && $tooltip_trigger_html} - {$tooltip_trigger_html nofilter} - {elseif isset($tooltip_title) && $tooltip_title} - - {if isset($tooltip_icon_class) && $tooltip_icon_class} - - {/if} - {$tooltip_title|escape:'html':'UTF-8'} + {if isset($tooltip_title) && $tooltip_title} + {$tooltip_title nofilter} {elseif isset($tooltip_icon_class) && $tooltip_icon_class} {else} diff --git a/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js b/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js index 79d4bb846..5017805f5 100644 --- a/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js +++ b/modules/hotelreservationsystem/views/js/admin/hotel_rooms_booking.js @@ -23,9 +23,9 @@ $(document).ready(function() { // calender - - if ($('#fullcalendar').length) { - var calendar = new FullCalendar.Calendar($('#fullcalendar').get(0), { + var calendar; + function initBookingCalendar() { + calendar = new FullCalendar.Calendar($('#fullcalendar').get(0), { initialView: 'dayGridMonth', initialDate: initialDate, events: { @@ -54,70 +54,66 @@ $(document).ready(function() { if (info.event.extendedProps.is_notification) { var $cell = $(info.el).closest('td'); $cell.css('background-color', info.event.backgroundColor); - if (typeof initTooltip === 'function') { - initTooltip($cell, function() { - $('#date-stats-tooltop .tip_date').text(info.event.extendedProps.data.date_format); - $.each(info.event.extendedProps.data.stats, function(elem, val) { - if (elem == 'num_part_avai') { - $('#date-stats-tooltop').find('.'+elem).hide().find('.tip_element_value').text(''); - } else { - $('#date-stats-tooltop').find('.'+elem).show().find('.tip_element_value').text(val); - } - }); - return $('#date-stats-tooltop').html(); - }, 'td'); - $cell.tooltip('option', { - position: { - my: "left top", - at: "left+50% bottom-50%", - collision: "flipfit" - }, - open: function(event, ui) - { - if(event.buttons == 1 || event.buttons == 3){ - ui.tooltip.remove(); - } - - if (typeof(event.originalEvent) === 'undefined') { - return false; - } - - // suppress cell tooltip when hovering the search result bar - if ($(event.originalEvent.target).closest('.search-result-event').length) { - ui.tooltip.remove(); - $(this).removeData('ui-tooltip-id').removeAttr('aria-describedby'); - return false; - } - - var $id = $(ui.tooltip).attr('id'); - - // close any lingering tooltips - if ($('div.ui-tooltip').not('#' + $id).length) { - return false; - } + initTooltip($cell, function() { + $('#date-stats-tooltop .tip_date').text(info.event.extendedProps.data.date_format); + $.each(info.event.extendedProps.data.stats, function(elem, val) { + if (elem == 'num_part_avai') { + $('#date-stats-tooltop').find('.'+elem).hide().find('.tip_element_value').text(''); + } else { + $('#date-stats-tooltop').find('.'+elem).show().find('.tip_element_value').text(val); } }); - } + return $('#date-stats-tooltop').html(); + }, 'td'); + $cell.tooltip('option', { + position: { + my: "left top", + at: "left+50% bottom-50%", + collision: "flipfit" + }, + open: function(event, ui) + { + if(event.buttons == 1 || event.buttons == 3){ + ui.tooltip.remove(); + } + + if (typeof(event.originalEvent) === 'undefined') { + return false; + } + + // suppress cell tooltip when hovering the search result bar + if ($(event.originalEvent.target).closest('.search-result-event').length) { + ui.tooltip.remove(); + $(this).removeData('ui-tooltip-id').removeAttr('aria-describedby'); + return false; + } + + var $id = $(ui.tooltip).attr('id'); + + // close any lingering tooltips + if ($('div.ui-tooltip').not('#' + $id).length) { + return false; + } + } + }); } else { $(info.el).addClass('search-result-event'); - if (typeof initTooltip === 'function') { - initTooltip($(info.el), function() { - $('#date-stats-tooltop .tip_date').text(info.event.extendedProps.data.date_from_format + ' - ' +info.event.extendedProps.data.date_to_format); - $.each(info.event.extendedProps.data.stats, function(elem, val) { - if (elem == 'num_part_avai') { - if (val > 0) { - $('#date-stats-tooltop').find('.'+elem).show().find('.tip_element_value').text(val); - } else { - $('#date-stats-tooltop').find('.'+elem).hide().find('.tip_element_value').text(''); - } + initTooltip($(info.el), function() { + $('#date-stats-tooltop .tip_date').text(info.event.extendedProps.data.date_from_format + ' - ' +info.event.extendedProps.data.date_to_format); + $.each(info.event.extendedProps.data.stats, function(elem, val) { + if (elem == 'num_part_avai') { + if (val > 0) { + $('#date-stats-tooltop').find('.'+elem).show().find('.tip_element_value').text(val); } else { - $('#date-stats-tooltop').find('.'+elem).find('.tip_element_value').text(val); + $('#date-stats-tooltop').find('.'+elem).hide().find('.tip_element_value').text(''); } - }); - return $('#date-stats-tooltop').html(); - }, 'div'); - $(info.el).tooltip('option', 'track', true); - } + } else { + $('#date-stats-tooltop').find('.'+elem).find('.tip_element_value').text(val); + } + }); + return $('#date-stats-tooltop').html(); + }, 'div'); + $(info.el).tooltip('option', 'track', true); info.el.style.borderLeftColor = info.event.extendedProps.data.eventColor; resizeSearchResultEventBar($(info.el)); } @@ -141,6 +137,14 @@ $(document).ready(function() { }); } + if ($('#fullcalendar').length) { + if (typeof initTooltip === 'function') { + initBookingCalendar(); + } else { + $(document).on('QloApps:adminThemeReady', initBookingCalendar); + } + } + function resizeSearchResultEventBar($bar) { requestAnimationFrame(function() { var $td = $bar.closest('td');