PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 2.4.1
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v2.4.1
2.4.1 2.4.0 2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.2 2.2.1 2.2.0 2.1.2 2.1.1 trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 All 68 releases
← All changes | assets/js/admin.js +28 -495 0.0.3 → 2.4.1 View file →
@@ -1,499 +1,32 @@
1 -(function($) {
2 - $(document).ready(function() {
3 - "use strict";
1 +/*
2 + * ATTENTION: The "eval" devtool has been used (maybe by default in mode: "development").
3 + * This devtool is neither made for production nor for readable output files.
4 + * It uses "eval()" calls to create a separate source file in the browser devtools.
5 + * If you are trying to read the output file, select a different devtool (https://webpack.js.org/configuration/devtool/)
6 + * or disable the default devtool with "devtool: false".
7 + * If you are looking for production-ready output files, see mode: "production" (https://webpack.js.org/configuration/mode/).
8 + */
9 +/******/ (() => { // webpackBootstrap
10 +/******/ var __webpack_modules__ = ({
4 11
5 - //Settings Page Starts
6 - $(".bp-tabs .tab__link").on("click", function(e) {
7 - e.preventDefault();
8 - $(".bp-tabs .tab__link").removeClass("active");
9 - $(this).addClass("active");
12 +/***/ "./src/js/admin.js"
13 +/*!*************************!*\
14 + !*** ./src/js/admin.js ***!
15 + \*************************/
16 +() {
10 17
11 - var dataId = $(this).data("id");
18 +eval("{/**\n * Front-end helpers shared by the user-dashboard templates.\n *\n * This file used to drive the PHP admin: settings tabs and save, the\n * transactions list (filters, dropdowns, import/export, delete,\n * mark-as-completed), the onboarding progress bar and the quick-start video.\n * That admin is React now and none of its markup renders anywhere, so only what\n * live templates still use remains:\n * - copy-to-clipboard on transaction ids and emails (the user-dashboard\n * templates, the rows bp-dashboard-pagination.js builds, Pro's subscriptions tab);\n * - the global toastr options (front-end payment toasts go through them).\n *\n * The jQuery UI datepicker on `.bp-datepicker` belonged to Pro's analytics-reports\n * tab and moved to Pro (src/js/user-dashboard.js).\n *\n * Enqueued on every front-end request as `bp-admin-settings` (Admin\\Menu).\n */\n(function ($) {\n $(document).ready(function () {\n 'use strict';\n\n // Copy Transaction Id\n $(document).on('click', '.bp-copy-clipboard', bpTransactionIdCopy);\n function bpTransactionIdCopy() {\n let bpTxnCounter = $(this).attr('data-bp_txn_counter');\n let node = 'bp_copy_clipboard_input_' + bpTxnCounter;\n let nodeInfo = 'bp_copy_clipboard_info_' + bpTxnCounter;\n node = document.getElementById(node);\n if (document.body.createTextRange) {\n const range = document.body.createTextRange();\n range.moveToElementText(node);\n range.select();\n document.execCommand('copy');\n } else if (window.getSelection) {\n const selection = window.getSelection();\n const range = document.createRange();\n range.selectNodeContents(node);\n selection.removeAllRanges();\n selection.addRange(range);\n document.execCommand('copy');\n selection.removeAllRanges();\n } else {\n console.warn('Could not select text in node: Unsupported browser.');\n }\n $('.bp-copy-clipboard').attr('title', 'Copy').css('color', '#2a3256');\n $(this).attr('title', 'Copied!').css('color', '#6e58f7');\n $('#' + nodeInfo).removeClass('is-hidden').fadeIn().fadeOut(3000);\n }\n\n // Copy Email\n $(document).on('click', '.bp-email-copy-clipboard', bpEmailCopy);\n function bpEmailCopy() {\n let bpTxnCounter = $(this).attr('data-bp_txn_counter');\n let node = 'bp_email_copy_clipboard_input_' + bpTxnCounter;\n let nodeInfo = 'bp_email_copy_clipboard_info_' + bpTxnCounter;\n node = document.getElementById(node);\n if (document.body.createTextRange) {\n const range = document.body.createTextRange();\n range.moveToElementText(node);\n range.select();\n document.execCommand('copy');\n } else if (window.getSelection) {\n const selection = window.getSelection();\n const range = document.createRange();\n range.selectNodeContents(node);\n selection.removeAllRanges();\n selection.addRange(range);\n document.execCommand('copy');\n selection.removeAllRanges();\n } else {\n console.warn('Could not select text in node: Unsupported browser.');\n }\n $('.bp-email-copy-clipboard').attr('title', 'Copy').css('color', '#2a3256');\n $(this).attr('title', 'Copied!').css('color', '#6e58f7');\n $('#' + nodeInfo).removeClass('is-hidden').fadeIn().fadeOut(3000);\n }\n\n //Helper Functions Starts\n function toasterOptions() {\n toastr.options = {\n timeOut: '2000',\n toastClass: 'font-size-md',\n positionClass: 'toast-top-center',\n showMethod: 'slideDown',\n hideMethod: 'slideUp'\n };\n }\n toasterOptions();\n //Helper Functions Ends\n });\n})(jQuery);\n\n//# sourceURL=webpack://better-payment/./src/js/admin.js?\n}");
12 19
13 - $(".bp-tabs .tab__content__item").removeClass("show").fadeOut();
14 - $("#" + dataId)
15 - .addClass("show")
16 - .fadeIn();
17 - });
20 +/***/ }
18 21
19 - $(document).on("click", ".sidebar__menu a", function(e) {
20 - e.preventDefault();
21 -
22 - let sidebar_link_class = "sidebar__link";
23 - if ($(this).hasClass("sidebar__link_submenu")) {
24 - sidebar_link_class = "sidebar__link_submenu";
25 - }
26 -
27 - $(".sidebar__menu ." + sidebar_link_class).removeClass("active");
28 - $(this).addClass("active");
29 -
30 - var dataId = $(this).data("id");
31 - $(".content__area__body .sidebar__tab__content")
32 - .removeClass("show")
33 - .fadeOut();
34 - $("#" + dataId)
35 - .addClass("show")
36 - .fadeIn();
37 -
38 - //Auto active first submenu item
39 - if (
40 - $(this).hasClass("sidebar__link") &&
41 - (dataId === "admin-email" || dataId === "paypal")
42 - ) {
43 - $(this).siblings("ul").find("li a").removeClass("active");
44 - $(this).siblings("ul").find("li:first-child a").addClass("active");
45 - }
46 - });
47 -
48 - $(document).on(
49 - "click",
50 - ".sidebar__item .sidebar__link, .email-additional-headers",
51 - function(e) {
52 - e.preventDefault();
53 - let $this = $(this);
54 - let bpTargetSelector = $(this).hasClass("email-additional-headers") ?
55 - ".email-additional-headers-content" :
56 - ".sub__menu";
57 -
58 - if ($this.siblings(bpTargetSelector).hasClass("show")) {
59 - $this.siblings(bpTargetSelector).removeClass("show").slideUp();
60 - } else {
61 - $(bpTargetSelector + ".show")
62 - .slideUp()
63 - .removeClass("show");
64 - $this.siblings(bpTargetSelector).addClass("show").slideDown();
65 - }
66 - }
67 - );
68 -
69 - //PayPal toggle button
70 - $(document).on(
71 - "change",
72 - '.better-payment-settings-payment-paypal input[name="better_payment_settings_payment_paypal_live_mode"]',
73 - function(e) {
74 - e.preventDefault();
75 - let bpAdminSettingsPaymentPayPal = $(this).attr("data-targettest");
76 -
77 - if ($(this).is(":checked")) {
78 - bpAdminSettingsPaymentPayPal = $(this).attr("data-targetlive");
79 - }
80 -
81 - $(".bp-paypal-key").removeClass("bp-d-block").addClass("bp-d-none");
82 - $(`.${bpAdminSettingsPaymentPayPal}`)
83 - .removeClass("bp-d-none")
84 - .addClass("bp-d-block");
85 - }
86 - );
87 -
88 - //Stripe toggle button
89 - $(document).on(
90 - "change",
91 - '.better-payment-settings-payment-stripe input[name="better_payment_settings_payment_stripe_live_mode"]',
92 - function(e) {
93 - e.preventDefault();
94 - let bpAdminSettingsPaymentStripe = $(this).attr("data-targettest");
95 -
96 - if ($(this).is(":checked")) {
97 - bpAdminSettingsPaymentStripe = $(this).attr("data-targetlive");
98 - }
99 -
100 - $(".bp-stripe-key").removeClass("bp-d-block").addClass("bp-d-none");
101 - $(`.${bpAdminSettingsPaymentStripe}`)
102 - .removeClass("bp-d-none")
103 - .addClass("bp-d-block");
104 - }
105 - );
106 -
107 - //Settings Save
108 - $(document).on(
109 - "click",
110 - ".better-payment-admin-settings-button",
111 - function(e) {
112 - e.preventDefault();
113 - let bpAdminSettingsForm = $("#better-payment-admin-settings-form");
114 - bpAdminSettingsSave(this, bpAdminSettingsForm);
115 - }
116 - );
117 -
118 - function bpAdminSettingsSave(button, form) {
119 - let bpAdminSettingsSaveBtn = $(button),
120 - nonce = betterPaymentObj.nonce,
121 - formData = $(form).serializeArray();
122 -
123 - let bpIsFormValidated = bpValidateFormFields(formData);
124 -
125 - //Reset button
126 - $(".better-payment-settings-reset").val(0);
127 - if ($(button).hasClass("better-payment-reset-button")) {
128 - $(".better-payment-settings-reset").val(1);
129 - }
130 -
131 - if (!bpIsFormValidated) {
132 - return false;
133 - }
134 -
135 - let bpIsResetButton = $(button).hasClass("better-payment-reset-button");
136 -
137 - $.ajax({
138 - type: "POST",
139 - url: ajaxurl,
140 - data: {
141 - action: "better_payment_settings_action",
142 - nonce: nonce,
143 - form_data: formData,
144 - reset_button: bpIsResetButton,
145 - },
146 - beforeSend: function() {
147 - bpAdminSettingsSaveBtn.addClass("is-loading");
148 - },
149 - success: function(res) {
150 - bpAdminSettingsSaveBtn.removeClass("is-loading");
151 - if (res.data === "success") {
152 - toastr.success("Changes saved successfully!");
153 - } else {
154 - toastr.error("Opps! something went wrong!");
155 - }
156 - },
157 - });
158 - }
159 -
160 - function bpValidateFormFields(formFields, emailFields = []) {
161 - $(`#better-payment-admin-settings-form input`).removeClass("is-danger");
162 - if (!emailFields.length) {
163 - emailFields = [
164 - "better_payment_settings_general_email_to",
165 - "better_payment_settings_general_email_from_email",
166 - "better_payment_settings_general_email_reply_to",
167 - "better_payment_settings_general_email_cc",
168 - "better_payment_settings_general_email_bcc",
169 - "better_payment_settings_general_email_to_customer",
170 - "better_payment_settings_general_email_from_email_customer",
171 - "better_payment_settings_general_email_reply_to_customer",
172 - "better_payment_settings_general_email_cc_customer",
173 - "better_payment_settings_general_email_bcc_customer",
174 - "better_payment_settings_payment_paypal_email",
175 - ];
176 - }
177 -
178 - let formFieldName = "",
179 - formFieldValue = "",
180 - formField = "",
181 - isFormFieldValidated = false,
182 - errorMessageStr = "";
183 - for (const property in formFields) {
184 - formField = formFields[property];
185 - formFieldName = formField.name;
186 - formFieldValue = formField.value;
187 -
188 - if (emailFields.indexOf(formFieldName) >= 0 && formFieldValue != "") {
189 - isFormFieldValidated = admin_better_email_validation(formFieldValue);
190 -
191 - if (!isFormFieldValidated) {
192 - if (formFieldName == "better_payment_settings_general_email_to") {
193 - errorMessageStr = "Admin Email: To Email";
194 - } else if (
195 - formFieldName ==
196 - "better_payment_settings_general_email_from_email"
197 - ) {
198 - errorMessageStr = "Admin Email: From Email";
199 - } else if (
200 - formFieldName == "better_payment_settings_general_email_reply_to"
201 - ) {
202 - errorMessageStr = "Admin Email: Reply-To";
203 - } else if (
204 - formFieldName == "better_payment_settings_general_email_cc"
205 - ) {
206 - errorMessageStr = "Admin Email: Cc";
207 - } else if (
208 - formFieldName == "better_payment_settings_general_email_bcc"
209 - ) {
210 - errorMessageStr = "Admin Email: Bcc";
211 - }
212 - if (
213 - formFieldName ==
214 - "better_payment_settings_general_email_to_customer"
215 - ) {
216 - errorMessageStr = "Customer Email: To Email";
217 - } else if (
218 - formFieldName ==
219 - "better_payment_settings_general_email_from_email_customer"
220 - ) {
221 - errorMessageStr = "Customer Email: From Email";
222 - } else if (
223 - formFieldName ==
224 - "better_payment_settings_general_email_reply_to_customer"
225 - ) {
226 - errorMessageStr = "Customer Email: Reply-To";
227 - } else if (
228 - formFieldName ==
229 - "better_payment_settings_general_email_cc_customer"
230 - ) {
231 - errorMessageStr = "Customer Email: Cc";
232 - } else if (
233 - formFieldName ==
234 - "better_payment_settings_general_email_bcc_customer"
235 - ) {
236 - errorMessageStr = "Customer Email: Bcc";
237 - } else if (
238 - formFieldName == "better_payment_settings_payment_paypal_email"
239 - ) {
240 - errorMessageStr = "PayPal Business Email";
241 - }
242 -
243 - toastr.error(`Invalid email address on ${errorMessageStr} field!`);
244 - $(
245 - `#better-payment-admin-settings-form input[name="${formFieldName}"]`
246 - ).addClass("is-danger");
247 - return false;
248 - }
249 - }
250 - }
251 -
252 - return true;
253 - }
254 -
255 - function admin_better_email_validation(email) {
256 - return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
257 - }
258 - //Settings Page Ends
259 -
260 - //Transaction Page Starts
261 - $(document).on(
262 - "change",
263 - ".better-payment .header__show_entries select",
264 - function(e) {
265 - e.preventDefault();
266 - let perPageVal = $(this).val();
267 - location =
268 - location.origin +
269 - location.pathname +
270 - location.search +
271 - "&paged=1&per_page=" +
272 - perPageVal +
273 - location.hash;
274 - }
275 - );
276 -
277 - $(document).on(
278 - "click",
279 - ".better-payment-transaction-edit, .better-payment-transaction-email-resend",
280 - function(e) {
281 - e.preventDefault();
282 - toastr.warning("Coming REAL Soon!");
283 - }
284 - );
285 - //Pagination
286 -
287 - //Filter transactions
288 - $(document).on("click", ".better-payment-transaction-filter", function(e) {
289 - e.preventDefault();
290 - let paymentFromDate = $(".better-payment input[name='payment_date_from']").val();
291 - let paymentToDate = $(".better-payment input[name='payment_date_to']").val();
292 - if (paymentFromDate != "" && paymentToDate != "") {
293 - if (paymentFromDate > paymentToDate) {
294 - toastr.error("From Date must be smaller than To Date!");
295 - return false;
296 - }
297 - }
298 - let tableSelector = $(
299 - ".better-payment-admin-transactions-page .transaction__table"
300 - );
301 -
302 - let filterFormData = {};
303 - filterFormData.search_text = $(".better-payment .serch-text").val();
304 -
305 - filterFormData.payment_date_from = paymentFromDate;
306 - filterFormData.payment_date_to = paymentToDate;
307 - filterFormData.order_by = $(".better-payment input[name='order_by[]']:checked").val();
308 - filterFormData.order = $(".better-payment input[name='order[]']:checked").val();
309 -
310 - filterFormData.status = $(".better-payment input[name='status[]']:checked").val();
311 - filterFormData.source = $(".better-payment input[name='source[]']:checked").val();
312 -
313 - filterFormData.paged = $(".better-payment .paged").val();
314 - filterFormData.per_page = $(".better-payment .per-page").val();
315 - filterFormData.total_entry = $(".better-payment .total-entry").val();
316 -
317 - bpTransactionFilter(tableSelector, filterFormData);
318 - });
319 -
320 - let elements = document.getElementsByClassName("bp-copy-clipboard");
321 - Array.from(elements).forEach(function(element) {
322 - element.addEventListener("click", bpTransactionIdCopy);
323 - });
324 -
325 - function bpTransactionIdCopy() {
326 - let bpTxnCounter = $(this).attr("data-bp_txn_counter");
327 - let node = "bp_copy_clipboard_input_" + bpTxnCounter;
328 -
329 - node = document.getElementById(node);
330 -
331 - if (document.body.createTextRange) {
332 - const range = document.body.createTextRange();
333 - range.moveToElementText(node);
334 - range.select();
335 -
336 - document.execCommand("copy");
337 - } else if (window.getSelection) {
338 - const selection = window.getSelection();
339 - const range = document.createRange();
340 - range.selectNodeContents(node);
341 - selection.removeAllRanges();
342 - selection.addRange(range);
343 -
344 - document.execCommand("copy");
345 - selection.removeAllRanges();
346 - } else {
347 - console.warn("Could not select text in node: Unsupported browser.");
348 - }
349 - $(".bp-copy-clipboard").attr("title", "Copy").css("color", "#2a3256");
350 - $(this).attr("title", "Copied!").css("color", "#6e58f7");
351 - }
352 -
353 - function bpTransactionFilter(tableSelector, filterFormData) {
354 - $.ajax({
355 - type: "POST",
356 - url: ajaxurl,
357 - data: {
358 - action: "better-payment-filter-transaction",
359 - nonce: betterPaymentObj.nonce,
360 - filterFormData: filterFormData,
361 - },
362 - dataType: "html",
363 - beforeSend: function() {
364 - tableSelector.css("opacity", ".5");
365 - },
366 - success: function(resultHtml) {
367 - $(".better-payment .transaction-table-wrapper").replaceWith(
368 - resultHtml
369 - );
370 - tableSelector.css("opacity", "1");
371 - },
372 - });
373 - }
374 -
375 - // Custom Dropdown Button
376 - $(document).on(
377 - "click",
378 - ".better-payment .bp_time_period-custom-range",
379 - function (e) {
380 - $(".better-payment .modal.bp-custom-time-period").addClass(
381 - "is-active"
382 - );
383 - }
384 - );
385 -
386 - $(document).on("click", ".bp-select-custom-button", function(e) {
387 - e.preventDefault();
388 - let $this = $(this);
389 - let dataTarget = $this.attr("data-target");
390 - $(dataTarget).toggleClass("is-hidden");
391 -
392 - let dropdownInputs = ['status', 'order_by', 'order', 'source'];
393 -
394 - hideOtherDropdownsV2(dropdownInputs, dataTarget);
395 - });
396 -
397 - $(document).on("click", "body", function(e) {
398 - let dropdownInputs = ['status', 'order_by', 'order', 'source'];
399 - hideOtherDropdowns(dropdownInputs, e);
400 - });
401 -
402 - $(".bp-select-custom-button-dropdown input[type='checkbox']").change(
403 - function() {
404 - let inputName = $(this).attr("name");
405 - inputName = inputName.replace("[]", "");
406 -
407 - let inputValueDefault = $(this).closest('.bp-select-custom-button-dropdown').attr("data-defaultvalue");
408 -
409 - if (this.checked) {
410 - //Uncheck other checkboxes but this one
411 - $(`.${inputName}-dropdown input[name='${inputName}[]']`)
412 - .not(this)
413 - .prop("checked", false);
414 -
415 - updateDropdownText(this.value, inputName);
416 - } else {
417 - //If four checkboxes are unchecked then check Default checkbox
418 - if (
419 - !$(`.${inputName}-dropdown input[name='${inputName}[]']:checked`)
420 - .length
421 - ) {
422 - if (typeof inputValueDefault !== "undefined") {
423 - $(`.${inputName}-dropdown .${inputName}-${inputValueDefault}`).prop(
424 - "checked",
425 - true
426 - );
427 - }
428 -
429 - updateDropdownText(capitalizeFirstLetter(inputName), inputName);
430 - }
431 - }
432 - }
433 - );
434 -
435 - function hideOtherDropdowns(inputs = ['status', 'source'], e, containerClass = 'bp-select-custom-button-wrap') {
436 - let filter_button_container = $(`.${containerClass}`);
437 -
438 - if (
439 - !filter_button_container.is(e.target) &&
440 - filter_button_container.has(e.target).length === 0
441 - ) {
442 - if(inputs.length > 0) {
443 - inputs.forEach(function(input) {
444 - if (!$(`.${input}-dropdown`).hasClass("is-hidden")) {
445 - $(`.${input}-dropdown`).addClass("is-hidden");
446 - }
447 - });
448 - }
449 - }
450 - }
451 -
452 - function hideOtherDropdownsV2(inputs, dataTarget){
453 - let currentInputName = dataTarget.replace(".", "").replace("-dropdown", "");
454 - if(inputs.length > 0) {
455 - inputs.forEach(function(inputName) {
456 - if (inputName !== currentInputName) {
457 - if (!$(`.${inputName}-dropdown`).hasClass("is-hidden")) {
458 - $(`.${inputName}-dropdown`).addClass("is-hidden");
459 - }
460 - }
461 - });
462 - }
463 - }
464 -
465 - function capitalizeFirstLetter(string) {
466 - let capitalized = string.charAt(0).toUpperCase() + string.slice(1);
467 - return capitalized.replace('_', ' ');
468 - }
469 -
470 - function updateDropdownText(
471 - text,
472 - inputName = "status",
473 - buttonTextPrefix = ""
474 - ) {
475 - $(`.${inputName}-button-text`).html(
476 - buttonTextPrefix + capitalizeFirstLetter(text)
477 - );
478 - }
479 -
480 - //Transaction Page Ends
481 -
482 - //Helper Functions Starts
483 - function toasterOptions() {
484 - toastr.options = {
485 - timeOut: "2000",
486 - toastClass: "font-size-md",
487 - positionClass: "toast-top-center",
488 - showMethod: "slideDown",
489 - hideMethod: "slideUp",
490 - };
491 - }
492 - toasterOptions();
493 -
494 - $(".bp-datepicker").datepicker({
495 - dateFormat: "dd-mm-yy",
496 - });
497 - //Helper Functions Ends
498 - });
499 -})(jQuery);
22 +/******/ });
23 +/************************************************************************/
24 +/******/
25 +/******/ // startup
26 +/******/ // Load entry module and return exports
27 +/******/ // This entry module can't be inlined because the eval devtool is used.
28 +/******/ var __webpack_exports__ = {};
29 +/******/ __webpack_modules__["./src/js/admin.js"]();
30 +/******/
31 +/******/ })()
32 +;