PluginProbe
Post Grid Gutenberg Blocks – PostX / 5.0.24
Post Grid Gutenberg Blocks – PostX v5.0.24
5.0.41 5.0.39 5.0.38 5.0.37 5.0.36 5.0.35 5.0.34 5.0.33 5.0.32 5.0.31 5.0.30 5.0.29 5.0.28 5.0.27 5.0.26 5.0.25 5.0.23 5.0.24 5.0.22 5.0.21 5.0.20 5.0.19 5.0.18 5.0.17 2.1.1 All 238 releases
ultimate-post / assets / js / ultp-option.js

ultp-option.js in Post Grid Gutenberg Blocks – PostX 5.0.24, at assets/js/ultp-option.js

353 lines 9.5 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 // -------- Custom Font ----------
6 // -------------------------------z
7 $(".ultp-font-variation-action").on("click", function (e) {
8 const content = $(".ultp-custom-font-copy")[0].outerHTML;
9 $(this).before(
10 content.replace(
11 "ultp-custom-font-copy",
12 "ultp-custom-font ultp-font-open",
13 ),
14 );
15 });
16 $(document).on("click", ".ultp-custom-font-close", function (e) {
17 $(this)
18 .closest(".ultp-custom-font-container")
19 .removeClass("ultp-font-open");
20 });
21 $(document).on("click", ".ultp-custom-font-edit", function (e) {
22 $(this).closest(".ultp-custom-font-container").addClass("ultp-font-open");
23 });
24 $(document).on("click", ".ultp-custom-font-delete", function (e) {
25 $(this).closest(".ultp-custom-font").remove();
26 });
27 $(document).on("click", ".ultp-font-upload", function (e) {
28 const that = $(this);
29 $(this).addClass("rty");
30 const ultpCustomFont = wp
31 .media({
32 title: "Add Font",
33 button: { text: "Add New Font" },
34 multiple: false,
35 })
36 .on("select", function () {
37 const attachment = ultpCustomFont
38 .state()
39 .get("selection")
40 .first()
41 .toJSON();
42 that.closest(".ultp-font-file-list").find("input").val(attachment.url);
43 })
44 .open();
45 });
46 // -------------------------------
47 // -------------------------------
48 // -------------------------------
49
50 if (window?.location?.search == "?page=ultp-settings") {
51 function initializeColorPicker() {
52 // handle color picker
53 $(".ultp-color-picker").wpColorPicker({
54 change: function (e, ui) {
55 $(this)
56 .closest(".ultp-settings-field")
57 .find(".ultp-color-code")
58 .val(ui.color.toString());
59 },
60 });
61 $(".ultp-color-code").bind("change keyup input", function () {
62 $(this)
63 .closest(".ultp-settings-field")
64 .find(".wp-color-result")
65 .css("background-color", $(this).val());
66 });
67
68 // handle re generate google font
69 $("input[name=disable_google_font]")
70 .off("change")
71 .on("change", function () {
72 if ($(this).is(":checked")) {
73 $("#postx-regenerate-css").addClass("active");
74 } else {
75 $("#postx-regenerate-css").removeClass("active");
76 }
77 });
78 }
79
80 // Initialize color picker
81 initializeColorPicker();
82
83 // MutationObserver instance
84 const observer = new MutationObserver(function (mutations) {
85 mutations.forEach(function (mutation) {
86 if (mutation.type === "childList" || mutation.type === "subtree") {
87 initializeColorPicker();
88 }
89 });
90 });
91
92 // Start observing
93 observer.observe(document.body, {
94 childList: true,
95 subtree: true,
96 });
97 }
98
99 // *************************************
100 // Add target blank for upgrade button
101 // *************************************
102 const postxMenuHref = $("#toplevel_page_ultp-settings > a").attr("href");
103 if (postxMenuHref?.indexOf("?page=ultp-settings") > 0) {
104 $("#toplevel_page_ultp-settings > a").attr("href", postxMenuHref + "#home");
105 }
106
107 // $("#toplevel_page_ultp-settings ul > li > a").each(function (e) {
108 // if (
109 // $(this).attr("href") &&
110 // $(this).attr("href").indexOf("?page=ultp-settings") > 0
111 // ) {
112 // if ($(this).hasClass("wp-first-item") != false) {
113 // $(this).attr("href", $(this).attr("href") + "#home");
114 // }
115
116 // if (ultp_option_panel.settings) {
117 // if (
118 // $(this).attr("href").indexOf("#builder") > 0 &&
119 // ultp_option_panel.settings?.ultp_builder != "true"
120 // ) {
121 // $(this).hide();
122 // }
123 // if (
124 // $(this).attr("href").indexOf("#custom-font") > 0 &&
125 // ultp_option_panel.settings?.ultp_custom_font != "true"
126 // ) {
127 // $(this).hide();
128 // }
129 // if (
130 // $(this).attr("href").indexOf("#saved-templates") > 0 &&
131 // ultp_option_panel.settings?.ultp_templates != "true"
132 // ) {
133 // $(this).hide();
134 // }
135 // }
136
137 // let hasID = $(this).attr("href").indexOf("#");
138 // $(this).attr(
139 // "id",
140 // "postx-submenu-" +
141 // (hasID > 0 ? $(this).attr("href").split("#")[1] : "home"),
142 // );
143
144 // if ($(this).attr("href").indexOf("?ultp=plugins") > 0) {
145 // $(this).attr("target", "_blank");
146 // }
147 // }
148 // if ($(this).attr("href").indexOf("?page=go_postx_pro") > 0) {
149 // $(this).attr("target", "_blank");
150 // }
151 // });
152
153 $(document).on("click", ".ultp-popup-close", function (e) {
154 if (!$(this).hasClass("popup-center")) {
155 $(this).closest(".ultp-popup-container").removeClass("active");
156 }
157 });
158
159 $(document).on("click", ".ultp-block-settings", function (e) {
160 $(this).parent().find(".ultp-popup-container").addClass("active");
161 });
162
163 const actionBtn = $(".page-title-action");
164 const savedBtn = $(".ultp-saved-templates-action");
165 if (savedBtn.length > 0) {
166 if (savedBtn.data())
167 actionBtn.addClass("ultp-save-templates-pro").text(savedBtn.data("text"));
168 actionBtn.attr("href", savedBtn.data("link"));
169 actionBtn.attr("target", "_blank");
170 }
171
172 // *************************************
173 // Add URL for PostX
174 // *************************************
175 $(document).on(
176 "click",
177 "#plugin-information-content ul > li > a",
178 function (e) {
179 const URL = $(this).attr("href");
180 if (URL.includes("downloads/gutenberg-post-blocks-pro")) {
181 e.preventDefault();
182 window.open("https://www.wpxpo.com/postx/");
183 }
184 },
185 );
186
187 // *************************************
188 // PostX Builder Metabox Settings
189 // *************************************
190 const selector = $(".postx-meta-sidebar-position select");
191 function changeSidebar() {
192 if (selector.length > 0) {
193 if (selector.val() == "left" || selector.val() == "right") {
194 $(".postx-meta-sidebar-widget").show();
195 } else {
196 $(".postx-meta-sidebar-widget").hide();
197 }
198 }
199 }
200 changeSidebar();
201 selector.on("change", function () {
202 changeSidebar();
203 });
204
205 // Settings Option
206 if ("?page=ultp-settings" == window.location.search) {
207 const hash = window.location.hash;
208 if (hash) {
209 if (hash.indexOf("demoid") < 0) {
210 $("#toplevel_page_ultp-settings ul li").removeClass("current");
211 $("#toplevel_page_ultp-settings ul li a[href$=" + hash + "]")
212 .closest("li")
213 .addClass("current");
214 if (hash == "#home") {
215 $("#toplevel_page_ultp-settings ul li.wp-first-item").addClass(
216 "current",
217 );
218 } else {
219 $(
220 "#toplevel_page_ultp-settings ul li a[href$=" + hash + "]",
221 ).addClass("current");
222 }
223 }
224 }
225 }
226
227 $(document).on(
228 "click",
229 "#ultp-dashboard-ultp-settings-tab li a, #toplevel_page_ultp-settings ul li a",
230 function (e) {
231 let value = $(this).attr("href");
232 if (value) {
233 value = value.split("#");
234 if (
235 typeof value[1] != "undefined" &&
236 value[1].indexOf("demoid") < 0 &&
237 value[1]
238 ) {
239 $("#toplevel_page_ultp-settings ul li a")
240 .closest("ul")
241 .find("li")
242 .removeClass("current");
243 $(this).closest("li").addClass("current"); // Submenu click
244 $("#toplevel_page_ultp-settings ul li a[href$=" + value[1] + "]")
245 .closest("li")
246 .addClass("current"); // Dash Nav Menu click
247 if (value[1] == "home") {
248 $("#toplevel_page_ultp-settings ul li.wp-first-item").addClass(
249 "current",
250 );
251 }
252 }
253 }
254 },
255 );
256
257 $(".page-title-action").on("click", function (e) {
258 if ($(".ultp-pro-needed").length > 0) {
259 const href = $(this).attr("href");
260 if (href.indexOf("post_type=ultp_builder") > 0) {
261 e.preventDefault();
262 $(".ultp-popup-container").addClass("active");
263 }
264 }
265 });
266 $(".ultp-popup-close").on("click", function (e) {
267 $(this).closest(".ultp-popup-container").removeClass("active");
268 });
269 // *************************************
270 // Ultp Builder Image
271 // *************************************
272 // If any Default Video Have not Caption Default caption should be empty
273 $("#ultp-add-input").on("change", function (e) {
274 const inputVal = $(this).val();
275 if (inputVal == "") {
276 jQuery("#ultp-add-caption").val("");
277 }
278 });
279
280 $(".ultp-add-media").on("click", function () {
281 let videoView = jQuery(".ultp-video-src > source");
282 let ultpFeatVideo = wp
283 .media({
284 title: "Insert Video",
285 button: {
286 text: "Add New Image",
287 },
288 multiple: false,
289 library: {
290 type: "video",
291 },
292 })
293 .on("select", function () {
294 let attachment = ultpFeatVideo
295 .state()
296 .get("selection")
297 .first()
298 .toJSON();
299 jQuery("#ultp-add-input").val(attachment.url);
300 jQuery("#ultp-add-caption").val(attachment.caption);
301 // videoView.attr('src', attachment.url);
302 })
303 .open();
304 });
305
306 // *************************************
307 // Disable Google Font Action
308 // *************************************
309
310 $(document).on("click", "#postx-regenerate-css", function (e) {
311 const that = $(this);
312 $.ajax({
313 url: ultp_option_panel.ajax,
314 type: "POST",
315 data: {
316 action: "disable_google_font",
317 wpnonce: ultp_option_panel.security,
318 },
319 beforeSend: function () {
320 that.addClass("ultp-spinner");
321 },
322 success: function (res) {
323 if (res.success) {
324 that.find(".ultp-text").text(res.data);
325 }
326 },
327 complete: function () {
328 that.removeClass("ultp-spinner");
329 },
330 error: function (xhr) {
331 console.log(
332 "Error occured.please try again" + xhr.statusText + xhr.responseText,
333 );
334 },
335 });
336 });
337
338 // saved template back button
339 $(document).ready(function () {
340 if (
341 $(".block-editor-page") &&
342 ultp_option_panel.post_type == "ultp_templates"
343 ) {
344 setTimeout(function () {
345 if ($(".edit-post-fullscreen-mode-close").length > 0) {
346 $(".edit-post-fullscreen-mode-close")[0].href =
347 ultp_option_panel.saved_template_url;
348 }
349 }, 1);
350 }
351 });
352 })(jQuery);
353