PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 9.0.1
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v9.0.1
9.1.3 9.1.2 9.1.1 9.1.0 9.0.3 9.0.2 9.0.1 9.0.0 8.5.79 8.5.78 8.5.77 8.5.76 8.5.75 8.5.74 8.5.73 8.5.72 8.5.71 8.5.70 8.5.69 8.5.68 8.5.35 8.5.36 8.5.37 8.5.38 8.5.39 All 222 releases
wpvr / legacy / public / js / wpvr-public.js

wpvr-public.js in WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress 9.0.1, at legacy/public/js/wpvr-public.js

228 lines 7.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 const content = document.createElement('div');
64 content.className = 'wpvr-tooltip-content';
65 content.innerHTML = cleanArgs;
66 p.appendChild(content);
67 hotSpotDiv.appendChild(p);
68
69 p.style.marginLeft = -(p.scrollWidth - hotSpotDiv.offsetWidth) / 2 + 'px';
70 p.style.marginTop = -p.scrollHeight - 12 + 'px';
71
72 // Optional: inject style once
73 if (!document.getElementById('wpvr-tooltip-style')) {
74 const style = document.createElement('style');
75 style.id = 'wpvr-tooltip-style';
76 style.textContent = `
77 .table, .table td, .table th {
78 border: 1px solid #dee2e6;
79 border-collapse: collapse;
80 padding: 8px;
81 }
82 `;
83 document.head.appendChild(style);
84 }
85 }
86 }
87 }
88
89 jQuery(document).ready(function($) {
90
91 $(".cross").on("click", function(e) {
92 e.preventDefault();
93 $(this).parent(".custom-ifram-wrapper").fadeOut();
94 $(this).parents(".pano-wrap").removeClass("show-modal");
95
96 $('.vr-iframe').attr('src', '');
97 // $('iframe').attr('src', $('iframe').attr('src'));
98 if ($('#wpvr-video').length != 0) {
99 $('#wpvr-video').get(0).pause();
100 }
101
102 $(this).parent(".custom-ifram-wrapper").find('.custom-ifram').empty();
103
104 });
105
106 });
107
108 jQuery(document).ready(function($) {
109
110 var notice_active = wpvr_public.notice_active;
111 var notice = wpvr_public.notice;
112 if (notice_active == "true") {
113 if (!$.cookie("wpvr_mobile_notice")) {
114 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)) {
115 if ($(".pano-wrap")[0]) {
116 $('body').append("<div class='wpvr-mobile-notice'><p>" + notice + "</p> <span class='notice-close'><i class='fa fa-times'></i></span></div>");
117 }
118 }
119 }
120 }
121
122 $('.wpvr-mobile-notice .notice-close').on('click', function() {
123 $('.wpvr-mobile-notice').fadeOut();
124 $.cookie('wpvr_mobile_notice', 'true');
125 });
126 });
127
128 // WPVR Hotspot Long-Press Mobile Support
129 jQuery(document).ready(function($) {
130 var isTouchDevice = ("ontouchstart" in window) || (navigator.maxTouchPoints > 0);
131 var disOnHover = (typeof wpvr_public !== 'undefined') ? wpvr_public.dis_on_hover : undefined;
132 var tipEnabled = (typeof wpvr_public !== 'undefined') ? wpvr_public.mobile_hotspot_tip : undefined;
133 var shouldShowAlert = isTouchDevice && (disOnHover !== "1");
134 if (shouldShowAlert) {
135 setTimeout(function() {
136 if (!$('.pnlm-container').length) {
137 return;
138 }
139 $('.pnlm-hotspot-base, .pnlm-hotspot').each(function() {
140 $(this).off('mouseenter mouseover mouseleave');
141
142 // Hide only the inner content <p>, not the hotspot pointer
143 $(this).find('p').hide();
144
145 var longPressTimer;
146 var isLongPress = false;
147
148 // Prevent click after long press
149 $(this).off('click._wpvrHotspotFix').on('click._wpvrHotspotFix', function(e) {
150 if ($(this).data('wpvr-longpress')) {
151 e.preventDefault();
152 e.stopImmediatePropagation();
153 $(this).data('wpvr-longpress', false);
154 return false;
155 }
156 });
157
158 $(this).on('touchstart', function(e) {
159 isLongPress = false;
160 var $hotspot = $(this);
161
162 // Hide inner content on touch start
163 $hotspot.find('p').hide();
164
165 longPressTimer = setTimeout(function() {
166 isLongPress = true;
167 $hotspot.data('wpvr-longpress', true);
168
169 // Hide all other hotspot contents first
170 $('.pnlm-hotspot-base p, .pnlm-hotspot p').hide();
171
172 // Show only this hotspot's content
173 $hotspot.find('p').show();
174 }, 600);
175 });
176
177 $(this).on('touchend', function(e) {
178 clearTimeout(longPressTimer);
179 if (isLongPress) {
180 e.preventDefault();
181 e.stopPropagation();
182 // Do NOT auto-hide after 2 seconds anymore
183 // Content will stay open until user taps elsewhere
184 } else {
185 // Short tap: hide inner content, let click fire
186 $(this).find('p').hide();
187 }
188 });
189
190 $(this).on('touchmove', function() {
191 clearTimeout(longPressTimer);
192 isLongPress = false;
193 // Hide inner content if user starts panning
194 $(this).find('p').hide();
195 });
196 });
197
198 // Hide hotspot content when tapping outside any hotspot
199 $(document).on('touchstart.wpvrHotspotOutside', function(e) {
200 // If the tap is not inside a hotspot or its content
201 if (!$(e.target).closest('.pnlm-hotspot-base, .pnlm-hotspot').length) {
202 $('.pnlm-hotspot-base p, .pnlm-hotspot p').hide();
203 }
204 });
205
206 // Hide other hotspot contents when another hotspot is long-pressed
207 $('.pnlm-hotspot-base, .pnlm-hotspot').on('touchstart', function(e) {
208 // Hide all other hotspot contents except the one being touched
209 var $current = $(this);
210 $('.pnlm-hotspot-base, .pnlm-hotspot').not($current).find('p').hide();
211 });
212
213 if (tipEnabled == '1') {
214 function showHotspotTip() {
215 if (window.sessionStorage && sessionStorage.getItem('wpvrHotspotTipShown')) return;
216 if (window.sessionStorage) {
217 sessionStorage.setItem('wpvrHotspotTipShown', '1');
218 }
219 alert('Tip: On mobile devices, long-press a hotspot to show its hover content.');
220 }
221 $('.pnlm-container').on('touchstart.wpvrTip touchmove.wpvrTip', showHotspotTip);
222 $('.pnlm-hotspot-base, .pnlm-hotspot').on('touchstart.wpvrTip', showHotspotTip);
223 }
224 }, 800);
225 }
226 });
227
228