PluginProbe
Post Grid Gutenberg Blocks – PostX / 5.1.1
Post Grid Gutenberg Blocks – PostX v5.1.1
5.1.1 5.1.0 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 All 240 releases
ultimate-post / assets / js / ultp-option.js

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

344 lines 9.1 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 // *************************************
164 // Add URL for PostX
165 // *************************************
166 $(document).on(
167 "click",
168 "#plugin-information-content ul > li > a",
169 function (e) {
170 const URL = $(this).attr("href");
171 if (URL.includes("downloads/gutenberg-post-blocks-pro")) {
172 e.preventDefault();
173 window.open("https://www.wpxpo.com/postx/");
174 }
175 },
176 );
177
178 // *************************************
179 // PostX Builder Metabox Settings
180 // *************************************
181 const selector = $(".postx-meta-sidebar-position select");
182 function changeSidebar() {
183 if (selector.length > 0) {
184 if (selector.val() == "left" || selector.val() == "right") {
185 $(".postx-meta-sidebar-widget").show();
186 } else {
187 $(".postx-meta-sidebar-widget").hide();
188 }
189 }
190 }
191 changeSidebar();
192 selector.on("change", function () {
193 changeSidebar();
194 });
195
196 // Settings Option
197 if ("?page=ultp-settings" == window.location.search) {
198 const hash = window.location.hash;
199 if (hash) {
200 if (hash.indexOf("demoid") < 0) {
201 $("#toplevel_page_ultp-settings ul li").removeClass("current");
202 $("#toplevel_page_ultp-settings ul li a[href$=" + hash + "]")
203 .closest("li")
204 .addClass("current");
205 if (hash == "#home") {
206 $("#toplevel_page_ultp-settings ul li.wp-first-item").addClass(
207 "current",
208 );
209 } else {
210 $(
211 "#toplevel_page_ultp-settings ul li a[href$=" + hash + "]",
212 ).addClass("current");
213 }
214 }
215 }
216 }
217
218 $(document).on(
219 "click",
220 "#ultp-dashboard-ultp-settings-tab li a, #toplevel_page_ultp-settings ul li a",
221 function (e) {
222 let value = $(this).attr("href");
223 if (value) {
224 value = value.split("#");
225 if (
226 typeof value[1] != "undefined" &&
227 value[1].indexOf("demoid") < 0 &&
228 value[1]
229 ) {
230 $("#toplevel_page_ultp-settings ul li a")
231 .closest("ul")
232 .find("li")
233 .removeClass("current");
234 $(this).closest("li").addClass("current"); // Submenu click
235 $("#toplevel_page_ultp-settings ul li a[href$=" + value[1] + "]")
236 .closest("li")
237 .addClass("current"); // Dash Nav Menu click
238 if (value[1] == "home") {
239 $("#toplevel_page_ultp-settings ul li.wp-first-item").addClass(
240 "current",
241 );
242 }
243 }
244 }
245 },
246 );
247
248 $(".page-title-action").on("click", function (e) {
249 if ($(".ultp-pro-needed").length > 0) {
250 const href = $(this).attr("href");
251 if (href.indexOf("post_type=ultp_builder") > 0) {
252 e.preventDefault();
253 $(".ultp-popup-container").addClass("active");
254 }
255 }
256 });
257 $(".ultp-popup-close").on("click", function (e) {
258 $(this).closest(".ultp-popup-container").removeClass("active");
259 });
260 // *************************************
261 // Ultp Builder Image
262 // *************************************
263 // If any Default Video Have not Caption Default caption should be empty
264 $("#ultp-add-input").on("change", function (e) {
265 const inputVal = $(this).val();
266 if (inputVal == "") {
267 jQuery("#ultp-add-caption").val("");
268 }
269 });
270
271 $(".ultp-add-media").on("click", function () {
272 let videoView = jQuery(".ultp-video-src > source");
273 let ultpFeatVideo = wp
274 .media({
275 title: "Insert Video",
276 button: {
277 text: "Add New Image",
278 },
279 multiple: false,
280 library: {
281 type: "video",
282 },
283 })
284 .on("select", function () {
285 let attachment = ultpFeatVideo
286 .state()
287 .get("selection")
288 .first()
289 .toJSON();
290 jQuery("#ultp-add-input").val(attachment.url);
291 jQuery("#ultp-add-caption").val(attachment.caption);
292 // videoView.attr('src', attachment.url);
293 })
294 .open();
295 });
296
297 // *************************************
298 // Disable Google Font Action
299 // *************************************
300
301 $(document).on("click", "#postx-regenerate-css", function (e) {
302 const that = $(this);
303 $.ajax({
304 url: ultp_option_panel.ajax,
305 type: "POST",
306 data: {
307 action: "disable_google_font",
308 wpnonce: ultp_option_panel.security,
309 },
310 beforeSend: function () {
311 that.addClass("ultp-spinner");
312 },
313 success: function (res) {
314 if (res.success) {
315 that.find(".ultp-text").text(res.data);
316 }
317 },
318 complete: function () {
319 that.removeClass("ultp-spinner");
320 },
321 error: function (xhr) {
322 console.log(
323 "Error occured.please try again" + xhr.statusText + xhr.responseText,
324 );
325 },
326 });
327 });
328
329 // saved template back button
330 $(document).ready(function () {
331 if (
332 $(".block-editor-page") &&
333 ultp_option_panel.post_type == "ultp_templates"
334 ) {
335 setTimeout(function () {
336 if ($(".edit-post-fullscreen-mode-close").length > 0) {
337 $(".edit-post-fullscreen-mode-close")[0].href =
338 ultp_option_panel.saved_template_url;
339 }
340 }, 1);
341 }
342 });
343 })(jQuery);
344