Merge pull request #1802 from amitsharma322/gli-3083

Fixed: centralize and Optimize Tooltip Handling  in the back-office
This commit is contained in:
Rohit Jain
2026-08-24 13:15:08 +05:30
committed by GitHub
12 changed files with 173 additions and 201 deletions

View File

@@ -0,0 +1,4 @@
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="8" cy="8" r="8" fill="#7EC77B"/>
<path d="M8.06536 3C8.30937 3 8.51561 3.07032 8.6841 3.21097C8.85839 3.34693 8.94553 3.51336 8.94553 3.71027C8.94553 3.90717 8.85839 4.07595 8.6841 4.2166C8.51561 4.35724 8.30937 4.42757 8.06536 4.42757C7.82135 4.42757 7.6122 4.35724 7.43791 4.2166C7.26362 4.07595 7.17647 3.90717 7.17647 3.71027C7.17647 3.51336 7.26071 3.34693 7.42919 3.21097C7.60349 3.07032 7.81554 3 8.06536 3ZM8.78867 6.3685V11.5443C8.78867 11.9475 8.82353 12.2171 8.89325 12.353C8.96877 12.4843 9.07625 12.5827 9.21569 12.6484C9.36093 12.714 9.62237 12.7468 10 12.7468V13H6.122V12.7468C6.51126 12.7468 6.77269 12.7164 6.90632 12.6554C7.03994 12.5945 7.14452 12.4937 7.22004 12.353C7.30138 12.2124 7.34205 11.9428 7.34205 11.5443V9.06188C7.34205 8.36334 7.3159 7.91092 7.26362 7.70464C7.22295 7.55462 7.15904 7.45148 7.0719 7.39522C6.98475 7.33427 6.86565 7.3038 6.7146 7.3038C6.55192 7.3038 6.35439 7.33896 6.122 7.40928L6 7.15612L8.40523 6.3685H8.78867Z" fill="white"/>
</svg>

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -478,4 +478,42 @@ $(document).ready(function() {
$('.no-htl-access-option').on('click', function() {
$(this).prop('selected', false);
});
initTooltip();
}); //end dom ready
function initTooltip($target, contentFn, items) {
var $elements = $target || $('.tooltip-trigger');
if (!$elements.length) {
return;
}
$elements.each(function () {
var $this = $(this);
if (!contentFn && $this.data('ui-tooltip')) {
return;
}
$this.tooltip({
content: contentFn || $this.next('.tooltip-content').html(),
items: items || 'span',
trigger: 'hover',
tooltipClass: 'tooltip-popup',
open: function (event, ui) {
if (event.buttons == 1 || event.buttons == 3) {
ui.tooltip.remove();
}
if (typeof event.originalEvent === 'undefined') {
return false;
}
var $id = $(ui.tooltip).attr('id');
if ($('div.ui-tooltip').not('#' + $id).length) {
return false;
}
},
close: function (event, ui) {
ui.tooltip.hover(
function () { $(this).stop(true).fadeTo(300, 1); },
function () { $(this).fadeOut(300, function () { $(this).remove(); }); }
);
}
});
});
}

View File

@@ -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('admin-theme.js.ready');
}
}
]);

View File

@@ -1,5 +1,4 @@
.tooltip_cont
min-width: 280px
width: 100%
font-size: 14px
font-weight: 600
@@ -7,6 +6,7 @@
margin-bottom: 10px
.tip-body > div
margin-bottom: 6px
margin-right: 10px
.tip_element_head
font-size: 12px
@@ -28,3 +28,30 @@
border: none
padding: 10px
box-shadow: 0px 0px 15px 0px rgba(0, 0, 0, 0.15)
width: auto
.tooltip-trigger
cursor: pointer
display: inline-block
vertical-align: middle
.ui-tooltip.tooltip-popup
ul
margin: 0
padding: 0 0 0 16px
list-style: disc
li
padding: 2px 0
.tooltip-popup-row
display: flex
justify-content: space-between
align-items: center
gap: 12px
margin: 3px 0
white-space: nowrap
label
font-weight: 600
margin: 0

View File

@@ -1404,6 +1404,7 @@
{
$("#customer_cart_details").empty();
$("#customer_cart_details").append(res.cart_detail_html);
initTooltip();
displaySummary(res);
}

View File

@@ -20,63 +20,22 @@
* @license https://opensource.org/license/osl-3-0-php Open Software License version 3.0
*}
{if isset($htl_connected_rooms) && $htl_connected_rooms|@count > 0}
<span class="connected-room-tooltip-trigger"
data-connected-details='{json_encode($htl_connected_rooms.connected_room_types)|escape:'html':'UTF-8'}'>
<i class="icon-random" style="color: #008abd; cursor: pointer;"></i>
</span>
{capture name='connected_room_tooltip'}
<div class="tooltip_cont">
<div class="tip_header"><div class="tip_date">{l s='Connected Rooms'}</div></div>
<div class="tip-body tip-body-grid">
{foreach from=$htl_connected_rooms.connected_room_types item=group}
<div>
<div class="tip_element_head">{$group.room_type_name|escape:'html':'UTF-8'}</div>
<div class="tip_element_value">
{foreach from=$group.connected_rooms item=room name=connected_rooms}
{$room.name|escape:'html':'UTF-8'}{if !$smarty.foreach.connected_rooms.last}, {/if}
{/foreach}
</div>
</div>
{/foreach}
</div>
</div>
{/capture}
{include file='helpers/tooltip.tpl' tooltip_content=$smarty.capture.connected_room_tooltip tooltip_icon_class='icon-random' tooltip_icon_style='color: #008abd;' }
{/if}
<script>
$(document).ready(function() {
{literal}
if (typeof window.initConnectedRoomTooltips === 'undefined') {
window.initConnectedRoomTooltips = function() {
if (typeof $.fn.tooltip === 'undefined' || typeof $.ui === 'undefined' || typeof $.ui.tooltip === 'undefined') {
return;
}
$('.connected-room-tooltip-trigger').each(function() {
if ($(this).data('ui-tooltip')) {
return;
}
$(this).tooltip({
items: '.connected-room-tooltip-trigger',
content: function() {
var details = $(this).data('connected-details');
if (!details || $.isEmptyObject(details)) {
return "{/literal}{l s='No rooms connected' js=1}{literal}";
}
var html = '<div class="tooltip_cont">';
html += '<div class="tip_header"><div class="tip_date">{/literal}{l s="Connected Rooms" js=1}{literal}</div></div>';
html += '<div class="tip-body tip-body-grid">';
for (var typeId in details) {
var group = details[typeId];
var names = [];
for (var i = 0; i < group.connected_rooms.length; i++) {
names.push(group.connected_rooms[i].name);
}
html += '<div>';
html += '<div class="tip_element_head">' + group.room_type_name + '</div>';
html += '<div class="tip_element_value">' + names.join(', ') + '</div>';
html += '</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();
});
});
}
});
});
};
}
window.initConnectedRoomTooltips();
{/literal}
});
</script>

View File

@@ -0,0 +1,38 @@
{*
* 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
*}
<span class="tooltip-trigger{if isset($tooltip_class) && $tooltip_class} {$tooltip_class|escape:'html':'UTF-8'}{/if}">
{if isset($tooltip_title) && $tooltip_title}
{$tooltip_title nofilter}
{elseif isset($tooltip_icon_class) && $tooltip_icon_class}
<i class="{$tooltip_icon_class|escape:'html':'UTF-8'}"{if isset($tooltip_icon_style) && $tooltip_icon_style} style="{$tooltip_icon_style|escape:'html':'UTF-8'}"{/if}></i>
{else}
<img src="themes/default/img/icon-info.svg" alt="" />
{/if}
</span>
<div class="tooltip-content" style="display: none;">
{if isset($allow_html) && !$allow_html}
{$tooltip_content|escape:'html':'UTF-8'}
{else}
{$tooltip_content nofilter}
{/if}
</div>

View File

@@ -350,7 +350,6 @@ class AdminOrderRefundRequestsController extends ModuleAdminController
'isRefundCompleted' => $objOrderReturn->hasBeenCompleted(),
'paymentMethods' => $paymentMethods,
'name_controller' => Tools::getValue('controller'),
'info_icon_path' => $this->context->link->getMediaLink(_MODULE_DIR_.'hotelreservationsystem/views/img/Slices/icon-info.svg'),
'expiry_date' => time() + (3600 * 24 * 365.25)
)
);

View File

@@ -24,9 +24,9 @@ body.adminorderrefundrequests .ui-tooltip {
padding: 10px;
box-shadow: 0px 0px 15px 0px #00000026;
}
.ui-tooltip.price_info-tooltip span {
.ui-tooltip.tooltip-popup span {
margin-left: 15px;
}
.ui-tooltip.price_info-tooltip label {
.ui-tooltip.tooltip-popup label {
font-weight: 600;
}

View File

@@ -23,8 +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: {
@@ -53,32 +54,23 @@ $(document).ready(function() {
if (info.event.extendedProps.is_notification) {
var $cell = $(info.el).closest('td');
$cell.css('background-color', info.event.backgroundColor);
$cell.tooltip({
content: 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();
},
items: "td",
trigger : 'hover',
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"
},
show: {
delay: 100,
},
hide: {
delay: 300,
},
open: function(event, ui)
{
if(event.buttons == 1 || event.buttons == 3){
@@ -102,27 +94,11 @@ $(document).ready(function() {
if ($('div.ui-tooltip').not('#' + $id).length) {
return false;
}
// ajax function to pull in data and add it to the tooltip goes here
},
close: function(event, ui)
{
ui.tooltip.hover(function() {
$(this).stop(true).fadeTo(300, 1);
},
function() {
$(this).fadeOut('300', function()
{
$(this).remove();
});
});
}
});
} else {
$(info.el).addClass('search-result-event');
$(info.el).tooltip({
content: function()
{
}
});
} else {
$(info.el).addClass('search-result-event');
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') {
@@ -136,48 +112,8 @@ $(document).ready(function() {
}
});
return $('#date-stats-tooltop').html();
},
items: "div",
trigger : 'hover',
track: true,
show: {
delay: 100,
},
hide: {
delay: 300,
},
open: function(event, ui)
{
if(event.buttons == 1 || event.buttons == 3){
ui.tooltip.remove();
}
if (typeof(event.originalEvent) === 'undefined') {
return false;
}
var $id = $(ui.tooltip).attr('id');
// close any lingering tooltips
if ($('div.ui-tooltip').not('#' + $id).length) {
return false;
}
// ajax function to pull in data and add it to the tooltip goes here
},
close: function(event, ui)
{
ui.tooltip.hover(function() {
$(this).stop(true).fadeTo(300, 1);
},
function() {
$(this).fadeOut('300', function()
{
$(this).remove();
});
});
}
});
}, 'div');
$(info.el).tooltip('option', 'track', true);
info.el.style.borderLeftColor = info.event.extendedProps.data.eventColor;
resizeSearchResultEventBar($(info.el));
}
@@ -201,6 +137,14 @@ $(document).ready(function() {
});
}
if ($('#fullcalendar').length) {
if (typeof initTooltip === 'function') {
initBookingCalendar();
} else {
$(document).on('admin-theme.js.ready', initBookingCalendar);
}
}
function resizeSearchResultEventBar($bar) {
requestAnimationFrame(function() {
var $td = $bar.closest('td');
@@ -548,6 +492,7 @@ $(document).ready(function() {
} else {
showSuccessMessage(removed_room_success_txt);
$("#htl_rooms_list").empty().append(result.data.room_tpl);
initTooltip();
refreshCartData();
refreshStatsData();
calendar.refetchEvents();
@@ -1077,4 +1022,4 @@ $(document).ready(function() {
return [true, ""];
}
}
});
});

View File

@@ -41,45 +41,6 @@ $(document).ready(function() {
$('#voucher_expiry').parent().removeClass('has-error');
});
// initialize tootip for room price
if ($('#rooms_refund_info .price_info').length) {
$('#rooms_refund_info .price_info').each(function (i, element) {
$(this).find('img').tooltip({
content: $(this).closest('td').find('.price_info_container').html(),
items: "span",
trigger : 'hover',
tooltipClass: "price_info-tooltip",
open: function(event, ui)
{
if (typeof(event.originalEvent) === 'undefined')
{
return false;
}
var $id = $(ui.tooltip).attr('id');
if ($('div.ui-tooltip').not('#' + $id).length) {
return false;
}
},
close: function(event, ui)
{
ui.tooltip.hover(function()
{
$(this).stop(true).fadeTo(400, 1);
},
function()
{
$(this).fadeOut('400', function()
{
$(this).remove();
});
});
}
});
});
}
$(document).on('change', '#refundTransactionAmount', function() {
if ($(this).is(':checked')) {
$(".refund_transaction_fields").show(200);

View File

@@ -171,10 +171,7 @@
<td>{dateFormat date=$booking['date_from'] full=$is_full_date} {l s='To' mod='hotelreservationsystem'} {dateFormat date=$booking['date_to'] full=$is_full_date}</td>
<td>
{displayPrice price=($booking['total_price_tax_incl'] + $booking['extra_service_total_price_tax_incl']) currency=$orderCurrency['id']}
<span class="price_info">
&nbsp;<img src="{$info_icon_path|escape:'htmlall':'UTF-8'}" />
</span>
<div class="price_info_container" style="display: none;">
{capture name='refund_total_tooltip'}
<div>
<label>{l s='Room cost:' mod='hotelreservationsystem'}</label>
<span class="pull-right">{displayPrice price=$booking['total_price_tax_incl'] currency=$orderCurrency['id']}</span>
@@ -183,14 +180,12 @@
<label>{l s='Services cost:' mod='hotelreservationsystem'}</label>
<span class="pull-right">{displayPrice price=$booking['extra_service_total_price_tax_incl'] currency=$orderCurrency['id']}</span>
</div>
</div>
{/capture}
{include file='helpers/tooltip.tpl' tooltip_content=$smarty.capture.refund_total_tooltip}
</td>
<td>
{displayPrice price=($booking['room_paid_amount'] + $booking['extra_service_total_paid_amount']) currency=$orderCurrency['id']}
<span class="price_info">
&nbsp;<img src="{$info_icon_path|escape:'htmlall':'UTF-8'}" />
</span>
<div class="price_info_container" style="display: none;">
{capture name='refund_paid_tooltip'}
<div>
<label>{l s='Room paid amount:' mod='hotelreservationsystem'}</label>
<span class="pull-right">{displayPrice price=$booking['room_paid_amount'] currency=$orderCurrency['id']}</span>
@@ -199,7 +194,8 @@
<label>{l s='Services paid amount:' mod='hotelreservationsystem'}</label>
<span class="pull-right">{displayPrice price=$booking['extra_service_total_paid_amount'] currency=$orderCurrency['id']}</span>
</div>
</div>
{/capture}
{include file='helpers/tooltip.tpl' tooltip_content=$smarty.capture.refund_paid_tooltip }
</td>
{if !$isRefundCompleted}
<td>