PluginProbe
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News / 2.2.10
Smart Post – Post Grid, Post Carousel, Post Slider Gutenberg Blocks for Blog & News v2.2.10
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
← All changes | admin/assets/js/post-carousel-admin.js +101 -146 4.0.8 → 2.2.10 View file →
@@ -1,157 +1,112 @@
1 1 ; (function ($) {
2 - 'use strict'
2 + 'use strict'
3 3
4 - /**
5 - * JavaScript code for admin dashboard.
6 - *
7 - */
8 - $(function () {
9 - /* Preloader */
10 - $("#sp_pcp_view_options .spf-metabox").css("visibility", "hidden");
4 + /**
5 + * JavaScript code for admin dashboard.
6 + *
7 + */
11 8
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);
9 + $(function () {
10 + /* Preloader */
11 + $("#sp_pcp_view_options .spf-metabox").css("visibility", "hidden");
17 12
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 - }
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()
22 21
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);
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 + }
27 32
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 + * 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();
33 39
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 - });
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 + })
48 51
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'];
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);
60 55
61 - valuesToDisable.forEach(function (value) {
62 - $('.pro-overlay-options-select').find('select option[value="' + value + '"]').attr('disabled', 'disabled').addClass('pcp_pro_only');
63 - });
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 + }
64 110
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 - /* Add Visual Block Editor button on the list page */
129 - function addVisualBlockEditorButton() {
130 - if (typeof ajaxurl === 'undefined') {
131 - return false;
132 - }
133 - if (document.body.classList.contains('post-type-sp_post_carousel') &&
134 - document.body.classList.contains('edit-php')) {
135 - var pageTitleAction = document.querySelector('.page-title-action');
136 - if (pageTitleAction && !document.querySelector('.sp-pcp-visual-block-editor-btn')) {
137 - var button = document.createElement('a');
138 - button.href = ajaxurl.replace('admin-ajax.php', 'post-new.php?post_type=page&spblock_inserter=true');
139 - button.className = 'sp-pcp-visual-block-editor-btn';
140 - button.textContent = 'Start with Smart Post Blocks';
141 - pageTitleAction.parentNode.insertBefore(button, pageTitleAction.nextSibling);
142 - return true;
143 - }
144 - }
145 - return false;
146 - }
147 -
148 - function tryAddButton() {
149 - if (addVisualBlockEditorButton()) {
150 - return;
151 - }
152 - setTimeout(tryAddButton, 100);
153 - }
154 -
155 - tryAddButton();
156 - })
111 + })
157 112 })(jQuery)