PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 8.5.35
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v8.5.35
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 8.5.4 All 221 releases
wpvr / admin / js / wpvr-admin.js

wpvr-admin.js in WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress 8.5.35, at admin/js/wpvr-admin.js

2,845 lines 127.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function ($) {
2 'use strict';
3 var j = 1;
4 var color = '#00b4ff';
5 var scene_parent = '';
6
7 window.jQuery.migrateMute = true;
8 /**
9 * All of the code for your admin-facing JavaScript source
10 * should reside in this file.
11 *
12 * Note: It has been assumed you will write jQuery code here, so the
13 * $ function reference has been prepared for usage within the scope
14 * of this function.
15 *
16 * This enables you to define handlers, for when the DOM is ready:
17 *
18 * $(function() {
19 *
20 * });
21 *
22 * When the window is loaded:
23 *
24 * $( window ).load(function() {
25 *
26 * });
27 *
28 * ...and/or other possibilities.
29 *
30 * Ideally, it is not considered best practise to attach more than a
31 * single DOM-ready or window-load handler for a particular page.
32 * Although scripts in the WordPress core, Plugins and Themes may be
33 * practising this, we should strive to set a better example in our own work.
34 */
35
36 let lastChildClicked = false;
37 $(document).ready(function () {
38 if($('#scene-1').find('input.sceneid').val()){
39 $('.scene-gallery').append('<ul style="width:150px;"><li class="owlscene owl" ></li><li title="Double click to Upload scene"><div class="upload-scene-wrapper"><img loading="lazy" class="scctrl upload-form-scene-gallery" src="'+window.wpvr_localize.WPVR_ASSET_PATH+'/icon/scene-upload.svg"><p>Upload Scene</p></div></li></ul>');
40 }else{
41 $('.scene-gallery').append('<ul style="width:150px;"><li class="owlscene owl" ></li><li title="Double click to Upload scene"><div class="upload-scene-wrapper-first"><img loading="lazy" class="scctrl upload-form-scene-gallery-first" src="'+window.wpvr_localize.WPVR_ASSET_PATH+'/icon/scene-upload.svg"><p>Upload Scene</p></div></li></ul>');
42 }
43
44 $(".vrowl-carousel").owlCarousel({
45 margin: 10,
46 autoWidth: true,
47 nav: true
48 });
49
50 var primary_markng = $('#scene-1').find('input.sceneid').val();
51 $('.owl' + primary_markng).parents('.owl-item').addClass('marked');
52
53 $('.meta-box-sortables').sortable({
54 items: '#wpvr_item_builder_box',
55 disabled: true
56 });
57
58 $('.postbox .hndle').css('cursor', 'pointer');
59
60
61 });
62
63 $(document).on("change", "input.vr-switcher-check", function (event) {
64 updateCheckboxStates();
65 $(this).val(this.checked ? 'on' : 'off');
66 });
67
68 updateCheckboxStates();
69 function updateCheckboxStates() {
70 // Check movement controls if wpvr_controls is checked
71 if ($('#wpvr_controls').prop('checked')) {
72 $('#wpvr-check-movement-controls').prop('checked', true);
73 $('#wpvr-check-movement-controls').closest('.wpvr-checklist-item').css('color', '#0E003C');
74 } else if (!$('#wpvr_controls').prop('checked')) {
75 $('#wpvr-check-movement-controls').prop('checked', false);
76 $('#wpvr-check-movement-controls').closest('.wpvr-checklist-item').css('color', '#73707D');
77 }
78
79 // Check zoom controls if either wpvr_mouseZoom or wpvr_keyboardzoom is checked
80 if (($('#wpvr_mouseZoom').prop('checked') || $('#wpvr_keyboardzoom').prop('checked'))) {
81 $('#wpvr-check-zoom-controls').prop('checked', true);
82 $('#wpvr-check-zoom-controls').closest('.wpvr-checklist-item').css('color', '#0E003C');
83 } else if (!$('#wpvr_mouseZoom').prop('checked') && !$('#wpvr_keyboardzoom').prop('checked')) {
84 $('#wpvr-check-zoom-controls').prop('checked', false);
85 $('#wpvr-check-zoom-controls').closest('.wpvr-checklist-item').css('color', '#73707D');
86 }
87
88 updateProgress();
89 }
90
91
92 var specificeSceneID = ''
93 var newScene = ''
94 $(document).on("click", ".scene-nav ul li span", function (event) {
95 $('.owl-item').removeClass('marked');
96 setTimeout(function(){
97 var target = $('.scene-nav ul li.active span').attr("data-index");
98 if(target == undefined){
99 var currentLi = $(this).parent('li');
100 var previousLi = currentLi.prev();
101 if (previousLi.length > 0) {
102 newScene = previousLi.find('span').attr('data-index');
103 }
104 }
105 var data = $('#scene-' + target).find('input.sceneid').val();
106 if (data) {
107 specificeSceneID = data;
108 if(!lastChildClicked){
109 $('.panolenspreview').trigger('click')
110 }
111 $('.owl' + data).parents('.owl-item').addClass('marked');
112 }
113 lastChildClicked = false;
114 }, 500);
115 });
116
117 jQuery(document).ready(function ($) {
118
119 j = $('#scene-1').find('.hotspot-nav li').eq(-2).find('span').attr('data-index');
120 var ajaxurl = wpvr_obj.ajaxurl;
121 $('.panolenspreview').on('click', function (e) {
122 e.preventDefault();
123 $('.wpvr-loading').show();
124 var videourl = $("input[name='video-attachment-url']").val();
125 var vidautoplay = $("input[name='playvideo']:checked").val();
126 var vidcontrol = $("input[name='playcontrol']:checked").val();
127
128 var panovideo = $("input[name='panovideo']:checked").val();
129
130 var postid = $("#post_ID").val();
131 var autoload = $("input[name='autoload']").is(':checked') ? 'on' : 'off';
132 var compass = $("input[name='compass']:checked").val();
133 var control = $("input[name='controls']").is(':checked') ? 'on' : 'off';
134 var rotation = $("input[name='autorotation']").is(':checked') ? 'on' : 'off';
135 var defaultscene = $("input[name='default-scene-id']").val();
136 var preview = $("input[name='preview-attachment-url']").val();
137 var scenefadeduration = $("input[name='scene-fade-duration']").val();
138
139 var autorotation = $("input[name='auto-rotation']").val();
140 var autorotationinactivedelay = $("input[name='auto-rotation-inactive-delay']").val();
141 var autorotationstopdelay = $("input[name='auto-rotation-stop-delay']").val();
142
143 var panodata = $('.scene-setup').repeaterVal();
144 var panolist = JSON.stringify(panodata);
145 var previewtext = $('.previewtext').val();
146
147 jQuery.ajax({
148 type: "POST",
149 url: ajaxurl,
150 data: {
151 action: "wpvr_preview",
152 nonce : wpvr_obj.ajax_nonce,
153 postid: postid,
154 compass: compass,
155 control: control,
156 autoload: autoload,
157 panodata: panolist,
158 defaultscene: defaultscene,
159 rotation: rotation,
160 autorotation: autorotation,
161 autorotationinactivedelay: autorotationinactivedelay,
162 autorotationstopdelay: autorotationstopdelay,
163 preview: preview,
164 scenefadeduration: scenefadeduration,
165 panovideo: panovideo,
166 videourl: videourl,
167 vidautoplay: vidautoplay,
168 vidcontrol: vidcontrol
169 },
170
171 success: function (response) {
172 $('.wpvr-loading').hide();
173 if (response.success == true) {
174 if(response.data[2] == 'off'){
175 $('#error_occured').hide();
176 $('#error_occuredpub').hide();
177 $('#' + response.data[0]["panoid"]).empty();
178 var scenes = response.data[1];
179
180 if (scenes) {
181 $.each(scenes.scenes, function (i) {
182 $.each(scenes.scenes[i]['hotSpots'], function (key, val) {
183 if (val["clickHandlerArgs"] != "") {
184 val["clickHandlerFunc"] = wpvrhotspot;
185 }
186 if (val["createTooltipArgs"] != "") {
187 val["createTooltipFunc"] = wpvrtooltip;
188 }
189 });
190 });
191 }
192 if (scenes) {
193 $('.scene-gallery').trigger('destroy.owl.carousel');
194 $('.scene-gallery').empty();
195
196 $.each(scenes.scenes, function (key, val) {
197 $('.scene-gallery').append('<ul style="width:150px;"><li class="owlscene owl' + key + '">' + key + '</li><li title="Double click to view scene"><img loading="lazy" class="scctrl" id="' + key + '_gallery" src="' + val.panorama + '"></li></ul>');
198 });
199 $('.scene-gallery').append('<ul style="width:150px;"><li class="owlscene owl" ></li><li title="Double click to Upload scene"><div class="upload-scene-wrapper"><img loading="lazy" class="scctrl upload-form-scene-gallery" src="'+window.wpvr_localize.WPVR_ASSET_PATH+'/icon/scene-upload.svg"><p>Upload Image</p></div></li></ul>');
200
201 $(".vrowl-carousel").owlCarousel({
202 margin: 10,
203 autoWidth: true,
204 });
205 var active_owl_target = $('#wpvr_active_scenes').val();
206 var get_owl_target = $('#scene-' + active_owl_target).find('input.sceneid').val();
207 $('.owl' + get_owl_target).parents('.owl-item').addClass('marked');
208 }
209 var panoshow = pannellum.viewer(response.data[0]["panoid"], scenes);
210 if (scenes.autoRotate) {
211 panoshow.on('load', function () {
212 setTimeout(function () {
213 panoshow.startAutoRotate(scenes.autoRotate, 0);
214 }, 3000);
215 });
216 panoshow.on('scenechange', function () {
217 setTimeout(function () {
218 panoshow.startAutoRotate(scenes.autoRotate, 0);
219 }, 3000);
220 });
221 }
222 var touchtime = 0;
223 if (scenes) {
224 $.each(scenes.scenes, function (key, val) {
225 document.getElementById('' + key + '_gallery').addEventListener('click', function (e) {
226 if (touchtime == 0) {
227 touchtime = new Date().getTime();
228 } else {
229 if (((new Date().getTime()) - touchtime) < 800) {
230 panoshow.loadScene(key);
231 activateSceneTab(key)
232 touchtime = 0;
233 } else {
234 touchtime = new Date().getTime();
235 }
236 }
237 });
238 });
239 }
240 if( newScene){
241 var data = $('#scene-' + newScene).find('input.sceneid').val();
242 if(data){
243 panoshow.loadScene(data);
244 }
245 //newScene = ''
246 }
247 if(specificeSceneID){
248 setTimeout(() => {
249 panoshow.loadScene(specificeSceneID);
250 }, 500);
251 }
252 $('html, body').animate({
253 scrollTop: $("#wpvr_item_builder__box").offset().top
254 }, 500);
255 //set preview text
256 if ("" != previewtext) {
257 $('.pnlm-load-button p').text(previewtext);
258 }
259 }else{
260 $('#' + response.data["panoid"]).empty();
261 $('#' + response.data["panoid"]).html(response.data["panodata"]);
262 if (response.data['vidtype'] == 'selfhost') {
263 videojs(response.data["vidid"], {
264 plugins: {
265 pannellum: {}
266 }
267 });
268 }
269 $('html, body').animate({
270 scrollTop: $("#wpvr_item_builder__box").offset().top
271 }, 500);
272 }
273
274 } else {
275 $('#error_occured').show();
276 $('#error_occured .pano-error-message').html(response.data);
277 $('#error_occuredpub').show();
278 $('#error_occuredpub').html(response.data);
279 $('body').addClass('error-overlay');
280 $('html, body').animate({
281 scrollTop: $("#error_occured").offset().top
282 }, 500);
283 }
284
285 }
286 });
287 });
288 });
289 function activateSceneTab(sceneId){
290 jQuery(".scene-nav ul li span").each(function() {
291 // Get the value of the data-href attribute
292 var dataHrefValue = jQuery(this).attr("data-href");
293 var currentScene = jQuery(dataHrefValue).find('input.sceneid').val();
294
295 if(sceneId == currentScene){
296 jQuery(this).trigger('click');
297 }
298 });
299 }
300
301 //-- Set Cookie--//
302
303 function setCookie(cName, cValue, expDays) {
304 let date = new Date();
305 date.setTime(date.getTime() + (expDays * 24 * 60 * 60 * 1000));
306 const expires = "expires=" + date.toUTCString();
307 document.cookie = cName + "=" + cValue + "; " + expires + "; path=/";
308 }
309 // Get a cookie
310
311 function getCookie(cName) {
312 const name = cName + "=";
313 const cDecoded = decodeURIComponent(document.cookie); //to be careful
314 const cArr = cDecoded .split('; ');
315 let res;
316 cArr.forEach(val => {
317 if (val.indexOf(name) === 0) res = val.substring(name.length);
318 })
319 return res;
320 }
321
322 function getParameterByName(name, url = window.location.href) {
323 name = name.replace(/[\[\]]/g, '\\$&');
324 var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
325 results = regex.exec(url);
326 if (!results) return null;
327 if (!results[2]) return '';
328 return decodeURIComponent(results[2].replace(/\+/g, ' '));
329 }
330 function findValueByName(name,dataArray) {
331 for (var i = 0; i < dataArray.length; i++) {
332 if (dataArray[i].name === name) {
333 return dataArray[i].value;
334 }
335 }
336 // Return a default value or handle the case when the name is not found
337 return '';
338 }
339
340 jQuery(document).ready(function ($) {
341 var getRedirectUrl = getCookie("redirectUrl");
342 var getCookiePostID = getCookie("postID");
343
344 const urlParams = getParameterByName("active_tab");
345 const action = wpvr_global_obj.url_info.param.action;
346 let getPostID = wpvr_global_obj.url_info.param.post;
347
348 if(getCookiePostID == getPostID){
349 if(urlParams == '' || urlParams == undefined){
350 if (action == 'edit' && getRedirectUrl != undefined){
351 window.location.replace(getRedirectUrl)
352 setCookie('postID', '', 1);
353 setCookie('redirectUrl', '', 1);
354 }
355 }
356 }
357 var flag_ok = false;
358 $('#publish').on('click', function (e) {
359 e.preventDefault();
360 $('#publish').prop('disabled', true);
361
362 $('.panolenspreview').trigger('click')
363 var data = $('form#post').serializeArray();
364 var post_status = findValueByName('post_status',data)
365 var hidden_post_status = findValueByName('hidden_post_status',data)
366 var hidden_post_password = findValueByName('hidden_post_password',data)
367 var hidden_post_visibility = findValueByName('hidden_post_visibility',data)
368 var visibility = findValueByName('visibility',data)
369 var post_password = findValueByName('post_password',data)
370 var post_title = findValueByName('post_title',data)
371 var x = $(this).val();
372 // if (!flag_ok) {
373 $('.wpvr-loading').show();
374 var postid = $("#post_ID").val();
375 var panovideo = $("input[name='panovideo']:checked").val();
376 var videourl = $("input[name='video-attachment-url']").val();
377 var autoload = $("input[name='autoload']").is(':checked') ? 'on' : 'off';
378 var control = $("input[name='controls']").is(':checked') ? 'on' : 'off';
379 var compass = $("input[name='compass']:checked").val();
380 var defaultscene = $("input[name='default-scene-id']").val();
381 var preview = $("input[name='preview-attachment-url']").val();
382 var rotation = $("input[name='autorotation']").is(':checked') ? 'on' : 'off'; // Auto Rotation checkbox value
383 var autorotation = $("input[name='auto-rotation']").val();
384 var autorotationinactivedelay = $("input[name='auto-rotation-inactive-delay']").val();
385 var autorotationstopdelay = $("input[name='auto-rotation-stop-delay']").val();
386
387 var scenefadeduration = $("input[name='scene-fade-duration']").val();
388 var previewtext = $('.previewtext').val();
389 if ($('.scene-setup')[0]) {
390 var panodata = $('.scene-setup').repeaterVal();
391
392 var panolist = JSON.stringify(panodata);
393 } else {
394 var panodata = '';
395 var panolist = '';
396 }
397
398
399 //get the checklist data
400 var checklistData = {};
401 var checklistKeys = [
402 'scene',
403 'media',
404 'default',
405 'hotspots',
406 'movement-controls',
407 'publish'
408 ];
409
410 if(wpvr_obj?.is_wpvr_pro_active){
411 checklistKeys.push('zoom-controls');
412 }
413
414 checklistKeys.forEach(function (key) {
415 checklistData['wpvr_check_' + key] = document.getElementById('wpvr-check-' + key).checked;
416 });
417
418 jQuery.ajax({
419
420 type: "POST",
421 url: ajaxurl,
422 data: {
423 action: "wpvr_save",
424 nonce : wpvr_obj.ajax_nonce,
425 postid: postid,
426 panovideo: panovideo,
427 videourl: videourl,
428 control: control,
429 compass: compass,
430 autoload: autoload,
431 panodata: panolist,
432 defaultscene: defaultscene,
433 preview: preview,
434 rotation: rotation, // Auto Rotation checkbox value
435 autorotation: autorotation, // Rotatin speed
436 autorotationinactivedelay: autorotationinactivedelay,
437 autorotationstopdelay: autorotationstopdelay,
438 scenefadeduration: scenefadeduration,
439 previewtext: previewtext,
440
441 hidden_post_status: hidden_post_status,
442 post_status: post_status,
443 hidden_post_password: hidden_post_password,
444 hidden_post_visibility: hidden_post_visibility,
445 visibility: visibility,
446 post_password: post_password,
447 post_value: $('#publish').val(),
448 post_title: post_title,
449 checklistData: checklistData,
450 },
451
452 success: function (response) {
453 $('.wpvr-loading').hide();
454 $('#publish').prop('disabled', false);
455 if (response.success == false) {
456 $('#error_occured').show();
457 $('#error_occured .pano-error-message').html(response.data);
458 $('#error_occuredpub').show();
459 $('#error_occuredpub').html(response.data);
460
461 $('body').addClass('error-overlay');
462 $('html, body').animate({
463 scrollTop: $("#error_occured").offset().top
464 }, 500);
465 } else {
466
467 if(!$('#wpvr-check-publish').prop('checked')){
468 $('#wpvr-check-publish').prop('checked', true);
469 $('#wpvr-check-publish').closest('.wpvr-checklist-item').css('color', '#0E003C');
470 }
471 updateProgress();
472
473 flag_ok = true;
474 $("#publishing-action").prepend(
475 `<div class="success-message" id="wpvr-success-message">
476 <p>${wpvr_obj?.successfully_updated}</p>
477 </div>`
478 );
479 setTimeout(function(){
480 $("#wpvr-success-message").remove();
481 }, 3000 );
482 var url_info = wpvr_global_obj.url_info
483 var oldUrl = '';
484 let params = (new URL(document.location)).searchParams;
485 let active_tab = params.get('active_tab');
486 oldUrl = url_info.admin_url+"post.php?"+"post="+postid+"&action=edit"+"&active_tab="+active_tab;
487 if ( 'add' == url_info.screen ){
488 setCookie('redirectUrl', oldUrl, 1);
489 setCookie('postID', postid, 1);
490 }else{
491 setCookie('postID', postid, 1);
492
493 setCookie('redirectUrl', oldUrl, 1);
494 }
495 var publishedOptionSelected = $("#post_status option[value='publish']").length > 0;
496 if (!publishedOptionSelected) {
497 $("#post_status").append('<option selected="selected" value="publish">Published</option>')
498 }
499 var statusText = $("#post_status").val()
500 $("#post-status-display").text(statusText)
501 let site_language = wpvr_obj?.site_language;
502 let translatedText = wpvr_obj?.translated_languages?.[site_language] ?? {};
503 if(response.data.post_status == 'draft'){
504 let publish_text = translatedText?.['Publish'] ?? 'Publish';
505 $('#publish').val(publish_text);
506 }else{
507 let update_text = translatedText?.['Update'] ?? 'Update';
508 $('#publish').val(update_text);
509 }
510 window.history.replaceState(null, '', url_info.admin_url+"post.php?"+"post="+postid+"&action=edit");
511 }
512 }
513 });
514 // }
515 });
516 });
517
518 jQuery(document).ready(function ($) {
519 $("body, .pano-error-close-btn").on("click", function (e) {
520 $("#error_occured").hide();
521 $('body').removeClass('error-overlay');
522 });
523
524 $(".panolenspreview, #error_occured").on("click", function (e) {
525 e.stopPropagation();
526 });
527 });
528
529 jQuery(document).ready(function ($) {
530 var previewtext = $('.previewtext').val();
531 if ("" != previewtext) {
532 $('.pnlm-load-button p').text(previewtext);
533 }
534 });
535
536 jQuery(document).ready(function ($) {
537
538 var flag_ok = false;
539 $('#save-post').on('click', function (e) {
540 var x = $(this).val();
541 if (!flag_ok) {
542 e.preventDefault();
543 $('.wpvr-loading').show();
544 var postid = $("#post_ID").val();
545 var panovideo = $("input[name='panovideo']:checked").val();
546 var videourl = $("input[name='video-attachment-url']").val();
547 var autoload = $("input[name='autoload']").val();
548 var control = $("input[name='controls']").val();
549 var compass = $("input[name='compass']:checked").val();
550 var defaultscene = $("input[name='default-scene-id']").val();
551 var preview = $("input[name='preview-attachment-url']").val();
552 var rotation = $("input[name='autorotation']").is(':checked') ? 'on' : 'off';
553 var autorotation = $("input[name='auto-rotation']").val();
554 var autorotationinactivedelay = $("input[name='auto-rotation-inactive-delay']").val();
555 var autorotationstopdelay = $("input[name='auto-rotation-stop-delay']").val();
556
557 var scenefadeduration = $("input[name='scene-fade-duration']").val();
558
559 if ($('.scene-setup')[0]) {
560 var panodata = $('.scene-setup').repeaterVal();
561 var panolist = JSON.stringify(panodata);
562 } else {
563 var panodata = '';
564 var panolist = '';
565 }
566
567 //get the checklist data
568 var checklistData = {};
569 var checklistKeys = [
570 'scene',
571 'media',
572 'default',
573 'hotspots',
574 'movement-controls',
575 'publish'
576 ];
577
578 if(wpvr_localize?.is_wpvr_pro_active){
579 checklistKeys.push('zoom-controls');
580 }
581
582 checklistKeys.forEach(function (key) {
583 checklistData['wpvr_check_' + key] = document.getElementById('wpvr-check-' + key).checked;
584 });
585
586 updateProgress();
587
588 jQuery.ajax({
589
590 type: "POST",
591 url: ajaxurl,
592 data: {
593 action: "wpvr_save",
594 nonce : wpvr_obj.ajax_nonce,
595 postid: postid,
596 panovideo: panovideo,
597 videourl: videourl,
598 control: control,
599 compass: compass,
600 autoload: autoload,
601 panodata: panolist,
602 defaultscene: defaultscene,
603 preview: preview,
604 rotation: rotation,
605 autorotation: autorotation,
606 autorotationinactivedelay: autorotationinactivedelay,
607 autorotationstopdelay: autorotationstopdelay,
608 scenefadeduration: scenefadeduration,
609 checklistData: checklistData
610 },
611
612 success: function (response) {
613 $('.wpvr-loading').hide();
614 if (response.success == false) {
615 $('#error_occured').show();
616 $('#error_occured').html(response.data);
617 $('#error_occuredpub').show();
618 $('#error_occuredpub').html(response.data);
619
620 $('body').addClass('error-overlay');
621 $('html, body').animate({
622 scrollTop: $("#error_occured").offset().top
623 }, 500);
624 } else {
625
626 if(!$('#wpvr-check-publish').prop('checked')){
627 $('#wpvr-check-publish').prop('checked', true);
628 $('#wpvr-check-publish').closest('.wpvr-checklist-item').css('color', '#0E003C');
629 }
630 updateProgress();
631
632 flag_ok = true;
633 $('#save-post').trigger('click');
634 }
635 }
636 });
637 }
638 });
639 });
640 // $("#custom-ifram").css({
641 // "height": "auto",
642 // "width": "auto",
643 // "max-width": "60%",
644 // "max-height": "80%",
645 // "text-align": "center",
646 // "padding": "8px",
647 // "overflow": "auto",
648 // });
649
650
651
652
653
654
655 function wpvrhotspot(hotSpotDiv, args) {
656 var argst = args.replace(/\\/g, '');
657 $("#custom-ifram").html(argst);
658 $("#custom-ifram").fadeToggle();
659 $(".iframe-wrapper").toggleClass("show-modal");
660
661 }
662
663 function wpvrtooltip(hotSpotDiv, args) {
664 hotSpotDiv.classList.add('custom-tooltip');
665 var span = document.createElement('p');
666 args = args.replace(/\\/g, "");
667 span.innerHTML = args;
668 hotSpotDiv.appendChild(span);
669 span.style.marginLeft = -(span.scrollWidth - hotSpotDiv.offsetWidth) / 2 + 'px';
670 span.style.marginTop = -span.scrollHeight - 12 + 'px';
671 }
672
673 jQuery(document).ready(function ($) {
674 $("#cross").on("click", function (e) {
675 e.preventDefault();
676 $("#custom-ifram").fadeOut();
677 $(".iframe-wrapper").removeClass("show-modal");
678 $('iframe').attr('src', $('iframe').attr('src'));
679 });
680 });
681
682 jQuery(document).ready(function ($) {
683
684 var i = $('.scene-nav li').eq(-2).find('span').attr('data-index');
685 i = parseInt(i);
686
687 $('.scene-setup').repeater({
688
689 defaultValues: {
690 'scene-type': 'equirectangular',
691 'dscene': 'off',
692 'ptyscene': 'off',
693 'cvgscene': 'off',
694 'chgscene': 'off',
695 'czscene': 'off',
696 },
697 show: function () {
698 $('textarea[name*=hotspot-content]').summernote({
699 toolbar: [
700 ['style', ['style']],
701 ['font', ['bold', 'underline', 'clear']],
702 ['fontname', ['fontname']],
703 ['color', ['color']],
704 ['para', ['ul', 'ol', 'paragraph']],
705 ['table', ['table']],
706 ['insert', ['link', 'picture', 'video']],
707 ['view', ['codeview', 'help']],
708 ],
709 callbacks: {
710 onKeyup: function(e) {
711 var getHotspotContent = $(this).summernote('code').trim();
712 var tempDiv = document.createElement('div');
713 tempDiv.innerHTML = getHotspotContent;
714 var plainText = tempDiv.textContent || tempDiv.innerText || '';
715 plainText = plainText.replace(/\u00a0/g, '').trim();
716 var getParent = $(this).parent();
717 var getMainParent = getParent.parent();
718 var getClickContent = getMainParent.find('.hotspot-url');
719
720 if (plainText.length > 0) {
721 getClickContent.find('input[name*=hotspot-url]').val('');
722 getClickContent.find('input[name*=hotspot-url]').attr('placeholder', 'You can set either a URL or an On-click content');
723 getClickContent.find('input[name*=hotspot-url]').attr("disabled", true);
724 } else {
725 getClickContent.find('input[name*=hotspot-url]').attr("disabled", false);
726 }
727 }
728 }
729 });
730 $('textarea[name*=hotspot-hover]').summernote({
731 toolbar: [
732 ['style', ['style']],
733 ['font', ['bold', 'underline', 'clear']],
734 ['fontname', ['fontname']],
735 ['color', ['color']],
736 ['para', ['ul', 'ol', 'paragraph']],
737 ['table', ['table']],
738 ['insert', ['link', 'picture', 'video']],
739 ['view', ['codeview', 'help']],
740 ],
741 fontNames: ['Arial', 'Helvetica', 'Tahoma', 'Courier New', 'Verdana', 'Impact', 'Times New Roman', 'system-ui', 'Helvetica Neue'],
742 callbacks: {
743 onInit: function() {
744 var $editor = $(this);
745
746 // Override font name dropdown click handler for this specific editor
747 $editor.next('.note-editor').find('.dropdown-fontname a').off('click').on('click', function(e) {
748 e.preventDefault();
749 var fontName = $(this).data('value') || $(this).text();
750
751 // Focus on the current editor
752 $editor.summernote('focus');
753
754 // Use Summernote's built-in method to apply font
755 try {
756 // First, clear any existing font formatting
757 var range = $editor.summernote('createRange');
758 if (range && !range.isCollapsed()) {
759 // Get selected text
760 var selectedText = range.toString();
761
762 // Use Summernote's insertHTML to replace content
763 var fontHtml = '<span style="font-family: ' + fontName + ';">' + selectedText + '</span>';
764 $editor.summernote('insertHTML', fontHtml);
765 } else {
766 // No selection, use execCommand for typing
767 $editor.summernote('focus');
768 document.execCommand('fontName', false, fontName);
769 }
770 } catch (error) {
771 console.log('Font application error, using fallback method');
772 // Fallback method
773 document.execCommand('fontName', false, fontName);
774 }
775
776 // Update dropdown button text for this editor
777 $(this).closest('.note-editor').find('.note-current-fontname').text(fontName);
778
779 // Close dropdown
780 var $dropdownMenu = $(this).closest('.dropdown-menu');
781 $dropdownMenu.removeClass('show').hide();
782 $dropdownMenu.prev('.dropdown-toggle').removeClass('show').attr('aria-expanded', 'false');
783
784 // Trigger change event
785 setTimeout(function() {
786 $editor.trigger('summernote.change');
787 }, 100);
788 });
789 },
790
791 // Clean up the content after any change
792 onChange: function(contents, $editable) {
793 // Debounce the cleanup to avoid conflicts
794 clearTimeout(this.cleanupTimeout);
795 this.cleanupTimeout = setTimeout(function() {
796 // Remove all font-family styles from elements that shouldn't have them
797 $editable.find('*:not(span)').each(function() {
798 if (this.style && this.style.fontFamily) {
799 this.style.fontFamily = '';
800 }
801 });
802
803 // Clean up empty spans
804 $editable.find('span').each(function() {
805 var $span = $(this);
806 var text = $span.text().replace(/[\uFEFF\u200B-\u200D\u2060]/g, '').trim();
807
808 if (!text) {
809 $span.remove();
810 } else {
811 // If span has other styles besides font-family, keep only font-family
812 var fontFamily = $span.css('font-family');
813 if (fontFamily && fontFamily !== 'inherit') {
814 $span.attr('style', 'font-family: ' + fontFamily + ';');
815 } else if (!fontFamily || fontFamily === 'inherit') {
816 $span.contents().unwrap();
817 }
818 }
819 });
820
821 // Remove nested spans with font-family
822 $editable.find('span[style*="font-family"] span[style*="font-family"]').each(function() {
823 $(this).contents().unwrap();
824 });
825 }, 200);
826 }
827 }
828 });
829 if ($(this).parents(".scene-setup").attr("data-limit").length > 0) {
830 lastChildClicked = true;
831 if ($(this).parents(".scene-setup").find("div[data-repeater-item]:not(.hotspot-setup div[data-repeater-item])").length <= $(this).parents(".scene-setup").attr("data-limit")) {
832
833 $(this).slideDown();
834 $(this).removeClass('active');
835
836 i = i + 1;
837 var scene = 'scene-' + i;
838
839 $(this).find(".title .scene-num").html(i);
840
841 $('<li><span data-index="' + i + '" data-href="#' + scene + '"><i class="fa fa-image"></i></span></li>').insertBefore($(this).parent().parent('.scene-setup').find('.scene-nav ul li:last-child'));
842
843 $(this).attr('id', scene);
844 changehotspotid(i);
845 $(this).siblings('.active').removeClass('active');
846 $(this).addClass('active');
847 $(this).find(".sceneid").val(generateRandomString(8));
848 setTimeout(changeicon, 1000);
849 } else {
850 $('.pano-alert .pano-error-message').html('<span class="pano-error-title">Limit Reached</span><p> You can add up to 5 scenes on each tour in the Free version. Upgrade to Pro to create tours with unlimited scenes.</p>');
851 $('body').addClass('error-overlay2');
852 $('.pano-alert').addClass('pano-default-warning').show();
853 $(this).remove();
854 }
855 } else {
856 jQuery(this).slideDown();
857 $(this).removeClass('active');
858
859 i = i + 1;
860 var scene = 'scene-' + i;
861 $(this).find(".title .scene-num").html(i);
862 $('<li><span data-index="' + i + '" data-href="#' + scene + '"><i class="fa fa-image"></i></span></li>').insertBefore($(this).parent().parent('.scene-setup').find('.scene-nav ul li:last-child'));
863 $(this).attr('id', scene);
864 changehotspotid(i);
865 }
866
867 $(this).hide();
868
869 //tab active setup
870 $('#wpvr_active_scenes').val(i);
871 $('#wpvr_active_hotspot').val(1);
872 },
873 hide: function (deleteElement) {
874 var hide_id = $(this).attr("id");
875 var _hide_id = hide_id.split('-').pop();
876 hide_id = "#" + hide_id;
877
878 var current = $(this).attr('id');
879 var fchild = $('.single-scene:nth-child(2)').attr('id');
880 // var fchild = $(this).parent().children(":first").attr('id');
881
882
883 var elementcontains = $(this).attr("id");
884 var str1 = 'scene';
885 var str2 = 'hotspot';
886 if (elementcontains.indexOf(str1) != -1 && elementcontains.indexOf(str2) == -1) {
887
888 var _this = $(this);
889
890 if (confirm('Are you sure you want to delete?')) {
891 jQuery(_this).slideUp(deleteElement);
892 if (current == fchild) {
893 $(_this).next().addClass("active");
894 $(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").next().addClass("active");
895 $(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").next().children("span").trigger("click");
896 } else {
897 $(_this).prev().addClass("active");
898 $(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").prev().addClass("active");
899 $(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").prev().children("span").trigger("click");
900 }
901 $(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").remove();
902 setTimeout(deleteinfodata, 1000);
903
904 //tab active setup
905 if (parseInt(_hide_id) - 1 > 0) {
906 $('#wpvr_active_scenes').val(parseInt(_hide_id) - 1);
907 } else {
908 $('#wpvr_active_scenes').val(1);
909 }
910 $('#wpvr_active_hotspot').val(1);
911
912
913 setTimeout(function(){
914 let sceneImageCount = $('.rex-pano-tab .single-scene .scene-left .scene-setting .form-group img')
915 .filter(function() {
916 return $(this).attr('src') && $(this).attr('src').trim() !== '';
917 })
918 .length;
919
920 let defaultScene = false;
921 let hotspotCheck = false;
922
923 let $sceneCheckbox = $('#wpvr-check-scene');
924 let $mediaCheckbox = $('#wpvr-check-media');
925 let $hotspotCheck = $('#wpvr-check-hotspots');
926 let $defaultCheck = $('#wpvr-check-default');
927
928 $('select').each(function() {
929 if (/^scene-list\[\d+\]\[dscene\]$/.test($(this).attr('name'))) {
930 let selectedValue = $(this).val();
931 if('on' === selectedValue){
932 defaultScene = true;
933 }
934 }
935 });
936
937 if (sceneImageCount === 0) {
938 $sceneCheckbox.prop('checked', false);
939 $mediaCheckbox.prop('checked', false);
940 $sceneCheckbox.closest('.wpvr-checklist-item').css('color', '#73707D');
941 $mediaCheckbox.closest('.wpvr-checklist-item').css('color', '#73707D');
942 }
943
944 if(!defaultScene){
945 $defaultCheck.prop('checked', false);
946 $defaultCheck.closest('.wpvr-checklist-item').css('color', '#73707D');
947 }
948
949 let pitchInputs = document.querySelectorAll('.hotspot-pitch');
950 for (let pitchInput of pitchInputs) {
951 if (pitchInput.value.trim() !== '') {
952 hotspotCheck = true;
953 }
954 }
955
956 if(!hotspotCheck)
957 {
958 $hotspotCheck.prop('checked', false);
959 $hotspotCheck.closest('.wpvr-checklist-item').css('color', '#73707D');
960 }
961 updateProgress();
962 }, 500);
963 }
964
965 }
966 },
967 repeaters: [{
968 selector: '.hotspot-setup',
969 defaultValues: {
970 'hotspot-type': 'info',
971 'hotspot-customclass-pro': 'none',
972 },
973 show: function () {
974 $('textarea[name*=hotspot-content]').summernote({
975 toolbar: [
976 ['style', ['style']],
977 ['font', ['bold', 'underline', 'clear']],
978 ['fontname', ['fontname']],
979 ['color', ['color']],
980 ['para', ['ul', 'ol', 'paragraph']],
981 ['table', ['table']],
982 ['insert', ['link', 'picture', 'video']],
983 ['view', ['codeview', 'help']],
984 ],
985 callbacks: {
986 onKeyup: function(e) {
987 var getHotspotContent = $(this).summernote('code').trim();
988 var tempDiv = document.createElement('div');
989 tempDiv.innerHTML = getHotspotContent;
990 var plainText = tempDiv.textContent || tempDiv.innerText || '';
991 plainText = plainText.replace(/\u00a0/g, '').trim();
992 var getParent = $(this).parent();
993 var getMainParent = getParent.parent();
994 var getClickContent = getMainParent.find('.hotspot-url');
995
996 if (plainText.length > 0) {
997 getClickContent.find('input[name*=hotspot-url]').val('');
998 getClickContent.find('input[name*=hotspot-url]').attr('placeholder', 'You can set either a URL or an On-click content');
999 getClickContent.find('input[name*=hotspot-url]').attr("disabled", true);
1000 } else {
1001 getClickContent.find('input[name*=hotspot-url]').attr("disabled", false);
1002 }
1003 }
1004 }
1005 });
1006 $('textarea[name*=hotspot-hover]').summernote({
1007 toolbar: [
1008 ['style', ['style']],
1009 ['font', ['bold', 'underline', 'clear']],
1010 ['fontname', ['fontname']],
1011 ['color', ['color']],
1012 ['para', ['ul', 'ol', 'paragraph']],
1013 ['table', ['table']],
1014 ['insert', ['link', 'picture', 'video']],
1015 ['view', ['codeview', 'help']],
1016 ],
1017 fontNames: ['Arial', 'Helvetica', 'Tahoma', 'Courier New', 'Verdana', 'Impact', 'Times New Roman', 'system-ui', 'Helvetica Neue'],
1018 callbacks: {
1019 onInit: function() {
1020 var $editor = $(this);
1021
1022 // Override font name dropdown click handler for this specific editor
1023 $editor.next('.note-editor').find('.dropdown-fontname a').off('click').on('click', function(e) {
1024 e.preventDefault();
1025 var fontName = $(this).data('value') || $(this).text();
1026
1027 // Focus on the current editor
1028 $editor.summernote('focus');
1029
1030 // Use Summernote's built-in method to apply font
1031 try {
1032 // First, clear any existing font formatting
1033 var range = $editor.summernote('createRange');
1034 if (range && !range.isCollapsed()) {
1035 // Get selected text
1036 var selectedText = range.toString();
1037
1038 // Use Summernote's insertHTML to replace content
1039 var fontHtml = '<span style="font-family: ' + fontName + ';">' + selectedText + '</span>';
1040 $editor.summernote('insertHTML', fontHtml);
1041 } else {
1042 // No selection, use execCommand for typing
1043 $editor.summernote('focus');
1044 document.execCommand('fontName', false, fontName);
1045 }
1046 } catch (error) {
1047 console.log('Font application error, using fallback method');
1048 // Fallback method
1049 document.execCommand('fontName', false, fontName);
1050 }
1051
1052 // Update dropdown button text for this editor
1053 $(this).closest('.note-editor').find('.note-current-fontname').text(fontName);
1054
1055 // Close dropdown
1056 var $dropdownMenu = $(this).closest('.dropdown-menu');
1057 $dropdownMenu.removeClass('show').hide();
1058 $dropdownMenu.prev('.dropdown-toggle').removeClass('show').attr('aria-expanded', 'false');
1059
1060 // Trigger change event
1061 setTimeout(function() {
1062 $editor.trigger('summernote.change');
1063 }, 100);
1064 });
1065 },
1066
1067 // Clean up the content after any change
1068 onChange: function(contents, $editable) {
1069 // Debounce the cleanup to avoid conflicts
1070 clearTimeout(this.cleanupTimeout);
1071 this.cleanupTimeout = setTimeout(function() {
1072 // Remove all font-family styles from elements that shouldn't have them
1073 $editable.find('*:not(span)').each(function() {
1074 if (this.style && this.style.fontFamily) {
1075 this.style.fontFamily = '';
1076 }
1077 });
1078
1079 // Clean up empty spans
1080 $editable.find('span').each(function() {
1081 var $span = $(this);
1082 var text = $span.text().replace(/[\uFEFF\u200B-\u200D\u2060]/g, '').trim();
1083
1084 if (!text) {
1085 $span.remove();
1086 } else {
1087 // If span has other styles besides font-family, keep only font-family
1088 var fontFamily = $span.css('font-family');
1089 if (fontFamily && fontFamily !== 'inherit') {
1090 $span.attr('style', 'font-family: ' + fontFamily + ';');
1091 } else if (!fontFamily || fontFamily === 'inherit') {
1092 $span.contents().unwrap();
1093 }
1094 }
1095 });
1096
1097 // Remove nested spans with font-family
1098 $editable.find('span[style*="font-family"] span[style*="font-family"]').each(function() {
1099 $(this).contents().unwrap();
1100 });
1101 }, 200);
1102 }
1103 }
1104 });
1105 if ($(this).parents(".hotspot-setup").attr("data-limit").length > 0) {
1106
1107 if ($(this).parents(".hotspot-setup").find("div[data-repeater-item]").length <= $(this).parents(".hotspot-setup").attr("data-limit")) {
1108
1109 $(this).slideDown();
1110 $(this).removeClass('active');
1111 $(this).siblings('.active').removeClass('active');
1112 $(this).addClass('active');
1113 j = parseInt(j);
1114 j = j + 1;
1115 var parent_scene = $(this).parent().parent().parent('.single-scene.active').attr('id');
1116 scene_parent = parent_scene;
1117 var hotspot = parent_scene + '-hotspot-' + j;
1118
1119 var replace_string = parent_scene.replace("scene-", "");
1120
1121 $(this).find(".title .hotspot-num").html(j);
1122 $(this).find(".title .scene-num").html(replace_string);
1123
1124 $('<li><span data-index="' + j + '" data-href="#' + hotspot + '"><i class="far fa-dot-circle"></i></span></li>').insertBefore($(this).parent().parent('.hotspot-setup').find('.hotspot-nav ul li:last-child'));
1125
1126 $(this).attr('id', hotspot);
1127
1128 setTimeout(changeicon, 1000);
1129 } else {
1130 $('.pano-alert .pano-error-message').html('<span class="pano-error-title">Limit Reached</span><p> You can add up to 5 hotspots on each scene in the Free version. <br> Upgrade to Pro to add an unlimited number of hotspots.</p>');
1131 $('body').addClass('error-overlay2');
1132 $('.pano-alert').addClass('pano-default-warning').show();
1133 $(this).remove();
1134 }
1135 } else {
1136 jQuery(this).slideDown();
1137 $(this).removeClass('active');
1138 j = parseInt(j);
1139 j = j + 1;
1140 var parent_scene = $(this).parent().parent().parent('.single-scene.active').attr('id');
1141 var hotspot = parent_scene + '-hotspot-' + j;
1142
1143 var replace_string = parent_scene.replace("scene-", "");
1144
1145 $(this).find(".title .hotspot-num").html(j);
1146 $(this).find(".title .scene-num").html(replace_string);
1147
1148 $('<li><span data-index="' + j + '" data-href="#' + hotspot + '"><i class="far fa-dot-circle"></i></span></li>').insertBefore($(this).parent().parent('.hotspot-setup').find('.hotspot-nav ul li:last-child'));
1149
1150 $(this).attr('id', hotspot);
1151 }
1152 $('#wpvr_active_hotspot').val(j);
1153 },
1154 hide: function (deleteElement) {
1155 var hotspot_hide_id = $(this).attr("id");
1156 var _hide_id = hotspot_hide_id.split('-').pop();
1157 hotspot_hide_id = "#" + hotspot_hide_id;
1158 var hotspot_current = $(this).attr('id');
1159 var hotspot_fchild = $(this).parent().children(":first").attr('id');
1160
1161 var hpelementcontains = $(this).attr("id");
1162 var hpstr1 = 'scene';
1163 var hpstr2 = 'hotspot';
1164 if (hpelementcontains.indexOf(hpstr1) != -1 && hpelementcontains.indexOf(hpstr2) != -1) {
1165
1166 var _this = $(this);
1167
1168 if (confirm('Are you sure you want to delete?')) {
1169 jQuery(_this).slideUp(deleteElement);
1170 if (hotspot_current == hotspot_fchild) {
1171 $(_this).next().addClass("active");
1172 $(_this).parent().parent('.hotspot-setup').find('.hotspot-nav li span[data-href="' + hotspot_hide_id + '"]').parent("li").next().addClass("active");
1173
1174 } else {
1175 $(_this).prev().addClass("active");
1176 $(_this).parent().parent('.hotspot-setup').find('.hotspot-nav li span[data-href="' + hotspot_hide_id + '"]').parent("li").prev().addClass("active");
1177 }
1178
1179 $(_this).parent().parent('.hotspot-setup').find('.hotspot-nav li:not(:last-child) span[data-href="' + hotspot_hide_id + '"]').parent("li").remove();
1180
1181 //tab active setup
1182 if (parseInt(_hide_id) - 1 > 0) {
1183 $('#wpvr_active_hotspot').val(parseInt(_hide_id) - 1);
1184 } else {
1185 $('#wpvr_active_hotspot').val(1);
1186 }
1187
1188 setTimeout(function(){
1189 let yawInputs = $('.hotspot-yaw');
1190 let pitchInputs = $('.hotspot-pitch');
1191 let hasYawValue = false;
1192 let hasPitchValue = false;
1193
1194 yawInputs.each(function() {
1195 if ($(this).val() && $(this).val().trim() !== '') {
1196 hasYawValue = true;
1197 return false; // break loop
1198 }
1199 });
1200 pitchInputs.each(function() {
1201 if ($(this).val() && $(this).val().trim() !== '') {
1202 hasPitchValue = true;
1203 return false; // break loop
1204 }
1205 });
1206
1207 let $hotspotCheckbox = $('#wpvr-check-hotspots');
1208
1209 if (!hasYawValue && !hasPitchValue) {
1210 $hotspotCheckbox.prop('checked', false);
1211 $hotspotCheckbox.closest('.wpvr-checklist-item').css('color', '#73707D');
1212 } else {
1213 $hotspotCheckbox.prop('checked', true);
1214 $hotspotCheckbox.closest('.wpvr-checklist-item').css('color', '#0E003C');
1215 }
1216 updateProgress();
1217 },500);
1218 }
1219 }
1220 },
1221
1222 }]
1223 });
1224 });
1225
1226 $(document).on("click", ".upload-scene-wrapper", function (event) {
1227 $(".scene-nav ul li:last-child span").trigger("click");
1228 $(".scene-upload").trigger("click");
1229 })
1230
1231 $(document).on("click", ".upload-scene-wrapper-first", function (event) {
1232 $(".scene-upload").trigger("click");
1233 })
1234
1235 $(document).on("click", ".scene-upload", function (event) {
1236 event.preventDefault();
1237 var parent = $(this).parent('.form-group');
1238
1239 var scene_uploader = wp.media({
1240 title: $(this).data('uploader_title'),
1241 button: {
1242 text: $(this).data('uploader_button_text'),
1243 },
1244 library: {
1245 type: ['image']
1246 },
1247 multiple: false
1248 });
1249
1250 scene_uploader.on('select', function () {
1251
1252 var attachment = scene_uploader.state().get('selection').first().toJSON();
1253
1254 var imageUrl = attachment.url;
1255 var siteProtocol = window.location.protocol;
1256 var imageProtocol = new URL(imageUrl).protocol;
1257
1258 $('.rex-add-coordinates .mixed-content-warning, .rex-add-coordinates .mixed-content-doc-link').remove();
1259
1260 if (siteProtocol !== imageProtocol) {
1261
1262 // Create warning message
1263 var $warningBox = $('<div>', {
1264 text: "You're loading an image over " + imageProtocol.replace(':', '').toUpperCase() +
1265 " on a site using " + siteProtocol.replace(':', '').toUpperCase() +
1266 ". This may cause a mixed content issue.",
1267 class: 'mixed-content-warning',
1268 css: {
1269 color: 'red',
1270 marginTop: '35px',
1271 }
1272 });
1273
1274 // Create doc link
1275 var $docLink = $('<a>', {
1276 href: 'https://rextheme.com/docs/wp-vr-tour-not-displaying/',
1277 text: 'View fix guide',
1278 target: '_blank',
1279 class: 'mixed-content-doc-link',
1280 css: {
1281 display: 'block',
1282 color: '#0073aa',
1283 textDecoration: 'underline'
1284 }
1285 }).on('click', function () {
1286 $(this).blur(); // Remove focus after click
1287 });
1288
1289 // Prepend warning and link to the top of the container
1290 $('.rex-add-coordinates').prepend($warningBox, $docLink);
1291 }
1292
1293 parent.find('.scene-attachment-url').val(attachment.url);
1294 parent.find('img').attr('src', attachment.url).show();
1295
1296 setTimeout(function () {
1297 if (!$('#wpvr-check-scene').is(':checked')) {
1298 $('#wpvr-check-scene').prop('checked', true);
1299 $('#wpvr-check-scene').closest('.wpvr-checklist-item').css('color', '#0E003C');
1300 }
1301
1302 if (!$('#wpvr-check-media').is(':checked')) {
1303 $('#wpvr-check-media').prop('checked', true);
1304 $('#wpvr-check-media').closest('.wpvr-checklist-item').css('color', '#0E003C');
1305 }
1306
1307 updateProgress();
1308
1309 $('.panolenspreview').trigger('click');
1310 }, 1000);
1311
1312
1313 });
1314
1315 scene_uploader.open();
1316 });
1317
1318 $(document).on("click", ".video-upload", function (event) {
1319 event.preventDefault();
1320
1321 var parent = $(this).parent('.form-group');
1322
1323 var video_uploader = wp.media({
1324 title: $(this).data('uploader_title'),
1325 button: {
1326 text: $(this).data('uploader_button_text'),
1327 },
1328 library: {
1329 type: ['video/mp4']
1330 },
1331 multiple: false
1332 });
1333
1334 video_uploader.on('select', function () {
1335 var attachment = video_uploader.state().get('selection').first().toJSON();
1336 parent.find('.video-attachment-url').val(attachment.url);
1337 });
1338
1339 video_uploader.open();
1340 });
1341
1342 $(document).on("click", ".preview-upload", function (event) {
1343 event.preventDefault();
1344 var parent = $(this).parent('.form-group');
1345
1346 var preview_uploader = wp.media({
1347 title: $(this).data('uploader_title'),
1348 button: {
1349 text: $(this).data('uploader_button_text'),
1350 },
1351 library: {
1352 type: ['image']
1353 },
1354 multiple: false
1355 });
1356
1357 preview_uploader.on('select', function () {
1358 var attachment = preview_uploader.state().get('selection').first().toJSON();
1359 parent.find('.preview-attachment-url').val(attachment.url);
1360 parent.find('.img-upload-frame').css('background-image', 'url(' + attachment.url + ')');
1361 parent.find('.img-upload-frame').addClass('img-uploaded');
1362 parent.find('.remove-attachment').show();
1363 });
1364
1365 preview_uploader.open();
1366 });
1367
1368 //----remove tour preview image----
1369 $(document).on("click", ".remove-attachment", function (event) {
1370 $(this).hide();
1371 parent = $(this).parents('.form-group');
1372
1373 parent.find('.preview-attachment-url').val('');
1374 parent.find('.img-upload-frame').css('background-image', '');
1375 parent.find('.img-upload-frame').removeClass('img-uploaded');
1376 });
1377
1378
1379 $(document).on("change", "select[name*=hotspot-type]", function (event) {
1380
1381 var getparent = $(this).parent();
1382 var getvalue = $(this).val();
1383 if (getvalue == 'info') {
1384 getparent.find('.hotspot-scene').hide();
1385 getparent.find('.hotspot-scene input').val('');
1386 getparent.find('.hotspot-scene .hotspotscene').val('none');
1387 getparent.find('.hotspot-url').show();
1388 getparent.find('.s_tab').show();
1389 getparent.find('.hotspot-content').show();
1390 getparent.find('input[name*=hotspot-url]').attr("disabled",false)
1391 getparent.find('textarea[name*=hotspot-content]').next().find(".note-editable").attr("contenteditable", true);
1392 } else {
1393 getparent.find('.hotspot-scene').show();
1394 getparent.find('.hotspot-url').hide();
1395 getparent.find('.hotspot-url input').val('');
1396 getparent.find('.s_tab').hide();
1397 getparent.find('.s_tab input').val('off');
1398 getparent.find('.s_tab input').removeAttr('checked');
1399 getparent.find('.hotspot-content').hide();
1400 getparent.find('.hotspot-content textarea').val('');
1401 getparent.find('textarea[name*=hotspot-content]').next().find(".note-editable").html('');
1402 }
1403 });
1404 $(document).ready(function ($){
1405 $(document).on("keyup","input[name*=hotspot-url]",function (){
1406 var getHotspotUrl = $(this).val();
1407 var getParent = $(this).parent();
1408 var getMainParent = getParent.parent()
1409 var getClickContent = getMainParent.find('.hotspot-content')
1410 if(getHotspotUrl.length > 0){
1411 getClickContent.find('textarea').val('')
1412 getClickContent.find('textarea').attr('placeholder','You can set either a URL or an On-click content')
1413 getClickContent.find('textarea').attr("disabled",true)
1414 getClickContent.find('textarea[name*=hotspot-content]').next().find(".note-editable").attr("contenteditable", false);
1415 getClickContent.find('textarea[name*=hotspot-content]').next().find(".note-editable").html('');
1416
1417 }else{
1418 getClickContent.find('textarea').attr("disabled",false)
1419 getClickContent.find('textarea[name*=hotspot-content]').next().find(".note-editable").attr("contenteditable", true);
1420 }
1421 })
1422
1423 $(document).on("keyup","textarea[name*=hotspot-content]",function (){
1424 var getHotspotContent = $(this).summernote('code').trim();
1425 if (getHotspotContent === '<br>' || getHotspotContent === '<p><br></p>') {
1426 getHotspotContent = '';
1427 }
1428 var getParent = $(this).parent();
1429 var getMainParent = getParent.parent()
1430 var getClickContent = getMainParent.find('.hotspot-url')
1431 if(getHotspotContent.length > 0){
1432 getClickContent.find('input[name*=hotspot-url').val('')
1433 getClickContent.find('input[name*=hotspot-url').attr('placeholder','You can set either a URL or an On-click content')
1434 getClickContent.find('input[name*=hotspot-url]').attr("disabled",true)
1435 }else{
1436 getClickContent.find('input[name*=hotspot-url]').attr("disabled",false)
1437 }
1438 })
1439 })
1440
1441
1442 $(document).on("click", ".pano-error-close-btn", function (e) {
1443 e.preventDefault();
1444 $('.wpvr-delete-alert-wrapper').css('display', 'none');
1445 $('.wpvr-delete-alert-wrapper').hide();
1446 });
1447
1448 $(document).on("change", "input[type=radio][name=panovideo]", function (event) {
1449 var getvalue = $(this).val();
1450
1451 if (getvalue == 'on') {
1452 $('#confirm_text').html(`${window.wpvr_localize.VideoTourNotice}`);
1453 $('.wpvr-delete-alert-wrapper').css('display', 'flex');
1454 } else {
1455 $('.wpvr-delete-alert-wrapper').css('display', 'none');
1456 // $(".video-setting").hide();
1457
1458 $("li.general").show();
1459 $("li.scene").show();
1460 $("li.hotspot").show();
1461 $("li.streetview").show();
1462 $(".video-setting").hide();
1463 }
1464
1465 $(document).on("click", ".wpvr-delete-confirm-btn .cancel,.wpvr-delete-alert-wrapper .cross", function (e) {
1466 e.preventDefault();
1467 $('.wpvr-delete-alert-wrapper').css('display', 'none');
1468 $('.wpvr-delete-alert-wrapper').hide();
1469
1470 $(".video_on").prop('checked', false);
1471 $(".video_off").prop('checked', true);
1472
1473 $("li.general").show();
1474 $("li.scene").show();
1475 $("li.hotspot").show();
1476 $("li.streetview").show();
1477 $(".video-setting").hide();
1478
1479 });
1480
1481 $(document).on("click", ".wpvr-delete-confirm-btn .yes", function (e) {
1482 e.preventDefault();
1483 $('.wpvr-delete-alert-wrapper').css('display', 'none');
1484 $('.wpvr-delete-alert-wrapper').hide();
1485
1486 $(".video_off").prop('checked', false);
1487 $(".video_on").prop('checked', true);
1488 $(".video-setting").show();
1489 $("li.general").hide();
1490 $("li.scene").hide();
1491 $("li.hotspot").hide();
1492 $("li.streetview").hide();
1493
1494 });
1495 });
1496
1497 jQuery(document).ready(function ($) {
1498 let detect_scene_1_data = $('#scene-1').find('.sceneid').val();
1499 if(detect_scene_1_data === "") {
1500 $('#scene-1').find('.sceneid').val(generateRandomString(8));
1501 }
1502 });
1503
1504 function generateRandomString(length) {
1505 var result = '';
1506 var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
1507 var charactersLength = characters.length;
1508
1509 for (var i = 0; i < length; i++) {
1510 var randomIndex = Math.floor(Math.random() * charactersLength);
1511 result += characters.charAt(randomIndex);
1512 }
1513
1514 return result;
1515 }
1516 function prepare_hotspot_configuration_data() {
1517 var datacoords = $('#panodata').text().split(',');
1518 var pitchsplit = datacoords[0];
1519 var pitch = pitchsplit.split(':');
1520 var yawsplit = datacoords[1];
1521 var yaw = yawsplit.split(':');
1522 let detect_active_hotspot_id = $('div.single-scene.rex-pano-tab.active').children('div.hotspot-setup.rex-pano-sub-tabs').children('div.rex-pano-tab-content').children('div.single-hotspot.rex-pano-tab.active.clearfix').find("#hotspot-title").val();
1523 if(detect_active_hotspot_id === "" || detect_active_hotspot_id == undefined) {
1524 $('div.single-scene.rex-pano-tab.active').children('div.hotspot-setup.rex-pano-sub-tabs').children('div.rex-pano-tab-content').children('div.single-hotspot.rex-pano-tab.active.clearfix').find("#hotspot-title").val(generateRandomString(8));
1525 }
1526 $('div.single-scene.rex-pano-tab.active').children('div.hotspot-setup.rex-pano-sub-tabs').children('div.rex-pano-tab-content').children('div.single-hotspot.rex-pano-tab.active.clearfix').find('.hotspot-pitch').val(pitch[1]);
1527 $('div.single-scene.rex-pano-tab.active').children('div.hotspot-setup.rex-pano-sub-tabs').children('div.rex-pano-tab-content').children('div.single-hotspot.rex-pano-tab.active.clearfix').find('.hotspot-yaw').val(yaw[1]);
1528 }
1529
1530 function register_hotspot() {
1531 $('.panolenspreview').trigger('click');
1532 }
1533
1534 $(document).on("click", ".toppitch", function (event) {
1535 $.when(prepare_hotspot_configuration_data()).done(function() {
1536 register_hotspot();
1537 });
1538 });
1539
1540 jQuery(document).ready(function ($) {
1541 var viddata = $("input[name='panovideo']:checked").val();
1542
1543 if (viddata == 'on') {
1544
1545 $("li.scene").removeClass('active');
1546 $(".rex-pano-tab.wpvr_scene").removeClass('active');
1547 $("li.videos").addClass('active');
1548 $(".rex-pano-tab.video").addClass('active');
1549 $(".video-setting").show();
1550 $("li.general").hide();
1551 $("li.scene").hide();
1552 $("li.hotspot").hide();
1553 } else {
1554 // $(".video-setting").hide();
1555 $("li.general").show();
1556 $("li.scene").show();
1557 $("li.hotspot").show();
1558 }
1559 });
1560
1561 $(document).on("change", "select[name*=hotspot-customclass-pro]", function (event) {
1562 var getval = $(this).val();
1563 $(this).parent('.hotspot-setting').children('span.change-icon').html('<i class="' + getval + '"></i>');
1564
1565 });
1566
1567 $(document).on("change", ".hotspot-customclass-color", function (event) {
1568 var getcolor = $(this).val();
1569 color = getcolor;
1570 $('.hotspot-customclass-color-icon-value').val(getcolor);
1571 $('.hotspot-customclass-color').val(getcolor);
1572 });
1573
1574 jQuery(document).ready(function ($) {
1575 if ($(".icon-found-value")[0]) {
1576 color = $('.hotspot-customclass-color-icon-value.icon-found-value').val();
1577 } else {
1578 color = '#00b4ff';
1579 }
1580 });
1581
1582 function changeicon() {
1583 $('.hotspot-customclass-color-icon-value').val(color);
1584 $('.hotspot-customclass-color').val(color);
1585 }
1586
1587 //------------panolens tab js------------------
1588
1589
1590 $(document).on("click", ".scene-nav ul li:not(:last-child) span", function () {
1591
1592 var scene_id = $(this).data('index');
1593 scene_id = '#scene-' + scene_id;
1594
1595 j = $(scene_id).find('.hotspot-nav li').eq(-2).find('span').attr('data-index');
1596
1597 $([$(this).parent()[0], $($(this).data('href'))[0]]).addClass('active').siblings('.active').removeClass('active');
1598 $('#wpvr_active_scenes').val($(this).data('index'));
1599 });
1600
1601 //add click
1602 $(document).on("click", ".scene-nav ul li:last-child span", function () {
1603 var scene_id = $(this).parent('li').prev().children("span").data('index');
1604 scene_id = '#scene-' + scene_id;
1605 $(scene_id).removeAttr("style");
1606 j = $(scene_id).find('.hotspot-nav li').eq(-2).find('span').attr('data-index');
1607 $('.scene-nav ul li.active').removeClass('active');
1608 $(this).parent('li').prev().addClass('active');
1609 var sceneinfo = $('.scene-setup').repeaterVal();
1610 var infodata = sceneinfo['scene-list'];
1611 $('.hotspotscene').find('option').remove();
1612 $('.hotspotscene').append("<option value='none'>None</option>");
1613 for (var i in infodata) {
1614 var optiondata = infodata[i]['scene-id'];
1615 if (optiondata != '') {
1616 $('.hotspotscene').append("<option value='" + optiondata + "'>" + optiondata + "</option>");
1617 }
1618 }
1619 $('.hotspot-customclass-pro-select').fontIconPicker();
1620 $('span.change-icon').hide();
1621 });
1622
1623 //end add click
1624 $(document).on("click", ".hotspot-nav ul li:not(:last-child) span", function () {
1625 $('#wpvr_active_hotspot').val($(this).data('index'));
1626 $([$(this).parent()[0], $($(this).data('href'))[0]]).addClass('active').siblings('.active').removeClass('active');
1627 });
1628
1629 $(document).on("click", ".hotspot-nav ul li:last-child span", function () {
1630 $(this).parent('li').siblings('.active').removeClass('active');
1631 $(this).parent('li').prev().addClass('active');
1632 var sceneinfo = $('.scene-setup').repeaterVal();
1633 var infodata = sceneinfo['scene-list'];
1634 $('.hotspotscene').find('option').remove();
1635 $('.hotspotscene').append("<option value='none'>None</option>");
1636 for (var i in infodata) {
1637 var optiondata = infodata[i]['scene-id'];
1638 if (optiondata != '') {
1639 $('.hotspotscene').append("<option value='" + optiondata + "'>" + optiondata + "</option>");
1640 }
1641 }
1642 $('.trtr').trigger('change');
1643 $('.hotspot-customclass-pro-select').fontIconPicker();
1644 $('span.change-icon').hide();
1645
1646 });
1647
1648 function changehotspotid(id) {
1649 var scene_id = '#scene-' + id;
1650 var hotspot_id = 'scene-' + id + '-hotspot-1';
1651 $(scene_id).find('.hotspot-nav li span').attr('data-href', '#' + hotspot_id + '');
1652 $(scene_id).find('.single-hotspot').attr('id', hotspot_id);
1653
1654 }
1655
1656 $(document).on("click", ".rex-pano-nav-menu.main-nav ul li span", function () {
1657 var screen = $(this).parent().attr('data-screen');
1658
1659 var url_info = wpvr_global_obj.url_info
1660 if ( 'add' == url_info.screen ){
1661 var newUrl = url_info.admin_url+"post-new.php?"+"post_type="+url_info.param.post_type+"&active_tab="+screen;
1662 }else{
1663 var newUrl = url_info.admin_url+"post.php?"+"post="+url_info.param.post+"&action=edit"+"&active_tab="+screen;
1664 }
1665
1666 handle_add_pitch_button(screen);
1667
1668 if (window.history != 'undefined' && window.history.pushState != 'undefined') {
1669 window.history.pushState({ path: newUrl }, '', newUrl);
1670 }
1671
1672 $('#wpvr_active_tab').val(screen);
1673 if ('hotspot' == screen) {
1674 $('.active_scene_id').show();
1675 var id = $('.single-scene.active').attr('id');
1676 $('.active_scene_id p').text(`${window.wpvr_localize.AddingHotspotsOnScene}`);
1677 var scenceID = $('#' + id + ' .sceneid').val();
1678 var span = '<span>(' + scenceID + ')</span>'
1679 $('.active_scene_id p').append(span);
1680 $('.active_scene_id').css({ "background-color": "#E0E1F7", "width": "100%", "text-align": "center", "padding": "10px 15px" });
1681 $('.active_scene_id p').css({ "color": "black", "font-size": "15px" });
1682 $('.active_scene_id p span').css({ "color": "#004efa", "font-size": "15px" });
1683
1684 } else {
1685 $('.active_scene_id').hide();
1686 }
1687 $([$(this).parent()[0], $($(this).data('href'))[0]]).addClass('active').siblings('.active').removeClass('active');
1688 });
1689
1690 //-Get Started reloaded -//
1691 $(document).on("click",".tabs.rex-tabs li a",function(){
1692 var tab = $(this).attr('href');
1693 var url = window.location;
1694 var origin = url.origin;
1695 var pathname = url.pathname
1696 var search_perameter = window.location.search.split('&');
1697 var makeUrl = origin + pathname + search_perameter[0]
1698 var newUrl = makeUrl + tab;
1699
1700 if (window.history != 'undefined' && window.history.pushState != 'undefined') {
1701 window.history.pushState({ path: newUrl }, '', newUrl);
1702 }
1703 })
1704 //----------alert dismiss--------//
1705 $(document).on("click", "body", function () {
1706 $('body').removeClass('error-overlay2');
1707 $('.pano-alert').removeClass('pano-default-warning').hide();
1708 });
1709 $(document).on("click", ".pano-alert .pano-error-close-btn", function () {
1710 $('body').removeClass('error-overlay2');
1711 $('.pano-alert').removeClass('pano-default-warning').hide();
1712 });
1713 $(document).on("click", ".pano-alert, .rex-pano-sub-tabs .rex-pano-tab-nav li.add", function (e) {
1714 e.stopPropagation();
1715 });
1716
1717
1718 $(document).on("click", ".main-nav li.hotspot span", function () {
1719 $(".hotspot-setup.rex-pano-sub-tabs").show();
1720 $(".scene-setup > nav.scene-nav").hide();
1721 $(".scene-setup .single-scene > .scene-content").hide();
1722 $(".scene-setup .delete-scene").hide();
1723 });
1724
1725 $(document).on("click", ".main-nav li.scene span", function () {
1726 $(".hotspot-setup.rex-pano-sub-tabs").hide();
1727 $(".scene-setup > nav.scene-nav").show();
1728 $(".scene-setup .single-scene > .scene-content").show();
1729 $(".scene-setup .delete-scene").show();
1730 });
1731
1732 $(document).on("change", ".dscen", function () {
1733 var dscene = $(this).val();
1734 if('on' === dscene){
1735 $('#wpvr-check-default').prop('checked', true);
1736 $('#wpvr-check-default').closest('.wpvr-checklist-item').css('color', '#0E003C');
1737 }else{
1738 $('#wpvr-check-default').prop('checked', false);
1739 $('#wpvr-check-default').closest('.wpvr-checklist-item').css('color', '#73707D');
1740 }
1741 updateProgress()
1742 $(".dscen").not(this).each(function () {
1743 var oth_scene = $(this).val();
1744 if (dscene == 'on' && oth_scene == 'on') {
1745 $('#error_occured').show();
1746 $('#error_occured .pano-error-message').html('<span class="pano-error-title">Default scene has been updated</span>');
1747 $('body').addClass('error-overlay');
1748 $('html, body').animate({
1749 scrollTop: $("#error_occured").offset().top
1750 }, 500);
1751 $(this).val('off');
1752
1753 }
1754 });
1755 });
1756
1757 $(document).on("change", ".sceneid", function () {
1758 var sceneinfo = $('.scene-setup').repeaterVal();
1759 var infodata = sceneinfo['scene-list'];
1760 $('.hotspotscene').find('option').remove();
1761 $('.hotspotscene').append("<option value='none'>None</option>");
1762 for (var i in infodata) {
1763 var optiondata = infodata[i]['scene-id'];
1764 if (optiondata != '') {
1765 $('.hotspotscene').append("<option value='" + optiondata + "'>" + optiondata + "</option>");
1766 }
1767 }
1768 });
1769
1770
1771
1772 function deleteinfodata() {
1773 var sceneinfo = $('.scene-setup').repeaterVal();
1774 var infodata = sceneinfo['scene-list'];
1775 $('.hotspotscene').find('option').remove();
1776 $('.hotspotscene').append("<option value='none'>None</option>");
1777 for (var i in infodata) {
1778 var optiondata = infodata[i]['scene-id'];
1779 if (optiondata != '') {
1780 $('.hotspotscene').append("<option value='" + optiondata + "'>" + optiondata + "</option>");
1781 }
1782 }
1783 }
1784
1785 $(document).on("change", ".hotspotscene", function () {
1786
1787 var chanheghtptpval = $(this).val();
1788 if (chanheghtptpval != "none") {
1789 $(this).parent('.hotspot-scene').siblings('.hotspot-scene').children('.hotspotsceneinfodata').val(chanheghtptpval);
1790 } else {
1791 $(this).parent('.hotspot-scene').siblings('.hotspot-scene').children('.hotspotsceneinfodata').val('');
1792 }
1793 });
1794
1795 $(document).on("click", ".hotpitch", function (event) {
1796 var datacoords = $('#panodata').text().split(',');
1797 var pitchsplit = datacoords[0];
1798 var pitch = pitchsplit.split(':');
1799 $(this).parent().parent('.hotspot-setting').children('.hotspot-pitch').val(pitch[1]);
1800 });
1801
1802 $(document).on("click", ".hotyaw", function (event) {
1803 var datacoords = $('#panodata').text().split(',');
1804 var yawsplit = datacoords[1];
1805 var yaw = yawsplit.split(':');
1806 $(this).parent().parent('.hotspot-setting').children('.hotspot-yaw').val(yaw[1]);
1807 });
1808
1809 jQuery(document).ready(function ($) {
1810
1811 if ($(".scene-setup").length > 0) {
1812 var sceneinfo = $('.scene-setup').repeaterVal();
1813 var infodata = sceneinfo['scene-list'];
1814 $('.hotspotscene').find('option').remove();
1815 $('.hotspotscene').append("<option value='none'>None</option>");
1816 for (var i in infodata) {
1817 var optiondata = infodata[i]['scene-id'];
1818 if (optiondata != '') {
1819 $('.hotspotscene').append("<option value='" + optiondata + "'>" + optiondata + "</option>");
1820 }
1821 }
1822 }
1823 });
1824
1825 $(document).on("click", ".toppitch", function (event) {
1826 var datacoords = $('#panodata').text().split(',');
1827 var pitchsplit = datacoords[0];
1828 var pitch = pitchsplit.split(':');
1829 var yawsplit = datacoords[1];
1830 var yaw = yawsplit.split(':');
1831
1832 $('div.single-scene.rex-pano-tab.active').children('div.hotspot-setup.rex-pano-sub-tabs').children('div.rex-pano-tab-content').children('div.single-hotspot.rex-pano-tab.active.clearfix').find('.hotspot-pitch').val(pitch[1]);
1833 $('div.single-scene.rex-pano-tab.active').children('div.hotspot-setup.rex-pano-sub-tabs').children('div.rex-pano-tab-content').children('div.single-hotspot.rex-pano-tab.active.clearfix').find('.hotspot-yaw').val(yaw[1]);
1834 });
1835 jQuery(document).ready(function ($) {
1836 $('.hotspot-customclass-pro-select').fontIconPicker();
1837 });
1838 jQuery(document).ready(function ($) {
1839 $('span.change-icon').hide();
1840 });
1841
1842 jQuery(document).ready(function ($) {
1843 var autrotateset = $("input[name='autorotation']").is(':checked') ? 'on' : 'off';
1844 if (autrotateset == 'off') {
1845 $('.autorotationdata-wrapper').hide();
1846 } else {
1847 $('.autorotationdata-wrapper').show();
1848 }
1849
1850
1851 });
1852
1853 $(document).on("change", "input[name='autorotation']", function (event) {
1854 var autrotateset = $(this).is(':checked') ? 'on' : 'off';
1855
1856 if (autrotateset == 'on') {
1857 $('.autorotationdata-wrapper').show();
1858 } else {
1859 $('.autorotationdata-wrapper').hide();
1860 }
1861 });
1862
1863
1864 $(document).on("change", ".ptyscene", function (event) {
1865 var ptyscene = $(this).val();
1866 if (ptyscene == 'off') {
1867 $(this).parent('.single-settings').siblings('.ptyscenedata').hide();
1868 } else {
1869 $(this).parent('.single-settings').siblings('.ptyscenedata').show();
1870 }
1871 });
1872
1873 $(document).on("change", ".cvgscene", function (event) {
1874 var cvgscene = $(this).val();
1875 if (cvgscene == 'off') {
1876 $(this).parent('.single-settings').siblings('.cvgscenedata').hide();
1877 } else {
1878 $(this).parent('.single-settings').siblings('.cvgscenedata').show();
1879 }
1880 });
1881
1882 $(document).on("change", ".chgscene", function (event) {
1883 var chgscenedata = $(this).val();
1884 if (chgscenedata == 'off') {
1885 $(this).parent('.single-settings').siblings('.chgscenedata').hide();
1886 } else {
1887 $(this).parent('.single-settings').siblings('.chgscenedata').show();
1888 }
1889 });
1890
1891 $(document).on("change", ".czscene", function (event) {
1892 var czscene = $(this).val();
1893 if (czscene == 'off') {
1894 $(this).parent('.single-settings').siblings('.czscenedata').hide();
1895 } else {
1896 $(this).parent('.single-settings').siblings('.czscenedata').show();
1897 }
1898 });
1899
1900 /**
1901 * Nasim
1902 * enable script button on chnage action
1903 */
1904 $("#wpvr_script_control").change(function () {
1905
1906 if ($('#wpvr_script_control').is(':checked')) {
1907
1908 $(".wpvr_enqueue_script_list").show();
1909
1910 } else {
1911
1912 $(".wpvr_enqueue_script_list").hide();
1913 }
1914
1915 });
1916
1917 /**
1918 * Sakib
1919 * enable script button on chnage action
1920 */
1921 $("#wpvr_video_script_control").change(function () {
1922
1923 if ($('#wpvr_video_script_control').is(':checked')) {
1924
1925 $(".wpvr_enqueue_video_script_list").show();
1926
1927 } else {
1928
1929 $(".wpvr_enqueue_video_script_list").hide();
1930 }
1931
1932 });
1933
1934
1935 /**
1936 * Nasim
1937 * Check enable script button is on or not
1938 * if on then script list field will be show and if off then script list field will be hide
1939 */
1940 if ($('#wpvr_script_control').is(':checked')) {
1941
1942 $(".wpvr_enqueue_script_list").show();
1943
1944 } else {
1945
1946 $(".wpvr_enqueue_script_list").hide();
1947 }
1948
1949 /**
1950 * Sakib
1951 * Check enable script button is on or not
1952 * if on then script list field will be show and if off then script list field will be hide
1953 */
1954 if ($('#wpvr_video_script_control').is(':checked')) {
1955
1956 $(".wpvr_enqueue_video_script_list").show();
1957
1958 } else {
1959
1960 $(".wpvr_enqueue_video_script_list").hide();
1961 }
1962
1963 /**
1964 * Hides the alert in the settings footer area after a 2000ms delay.
1965 *
1966 * @return {void} No return value
1967 */
1968 function remove_alert(){
1969 setTimeout(function(){
1970 $('.settings-footer-area .wpvr-alert').hide();
1971 }, 2000);
1972 }
1973
1974 $(document).on("click", "#wpvr_role_submit", function (e) {
1975 e.preventDefault();
1976 var ajaxurl = wpvr_obj.ajaxurl;
1977 $(this).children().css('display', 'inline-block');
1978
1979 $('#wpvr_role_submit').attr('disabled', true);
1980 var editor = $('#wpvr_editor_active').is(':checked');
1981 var author = $('#wpvr_author_active').is(':checked');
1982 var fontawesome = $('#wpvr_fontawesome_disable').is(':checked');
1983 var mobile_media_resize = $('#mobile_media_resize').is(':checked');
1984 var wpvr_frontend_notice = $('#wpvr_frontend_notice').is(':checked');
1985 var wpvr_frontend_notice_area = $('#wpvr_frontend_notice_area').val();
1986 var wpvr_script_control = $('#wpvr_script_control').is(':checked');
1987 var wpvr_script_list = $('#wpvr_script_list').val();
1988 var wpvr_video_script_control = $('#wpvr_video_script_control').is(':checked');
1989 var wpvr_video_script_list = $('#wpvr_video_script_list').val();
1990 var high_res_image = $('#high_res_image').is(':checked');
1991 var dis_on_hover = $('#dis_on_hover').is(':checked');
1992 var dokan_vendor = $('#wpvr_dokan_vendor_active').is(':checked');
1993
1994 /**
1995 * check enable script button is on and script list field is not empty
1996 */
1997 if ( ($('#wpvr_video_script_control').is(':checked') && wpvr_video_script_list == '') || ($('#wpvr_script_control').is(':checked') && wpvr_script_list == '') ) {
1998 if(($('#wpvr_script_control').is(':checked') && wpvr_script_list == '')){
1999 if (confirm('The "List of Allowed Pages To Load WP VR Scripts " Field Is Empty. No Virtual Tours Will Show Up on Your Site.')) {
2000 if($('#wpvr_video_script_control').is(':checked') && wpvr_video_script_list == ''){
2001 if (confirm("The 'List of Allowed Pages To Load WPVR Video.js ' Field Is Empty. Any Self-hosted 360-degree videos won't function on your site.")) {
2002 jQuery.ajax({
2003 type: "POST",
2004 url: ajaxurl,
2005 data: {
2006 action: "wpvr_role_management",
2007 nonce : wpvr_obj.ajax_nonce,
2008 editor: editor,
2009 author: author,
2010 fontawesome: fontawesome,
2011 mobile_media_resize: mobile_media_resize,
2012 high_res_image: high_res_image,
2013 dis_on_hover: dis_on_hover,
2014 wpvr_frontend_notice: wpvr_frontend_notice,
2015 wpvr_frontend_notice_area: wpvr_frontend_notice_area,
2016 wpvr_script_control: wpvr_script_control,
2017 wpvr_script_list: wpvr_script_list,
2018 wpvr_video_script_control: wpvr_video_script_control,
2019 wpvr_video_script_list: wpvr_video_script_list,
2020 dokan_vendor: dokan_vendor,
2021 // woocommerce: woocommerce,
2022 },
2023 success: function (response) {
2024 $('#wpvr_role_submit .wpvr-loader').css('display', 'none');
2025 $('#wpvr_role_submit').attr('disabled', false);
2026
2027 if (response.status == 'success') {
2028 $('.settings-footer-area .wpvr-alert').text(response.message).show();
2029 }
2030
2031 remove_alert();
2032
2033 }
2034 });
2035 } else {
2036 $('#wpvr_role_submit .wpvr-loader').css('display', 'none');
2037 $('#wpvr_role_submit').attr('disabled', false);
2038 }
2039 }else{
2040 jQuery.ajax({
2041 type: "POST",
2042 url: ajaxurl,
2043 data: {
2044 action: "wpvr_role_management",
2045 nonce : wpvr_obj.ajax_nonce,
2046 editor: editor,
2047 author: author,
2048 fontawesome: fontawesome,
2049 mobile_media_resize: mobile_media_resize,
2050 high_res_image: high_res_image,
2051 wpvr_frontend_notice: wpvr_frontend_notice,
2052 wpvr_frontend_notice_area: wpvr_frontend_notice_area,
2053 wpvr_script_control: wpvr_script_control,
2054 wpvr_script_list: wpvr_script_list,
2055 wpvr_video_script_control: wpvr_video_script_control,
2056 wpvr_video_script_list: wpvr_video_script_list,
2057 dokan_vendor: dokan_vendor,
2058 // woocommerce: woocommerce,
2059 },
2060 success: function (response) {
2061 $('#wpvr_role_submit .wpvr-loader').css('display', 'none');
2062 $('#wpvr_role_submit').attr('disabled', false);
2063
2064 if (response.status == 'success') {
2065 $('.settings-footer-area .wpvr-alert').text(response.message).show();
2066 }
2067
2068 remove_alert();
2069
2070 }
2071 });
2072 }
2073 } else {
2074 $('#wpvr_role_submit .wpvr-loader').css('display', 'none');
2075 $('#wpvr_role_submit').attr('disabled', false);
2076 }
2077 }else if($('#wpvr_video_script_control').is(':checked') && wpvr_video_script_list == ''){
2078
2079 if (confirm("The 'List of Allowed Pages To Load WPVR Video.js ' Field Is Empty. Any Self-hosted 360-degree videos won't function on your site.")) {
2080 if(($('#wpvr_script_control').is(':checked') && wpvr_script_list == '')){
2081 if (confirm('The "List of Allowed Pages To Load WP VR Scripts " Field Is Empty. No Virtual Tours Will Show Up on Your Site.')) {
2082 jQuery.ajax({
2083 type: "POST",
2084 url: ajaxurl,
2085 data: {
2086 action: "wpvr_role_management",
2087 nonce : wpvr_obj.ajax_nonce,
2088 editor: editor,
2089 author: author,
2090 fontawesome: fontawesome,
2091 mobile_media_resize: mobile_media_resize,
2092 high_res_image: high_res_image,
2093 dis_on_hover: dis_on_hover,
2094 wpvr_frontend_notice: wpvr_frontend_notice,
2095 wpvr_frontend_notice_area: wpvr_frontend_notice_area,
2096 wpvr_script_control: wpvr_script_control,
2097 wpvr_script_list: wpvr_script_list,
2098 wpvr_video_script_control: wpvr_video_script_control,
2099 wpvr_video_script_list: wpvr_video_script_list,
2100 dokan_vendor: dokan_vendor,
2101 // woocommerce: woocommerce,
2102 },
2103 success: function (response) {
2104 $('#wpvr_role_submit .wpvr-loader').css('display', 'none');
2105 $('#wpvr_role_submit').attr('disabled', false);
2106
2107 if (response.status == 'success') {
2108 $('.settings-footer-area .wpvr-alert').text(response.message).show();
2109 }
2110 remove_alert();
2111
2112 }
2113 });
2114 }else {
2115 $('#wpvr_role_submit .wpvr-loader').css('display', 'none');
2116 $('#wpvr_role_submit').attr('disabled', false);
2117 }
2118 }else{
2119 jQuery.ajax({
2120 type: "POST",
2121 url: ajaxurl,
2122 data: {
2123 action: "wpvr_role_management",
2124 nonce : wpvr_obj.ajax_nonce,
2125 editor: editor,
2126 author: author,
2127 fontawesome: fontawesome,
2128 mobile_media_resize: mobile_media_resize,
2129 high_res_image: high_res_image,
2130 dis_on_hover: dis_on_hover,
2131 wpvr_frontend_notice: wpvr_frontend_notice,
2132 wpvr_frontend_notice_area: wpvr_frontend_notice_area,
2133 wpvr_script_control: wpvr_script_control,
2134 wpvr_script_list: wpvr_script_list,
2135 wpvr_video_script_control: wpvr_video_script_control,
2136 wpvr_video_script_list: wpvr_video_script_list,
2137 dokan_vendor: dokan_vendor,
2138 // woocommerce: woocommerce,
2139 },
2140 success: function (response) {
2141 $('#wpvr_role_submit .wpvr-loader').css('display', 'none');
2142 $('#wpvr_role_submit').attr('disabled', false);
2143
2144 if (response.status == 'success') {
2145 $('.settings-footer-area .wpvr-alert').text(response.message).show();
2146 }
2147
2148 remove_alert();
2149
2150 }
2151 });
2152 }
2153 } else {
2154 $('#wpvr_role_submit .wpvr-loader').css('display', 'none');
2155 $('#wpvr_role_submit').attr('disabled', false);
2156 }
2157 }
2158
2159 } else {
2160 jQuery.ajax({
2161 type: "POST",
2162 url: ajaxurl,
2163 data: {
2164 action: "wpvr_role_management",
2165 nonce : wpvr_obj.ajax_nonce,
2166 editor: editor,
2167 author: author,
2168 fontawesome: fontawesome,
2169 mobile_media_resize: mobile_media_resize,
2170 high_res_image: high_res_image,
2171 dis_on_hover: dis_on_hover,
2172 wpvr_frontend_notice: wpvr_frontend_notice,
2173 wpvr_frontend_notice_area: wpvr_frontend_notice_area,
2174 wpvr_script_control: wpvr_script_control,
2175 wpvr_script_list: wpvr_script_list,
2176 wpvr_video_script_control: wpvr_video_script_control,
2177 wpvr_video_script_list: wpvr_video_script_list,
2178 dokan_vendor: dokan_vendor,
2179 },
2180 success: function (response) {
2181 $('#wpvr_role_submit .wpvr-loader').css('display', 'none');
2182 $('#wpvr_role_submit').attr('disabled', false);
2183 if (response.status == 'success') {
2184 $('.settings-footer-area .wpvr-alert').text(response.message).show();
2185 }
2186
2187 remove_alert();
2188 }
2189 });
2190 }
2191
2192
2193
2194 });
2195
2196
2197 //-----------reset button----------
2198 $(document).on("click", "#wpvr_role_reset", function (e) {
2199 e.preventDefault();
2200 $(this).attr('disabled', true);
2201
2202 var confirmation = confirm('All settings will be reset to default. Are you sure?');
2203 // Code to reset settings to default if the user clicks "Yes"
2204 if (confirmation) {
2205 $('#wpvr_editor_active').prop('checked', false);
2206 $('#wpvr_author_active').prop('checked', false);
2207 $('#wpvr_fontawesome_disable').prop('checked', false);
2208 $('#mobile_media_resize').prop('checked', false);
2209 $('#wpvr_frontend_notice').prop('checked', false);
2210 $('#wpvr_script_control').prop('checked', false);
2211 $('#wpvr_video_script_control').prop('checked', false);
2212 $('#high_res_image').prop('checked', false);
2213 $('#dis_on_hover').prop('checked', false);
2214 $('#wpvr_dokan_vendor_active').prop('checked', false);
2215 $(".wpvr_enqueue_video_script_list").hide();
2216 $(".wpvr_enqueue_script_list").hide();
2217
2218 $("#wpvr_role_submit").trigger('click');
2219 }
2220 $(this).attr('disabled', false);
2221
2222 });
2223
2224 //------general tab's inner tab-------
2225 jQuery(document).ready(function ($) {
2226
2227 $('.general-inner-tab .inner-nav li span').on('click', function () {
2228 var this_id = $(this).attr('data-href');
2229
2230 $(this).parent('li').addClass('active');
2231 $(this).parent('li').siblings().removeClass('active');
2232
2233 $(this_id).show();
2234 $(this_id).siblings().hide();
2235 });
2236 });
2237
2238 //------active tab scripts-------
2239 jQuery(document).ready(function ($) {
2240
2241 function getUrlVars() {
2242 var vars = [],
2243 hash;
2244 var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
2245 for (var i = 0; i < hashes.length; i++) {
2246 hash = hashes[i].split('=');
2247 vars.push(hash[0]);
2248 vars[hash[0]] = hash[1];
2249 }
2250 return vars;
2251 }
2252 var activeTab = 'general',
2253 vr_main_tab = $('#wpvr-main-nav'),
2254 var_main_tab_contents = $('#wpvr-main-tab-contents').find('.rex-pano-tab').not(".single-scene,.single-hotspot"),
2255 scene_content = $('.scene-content'),
2256 scene_nav = $('.scene-nav'),
2257 single_scene = $('.single-scene'),
2258 hotspot_content = $('.hotspot-setup'),
2259 single_hotspot = $('.single-hotspot'),
2260 delete_scene_btn = $('.delete-scene'),
2261 delete_hotspot_btn = $('.delete-hotspot');
2262
2263 var _q_activeTab = getUrlVars()["active_tab"];
2264 var _sceneID = getUrlVars()["scene"];
2265 var _hotspotID = getUrlVars()["hotspot"];
2266 var default_tabs = ['general', 'scene', 'hotspot', 'video'];
2267 if (_q_activeTab) {
2268 if (default_tabs.includes(_q_activeTab)) {
2269 activeTab = _q_activeTab;
2270 if(activeTab == "video" ){
2271 vr_main_tab.find('li:not(:first)').removeClass('active');
2272 vr_main_tab.find(".videos").addClass('active');
2273 }else{
2274 vr_main_tab.find('li:not(:first)').removeClass('active');
2275 vr_main_tab.find('.' + activeTab).addClass('active');
2276 }
2277
2278 // scene screens
2279 var_main_tab_contents.addClass('active');
2280 if (activeTab === 'scene' || activeTab === 'hotspot') {
2281 var_main_tab_contents.not('#scenes').removeClass('active');
2282 } else {
2283 var_main_tab_contents.not('#' + activeTab).removeClass('active');
2284 }
2285 if(activeTab === 'hotspot'){
2286 $(".rex-pano-nav-menu.main-nav ul li.hotspot span").trigger('click')
2287 }
2288
2289 // scene contents
2290 if (_sceneID) {
2291 var scenesIds = [];
2292 var sceneID = '#scene-' + _sceneID;
2293 var scene_nav_items = scene_nav.find('li');
2294 scene_nav.find('li').each(function () {
2295 var index = $(this).find('span').attr('data-index');
2296 if (index) {
2297 scenesIds.push(index);
2298 }
2299 });
2300 if (scenesIds.includes(_sceneID)) {
2301 scene_nav_items.removeClass('active');
2302 scene_nav.find('li').each(function () {
2303 var index = $(this).find('span').attr('data-index');
2304 if (_sceneID == index) {
2305 $(this).addClass('active');
2306 }
2307 });
2308 if (activeTab == 'scene' || _sceneID) {
2309 single_scene.removeClass('active');
2310 $(sceneID).addClass('active');
2311 }
2312 } else {
2313 scene_nav.find('li:first').addClass('active');
2314 }
2315
2316 if (activeTab === 'scene') {
2317 if (scenesIds.includes(_sceneID)) {
2318 $(single_scene).removeClass('active');
2319 $(sceneID).addClass('active');
2320 }
2321 } else {
2322 $(delete_scene_btn).hide();
2323 $(scene_nav).hide();
2324 $('.scene-content').hide();
2325 $(sceneID).find('.hotspot-setup').show();
2326 }
2327
2328 //hotspot contents
2329 var hotspot_nav = $('.single-scene.active').find('.hotspot-nav');
2330 var hotspotIds = [];
2331 var hotspot_nav_items = $('.single-scene.active').find('.hotspot-nav').find('li');
2332 var activeHotspotId = '#scene-' + _sceneID + 'hotspot-' + _hotspotID;
2333 hotspot_nav_items.each(function () {
2334 var index = $(this).find('span').attr('data-index');
2335 if (index) {
2336 hotspotIds.push(index);
2337 activeHotspotId = $(this).find('span').attr('data-href');
2338 }
2339 });
2340 if (hotspotIds.includes(_hotspotID)) {
2341 hotspot_nav_items.removeClass('active');
2342 hotspot_nav.find('li').each(function () {
2343 var index = $(this).find('span').attr('data-index');
2344 if (_hotspotID === index) {
2345 $(this).addClass('active');
2346 }
2347 });
2348 if (activeHotspotId) {
2349 $(sceneID).find('.single-hotspot').removeClass('active');
2350 $(activeHotspotId).addClass('active');
2351 }
2352 }
2353 }
2354 }
2355 }
2356
2357
2358 $(document).on("click", ".wpvr-help-resource__video-section", function () {
2359 $('#wpvr-help-video-iframe').attr('src', 'https://www.youtube.com/embed/kKHUlVKtesQ');
2360 if($('#wpvr-help-video-iframe').attr('src') != ''){
2361 $(".wpvr-iframe-modal").show();
2362 }
2363 });
2364
2365
2366 $(document).on("click", ".wpvr-iframe-modal__cross-icon", function () {
2367 $(".wpvr-iframe-modal").hide();
2368 var videoPlayer =$('#wpvr-help-video-iframe');
2369 videoPlayer.attr('src', '');
2370
2371 });
2372
2373
2374
2375 });
2376
2377 $(document).on("click", ".wpvr_url_open", function (event) {
2378 if ($(this).val() == 'off') {
2379 $(this).val('on');
2380 }
2381 else {
2382 $(this).val('off');
2383 }
2384 });
2385
2386 $(document).ready(function() {
2387 $('textarea[name*=hotspot-content]').summernote({
2388 toolbar: [
2389 ['style', ['style']],
2390 ['font', ['bold', 'underline', 'clear']],
2391 ['fontname', ['fontname']],
2392 ['color', ['color']],
2393 ['para', ['ul', 'ol', 'paragraph']],
2394 ['table', ['table']],
2395 ['insert', ['link', 'picture', 'video']],
2396 ['view', ['codeview', 'help']],
2397 ],
2398 callbacks: {
2399 onKeyup: function(e) {
2400 var getHotspotContent = $(this).summernote('code').trim();
2401 var tempDiv = document.createElement('div');
2402 tempDiv.innerHTML = getHotspotContent;
2403 var plainText = tempDiv.textContent || tempDiv.innerText || '';
2404 plainText = plainText.replace(/\u00a0/g, '').trim();
2405 var getParent = $(this).parent();
2406 var getMainParent = getParent.parent();
2407 var getClickContent = getMainParent.find('.hotspot-url');
2408
2409 if (plainText.length > 0) {
2410 getClickContent.find('input[name*=hotspot-url]').val('');
2411 getClickContent.find('input[name*=hotspot-url]').attr('placeholder', 'You can set either a URL or an On-click content');
2412 getClickContent.find('input[name*=hotspot-url]').attr("disabled", true);
2413 } else {
2414 getClickContent.find('input[name*=hotspot-url]').attr("disabled", false);
2415 }
2416 }
2417 }
2418 });
2419 $('textarea[name*=hotspot-hover]').summernote({
2420 toolbar: [
2421 ['style', ['style']],
2422 ['font', ['bold', 'underline', 'clear']],
2423 ['fontname', ['fontname']],
2424 ['color', ['color']],
2425 ['para', ['ul', 'ol', 'paragraph']],
2426 ['table', ['table']],
2427 ['insert', ['link', 'picture', 'video']],
2428 ['view', ['codeview', 'help']],
2429 ],
2430 fontNames: ['Arial', 'Helvetica', 'Tahoma', 'Courier New', 'Verdana', 'Impact', 'Times New Roman', 'system-ui', 'Helvetica Neue'],
2431 callbacks: {
2432 onInit: function() {
2433 var $editor = $(this);
2434
2435 // Override font name dropdown click handler for this specific editor
2436 $editor.next('.note-editor').find('.dropdown-fontname a').off('click').on('click', function(e) {
2437 e.preventDefault();
2438 var fontName = $(this).data('value') || $(this).text();
2439
2440 // Focus on the current editor
2441 $editor.summernote('focus');
2442
2443 // Use Summernote's built-in method to apply font
2444 try {
2445 // First, clear any existing font formatting
2446 var range = $editor.summernote('createRange');
2447 if (range && !range.isCollapsed()) {
2448 // Get selected text
2449 var selectedText = range.toString();
2450
2451 // Use Summernote's insertHTML to replace content
2452 var fontHtml = '<span style="font-family: ' + fontName + ';">' + selectedText + '</span>';
2453 $editor.summernote('insertHTML', fontHtml);
2454 } else {
2455 // No selection, use execCommand for typing
2456 $editor.summernote('focus');
2457 document.execCommand('fontName', false, fontName);
2458 }
2459 } catch (error) {
2460 console.log('Font application error, using fallback method');
2461 // Fallback method
2462 document.execCommand('fontName', false, fontName);
2463 }
2464
2465 // Update dropdown button text for this editor
2466 $(this).closest('.note-editor').find('.note-current-fontname').text(fontName);
2467
2468 // Close dropdown
2469 var $dropdownMenu = $(this).closest('.dropdown-menu');
2470 $dropdownMenu.removeClass('show').hide();
2471 $dropdownMenu.prev('.dropdown-toggle').removeClass('show').attr('aria-expanded', 'false');
2472
2473 // Trigger change event
2474 setTimeout(function() {
2475 $editor.trigger('summernote.change');
2476 }, 100);
2477 });
2478 },
2479
2480 // Clean up the content after any change
2481 onChange: function(contents, $editable) {
2482 // Debounce the cleanup to avoid conflicts
2483 clearTimeout(this.cleanupTimeout);
2484 this.cleanupTimeout = setTimeout(function() {
2485 // Remove all font-family styles from elements that shouldn't have them
2486 $editable.find('*:not(span)').each(function() {
2487 if (this.style && this.style.fontFamily) {
2488 this.style.fontFamily = '';
2489 }
2490 });
2491
2492 // Clean up empty spans
2493 $editable.find('span').each(function() {
2494 var $span = $(this);
2495 var text = $span.text().replace(/[\uFEFF\u200B-\u200D\u2060]/g, '').trim();
2496
2497 if (!text) {
2498 $span.remove();
2499 } else {
2500 // If span has other styles besides font-family, keep only font-family
2501 var fontFamily = $span.css('font-family');
2502 if (fontFamily && fontFamily !== 'inherit') {
2503 $span.attr('style', 'font-family: ' + fontFamily + ';');
2504 } else if (!fontFamily || fontFamily === 'inherit') {
2505 $span.contents().unwrap();
2506 }
2507 }
2508 });
2509
2510 // Remove nested spans with font-family
2511 $editable.find('span[style*="font-family"] span[style*="font-family"]').each(function() {
2512 $(this).contents().unwrap();
2513 });
2514 }, 200);
2515 }
2516 }
2517 });
2518 });
2519
2520 $(document).on("submit", "#trigger-rollback", function (event) {
2521 event.preventDefault();
2522 if(confirm('Are you sure?')) {
2523 let version = $("#trigger-rollback").serialize();
2524 let redirectUrl = wpvr_global_obj.url_info.admin_url + 'admin.php?' + version;
2525 window.location.href = redirectUrl;
2526 }
2527 });
2528
2529 $(document).on("click", ".single-settings .wpvr-switcher input:disabled+label,.vr-export,#styled-radio-sv-off,#styled-radio-sv-on,#wpvr_floor_plan_enabler,.wpvr_cardboard_disable_label,.rex-import-disable,.single-settings.scene-animation", function (event) {
2530 event.preventDefault();
2531 $("#wpvr_premium_feature_popup").show();
2532 });
2533
2534
2535
2536 $(document).on("click", "#wpvr_premium_feature_close", function () {
2537 $("#wpvr_premium_feature_popup").hide();
2538 });
2539
2540
2541 $(document).on("click", ".wpvr-help-resource__dropdown-section", function () {
2542 // When an element with the class 'wpvr-help-resource__dropdown-section' is clicked,
2543 // toggle the 'show-dropdown' class on its siblings.
2544 $(this).siblings().toggleClass("show-dropdown");
2545 });
2546
2547 $(document).on("click", ".wpvr-layout__radio-container", function () {
2548 let findLayout = $(this).find('.wpvr-layout__radio-label').data('layout');
2549 if(findLayout == 'layout1'){
2550 event.preventDefault();
2551 $('#wpvr_premium_feature_popup').show();
2552 }
2553 });
2554
2555 // ------window on scroll add class to comparison table header------
2556 $(window).on('scroll', function() {
2557 var $header = $('.wpvr-compare .list-header');
2558
2559 if ($header.length > 0) {
2560 var headerOffset = $header.offset().top - $(window).scrollTop();
2561
2562 if (headerOffset < 27) {
2563 $header.addClass('sticked');
2564 } else {
2565 $header.removeClass('sticked');
2566 }
2567
2568 }
2569
2570 });
2571
2572 $(document).ready(function() {
2573 handle_add_pitch_button();
2574 toggleSceneGallery();
2575 });
2576
2577 $(document).on( 'mousedown', 'div.pnlm-dragfix', () => { handle_add_pitch_button() } );
2578
2579 function get_active_tab() {
2580 let activeTab = $('#wpvr_active_tab').val() ?? null;
2581 if ( !activeTab ) {
2582 activeTab = $(".rex-pano-tab-nav li.active").data('screen');
2583 }
2584 return activeTab;
2585 }
2586
2587 function handle_add_pitch_button( activeTab = null ) {
2588 activeTab = activeTab === null ? get_active_tab() : activeTab;
2589
2590 if(handle_hotspot_tab(activeTab, true))
2591 return;
2592
2593 if( activeTab && 'hotspot' === activeTab && '' !== $( "#panodata" ).html().trim() ) {
2594 $(".add-pitch").removeClass('rex-hide-coordinates');
2595 }
2596 else {
2597 $(".add-pitch").addClass('rex-hide-coordinates');
2598 }
2599
2600 if('video' === activeTab){
2601 $(".rex-add-coordinates").addClass('rex-hide-coordinates');
2602 }else{
2603 $(".rex-add-coordinates").removeClass('rex-hide-coordinates');
2604 }
2605
2606 if( 'streetview' === activeTab || 'video' === activeTab || $('.videos.active').length ) {
2607 $('#wpvr_item_tour_checklist__box').css('display', 'none');
2608 }else{
2609 $('#wpvr_item_tour_checklist__box').css('display', 'block');
2610 }
2611
2612 }
2613
2614 $(document).ready(function() {
2615 $(".rex-pano-tab-nav li").on( 'click', function() {
2616 var activeTab = jQuery(this).data('screen');
2617 if(handle_hotspot_tab(activeTab, false))
2618 return false;
2619 });
2620 });
2621
2622 function handle_hotspot_tab(activeTab, redirect) {
2623 let isReturn = false;
2624 if (activeTab && 'hotspot' === activeTab) {
2625 const activeScene = jQuery('.scene-nav li.active span').attr('data-index');
2626 const activeSceneId = $('#scene-' + activeScene).find(".form-group img").attr('src');
2627 let activeTabUrl = window?.wpvr_global_obj?.active_tab_url;
2628 if (!activeSceneId && redirect) {
2629 window.location.replace(activeTabUrl);
2630 isReturn = true;
2631 } else if(!activeSceneId && !redirect){
2632 alert(window?.wpvr_global_obj?.hotspot_warning_text);
2633 jQuery('.rex-pano-tab-nav li scene').addClass('active');
2634 isReturn = true;
2635 }
2636 }
2637 return isReturn;
2638 }
2639
2640
2641 function toggleSceneGallery(activeTab = null) {
2642 activeTab = activeTab === null ? get_active_tab() : activeTab;
2643 if (activeTab && 'video' === activeTab) {
2644 jQuery('.scene-gallery').hide();
2645 } else {
2646 jQuery('.scene-gallery').show();
2647 }
2648 }
2649
2650 // Function to update the progress bar
2651 function updateProgress() {
2652 let totalItems = $('.wpvr-checklist-items').length; // Total number of checklist items
2653 let checkedItems = $('.wpvr-checklist-items:checked').length; // Number of checked items
2654
2655 // Calculate progress percentage
2656 let progress = Math.round((checkedItems / totalItems) * 100);
2657
2658 // Update progress bar
2659 $('#wpvr-progress-bar').css('width', progress + '%');
2660 $('#wpvr-progress-text').text(progress + '%');
2661
2662 // Change color of progress bar based on progress
2663 if (progress === 100) {
2664 $('#wpvr-progress-bar').css('background-color', 'green');
2665 $('#wpvr-progress-text').css('color', 'white');
2666 }else{
2667 $('#wpvr-progress-text').css('color', '#3F04FE');
2668 }
2669 }
2670
2671 updateProgress();
2672
2673 $(document).on("click", ".toppitch", function () {
2674 if (!$('#wpvr-check-hotspots').is(':checked')) {
2675 $('#wpvr-check-hotspots').prop('checked', true);
2676 $('#wpvr-check-hotspots').closest('.wpvr-checklist-item').css('color', '#0E003C');
2677 }
2678 updateProgress();
2679 });
2680
2681
2682 $(document).ready(function() {
2683 $(".rex-pano-tab .inner-nav-content .single-settings.has-children .vr-switcher-check").each(function() {
2684 if ($(this).is(':checked')) {
2685 $(this).parents('.single-settings').addClass('margin-bottom-remove');
2686 } else {
2687 $(this).parents('.single-settings').removeClass('margin-bottom-remove');
2688 }
2689 });
2690 });
2691
2692
2693
2694 $('.rex-pano-tab .inner-nav-content .single-settings.has-children .vr-switcher-check').on('change', function() {
2695 if ($(this).is(':checked')) {
2696 $(this).parents('.single-settings').addClass('margin-bottom-remove');
2697 } else {
2698 $(this).parents('.single-settings').removeClass('margin-bottom-remove');
2699 }
2700 });
2701
2702 // Function to handle visibility toggle based on checkbox state
2703 function toggleKeyboardZoom() {
2704 var isChecked = $("input[name='mouseZoom']").is(':checked');
2705 $('.mouse-zoom-control-settings-wrapper').toggle(isChecked);
2706 }
2707
2708 // Initial state setup on page load
2709 toggleKeyboardZoom();
2710
2711 // Event listener for checkbox changes using more specific selector
2712 $("input[name='mouseZoom']").on("change", toggleKeyboardZoom);
2713
2714
2715
2716
2717
2718 // Function to handle visibility toggle based on checkbox state
2719 function toggleKeyboardSettings() {
2720 var isChecked = $("input[name='draggable']").is(':checked');
2721 $('.mouse-dragable-control-settings-wrapper').toggle(isChecked);
2722 }
2723
2724 // Initial state setup on page load
2725 toggleKeyboardSettings();
2726
2727 // Event listener for checkbox changes using more specific selector
2728 $("input[name='draggable']").on("change", toggleKeyboardSettings);
2729
2730
2731
2732 // Function to handle visibility toggle based on checkbox state
2733 function toggleGallerySettings() {
2734 var isChecked = $("input[name='vrgallery']").is(':checked');
2735 $('.scene-gallery-settings-wrapper').toggle(isChecked);
2736 }
2737
2738 // Initial state setup on page load
2739 toggleGallerySettings();
2740
2741 // Event listener for checkbox changes using more specific selector
2742 $("input[name='vrgallery']").on("change", toggleGallerySettings);
2743
2744
2745
2746 // Function to handle visibility toggle based on checkbox state
2747 function toggleGyroSettings() {
2748 var isChecked = $("input[name='gyro']").is(':checked');
2749 $('.zyro-settings-wrapper').toggle(isChecked);
2750 }
2751
2752 // Initial state setup on page load
2753 toggleGyroSettings();
2754
2755 // Event listener for checkbox changes using more specific selector
2756 $("input[name='gyro']").on("change", toggleGyroSettings);
2757
2758
2759 // Function to handle visibility toggle based on checkbox state
2760 function toggleExplainerSwitch() {
2761 var isChecked = $("input[name='explainerSwitch']").is(':checked');
2762 $('.explainer-video-settings-wrapper').toggle(isChecked);
2763 }
2764
2765 // Initial state setup on page load
2766 toggleExplainerSwitch();
2767
2768 // Event listener for checkbox changes using more specific selector
2769 $("input[name='explainerSwitch']").on("change", toggleExplainerSwitch);
2770
2771
2772 // Function to handle visibility toggle based on checkbox state
2773 function toggleZoomSwitch() {
2774 var isChecked = $("input[name='globalzoom']").is(':checked');
2775 $('.set-zoom-perference-control-settings-wrapper').toggle(isChecked);
2776 }
2777
2778 // Initial state setup on page load
2779 toggleZoomSwitch();
2780
2781 // Event listener for checkbox changes using more specific selector
2782 $("input[name='globalzoom']").on("change", toggleZoomSwitch);
2783
2784
2785
2786
2787
2788 // Get initial checkbox value and convert to boolean
2789 var callToAction = $("input[name='calltoaction']").val();
2790 callToAction = callToAction == 'on' ? true : false;
2791
2792 // Show or hide the call-to-action section on page load
2793 if (callToAction) {
2794 $('.call-to-action').show();
2795 } else {
2796 $('.call-to-action').hide();
2797 }
2798
2799 // Toggle visibility of the call-to-action section on checkbox change
2800 $(document).on("change", "input[name='calltoaction']", function () {
2801 var calltoactionbutton = $(this).is(':checked') ? 'on' : 'off';
2802 if (calltoactionbutton == 'on') {
2803 $('.call-to-action').show();
2804 } else {
2805 $('.call-to-action').hide();
2806 }
2807 });
2808
2809
2810 // Toggle visibility of the ".custom-css-field" section based on the "customcss" checkbox state.
2811
2812 // 1. On page load:
2813 // - Get the current value of the "customcss" input.
2814 // - Convert 'on' to boolean true.
2815 // - Show or hide the ".custom-css-field" section accordingly.
2816
2817 var customCssEnable = $("input[name='customcss']").val();
2818 customCssEnable = customCssEnable == 'on' ? true : false;
2819
2820 if (customCssEnable) {
2821 $('.custom-css-field').show();
2822 } else {
2823 $('.custom-css-field').hide();
2824 }
2825
2826 // 2. On checkbox state change:
2827 // - Detect changes to the "customcss" checkbox.
2828 // - Use .is(':checked') to determine current state.
2829 // - Alert the value ('on' or 'off').
2830 // - Show or hide the ".custom-css-field" section accordingly.
2831
2832 $(document).on("change", "input[name='customcss']", function () {
2833 var custom_css_field = $(this).is(':checked') ? 'on' : 'off';
2834 alert(custom_css_field);
2835
2836 if (custom_css_field == 'on') {
2837 $('.custom-css-field').show();
2838 } else {
2839 $('.custom-css-field').hide();
2840 }
2841 });
2842
2843
2844
2845 })(jQuery);