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.
This commit is contained in:
aradhana kumari
2026-07-24 16:35:32 +05:30
parent 28c1e74579
commit 4cfe970dac
3 changed files with 53 additions and 108 deletions

View File

@@ -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
*}
<div id="qlo-stay-period-tooltip"
style="display:none;"
data-label-dates="{l s='Dates'}"
data-label-rooms="{l s='Rooms'}">
<div class="qlo-stay-period-cont">
<div class="qlo-stay-period-header">
<div class="qlo-stay-period-date">{l s='Stay Periods'}</div>
</div>
<div class="qlo-stay-period-body"></div>
</div>
</div>

View File

@@ -397,8 +397,11 @@ class AdminOrdersControllerCore extends AdminController
$uniqueStayPeriods = count($stayPeriods);
if ($uniqueStayPeriods > 1) {
$stayPeriodHtml .= ' <span class="qlo-stay-period-badge qlo-stay-period-tip" data-stay-tip="'
.htmlspecialchars(json_encode($stayPeriods)).'">+'
$stayPeriodHtml .= ' <span class="badge qlo-stay-period-badge"'
.' data-stay-tip="'.htmlspecialchars(json_encode($stayPeriods)).'"'
.' data-label-title="'.htmlspecialchars($this->l('Stay Periods')).'"'
.' data-label-duration="'.htmlspecialchars($this->l('Duration')).'"'
.' data-label-rooms="'.htmlspecialchars($this->l('Rooms')).'">+'
.($uniqueStayPeriods - 1).'</span>';
}
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();
}

View File

@@ -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(
$('<div class="qlo-stay-period qlo-stay-period-header">').append(
$('<span class="qlo-stay-period-element-head">').text($('#qlo-stay-period-tooltip').data('label-dates')),
$('<span class="qlo-stay-period-element-value">').text($('#qlo-stay-period-tooltip').data('label-rooms'))
)
);
$.each(periods, function (_, p) {
$stayPeriodBody.append(
$('<div class="qlo-stay-period">').append(
$('<span class="qlo-stay-period-element-head">').text(p.from + ' – ' + p.to),
$('<span class="qlo-stay-period-element-value">').text(p.count)
)
);
});
return $('<div>', {
'class': 'ui-tooltip ui-widget ui-corner-all ui-widget-content qlo-stay-period-tooltip',
'role' : 'tooltip'
}).append(
$('<div class="ui-tooltip-content">').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 = '<div class="tooltip_cont qlo-stay-period-tooltip">';
html += '<div class="tip_header"><div class="tip_date">' + $badge.data('label-title') + '</div></div>';
html += '<div class="tip-body">';
html += '<div class="qlo-stay-period-row qlo-stay-period-row-header">'
+ '<span class="tip_element_head">' + $badge.data('label-duration') + '</span>'
+ '<span class="tip_element_head">' + $badge.data('label-rooms') + '</span>'
+ '</div>';
$.each(periods, function (_, p) {
html += '<div class="qlo-stay-period-row">'
+ '<span class="tip_element_value">' + p.from + ' – ' + p.to + '</span>'
+ '<span class="tip_element_value">' + p.count + '</span>'
+ '</div>';
});
html += '</div></div>';
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();
});