From 4cfe970dac4d8fe077e14d70fd00471bbf526e07 Mon Sep 17 00:00:00 2001 From: aradhana kumari Date: Fri, 24 Jul 2026 16:35:32 +0530 Subject: [PATCH] Rework stay-period tooltip to reuse core tooltip pattern Remove the hand-rolled clone/mouseenter tooltip skeleton and switch to jQuery UI's tooltip() widget with the shared core tooltip classes, same pattern already used by connected-rooms.tpl. --- .../orders/_stay_periods_tooltip.tpl | 33 ----- controllers/admin/AdminOrdersController.php | 9 +- js/admin/orders_stay_periods.js | 119 +++++++----------- 3 files changed, 53 insertions(+), 108 deletions(-) delete mode 100644 admin/themes/default/template/controllers/orders/_stay_periods_tooltip.tpl diff --git a/admin/themes/default/template/controllers/orders/_stay_periods_tooltip.tpl b/admin/themes/default/template/controllers/orders/_stay_periods_tooltip.tpl deleted file mode 100644 index 71f72d64d..000000000 --- a/admin/themes/default/template/controllers/orders/_stay_periods_tooltip.tpl +++ /dev/null @@ -1,33 +0,0 @@ -{* -* NOTICE OF LICENSE -* -* This source file is subject to the Open Software License version 3.0 -* that is bundled with this package in the file LICENSE.md -* It is also available through the world-wide-web at this URL: -* https://opensource.org/license/osl-3-0-php -* If you did not receive a copy of the license and are unable to -* obtain it through the world-wide-web, please send an email -* to support@qloapps.com so we can send you a copy immediately. -* -* DISCLAIMER -* -* Do not edit or add to this file if you wish to upgrade this module to a newer -* versions in the future. If you wish to customize this module for your needs -* please refer to https://store.webkul.com/customisation-guidelines for more information. -* -* @author Webkul IN -* @copyright Since 2010 Webkul -* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0 -*} - - diff --git a/controllers/admin/AdminOrdersController.php b/controllers/admin/AdminOrdersController.php index 3f26e8782..64c32281f 100644 --- a/controllers/admin/AdminOrdersController.php +++ b/controllers/admin/AdminOrdersController.php @@ -397,8 +397,11 @@ class AdminOrdersControllerCore extends AdminController $uniqueStayPeriods = count($stayPeriods); if ($uniqueStayPeriods > 1) { - $stayPeriodHtml .= ' +' + $stayPeriodHtml .= ' +' .($uniqueStayPeriods - 1).''; } return $stayPeriodHtml; @@ -1513,8 +1516,6 @@ class AdminOrdersControllerCore extends AdminController $this->_new_list_header_design = true; - $this->content .= $this->context->smarty->fetch('controllers/orders/_stay_periods_tooltip.tpl'); - return parent::renderList(); } diff --git a/js/admin/orders_stay_periods.js b/js/admin/orders_stay_periods.js index 4a557dea8..f028b5096 100644 --- a/js/admin/orders_stay_periods.js +++ b/js/admin/orders_stay_periods.js @@ -21,76 +21,53 @@ */ $(document).ready(function () { - var closeTimer = null; - - function stayPeriodTooltip(periods) { - var $stayPeriodCont = $('#qlo-stay-period-tooltip .qlo-stay-period-cont').clone(); - var $stayPeriodBody = $stayPeriodCont.find('.qlo-stay-period-body').empty(); - - $stayPeriodBody.append( - $('
').append( - $('').text($('#qlo-stay-period-tooltip').data('label-dates')), - $('').text($('#qlo-stay-period-tooltip').data('label-rooms')) - ) - ); - - $.each(periods, function (_, p) { - $stayPeriodBody.append( - $('
').append( - $('').text(p.from + ' – ' + p.to), - $('').text(p.count) - ) - ); - }); - return $('
', { - 'class': 'ui-tooltip ui-widget ui-corner-all ui-widget-content qlo-stay-period-tooltip', - 'role' : 'tooltip' - }).append( - $('
').append($stayPeriodCont) - ); + if (typeof window.initStayPeriodTooltips === 'undefined') { + window.initStayPeriodTooltips = function () { + if (typeof $.fn.tooltip === 'undefined' || typeof $.ui === 'undefined' || typeof $.ui.tooltip === 'undefined') { + return; + } + $('.qlo-stay-period-badge').each(function () { + if ($(this).data('ui-tooltip')) { + return; + } + $(this).tooltip({ + items: '.qlo-stay-period-badge', + content: function () { + var $badge = $(this); + var periods = $badge.data('stay-tip'); + if (!periods || !periods.length) { + return ''; + } + var html = '
'; + html += '
' + $badge.data('label-title') + '
'; + html += '
'; + html += '
' + + '' + $badge.data('label-duration') + '' + + '' + $badge.data('label-rooms') + '' + + '
'; + $.each(periods, function (_, p) { + html += '
' + + '' + p.from + ' – ' + p.to + '' + + '' + p.count + '' + + '
'; + }); + html += '
'; + return html; + }, + position: { my: 'left top+10', at: 'left bottom', collision: 'flipfit', within: '#content' }, + close: function (event, ui) { + ui.tooltip.hover(function () { + $(this).stop(true).fadeTo(300, 1); + }, + function () { + $(this).fadeOut('300', function () { + $(this).remove(); + }); + }); + } + }); + }); + }; } - - function cancelClose() { - clearTimeout(closeTimer); - closeTimer = null; - } - - function scheduleClose($tip) { - cancelClose(); - closeTimer = setTimeout(function () { - $tip.fadeOut(300, function () { $tip.remove(); }); - }, 300); - } - - $(document).on('mouseenter', '.qlo-stay-period-tip', function () { - cancelClose(); - - var periods = $(this).data('stay-tip'); - if (!periods || !periods.length) { return; } - - $('.qlo-stay-period-tooltip').stop(true).remove(); - - var $icon = $(this); - var $tip = stayPeriodTooltip(periods).appendTo('body').hide().fadeIn(200); - - var iconOffset = $icon.offset(); - $tip.css({ - position : 'absolute', - zIndex : 9999, - top : iconOffset.top + ($icon.outerHeight() / 2) - ($tip.outerHeight() / 2), - left : iconOffset.left + $icon.outerWidth() + 8 - }); - - $tip.on('mouseenter', function () { - cancelClose(); - }).on('mouseleave', function () { - scheduleClose($tip); - }); - - }).on('mouseleave', '.qlo-stay-period-tip', function () { - var $tip = $('.qlo-stay-period-tooltip'); - if ($tip.length) { - scheduleClose($tip); - } - }); + window.initStayPeriodTooltips(); });