PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 9.0.2
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v9.0.2
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.2, at legacy/public/js/wpvr-public.js

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