| 1 |
; (function ($) { |
| 2 |
'use strict' |
| 3 |
|
| 4 |
/** |
| 5 |
* JavaScript code for admin dashboard. |
| 6 |
* |
| 7 |
*/ |
| 8 |
|
| 9 |
$(function () { |
| 10 |
/* Preloader */ |
| 11 |
$("#sp_pcp_view_options .spf-metabox").css("visibility", "hidden"); |
| 12 |
|
| 13 |
var PCP_layout_type = $( |
| 14 |
'#spf-section-sp_pcp_layouts_1 .spf-field-layout_preset .spf-siblings .spf--sibling' |
| 15 |
) |
| 16 |
var PCP_get_layout_value = $( |
| 17 |
'#spf-section-sp_pcp_layouts_1 .spf-field-layout_preset .spf-siblings .spf--sibling.spf--active' |
| 18 |
) |
| 19 |
.find('input') |
| 20 |
.val() |
| 21 |
|
| 22 |
// Carousel Layout. |
| 23 |
if (PCP_get_layout_value !== 'carousel_layout') { |
| 24 |
$( |
| 25 |
'#sp_pcp_view_options .spf-nav ul li.menu-item_sp_pcp_view_options_3' |
| 26 |
).hide() |
| 27 |
} else { |
| 28 |
$( |
| 29 |
'#sp_pcp_view_options .spf-nav ul li.menu-item_sp_pcp_view_options_3' |
| 30 |
).show() |
| 31 |
} |
| 32 |
|
| 33 |
/** |
| 34 |
* Show/Hide tabs on changing of layout. |
| 35 |
*/ |
| 36 |
$(PCP_layout_type).on('change', 'input', function (event) { |
| 37 |
//event.stopPropagation() |
| 38 |
var PCP_get_layout_value = $(this).val(); |
| 39 |
|
| 40 |
// Carousel Layout. |
| 41 |
if (PCP_get_layout_value !== 'carousel_layout') { |
| 42 |
$( |
| 43 |
'#sp_pcp_view_options .spf-nav ul li.menu-item_sp_pcp_view_options_3' |
| 44 |
).hide() |
| 45 |
} else { |
| 46 |
$( |
| 47 |
'#sp_pcp_view_options .spf-nav ul li.menu-item_sp_pcp_view_options_3' |
| 48 |
).show() |
| 49 |
} |
| 50 |
}) |
| 51 |
|
| 52 |
/* Preloader js */ |
| 53 |
$("#sp_pcp_view_options .spf-metabox").css({ "backgroundImage": "none", "visibility": "visible", "minHeight": "auto" }); |
| 54 |
$("#sp_pcp_view_options .spf-nav-metabox li").css("opacity", 1); |
| 55 |
|
| 56 |
/* Copy to clipboard */ |
| 57 |
$('.pcp-shortcode-selectable').click(function (e) { |
| 58 |
e.preventDefault(); |
| 59 |
pcp_copyToClipboard($(this)); |
| 60 |
pcp_SelectText($(this)); |
| 61 |
$(this).focus().select(); |
| 62 |
$('.pcp-after-copy-text').animate({ |
| 63 |
opacity: 1, |
| 64 |
bottom: 25 |
| 65 |
}, 300); |
| 66 |
setTimeout(function () { |
| 67 |
jQuery(".pcp-after-copy-text").animate({ |
| 68 |
opacity: 0, |
| 69 |
}, 200); |
| 70 |
jQuery(".pcp-after-copy-text").animate({ |
| 71 |
bottom: 0 |
| 72 |
}, 0); |
| 73 |
}, 2000); |
| 74 |
}); |
| 75 |
$('.sp_pcp_input').click(function (e) { |
| 76 |
e.preventDefault(); |
| 77 |
/* Get the text field */ |
| 78 |
var copyText = $(this); |
| 79 |
/* Select the text field */ |
| 80 |
copyText.select(); |
| 81 |
document.execCommand("copy"); |
| 82 |
$('.pcp-after-copy-text').animate({ |
| 83 |
opacity: 1, |
| 84 |
bottom: 25 |
| 85 |
}, 300); |
| 86 |
setTimeout(function () { |
| 87 |
jQuery(".pcp-after-copy-text").animate({ |
| 88 |
opacity: 0, |
| 89 |
}, 200); |
| 90 |
jQuery(".pcp-after-copy-text").animate({ |
| 91 |
bottom: 0 |
| 92 |
}, 0); |
| 93 |
}, 2000); |
| 94 |
}); |
| 95 |
function pcp_copyToClipboard(element) { |
| 96 |
var $temp = $("<input>"); |
| 97 |
$("body").append($temp); |
| 98 |
$temp.val($(element).text()).select(); |
| 99 |
document.execCommand("copy"); |
| 100 |
$temp.remove(); |
| 101 |
} |
| 102 |
function pcp_SelectText(element) { |
| 103 |
var r = document.createRange(); |
| 104 |
var w = element.get(0); |
| 105 |
r.selectNodeContents(w); |
| 106 |
var sel = window.getSelection(); |
| 107 |
sel.removeAllRanges(); |
| 108 |
sel.addRange(r); |
| 109 |
} |
| 110 |
|
| 111 |
}) |
| 112 |
})(jQuery) |
| 113 |
|