| 1 |
(function( $ ) { |
| 2 |
'use strict'; |
| 3 |
/** |
| 4 |
* All of the code for your admin-facing JavaScript source |
| 5 |
* should reside in this file. |
| 6 |
* |
| 7 |
* Note: It has been assumed you will write jQuery code here, so the |
| 8 |
* $ function reference has been prepared for usage within the scope |
| 9 |
* of this function. |
| 10 |
* |
| 11 |
* This enables you to define handlers, for when the DOM is ready: |
| 12 |
* |
| 13 |
* $(function() { |
| 14 |
* |
| 15 |
* }); |
| 16 |
* |
| 17 |
* When the window is loaded: |
| 18 |
* |
| 19 |
* $( window ).load(function() { |
| 20 |
* |
| 21 |
* }); |
| 22 |
* |
| 23 |
* ...and/or other possibilities. |
| 24 |
* |
| 25 |
* Ideally, it is not considered best practise to attach more than a |
| 26 |
* single DOM-ready or window-load handler for a particular page. |
| 27 |
* Although scripts in the WordPress core, Plugins and Themes may be |
| 28 |
* practising this, we should strive to set a better example in our own work. |
| 29 |
*/ |
| 30 |
|
| 31 |
$(document).ready(function(){ |
| 32 |
|
| 33 |
$( '#wpvr-gopro-submenu' ).parent().attr( 'target', '_blank' ); |
| 34 |
|
| 35 |
$('.setup-wizard-carousel').owlCarousel({ |
| 36 |
loop:false, |
| 37 |
items:1, |
| 38 |
dots: false, |
| 39 |
mouseDrag: false, |
| 40 |
touchDrag: false, |
| 41 |
navText: ['Previous','Next'], |
| 42 |
}); |
| 43 |
|
| 44 |
$(".choose-tour input[type='radio']").on('click', function(){ |
| 45 |
var val = $(this).val(); |
| 46 |
$('#'+val).show(); |
| 47 |
$('#'+val).siblings().hide(); |
| 48 |
}); |
| 49 |
|
| 50 |
function wpvr_bf_notice_dismiss(event) { |
| 51 |
event.preventDefault(); |
| 52 |
var ajaxurl = wpvr_global_obj.ajaxurl; |
| 53 |
var that = $(this); |
| 54 |
$.ajax({ |
| 55 |
type : "post", |
| 56 |
dataType : "json", |
| 57 |
url : ajaxurl, |
| 58 |
data : { action: "wpvr_black_friday_offer_notice_dismiss", nonce : wpvr_global_obj.ajax_nonce }, |
| 59 |
success: function(response) { |
| 60 |
if(response.success) { |
| 61 |
that.fadeOut('slow'); |
| 62 |
} |
| 63 |
} |
| 64 |
}) |
| 65 |
} |
| 66 |
$(document).on('click', '.wpvr-black-friday-offer notice-dismiss', wpvr_bf_notice_dismiss); |
| 67 |
|
| 68 |
|
| 69 |
function wpvr_halloween_notice_dismiss(event) { |
| 70 |
event.preventDefault(); |
| 71 |
$('#rex_wpvr_deal_notification').css('display','none'); |
| 72 |
var ajaxurl = wpvr_global_obj.ajaxurl; |
| 73 |
var that = $(this); |
| 74 |
$.ajax({ |
| 75 |
type : "post", |
| 76 |
dataType : "json", |
| 77 |
url : ajaxurl, |
| 78 |
data : { action: "wpvr_halloween_offer_notice_dismiss", nonce : wpvr_global_obj.ajax_nonce }, |
| 79 |
success: function(response) { |
| 80 |
if(response.success) { |
| 81 |
that.fadeOut('slow'); |
| 82 |
} |
| 83 |
} |
| 84 |
}) |
| 85 |
} |
| 86 |
$(document).on('click', '.close-promotional-banner', wpvr_halloween_notice_dismiss); |
| 87 |
|
| 88 |
}); |
| 89 |
|
| 90 |
$(document).on("click","#wpvr-dismissible",function(e) { |
| 91 |
|
| 92 |
e.preventDefault(); |
| 93 |
var ajaxurl = wpvr_global_obj.ajaxurl; |
| 94 |
jQuery.ajax({ |
| 95 |
type: "POST", |
| 96 |
url: ajaxurl, |
| 97 |
data: { |
| 98 |
action: "wpvr_notice", |
| 99 |
nonce : wpvr_global_obj.ajax_nonce |
| 100 |
}, |
| 101 |
success: function( response ){ |
| 102 |
$('#wpvr-warning').hide(); |
| 103 |
} |
| 104 |
}); |
| 105 |
}); |
| 106 |
|
| 107 |
|
| 108 |
/** |
| 109 |
* Dismiss black friday notice |
| 110 |
* |
| 111 |
* @param e |
| 112 |
*/ |
| 113 |
function wpvr_dismiss_black_friday_notice(e) { |
| 114 |
e.preventDefault(); |
| 115 |
jQuery.ajax({ |
| 116 |
type: "POST", |
| 117 |
url: ajaxurl, |
| 118 |
data: { |
| 119 |
action: "wpvr_dismiss_black_friday_notice", |
| 120 |
nonce : wpvr_global_obj.ajax_nonce |
| 121 |
}, |
| 122 |
success: function(response) { |
| 123 |
$('.wpvr-black-friday-banner').hide(); |
| 124 |
} |
| 125 |
}); |
| 126 |
} |
| 127 |
$(document).on('click', '#wpvr-black-friday-close-button, #wpvr-black-friday-close-button svg', wpvr_dismiss_black_friday_notice); |
| 128 |
|
| 129 |
|
| 130 |
// video setup wizard__video |
| 131 |
$( document ).on( 'click', '.box-video', function() { |
| 132 |
$('iframe',this)[0].src += "?autoplay=1"; |
| 133 |
$(this).addClass('open'); |
| 134 |
}); |
| 135 |
|
| 136 |
$(document).on('click','.wpvr-halloween-notice .notice-dismiss',function (){ |
| 137 |
var ajaxurl = wpvr_global_obj.ajaxurl; |
| 138 |
jQuery.ajax({ |
| 139 |
type: "POST", |
| 140 |
url: ajaxurl, |
| 141 |
data: { |
| 142 |
action: "wpvr_notice", |
| 143 |
nonce : wpvr_global_obj.ajax_nonce |
| 144 |
}, |
| 145 |
}); |
| 146 |
}) |
| 147 |
|
| 148 |
$(document).on('click','#wpvr-copy-shortcode-listing',function() { |
| 149 |
var shortcode = $(this).parent().find('code').text(); // Get the shortcode text |
| 150 |
copyToClipboard(shortcode,$(this)); // Copy the shortcode to clipboard |
| 151 |
}); |
| 152 |
|
| 153 |
function copyToClipboard(text,current) { |
| 154 |
|
| 155 |
var tempInput = $("<input>"); |
| 156 |
$("body").append(tempInput); |
| 157 |
tempInput.val(text).select(); |
| 158 |
document.execCommand("copy"); |
| 159 |
tempInput.remove(); |
| 160 |
current.find('.copy-shortcode-text').show(); |
| 161 |
|
| 162 |
setTimeout(function(){ |
| 163 |
current.find(".copy-shortcode-text").hide(); |
| 164 |
}, 2000 ); |
| 165 |
|
| 166 |
} |
| 167 |
|
| 168 |
|
| 169 |
|
| 170 |
})( jQuery ); |
| 171 |
|