| 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 |
|
| 657 |
function wpvrhotspot(hotSpotDiv, args) { |
| 658 |
if (args) { |
| 659 |
const hasTextContent = args.replace(/<[^>]*>/g, '').trim() !== ''; |
| 660 |
const hasMediaContent = /<(img|video|audio|iframe|embed|object)\b[^>]*>/i.test(args); |
| 661 |
const hasOtherContent = args.replace(/<(p|br|div|span)\b[^>]*\/?>/gi, '').trim() !== ''; |
| 662 |
|
| 663 |
if (hasTextContent || hasMediaContent || hasOtherContent) { |
| 664 |
const cleanArgs = args.replace(/\\/g, ''); |
| 665 |
$("#custom-ifram").html(cleanArgs); |
| 666 |
$("#custom-ifram").fadeToggle(); |
| 667 |
$(".iframe-wrapper").toggleClass("show-modal"); |
| 668 |
} |
| 669 |
} |
| 670 |
} |
| 671 |
|
| 672 |
function wpvrtooltip(hotSpotDiv, args) { |
| 673 |
if (args) { |
| 674 |
const hasTextContent = args.replace(/<[^>]*>/g, '').trim() !== ''; |
| 675 |
const hasMediaContent = /<(img|video|audio|iframe|embed|object)\b[^>]*>/i.test(args); |
| 676 |
const hasOtherContent = args.replace(/<(p|br|div|span)\b[^>]*\/?>/gi, '').trim() !== ''; |
| 677 |
|
| 678 |
if (hasTextContent || hasMediaContent || hasOtherContent) { |
| 679 |
const cleanArgs = args.replace(/\\/g, ''); |
| 680 |
hotSpotDiv.classList.add('custom-tooltip'); |
| 681 |
|
| 682 |
const span = document.createElement('p'); |
| 683 |
span.innerHTML = cleanArgs; |
| 684 |
hotSpotDiv.appendChild(span); |
| 685 |
|
| 686 |
span.style.marginLeft = -(span.scrollWidth - hotSpotDiv.offsetWidth) / 2 + 'px'; |
| 687 |
span.style.marginTop = -span.scrollHeight - 12 + 'px'; |
| 688 |
|
| 689 |
if (!document.getElementById('wpvr-tooltip-style')) { |
| 690 |
const style = document.createElement('style'); |
| 691 |
style.id = 'wpvr-tooltip-style'; |
| 692 |
style.textContent = ` |
| 693 |
.table, .table td, .table th { |
| 694 |
border: 1px solid #dee2e6; |
| 695 |
border-collapse: collapse; |
| 696 |
padding: 8px; |
| 697 |
} |
| 698 |
`; |
| 699 |
document.head.appendChild(style); |
| 700 |
} |
| 701 |
} |
| 702 |
} |
| 703 |
} |
| 704 |
|
| 705 |
|
| 706 |
jQuery(document).ready(function ($) { |
| 707 |
$("#cross").on("click", function (e) { |
| 708 |
e.preventDefault(); |
| 709 |
$("#custom-ifram").fadeOut(); |
| 710 |
$(".iframe-wrapper").removeClass("show-modal"); |
| 711 |
$('iframe').attr('src', $('iframe').attr('src')); |
| 712 |
}); |
| 713 |
}); |
| 714 |
|
| 715 |
jQuery(document).ready(function ($) { |
| 716 |
|
| 717 |
var i = $('.scene-nav li').eq(-2).find('span').attr('data-index'); |
| 718 |
i = parseInt(i); |
| 719 |
|
| 720 |
$('.scene-setup').repeater({ |
| 721 |
|
| 722 |
defaultValues: { |
| 723 |
'scene-type': 'equirectangular', |
| 724 |
'dscene': 'off', |
| 725 |
'ptyscene': 'off', |
| 726 |
'cvgscene': 'off', |
| 727 |
'chgscene': 'off', |
| 728 |
'czscene': 'off', |
| 729 |
}, |
| 730 |
show: function () { |
| 731 |
$('textarea[name*=hotspot-content]').summernote({ |
| 732 |
toolbar: [ |
| 733 |
['style', ['style']], |
| 734 |
['font', ['bold', 'underline', 'clear']], |
| 735 |
['fontname', ['fontname']], |
| 736 |
['color', ['color']], |
| 737 |
['para', ['ul', 'ol', 'paragraph']], |
| 738 |
['table', ['table']], |
| 739 |
['insert', ['link', 'picture', 'video']], |
| 740 |
['view', ['codeview', 'help']], |
| 741 |
], |
| 742 |
callbacks: { |
| 743 |
onKeyup: function(e) { |
| 744 |
var getHotspotContent = $(this).summernote('code').trim(); |
| 745 |
var tempDiv = document.createElement('div'); |
| 746 |
tempDiv.innerHTML = getHotspotContent; |
| 747 |
var plainText = tempDiv.textContent || tempDiv.innerText || ''; |
| 748 |
plainText = plainText.replace(/\u00a0/g, '').trim(); |
| 749 |
var getParent = $(this).parent(); |
| 750 |
var getMainParent = getParent.parent(); |
| 751 |
var getClickContent = getMainParent.find('.hotspot-url'); |
| 752 |
|
| 753 |
if (plainText.length > 0) { |
| 754 |
getClickContent.find('input[name*=hotspot-url]').val(''); |
| 755 |
getClickContent.find('input[name*=hotspot-url]').attr('placeholder', 'You can set either a URL or an On-click content'); |
| 756 |
getClickContent.find('input[name*=hotspot-url]').attr("disabled", true); |
| 757 |
} else { |
| 758 |
getClickContent.find('input[name*=hotspot-url]').attr("disabled", false); |
| 759 |
} |
| 760 |
} |
| 761 |
} |
| 762 |
}); |
| 763 |
$('textarea[name*=hotspot-hover]').summernote({ |
| 764 |
toolbar: [ |
| 765 |
['style', ['style']], |
| 766 |
['font', ['bold', 'underline', 'clear']], |
| 767 |
['fontname', ['fontname']], |
| 768 |
['color', ['color']], |
| 769 |
['para', ['ul', 'ol', 'paragraph']], |
| 770 |
['table', ['table']], |
| 771 |
['insert', ['link', 'picture', 'video']], |
| 772 |
['view', ['codeview', 'help']], |
| 773 |
], |
| 774 |
fontNames: ['Arial', 'Helvetica', 'Tahoma', 'Courier New', 'Verdana', 'Impact', 'Times New Roman', 'system-ui', 'Helvetica Neue'], |
| 775 |
callbacks: { |
| 776 |
onInit: function() { |
| 777 |
var $editor = $(this); |
| 778 |
|
| 779 |
// Override font name dropdown click handler for this specific editor |
| 780 |
$editor.next('.note-editor').find('.dropdown-fontname a').off('click').on('click', function(e) { |
| 781 |
e.preventDefault(); |
| 782 |
var fontName = $(this).data('value') || $(this).text(); |
| 783 |
|
| 784 |
// Focus on the current editor |
| 785 |
$editor.summernote('focus'); |
| 786 |
|
| 787 |
// Use Summernote's built-in method to apply font |
| 788 |
try { |
| 789 |
// First, clear any existing font formatting |
| 790 |
var range = $editor.summernote('createRange'); |
| 791 |
if (range && !range.isCollapsed()) { |
| 792 |
// Get selected text |
| 793 |
var selectedText = range.toString(); |
| 794 |
|
| 795 |
// Use Summernote's insertHTML to replace content |
| 796 |
var fontHtml = '<span style="font-family: ' + fontName + ';">' + selectedText + '</span>'; |
| 797 |
$editor.summernote('insertHTML', fontHtml); |
| 798 |
} else { |
| 799 |
// No selection, use execCommand for typing |
| 800 |
$editor.summernote('focus'); |
| 801 |
document.execCommand('fontName', false, fontName); |
| 802 |
} |
| 803 |
} catch (error) { |
| 804 |
console.log('Font application error, using fallback method'); |
| 805 |
// Fallback method |
| 806 |
document.execCommand('fontName', false, fontName); |
| 807 |
} |
| 808 |
|
| 809 |
// Update dropdown button text for this editor |
| 810 |
$(this).closest('.note-editor').find('.note-current-fontname').text(fontName); |
| 811 |
|
| 812 |
// Close dropdown |
| 813 |
var $dropdownMenu = $(this).closest('.dropdown-menu'); |
| 814 |
$dropdownMenu.removeClass('show').hide(); |
| 815 |
$dropdownMenu.prev('.dropdown-toggle').removeClass('show').attr('aria-expanded', 'false'); |
| 816 |
|
| 817 |
// Trigger change event |
| 818 |
setTimeout(function() { |
| 819 |
$editor.trigger('summernote.change'); |
| 820 |
}, 100); |
| 821 |
}); |
| 822 |
}, |
| 823 |
|
| 824 |
// Clean up the content after any change |
| 825 |
onChange: function(contents, $editable) { |
| 826 |
// Debounce the cleanup to avoid conflicts |
| 827 |
clearTimeout(this.cleanupTimeout); |
| 828 |
this.cleanupTimeout = setTimeout(function() { |
| 829 |
// Remove all font-family styles from elements that shouldn't have them |
| 830 |
$editable.find('*:not(span)').each(function() { |
| 831 |
if (this.style && this.style.fontFamily) { |
| 832 |
this.style.fontFamily = ''; |
| 833 |
} |
| 834 |
}); |
| 835 |
|
| 836 |
// Clean up empty spans |
| 837 |
$editable.find('span').each(function() { |
| 838 |
var $span = $(this); |
| 839 |
var text = $span.text().replace(/[\uFEFF\u200B-\u200D\u2060]/g, '').trim(); |
| 840 |
|
| 841 |
if (!text) { |
| 842 |
$span.remove(); |
| 843 |
} else { |
| 844 |
// If span has other styles besides font-family, keep only font-family |
| 845 |
var fontFamily = $span.css('font-family'); |
| 846 |
if (fontFamily && fontFamily !== 'inherit') { |
| 847 |
$span.attr('style', 'font-family: ' + fontFamily + ';'); |
| 848 |
} else if (!fontFamily || fontFamily === 'inherit') { |
| 849 |
$span.contents().unwrap(); |
| 850 |
} |
| 851 |
} |
| 852 |
}); |
| 853 |
|
| 854 |
// Remove nested spans with font-family |
| 855 |
$editable.find('span[style*="font-family"] span[style*="font-family"]').each(function() { |
| 856 |
$(this).contents().unwrap(); |
| 857 |
}); |
| 858 |
}, 200); |
| 859 |
} |
| 860 |
} |
| 861 |
}); |
| 862 |
if ($(this).parents(".scene-setup").attr("data-limit").length > 0) { |
| 863 |
lastChildClicked = true; |
| 864 |
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")) { |
| 865 |
|
| 866 |
$(this).slideDown(); |
| 867 |
$(this).removeClass('active'); |
| 868 |
|
| 869 |
i = i + 1; |
| 870 |
var scene = 'scene-' + i; |
| 871 |
|
| 872 |
$(this).find(".title .scene-num").html(i); |
| 873 |
|
| 874 |
$('<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')); |
| 875 |
|
| 876 |
$(this).attr('id', scene); |
| 877 |
changehotspotid(i); |
| 878 |
$(this).siblings('.active').removeClass('active'); |
| 879 |
$(this).addClass('active'); |
| 880 |
$(this).find(".sceneid").val(generateRandomString(8)); |
| 881 |
setTimeout(changeicon, 1000); |
| 882 |
} else { |
| 883 |
$('.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>'); |
| 884 |
$('body').addClass('error-overlay2'); |
| 885 |
$('.pano-alert').addClass('pano-default-warning').show(); |
| 886 |
$(this).remove(); |
| 887 |
} |
| 888 |
} else { |
| 889 |
jQuery(this).slideDown(); |
| 890 |
$(this).removeClass('active'); |
| 891 |
|
| 892 |
i = i + 1; |
| 893 |
var scene = 'scene-' + i; |
| 894 |
$(this).find(".title .scene-num").html(i); |
| 895 |
$('<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')); |
| 896 |
$(this).attr('id', scene); |
| 897 |
changehotspotid(i); |
| 898 |
} |
| 899 |
|
| 900 |
$(this).hide(); |
| 901 |
|
| 902 |
//tab active setup |
| 903 |
$('#wpvr_active_scenes').val(i); |
| 904 |
$('#wpvr_active_hotspot').val(1); |
| 905 |
}, |
| 906 |
hide: function (deleteElement) { |
| 907 |
var hide_id = $(this).attr("id"); |
| 908 |
var _hide_id = hide_id.split('-').pop(); |
| 909 |
hide_id = "#" + hide_id; |
| 910 |
|
| 911 |
var current = $(this).attr('id'); |
| 912 |
var fchild = $('.single-scene:nth-child(2)').attr('id'); |
| 913 |
// var fchild = $(this).parent().children(":first").attr('id'); |
| 914 |
|
| 915 |
|
| 916 |
var elementcontains = $(this).attr("id"); |
| 917 |
var str1 = 'scene'; |
| 918 |
var str2 = 'hotspot'; |
| 919 |
if (elementcontains.indexOf(str1) != -1 && elementcontains.indexOf(str2) == -1) { |
| 920 |
|
| 921 |
var _this = $(this); |
| 922 |
|
| 923 |
if (confirm('Are you sure you want to delete?')) { |
| 924 |
jQuery(_this).slideUp(deleteElement); |
| 925 |
if (current == fchild) { |
| 926 |
$(_this).next().addClass("active"); |
| 927 |
$(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").next().addClass("active"); |
| 928 |
$(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").next().children("span").trigger("click"); |
| 929 |
} else { |
| 930 |
$(_this).prev().addClass("active"); |
| 931 |
$(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").prev().addClass("active"); |
| 932 |
$(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").prev().children("span").trigger("click"); |
| 933 |
} |
| 934 |
$(_this).parent().parent('.scene-setup').find('.scene-nav li span[data-href="' + hide_id + '"]').parent("li").remove(); |
| 935 |
setTimeout(deleteinfodata, 1000); |
| 936 |
|
| 937 |
//tab active setup |
| 938 |
if (parseInt(_hide_id) - 1 > 0) { |
| 939 |
$('#wpvr_active_scenes').val(parseInt(_hide_id) - 1); |
| 940 |
} else { |
| 941 |
$('#wpvr_active_scenes').val(1); |
| 942 |
} |
| 943 |
$('#wpvr_active_hotspot').val(1); |
| 944 |
|
| 945 |
|
| 946 |
setTimeout(function(){ |
| 947 |
let sceneImageCount = $('.rex-pano-tab .single-scene .scene-left .scene-setting .form-group img') |
| 948 |
.filter(function() { |
| 949 |
return $(this).attr('src') && $(this).attr('src').trim() !== ''; |
| 950 |
}) |
| 951 |
.length; |
| 952 |
|
| 953 |
let defaultScene = false; |
| 954 |
let hotspotCheck = false; |
| 955 |
|
| 956 |
let $sceneCheckbox = $('#wpvr-check-scene'); |
| 957 |
let $mediaCheckbox = $('#wpvr-check-media'); |
| 958 |
let $hotspotCheck = $('#wpvr-check-hotspots'); |
| 959 |
let $defaultCheck = $('#wpvr-check-default'); |
| 960 |
|
| 961 |
$('select').each(function() { |
| 962 |
if (/^scene-list\[\d+\]\[dscene\]$/.test($(this).attr('name'))) { |
| 963 |
let selectedValue = $(this).val(); |
| 964 |
if('on' === selectedValue){ |
| 965 |
defaultScene = true; |
| 966 |
} |
| 967 |
} |
| 968 |
}); |
| 969 |
|
| 970 |
if (sceneImageCount === 0) { |
| 971 |
$sceneCheckbox.prop('checked', false); |
| 972 |
$mediaCheckbox.prop('checked', false); |
| 973 |
$sceneCheckbox.closest('.wpvr-checklist-item').css('color', '#73707D'); |
| 974 |
$mediaCheckbox.closest('.wpvr-checklist-item').css('color', '#73707D'); |
| 975 |
} |
| 976 |
|
| 977 |
if(!defaultScene){ |
| 978 |
$defaultCheck.prop('checked', false); |
| 979 |
$defaultCheck.closest('.wpvr-checklist-item').css('color', '#73707D'); |
| 980 |
} |
| 981 |
|
| 982 |
let pitchInputs = document.querySelectorAll('.hotspot-pitch'); |
| 983 |
for (let pitchInput of pitchInputs) { |
| 984 |
if (pitchInput.value.trim() !== '') { |
| 985 |
hotspotCheck = true; |
| 986 |
} |
| 987 |
} |
| 988 |
|
| 989 |
if(!hotspotCheck) |
| 990 |
{ |
| 991 |
$hotspotCheck.prop('checked', false); |
| 992 |
$hotspotCheck.closest('.wpvr-checklist-item').css('color', '#73707D'); |
| 993 |
} |
| 994 |
updateProgress(); |
| 995 |
}, 500); |
| 996 |
} |
| 997 |
|
| 998 |
} |
| 999 |
}, |
| 1000 |
repeaters: [{ |
| 1001 |
selector: '.hotspot-setup', |
| 1002 |
defaultValues: { |
| 1003 |
'hotspot-type': 'info', |
| 1004 |
'hotspot-customclass-pro': 'none', |
| 1005 |
}, |
| 1006 |
show: function () { |
| 1007 |
$('textarea[name*=hotspot-content]').summernote({ |
| 1008 |
toolbar: [ |
| 1009 |
['style', ['style']], |
| 1010 |
['font', ['bold', 'underline', 'clear']], |
| 1011 |
['fontname', ['fontname']], |
| 1012 |
['color', ['color']], |
| 1013 |
['para', ['ul', 'ol', 'paragraph']], |
| 1014 |
['table', ['table']], |
| 1015 |
['insert', ['link', 'picture', 'video']], |
| 1016 |
['view', ['codeview', 'help']], |
| 1017 |
], |
| 1018 |
callbacks: { |
| 1019 |
onKeyup: function(e) { |
| 1020 |
var getHotspotContent = $(this).summernote('code').trim(); |
| 1021 |
var tempDiv = document.createElement('div'); |
| 1022 |
tempDiv.innerHTML = getHotspotContent; |
| 1023 |
var plainText = tempDiv.textContent || tempDiv.innerText || ''; |
| 1024 |
plainText = plainText.replace(/\u00a0/g, '').trim(); |
| 1025 |
var getParent = $(this).parent(); |
| 1026 |
var getMainParent = getParent.parent(); |
| 1027 |
var getClickContent = getMainParent.find('.hotspot-url'); |
| 1028 |
|
| 1029 |
if (plainText.length > 0) { |
| 1030 |
getClickContent.find('input[name*=hotspot-url]').val(''); |
| 1031 |
getClickContent.find('input[name*=hotspot-url]').attr('placeholder', 'You can set either a URL or an On-click content'); |
| 1032 |
getClickContent.find('input[name*=hotspot-url]').attr("disabled", true); |
| 1033 |
} else { |
| 1034 |
getClickContent.find('input[name*=hotspot-url]').attr("disabled", false); |
| 1035 |
} |
| 1036 |
} |
| 1037 |
} |
| 1038 |
}); |
| 1039 |
$('textarea[name*=hotspot-hover]').summernote({ |
| 1040 |
toolbar: [ |
| 1041 |
['style', ['style']], |
| 1042 |
['font', ['bold', 'underline', 'clear']], |
| 1043 |
['fontname', ['fontname']], |
| 1044 |
['color', ['color']], |
| 1045 |
['para', ['ul', 'ol', 'paragraph']], |
| 1046 |
['table', ['table']], |
| 1047 |
['insert', ['link', 'picture', 'video']], |
| 1048 |
['view', ['codeview', 'help']], |
| 1049 |
], |
| 1050 |
fontNames: ['Arial', 'Helvetica', 'Tahoma', 'Courier New', 'Verdana', 'Impact', 'Times New Roman', 'system-ui', 'Helvetica Neue'], |
| 1051 |
callbacks: { |
| 1052 |
onInit: function() { |
| 1053 |
var $editor = $(this); |
| 1054 |
|
| 1055 |
// Override font name dropdown click handler for this specific editor |
| 1056 |
$editor.next('.note-editor').find('.dropdown-fontname a').off('click').on('click', function(e) { |
| 1057 |
e.preventDefault(); |
| 1058 |
var fontName = $(this).data('value') || $(this).text(); |
| 1059 |
|
| 1060 |
// Focus on the current editor |
| 1061 |
$editor.summernote('focus'); |
| 1062 |
|
| 1063 |
// Use Summernote's built-in method to apply font |
| 1064 |
try { |
| 1065 |
// First, clear any existing font formatting |
| 1066 |
var range = $editor.summernote('createRange'); |
| 1067 |
if (range && !range.isCollapsed()) { |
| 1068 |
// Get selected text |
| 1069 |
var selectedText = range.toString(); |
| 1070 |
|
| 1071 |
// Use Summernote's insertHTML to replace content |
| 1072 |
var fontHtml = '<span style="font-family: ' + fontName + ';">' + selectedText + '</span>'; |
| 1073 |
$editor.summernote('insertHTML', fontHtml); |
| 1074 |
} else { |
| 1075 |
// No selection, use execCommand for typing |
| 1076 |
$editor.summernote('focus'); |
| 1077 |
document.execCommand('fontName', false, fontName); |
| 1078 |
} |
| 1079 |
} catch (error) { |
| 1080 |
console.log('Font application error, using fallback method'); |
| 1081 |
// Fallback method |
| 1082 |
document.execCommand('fontName', false, fontName); |
| 1083 |
} |
| 1084 |
|
| 1085 |
// Update dropdown button text for this editor |
| 1086 |
$(this).closest('.note-editor').find('.note-current-fontname').text(fontName); |
| 1087 |
|
| 1088 |
// Close dropdown |
| 1089 |
var $dropdownMenu = $(this).closest('.dropdown-menu'); |
| 1090 |
$dropdownMenu.removeClass('show').hide(); |
| 1091 |
$dropdownMenu.prev('.dropdown-toggle').removeClass('show').attr('aria-expanded', 'false'); |
| 1092 |
|
| 1093 |
// Trigger change event |
| 1094 |
setTimeout(function() { |
| 1095 |
$editor.trigger('summernote.change'); |
| 1096 |
}, 100); |
| 1097 |
}); |
| 1098 |
}, |
| 1099 |
|
| 1100 |
// Clean up the content after any change |
| 1101 |
onChange: function(contents, $editable) { |
| 1102 |
// Debounce the cleanup to avoid conflicts |
| 1103 |
clearTimeout(this.cleanupTimeout); |
| 1104 |
this.cleanupTimeout = setTimeout(function() { |
| 1105 |
// Remove all font-family styles from elements that shouldn't have them |
| 1106 |
$editable.find('*:not(span)').each(function() { |
| 1107 |
if (this.style && this.style.fontFamily) { |
| 1108 |
this.style.fontFamily = ''; |
| 1109 |
} |
| 1110 |
}); |
| 1111 |
|
| 1112 |
// Clean up empty spans |
| 1113 |
$editable.find('span').each(function() { |
| 1114 |
var $span = $(this); |
| 1115 |
var text = $span.text().replace(/[\uFEFF\u200B-\u200D\u2060]/g, '').trim(); |
| 1116 |
|
| 1117 |
if (!text) { |
| 1118 |
$span.remove(); |
| 1119 |
} else { |
| 1120 |
// If span has other styles besides font-family, keep only font-family |
| 1121 |
var fontFamily = $span.css('font-family'); |
| 1122 |
if (fontFamily && fontFamily !== 'inherit') { |
| 1123 |
$span.attr('style', 'font-family: ' + fontFamily + ';'); |
| 1124 |
} else if (!fontFamily || fontFamily === 'inherit') { |
| 1125 |
$span.contents().unwrap(); |
| 1126 |
} |
| 1127 |
} |
| 1128 |
}); |
| 1129 |
|
| 1130 |
// Remove nested spans with font-family |
| 1131 |
$editable.find('span[style*="font-family"] span[style*="font-family"]').each(function() { |
| 1132 |
$(this).contents().unwrap(); |
| 1133 |
}); |
| 1134 |
}, 200); |
| 1135 |
} |
| 1136 |
} |
| 1137 |
}); |
| 1138 |
if ($(this).parents(".hotspot-setup").attr("data-limit").length > 0) { |
| 1139 |
|
| 1140 |
if ($(this).parents(".hotspot-setup").find("div[data-repeater-item]").length <= $(this).parents(".hotspot-setup").attr("data-limit")) { |
| 1141 |
|
| 1142 |
$(this).slideDown(); |
| 1143 |
$(this).removeClass('active'); |
| 1144 |
$(this).siblings('.active').removeClass('active'); |
| 1145 |
$(this).addClass('active'); |
| 1146 |
j = parseInt(j); |
| 1147 |
j = j + 1; |
| 1148 |
var parent_scene = $(this).parent().parent().parent('.single-scene.active').attr('id'); |
| 1149 |
scene_parent = parent_scene; |
| 1150 |
var hotspot = parent_scene + '-hotspot-' + j; |
| 1151 |
|
| 1152 |
var replace_string = parent_scene.replace("scene-", ""); |
| 1153 |
|
| 1154 |
$(this).find(".title .hotspot-num").html(j); |
| 1155 |
$(this).find(".title .scene-num").html(replace_string); |
| 1156 |
|
| 1157 |
$('<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')); |
| 1158 |
|
| 1159 |
$(this).attr('id', hotspot); |
| 1160 |
|
| 1161 |
setTimeout(changeicon, 1000); |
| 1162 |
} else { |
| 1163 |
$('.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>'); |
| 1164 |
$('body').addClass('error-overlay2'); |
| 1165 |
$('.pano-alert').addClass('pano-default-warning').show(); |
| 1166 |
$(this).remove(); |
| 1167 |
} |
| 1168 |
} else { |
| 1169 |
jQuery(this).slideDown(); |
| 1170 |
$(this).removeClass('active'); |
| 1171 |
j = parseInt(j); |
| 1172 |
j = j + 1; |
| 1173 |
var parent_scene = $(this).parent().parent().parent('.single-scene.active').attr('id'); |
| 1174 |
var hotspot = parent_scene + '-hotspot-' + j; |
| 1175 |
|
| 1176 |
var replace_string = parent_scene.replace("scene-", ""); |
| 1177 |
|
| 1178 |
$(this).find(".title .hotspot-num").html(j); |
| 1179 |
$(this).find(".title .scene-num").html(replace_string); |
| 1180 |
|
| 1181 |
$('<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')); |
| 1182 |
|
| 1183 |
$(this).attr('id', hotspot); |
| 1184 |
} |
| 1185 |
$('#wpvr_active_hotspot').val(j); |
| 1186 |
}, |
| 1187 |
hide: function (deleteElement) { |
| 1188 |
var hotspot_hide_id = $(this).attr("id"); |
| 1189 |
var _hide_id = hotspot_hide_id.split('-').pop(); |
| 1190 |
hotspot_hide_id = "#" + hotspot_hide_id; |
| 1191 |
var hotspot_current = $(this).attr('id'); |
| 1192 |
var hotspot_fchild = $(this).parent().children(":first").attr('id'); |
| 1193 |
|
| 1194 |
var hpelementcontains = $(this).attr("id"); |
| 1195 |
var hpstr1 = 'scene'; |
| 1196 |
var hpstr2 = 'hotspot'; |
| 1197 |
if (hpelementcontains.indexOf(hpstr1) != -1 && hpelementcontains.indexOf(hpstr2) != -1) { |
| 1198 |
|
| 1199 |
var _this = $(this); |
| 1200 |
|
| 1201 |
if (confirm('Are you sure you want to delete?')) { |
| 1202 |
jQuery(_this).slideUp(deleteElement); |
| 1203 |
if (hotspot_current == hotspot_fchild) { |
| 1204 |
$(_this).next().addClass("active"); |
| 1205 |
$(_this).parent().parent('.hotspot-setup').find('.hotspot-nav li span[data-href="' + hotspot_hide_id + '"]').parent("li").next().addClass("active"); |
| 1206 |
|
| 1207 |
} else { |
| 1208 |
$(_this).prev().addClass("active"); |
| 1209 |
$(_this).parent().parent('.hotspot-setup').find('.hotspot-nav li span[data-href="' + hotspot_hide_id + '"]').parent("li").prev().addClass("active"); |
| 1210 |
} |
| 1211 |
|
| 1212 |
$(_this).parent().parent('.hotspot-setup').find('.hotspot-nav li:not(:last-child) span[data-href="' + hotspot_hide_id + '"]').parent("li").remove(); |
| 1213 |
|
| 1214 |
//tab active setup |
| 1215 |
if (parseInt(_hide_id) - 1 > 0) { |
| 1216 |
$('#wpvr_active_hotspot').val(parseInt(_hide_id) - 1); |
| 1217 |
} else { |
| 1218 |
$('#wpvr_active_hotspot').val(1); |
| 1219 |
} |
| 1220 |
|
| 1221 |
setTimeout(function(){ |
| 1222 |
let yawInputs = $('.hotspot-yaw'); |
| 1223 |
let pitchInputs = $('.hotspot-pitch'); |
| 1224 |
let hasYawValue = false; |
| 1225 |
let hasPitchValue = false; |
| 1226 |
|
| 1227 |
yawInputs.each(function() { |
| 1228 |
if ($(this).val() && $(this).val().trim() !== '') { |
| 1229 |
hasYawValue = true; |
| 1230 |
return false; // break loop |
| 1231 |
} |
| 1232 |
}); |
| 1233 |
pitchInputs.each(function() { |
| 1234 |
if ($(this).val() && $(this).val().trim() !== '') { |
| 1235 |
hasPitchValue = true; |
| 1236 |
return false; // break loop |
| 1237 |
} |
| 1238 |
}); |
| 1239 |
|
| 1240 |
let $hotspotCheckbox = $('#wpvr-check-hotspots'); |
| 1241 |
|
| 1242 |
if (!hasYawValue && !hasPitchValue) { |
| 1243 |
$hotspotCheckbox.prop('checked', false); |
| 1244 |
$hotspotCheckbox.closest('.wpvr-checklist-item').css('color', '#73707D'); |
| 1245 |
} else { |
| 1246 |
$hotspotCheckbox.prop('checked', true); |
| 1247 |
$hotspotCheckbox.closest('.wpvr-checklist-item').css('color', '#0E003C'); |
| 1248 |
} |
| 1249 |
updateProgress(); |
| 1250 |
},500); |
| 1251 |
} |
| 1252 |
} |
| 1253 |
}, |
| 1254 |
|
| 1255 |
}] |
| 1256 |
}); |
| 1257 |
}); |
| 1258 |
|
| 1259 |
$(document).on("click", ".upload-scene-wrapper", function (event) { |
| 1260 |
$(".scene-nav ul li:last-child span").trigger("click"); |
| 1261 |
$(".scene-upload").trigger("click"); |
| 1262 |
}) |
| 1263 |
|
| 1264 |
$(document).on("click", ".upload-scene-wrapper-first", function (event) { |
| 1265 |
$(".scene-upload").trigger("click"); |
| 1266 |
}) |
| 1267 |
|
| 1268 |
$(document).on("click", ".scene-upload", function (event) { |
| 1269 |
event.preventDefault(); |
| 1270 |
var parent = $(this).parent('.form-group'); |
| 1271 |
|
| 1272 |
var scene_uploader = wp.media({ |
| 1273 |
title: $(this).data('uploader_title'), |
| 1274 |
button: { |
| 1275 |
text: $(this).data('uploader_button_text'), |
| 1276 |
}, |
| 1277 |
library: { |
| 1278 |
type: ['image'] |
| 1279 |
}, |
| 1280 |
multiple: false |
| 1281 |
}); |
| 1282 |
|
| 1283 |
scene_uploader.on('select', function () { |
| 1284 |
|
| 1285 |
var attachment = scene_uploader.state().get('selection').first().toJSON(); |
| 1286 |
|
| 1287 |
var imageUrl = attachment.url; |
| 1288 |
var siteProtocol = window.location.protocol; |
| 1289 |
var imageProtocol = new URL(imageUrl).protocol; |
| 1290 |
|
| 1291 |
$('.rex-add-coordinates .mixed-content-warning, .rex-add-coordinates .mixed-content-doc-link').remove(); |
| 1292 |
|
| 1293 |
if (siteProtocol !== imageProtocol) { |
| 1294 |
|
| 1295 |
// Create warning message |
| 1296 |
var $warningBox = $('<div>', { |
| 1297 |
text: "You're loading an image over " + imageProtocol.replace(':', '').toUpperCase() + |
| 1298 |
" on a site using " + siteProtocol.replace(':', '').toUpperCase() + |
| 1299 |
". This may cause a mixed content issue.", |
| 1300 |
class: 'mixed-content-warning', |
| 1301 |
css: { |
| 1302 |
color: 'red', |
| 1303 |
marginTop: '35px', |
| 1304 |
} |
| 1305 |
}); |
| 1306 |
|
| 1307 |
// Create doc link |
| 1308 |
var $docLink = $('<a>', { |
| 1309 |
href: 'https://rextheme.com/docs/wp-vr-tour-not-displaying/', |
| 1310 |
text: 'View fix guide', |
| 1311 |
target: '_blank', |
| 1312 |
class: 'mixed-content-doc-link', |
| 1313 |
css: { |
| 1314 |
display: 'block', |
| 1315 |
color: '#0073aa', |
| 1316 |
textDecoration: 'underline' |
| 1317 |
} |
| 1318 |
}).on('click', function () { |
| 1319 |
$(this).blur(); // Remove focus after click |
| 1320 |
}); |
| 1321 |
|
| 1322 |
// Prepend warning and link to the top of the container |
| 1323 |
$('.rex-add-coordinates').prepend($warningBox, $docLink); |
| 1324 |
} |
| 1325 |
|
| 1326 |
parent.find('.scene-attachment-url').val(attachment.url); |
| 1327 |
parent.find('img').attr('src', attachment.url).show(); |
| 1328 |
|
| 1329 |
setTimeout(function () { |
| 1330 |
if (!$('#wpvr-check-scene').is(':checked')) { |
| 1331 |
$('#wpvr-check-scene').prop('checked', true); |
| 1332 |
$('#wpvr-check-scene').closest('.wpvr-checklist-item').css('color', '#0E003C'); |
| 1333 |
} |
| 1334 |
|
| 1335 |
if (!$('#wpvr-check-media').is(':checked')) { |
| 1336 |
$('#wpvr-check-media').prop('checked', true); |
| 1337 |
$('#wpvr-check-media').closest('.wpvr-checklist-item').css('color', '#0E003C'); |
| 1338 |
} |
| 1339 |
|
| 1340 |
updateProgress(); |
| 1341 |
|
| 1342 |
$('.panolenspreview').trigger('click'); |
| 1343 |
}, 1000); |
| 1344 |
|
| 1345 |
|
| 1346 |
}); |
| 1347 |
|
| 1348 |
scene_uploader.open(); |
| 1349 |
}); |
| 1350 |
|
| 1351 |
$(document).on("click", ".video-upload", function (event) { |
| 1352 |
event.preventDefault(); |
| 1353 |
|
| 1354 |
var parent = $(this).parent('.form-group'); |
| 1355 |
|
| 1356 |
var video_uploader = wp.media({ |
| 1357 |
title: $(this).data('uploader_title'), |
| 1358 |
button: { |
| 1359 |
text: $(this).data('uploader_button_text'), |
| 1360 |
}, |
| 1361 |
library: { |
| 1362 |
type: ['video/mp4'] |
| 1363 |
}, |
| 1364 |
multiple: false |
| 1365 |
}); |
| 1366 |
|
| 1367 |
video_uploader.on('select', function () { |
| 1368 |
var attachment = video_uploader.state().get('selection').first().toJSON(); |
| 1369 |
parent.find('.video-attachment-url').val(attachment.url); |
| 1370 |
}); |
| 1371 |
|
| 1372 |
video_uploader.open(); |
| 1373 |
}); |
| 1374 |
|
| 1375 |
$(document).on("click", ".preview-upload", function (event) { |
| 1376 |
event.preventDefault(); |
| 1377 |
var parent = $(this).parent('.form-group'); |
| 1378 |
|
| 1379 |
var preview_uploader = wp.media({ |
| 1380 |
title: $(this).data('uploader_title'), |
| 1381 |
button: { |
| 1382 |
text: $(this).data('uploader_button_text'), |
| 1383 |
}, |
| 1384 |
library: { |
| 1385 |
type: ['image'] |
| 1386 |
}, |
| 1387 |
multiple: false |
| 1388 |
}); |
| 1389 |
|
| 1390 |
preview_uploader.on('select', function () { |
| 1391 |
var attachment = preview_uploader.state().get('selection').first().toJSON(); |
| 1392 |
parent.find('.preview-attachment-url').val(attachment.url); |
| 1393 |
parent.find('.img-upload-frame').css('background-image', 'url(' + attachment.url + ')'); |
| 1394 |
parent.find('.img-upload-frame').addClass('img-uploaded'); |
| 1395 |
parent.find('.remove-attachment').show(); |
| 1396 |
}); |
| 1397 |
|
| 1398 |
preview_uploader.open(); |
| 1399 |
}); |
| 1400 |
|
| 1401 |
//----remove tour preview image---- |
| 1402 |
$(document).on("click", ".remove-attachment", function (event) { |
| 1403 |
$(this).hide(); |
| 1404 |
parent = $(this).parents('.form-group'); |
| 1405 |
|
| 1406 |
parent.find('.preview-attachment-url').val(''); |
| 1407 |
parent.find('.img-upload-frame').css('background-image', ''); |
| 1408 |
parent.find('.img-upload-frame').removeClass('img-uploaded'); |
| 1409 |
}); |
| 1410 |
|
| 1411 |
|
| 1412 |
$(document).on("change", "select[name*=hotspot-type]", function (event) { |
| 1413 |
|
| 1414 |
var getparent = $(this).parent(); |
| 1415 |
var getvalue = $(this).val(); |
| 1416 |
if (getvalue == 'info') { |
| 1417 |
getparent.find('.hotspot-scene').hide(); |
| 1418 |
getparent.find('.hotspot-scene input').val(''); |
| 1419 |
getparent.find('.hotspot-scene .hotspotscene').val('none'); |
| 1420 |
getparent.find('.hotspot-url').show(); |
| 1421 |
getparent.find('.s_tab').show(); |
| 1422 |
getparent.find('.hotspot-content').show(); |
| 1423 |
getparent.find('input[name*=hotspot-url]').attr("disabled",false) |
| 1424 |
getparent.find('textarea[name*=hotspot-content]').next().find(".note-editable").attr("contenteditable", true); |
| 1425 |
} else { |
| 1426 |
getparent.find('.hotspot-scene').show(); |
| 1427 |
getparent.find('.hotspot-url').hide(); |
| 1428 |
getparent.find('.hotspot-url input').val(''); |
| 1429 |
getparent.find('.s_tab').hide(); |
| 1430 |
getparent.find('.s_tab input').val('off'); |
| 1431 |
getparent.find('.s_tab input').removeAttr('checked'); |
| 1432 |
getparent.find('.hotspot-content').hide(); |
| 1433 |
getparent.find('.hotspot-content textarea').val(''); |
| 1434 |
getparent.find('textarea[name*=hotspot-content]').next().find(".note-editable").html(''); |
| 1435 |
} |
| 1436 |
}); |
| 1437 |
$(document).ready(function ($){ |
| 1438 |
$(document).on("keyup","input[name*=hotspot-url]",function (){ |
| 1439 |
var getHotspotUrl = $(this).val(); |
| 1440 |
var getParent = $(this).parent(); |
| 1441 |
var getMainParent = getParent.parent() |
| 1442 |
var getClickContent = getMainParent.find('.hotspot-content') |
| 1443 |
if(getHotspotUrl.length > 0){ |
| 1444 |
getClickContent.find('textarea').val('') |
| 1445 |
getClickContent.find('textarea').attr('placeholder','You can set either a URL or an On-click content') |
| 1446 |
getClickContent.find('textarea').attr("disabled",true) |
| 1447 |
getClickContent.find('textarea[name*=hotspot-content]').next().find(".note-editable").attr("contenteditable", false); |
| 1448 |
getClickContent.find('textarea[name*=hotspot-content]').next().find(".note-editable").html(''); |
| 1449 |
|
| 1450 |
}else{ |
| 1451 |
getClickContent.find('textarea').attr("disabled",false) |
| 1452 |
getClickContent.find('textarea[name*=hotspot-content]').next().find(".note-editable").attr("contenteditable", true); |
| 1453 |
} |
| 1454 |
}) |
| 1455 |
|
| 1456 |
$(document).on("keyup","textarea[name*=hotspot-content]",function (){ |
| 1457 |
var getHotspotContent = $(this).summernote('code').trim(); |
| 1458 |
if (getHotspotContent === '<br>' || getHotspotContent === '<p><br></p>') { |
| 1459 |
getHotspotContent = ''; |
| 1460 |
} |
| 1461 |
var getParent = $(this).parent(); |
| 1462 |
var getMainParent = getParent.parent() |
| 1463 |
var getClickContent = getMainParent.find('.hotspot-url') |
| 1464 |
if(getHotspotContent.length > 0){ |
| 1465 |
getClickContent.find('input[name*=hotspot-url').val('') |
| 1466 |
getClickContent.find('input[name*=hotspot-url').attr('placeholder','You can set either a URL or an On-click content') |
| 1467 |
getClickContent.find('input[name*=hotspot-url]').attr("disabled",true) |
| 1468 |
}else{ |
| 1469 |
getClickContent.find('input[name*=hotspot-url]').attr("disabled",false) |
| 1470 |
} |
| 1471 |
}) |
| 1472 |
}) |
| 1473 |
|
| 1474 |
|
| 1475 |
$(document).on("click", ".pano-error-close-btn", function (e) { |
| 1476 |
e.preventDefault(); |
| 1477 |
$('.wpvr-delete-alert-wrapper').css('display', 'none'); |
| 1478 |
$('.wpvr-delete-alert-wrapper').hide(); |
| 1479 |
}); |
| 1480 |
|
| 1481 |
$(document).on("change", "input[type=radio][name=panovideo]", function (event) { |
| 1482 |
var getvalue = $(this).val(); |
| 1483 |
|
| 1484 |
if (getvalue == 'on') { |
| 1485 |
$('#confirm_text').html(`${window.wpvr_localize.VideoTourNotice}`); |
| 1486 |
$('.wpvr-delete-alert-wrapper').css('display', 'flex'); |
| 1487 |
} else { |
| 1488 |
$('.wpvr-delete-alert-wrapper').css('display', 'none'); |
| 1489 |
// $(".video-setting").hide(); |
| 1490 |
|
| 1491 |
$("li.general").show(); |
| 1492 |
$("li.scene").show(); |
| 1493 |
$("li.hotspot").show(); |
| 1494 |
$("li.streetview").show(); |
| 1495 |
$(".video-setting").hide(); |
| 1496 |
} |
| 1497 |
|
| 1498 |
$(document).on("click", ".wpvr-delete-confirm-btn .cancel,.wpvr-delete-alert-wrapper .cross", function (e) { |
| 1499 |
e.preventDefault(); |
| 1500 |
$('.wpvr-delete-alert-wrapper').css('display', 'none'); |
| 1501 |
$('.wpvr-delete-alert-wrapper').hide(); |
| 1502 |
|
| 1503 |
$(".video_on").prop('checked', false); |
| 1504 |
$(".video_off").prop('checked', true); |
| 1505 |
|
| 1506 |
$("li.general").show(); |
| 1507 |
$("li.scene").show(); |
| 1508 |
$("li.hotspot").show(); |
| 1509 |
$("li.streetview").show(); |
| 1510 |
$(".video-setting").hide(); |
| 1511 |
|
| 1512 |
}); |
| 1513 |
|
| 1514 |
$(document).on("click", ".wpvr-delete-confirm-btn .yes", function (e) { |
| 1515 |
e.preventDefault(); |
| 1516 |
$('.wpvr-delete-alert-wrapper').css('display', 'none'); |
| 1517 |
$('.wpvr-delete-alert-wrapper').hide(); |
| 1518 |
|
| 1519 |
$(".video_off").prop('checked', false); |
| 1520 |
$(".video_on").prop('checked', true); |
| 1521 |
$(".video-setting").show(); |
| 1522 |
$("li.general").hide(); |
| 1523 |
$("li.scene").hide(); |
| 1524 |
$("li.hotspot").hide(); |
| 1525 |
$("li.streetview").hide(); |
| 1526 |
|
| 1527 |
}); |
| 1528 |
}); |
| 1529 |
|
| 1530 |
jQuery(document).ready(function ($) { |
| 1531 |
let detect_scene_1_data = $('#scene-1').find('.sceneid').val(); |
| 1532 |
if(detect_scene_1_data === "") { |
| 1533 |
$('#scene-1').find('.sceneid').val(generateRandomString(8)); |
| 1534 |
} |
| 1535 |
}); |
| 1536 |
|
| 1537 |
function generateRandomString(length) { |
| 1538 |
var result = ''; |
| 1539 |
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789'; |
| 1540 |
var charactersLength = characters.length; |
| 1541 |
|
| 1542 |
for (var i = 0; i < length; i++) { |
| 1543 |
var randomIndex = Math.floor(Math.random() * charactersLength); |
| 1544 |
result += characters.charAt(randomIndex); |
| 1545 |
} |
| 1546 |
|
| 1547 |
return result; |
| 1548 |
} |
| 1549 |
function prepare_hotspot_configuration_data() { |
| 1550 |
var datacoords = $('#panodata').text().split(','); |
| 1551 |
var pitchsplit = datacoords[0]; |
| 1552 |
var pitch = pitchsplit.split(':'); |
| 1553 |
var yawsplit = datacoords[1]; |
| 1554 |
var yaw = yawsplit.split(':'); |
| 1555 |
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(); |
| 1556 |
if(detect_active_hotspot_id === "" || detect_active_hotspot_id == undefined) { |
| 1557 |
$('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)); |
| 1558 |
} |
| 1559 |
$('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]); |
| 1560 |
$('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]); |
| 1561 |
} |
| 1562 |
|
| 1563 |
function register_hotspot() { |
| 1564 |
$('.panolenspreview').trigger('click'); |
| 1565 |
} |
| 1566 |
|
| 1567 |
$(document).on("click", ".toppitch", function (event) { |
| 1568 |
$.when(prepare_hotspot_configuration_data()).done(function() { |
| 1569 |
register_hotspot(); |
| 1570 |
}); |
| 1571 |
}); |
| 1572 |
|
| 1573 |
jQuery(document).ready(function ($) { |
| 1574 |
var viddata = $("input[name='panovideo']:checked").val(); |
| 1575 |
|
| 1576 |
if (viddata == 'on') { |
| 1577 |
|
| 1578 |
$("li.scene").removeClass('active'); |
| 1579 |
$(".rex-pano-tab.wpvr_scene").removeClass('active'); |
| 1580 |
$("li.videos").addClass('active'); |
| 1581 |
$(".rex-pano-tab.video").addClass('active'); |
| 1582 |
$(".video-setting").show(); |
| 1583 |
$("li.general").hide(); |
| 1584 |
$("li.scene").hide(); |
| 1585 |
$("li.hotspot").hide(); |
| 1586 |
} else { |
| 1587 |
// $(".video-setting").hide(); |
| 1588 |
$("li.general").show(); |
| 1589 |
$("li.scene").show(); |
| 1590 |
$("li.hotspot").show(); |
| 1591 |
} |
| 1592 |
}); |
| 1593 |
|
| 1594 |
$(document).on("change", "select[name*=hotspot-customclass-pro]", function (event) { |
| 1595 |
var getval = $(this).val(); |
| 1596 |
$(this).parent('.hotspot-setting').children('span.change-icon').html('<i class="' + getval + '"></i>'); |
| 1597 |
|
| 1598 |
}); |
| 1599 |
|
| 1600 |
$(document).on("change", ".hotspot-customclass-color", function (event) { |
| 1601 |
var getcolor = $(this).val(); |
| 1602 |
color = getcolor; |
| 1603 |
$('.hotspot-customclass-color-icon-value').val(getcolor); |
| 1604 |
$('.hotspot-customclass-color').val(getcolor); |
| 1605 |
}); |
| 1606 |
|
| 1607 |
jQuery(document).ready(function ($) { |
| 1608 |
if ($(".icon-found-value")[0]) { |
| 1609 |
color = $('.hotspot-customclass-color-icon-value.icon-found-value').val(); |
| 1610 |
} else { |
| 1611 |
color = '#00b4ff'; |
| 1612 |
} |
| 1613 |
}); |
| 1614 |
|
| 1615 |
function changeicon() { |
| 1616 |
$('.hotspot-customclass-color-icon-value').val(color); |
| 1617 |
$('.hotspot-customclass-color').val(color); |
| 1618 |
} |
| 1619 |
|
| 1620 |
//------------panolens tab js------------------ |
| 1621 |
|
| 1622 |
|
| 1623 |
$(document).on("click", ".scene-nav ul li:not(:last-child) span", function () { |
| 1624 |
|
| 1625 |
var scene_id = $(this).data('index'); |
| 1626 |
scene_id = '#scene-' + scene_id; |
| 1627 |
|
| 1628 |
j = $(scene_id).find('.hotspot-nav li').eq(-2).find('span').attr('data-index'); |
| 1629 |
|
| 1630 |
$([$(this).parent()[0], $($(this).data('href'))[0]]).addClass('active').siblings('.active').removeClass('active'); |
| 1631 |
$('#wpvr_active_scenes').val($(this).data('index')); |
| 1632 |
}); |
| 1633 |
|
| 1634 |
//add click |
| 1635 |
$(document).on("click", ".scene-nav ul li:last-child span", function () { |
| 1636 |
var scene_id = $(this).parent('li').prev().children("span").data('index'); |
| 1637 |
scene_id = '#scene-' + scene_id; |
| 1638 |
$(scene_id).removeAttr("style"); |
| 1639 |
j = $(scene_id).find('.hotspot-nav li').eq(-2).find('span').attr('data-index'); |
| 1640 |
$('.scene-nav ul li.active').removeClass('active'); |
| 1641 |
$(this).parent('li').prev().addClass('active'); |
| 1642 |
var sceneinfo = $('.scene-setup').repeaterVal(); |
| 1643 |
var infodata = sceneinfo['scene-list']; |
| 1644 |
$('.hotspotscene').find('option').remove(); |
| 1645 |
$('.hotspotscene').append("<option value='none'>None</option>"); |
| 1646 |
for (var i in infodata) { |
| 1647 |
var optiondata = infodata[i]['scene-id']; |
| 1648 |
if (optiondata != '') { |
| 1649 |
$('.hotspotscene').append("<option value='" + optiondata + "'>" + optiondata + "</option>"); |
| 1650 |
} |
| 1651 |
} |
| 1652 |
$('.hotspot-customclass-pro-select').fontIconPicker(); |
| 1653 |
$('span.change-icon').hide(); |
| 1654 |
}); |
| 1655 |
|
| 1656 |
//end add click |
| 1657 |
$(document).on("click", ".hotspot-nav ul li:not(:last-child) span", function () { |
| 1658 |
$('#wpvr_active_hotspot').val($(this).data('index')); |
| 1659 |
$([$(this).parent()[0], $($(this).data('href'))[0]]).addClass('active').siblings('.active').removeClass('active'); |
| 1660 |
}); |
| 1661 |
|
| 1662 |
$(document).on("click", ".hotspot-nav ul li:last-child span", function () { |
| 1663 |
$(this).parent('li').siblings('.active').removeClass('active'); |
| 1664 |
$(this).parent('li').prev().addClass('active'); |
| 1665 |
var sceneinfo = $('.scene-setup').repeaterVal(); |
| 1666 |
var infodata = sceneinfo['scene-list']; |
| 1667 |
$('.hotspotscene').find('option').remove(); |
| 1668 |
$('.hotspotscene').append("<option value='none'>None</option>"); |
| 1669 |
for (var i in infodata) { |
| 1670 |
var optiondata = infodata[i]['scene-id']; |
| 1671 |
if (optiondata != '') { |
| 1672 |
$('.hotspotscene').append("<option value='" + optiondata + "'>" + optiondata + "</option>"); |
| 1673 |
} |
| 1674 |
} |
| 1675 |
$('.trtr').trigger('change'); |
| 1676 |
$('.hotspot-customclass-pro-select').fontIconPicker(); |
| 1677 |
$('span.change-icon').hide(); |
| 1678 |
|
| 1679 |
}); |
| 1680 |
|
| 1681 |
function changehotspotid(id) { |
| 1682 |
var scene_id = '#scene-' + id; |
| 1683 |
var hotspot_id = 'scene-' + id + '-hotspot-1'; |
| 1684 |
$(scene_id).find('.hotspot-nav li span').attr('data-href', '#' + hotspot_id + ''); |
| 1685 |
$(scene_id).find('.single-hotspot').attr('id', hotspot_id); |
| 1686 |
|
| 1687 |
} |
| 1688 |
|
| 1689 |
$(document).on("click", ".rex-pano-nav-menu.main-nav ul li span", function () { |
| 1690 |
var screen = $(this).parent().attr('data-screen'); |
| 1691 |
|
| 1692 |
var url_info = wpvr_global_obj.url_info |
| 1693 |
if ( 'add' == url_info.screen ){ |
| 1694 |
var newUrl = url_info.admin_url+"post-new.php?"+"post_type="+url_info.param.post_type+"&active_tab="+screen; |
| 1695 |
}else{ |
| 1696 |
var newUrl = url_info.admin_url+"post.php?"+"post="+url_info.param.post+"&action=edit"+"&active_tab="+screen; |
| 1697 |
} |
| 1698 |
|
| 1699 |
handle_add_pitch_button(screen); |
| 1700 |
|
| 1701 |
if (window.history != 'undefined' && window.history.pushState != 'undefined') { |
| 1702 |
window.history.pushState({ path: newUrl }, '', newUrl); |
| 1703 |
} |
| 1704 |
|
| 1705 |
$('#wpvr_active_tab').val(screen); |
| 1706 |
if ('hotspot' == screen) { |
| 1707 |
$('.active_scene_id').show(); |
| 1708 |
var id = $('.single-scene.active').attr('id'); |
| 1709 |
$('.active_scene_id p').text(`${window.wpvr_localize.AddingHotspotsOnScene}`); |
| 1710 |
var scenceID = $('#' + id + ' .sceneid').val(); |
| 1711 |
var span = '<span>(' + scenceID + ')</span>' |
| 1712 |
$('.active_scene_id p').append(span); |
| 1713 |
$('.active_scene_id').css({ "background-color": "#E0E1F7", "width": "100%", "text-align": "center", "padding": "10px 15px" }); |
| 1714 |
$('.active_scene_id p').css({ "color": "black", "font-size": "15px" }); |
| 1715 |
$('.active_scene_id p span').css({ "color": "#004efa", "font-size": "15px" }); |
| 1716 |
|
| 1717 |
} else { |
| 1718 |
$('.active_scene_id').hide(); |
| 1719 |
} |
| 1720 |
$([$(this).parent()[0], $($(this).data('href'))[0]]).addClass('active').siblings('.active').removeClass('active'); |
| 1721 |
}); |
| 1722 |
|
| 1723 |
//-Get Started reloaded -// |
| 1724 |
$(document).on("click",".tabs.rex-tabs li a",function(){ |
| 1725 |
var tab = $(this).attr('href'); |
| 1726 |
var url = window.location; |
| 1727 |
var origin = url.origin; |
| 1728 |
var pathname = url.pathname |
| 1729 |
var search_perameter = window.location.search.split('&'); |
| 1730 |
var makeUrl = origin + pathname + search_perameter[0] |
| 1731 |
var newUrl = makeUrl + tab; |
| 1732 |
|
| 1733 |
if (window.history != 'undefined' && window.history.pushState != 'undefined') { |
| 1734 |
window.history.pushState({ path: newUrl }, '', newUrl); |
| 1735 |
} |
| 1736 |
}) |
| 1737 |
//----------alert dismiss--------// |
| 1738 |
$(document).on("click", "body", function () { |
| 1739 |
$('body').removeClass('error-overlay2'); |
| 1740 |
$('.pano-alert').removeClass('pano-default-warning').hide(); |
| 1741 |
}); |
| 1742 |
$(document).on("click", ".pano-alert .pano-error-close-btn", function () { |
| 1743 |
$('body').removeClass('error-overlay2'); |
| 1744 |
$('.pano-alert').removeClass('pano-default-warning').hide(); |
| 1745 |
}); |
| 1746 |
$(document).on("click", ".pano-alert, .rex-pano-sub-tabs .rex-pano-tab-nav li.add", function (e) { |
| 1747 |
e.stopPropagation(); |
| 1748 |
}); |
| 1749 |
|
| 1750 |
|
| 1751 |
$(document).on("click", ".main-nav li.hotspot span", function () { |
| 1752 |
$(".hotspot-setup.rex-pano-sub-tabs").show(); |
| 1753 |
$(".scene-setup > nav.scene-nav").hide(); |
| 1754 |
$(".scene-setup .single-scene > .scene-content").hide(); |
| 1755 |
$(".scene-setup .delete-scene").hide(); |
| 1756 |
}); |
| 1757 |
|
| 1758 |
$(document).on("click", ".main-nav li.scene span", function () { |
| 1759 |
$(".hotspot-setup.rex-pano-sub-tabs").hide(); |
| 1760 |
$(".scene-setup > nav.scene-nav").show(); |
| 1761 |
$(".scene-setup .single-scene > .scene-content").show(); |
| 1762 |
$(".scene-setup .delete-scene").show(); |
| 1763 |
}); |
| 1764 |
|
| 1765 |
$(document).on("change", ".dscen", function () { |
| 1766 |
var dscene = $(this).val(); |
| 1767 |
if('on' === dscene){ |
| 1768 |
$('#wpvr-check-default').prop('checked', true); |
| 1769 |
$('#wpvr-check-default').closest('.wpvr-checklist-item').css('color', '#0E003C'); |
| 1770 |
}else{ |
| 1771 |
$('#wpvr-check-default').prop('checked', false); |
| 1772 |
$('#wpvr-check-default').closest('.wpvr-checklist-item').css('color', '#73707D'); |
| 1773 |
} |
| 1774 |
updateProgress() |
| 1775 |
$(".dscen").not(this).each(function () { |
| 1776 |
var oth_scene = $(this).val(); |
| 1777 |
if (dscene == 'on' && oth_scene == 'on') { |
| 1778 |
$('#error_occured').show(); |
| 1779 |
$('#error_occured .pano-error-message').html('<span class="pano-error-title">Default scene has been updated</span>'); |
| 1780 |
$('body').addClass('error-overlay'); |
| 1781 |
$('html, body').animate({ |
| 1782 |
scrollTop: $("#error_occured").offset().top |
| 1783 |
}, 500); |
| 1784 |
$(this).val('off'); |
| 1785 |
|
| 1786 |
} |
| 1787 |
}); |
| 1788 |
}); |
| 1789 |
|
| 1790 |
$(document).on("change", ".sceneid", function () { |
| 1791 |
var sceneinfo = $('.scene-setup').repeaterVal(); |
| 1792 |
var infodata = sceneinfo['scene-list']; |
| 1793 |
$('.hotspotscene').find('option').remove(); |
| 1794 |
$('.hotspotscene').append("<option value='none'>None</option>"); |
| 1795 |
for (var i in infodata) { |
| 1796 |
var optiondata = infodata[i]['scene-id']; |
| 1797 |
if (optiondata != '') { |
| 1798 |
$('.hotspotscene').append("<option value='" + optiondata + "'>" + optiondata + "</option>"); |
| 1799 |
} |
| 1800 |
} |
| 1801 |
}); |
| 1802 |
|
| 1803 |
|
| 1804 |
|
| 1805 |
function deleteinfodata() { |
| 1806 |
var sceneinfo = $('.scene-setup').repeaterVal(); |
| 1807 |
var infodata = sceneinfo['scene-list']; |
| 1808 |
$('.hotspotscene').find('option').remove(); |
| 1809 |
$('.hotspotscene').append("<option value='none'>None</option>"); |
| 1810 |
for (var i in infodata) { |
| 1811 |
var optiondata = infodata[i]['scene-id']; |
| 1812 |
if (optiondata != '') { |
| 1813 |
$('.hotspotscene').append("<option value='" + optiondata + "'>" + optiondata + "</option>"); |
| 1814 |
} |
| 1815 |
} |
| 1816 |
} |
| 1817 |
|
| 1818 |
$(document).on("change", ".hotspotscene", function () { |
| 1819 |
|
| 1820 |
var chanheghtptpval = $(this).val(); |
| 1821 |
if (chanheghtptpval != "none") { |
| 1822 |
$(this).parent('.hotspot-scene').siblings('.hotspot-scene').children('.hotspotsceneinfodata').val(chanheghtptpval); |
| 1823 |
} else { |
| 1824 |
$(this).parent('.hotspot-scene').siblings('.hotspot-scene').children('.hotspotsceneinfodata').val(''); |
| 1825 |
} |
| 1826 |
}); |
| 1827 |
|
| 1828 |
$(document).on("click", ".hotpitch", function (event) { |
| 1829 |
var datacoords = $('#panodata').text().split(','); |
| 1830 |
var pitchsplit = datacoords[0]; |
| 1831 |
var pitch = pitchsplit.split(':'); |
| 1832 |
$(this).parent().parent('.hotspot-setting').children('.hotspot-pitch').val(pitch[1]); |
| 1833 |
}); |
| 1834 |
|
| 1835 |
$(document).on("click", ".hotyaw", function (event) { |
| 1836 |
var datacoords = $('#panodata').text().split(','); |
| 1837 |
var yawsplit = datacoords[1]; |
| 1838 |
var yaw = yawsplit.split(':'); |
| 1839 |
$(this).parent().parent('.hotspot-setting').children('.hotspot-yaw').val(yaw[1]); |
| 1840 |
}); |
| 1841 |
|
| 1842 |
jQuery(document).ready(function ($) { |
| 1843 |
|
| 1844 |
if ($(".scene-setup").length > 0) { |
| 1845 |
var sceneinfo = $('.scene-setup').repeaterVal(); |
| 1846 |
var infodata = sceneinfo['scene-list']; |
| 1847 |
$('.hotspotscene').find('option').remove(); |
| 1848 |
$('.hotspotscene').append("<option value='none'>None</option>"); |
| 1849 |
for (var i in infodata) { |
| 1850 |
var optiondata = infodata[i]['scene-id']; |
| 1851 |
if (optiondata != '') { |
| 1852 |
$('.hotspotscene').append("<option value='" + optiondata + "'>" + optiondata + "</option>"); |
| 1853 |
} |
| 1854 |
} |
| 1855 |
} |
| 1856 |
}); |
| 1857 |
|
| 1858 |
$(document).on("click", ".toppitch", function (event) { |
| 1859 |
var datacoords = $('#panodata').text().split(','); |
| 1860 |
var pitchsplit = datacoords[0]; |
| 1861 |
var pitch = pitchsplit.split(':'); |
| 1862 |
var yawsplit = datacoords[1]; |
| 1863 |
var yaw = yawsplit.split(':'); |
| 1864 |
|
| 1865 |
$('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]); |
| 1866 |
$('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]); |
| 1867 |
}); |
| 1868 |
jQuery(document).ready(function ($) { |
| 1869 |
$('.hotspot-customclass-pro-select').fontIconPicker(); |
| 1870 |
}); |
| 1871 |
jQuery(document).ready(function ($) { |
| 1872 |
$('span.change-icon').hide(); |
| 1873 |
}); |
| 1874 |
|
| 1875 |
jQuery(document).ready(function ($) { |
| 1876 |
var autrotateset = $("input[name='autorotation']").is(':checked') ? 'on' : 'off'; |
| 1877 |
if (autrotateset == 'off') { |
| 1878 |
$('.autorotationdata-wrapper').hide(); |
| 1879 |
} else { |
| 1880 |
$('.autorotationdata-wrapper').show(); |
| 1881 |
} |
| 1882 |
|
| 1883 |
|
| 1884 |
}); |
| 1885 |
|
| 1886 |
$(document).on("change", "input[name='autorotation']", function (event) { |
| 1887 |
var autrotateset = $(this).is(':checked') ? 'on' : 'off'; |
| 1888 |
|
| 1889 |
if (autrotateset == 'on') { |
| 1890 |
$('.autorotationdata-wrapper').show(); |
| 1891 |
} else { |
| 1892 |
$('.autorotationdata-wrapper').hide(); |
| 1893 |
} |
| 1894 |
}); |
| 1895 |
|
| 1896 |
|
| 1897 |
$(document).on("change", ".ptyscene", function (event) { |
| 1898 |
var ptyscene = $(this).val(); |
| 1899 |
if (ptyscene == 'off') { |
| 1900 |
$(this).parent('.single-settings').siblings('.ptyscenedata').hide(); |
| 1901 |
} else { |
| 1902 |
$(this).parent('.single-settings').siblings('.ptyscenedata').show(); |
| 1903 |
} |
| 1904 |
}); |
| 1905 |
|
| 1906 |
$(document).on("change", ".cvgscene", function (event) { |
| 1907 |
var cvgscene = $(this).val(); |
| 1908 |
if (cvgscene == 'off') { |
| 1909 |
$(this).parent('.single-settings').siblings('.cvgscenedata').hide(); |
| 1910 |
} else { |
| 1911 |
$(this).parent('.single-settings').siblings('.cvgscenedata').show(); |
| 1912 |
} |
| 1913 |
}); |
| 1914 |
|
| 1915 |
$(document).on("change", ".chgscene", function (event) { |
| 1916 |
var chgscenedata = $(this).val(); |
| 1917 |
if (chgscenedata == 'off') { |
| 1918 |
$(this).parent('.single-settings').siblings('.chgscenedata').hide(); |
| 1919 |
} else { |
| 1920 |
$(this).parent('.single-settings').siblings('.chgscenedata').show(); |
| 1921 |
} |
| 1922 |
}); |
| 1923 |
|
| 1924 |
$(document).on("change", ".czscene", function (event) { |
| 1925 |
var czscene = $(this).val(); |
| 1926 |
if (czscene == 'off') { |
| 1927 |
$(this).parent('.single-settings').siblings('.czscenedata').hide(); |
| 1928 |
} else { |
| 1929 |
$(this).parent('.single-settings').siblings('.czscenedata').show(); |
| 1930 |
} |
| 1931 |
}); |
| 1932 |
|
| 1933 |
/** |
| 1934 |
* Nasim |
| 1935 |
* enable script button on chnage action |
| 1936 |
*/ |
| 1937 |
$("#wpvr_script_control").change(function () { |
| 1938 |
|
| 1939 |
if ($('#wpvr_script_control').is(':checked')) { |
| 1940 |
|
| 1941 |
$(".wpvr_enqueue_script_list").show(); |
| 1942 |
|
| 1943 |
} else { |
| 1944 |
|
| 1945 |
$(".wpvr_enqueue_script_list").hide(); |
| 1946 |
} |
| 1947 |
|
| 1948 |
}); |
| 1949 |
|
| 1950 |
/** |
| 1951 |
* Sakib |
| 1952 |
* enable script button on chnage action |
| 1953 |
*/ |
| 1954 |
$("#wpvr_video_script_control").change(function () { |
| 1955 |
|
| 1956 |
if ($('#wpvr_video_script_control').is(':checked')) { |
| 1957 |
|
| 1958 |
$(".wpvr_enqueue_video_script_list").show(); |
| 1959 |
|
| 1960 |
} else { |
| 1961 |
|
| 1962 |
$(".wpvr_enqueue_video_script_list").hide(); |
| 1963 |
} |
| 1964 |
|
| 1965 |
}); |
| 1966 |
|
| 1967 |
|
| 1968 |
/** |
| 1969 |
* Nasim |
| 1970 |
* Check enable script button is on or not |
| 1971 |
* if on then script list field will be show and if off then script list field will be hide |
| 1972 |
*/ |
| 1973 |
if ($('#wpvr_script_control').is(':checked')) { |
| 1974 |
|
| 1975 |
$(".wpvr_enqueue_script_list").show(); |
| 1976 |
|
| 1977 |
} else { |
| 1978 |
|
| 1979 |
$(".wpvr_enqueue_script_list").hide(); |
| 1980 |
} |
| 1981 |
|
| 1982 |
/** |
| 1983 |
* Sakib |
| 1984 |
* Check enable script button is on or not |
| 1985 |
* if on then script list field will be show and if off then script list field will be hide |
| 1986 |
*/ |
| 1987 |
if ($('#wpvr_video_script_control').is(':checked')) { |
| 1988 |
|
| 1989 |
$(".wpvr_enqueue_video_script_list").show(); |
| 1990 |
|
| 1991 |
} else { |
| 1992 |
|
| 1993 |
$(".wpvr_enqueue_video_script_list").hide(); |
| 1994 |
} |
| 1995 |
|
| 1996 |
/** |
| 1997 |
* Hides the alert in the settings footer area after a 2000ms delay. |
| 1998 |
* |
| 1999 |
* @return {void} No return value |
| 2000 |
*/ |
| 2001 |
function remove_alert(){ |
| 2002 |
setTimeout(function(){ |
| 2003 |
$('.settings-footer-area .wpvr-alert').hide(); |
| 2004 |
}, 2000); |
| 2005 |
} |
| 2006 |
|
| 2007 |
$(document).on("click", "#wpvr_role_submit", function (e) { |
| 2008 |
e.preventDefault(); |
| 2009 |
var ajaxurl = wpvr_obj.ajaxurl; |
| 2010 |
$(this).children().css('display', 'inline-block'); |
| 2011 |
|
| 2012 |
$('#wpvr_role_submit').attr('disabled', true); |
| 2013 |
var editor = $('#wpvr_editor_active').is(':checked'); |
| 2014 |
var author = $('#wpvr_author_active').is(':checked'); |
| 2015 |
var fontawesome = $('#wpvr_fontawesome_disable').is(':checked'); |
| 2016 |
var mobile_media_resize = $('#mobile_media_resize').is(':checked'); |
| 2017 |
var wpvr_frontend_notice = $('#wpvr_frontend_notice').is(':checked'); |
| 2018 |
var wpvr_frontend_notice_area = $('#wpvr_frontend_notice_area').val(); |
| 2019 |
var wpvr_script_control = $('#wpvr_script_control').is(':checked'); |
| 2020 |
var wpvr_script_list = $('#wpvr_script_list').val(); |
| 2021 |
var wpvr_video_script_control = $('#wpvr_video_script_control').is(':checked'); |
| 2022 |
var wpvr_video_script_list = $('#wpvr_video_script_list').val(); |
| 2023 |
var high_res_image = $('#high_res_image').is(':checked'); |
| 2024 |
var dis_on_hover = $('#dis_on_hover').is(':checked'); |
| 2025 |
var dokan_vendor = $('#wpvr_dokan_vendor_active').is(':checked'); |
| 2026 |
|
| 2027 |
/** |
| 2028 |
* check enable script button is on and script list field is not empty |
| 2029 |
*/ |
| 2030 |
if ( ($('#wpvr_video_script_control').is(':checked') && wpvr_video_script_list == '') || ($('#wpvr_script_control').is(':checked') && wpvr_script_list == '') ) { |
| 2031 |
if(($('#wpvr_script_control').is(':checked') && wpvr_script_list == '')){ |
| 2032 |
if (confirm('The "List of Allowed Pages To Load WP VR Scripts " Field Is Empty. No Virtual Tours Will Show Up on Your Site.')) { |
| 2033 |
if($('#wpvr_video_script_control').is(':checked') && wpvr_video_script_list == ''){ |
| 2034 |
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.")) { |
| 2035 |
jQuery.ajax({ |
| 2036 |
type: "POST", |
| 2037 |
url: ajaxurl, |
| 2038 |
data: { |
| 2039 |
action: "wpvr_role_management", |
| 2040 |
nonce : wpvr_obj.ajax_nonce, |
| 2041 |
editor: editor, |
| 2042 |
author: author, |
| 2043 |
fontawesome: fontawesome, |
| 2044 |
mobile_media_resize: mobile_media_resize, |
| 2045 |
high_res_image: high_res_image, |
| 2046 |
dis_on_hover: dis_on_hover, |
| 2047 |
wpvr_frontend_notice: wpvr_frontend_notice, |
| 2048 |
wpvr_frontend_notice_area: wpvr_frontend_notice_area, |
| 2049 |
wpvr_script_control: wpvr_script_control, |
| 2050 |
wpvr_script_list: wpvr_script_list, |
| 2051 |
wpvr_video_script_control: wpvr_video_script_control, |
| 2052 |
wpvr_video_script_list: wpvr_video_script_list, |
| 2053 |
dokan_vendor: dokan_vendor, |
| 2054 |
// woocommerce: woocommerce, |
| 2055 |
}, |
| 2056 |
success: function (response) { |
| 2057 |
$('#wpvr_role_submit .wpvr-loader').css('display', 'none'); |
| 2058 |
$('#wpvr_role_submit').attr('disabled', false); |
| 2059 |
|
| 2060 |
if (response.status == 'success') { |
| 2061 |
$('.settings-footer-area .wpvr-alert').text(response.message).show(); |
| 2062 |
} |
| 2063 |
|
| 2064 |
remove_alert(); |
| 2065 |
|
| 2066 |
} |
| 2067 |
}); |
| 2068 |
} else { |
| 2069 |
$('#wpvr_role_submit .wpvr-loader').css('display', 'none'); |
| 2070 |
$('#wpvr_role_submit').attr('disabled', false); |
| 2071 |
} |
| 2072 |
}else{ |
| 2073 |
jQuery.ajax({ |
| 2074 |
type: "POST", |
| 2075 |
url: ajaxurl, |
| 2076 |
data: { |
| 2077 |
action: "wpvr_role_management", |
| 2078 |
nonce : wpvr_obj.ajax_nonce, |
| 2079 |
editor: editor, |
| 2080 |
author: author, |
| 2081 |
fontawesome: fontawesome, |
| 2082 |
mobile_media_resize: mobile_media_resize, |
| 2083 |
high_res_image: high_res_image, |
| 2084 |
wpvr_frontend_notice: wpvr_frontend_notice, |
| 2085 |
wpvr_frontend_notice_area: wpvr_frontend_notice_area, |
| 2086 |
wpvr_script_control: wpvr_script_control, |
| 2087 |
wpvr_script_list: wpvr_script_list, |
| 2088 |
wpvr_video_script_control: wpvr_video_script_control, |
| 2089 |
wpvr_video_script_list: wpvr_video_script_list, |
| 2090 |
dokan_vendor: dokan_vendor, |
| 2091 |
// woocommerce: woocommerce, |
| 2092 |
}, |
| 2093 |
success: function (response) { |
| 2094 |
$('#wpvr_role_submit .wpvr-loader').css('display', 'none'); |
| 2095 |
$('#wpvr_role_submit').attr('disabled', false); |
| 2096 |
|
| 2097 |
if (response.status == 'success') { |
| 2098 |
$('.settings-footer-area .wpvr-alert').text(response.message).show(); |
| 2099 |
} |
| 2100 |
|
| 2101 |
remove_alert(); |
| 2102 |
|
| 2103 |
} |
| 2104 |
}); |
| 2105 |
} |
| 2106 |
} else { |
| 2107 |
$('#wpvr_role_submit .wpvr-loader').css('display', 'none'); |
| 2108 |
$('#wpvr_role_submit').attr('disabled', false); |
| 2109 |
} |
| 2110 |
}else if($('#wpvr_video_script_control').is(':checked') && wpvr_video_script_list == ''){ |
| 2111 |
|
| 2112 |
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.")) { |
| 2113 |
if(($('#wpvr_script_control').is(':checked') && wpvr_script_list == '')){ |
| 2114 |
if (confirm('The "List of Allowed Pages To Load WP VR Scripts " Field Is Empty. No Virtual Tours Will Show Up on Your Site.')) { |
| 2115 |
jQuery.ajax({ |
| 2116 |
type: "POST", |
| 2117 |
url: ajaxurl, |
| 2118 |
data: { |
| 2119 |
action: "wpvr_role_management", |
| 2120 |
nonce : wpvr_obj.ajax_nonce, |
| 2121 |
editor: editor, |
| 2122 |
author: author, |
| 2123 |
fontawesome: fontawesome, |
| 2124 |
mobile_media_resize: mobile_media_resize, |
| 2125 |
high_res_image: high_res_image, |
| 2126 |
dis_on_hover: dis_on_hover, |
| 2127 |
wpvr_frontend_notice: wpvr_frontend_notice, |
| 2128 |
wpvr_frontend_notice_area: wpvr_frontend_notice_area, |
| 2129 |
wpvr_script_control: wpvr_script_control, |
| 2130 |
wpvr_script_list: wpvr_script_list, |
| 2131 |
wpvr_video_script_control: wpvr_video_script_control, |
| 2132 |
wpvr_video_script_list: wpvr_video_script_list, |
| 2133 |
dokan_vendor: dokan_vendor, |
| 2134 |
// woocommerce: woocommerce, |
| 2135 |
}, |
| 2136 |
success: function (response) { |
| 2137 |
$('#wpvr_role_submit .wpvr-loader').css('display', 'none'); |
| 2138 |
$('#wpvr_role_submit').attr('disabled', false); |
| 2139 |
|
| 2140 |
if (response.status == 'success') { |
| 2141 |
$('.settings-footer-area .wpvr-alert').text(response.message).show(); |
| 2142 |
} |
| 2143 |
remove_alert(); |
| 2144 |
|
| 2145 |
} |
| 2146 |
}); |
| 2147 |
}else { |
| 2148 |
$('#wpvr_role_submit .wpvr-loader').css('display', 'none'); |
| 2149 |
$('#wpvr_role_submit').attr('disabled', false); |
| 2150 |
} |
| 2151 |
}else{ |
| 2152 |
jQuery.ajax({ |
| 2153 |
type: "POST", |
| 2154 |
url: ajaxurl, |
| 2155 |
data: { |
| 2156 |
action: "wpvr_role_management", |
| 2157 |
nonce : wpvr_obj.ajax_nonce, |
| 2158 |
editor: editor, |
| 2159 |
author: author, |
| 2160 |
fontawesome: fontawesome, |
| 2161 |
mobile_media_resize: mobile_media_resize, |
| 2162 |
high_res_image: high_res_image, |
| 2163 |
dis_on_hover: dis_on_hover, |
| 2164 |
wpvr_frontend_notice: wpvr_frontend_notice, |
| 2165 |
wpvr_frontend_notice_area: wpvr_frontend_notice_area, |
| 2166 |
wpvr_script_control: wpvr_script_control, |
| 2167 |
wpvr_script_list: wpvr_script_list, |
| 2168 |
wpvr_video_script_control: wpvr_video_script_control, |
| 2169 |
wpvr_video_script_list: wpvr_video_script_list, |
| 2170 |
dokan_vendor: dokan_vendor, |
| 2171 |
// woocommerce: woocommerce, |
| 2172 |
}, |
| 2173 |
success: function (response) { |
| 2174 |
$('#wpvr_role_submit .wpvr-loader').css('display', 'none'); |
| 2175 |
$('#wpvr_role_submit').attr('disabled', false); |
| 2176 |
|
| 2177 |
if (response.status == 'success') { |
| 2178 |
$('.settings-footer-area .wpvr-alert').text(response.message).show(); |
| 2179 |
} |
| 2180 |
|
| 2181 |
remove_alert(); |
| 2182 |
|
| 2183 |
} |
| 2184 |
}); |
| 2185 |
} |
| 2186 |
} else { |
| 2187 |
$('#wpvr_role_submit .wpvr-loader').css('display', 'none'); |
| 2188 |
$('#wpvr_role_submit').attr('disabled', false); |
| 2189 |
} |
| 2190 |
} |
| 2191 |
|
| 2192 |
} else { |
| 2193 |
jQuery.ajax({ |
| 2194 |
type: "POST", |
| 2195 |
url: ajaxurl, |
| 2196 |
data: { |
| 2197 |
action: "wpvr_role_management", |
| 2198 |
nonce : wpvr_obj.ajax_nonce, |
| 2199 |
editor: editor, |
| 2200 |
author: author, |
| 2201 |
fontawesome: fontawesome, |
| 2202 |
mobile_media_resize: mobile_media_resize, |
| 2203 |
high_res_image: high_res_image, |
| 2204 |
dis_on_hover: dis_on_hover, |
| 2205 |
wpvr_frontend_notice: wpvr_frontend_notice, |
| 2206 |
wpvr_frontend_notice_area: wpvr_frontend_notice_area, |
| 2207 |
wpvr_script_control: wpvr_script_control, |
| 2208 |
wpvr_script_list: wpvr_script_list, |
| 2209 |
wpvr_video_script_control: wpvr_video_script_control, |
| 2210 |
wpvr_video_script_list: wpvr_video_script_list, |
| 2211 |
dokan_vendor: dokan_vendor, |
| 2212 |
}, |
| 2213 |
success: function (response) { |
| 2214 |
$('#wpvr_role_submit .wpvr-loader').css('display', 'none'); |
| 2215 |
$('#wpvr_role_submit').attr('disabled', false); |
| 2216 |
if (response.status == 'success') { |
| 2217 |
$('.settings-footer-area .wpvr-alert').text(response.message).show(); |
| 2218 |
} |
| 2219 |
|
| 2220 |
remove_alert(); |
| 2221 |
} |
| 2222 |
}); |
| 2223 |
} |
| 2224 |
|
| 2225 |
|
| 2226 |
|
| 2227 |
}); |
| 2228 |
|
| 2229 |
|
| 2230 |
//-----------reset button---------- |
| 2231 |
$(document).on("click", "#wpvr_role_reset", function (e) { |
| 2232 |
e.preventDefault(); |
| 2233 |
$(this).attr('disabled', true); |
| 2234 |
|
| 2235 |
var confirmation = confirm('All settings will be reset to default. Are you sure?'); |
| 2236 |
// Code to reset settings to default if the user clicks "Yes" |
| 2237 |
if (confirmation) { |
| 2238 |
$('#wpvr_editor_active').prop('checked', false); |
| 2239 |
$('#wpvr_author_active').prop('checked', false); |
| 2240 |
$('#wpvr_fontawesome_disable').prop('checked', false); |
| 2241 |
$('#mobile_media_resize').prop('checked', false); |
| 2242 |
$('#wpvr_frontend_notice').prop('checked', false); |
| 2243 |
$('#wpvr_script_control').prop('checked', false); |
| 2244 |
$('#wpvr_video_script_control').prop('checked', false); |
| 2245 |
$('#high_res_image').prop('checked', false); |
| 2246 |
$('#dis_on_hover').prop('checked', false); |
| 2247 |
$('#wpvr_dokan_vendor_active').prop('checked', false); |
| 2248 |
$(".wpvr_enqueue_video_script_list").hide(); |
| 2249 |
$(".wpvr_enqueue_script_list").hide(); |
| 2250 |
|
| 2251 |
$("#wpvr_role_submit").trigger('click'); |
| 2252 |
} |
| 2253 |
$(this).attr('disabled', false); |
| 2254 |
|
| 2255 |
}); |
| 2256 |
|
| 2257 |
//------general tab's inner tab------- |
| 2258 |
jQuery(document).ready(function ($) { |
| 2259 |
|
| 2260 |
$('.general-inner-tab .inner-nav li span').on('click', function () { |
| 2261 |
var this_id = $(this).attr('data-href'); |
| 2262 |
|
| 2263 |
$(this).parent('li').addClass('active'); |
| 2264 |
$(this).parent('li').siblings().removeClass('active'); |
| 2265 |
|
| 2266 |
$(this_id).show(); |
| 2267 |
$(this_id).siblings().hide(); |
| 2268 |
}); |
| 2269 |
}); |
| 2270 |
|
| 2271 |
//------active tab scripts------- |
| 2272 |
jQuery(document).ready(function ($) { |
| 2273 |
|
| 2274 |
function getUrlVars() { |
| 2275 |
var vars = [], |
| 2276 |
hash; |
| 2277 |
var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); |
| 2278 |
for (var i = 0; i < hashes.length; i++) { |
| 2279 |
hash = hashes[i].split('='); |
| 2280 |
vars.push(hash[0]); |
| 2281 |
vars[hash[0]] = hash[1]; |
| 2282 |
} |
| 2283 |
return vars; |
| 2284 |
} |
| 2285 |
var activeTab = 'general', |
| 2286 |
vr_main_tab = $('#wpvr-main-nav'), |
| 2287 |
var_main_tab_contents = $('#wpvr-main-tab-contents').find('.rex-pano-tab').not(".single-scene,.single-hotspot"), |
| 2288 |
scene_content = $('.scene-content'), |
| 2289 |
scene_nav = $('.scene-nav'), |
| 2290 |
single_scene = $('.single-scene'), |
| 2291 |
hotspot_content = $('.hotspot-setup'), |
| 2292 |
single_hotspot = $('.single-hotspot'), |
| 2293 |
delete_scene_btn = $('.delete-scene'), |
| 2294 |
delete_hotspot_btn = $('.delete-hotspot'); |
| 2295 |
|
| 2296 |
var _q_activeTab = getUrlVars()["active_tab"]; |
| 2297 |
var _sceneID = getUrlVars()["scene"]; |
| 2298 |
var _hotspotID = getUrlVars()["hotspot"]; |
| 2299 |
var default_tabs = ['general', 'scene', 'hotspot', 'video']; |
| 2300 |
if (_q_activeTab) { |
| 2301 |
if (default_tabs.includes(_q_activeTab)) { |
| 2302 |
activeTab = _q_activeTab; |
| 2303 |
if(activeTab == "video" ){ |
| 2304 |
vr_main_tab.find('li:not(:first)').removeClass('active'); |
| 2305 |
vr_main_tab.find(".videos").addClass('active'); |
| 2306 |
}else{ |
| 2307 |
vr_main_tab.find('li:not(:first)').removeClass('active'); |
| 2308 |
vr_main_tab.find('.' + activeTab).addClass('active'); |
| 2309 |
} |
| 2310 |
|
| 2311 |
// scene screens |
| 2312 |
var_main_tab_contents.addClass('active'); |
| 2313 |
if (activeTab === 'scene' || activeTab === 'hotspot') { |
| 2314 |
var_main_tab_contents.not('#scenes').removeClass('active'); |
| 2315 |
} else { |
| 2316 |
var_main_tab_contents.not('#' + activeTab).removeClass('active'); |
| 2317 |
} |
| 2318 |
if(activeTab === 'hotspot'){ |
| 2319 |
$(".rex-pano-nav-menu.main-nav ul li.hotspot span").trigger('click') |
| 2320 |
} |
| 2321 |
|
| 2322 |
// scene contents |
| 2323 |
if (_sceneID) { |
| 2324 |
var scenesIds = []; |
| 2325 |
var sceneID = '#scene-' + _sceneID; |
| 2326 |
var scene_nav_items = scene_nav.find('li'); |
| 2327 |
scene_nav.find('li').each(function () { |
| 2328 |
var index = $(this).find('span').attr('data-index'); |
| 2329 |
if (index) { |
| 2330 |
scenesIds.push(index); |
| 2331 |
} |
| 2332 |
}); |
| 2333 |
if (scenesIds.includes(_sceneID)) { |
| 2334 |
scene_nav_items.removeClass('active'); |
| 2335 |
scene_nav.find('li').each(function () { |
| 2336 |
var index = $(this).find('span').attr('data-index'); |
| 2337 |
if (_sceneID == index) { |
| 2338 |
$(this).addClass('active'); |
| 2339 |
} |
| 2340 |
}); |
| 2341 |
if (activeTab == 'scene' || _sceneID) { |
| 2342 |
single_scene.removeClass('active'); |
| 2343 |
$(sceneID).addClass('active'); |
| 2344 |
} |
| 2345 |
} else { |
| 2346 |
scene_nav.find('li:first').addClass('active'); |
| 2347 |
} |
| 2348 |
|
| 2349 |
if (activeTab === 'scene') { |
| 2350 |
if (scenesIds.includes(_sceneID)) { |
| 2351 |
$(single_scene).removeClass('active'); |
| 2352 |
$(sceneID).addClass('active'); |
| 2353 |
} |
| 2354 |
} else { |
| 2355 |
$(delete_scene_btn).hide(); |
| 2356 |
$(scene_nav).hide(); |
| 2357 |
$('.scene-content').hide(); |
| 2358 |
$(sceneID).find('.hotspot-setup').show(); |
| 2359 |
} |
| 2360 |
|
| 2361 |
//hotspot contents |
| 2362 |
var hotspot_nav = $('.single-scene.active').find('.hotspot-nav'); |
| 2363 |
var hotspotIds = []; |
| 2364 |
var hotspot_nav_items = $('.single-scene.active').find('.hotspot-nav').find('li'); |
| 2365 |
var activeHotspotId = '#scene-' + _sceneID + 'hotspot-' + _hotspotID; |
| 2366 |
hotspot_nav_items.each(function () { |
| 2367 |
var index = $(this).find('span').attr('data-index'); |
| 2368 |
if (index) { |
| 2369 |
hotspotIds.push(index); |
| 2370 |
activeHotspotId = $(this).find('span').attr('data-href'); |
| 2371 |
} |
| 2372 |
}); |
| 2373 |
if (hotspotIds.includes(_hotspotID)) { |
| 2374 |
hotspot_nav_items.removeClass('active'); |
| 2375 |
hotspot_nav.find('li').each(function () { |
| 2376 |
var index = $(this).find('span').attr('data-index'); |
| 2377 |
if (_hotspotID === index) { |
| 2378 |
$(this).addClass('active'); |
| 2379 |
} |
| 2380 |
}); |
| 2381 |
if (activeHotspotId) { |
| 2382 |
$(sceneID).find('.single-hotspot').removeClass('active'); |
| 2383 |
$(activeHotspotId).addClass('active'); |
| 2384 |
} |
| 2385 |
} |
| 2386 |
} |
| 2387 |
} |
| 2388 |
} |
| 2389 |
|
| 2390 |
|
| 2391 |
$(document).on("click", ".wpvr-help-resource__video-section", function () { |
| 2392 |
$('#wpvr-help-video-iframe').attr('src', 'https://www.youtube.com/embed/kKHUlVKtesQ'); |
| 2393 |
if($('#wpvr-help-video-iframe').attr('src') != ''){ |
| 2394 |
$(".wpvr-iframe-modal").show(); |
| 2395 |
} |
| 2396 |
}); |
| 2397 |
|
| 2398 |
|
| 2399 |
$(document).on("click", ".wpvr-iframe-modal__cross-icon", function () { |
| 2400 |
$(".wpvr-iframe-modal").hide(); |
| 2401 |
var videoPlayer =$('#wpvr-help-video-iframe'); |
| 2402 |
videoPlayer.attr('src', ''); |
| 2403 |
|
| 2404 |
}); |
| 2405 |
|
| 2406 |
|
| 2407 |
|
| 2408 |
}); |
| 2409 |
|
| 2410 |
$(document).on("click", ".wpvr_url_open", function (event) { |
| 2411 |
if ($(this).val() == 'off') { |
| 2412 |
$(this).val('on'); |
| 2413 |
} |
| 2414 |
else { |
| 2415 |
$(this).val('off'); |
| 2416 |
} |
| 2417 |
}); |
| 2418 |
|
| 2419 |
$(document).ready(function() { |
| 2420 |
$('textarea[name*=hotspot-content]').summernote({ |
| 2421 |
toolbar: [ |
| 2422 |
['style', ['style']], |
| 2423 |
['font', ['bold', 'underline', 'clear']], |
| 2424 |
['fontname', ['fontname']], |
| 2425 |
['color', ['color']], |
| 2426 |
['para', ['ul', 'ol', 'paragraph']], |
| 2427 |
['table', ['table']], |
| 2428 |
['insert', ['link', 'picture', 'video']], |
| 2429 |
['view', ['codeview', 'help']], |
| 2430 |
], |
| 2431 |
callbacks: { |
| 2432 |
onKeyup: function(e) { |
| 2433 |
var getHotspotContent = $(this).summernote('code').trim(); |
| 2434 |
var tempDiv = document.createElement('div'); |
| 2435 |
tempDiv.innerHTML = getHotspotContent; |
| 2436 |
var plainText = tempDiv.textContent || tempDiv.innerText || ''; |
| 2437 |
plainText = plainText.replace(/\u00a0/g, '').trim(); |
| 2438 |
var getParent = $(this).parent(); |
| 2439 |
var getMainParent = getParent.parent(); |
| 2440 |
var getClickContent = getMainParent.find('.hotspot-url'); |
| 2441 |
|
| 2442 |
if (plainText.length > 0) { |
| 2443 |
getClickContent.find('input[name*=hotspot-url]').val(''); |
| 2444 |
getClickContent.find('input[name*=hotspot-url]').attr('placeholder', 'You can set either a URL or an On-click content'); |
| 2445 |
getClickContent.find('input[name*=hotspot-url]').attr("disabled", true); |
| 2446 |
} else { |
| 2447 |
getClickContent.find('input[name*=hotspot-url]').attr("disabled", false); |
| 2448 |
} |
| 2449 |
} |
| 2450 |
} |
| 2451 |
}); |
| 2452 |
$('textarea[name*=hotspot-hover]').summernote({ |
| 2453 |
toolbar: [ |
| 2454 |
['style', ['style']], |
| 2455 |
['font', ['bold', 'underline', 'clear']], |
| 2456 |
['fontname', ['fontname']], |
| 2457 |
['color', ['color']], |
| 2458 |
['para', ['ul', 'ol', 'paragraph']], |
| 2459 |
['table', ['table']], |
| 2460 |
['insert', ['link', 'picture', 'video']], |
| 2461 |
['view', ['codeview', 'help']], |
| 2462 |
], |
| 2463 |
fontNames: ['Arial', 'Helvetica', 'Tahoma', 'Courier New', 'Verdana', 'Impact', 'Times New Roman', 'system-ui', 'Helvetica Neue'], |
| 2464 |
callbacks: { |
| 2465 |
onInit: function() { |
| 2466 |
var $editor = $(this); |
| 2467 |
|
| 2468 |
// Override font name dropdown click handler for this specific editor |
| 2469 |
$editor.next('.note-editor').find('.dropdown-fontname a').off('click').on('click', function(e) { |
| 2470 |
e.preventDefault(); |
| 2471 |
var fontName = $(this).data('value') || $(this).text(); |
| 2472 |
|
| 2473 |
// Focus on the current editor |
| 2474 |
$editor.summernote('focus'); |
| 2475 |
|
| 2476 |
// Use Summernote's built-in method to apply font |
| 2477 |
try { |
| 2478 |
// First, clear any existing font formatting |
| 2479 |
var range = $editor.summernote('createRange'); |
| 2480 |
if (range && !range.isCollapsed()) { |
| 2481 |
// Get selected text |
| 2482 |
var selectedText = range.toString(); |
| 2483 |
|
| 2484 |
// Use Summernote's insertHTML to replace content |
| 2485 |
var fontHtml = '<span style="font-family: ' + fontName + ';">' + selectedText + '</span>'; |
| 2486 |
$editor.summernote('insertHTML', fontHtml); |
| 2487 |
} else { |
| 2488 |
// No selection, use execCommand for typing |
| 2489 |
$editor.summernote('focus'); |
| 2490 |
document.execCommand('fontName', false, fontName); |
| 2491 |
} |
| 2492 |
} catch (error) { |
| 2493 |
console.log('Font application error, using fallback method'); |
| 2494 |
// Fallback method |
| 2495 |
document.execCommand('fontName', false, fontName); |
| 2496 |
} |
| 2497 |
|
| 2498 |
// Update dropdown button text for this editor |
| 2499 |
$(this).closest('.note-editor').find('.note-current-fontname').text(fontName); |
| 2500 |
|
| 2501 |
// Close dropdown |
| 2502 |
var $dropdownMenu = $(this).closest('.dropdown-menu'); |
| 2503 |
$dropdownMenu.removeClass('show').hide(); |
| 2504 |
$dropdownMenu.prev('.dropdown-toggle').removeClass('show').attr('aria-expanded', 'false'); |
| 2505 |
|
| 2506 |
// Trigger change event |
| 2507 |
setTimeout(function() { |
| 2508 |
$editor.trigger('summernote.change'); |
| 2509 |
}, 100); |
| 2510 |
}); |
| 2511 |
}, |
| 2512 |
|
| 2513 |
// Clean up the content after any change |
| 2514 |
onChange: function(contents, $editable) { |
| 2515 |
// Debounce the cleanup to avoid conflicts |
| 2516 |
clearTimeout(this.cleanupTimeout); |
| 2517 |
this.cleanupTimeout = setTimeout(function() { |
| 2518 |
// Remove all font-family styles from elements that shouldn't have them |
| 2519 |
$editable.find('*:not(span)').each(function() { |
| 2520 |
if (this.style && this.style.fontFamily) { |
| 2521 |
this.style.fontFamily = ''; |
| 2522 |
} |
| 2523 |
}); |
| 2524 |
|
| 2525 |
// Clean up empty spans |
| 2526 |
$editable.find('span').each(function() { |
| 2527 |
var $span = $(this); |
| 2528 |
var text = $span.text().replace(/[\uFEFF\u200B-\u200D\u2060]/g, '').trim(); |
| 2529 |
|
| 2530 |
if (!text) { |
| 2531 |
$span.remove(); |
| 2532 |
} else { |
| 2533 |
// If span has other styles besides font-family, keep only font-family |
| 2534 |
var fontFamily = $span.css('font-family'); |
| 2535 |
if (fontFamily && fontFamily !== 'inherit') { |
| 2536 |
$span.attr('style', 'font-family: ' + fontFamily + ';'); |
| 2537 |
} else if (!fontFamily || fontFamily === 'inherit') { |
| 2538 |
$span.contents().unwrap(); |
| 2539 |
} |
| 2540 |
} |
| 2541 |
}); |
| 2542 |
|
| 2543 |
// Remove nested spans with font-family |
| 2544 |
$editable.find('span[style*="font-family"] span[style*="font-family"]').each(function() { |
| 2545 |
$(this).contents().unwrap(); |
| 2546 |
}); |
| 2547 |
}, 200); |
| 2548 |
} |
| 2549 |
} |
| 2550 |
}); |
| 2551 |
}); |
| 2552 |
|
| 2553 |
$(document).on("submit", "#trigger-rollback", function (event) { |
| 2554 |
event.preventDefault(); |
| 2555 |
if(confirm('Are you sure?')) { |
| 2556 |
let version = $("#trigger-rollback").serialize(); |
| 2557 |
let redirectUrl = wpvr_global_obj.url_info.admin_url + 'admin.php?' + version; |
| 2558 |
window.location.href = redirectUrl; |
| 2559 |
} |
| 2560 |
}); |
| 2561 |
|
| 2562 |
$(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) { |
| 2563 |
event.preventDefault(); |
| 2564 |
$("#wpvr_premium_feature_popup").show(); |
| 2565 |
}); |
| 2566 |
|
| 2567 |
|
| 2568 |
|
| 2569 |
$(document).on("click", "#wpvr_premium_feature_close", function () { |
| 2570 |
$("#wpvr_premium_feature_popup").hide(); |
| 2571 |
}); |
| 2572 |
|
| 2573 |
|
| 2574 |
$(document).on("click", ".wpvr-help-resource__dropdown-section", function () { |
| 2575 |
// When an element with the class 'wpvr-help-resource__dropdown-section' is clicked, |
| 2576 |
// toggle the 'show-dropdown' class on its siblings. |
| 2577 |
$(this).siblings().toggleClass("show-dropdown"); |
| 2578 |
}); |
| 2579 |
|
| 2580 |
$(document).on("click", ".wpvr-layout__radio-container", function () { |
| 2581 |
let findLayout = $(this).find('.wpvr-layout__radio-label').data('layout'); |
| 2582 |
if(findLayout == 'layout1'){ |
| 2583 |
event.preventDefault(); |
| 2584 |
$('#wpvr_premium_feature_popup').show(); |
| 2585 |
} |
| 2586 |
}); |
| 2587 |
|
| 2588 |
// ------window on scroll add class to comparison table header------ |
| 2589 |
$(window).on('scroll', function() { |
| 2590 |
var $header = $('.wpvr-compare .list-header'); |
| 2591 |
|
| 2592 |
if ($header.length > 0) { |
| 2593 |
var headerOffset = $header.offset().top - $(window).scrollTop(); |
| 2594 |
|
| 2595 |
if (headerOffset < 27) { |
| 2596 |
$header.addClass('sticked'); |
| 2597 |
} else { |
| 2598 |
$header.removeClass('sticked'); |
| 2599 |
} |
| 2600 |
|
| 2601 |
} |
| 2602 |
|
| 2603 |
}); |
| 2604 |
|
| 2605 |
$(document).ready(function() { |
| 2606 |
handle_add_pitch_button(); |
| 2607 |
toggleSceneGallery(); |
| 2608 |
}); |
| 2609 |
|
| 2610 |
$(document).on( 'mousedown', 'div.pnlm-dragfix', () => { handle_add_pitch_button() } ); |
| 2611 |
|
| 2612 |
function get_active_tab() { |
| 2613 |
let activeTab = $('#wpvr_active_tab').val() ?? null; |
| 2614 |
if ( !activeTab ) { |
| 2615 |
activeTab = $(".rex-pano-tab-nav li.active").data('screen'); |
| 2616 |
} |
| 2617 |
return activeTab; |
| 2618 |
} |
| 2619 |
|
| 2620 |
function handle_add_pitch_button( activeTab = null ) { |
| 2621 |
activeTab = activeTab === null ? get_active_tab() : activeTab; |
| 2622 |
|
| 2623 |
if(handle_hotspot_tab(activeTab, true)) |
| 2624 |
return; |
| 2625 |
|
| 2626 |
if( activeTab && 'hotspot' === activeTab && '' !== $( "#panodata" ).html().trim() ) { |
| 2627 |
$(".add-pitch").removeClass('rex-hide-coordinates'); |
| 2628 |
} |
| 2629 |
else { |
| 2630 |
$(".add-pitch").addClass('rex-hide-coordinates'); |
| 2631 |
} |
| 2632 |
|
| 2633 |
if('video' === activeTab){ |
| 2634 |
$(".rex-add-coordinates").addClass('rex-hide-coordinates'); |
| 2635 |
}else{ |
| 2636 |
$(".rex-add-coordinates").removeClass('rex-hide-coordinates'); |
| 2637 |
} |
| 2638 |
|
| 2639 |
if( 'streetview' === activeTab || 'video' === activeTab || $('.videos.active').length ) { |
| 2640 |
$('#wpvr_item_tour_checklist__box').css('display', 'none'); |
| 2641 |
}else{ |
| 2642 |
$('#wpvr_item_tour_checklist__box').css('display', 'block'); |
| 2643 |
} |
| 2644 |
|
| 2645 |
} |
| 2646 |
|
| 2647 |
$(document).ready(function() { |
| 2648 |
$(".rex-pano-tab-nav li").on( 'click', function() { |
| 2649 |
var activeTab = jQuery(this).data('screen'); |
| 2650 |
if(handle_hotspot_tab(activeTab, false)) |
| 2651 |
return false; |
| 2652 |
}); |
| 2653 |
}); |
| 2654 |
|
| 2655 |
function handle_hotspot_tab(activeTab, redirect) { |
| 2656 |
let isReturn = false; |
| 2657 |
if (activeTab && 'hotspot' === activeTab) { |
| 2658 |
const activeScene = jQuery('.scene-nav li.active span').attr('data-index'); |
| 2659 |
const activeSceneId = $('#scene-' + activeScene).find(".form-group img").attr('src'); |
| 2660 |
let activeTabUrl = window?.wpvr_global_obj?.active_tab_url; |
| 2661 |
if (!activeSceneId && redirect) { |
| 2662 |
window.location.replace(activeTabUrl); |
| 2663 |
isReturn = true; |
| 2664 |
} else if(!activeSceneId && !redirect){ |
| 2665 |
alert(window?.wpvr_global_obj?.hotspot_warning_text); |
| 2666 |
jQuery('.rex-pano-tab-nav li scene').addClass('active'); |
| 2667 |
isReturn = true; |
| 2668 |
} |
| 2669 |
} |
| 2670 |
return isReturn; |
| 2671 |
} |
| 2672 |
|
| 2673 |
|
| 2674 |
function toggleSceneGallery(activeTab = null) { |
| 2675 |
activeTab = activeTab === null ? get_active_tab() : activeTab; |
| 2676 |
if (activeTab && 'video' === activeTab) { |
| 2677 |
jQuery('.scene-gallery').hide(); |
| 2678 |
} else { |
| 2679 |
jQuery('.scene-gallery').show(); |
| 2680 |
} |
| 2681 |
} |
| 2682 |
|
| 2683 |
// Function to update the progress bar |
| 2684 |
function updateProgress() { |
| 2685 |
let totalItems = $('.wpvr-checklist-items').length; // Total number of checklist items |
| 2686 |
let checkedItems = $('.wpvr-checklist-items:checked').length; // Number of checked items |
| 2687 |
|
| 2688 |
// Calculate progress percentage |
| 2689 |
let progress = Math.round((checkedItems / totalItems) * 100); |
| 2690 |
|
| 2691 |
// Update progress bar |
| 2692 |
$('#wpvr-progress-bar').css('width', progress + '%'); |
| 2693 |
$('#wpvr-progress-text').text(progress + '%'); |
| 2694 |
|
| 2695 |
// Change color of progress bar based on progress |
| 2696 |
if (progress === 100) { |
| 2697 |
$('#wpvr-progress-bar').css('background-color', 'green'); |
| 2698 |
$('#wpvr-progress-text').css('color', 'white'); |
| 2699 |
}else{ |
| 2700 |
$('#wpvr-progress-text').css('color', '#3F04FE'); |
| 2701 |
} |
| 2702 |
} |
| 2703 |
|
| 2704 |
updateProgress(); |
| 2705 |
|
| 2706 |
$(document).on("click", ".toppitch", function () { |
| 2707 |
if (!$('#wpvr-check-hotspots').is(':checked')) { |
| 2708 |
$('#wpvr-check-hotspots').prop('checked', true); |
| 2709 |
$('#wpvr-check-hotspots').closest('.wpvr-checklist-item').css('color', '#0E003C'); |
| 2710 |
} |
| 2711 |
updateProgress(); |
| 2712 |
}); |
| 2713 |
|
| 2714 |
|
| 2715 |
$(document).ready(function() { |
| 2716 |
$(".rex-pano-tab .inner-nav-content .single-settings.has-children .vr-switcher-check").each(function() { |
| 2717 |
if ($(this).is(':checked')) { |
| 2718 |
$(this).parents('.single-settings').addClass('margin-bottom-remove'); |
| 2719 |
} else { |
| 2720 |
$(this).parents('.single-settings').removeClass('margin-bottom-remove'); |
| 2721 |
} |
| 2722 |
}); |
| 2723 |
}); |
| 2724 |
|
| 2725 |
|
| 2726 |
|
| 2727 |
$('.rex-pano-tab .inner-nav-content .single-settings.has-children .vr-switcher-check').on('change', function() { |
| 2728 |
if ($(this).is(':checked')) { |
| 2729 |
$(this).parents('.single-settings').addClass('margin-bottom-remove'); |
| 2730 |
} else { |
| 2731 |
$(this).parents('.single-settings').removeClass('margin-bottom-remove'); |
| 2732 |
} |
| 2733 |
}); |
| 2734 |
|
| 2735 |
// Function to handle visibility toggle based on checkbox state |
| 2736 |
function toggleKeyboardZoom() { |
| 2737 |
var isChecked = $("input[name='mouseZoom']").is(':checked'); |
| 2738 |
$('.mouse-zoom-control-settings-wrapper').toggle(isChecked); |
| 2739 |
} |
| 2740 |
|
| 2741 |
// Initial state setup on page load |
| 2742 |
toggleKeyboardZoom(); |
| 2743 |
|
| 2744 |
// Event listener for checkbox changes using more specific selector |
| 2745 |
$("input[name='mouseZoom']").on("change", toggleKeyboardZoom); |
| 2746 |
|
| 2747 |
|
| 2748 |
|
| 2749 |
|
| 2750 |
|
| 2751 |
// Function to handle visibility toggle based on checkbox state |
| 2752 |
function toggleKeyboardSettings() { |
| 2753 |
var isChecked = $("input[name='draggable']").is(':checked'); |
| 2754 |
$('.mouse-dragable-control-settings-wrapper').toggle(isChecked); |
| 2755 |
} |
| 2756 |
|
| 2757 |
// Initial state setup on page load |
| 2758 |
toggleKeyboardSettings(); |
| 2759 |
|
| 2760 |
// Event listener for checkbox changes using more specific selector |
| 2761 |
$("input[name='draggable']").on("change", toggleKeyboardSettings); |
| 2762 |
|
| 2763 |
|
| 2764 |
|
| 2765 |
// Function to handle visibility toggle based on checkbox state |
| 2766 |
function toggleGallerySettings() { |
| 2767 |
var isChecked = $("input[name='vrgallery']").is(':checked'); |
| 2768 |
$('.scene-gallery-settings-wrapper').toggle(isChecked); |
| 2769 |
} |
| 2770 |
|
| 2771 |
// Initial state setup on page load |
| 2772 |
toggleGallerySettings(); |
| 2773 |
|
| 2774 |
// Event listener for checkbox changes using more specific selector |
| 2775 |
$("input[name='vrgallery']").on("change", toggleGallerySettings); |
| 2776 |
|
| 2777 |
|
| 2778 |
|
| 2779 |
// Function to handle visibility toggle based on checkbox state |
| 2780 |
function toggleGyroSettings() { |
| 2781 |
var isChecked = $("input[name='gyro']").is(':checked'); |
| 2782 |
$('.zyro-settings-wrapper').toggle(isChecked); |
| 2783 |
} |
| 2784 |
|
| 2785 |
// Initial state setup on page load |
| 2786 |
toggleGyroSettings(); |
| 2787 |
|
| 2788 |
// Event listener for checkbox changes using more specific selector |
| 2789 |
$("input[name='gyro']").on("change", toggleGyroSettings); |
| 2790 |
|
| 2791 |
|
| 2792 |
// Function to handle visibility toggle based on checkbox state |
| 2793 |
function toggleExplainerSwitch() { |
| 2794 |
var isChecked = $("input[name='explainerSwitch']").is(':checked'); |
| 2795 |
$('.explainer-video-settings-wrapper').toggle(isChecked); |
| 2796 |
} |
| 2797 |
|
| 2798 |
// Initial state setup on page load |
| 2799 |
toggleExplainerSwitch(); |
| 2800 |
|
| 2801 |
// Event listener for checkbox changes using more specific selector |
| 2802 |
$("input[name='explainerSwitch']").on("change", toggleExplainerSwitch); |
| 2803 |
|
| 2804 |
|
| 2805 |
// Function to handle visibility toggle based on checkbox state |
| 2806 |
function toggleZoomSwitch() { |
| 2807 |
var isChecked = $("input[name='globalzoom']").is(':checked'); |
| 2808 |
$('.set-zoom-perference-control-settings-wrapper').toggle(isChecked); |
| 2809 |
} |
| 2810 |
|
| 2811 |
// Initial state setup on page load |
| 2812 |
toggleZoomSwitch(); |
| 2813 |
|
| 2814 |
// Event listener for checkbox changes using more specific selector |
| 2815 |
$("input[name='globalzoom']").on("change", toggleZoomSwitch); |
| 2816 |
|
| 2817 |
|
| 2818 |
|
| 2819 |
|
| 2820 |
|
| 2821 |
// Get initial checkbox value and convert to boolean |
| 2822 |
var callToAction = $("input[name='calltoaction']").val(); |
| 2823 |
callToAction = callToAction == 'on' ? true : false; |
| 2824 |
|
| 2825 |
// Show or hide the call-to-action section on page load |
| 2826 |
if (callToAction) { |
| 2827 |
$('.call-to-action').show(); |
| 2828 |
} else { |
| 2829 |
$('.call-to-action').hide(); |
| 2830 |
} |
| 2831 |
|
| 2832 |
// Toggle visibility of the call-to-action section on checkbox change |
| 2833 |
$(document).on("change", "input[name='calltoaction']", function () { |
| 2834 |
var calltoactionbutton = $(this).is(':checked') ? 'on' : 'off'; |
| 2835 |
if (calltoactionbutton == 'on') { |
| 2836 |
$('.call-to-action').show(); |
| 2837 |
} else { |
| 2838 |
$('.call-to-action').hide(); |
| 2839 |
} |
| 2840 |
}); |
| 2841 |
|
| 2842 |
|
| 2843 |
// Toggle visibility of the ".custom-css-field" section based on the "customcss" checkbox state. |
| 2844 |
|
| 2845 |
// 1. On page load: |
| 2846 |
// - Get the current value of the "customcss" input. |
| 2847 |
// - Convert 'on' to boolean true. |
| 2848 |
// - Show or hide the ".custom-css-field" section accordingly. |
| 2849 |
|
| 2850 |
var customCssEnable = $("input[name='customcss']").val(); |
| 2851 |
customCssEnable = customCssEnable == 'on' ? true : false; |
| 2852 |
|
| 2853 |
if (customCssEnable) { |
| 2854 |
$('.custom-css-field').show(); |
| 2855 |
} else { |
| 2856 |
$('.custom-css-field').hide(); |
| 2857 |
} |
| 2858 |
|
| 2859 |
// 2. On checkbox state change: |
| 2860 |
// - Detect changes to the "customcss" checkbox. |
| 2861 |
// - Use .is(':checked') to determine current state. |
| 2862 |
// - Alert the value ('on' or 'off'). |
| 2863 |
// - Show or hide the ".custom-css-field" section accordingly. |
| 2864 |
|
| 2865 |
$(document).on("change", "input[name='customcss']", function () { |
| 2866 |
var custom_css_field = $(this).is(':checked') ? 'on' : 'off'; |
| 2867 |
alert(custom_css_field); |
| 2868 |
|
| 2869 |
if (custom_css_field == 'on') { |
| 2870 |
$('.custom-css-field').show(); |
| 2871 |
} else { |
| 2872 |
$('.custom-css-field').hide(); |
| 2873 |
} |
| 2874 |
}); |
| 2875 |
|
| 2876 |
// Run when the DOM is fully loaded |
| 2877 |
$(document).ready(function() { |
| 2878 |
// Only apply on admin panel |
| 2879 |
if ($('body').hasClass('post-type-wpvr_item')) { |
| 2880 |
// Apply fixes after preview is loaded |
| 2881 |
$(document).on('click', '.panolenspreview', function() { |
| 2882 |
setTimeout(fixFloorplanPointers, 2000); |
| 2883 |
}); |
| 2884 |
|
| 2885 |
// Also apply when document is ready |
| 2886 |
setTimeout(fixFloorplanPointers, 1000); |
| 2887 |
} |
| 2888 |
}); |
| 2889 |
|
| 2890 |
/** |
| 2891 |
* Fix floorplan pointers to stay within image boundaries |
| 2892 |
*/ |
| 2893 |
function fixFloorplanPointers() { |
| 2894 |
// Find all floorplan pointers in admin preview |
| 2895 |
$('.wpvr-floor-map .floor-plan-pointer').each(function() { |
| 2896 |
var $pointer = $(this); |
| 2897 |
var $container = $pointer.closest('.wpvr-floor-map'); |
| 2898 |
|
| 2899 |
if ($container.length) { |
| 2900 |
var containerWidth = $container.width(); |
| 2901 |
var containerHeight = $container.height(); |
| 2902 |
var pointerWidth = $pointer.outerWidth(); |
| 2903 |
var pointerHeight = $pointer.outerHeight(); |
| 2904 |
|
| 2905 |
// Get current position |
| 2906 |
var currentLeft = parseInt($pointer.css('left'), 10); |
| 2907 |
var currentTop = parseInt($pointer.css('top'), 10); |
| 2908 |
|
| 2909 |
// Calculate safe boundaries |
| 2910 |
var maxLeft = containerWidth - pointerWidth; |
| 2911 |
var maxTop = containerHeight - pointerHeight; |
| 2912 |
|
| 2913 |
// Store original position as custom properties for CSS clamp() |
| 2914 |
$pointer.css('--x-pos', currentLeft + 'px'); |
| 2915 |
$pointer.css('--y-pos', currentTop + 'px'); |
| 2916 |
|
| 2917 |
// Ensure pointer stays within boundaries |
| 2918 |
if (currentLeft < 0) { |
| 2919 |
$pointer.css('left', '9px'); |
| 2920 |
} else if (currentLeft > maxLeft) { |
| 2921 |
$pointer.css('left', (maxLeft - 9) + 'px'); |
| 2922 |
} |
| 2923 |
|
| 2924 |
if (currentTop < 0) { |
| 2925 |
$pointer.css('top', '9px'); |
| 2926 |
} else if (currentTop > maxTop) { |
| 2927 |
$pointer.css('top', (maxTop - 9) + 'px'); |
| 2928 |
} |
| 2929 |
} |
| 2930 |
}); |
| 2931 |
} |
| 2932 |
|
| 2933 |
// Check for floorplan pointers periodically in case they're added dynamically |
| 2934 |
setInterval(fixFloorplanPointers, 3000); |
| 2935 |
|
| 2936 |
|
| 2937 |
})(jQuery); |