PluginProbe
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress / 8.5.36
WPVR – 360 Panorama viewer and Virtual Tour Builder for WordPress v8.5.36
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.36, at admin/js/wpvr-admin.js

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