1/**
2 * WHMCS core JS library reference
3 *
4 * @copyright Copyright (c) WHMCS Limited 2005-2017
5 * @license http://www.whmcs.com/license/ WHMCS Eula
6 */
7
8(function (window, factory) {
9 if (typeof window.WHMCS !== 'object') {
10 window.WHMCS = factory;
11 }
12}(
13 window,
14 {
15 hasModule: function (name) {
16 return (typeof WHMCS[name] !== 'undefined'
17 && Object.getOwnPropertyNames(WHMCS[name]).length > 0);
18 },
19 loadModule: function (name, module) {
20 if (this.hasModule(name)) {
21 return;
22 }
23
24 WHMCS[name] = {};
25 if (typeof module === 'function') {
26 (module).apply(WHMCS[name]);
27 } else {
28 for (var key in module) {
29 if (module.hasOwnProperty(key)) {
30 WHMCS[name][key] = {};
31 (module[key]).apply(WHMCS[name][key]);
32 }
33 }
34 }
35 }
36 }
37));
38
39jQuery(document).ready(function() {
40 jQuery(document).on('click', '.disable-on-click', function () {
41 jQuery(this).addClass('disabled');
42
43 if (jQuery(this).hasClass('spinner-on-click')) {
44 var icon = $(this).find('i.fas,i.far,i.fal,i.fab');
45
46 jQuery(icon)
47 .removeAttr('class')
48 .addClass('fas fa-spinner fa-spin');
49 }
50 })
51 .on('click', '#openTicketSubmit.disabled', function () {
52 return false;
53 });
54});
55
56function scrollToGatewayInputError() {
57 var displayError = jQuery('.gateway-errors,.assisted-cc-input-feedback').first(),
58 frm = displayError.closest('form');
59 if (!frm) {
60 frm = jQuery('form').first();
61 }
62 frm.find('button[type="submit"],input[type="submit"]')
63 .prop('disabled', false)
64 .removeClass('disabled')
65 .find('i.fas,i.far,i.fal,i.fab')
66 .removeAttr('class')
67 .addClass('fas fa-arrow-circle-right')
68 .find('span').toggle();
69
70 if (displayError.length) {
71 if (elementOutOfViewPort(displayError[0])) {
72 jQuery('html, body').animate(
73 {
74 scrollTop: displayError.offset().top - 50
75 },
76 500
77 );
78 }
79 }
80}
81
82function elementOutOfViewPort(element) {
83 // Get element's bounding
84 var bounding = element.getBoundingClientRect();
85 // Check if it's out of the viewport on each side
86 var out = {};
87 out.top = bounding.top < 0;
88 out.left = bounding.left < 0;
89 out.bottom = bounding.bottom > (window.innerHeight || document.documentElement.clientHeight);
90 out.right = bounding.right > (window.innerWidth || document.documentElement.clientWidth);
91 out.any = out.top || out.left || out.bottom || out.right;
92
93 return out.any;
94};
95