PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 4.0.3
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v4.0.3
4.0.8 4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 2.3.5 2.3.6 2.4.0 2.4.1 2.4.10 2.4.11 2.4.12 2.4.13 2.4.14 2.4.15 2.4.16 2.4.17 2.4.18 2.4.19 2.4.2 2.4.20 2.4.21 All 88 releases
post-carousel / admin / assets / js / post-carousel-admin.js

post-carousel-admin.js in Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News 4.0.3, at admin/assets/js/post-carousel-admin.js

129 lines 4.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 ; (function ($) {
2 'use strict'
3
4 /**
5 * JavaScript code for admin dashboard.
6 *
7 */
8 $(function () {
9 /* Preloader */
10 $("#sp_pcp_view_options .spf-metabox").css("visibility", "hidden");
11
12 // Function to toggle visibility of menu items based on layout value.
13 function toggleMenuItems(layoutValue) {
14 // Determine whether to hide the pagination menu item
15 var isCarouselSliderThumbnail = (layoutValue === 'carousel_layout' || layoutValue === 'slider_layout');
16 $('.spf-tabbed-nav .pcp_ajax_pagination').toggle(!isCarouselSliderThumbnail);
17
18 // Show or hide the common menu item for carousel, slider, and thumbnail
19 $('.menu-item_sp_pcp_view_options_3').toggle(isCarouselSliderThumbnail);
20 $('.pcp-display-tabs .spf-tabbed-nav a:nth-child(1)').trigger('click');
21 }
22
23 $('.post_content_sorter .spf--sortable .spf--sortable-item:nth-child(1)').find('.spf-accordion-title').trigger('click');
24 // Initial setup
25 var layoutValue = $('.pcp-layout-preset .spf--sibling.spf--active').find('input').val();
26 toggleMenuItems(layoutValue);
27
28 // Event listener for layout change
29 $('.pcp-layout-preset .spf--sibling').on('change', 'input', function (event) {
30 layoutValue = $(this).val();
31 toggleMenuItems(layoutValue);
32 });
33
34 // Get the last activated or selected layout.
35 var lastSelectedOption = $('input[name="sp_pcp_layouts[pcp_layout_preset]"]:checked').val();
36 $('input[name="sp_pcp_layouts[pcp_layout_preset]"]').on('change', function () {
37 if (!$(this).is(':disabled')) {
38 lastSelectedOption = $(this).val();
39 }
40 });
41 // Get the last activated or selected layout.
42 var lastSelectedContentOrientation = 'default';
43 $('input[name="sp_pcp_view_options[post_content_orientation]"]').on('change', function () {
44 if (!$(this).is(':disabled')) {
45 lastSelectedContentOrientation = $(this).val();
46 }
47 });
48
49 // Revert the selection to the last valid activated option that was selected before if the disabled/pro option is chosen.
50 $('#publishing-action').on('click', '#publish', function (e) {
51 if ($('input[name="sp_pcp_layouts[pcp_layout_preset]"]:checked').is(':disabled')) {
52 $('input[name="sp_pcp_layouts[pcp_layout_preset]"][value="' + lastSelectedOption + '"]').prop('checked', true);
53 }
54 if ($('input[name="sp_pcp_view_options[post_content_orientation]"]:checked').is(':disabled')) {
55 $('input[name="sp_pcp_view_options[post_content_orientation]"][value="' + lastSelectedContentOrientation + '"]').prop('checked', true);
56 }
57 });
58 // Disable specific select options by their values
59 var valuesToDisable = ['1', '2', '3', '4', '5'];
60
61 valuesToDisable.forEach(function (value) {
62 $('.pro-overlay-options-select').find('select option[value="' + value + '"]').attr('disabled', 'disabled').addClass('pcp_pro_only');
63 });
64
65 $('.sps-live-demo-icon').on('click', function (event) {
66 event.stopPropagation();
67 })
68
69 /* Preloader js */
70 $("#sp_pcp_view_options .spf-metabox").css({ "backgroundImage": "none", "visibility": "visible", "minHeight": "auto" });
71 $("#sp_pcp_view_options .spf-nav-metabox li").css("opacity", 1);
72
73 /* Copy to clipboard */
74 $('.pcp-shortcode-selectable').on('click', function (e) {
75 e.preventDefault();
76 pcp_copyToClipboard($(this));
77 pcp_SelectText($(this));
78 $(this).focus().select();
79 $('.pcp-after-copy-text').animate({
80 opacity: 1,
81 bottom: 25
82 }, 300);
83 setTimeout(function () {
84 jQuery(".pcp-after-copy-text").animate({
85 opacity: 0,
86 }, 200);
87 jQuery(".pcp-after-copy-text").animate({
88 bottom: 0
89 }, 0);
90 }, 2000);
91 });
92 $('.sp_pcp_input').on('click', function (e) {
93 e.preventDefault();
94 /* Get the text field */
95 var copyText = $(this);
96 /* Select the text field */
97 copyText.select();
98 document.execCommand("copy");
99 $('.pcp-after-copy-text').animate({
100 opacity: 1,
101 bottom: 25
102 }, 300);
103 setTimeout(function () {
104 jQuery(".pcp-after-copy-text").animate({
105 opacity: 0,
106 }, 200);
107 jQuery(".pcp-after-copy-text").animate({
108 bottom: 0
109 }, 0);
110 }, 2000);
111 });
112 function pcp_copyToClipboard(element) {
113 var $temp = $("<input>");
114 $("body").append($temp);
115 $temp.val($(element).text()).select();
116 document.execCommand("copy");
117 $temp.remove();
118 }
119 function pcp_SelectText(element) {
120 var r = document.createRange();
121 var w = element.get(0);
122 r.selectNodeContents(w);
123 var sel = window.getSelection();
124 sel.removeAllRanges();
125 sel.addRange(r);
126 }
127 })
128 })(jQuery)
129