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

2,160 lines 96.4 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 * All of the code for your admin-facing JavaScript source
8 * should reside in this file.
9 *
10 * Note: It has been assumed you will write jQuery code here, so the
11 * $ function reference has been prepared for usage within the scope
12 * of this function.
13 *
14 * This enables you to define handlers, for when the DOM is ready:
15 *
16 * $(function() {
17 *
18 * });
19 *
20 * When the window is loaded:
21 *
22 * $( window ).load(function() {
23 *
24 * });
25 *
26 * ...and/or other possibilities.
27 *
28 * Ideally, it is not considered best practise to attach more than a
29 * single DOM-ready or window-load handler for a particular page.
30 * Although scripts in the WordPress core, Plugins and Themes may be
31 * practising this, we should strive to set a better example in our own work.
32 */
33
34
35 $(document).ready(function () {
36 if($('#scene-1').find('input.sceneid').val()){
37 $('.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>');
38 }else{
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-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>');
40 }
41
42 $(".vrowl-carousel").owlCarousel({
43 margin: 10,
44 autoWidth: true,
45 nav: true
46 });
47
48 var primary_markng = $('#scene-1').find('input.sceneid').val();
49 $('.owl' + primary_markng).parents('.owl-item').addClass('marked');
50
51 $('.meta-box-sortables').sortable({
52 items: '#wpvr_item_builder_box',
53 disabled: true
54 });
55
56 $('.postbox .hndle').css('cursor', 'pointer');
57
58
59 });
60
61 $(document).on("change", "input.vr-switcher-check", function (event) {
62 if (this.checked) {
63 $(this).val('on');
64 } else {
65 $(this).val('off');
66 }
67 });
68
69
70 var specificeSceneID = ''
71 var newScene = ''
72 $(document).on("click", ".scene-nav ul li span", function (event) {
73 $('.owl-item').removeClass('marked');
74 var target = $(this).attr("data-index");
75 if(target == undefined){
76 var currentLi = $(this).parent('li');
77 var previousLi = currentLi.prev();
78 if (previousLi.length > 0) {
79 newScene = previousLi.find('span').attr('data-index');
80 }
81 }
82 var data = $('#scene-' + target).find('input.sceneid').val();
83 if (data) {
84 specificeSceneID = data;
85 $('.panolenspreview').trigger('click')
86 $('.owl' + data).parents('.owl-item').addClass('marked');
87 }
88 });
89
90 jQuery(document).ready(function ($) {
91
92 j = $('#scene-1').find('.hotspot-nav li').eq(-2).find('span').attr('data-index');
93 var ajaxurl = wpvr_obj.ajaxurl;
94 $('.panolenspreview').on('click', function (e) {
95 e.preventDefault();
96 $('.wpvr-loading').show();
97 var videourl = $("input[name='video-attachment-url']").val();
98 var vidautoplay = $("input[name='playvideo']:checked").val();
99 var vidcontrol = $("input[name='playcontrol']:checked").val();
100
101 var panovideo = $("input[name='panovideo']:checked").val();
102
103 var postid = $("#post_ID").val();
104 var autoload = $("input[name='autoload']").is(':checked') ? 'on' : 'off';
105 var compass = $("input[name='compass']:checked").val();
106 var control = $("input[name='controls']").is(':checked') ? 'on' : 'off';
107 var rotation = $("input[name='autorotation']").is(':checked') ? 'on' : 'off';
108 var defaultscene = $("input[name='default-scene-id']").val();
109 var preview = $("input[name='preview-attachment-url']").val();
110 var scenefadeduration = $("input[name='scene-fade-duration']").val();
111
112 var autorotation = $("input[name='auto-rotation']").val();
113 var autorotationinactivedelay = $("input[name='auto-rotation-inactive-delay']").val();
114 var autorotationstopdelay = $("input[name='auto-rotation-stop-delay']").val();
115
116 var panodata = $('.scene-setup').repeaterVal();
117 var panolist = JSON.stringify(panodata);
118 var previewtext = $('.previewtext').val();
119
120 jQuery.ajax({
121 type: "POST",
122 url: ajaxurl,
123 data: {
124 action: "wpvr_preview",
125 nonce : wpvr_obj.ajax_nonce,
126 postid: postid,
127 compass: compass,
128 control: control,
129 autoload: autoload,
130 panodata: panolist,
131 defaultscene: defaultscene,
132 rotation: rotation,
133 autorotation: autorotation,
134 autorotationinactivedelay: autorotationinactivedelay,
135 autorotationstopdelay: autorotationstopdelay,
136 preview: preview,
137 scenefadeduration: scenefadeduration,
138 panovideo: panovideo,
139 videourl: videourl,
140 vidautoplay: vidautoplay,
141 vidcontrol: vidcontrol
142 },
143
144 success: function (response) {
145 $('.wpvr-loading').hide();
146 if (response.success == true) {
147 if(response.data[2] == 'off'){
148 $('#error_occured').hide();
149 $('#error_occuredpub').hide();
150 $('#' + response.data[0]["panoid"]).empty();
151 var scenes = response.data[1];
152
153 if (scenes) {
154 $.each(scenes.scenes, function (i) {
155 $.each(scenes.scenes[i]['hotSpots'], function (key, val) {
156 if (val["clickHandlerArgs"] != "") {
157 val["clickHandlerFunc"] = wpvrhotspot;
158 }
159 if (val["createTooltipArgs"] != "") {
160 val["createTooltipFunc"] = wpvrtooltip;
161 }
162 });
163 });
164 }
165 if (scenes) {
166 $('.scene-gallery').trigger('destroy.owl.carousel');
167 $('.scene-gallery').empty();
168
169 $.each(scenes.scenes, function (key, val) {
170 $('.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>');
171 });
172 $('.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>');
173
174 $(".vrowl-carousel").owlCarousel({
175 margin: 10,
176 autoWidth: true,
177 });
178 var active_owl_target = $('#wpvr_active_scenes').val();
179 var get_owl_target = $('#scene-' + active_owl_target).find('input.sceneid').val();
180 $('.owl' + get_owl_target).parents('.owl-item').addClass('marked');
181 }
182 var panoshow = pannellum.viewer(response.data[0]["panoid"], scenes);
183 if (scenes.autoRotate) {
184 panoshow.on('load', function () {
185 setTimeout(function () {
186 panoshow.startAutoRotate(scenes.autoRotate, 0);
187 }, 3000);
188 });
189 panoshow.on('scenechange', function () {
190 setTimeout(function () {
191 panoshow.startAutoRotate(scenes.autoRotate, 0);
192 }, 3000);
193 });
194 }
195 var touchtime = 0;
196 if (scenes) {
197 $.each(scenes.scenes, function (key, val) {
198 document.getElementById('' + key + '_gallery').addEventListener('click', function (e) {
199 if (touchtime == 0) {
200 touchtime = new Date().getTime();
201 } else {
202 if (((new Date().getTime()) - touchtime) < 800) {
203 panoshow.loadScene(key);
204 activateSceneTab(key)
205 touchtime = 0;
206 } else {
207 touchtime = new Date().getTime();
208 }
209 }
210 });
211 });
212 }
213 if( newScene){
214 var data = $('#scene-' + newScene).find('input.sceneid').val();
215 if(data){
216 panoshow.loadScene(data);
217 }
218 newScene = ''
219 }
220 if(specificeSceneID){
221 setTimeout(() => {
222 panoshow.loadScene(specificeSceneID);
223 }, 500);
224 }
225 $('html, body').animate({
226 scrollTop: $("#wpvr_item_builder__box").offset().top
227 }, 500);
228 //set preview text
229 if ("" != previewtext) {
230 $('.pnlm-load-button p').text(previewtext);
231 }
232 }else{
233 $('#' + response.data["panoid"]).empty();
234 $('#' + response.data["panoid"]).html(response.data["panodata"]);
235 if (response.data['vidtype'] == 'selfhost') {
236 videojs(response.data["vidid"], {
237 plugins: {
238 pannellum: {}
239 }
240 });
241 }
242 $('html, body').animate({
243 scrollTop: $("#wpvr_item_builder__box").offset().top
244 }, 500);
245 }
246
247 } else {
248 $('#error_occured').show();
249 $('#error_occured .pano-error-message').html(response.data);
250 $('#error_occuredpub').show();
251 $('#error_occuredpub').html(response.data);
252 $('body').addClass('error-overlay');
253 $('html, body').animate({
254 scrollTop: $("#error_occured").offset().top
255 }, 500);
256 }
257
258 }
259 });
260 });
261 });
262 function activateSceneTab(sceneId){
263 jQuery(".scene-nav ul li span").each(function() {
264 // Get the value of the data-href attribute
265 var dataHrefValue = jQuery(this).attr("data-href");
266 var currentScene = jQuery(dataHrefValue).find('input.sceneid').val();
267
268 if(sceneId == currentScene){
269 jQuery(this).trigger('click');
270 }
271 });
272 }
273
274 //-- Set Cookie--//
275
276 function setCookie(cName, cValue, expDays) {
277 let date = new Date();
278 date.setTime(date.getTime() + (expDays * 24 * 60 * 60 * 1000));
279 const expires = "expires=" + date.toUTCString();
280 document.cookie = cName + "=" + cValue + "; " + expires + "; path=/";
281 }
282 // Get a cookie
283
284 function getCookie(cName) {
285 const name = cName + "=";
286 const cDecoded = decodeURIComponent(document.cookie); //to be careful
287 const cArr = cDecoded .split('; ');
288 let res;
289 cArr.forEach(val => {
290 if (val.indexOf(name) === 0) res = val.substring(name.length);
291 })
292 return res;
293 }
294
295 function getParameterByName(name, url = window.location.href) {
296 name = name.replace(/[\[\]]/g, '\\$&');
297 var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
298 results = regex.exec(url);
299 if (!results) return null;
300 if (!results[2]) return '';
301 return decodeURIComponent(results[2].replace(/\+/g, ' '));
302 }
303 function findValueByName(name,dataArray) {
304 for (var i = 0; i < dataArray.length; i++) {
305 if (dataArray[i].name === name) {
306 return dataArray[i].value;
307 }
308 }
309 // Return a default value or handle the case when the name is not found
310 return '';
311 }
312
313 jQuery(document).ready(function ($) {
314 var getRedirectUrl = getCookie("redirectUrl");
315 var getCookiePostID = getCookie("postID");
316
317 const urlParams = getParameterByName("active_tab");
318 const action = wpvr_global_obj.url_info.param.action;
319 let getPostID = wpvr_global_obj.url_info.param.post;
320
321 if(getCookiePostID == getPostID){
322 if(urlParams == '' || urlParams == undefined){
323 if (action == 'edit' && getRedirectUrl != undefined){
324 window.location.replace(getRedirectUrl)
325 setCookie('postID', '', 1);
326 setCookie('redirectUrl', '', 1);
327 }
328 }
329 }
330 var flag_ok = false;
331 $('#publish').on('click', function (e) {
332 e.preventDefault();
333 $('#publish').prop('disabled', true);
334
335 $('.panolenspreview').trigger('click')
336 var data = $('form#post').serializeArray();
337 var post_status = findValueByName('post_status',data)
338 var hidden_post_status = findValueByName('hidden_post_status',data)
339 var hidden_post_password = findValueByName('hidden_post_password',data)
340 var hidden_post_visibility = findValueByName('hidden_post_visibility',data)
341 var visibility = findValueByName('visibility',data)
342 var post_password = findValueByName('post_password',data)
343 var post_title = findValueByName('post_title',data)
344 var x = $(this).val();
345 // if (!flag_ok) {
346 $('.wpvr-loading').show();
347 var postid = $("#post_ID").val();
348 var panovideo = $("input[name='panovideo']:checked").val();
349 var videourl = $("input[name='video-attachment-url']").val();
350 var autoload = $("input[name='autoload']").is(':checked') ? 'on' : 'off';
351 var control = $("input[name='controls']").is(':checked') ? 'on' : 'off';
352 var compass = $("input[name='compass']:checked").val();
353 var defaultscene = $("input[name='default-scene-id']").val();
354 var preview = $("input[name='preview-attachment-url']").val();
355 var rotation = $("input[name='autorotation']").is(':checked') ? 'on' : 'off'; // Auto Rotation checkbox value
356 var autorotation = $("input[name='auto-rotation']").val();
357 var autorotationinactivedelay = $("input[name='auto-rotation-inactive-delay']").val();
358 var autorotationstopdelay = $("input[name='auto-rotation-stop-delay']").val();
359
360 var scenefadeduration = $("input[name='scene-fade-duration']").val();
361 var previewtext = $('.previewtext').val();
362 if ($('.scene-setup')[0]) {
363 var panodata = $('.scene-setup').repeaterVal();
364
365 var panolist = JSON.stringify(panodata);
366 } else {
367 var panodata = '';
368 var panolist = '';
369 }
370
371 jQuery.ajax({
372
373 type: "POST",
374 url: ajaxurl,
375 data: {
376 action: "wpvr_save",
377 nonce : wpvr_obj.ajax_nonce,
378 postid: postid,
379 panovideo: panovideo,
380 videourl: videourl,
381 control: control,
382 compass: compass,
383 autoload: autoload,
384 panodata: panolist,
385 defaultscene: defaultscene,
386 preview: preview,
387 rotation: rotation, // Auto Rotation checkbox value
388 autorotation: autorotation, // Rotatin speed
389 autorotationinactivedelay: autorotationinactivedelay,
390 autorotationstopdelay: autorotationstopdelay,
391 scenefadeduration: scenefadeduration,
392 previewtext: previewtext,
393
394 hidden_post_status: hidden_post_status,
395 post_status: post_status,
396 hidden_post_password: hidden_post_password,
397 hidden_post_visibility: hidden_post_visibility,
398 visibility: visibility,
399 post_password: post_password,
400 post_value: $('#publish').val(),
401 post_title: post_title,
402 },
403
404 success: function (response) {
405 $('.wpvr-loading').hide();
406 $('#publish').prop('disabled', false);
407 if (response.success == false) {
408 $('#error_occured').show();
409 $('#error_occured .pano-error-message').html(response.data);
410 $('#error_occuredpub').show();
411 $('#error_occuredpub').html(response.data);
412
413 $('body').addClass('error-overlay');
414 $('html, body').animate({
415 scrollTop: $("#error_occured").offset().top
416 }, 500);
417 } else {
418 flag_ok = true;
419 $("#publishing-action").prepend('<div class="success-message" id="wpvr-success-message"><p>Successfully Updated</p></div>');
420 setTimeout(function(){
421 $("#wpvr-success-message").remove();
422 }, 3000 );
423 var url_info = wpvr_global_obj.url_info
424 var oldUrl = '';
425 let params = (new URL(document.location)).searchParams;
426 let active_tab = params.get('active_tab');
427 oldUrl = url_info.admin_url+"post.php?"+"post="+postid+"&action=edit"+"&active_tab="+active_tab;
428 if ( 'add' == url_info.screen ){
429 setCookie('redirectUrl', oldUrl, 1);
430 setCookie('postID', postid, 1);
431 }else{
432 setCookie('postID', postid, 1);
433
434 setCookie('redirectUrl', oldUrl, 1);
435 }
436 var publishedOptionSelected = $("#post_status option[value='publish']").length > 0;
437 if (!publishedOptionSelected) {
438 $("#post_status").append('<option selected="selected" value="publish">Published</option>')
439 }
440 var statusText = $("#post_status").val()
441 $("#post-status-display").text(statusText)
442 if(response.data.post_status == 'draft'){
443 $('#publish').val('Publish');
444 }else{
445 $('#publish').val('Update');
446 }
447 window.history.replaceState(null, '', url_info.admin_url+"post.php?"+"post="+postid+"&action=edit");
448 }
449 }
450 });
451 // }
452 });
453 });
454
455 jQuery(document).ready(function ($) {
456 $("body, .pano-error-close-btn").on("click", function (e) {
457 $("#error_occured").hide();
458 $('body').removeClass('error-overlay');
459 });
460
461 $(".panolenspreview, #error_occured").on("click", function (e) {
462 e.stopPropagation();
463 });
464 });
465
466 jQuery(document).ready(function ($) {
467 var previewtext = $('.previewtext').val();
468 if ("" != previewtext) {
469 $('.pnlm-load-button p').text(previewtext);
470 }
471 });
472
473 jQuery(document).ready(function ($) {
474
475 var flag_ok = false;
476 $('#save-post').on('click', function (e) {
477 var x = $(this).val();
478 if (!flag_ok) {
479 e.preventDefault();
480 $('.wpvr-loading').show();
481 var postid = $("#post_ID").val();
482 var panovideo = $("input[name='panovideo']:checked").val();
483 var videourl = $("input[name='video-attachment-url']").val();
484 var autoload = $("input[name='autoload']").val();
485 var control = $("input[name='controls']").val();
486 var compass = $("input[name='compass']:checked").val();
487 var defaultscene = $("input[name='default-scene-id']").val();
488 var preview = $("input[name='preview-attachment-url']").val();
489 var rotation = $("input[name='autorotation']").val();
490 var autorotation = $("input[name='auto-rotation']").val();
491 var autorotationinactivedelay = $("input[name='auto-rotation-inactive-delay']").val();
492 var autorotationstopdelay = $("input[name='auto-rotation-stop-delay']").val();
493
494 var scenefadeduration = $("input[name='scene-fade-duration']").val();
495
496 if ($('.scene-setup')[0]) {
497 var panodata = $('.scene-setup').repeaterVal();
498 var panolist = JSON.stringify(panodata);
499 } else {
500 var panodata = '';
501 var panolist = '';
502 }
503
504 jQuery.ajax({
505
506 type: "POST",
507 url: ajaxurl,
508 data: {
509 action: "wpvr_save",
510 nonce : wpvr_obj.ajax_nonce,
511 postid: postid,
512 panovideo: panovideo,
513 videourl: videourl,
514 control: control,
515 compass: compass,
516 autoload: autoload,
517 panodata: panolist,
518 defaultscene: defaultscene,
519 preview: preview,
520 rotation: rotation,
521 autorotation: autorotation,
522 autorotationinactivedelay: autorotationinactivedelay,
523 autorotationstopdelay: autorotationstopdelay,
524 scenefadeduration: scenefadeduration,
525 },
526
527 success: function (response) {
528 $('.wpvr-loading').hide();
529 if (response.success == false) {
530 $('#error_occured').show();
531 $('#error_occured').html(response.data);
532 $('#error_occuredpub').show();
533 $('#error_occuredpub').html(response.data);
534
535 $('body').addClass('error-overlay');
536 $('html, body').animate({
537 scrollTop: $("#error_occured").offset().top
538 }, 500);
539 } else {
540 flag_ok = true;
541 $('#save-post').trigger('click');
542 }
543 }
544 });
545 }
546 });
547 });
548 // $("#custom-ifram").css({
549 // "height": "auto",
550 // "width": "auto",
551 // "max-width": "60%",
552 // "max-height": "80%",
553 // "text-align": "center",
554 // "padding": "8px",
555 // "overflow": "auto",
556 // });
557
558
559
560
561
562
563 function wpvrhotspot(hotSpotDiv, args) {
564 var argst = args.replace(/\\/g, '');
565 $("#custom-ifram").html(argst);
566 $("#custom-ifram").fadeToggle();
567 $(".iframe-wrapper").toggleClass("show-modal");
568
569 }
570
571 function wpvrtooltip(hotSpotDiv, args) {
572 hotSpotDiv.classList.add('custom-tooltip');
573 var span = document.createElement('span');
574 args = args.replace(/\\/g, "");
575 span.innerHTML = args;
576 hotSpotDiv.appendChild(span);
577 span.style.marginLeft = -(span.scrollWidth - hotSpotDiv.offsetWidth) / 2 + 'px';
578 span.style.marginTop = -span.scrollHeight - 12 + 'px';
579 }
580
581 jQuery(document).ready(function ($) {
582 $("#cross").on("click", function (e) {
583 e.preventDefault();
584 $("#custom-ifram").fadeOut();
585 $(".iframe-wrapper").removeClass("show-modal");
586 $('iframe').attr('src', $('iframe').attr('src'));
587 });
588 });
589
590 jQuery(document).ready(function ($) {
591
592 var i = $('.scene-nav li').eq(-2).find('span').attr('data-index');
593 i = parseInt(i);
594
595 $('.scene-setup').repeater({
596
597 defaultValues: {
598 'scene-type': 'equirectangular',
599 'dscene': 'off',
600 'ptyscene': 'off',
601 'cvgscene': 'off',
602 'chgscene': 'off',
603 'czscene': 'off',
604 },
605 show: function () {
606 $('textarea[name*=hotspot-content]').summernote({
607 toolbar: [
608 ['style', ['style']],
609 ['font', ['bold', 'underline', 'clear']],
610 ['fontname', ['fontname']],
611 ['color', ['color']],
612 ['para', ['ul', 'ol', 'paragraph']],
613 ['table', ['table']],
614 ['insert', ['link', 'picture', 'video']],
615 ['view', ['codeview', 'help']],
616 ],
617 callbacks: {
618 onKeyup: function(e) {
619 var getHotspotContent = $(this).val();
620 var getParent = $(this).parent();
621 var getMainParent = getParent.parent()
622 var getClickContent = getMainParent.find('.hotspot-url')
623 if(getHotspotContent.length > 0){
624 getClickContent.find('input[name*=hotspot-url').val('')
625 getClickContent.find('input[name*=hotspot-url').attr('placeholder','You can set either a URL or an On-click content')
626 getClickContent.find('input[name*=hotspot-url]').attr("disabled",true)
627 }else{
628 getClickContent.find('input[name*=hotspot-url]').attr("disabled",false)
629 }
630 }
631 }
632 });
633 $('textarea[name*=hotspot-hover]').summernote({
634 toolbar: [
635 ['style', ['style']],
636 ['font', ['bold', 'underline', 'clear']],
637 ['fontname', ['fontname']],
638 ['color', ['color']],
639 ['para', ['ul', 'ol', 'paragraph']],
640 ['table', ['table']],
641 ['insert', ['link', 'picture', 'video']],
642 ['view', ['codeview', 'help']],
643 ],
644 });
645 if ($(this).parents(".scene-setup").attr("data-limit").length > 0) {
646
647 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")) {
648
649 $(this).slideDown();
650 $(this).removeClass('active');
651
652 i = i + 1;
653 var scene = 'scene-' + i;
654
655 $(this).find(".title .scene-num").html(i);
656
657 $('<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'));
658
659 $(this).attr('id', scene);
660 changehotspotid(i);
661 $(this).siblings('.active').removeClass('active');
662 $(this).addClass('active');
663 $(this).find(".sceneid").val(generateRandomString(8));
664 setTimeout(changeicon, 1000);
665 } else {
666 $('.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>');
667 $('body').addClass('error-overlay2');
668 $('.pano-alert').addClass('pano-default-warning').show();
669 $(this).remove();
670 }
671 } else {
672 jQuery(this).slideDown();
673 $(this).removeClass('active');
674
675 i = i + 1;
676 var scene = 'scene-' + i;
677 $(this).find(".title .scene-num").html(i);
678 $('<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'));
679 $(this).attr('id', scene);
680 changehotspotid(i);
681 }
682
683 $(this).hide();
684
685 //tab active setup
686 $('#wpvr_active_scenes').val(i);
687 $('#wpvr_active_hotspot').val(1);
688 },
689 hide: function (deleteElement) {
690 var hide_id = $(this).attr("id");
691 var _hide_id = hide_id.split('-').pop();
692 hide_id = "#" + hide_id;
693
694 var current = $(this).attr('id');
695 var fchild = $('.single-scene:nth-child(2)').attr('id');
696 // var fchild = $(this).parent().children(":first").attr('id');
697
698
699 var elementcontains = $(this).attr("id");
700 var str1 = 'scene';
701 var str2 = 'hotspot';
702 if (elementcontains.indexOf(str1) != -1 && elementcontains.indexOf(str2) == -1) {
703
704 var _this = $(this);
705 // $('.wpvr-delete-alert-wrapper').addClass('pano-error-color').css('display', 'flex');
706 // $('#confirm_text').html(' Are you sure you want to delete this Scene?');
707 // $('.wpvr-delete-confirm-btn .yes').click(function (e) {
708 // e.preventDefault();
709 // jQuery(_this).slideUp(deleteElement);
710 // if (current == fchild) {
711 // $(_this).next().addClass("active");
712 // $(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").next().addClass("active");
713 // $(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").next().children("span").trigger("click");
714 // } else {
715 // $(_this).prev().addClass("active");
716 // $(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").prev().addClass("active");
717 // $(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").prev().children("span").trigger("click");
718 // }
719 // $(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").remove();
720 // setTimeout(deleteinfodata, 1000);
721
722 // //tab active setup
723 // if (parseInt(_hide_id) - 1 > 0) {
724 // $('#wpvr_active_scenes').val(parseInt(_hide_id) - 1);
725 // } else {
726 // $('#wpvr_active_scenes').val(1);
727 // }
728 // $('#wpvr_active_hotspot').val(1);
729 // $('.wpvr-delete-alert-wrapper').removeClass('pano-error-color').css('display', 'none');
730 // $('.wpvr-delete-alert-wrapper').hide();
731 // });
732
733 // $(document).on("click", ".wpvr-delete-confirm-btn .cancel, .wpvr-delete-alert-wrapper .cross", function (e) {
734 // e.preventDefault();
735 // $('.wpvr-delete-alert-wrapper').removeClass('pano-error-color').css('display', 'none');
736 // $('.wpvr-delete-alert-wrapper').hide();
737 // });
738
739 if (confirm('Are you sure you want to delete?')) {
740 jQuery(_this).slideUp(deleteElement);
741 if (current == fchild) {
742 $(_this).next().addClass("active");
743 $(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").next().addClass("active");
744 $(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").next().children("span").trigger("click");
745 } else {
746 $(_this).prev().addClass("active");
747 $(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").prev().addClass("active");
748 $(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").prev().children("span").trigger("click");
749 }
750 $(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").remove();
751 setTimeout(deleteinfodata, 1000);
752
753 //tab active setup
754 if (parseInt(_hide_id) - 1 > 0) {
755 $('#wpvr_active_scenes').val(parseInt(_hide_id) - 1);
756 } else {
757 $('#wpvr_active_scenes').val(1);
758 }
759 $('#wpvr_active_hotspot').val(1);
760 }
761
762 }
763 },
764 repeaters: [{
765 selector: '.hotspot-setup',
766 defaultValues: {
767 'hotspot-type': 'info',
768 'hotspot-customclass-pro': 'none',
769 },
770 show: function () {
771 $('textarea[name*=hotspot-content]').summernote({
772 toolbar: [
773 ['style', ['style']],
774 ['font', ['bold', 'underline', 'clear']],
775 ['fontname', ['fontname']],
776 ['color', ['color']],
777 ['para', ['ul', 'ol', 'paragraph']],
778 ['table', ['table']],
779 ['insert', ['link', 'picture', 'video']],
780 ['view', ['codeview', 'help']],
781 ],
782 callbacks: {
783 onKeyup: function(e) {
784 var getHotspotContent = $(this).val();
785 var getParent = $(this).parent();
786 var getMainParent = getParent.parent()
787 var getClickContent = getMainParent.find('.hotspot-url')
788 if(getHotspotContent.length > 0){
789 getClickContent.find('input[name*=hotspot-url').val('')
790 getClickContent.find('input[name*=hotspot-url').attr('placeholder','You can set either a URL or an On-click content')
791 getClickContent.find('input[name*=hotspot-url]').attr("disabled",true)
792 }else{
793 getClickContent.find('input[name*=hotspot-url]').attr("disabled",false)
794 }
795 }
796 }
797 });
798 $('textarea[name*=hotspot-hover]').summernote({
799 toolbar: [
800 ['style', ['style']],
801 ['font', ['bold', 'underline', 'clear']],
802 ['fontname', ['fontname']],
803 ['color', ['color']],
804 ['para', ['ul', 'ol', 'paragraph']],
805 ['table', ['table']],
806 ['insert', ['link', 'picture', 'video']],
807 ['view', ['codeview', 'help']],
808 ],
809 });
810 if ($(this).parents(".hotspot-setup").attr("data-limit").length > 0) {
811
812 if ($(this).parents(".hotspot-setup").find("div[data-repeater-item]").length <= $(this).parents(".hotspot-setup").attr("data-limit")) {
813
814 $(this).slideDown();
815 $(this).removeClass('active');
816 $(this).siblings('.active').removeClass('active');
817 $(this).addClass('active');
818 j = parseInt(j);
819 j = j + 1;
820 var parent_scene = $(this).parent().parent().parent('.single-scene.active').attr('id');
821 scene_parent = parent_scene;
822 var hotspot = parent_scene + '-hotspot-' + j;
823
824 var replace_string = parent_scene.replace("scene-", "");
825
826 $(this).find(".title .hotspot-num").html(j);
827 $(this).find(".title .scene-num").html(replace_string);
828
829 $('<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'));
830
831 $(this).attr('id', hotspot);
832
833 setTimeout(changeicon, 1000);
834 } else {
835 $('.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>');
836 $('body').addClass('error-overlay2');
837 $('.pano-alert').addClass('pano-default-warning').show();
838 $(this).remove();
839 }
840 } else {
841 jQuery(this).slideDown();
842 $(this).removeClass('active');
843 j = parseInt(j);
844 j = j + 1;
845 var parent_scene = $(this).parent().parent().parent('.single-scene.active').attr('id');
846 var hotspot = parent_scene + '-hotspot-' + j;
847
848 var replace_string = parent_scene.replace("scene-", "");
849
850 $(this).find(".title .hotspot-num").html(j);
851 $(this).find(".title .scene-num").html(replace_string);
852
853 $('<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'));
854
855 $(this).attr('id', hotspot);
856 }
857 $('#wpvr_active_hotspot').val(j);
858 },
859 hide: function (deleteElement) {
860 var hotspot_hide_id = $(this).attr("id");
861 var _hide_id = hotspot_hide_id.split('-').pop();
862 hotspot_hide_id = "#" + hotspot_hide_id;
863 var hotspot_current = $(this).attr('id');
864 var hotspot_fchild = $(this).parent().children(":first").attr('id');
865
866 var hpelementcontains = $(this).attr("id");
867 var hpstr1 = 'scene';
868 var hpstr2 = 'hotspot';
869 if (hpelementcontains.indexOf(hpstr1) != -1 && hpelementcontains.indexOf(hpstr2) != -1) {
870
871 var _this = $(this);
872
873 // $('#confirm_text').html(' Are you sure you want to delete this Hotspot?');
874 // $('.wpvr-delete-alert-wrapper').addClass('pano-error-color').css('display', 'flex');
875
876 // $('.wpvr-delete-confirm-btn .yes').click(function (e) {
877 // e.preventDefault();
878 // jQuery(_this).slideUp(deleteElement);
879 // if (hotspot_current == hotspot_fchild) {
880 // $(_this).next().addClass("active");
881 // $(_this).parent().parent('.hotspot-setup').find('.hotspot-nav li span[data-href="' + hotspot_hide_id + '"]').parent("li").next().addClass("active");
882
883 // } else {
884 // $(_this).prev().addClass("active");
885 // $(_this).parent().parent('.hotspot-setup').find('.hotspot-nav li span[data-href="' + hotspot_hide_id + '"]').parent("li").prev().addClass("active");
886 // }
887
888 // $(_this).parent().parent('.hotspot-setup').find('.hotspot-nav li:not(:last-child) span[data-href="' + hotspot_hide_id + '"]').parent("li").remove();
889
890 // //tab active setup
891 // if (parseInt(_hide_id) - 1 > 0) {
892 // $('#wpvr_active_hotspot').val(parseInt(_hide_id) - 1);
893 // } else {
894 // $('#wpvr_active_hotspot').val(1);
895 // }
896 // $('.wpvr-delete-alert-wrapper').removeClass('pano-error-color').css('display', 'none');
897 // $('.wpvr-delete-alert-wrapper').hide();
898 // });
899
900 // $(document).on("click", ".wpvr-delete-confirm-btn .cancel, .wpvr-delete-alert-wrapper .cross", function (e) {
901 // e.preventDefault();
902 // $('.wpvr-delete-alert-wrapper').removeClass('pano-error-color').css('display', 'none');
903 // $('.wpvr-delete-alert-wrapper').hide();
904 // });
905
906 if (confirm('Are you sure you want to delete?')) {
907 jQuery(_this).slideUp(deleteElement);
908 if (hotspot_current == hotspot_fchild) {
909 $(_this).next().addClass("active");
910 $(_this).parent().parent('.hotspot-setup').find('.hotspot-nav li span[data-href="' + hotspot_hide_id + '"]').parent("li").next().addClass("active");
911
912 } else {
913 $(_this).prev().addClass("active");
914 $(_this).parent().parent('.hotspot-setup').find('.hotspot-nav li span[data-href="' + hotspot_hide_id + '"]').parent("li").prev().addClass("active");
915 }
916
917 $(_this).parent().parent('.hotspot-setup').find('.hotspot-nav li:not(:last-child) span[data-href="' + hotspot_hide_id + '"]').parent("li").remove();
918
919 //tab active setup
920 if (parseInt(_hide_id) - 1 > 0) {
921 $('#wpvr_active_hotspot').val(parseInt(_hide_id) - 1);
922 } else {
923 $('#wpvr_active_hotspot').val(1);
924 }
925 }
926 }
927 },
928
929 }]
930 });
931 });
932
933 $(document).on("click", ".upload-scene-wrapper", function (event) {
934 $(".scene-nav ul li:last-child span").trigger("click");
935 $(".scene-upload").trigger("click");
936 })
937
938 $(document).on("click", ".upload-scene-wrapper-first", function (event) {
939 $(".scene-upload").trigger("click");
940 })
941
942 var file_frame;
943 var parent;
944 $(document).on("click", ".scene-upload", function (event) {
945 event.preventDefault();
946 parent = $(this).parent('.form-group');
947
948 if (file_frame) {
949 file_frame.open();
950 return;
951 }
952
953 file_frame = wp.media.frames.file_frame = wp.media({
954 title: $(this).data('uploader_title'),
955 button: {
956 text: $(this).data('uploader_button_text'),
957 },
958 library: {
959 type: ['image']
960 },
961 multiple: false
962 });
963
964 file_frame.on('select', function () {
965
966 var attachment = file_frame.state().get('selection').first().toJSON();
967 parent.find('.scene-attachment-url').val(attachment.url);
968 parent.find('img').attr('src', attachment.url).show();
969 setTimeout(function () {
970 $('.panolenspreview').trigger('click');
971 },1000);
972 });
973
974 file_frame.open();
975 });
976
977 var file_frames;
978 $(document).on("click", ".video-upload", function (event) {
979 event.preventDefault();
980
981 parent = $(this).parent('.form-group');
982
983 if (file_frames) {
984 file_frames.open();
985 return;
986 }
987
988 file_frames = wp.media.frames.file_frames = wp.media({
989 title: $(this).data('uploader_title'),
990 button: {
991 text: $(this).data('uploader_button_text'),
992 },
993 library: {
994 type: ['video/mp4']
995 },
996 multiple: false
997 });
998
999 file_frames.on('select', function () {
1000 var attachment = file_frames.state().get('selection').first().toJSON();
1001 parent.find('.video-attachment-url').val(attachment.url);
1002 });
1003
1004 file_frames.open();
1005 });
1006
1007 var file_fram;
1008
1009 $(document).on("click", ".preview-upload", function (event) {
1010 event.preventDefault();
1011 parent = $(this).parent('.form-group');
1012
1013 if (file_fram) {
1014 file_fram.open();
1015 return;
1016 }
1017
1018 file_fram = wp.media.frames.file_fram = wp.media({
1019 title: $(this).data('uploader_title'),
1020 button: {
1021 text: $(this).data('uploader_button_text'),
1022 },
1023 library: {
1024 type: ['image']
1025 },
1026 multiple: false
1027 });
1028
1029 file_fram.on('select', function () {
1030 var attachment = file_fram.state().get('selection').first().toJSON();
1031 parent.find('.preview-attachment-url').val(attachment.url);
1032 parent.find('.img-upload-frame').css('background-image', 'url(' + attachment.url + ')');
1033 parent.find('.img-upload-frame').addClass('img-uploaded');
1034 parent.find('.remove-attachment').show();
1035 });
1036
1037 file_fram.open();
1038 });
1039
1040 //----remove tour preview image----
1041 $(document).on("click", ".remove-attachment", function (event) {
1042 $(this).hide();
1043 parent = $(this).parents('.form-group');
1044
1045 parent.find('.preview-attachment-url').val('');
1046 parent.find('.img-upload-frame').css('background-image', '');
1047 parent.find('.img-upload-frame').removeClass('img-uploaded');
1048 });
1049
1050
1051 $(document).on("change", "select[name*=hotspot-type]", function (event) {
1052
1053 var getparent = $(this).parent();
1054 var getvalue = $(this).val();
1055 if (getvalue == 'info') {
1056 getparent.find('.hotspot-scene').hide();
1057 getparent.find('.hotspot-scene input').val('');
1058 getparent.find('.hotspot-scene .hotspotscene').val('none');
1059 getparent.find('.hotspot-url').show();
1060 getparent.find('.s_tab').show();
1061 getparent.find('.hotspot-content').show();
1062 getparent.find('input[name*=hotspot-url]').attr("disabled",false)
1063 getparent.find('textarea[name*=hotspot-content]').next().find(".note-editable").attr("contenteditable", true);
1064 } else {
1065 getparent.find('.hotspot-scene').show();
1066 getparent.find('.hotspot-url').hide();
1067 getparent.find('.hotspot-url input').val('');
1068 getparent.find('.s_tab').hide();
1069 getparent.find('.s_tab input').val('off');
1070 getparent.find('.s_tab input').removeAttr('checked');
1071 getparent.find('.hotspot-content').hide();
1072 getparent.find('.hotspot-content textarea').val('');
1073 getparent.find('textarea[name*=hotspot-content]').next().find(".note-editable").html('');
1074 }
1075 });
1076 $(document).ready(function ($){
1077 $(document).on("keyup","input[name*=hotspot-url]",function (){
1078 var getHotspotUrl = $(this).val();
1079 var getParent = $(this).parent();
1080 var getMainParent = getParent.parent()
1081 var getClickContent = getMainParent.find('.hotspot-content')
1082 if(getHotspotUrl.length > 0){
1083 getClickContent.find('textarea').val('')
1084 getClickContent.find('textarea').attr('placeholder','You can set either a URL or an On-click content')
1085 getClickContent.find('textarea').attr("disabled",true)
1086 getClickContent.find('textarea[name*=hotspot-content]').next().find(".note-editable").attr("contenteditable", false);
1087 getClickContent.find('textarea[name*=hotspot-content]').next().find(".note-editable").html('');
1088
1089 }else{
1090 getClickContent.find('textarea').attr("disabled",false)
1091 getClickContent.find('textarea[name*=hotspot-content]').next().find(".note-editable").attr("contenteditable", true);
1092 }
1093 })
1094
1095 $(document).on("keyup","textarea[name*=hotspot-content]",function (){
1096 var getHotspotContent = $(this).val();
1097 var getParent = $(this).parent();
1098 var getMainParent = getParent.parent()
1099 var getClickContent = getMainParent.find('.hotspot-url')
1100 if(getHotspotContent.length > 0){
1101 getClickContent.find('input[name*=hotspot-url').val('')
1102 getClickContent.find('input[name*=hotspot-url').attr('placeholder','You can set either a URL or an On-click content')
1103 getClickContent.find('input[name*=hotspot-url]').attr("disabled",true)
1104 }else{
1105 getClickContent.find('input[name*=hotspot-url]').attr("disabled",false)
1106 }
1107 })
1108 })
1109
1110
1111 $(document).on("click", ".pano-error-close-btn", function (e) {
1112 e.preventDefault();
1113 $('.wpvr-delete-alert-wrapper').css('display', 'none');
1114 $('.wpvr-delete-alert-wrapper').hide();
1115 });
1116
1117 $(document).on("change", "input[type=radio][name=panovideo]", function (event) {
1118 var getvalue = $(this).val();
1119
1120 if (getvalue == 'on') {
1121 $('#confirm_text').html(`${window.wpvr_localize.VideoTourNotice}`);
1122 $('.wpvr-delete-alert-wrapper').css('display', 'flex');
1123 } else {
1124 $('.wpvr-delete-alert-wrapper').css('display', 'none');
1125 // $(".video-setting").hide();
1126
1127 $("li.general").show();
1128 $("li.scene").show();
1129 $("li.hotspot").show();
1130 $("li.streetview").show();
1131 $(".video-setting").hide();
1132 }
1133
1134 $(document).on("click", ".wpvr-delete-confirm-btn .cancel,.wpvr-delete-alert-wrapper .cross", function (e) {
1135 e.preventDefault();
1136 $('.wpvr-delete-alert-wrapper').css('display', 'none');
1137 $('.wpvr-delete-alert-wrapper').hide();
1138
1139 $(".video_on").prop('checked', false);
1140 $(".video_off").prop('checked', true);
1141
1142 $("li.general").show();
1143 $("li.scene").show();
1144 $("li.hotspot").show();
1145 $("li.streetview").show();
1146 $(".video-setting").hide();
1147
1148 });
1149
1150 $(document).on("click", ".wpvr-delete-confirm-btn .yes", function (e) {
1151 e.preventDefault();
1152 $('.wpvr-delete-alert-wrapper').css('display', 'none');
1153 $('.wpvr-delete-alert-wrapper').hide();
1154
1155 $(".video_off").prop('checked', false);
1156 $(".video_on").prop('checked', true);
1157 $(".video-setting").show();
1158 $("li.general").hide();
1159 $("li.scene").hide();
1160 $("li.hotspot").hide();
1161 $("li.streetview").hide();
1162
1163 });
1164 });
1165
1166 jQuery(document).ready(function ($) {
1167 let detect_scene_1_data = $('#scene-1').find('.sceneid').val();
1168 if(detect_scene_1_data === "") {
1169 $('#scene-1').find('.sceneid').val(generateRandomString(8));
1170 }
1171 });
1172
1173 function generateRandomString(length) {
1174 var result = '';
1175 var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
1176 var charactersLength = characters.length;
1177
1178 for (var i = 0; i < length; i++) {
1179 var randomIndex = Math.floor(Math.random() * charactersLength);
1180 result += characters.charAt(randomIndex);
1181 }
1182
1183 return result;
1184 }
1185 function prepare_hotspot_configuration_data() {
1186 var datacoords = $('#panodata').text().split(',');
1187 var pitchsplit = datacoords[0];
1188 var pitch = pitchsplit.split(':');
1189 var yawsplit = datacoords[1];
1190 var yaw = yawsplit.split(':');
1191 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();
1192 if(detect_active_hotspot_id === "" || detect_active_hotspot_id == undefined) {
1193 $('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));
1194 }
1195 $('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]);
1196 $('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]);
1197 }
1198
1199 function register_hotspot() {
1200 $('.panolenspreview').trigger('click');
1201 }
1202
1203 $(document).on("click", ".toppitch", function (event) {
1204 $.when(prepare_hotspot_configuration_data()).done(function() {
1205 register_hotspot();
1206 });
1207 });
1208
1209 // $(document).on("change", "input[type=radio][name=panovideo]", function(event) {
1210 // var getvalue = $(this).val();
1211
1212 // if (getvalue == 'on') {
1213
1214 // $(".video-setting").show();
1215 // $("li.general").hide();
1216 // $("li.scene").hide();
1217 // $("li.hotspot").hide();
1218 // $("li.streetview").hide();
1219 // } else {
1220 // $(".video-setting").hide();
1221 // $("li.general").show();
1222 // $("li.scene").show();
1223 // $("li.hotspot").show();
1224 // $("li.streetview").show();
1225 // }
1226 // });
1227
1228 jQuery(document).ready(function ($) {
1229 var viddata = $("input[name='panovideo']:checked").val();
1230
1231 if (viddata == 'on') {
1232
1233 $("li.scene").removeClass('active');
1234 $(".rex-pano-tab.wpvr_scene").removeClass('active');
1235 $("li.videos").addClass('active');
1236 $(".rex-pano-tab.video").addClass('active');
1237 $(".video-setting").show();
1238 $("li.general").hide();
1239 $("li.scene").hide();
1240 $("li.hotspot").hide();
1241 } else {
1242 // $(".video-setting").hide();
1243 $("li.general").show();
1244 $("li.scene").show();
1245 $("li.hotspot").show();
1246 }
1247 });
1248
1249 $(document).on("change", "select[name*=hotspot-customclass-pro]", function (event) {
1250 var getval = $(this).val();
1251 $(this).parent('.hotspot-setting').children('span.change-icon').html('<i class="' + getval + '"></i>');
1252
1253 });
1254
1255 $(document).on("change", ".hotspot-customclass-color", function (event) {
1256 var getcolor = $(this).val();
1257 color = getcolor;
1258 $('.hotspot-customclass-color-icon-value').val(getcolor);
1259 $('.hotspot-customclass-color').val(getcolor);
1260 });
1261
1262 jQuery(document).ready(function ($) {
1263 if ($(".icon-found-value")[0]) {
1264 color = $('.hotspot-customclass-color-icon-value.icon-found-value').val();
1265 } else {
1266 color = '#00b4ff';
1267 }
1268 });
1269
1270 function changeicon() {
1271 $('.hotspot-customclass-color-icon-value').val(color);
1272 $('.hotspot-customclass-color').val(color);
1273 }
1274
1275 //------------panolens tab js------------------
1276
1277
1278 $(document).on("click", ".scene-nav ul li:not(:last-child) span", function () {
1279
1280 var scene_id = $(this).data('index');
1281 scene_id = '#scene-' + scene_id;
1282
1283 j = $(scene_id).find('.hotspot-nav li').eq(-2).find('span').attr('data-index');
1284
1285 $([$(this).parent()[0], $($(this).data('href'))[0]]).addClass('active').siblings('.active').removeClass('active');
1286 $('#wpvr_active_scenes').val($(this).data('index'));
1287 });
1288
1289 //add click
1290 $(document).on("click", ".scene-nav ul li:last-child span", function () {
1291 var scene_id = $(this).parent('li').prev().children("span").data('index');
1292 scene_id = '#scene-' + scene_id;
1293 $(scene_id).removeAttr("style");
1294 j = $(scene_id).find('.hotspot-nav li').eq(-2).find('span').attr('data-index');
1295 $('.scene-nav ul li.active').removeClass('active');
1296 $(this).parent('li').prev().addClass('active');
1297 var sceneinfo = $('.scene-setup').repeaterVal();
1298 var infodata = sceneinfo['scene-list'];
1299 $('.hotspotscene').find('option').remove();
1300 $('.hotspotscene').append("<option value='none'>None</option>");
1301 for (var i in infodata) {
1302 var optiondata = infodata[i]['scene-id'];
1303 if (optiondata != '') {
1304 $('.hotspotscene').append("<option value='" + optiondata + "'>" + optiondata + "</option>");
1305 }
1306 }
1307 $('.hotspot-customclass-pro-select').fontIconPicker();
1308 $('span.change-icon').hide();
1309 });
1310
1311 //end add click
1312 $(document).on("click", ".hotspot-nav ul li:not(:last-child) span", function () {
1313 $('#wpvr_active_hotspot').val($(this).data('index'));
1314 $([$(this).parent()[0], $($(this).data('href'))[0]]).addClass('active').siblings('.active').removeClass('active');
1315 });
1316
1317 $(document).on("click", ".hotspot-nav ul li:last-child span", function () {
1318 $(this).parent('li').siblings('.active').removeClass('active');
1319 $(this).parent('li').prev().addClass('active');
1320 var sceneinfo = $('.scene-setup').repeaterVal();
1321 var infodata = sceneinfo['scene-list'];
1322 $('.hotspotscene').find('option').remove();
1323 $('.hotspotscene').append("<option value='none'>None</option>");
1324 for (var i in infodata) {
1325 var optiondata = infodata[i]['scene-id'];
1326 if (optiondata != '') {
1327 $('.hotspotscene').append("<option value='" + optiondata + "'>" + optiondata + "</option>");
1328 }
1329 }
1330 $('.trtr').trigger('change');
1331 $('.hotspot-customclass-pro-select').fontIconPicker();
1332 $('span.change-icon').hide();
1333
1334 });
1335
1336 function changehotspotid(id) {
1337 var scene_id = '#scene-' + id;
1338 var hotspot_id = 'scene-' + id + '-hotspot-1';
1339 $(scene_id).find('.hotspot-nav li span').attr('data-href', '#' + hotspot_id + '');
1340 $(scene_id).find('.single-hotspot').attr('id', hotspot_id);
1341
1342 }
1343
1344 $(document).on("click", ".rex-pano-nav-menu.main-nav ul li span", function () {
1345 var screen = $(this).parent().attr('data-screen');
1346
1347 var url_info = wpvr_global_obj.url_info
1348 if ( 'add' == url_info.screen ){
1349 var newUrl = url_info.admin_url+"post-new.php?"+"post_type="+url_info.param.post_type+"&active_tab="+screen;
1350 }else{
1351 var newUrl = url_info.admin_url+"post.php?"+"post="+url_info.param.post+"&action=edit"+"&active_tab="+screen;
1352 }
1353
1354
1355 if (window.history != 'undefined' && window.history.pushState != 'undefined') {
1356 window.history.pushState({ path: newUrl }, '', newUrl);
1357 }
1358
1359 $('#wpvr_active_tab').val(screen);
1360 if ('hotspot' == screen) {
1361 $('.active_scene_id').show();
1362 var id = $('.single-scene.active').attr('id');
1363 $('.active_scene_id p').text(`${window.wpvr_localize.AddingHotspotsOnScene}`);
1364 var scenceID = $('#' + id + ' .sceneid').val();
1365 var span = '<span>(' + scenceID + ')</span>'
1366 $('.active_scene_id p').append(span);
1367 $('.active_scene_id').css({ "background-color": "#E0E1F7", "width": "100%", "text-align": "center", "padding": "10px 15px" });
1368 $('.active_scene_id p').css({ "color": "black", "font-size": "15px" });
1369 $('.active_scene_id p span').css({ "color": "#004efa", "font-size": "15px" });
1370
1371 } else {
1372 $('.active_scene_id').hide();
1373 }
1374 $([$(this).parent()[0], $($(this).data('href'))[0]]).addClass('active').siblings('.active').removeClass('active');
1375 });
1376
1377 //-Get Started reloaded -//
1378 $(document).on("click",".tabs.rex-tabs li a",function(){
1379 var tab = $(this).attr('href');
1380 var url = window.location;
1381 var origin = url.origin;
1382 var pathname = url.pathname
1383 var search_perameter = window.location.search.split('&');
1384 var makeUrl = origin + pathname + search_perameter[0]
1385 var newUrl = makeUrl + tab;
1386
1387 if (window.history != 'undefined' && window.history.pushState != 'undefined') {
1388 window.history.pushState({ path: newUrl }, '', newUrl);
1389 }
1390 })
1391 //----------alert dismiss--------//
1392 $(document).on("click", "body", function () {
1393 $('body').removeClass('error-overlay2');
1394 $('.pano-alert').removeClass('pano-default-warning').hide();
1395 });
1396 $(document).on("click", ".pano-alert .pano-error-close-btn", function () {
1397 $('body').removeClass('error-overlay2');
1398 $('.pano-alert').removeClass('pano-default-warning').hide();
1399 });
1400 $(document).on("click", ".pano-alert, .rex-pano-sub-tabs .rex-pano-tab-nav li.add", function (e) {
1401 e.stopPropagation();
1402 });
1403
1404
1405 $(document).on("click", ".main-nav li.hotspot span", function () {
1406 $(".hotspot-setup.rex-pano-sub-tabs").show();
1407 $(".scene-setup > nav.scene-nav").hide();
1408 $(".scene-setup .single-scene > .scene-content").hide();
1409 $(".scene-setup .delete-scene").hide();
1410 });
1411
1412 $(document).on("click", ".main-nav li.scene span", function () {
1413 $(".hotspot-setup.rex-pano-sub-tabs").hide();
1414 $(".scene-setup > nav.scene-nav").show();
1415 $(".scene-setup .single-scene > .scene-content").show();
1416 $(".scene-setup .delete-scene").show();
1417 });
1418
1419 $(document).on("change", ".dscen", function () {
1420 var dscene = $(this).val();
1421 $(".dscen").not(this).each(function () {
1422 var oth_scene = $(this).val();
1423 if (dscene == 'on' && oth_scene == 'on') {
1424 $('#error_occured').show();
1425 $('#error_occured .pano-error-message').html('<span class="pano-error-title">Default scene has been updated</span>');
1426 $('body').addClass('error-overlay');
1427 $('html, body').animate({
1428 scrollTop: $("#error_occured").offset().top
1429 }, 500);
1430 $(this).val('off');
1431
1432 }
1433 });
1434 });
1435
1436 $(document).on("change", ".sceneid", function () {
1437 var sceneinfo = $('.scene-setup').repeaterVal();
1438 var infodata = sceneinfo['scene-list'];
1439 $('.hotspotscene').find('option').remove();
1440 $('.hotspotscene').append("<option value='none'>None</option>");
1441 for (var i in infodata) {
1442 var optiondata = infodata[i]['scene-id'];
1443 if (optiondata != '') {
1444 $('.hotspotscene').append("<option value='" + optiondata + "'>" + optiondata + "</option>");
1445 }
1446 }
1447 });
1448
1449
1450
1451 function deleteinfodata() {
1452 var sceneinfo = $('.scene-setup').repeaterVal();
1453 var infodata = sceneinfo['scene-list'];
1454 $('.hotspotscene').find('option').remove();
1455 $('.hotspotscene').append("<option value='none'>None</option>");
1456 for (var i in infodata) {
1457 var optiondata = infodata[i]['scene-id'];
1458 if (optiondata != '') {
1459 $('.hotspotscene').append("<option value='" + optiondata + "'>" + optiondata + "</option>");
1460 }
1461 }
1462 }
1463
1464 $(document).on("change", ".hotspotscene", function () {
1465
1466 var chanheghtptpval = $(this).val();
1467 if (chanheghtptpval != "none") {
1468 $(this).parent('.hotspot-scene').siblings('.hotspot-scene').children('.hotspotsceneinfodata').val(chanheghtptpval);
1469 } else {
1470 $(this).parent('.hotspot-scene').siblings('.hotspot-scene').children('.hotspotsceneinfodata').val('');
1471 }
1472 });
1473
1474 $(document).on("click", ".hotpitch", function (event) {
1475 var datacoords = $('#panodata').text().split(',');
1476 var pitchsplit = datacoords[0];
1477 var pitch = pitchsplit.split(':');
1478 $(this).parent().parent('.hotspot-setting').children('.hotspot-pitch').val(pitch[1]);
1479 });
1480
1481 $(document).on("click", ".hotyaw", function (event) {
1482 var datacoords = $('#panodata').text().split(',');
1483 var yawsplit = datacoords[1];
1484 var yaw = yawsplit.split(':');
1485 $(this).parent().parent('.hotspot-setting').children('.hotspot-yaw').val(yaw[1]);
1486 });
1487
1488 jQuery(document).ready(function ($) {
1489
1490 if ($(".scene-setup").length > 0) {
1491 var sceneinfo = $('.scene-setup').repeaterVal();
1492 var infodata = sceneinfo['scene-list'];
1493 $('.hotspotscene').find('option').remove();
1494 $('.hotspotscene').append("<option value='none'>None</option>");
1495 for (var i in infodata) {
1496 var optiondata = infodata[i]['scene-id'];
1497 if (optiondata != '') {
1498 $('.hotspotscene').append("<option value='" + optiondata + "'>" + optiondata + "</option>");
1499 }
1500 }
1501 }
1502 });
1503
1504 $(document).on("click", ".toppitch", function (event) {
1505 var datacoords = $('#panodata').text().split(',');
1506 var pitchsplit = datacoords[0];
1507 var pitch = pitchsplit.split(':');
1508 var yawsplit = datacoords[1];
1509 var yaw = yawsplit.split(':');
1510
1511 $('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]);
1512 $('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]);
1513 });
1514 jQuery(document).ready(function ($) {
1515 $('.hotspot-customclass-pro-select').fontIconPicker();
1516 });
1517 jQuery(document).ready(function ($) {
1518 $('span.change-icon').hide();
1519 });
1520
1521 jQuery(document).ready(function ($) {
1522 var autrotateset = $("input[name='autorotation']").is(':checked') ? 'on' : 'off';
1523 if (autrotateset == 'off') {
1524 $('.autorotationdata-wrapper').hide();
1525 } else {
1526 $('.autorotationdata-wrapper').show();
1527 }
1528 });
1529
1530 $(document).on("change", "input[name='autorotation']", function (event) {
1531 var autrotateset = $(this).is(':checked') ? 'on' : 'off';
1532
1533 if (autrotateset == 'on') {
1534 $('.autorotationdata-wrapper').show();
1535 } else {
1536 $('.autorotationdata-wrapper').hide();
1537 }
1538 });
1539
1540
1541 $(document).on("change", ".ptyscene", function (event) {
1542 var ptyscene = $(this).val();
1543 if (ptyscene == 'off') {
1544 $(this).parent('.single-settings').siblings('.ptyscenedata').hide();
1545 } else {
1546 $(this).parent('.single-settings').siblings('.ptyscenedata').show();
1547 }
1548 });
1549
1550 $(document).on("change", ".cvgscene", function (event) {
1551 var cvgscene = $(this).val();
1552 if (cvgscene == 'off') {
1553 $(this).parent('.single-settings').siblings('.cvgscenedata').hide();
1554 } else {
1555 $(this).parent('.single-settings').siblings('.cvgscenedata').show();
1556 }
1557 });
1558
1559 $(document).on("change", ".chgscene", function (event) {
1560 var chgscenedata = $(this).val();
1561 if (chgscenedata == 'off') {
1562 $(this).parent('.single-settings').siblings('.chgscenedata').hide();
1563 } else {
1564 $(this).parent('.single-settings').siblings('.chgscenedata').show();
1565 }
1566 });
1567
1568 $(document).on("change", ".czscene", function (event) {
1569 var czscene = $(this).val();
1570 if (czscene == 'off') {
1571 $(this).parent('.single-settings').siblings('.czscenedata').hide();
1572 } else {
1573 $(this).parent('.single-settings').siblings('.czscenedata').show();
1574 }
1575 });
1576
1577 /**
1578 * Nasim
1579 * enable script button on chnage action
1580 */
1581 $("#wpvr_script_control").change(function () {
1582
1583 if ($('#wpvr_script_control').is(':checked')) {
1584
1585 $(".wpvr_enqueue_script_list").show();
1586
1587 } else {
1588
1589 $(".wpvr_enqueue_script_list").hide();
1590 }
1591
1592 });
1593
1594 /**
1595 * Sakib
1596 * enable script button on chnage action
1597 */
1598 $("#wpvr_video_script_control").change(function () {
1599
1600 if ($('#wpvr_video_script_control').is(':checked')) {
1601
1602 $(".wpvr_enqueue_video_script_list").show();
1603
1604 } else {
1605
1606 $(".wpvr_enqueue_video_script_list").hide();
1607 }
1608
1609 });
1610
1611
1612 /**
1613 * Nasim
1614 * Check enable script button is on or not
1615 * if on then script list field will be show and if off then script list field will be hide
1616 */
1617 if ($('#wpvr_script_control').is(':checked')) {
1618
1619 $(".wpvr_enqueue_script_list").show();
1620
1621 } else {
1622
1623 $(".wpvr_enqueue_script_list").hide();
1624 }
1625
1626 /**
1627 * Sakib
1628 * Check enable script button is on or not
1629 * if on then script list field will be show and if off then script list field will be hide
1630 */
1631 if ($('#wpvr_video_script_control').is(':checked')) {
1632
1633 $(".wpvr_enqueue_video_script_list").show();
1634
1635 } else {
1636
1637 $(".wpvr_enqueue_video_script_list").hide();
1638 }
1639
1640 /**
1641 * Hides the alert in the settings footer area after a 2000ms delay.
1642 *
1643 * @return {void} No return value
1644 */
1645 function remove_alert(){
1646 setTimeout(function(){
1647 $('.settings-footer-area .wpvr-alert').hide();
1648 }, 2000);
1649 }
1650
1651 $(document).on("click", "#wpvr_role_submit", function (e) {
1652 e.preventDefault();
1653 var ajaxurl = wpvr_obj.ajaxurl;
1654 $(this).children().css('display', 'inline-block');
1655
1656 $('#wpvr_role_submit').attr('disabled', true);
1657 var editor = $('#wpvr_editor_active').is(':checked');
1658 var author = $('#wpvr_author_active').is(':checked');
1659 var fontawesome = $('#wpvr_fontawesome_disable').is(':checked');
1660 var mobile_media_resize = $('#mobile_media_resize').is(':checked');
1661 var wpvr_frontend_notice = $('#wpvr_frontend_notice').is(':checked');
1662 var wpvr_frontend_notice_area = $('#wpvr_frontend_notice_area').val();
1663 var wpvr_script_control = $('#wpvr_script_control').is(':checked');
1664 var wpvr_script_list = $('#wpvr_script_list').val();
1665 var wpvr_video_script_control = $('#wpvr_video_script_control').is(':checked');
1666 var wpvr_video_script_list = $('#wpvr_video_script_list').val();
1667 var high_res_image = $('#high_res_image').is(':checked');
1668 var dis_on_hover = $('#dis_on_hover').is(':checked');
1669
1670 /**
1671 * check enable script button is on and script list field is not empty
1672 */
1673 if ( ($('#wpvr_video_script_control').is(':checked') && wpvr_video_script_list == '') || ($('#wpvr_script_control').is(':checked') && wpvr_script_list == '') ) {
1674 if(($('#wpvr_script_control').is(':checked') && wpvr_script_list == '')){
1675 if (confirm('The "List of Allowed Pages To Load WP VR Scripts " Field Is Empty. No Virtual Tours Will Show Up on Your Site.')) {
1676 if($('#wpvr_video_script_control').is(':checked') && wpvr_video_script_list == ''){
1677 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.")) {
1678 jQuery.ajax({
1679 type: "POST",
1680 url: ajaxurl,
1681 data: {
1682 action: "wpvr_role_management",
1683 nonce : wpvr_obj.ajax_nonce,
1684 editor: editor,
1685 author: author,
1686 fontawesome: fontawesome,
1687 mobile_media_resize: mobile_media_resize,
1688 high_res_image: high_res_image,
1689 dis_on_hover: dis_on_hover,
1690 wpvr_frontend_notice: wpvr_frontend_notice,
1691 wpvr_frontend_notice_area: wpvr_frontend_notice_area,
1692 wpvr_script_control: wpvr_script_control,
1693 wpvr_script_list: wpvr_script_list,
1694 wpvr_video_script_control: wpvr_video_script_control,
1695 wpvr_video_script_list: wpvr_video_script_list,
1696 // woocommerce: woocommerce,
1697 },
1698 success: function (response) {
1699 $('#wpvr_role_submit .wpvr-loader').css('display', 'none');
1700 $('#wpvr_role_submit').attr('disabled', false);
1701
1702 if (response.status == 'success') {
1703 $('.settings-footer-area .wpvr-alert').text(response.message).show();
1704 }
1705
1706 remove_alert();
1707
1708 }
1709 });
1710 } else {
1711 $('#wpvr_role_submit .wpvr-loader').css('display', 'none');
1712 $('#wpvr_role_submit').attr('disabled', false);
1713 }
1714 }else{
1715 jQuery.ajax({
1716 type: "POST",
1717 url: ajaxurl,
1718 data: {
1719 action: "wpvr_role_management",
1720 nonce : wpvr_obj.ajax_nonce,
1721 editor: editor,
1722 author: author,
1723 fontawesome: fontawesome,
1724 mobile_media_resize: mobile_media_resize,
1725 high_res_image: high_res_image,
1726 wpvr_frontend_notice: wpvr_frontend_notice,
1727 wpvr_frontend_notice_area: wpvr_frontend_notice_area,
1728 wpvr_script_control: wpvr_script_control,
1729 wpvr_script_list: wpvr_script_list,
1730 wpvr_video_script_control: wpvr_video_script_control,
1731 wpvr_video_script_list: wpvr_video_script_list,
1732 // woocommerce: woocommerce,
1733 },
1734 success: function (response) {
1735 $('#wpvr_role_submit .wpvr-loader').css('display', 'none');
1736 $('#wpvr_role_submit').attr('disabled', false);
1737
1738 if (response.status == 'success') {
1739 $('.settings-footer-area .wpvr-alert').text(response.message).show();
1740 }
1741
1742 remove_alert();
1743
1744 }
1745 });
1746 }
1747 } else {
1748 $('#wpvr_role_submit .wpvr-loader').css('display', 'none');
1749 $('#wpvr_role_submit').attr('disabled', false);
1750 }
1751 }else if($('#wpvr_video_script_control').is(':checked') && wpvr_video_script_list == ''){
1752
1753 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.")) {
1754 if(($('#wpvr_script_control').is(':checked') && wpvr_script_list == '')){
1755 if (confirm('The "List of Allowed Pages To Load WP VR Scripts " Field Is Empty. No Virtual Tours Will Show Up on Your Site.')) {
1756 jQuery.ajax({
1757 type: "POST",
1758 url: ajaxurl,
1759 data: {
1760 action: "wpvr_role_management",
1761 nonce : wpvr_obj.ajax_nonce,
1762 editor: editor,
1763 author: author,
1764 fontawesome: fontawesome,
1765 mobile_media_resize: mobile_media_resize,
1766 high_res_image: high_res_image,
1767 dis_on_hover: dis_on_hover,
1768 wpvr_frontend_notice: wpvr_frontend_notice,
1769 wpvr_frontend_notice_area: wpvr_frontend_notice_area,
1770 wpvr_script_control: wpvr_script_control,
1771 wpvr_script_list: wpvr_script_list,
1772 wpvr_video_script_control: wpvr_video_script_control,
1773 wpvr_video_script_list: wpvr_video_script_list,
1774 // woocommerce: woocommerce,
1775 },
1776 success: function (response) {
1777 $('#wpvr_role_submit .wpvr-loader').css('display', 'none');
1778 $('#wpvr_role_submit').attr('disabled', false);
1779
1780 if (response.status == 'success') {
1781 $('.settings-footer-area .wpvr-alert').text(response.message).show();
1782 }
1783 remove_alert();
1784
1785 }
1786 });
1787 }else {
1788 $('#wpvr_role_submit .wpvr-loader').css('display', 'none');
1789 $('#wpvr_role_submit').attr('disabled', false);
1790 }
1791 }else{
1792 jQuery.ajax({
1793 type: "POST",
1794 url: ajaxurl,
1795 data: {
1796 action: "wpvr_role_management",
1797 nonce : wpvr_obj.ajax_nonce,
1798 editor: editor,
1799 author: author,
1800 fontawesome: fontawesome,
1801 mobile_media_resize: mobile_media_resize,
1802 high_res_image: high_res_image,
1803 dis_on_hover: dis_on_hover,
1804 wpvr_frontend_notice: wpvr_frontend_notice,
1805 wpvr_frontend_notice_area: wpvr_frontend_notice_area,
1806 wpvr_script_control: wpvr_script_control,
1807 wpvr_script_list: wpvr_script_list,
1808 wpvr_video_script_control: wpvr_video_script_control,
1809 wpvr_video_script_list: wpvr_video_script_list,
1810 // woocommerce: woocommerce,
1811 },
1812 success: function (response) {
1813 $('#wpvr_role_submit .wpvr-loader').css('display', 'none');
1814 $('#wpvr_role_submit').attr('disabled', false);
1815
1816 if (response.status == 'success') {
1817 $('.settings-footer-area .wpvr-alert').text(response.message).show();
1818 }
1819
1820 remove_alert();
1821
1822 }
1823 });
1824 }
1825 } else {
1826 $('#wpvr_role_submit .wpvr-loader').css('display', 'none');
1827 $('#wpvr_role_submit').attr('disabled', false);
1828 }
1829 }
1830
1831 } else {
1832 jQuery.ajax({
1833 type: "POST",
1834 url: ajaxurl,
1835 data: {
1836 action: "wpvr_role_management",
1837 nonce : wpvr_obj.ajax_nonce,
1838 editor: editor,
1839 author: author,
1840 fontawesome: fontawesome,
1841 mobile_media_resize: mobile_media_resize,
1842 high_res_image: high_res_image,
1843 dis_on_hover: dis_on_hover,
1844 wpvr_frontend_notice: wpvr_frontend_notice,
1845 wpvr_frontend_notice_area: wpvr_frontend_notice_area,
1846 wpvr_script_control: wpvr_script_control,
1847 wpvr_script_list: wpvr_script_list,
1848 wpvr_video_script_control: wpvr_video_script_control,
1849 wpvr_video_script_list: wpvr_video_script_list,
1850 },
1851 success: function (response) {
1852 $('#wpvr_role_submit .wpvr-loader').css('display', 'none');
1853 $('#wpvr_role_submit').attr('disabled', false);
1854 if (response.status == 'success') {
1855 $('.settings-footer-area .wpvr-alert').text(response.message).show();
1856 }
1857
1858 remove_alert();
1859 }
1860 });
1861 }
1862
1863
1864
1865 });
1866
1867
1868 //-----------reset button----------
1869 $(document).on("click", "#wpvr_role_reset", function (e) {
1870 e.preventDefault();
1871 $(this).attr('disabled', true);
1872
1873 var confirmation = confirm('All settings will be reset to default. Are you sure?');
1874 // Code to reset settings to default if the user clicks "Yes"
1875 if (confirmation) {
1876 $('#wpvr_editor_active').prop('checked', false);
1877 $('#wpvr_author_active').prop('checked', false);
1878 $('#wpvr_fontawesome_disable').prop('checked', false);
1879 $('#mobile_media_resize').prop('checked', false);
1880 $('#wpvr_frontend_notice').prop('checked', false);
1881 $('#wpvr_script_control').prop('checked', false);
1882 $('#wpvr_video_script_control').prop('checked', false);
1883 $('#high_res_image').prop('checked', false);
1884 $('#dis_on_hover').prop('checked', false);
1885 $(".wpvr_enqueue_video_script_list").hide();
1886 $(".wpvr_enqueue_script_list").hide();
1887
1888 $("#wpvr_role_submit").trigger('click');
1889 }
1890 $(this).attr('disabled', false);
1891
1892 });
1893
1894 //------general tab's inner tab-------
1895 jQuery(document).ready(function ($) {
1896
1897 $('.general-inner-tab .inner-nav li span').on('click', function () {
1898 var this_id = $(this).attr('data-href');
1899
1900 $(this).parent('li').addClass('active');
1901 $(this).parent('li').siblings().removeClass('active');
1902
1903 $(this_id).show();
1904 $(this_id).siblings().hide();
1905 });
1906 });
1907
1908 //------active tab scripts-------
1909 jQuery(document).ready(function ($) {
1910
1911 function getUrlVars() {
1912 var vars = [],
1913 hash;
1914 var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
1915 for (var i = 0; i < hashes.length; i++) {
1916 hash = hashes[i].split('=');
1917 vars.push(hash[0]);
1918 vars[hash[0]] = hash[1];
1919 }
1920 return vars;
1921 }
1922 var activeTab = 'general',
1923 vr_main_tab = $('#wpvr-main-nav'),
1924 var_main_tab_contents = $('#wpvr-main-tab-contents').find('.rex-pano-tab').not(".single-scene,.single-hotspot"),
1925 scene_content = $('.scene-content'),
1926 scene_nav = $('.scene-nav'),
1927 single_scene = $('.single-scene'),
1928 hotspot_content = $('.hotspot-setup'),
1929 single_hotspot = $('.single-hotspot'),
1930 delete_scene_btn = $('.delete-scene'),
1931 delete_hotspot_btn = $('.delete-hotspot');
1932
1933 var _q_activeTab = getUrlVars()["active_tab"];
1934 var _sceneID = getUrlVars()["scene"];
1935 var _hotspotID = getUrlVars()["hotspot"];
1936 var default_tabs = ['general', 'scene', 'hotspot', 'video'];
1937 if (_q_activeTab) {
1938 if (default_tabs.includes(_q_activeTab)) {
1939 activeTab = _q_activeTab;
1940 if(activeTab == "video" ){
1941 vr_main_tab.find('li:not(:first)').removeClass('active');
1942 vr_main_tab.find(".videos").addClass('active');
1943 }else{
1944 vr_main_tab.find('li:not(:first)').removeClass('active');
1945 vr_main_tab.find('.' + activeTab).addClass('active');
1946 }
1947
1948 // scene screens
1949 var_main_tab_contents.addClass('active');
1950 if (activeTab === 'scene' || activeTab === 'hotspot') {
1951 var_main_tab_contents.not('#scenes').removeClass('active');
1952 } else {
1953 var_main_tab_contents.not('#' + activeTab).removeClass('active');
1954 }
1955 if(activeTab === 'hotspot'){
1956 $(".rex-pano-nav-menu.main-nav ul li.hotspot span").trigger('click')
1957 }
1958
1959 // scene contents
1960 if (_sceneID) {
1961 var scenesIds = [];
1962 var sceneID = '#scene-' + _sceneID;
1963 var scene_nav_items = scene_nav.find('li');
1964 scene_nav.find('li').each(function () {
1965 var index = $(this).find('span').attr('data-index');
1966 if (index) {
1967 scenesIds.push(index);
1968 }
1969 });
1970 if (scenesIds.includes(_sceneID)) {
1971 scene_nav_items.removeClass('active');
1972 scene_nav.find('li').each(function () {
1973 var index = $(this).find('span').attr('data-index');
1974 if (_sceneID == index) {
1975 $(this).addClass('active');
1976 }
1977 });
1978 if (activeTab == 'scene' || _sceneID) {
1979 single_scene.removeClass('active');
1980 $(sceneID).addClass('active');
1981 }
1982 } else {
1983 scene_nav.find('li:first').addClass('active');
1984 }
1985
1986 if (activeTab === 'scene') {
1987 if (scenesIds.includes(_sceneID)) {
1988 $(single_scene).removeClass('active');
1989 $(sceneID).addClass('active');
1990 }
1991 } else {
1992 $(delete_scene_btn).hide();
1993 $(scene_nav).hide();
1994 $('.scene-content').hide();
1995 $(sceneID).find('.hotspot-setup').show();
1996 }
1997
1998 //hotspot contents
1999 var hotspot_nav = $('.single-scene.active').find('.hotspot-nav');
2000 var hotspotIds = [];
2001 var hotspot_nav_items = $('.single-scene.active').find('.hotspot-nav').find('li');
2002 var activeHotspotId = '#scene-' + _sceneID + 'hotspot-' + _hotspotID;
2003 hotspot_nav_items.each(function () {
2004 var index = $(this).find('span').attr('data-index');
2005 if (index) {
2006 hotspotIds.push(index);
2007 activeHotspotId = $(this).find('span').attr('data-href');
2008 }
2009 });
2010 if (hotspotIds.includes(_hotspotID)) {
2011 hotspot_nav_items.removeClass('active');
2012 hotspot_nav.find('li').each(function () {
2013 var index = $(this).find('span').attr('data-index');
2014 if (_hotspotID === index) {
2015 $(this).addClass('active');
2016 }
2017 });
2018 if (activeHotspotId) {
2019 $(sceneID).find('.single-hotspot').removeClass('active');
2020 $(activeHotspotId).addClass('active');
2021 }
2022 }
2023 }
2024 }
2025 }
2026
2027
2028 $(document).on("click", ".wpvr-help-resource__video-section", function () {
2029 $('#wpvr-help-video-iframe').attr('src', 'https://www.youtube.com/embed/kKHUlVKtesQ');
2030 if($('#wpvr-help-video-iframe').attr('src') != ''){
2031 $(".wpvr-iframe-modal").show();
2032 }
2033 });
2034
2035
2036 $(document).on("click", ".wpvr-iframe-modal__cross-icon", function () {
2037 $(".wpvr-iframe-modal").hide();
2038 var videoPlayer =$('#wpvr-help-video-iframe');
2039 videoPlayer.attr('src', '');
2040
2041 });
2042
2043
2044
2045 });
2046
2047 $(document).on("click", ".wpvr_url_open", function (event) {
2048 if ($(this).val() == 'off') {
2049 $(this).val('on');
2050 }
2051 else {
2052 $(this).val('off');
2053 }
2054 });
2055
2056 $(document).ready(function() {
2057 $('textarea[name*=hotspot-content]').summernote({
2058 toolbar: [
2059 ['style', ['style']],
2060 ['font', ['bold', 'underline', 'clear']],
2061 ['fontname', ['fontname']],
2062 ['color', ['color']],
2063 ['para', ['ul', 'ol', 'paragraph']],
2064 ['table', ['table']],
2065 ['insert', ['link', 'picture', 'video']],
2066 ['view', ['codeview', 'help']],
2067 ],
2068 callbacks: {
2069 onKeyup: function(e) {
2070 var getHotspotContent = $(this).val();
2071 var getParent = $(this).parent();
2072 var getMainParent = getParent.parent()
2073 var getClickContent = getMainParent.find('.hotspot-url')
2074 if(getHotspotContent.length > 0){
2075 getClickContent.find('input[name*=hotspot-url').val('')
2076 getClickContent.find('input[name*=hotspot-url').attr('placeholder','You can set either a URL or an On-click content')
2077 getClickContent.find('input[name*=hotspot-url]').attr("disabled",true)
2078 }else{
2079 getClickContent.find('input[name*=hotspot-url]').attr("disabled",false)
2080 }
2081 }
2082 }
2083 });
2084 $('textarea[name*=hotspot-hover]').summernote({
2085 toolbar: [
2086 ['style', ['style']],
2087 ['font', ['bold', 'underline', 'clear']],
2088 ['fontname', ['fontname']],
2089 ['color', ['color']],
2090 ['para', ['ul', 'ol', 'paragraph']],
2091 ['table', ['table']],
2092 ['insert', ['link', 'picture', 'video']],
2093 ['view', ['codeview', 'help']],
2094 ],
2095 });
2096 });
2097
2098 $(document).on("submit", "#trigger-rollback", function (event) {
2099 event.preventDefault();
2100 if(confirm('Are you sure?')) {
2101 let version = $("#trigger-rollback").serialize();
2102 let redirectUrl = wpvr_global_obj.url_info.admin_url + 'admin.php?' + version;
2103 window.location.href = redirectUrl;
2104 }
2105 });
2106
2107 // $(document).on('click','.rex-import-disable',function(){
2108 // setTimeout(function(){
2109 // $('.pano-alert .pano-error-message').html('<span class="pano-error-title">Import Tour</span><p> To import a VR tour, you\'ll need to upgrade to WP VR Pro from the free version you\'re currently using.</p>');
2110 // $('body').addClass('error-overlay2');
2111 // $('.pano-alert').addClass('pano-default-warning').show();
2112 // }, 500 );
2113 // });
2114
2115
2116 $(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) {
2117 event.preventDefault();
2118 $("#wpvr_premium_feature_popup").show();
2119 });
2120
2121
2122
2123 $(document).on("click", "#wpvr_premium_feature_close", function () {
2124 $("#wpvr_premium_feature_popup").hide();
2125 });
2126
2127
2128 $(document).on("click", ".wpvr-help-resource__dropdown-section", function () {
2129 // When an element with the class 'wpvr-help-resource__dropdown-section' is clicked,
2130 // toggle the 'show-dropdown' class on its siblings.
2131 $(this).siblings().toggleClass("show-dropdown");
2132 });
2133 $(document).on("click", ".wpvr-layout__radio-container", function () {
2134 let findLayout = $(this).find('.wpvr-layout__radio-label').data('layout');
2135 if(findLayout == 'layout1'){
2136 event.preventDefault();
2137 $('#wpvr_premium_feature_popup').show();
2138 }
2139 });
2140
2141 // ------window on scroll add class to comparison table header------
2142 $(window).on('scroll', function() {
2143 var $header = $('.wpvr-compare .list-header');
2144
2145 if ($header.length > 0) {
2146 var headerOffset = $header.offset().top - $(window).scrollTop();
2147
2148 if (headerOffset < 27) {
2149 $header.addClass('sticked');
2150 } else {
2151 $header.removeClass('sticked');
2152 }
2153
2154 }
2155
2156 });
2157
2158
2159 })(jQuery);
2160