| 1 |
(function($) { |
| 2 |
'use strict'; |
| 3 |
|
| 4 |
/** |
| 5 |
* All of the code for your public-facing JavaScript source |
| 6 |
* should reside in this file. |
| 7 |
* |
| 8 |
* Note: It has been assumed you will write jQuery code here, so the |
| 9 |
* $ function reference has been prepared for usage within the scope |
| 10 |
* of this function. |
| 11 |
* |
| 12 |
* This enables you to define handlers, for when the DOM is ready: |
| 13 |
* |
| 14 |
* $(function() { |
| 15 |
* |
| 16 |
* }); |
| 17 |
* |
| 18 |
* When the window is loaded: |
| 19 |
* |
| 20 |
* $( window ).load(function() { |
| 21 |
* |
| 22 |
* }); |
| 23 |
* |
| 24 |
* ...and/or other possibilities. |
| 25 |
* |
| 26 |
* Ideally, it is not considered best practise to attach more than a |
| 27 |
* single DOM-ready or window-load handler for a particular page. |
| 28 |
* Although scripts in the WordPress core, Plugins and Themes may be |
| 29 |
* practising this, we should strive to set a better example in our own work. |
| 30 |
*/ |
| 31 |
|
| 32 |
})(jQuery); |
| 33 |
function wpvrhotspot(hotSpotDiv, hotspotData) { |
| 34 |
const args = hotspotData.on_click_content; |
| 35 |
|
| 36 |
if (args) { |
| 37 |
const hasTextContent = args.replace(/<[^>]*>/g, '').trim() !== ''; |
| 38 |
const hasMediaContent = /<(img|video|audio|iframe|embed|object)\b[^>]*>/i.test(args); |
| 39 |
const hasOtherContent = args.replace(/<(p|br|div|span)\b[^>]*\/?>/gi, '').trim() !== ''; |
| 40 |
|
| 41 |
if (hasTextContent || hasMediaContent || hasOtherContent) { |
| 42 |
const cleanArgs = args.replace(/\\/g, ''); |
| 43 |
|
| 44 |
const $wrapper = jQuery(hotSpotDiv.target).parent().siblings(".custom-ifram-wrapper"); |
| 45 |
$wrapper.find('.custom-ifram').html(cleanArgs); |
| 46 |
$wrapper.fadeIn(); |
| 47 |
jQuery(hotSpotDiv.target).closest(".pano-wrap").addClass("show-modal"); |
| 48 |
} |
| 49 |
} |
| 50 |
} |
| 51 |
|
| 52 |
function wpvrtooltip(hotSpotDiv, args) { |
| 53 |
if (args) { |
| 54 |
const hasTextContent = args.replace(/<[^>]*>/g, '').trim() !== ''; |
| 55 |
const hasMediaContent = /<(img|video|audio|iframe|embed|object)\b[^>]*>/i.test(args); |
| 56 |
const hasOtherContent = args.replace(/<(p|br|div|span)\b[^>]*\/?>/gi, '').trim() !== ''; |
| 57 |
|
| 58 |
if (hasTextContent || hasMediaContent || hasOtherContent) { |
| 59 |
const cleanArgs = args.replace(/\\/g, ''); |
| 60 |
|
| 61 |
hotSpotDiv.classList.add('custom-tooltip'); |
| 62 |
const p = document.createElement('p'); |
| 63 |
p.innerHTML = cleanArgs; |
| 64 |
hotSpotDiv.appendChild(p); |
| 65 |
|
| 66 |
p.style.marginLeft = -(p.scrollWidth - hotSpotDiv.offsetWidth) / 2 + 'px'; |
| 67 |
p.style.marginTop = -p.scrollHeight - 12 + 'px'; |
| 68 |
|
| 69 |
// Optional: inject style once |
| 70 |
if (!document.getElementById('wpvr-tooltip-style')) { |
| 71 |
const style = document.createElement('style'); |
| 72 |
style.id = 'wpvr-tooltip-style'; |
| 73 |
style.textContent = ` |
| 74 |
.table, .table td, .table th { |
| 75 |
border: 1px solid #dee2e6; |
| 76 |
border-collapse: collapse; |
| 77 |
padding: 8px; |
| 78 |
} |
| 79 |
`; |
| 80 |
document.head.appendChild(style); |
| 81 |
} |
| 82 |
} |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
jQuery(document).ready(function($) { |
| 87 |
|
| 88 |
$(".cross").on("click", function(e) { |
| 89 |
e.preventDefault(); |
| 90 |
$(this).parent(".custom-ifram-wrapper").fadeOut(); |
| 91 |
$(this).parents(".pano-wrap").removeClass("show-modal"); |
| 92 |
|
| 93 |
$('.vr-iframe').attr('src', ''); |
| 94 |
// $('iframe').attr('src', $('iframe').attr('src')); |
| 95 |
if ($('#wpvr-video').length != 0) { |
| 96 |
$('#wpvr-video').get(0).pause(); |
| 97 |
} |
| 98 |
|
| 99 |
$(this).parent(".custom-ifram-wrapper").find('.custom-ifram').empty(); |
| 100 |
|
| 101 |
}); |
| 102 |
|
| 103 |
}); |
| 104 |
|
| 105 |
jQuery(document).ready(function($) { |
| 106 |
|
| 107 |
var notice_active = wpvr_public.notice_active; |
| 108 |
var notice = wpvr_public.notice; |
| 109 |
if (notice_active == "true") { |
| 110 |
if (!$.cookie("wpvr_mobile_notice")) { |
| 111 |
if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) { |
| 112 |
if ($(".pano-wrap")[0]) { |
| 113 |
$('body').append("<div class='wpvr-mobile-notice'><p>" + notice + "</p> <span class='notice-close'><i class='fa fa-times'></i></span></div>"); |
| 114 |
} |
| 115 |
} |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
$('.wpvr-mobile-notice .notice-close').on('click', function() { |
| 120 |
$('.wpvr-mobile-notice').fadeOut(); |
| 121 |
$.cookie('wpvr_mobile_notice', 'true'); |
| 122 |
}); |
| 123 |
}); |
| 124 |
|
| 125 |
// WPVR Hotspot Long-Press Mobile Support |
| 126 |
jQuery(document).ready(function($) { |
| 127 |
var isTouchDevice = ("ontouchstart" in window) || (navigator.maxTouchPoints > 0); |
| 128 |
var disOnHover = (typeof wpvr_public !== 'undefined') ? wpvr_public.dis_on_hover : undefined; |
| 129 |
var tipEnabled = (typeof wpvr_public !== 'undefined') ? wpvr_public.mobile_hotspot_tip : undefined; |
| 130 |
var shouldShowAlert = isTouchDevice && (disOnHover !== "1"); |
| 131 |
if (shouldShowAlert) { |
| 132 |
setTimeout(function() { |
| 133 |
if (!$('.pnlm-container').length) { |
| 134 |
return; |
| 135 |
} |
| 136 |
$('.pnlm-hotspot-base, .pnlm-hotspot').each(function() { |
| 137 |
$(this).off('mouseenter mouseover mouseleave'); |
| 138 |
|
| 139 |
// Hide only the inner content <p>, not the hotspot pointer |
| 140 |
$(this).find('p').hide(); |
| 141 |
|
| 142 |
var longPressTimer; |
| 143 |
var isLongPress = false; |
| 144 |
|
| 145 |
// Prevent click after long press |
| 146 |
$(this).off('click._wpvrHotspotFix').on('click._wpvrHotspotFix', function(e) { |
| 147 |
if ($(this).data('wpvr-longpress')) { |
| 148 |
e.preventDefault(); |
| 149 |
e.stopImmediatePropagation(); |
| 150 |
$(this).data('wpvr-longpress', false); |
| 151 |
return false; |
| 152 |
} |
| 153 |
}); |
| 154 |
|
| 155 |
$(this).on('touchstart', function(e) { |
| 156 |
isLongPress = false; |
| 157 |
var $hotspot = $(this); |
| 158 |
|
| 159 |
// Hide inner content on touch start |
| 160 |
$hotspot.find('p').hide(); |
| 161 |
|
| 162 |
longPressTimer = setTimeout(function() { |
| 163 |
isLongPress = true; |
| 164 |
$hotspot.data('wpvr-longpress', true); |
| 165 |
|
| 166 |
// Hide all other hotspot contents first |
| 167 |
$('.pnlm-hotspot-base p, .pnlm-hotspot p').hide(); |
| 168 |
|
| 169 |
// Show only this hotspot's content |
| 170 |
$hotspot.find('p').show(); |
| 171 |
}, 600); |
| 172 |
}); |
| 173 |
|
| 174 |
$(this).on('touchend', function(e) { |
| 175 |
clearTimeout(longPressTimer); |
| 176 |
if (isLongPress) { |
| 177 |
e.preventDefault(); |
| 178 |
e.stopPropagation(); |
| 179 |
// Do NOT auto-hide after 2 seconds anymore |
| 180 |
// Content will stay open until user taps elsewhere |
| 181 |
} else { |
| 182 |
// Short tap: hide inner content, let click fire |
| 183 |
$(this).find('p').hide(); |
| 184 |
} |
| 185 |
}); |
| 186 |
|
| 187 |
$(this).on('touchmove', function() { |
| 188 |
clearTimeout(longPressTimer); |
| 189 |
isLongPress = false; |
| 190 |
// Hide inner content if user starts panning |
| 191 |
$(this).find('p').hide(); |
| 192 |
}); |
| 193 |
}); |
| 194 |
|
| 195 |
// Hide hotspot content when tapping outside any hotspot |
| 196 |
$(document).on('touchstart.wpvrHotspotOutside', function(e) { |
| 197 |
// If the tap is not inside a hotspot or its content |
| 198 |
if (!$(e.target).closest('.pnlm-hotspot-base, .pnlm-hotspot').length) { |
| 199 |
$('.pnlm-hotspot-base p, .pnlm-hotspot p').hide(); |
| 200 |
} |
| 201 |
}); |
| 202 |
|
| 203 |
// Hide other hotspot contents when another hotspot is long-pressed |
| 204 |
$('.pnlm-hotspot-base, .pnlm-hotspot').on('touchstart', function(e) { |
| 205 |
// Hide all other hotspot contents except the one being touched |
| 206 |
var $current = $(this); |
| 207 |
$('.pnlm-hotspot-base, .pnlm-hotspot').not($current).find('p').hide(); |
| 208 |
}); |
| 209 |
|
| 210 |
if (tipEnabled == '1') { |
| 211 |
function showHotspotTip() { |
| 212 |
if (window.sessionStorage && sessionStorage.getItem('wpvrHotspotTipShown')) return; |
| 213 |
if (window.sessionStorage) { |
| 214 |
sessionStorage.setItem('wpvrHotspotTipShown', '1'); |
| 215 |
} |
| 216 |
alert('Tip: On mobile devices, long-press a hotspot to show its hover content.'); |
| 217 |
} |
| 218 |
$('.pnlm-container').on('touchstart.wpvrTip touchmove.wpvrTip', showHotspotTip); |
| 219 |
$('.pnlm-hotspot-base, .pnlm-hotspot').on('touchstart.wpvrTip', showHotspotTip); |
| 220 |
} |
| 221 |
}, 800); |
| 222 |
} |
| 223 |
}); |
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|