/*! * iCheck v1.0.3, http://git.io/arlzeA * =================================== * Powerful jQuery and Zepto plugin for checkboxes and radio buttons customization * * (c) 2013 Damir Sultanov, http://fronteed.com * MIT Licensed */ (function($) { // Cached vars var _iCheck = 'iCheck', _iCheckHelper = _iCheck + '-helper', _checkbox = 'checkbox', _radio = 'radio', _checked = 'checked', _unchecked = 'un' + _checked, _disabled = 'disabled', _determinate = 'determinate', _indeterminate = 'in' + _determinate, _update = 'update', _type = 'type', _click = 'click', _touch = 'touchbegin.i touchend.i', _add = 'addClass', _remove = 'removeClass', _callback = 'trigger', _label = 'label', _cursor = 'cursor', _mobile = /ip(hone|od|ad)|android|blackberry|windows phone|opera mini|silk/i.test(navigator.userAgent) || (navigator.platform === 'MacIntel' && navigator.maxTouchPoints > 1); // Plugin init $.fn[_iCheck] = function(options, fire) { // Walker var handle = 'input[type="' + _checkbox + '"], input[type="' + _radio + '"]', stack = $(), walker = function(object) { object.each(function() { var self = $(this); if (self.is(handle)) { stack = stack.add(self); } else { stack = stack.add(self.find(handle)); } }); }; // Check if we should operate with some method if (/^(check|uncheck|toggle|indeterminate|determinate|disable|enable|update|destroy)$/i.test(options)) { // Normalize method's name options = options.toLowerCase(); // Find checkboxes and radio buttons walker(this); return stack.each(function() { var self = $(this); if (options == 'destroy') { tidy(self, 'ifDestroyed'); } else { operate(self, true, options); } // Fire method's callback if ($.isFunction(fire)) { fire(); } }); // Customization } else if (typeof options == 'object' || !options) { // Check if any options were passed var settings = $.extend({ checkedClass: _checked, disabledClass: _disabled, indeterminateClass: _indeterminate, labelHover: true }, options), selector = settings.handle, hoverClass = settings.hoverClass || 'hover', focusClass = settings.focusClass || 'focus', activeClass = settings.activeClass || 'active', labelHover = !!settings.labelHover, labelHoverClass = settings.labelHoverClass || 'hover', // Setup clickable area area = ('' + settings.increaseArea).replace('%', '') | 0; // Selector limit if (selector == _checkbox || selector == _radio) { handle = 'input[type="' + selector + '"]'; } // Clickable area limit if (area < -50) { area = -50; } // Walk around the selector walker(this); return stack.each(function() { var self = $(this); // If already customized tidy(self); var node = this, id = node.id, // Layer styles offset = -area + '%', size = 100 + (area * 2) + '%', layer = { position: 'absolute', top: offset, left: offset, display: 'block', width: size, height: size, margin: 0, padding: 0, background: '#fff', border: 0, opacity: 0 }, // Choose how to hide input hide = _mobile ? { position: 'absolute', visibility: 'hidden' } : area ? layer : { position: 'absolute', opacity: 0 }, // Get proper class className = node[_type] == _checkbox ? settings.checkboxClass || 'i' + _checkbox : settings.radioClass || 'i' + _radio, // Find assigned labels label = $(_label + '[for="' + id + '"]').add(self.closest(_label)), // Check ARIA option aria = !!settings.aria, // Set ARIA placeholder ariaID = _iCheck + '-' + Math.random().toString(36).substr(2,6), // Parent & helper parent = '
')[_callback]('ifCreated').parent().append(settings.insert); // Layer addition helper = $('').css(layer).appendTo(parent); // Finalize customization self.data(_iCheck, {o: settings, s: self.attr('style')}).css(hide); !!settings.inheritClass && parent[_add](node.className || ''); !!settings.inheritID && id && parent.attr('id', _iCheck + '-' + id); parent.css('position') == 'static' && parent.css('position', 'relative'); operate(self, true, _update); // Label events if (label.length) { label.on(_click + '.i mouseover.i mouseout.i ' + _touch, function(event) { var type = event[_type], item = $(this); // Do nothing if input is disabled if (!node[_disabled]) { // Click if (type == _click) { if ($(event.target).is('a')) { return; } operate(self, false, true); // Hover state } else if (labelHover) { // mouseout|touchend if (/ut|nd/.test(type)) { parent[_remove](hoverClass); item[_remove](labelHoverClass); } else { parent[_add](hoverClass); item[_add](labelHoverClass); } } if (_mobile) { event.stopPropagation(); } else { return false; } } }); } // Input events self.on(_click + '.i focus.i blur.i keyup.i keydown.i keypress.i', function(event) { var type = event[_type], key = event.keyCode; // Click if (type == _click) { return false; // Keydown } else if (type == 'keydown' && key == 32) { if (!(node[_type] == _radio && node[_checked])) { if (node[_checked]) { off(self, _checked); } else { on(self, _checked); } } return false; // Keyup } else if (type == 'keyup' && node[_type] == _radio) { !node[_checked] && on(self, _checked); // Focus/blur } else if (/us|ur/.test(type)) { parent[type == 'blur' ? _remove : _add](focusClass); } }); // Helper events helper.on(_click + ' mousedown mouseup mouseover mouseout ' + _touch, function(event) { var type = event[_type], // mousedown|mouseup toggle = /wn|up/.test(type) ? activeClass : hoverClass; // Do nothing if input is disabled if (!node[_disabled]) { // Click if (type == _click) { operate(self, false, true); // Active and hover states } else { // State is on if (/wn|er|in/.test(type)) { // mousedown|mouseover|touchbegin parent[_add](toggle); // State is off } else { parent[_remove](toggle + ' ' + activeClass); } // Label hover if (label.length && labelHover && toggle == hoverClass) { // mouseout|touchend label[/ut|nd/.test(type) ? _remove : _add](labelHoverClass); } } if (_mobile) { event.stopPropagation(); } else { return false; } } }); }); } else { return this; } }; // Do something with inputs function operate(input, direct, method) { var node = input[0], state = /er/.test(method) ? _indeterminate : /bl/.test(method) ? _disabled : _checked, active = method == _update ? { checked: node[_checked], disabled: node[_disabled], indeterminate: input.attr(_indeterminate) == 'true' || input.attr(_determinate) == 'false' } : node[state]; // Check, disable or indeterminate if (/^(ch|di|in)/.test(method) && !active) { on(input, state); // Uncheck, enable or determinate } else if (/^(un|en|de)/.test(method) && active) { off(input, state); // Update } else if (method == _update) { // Handle states for (var each in active) { if (active[each]) { on(input, each, true); } else { off(input, each, true); } } } else if (!direct || method == 'toggle') { // Helper or label was clicked if (!direct) { input[_callback]('ifClicked'); } // Toggle checked state if (active) { if (node[_type] !== _radio) { off(input, state); } } else { on(input, state); } } } // Add checked, disabled or indeterminate state function on(input, state, keep) { var node = input[0], parent = input.parent(), checked = state == _checked, indeterminate = state == _indeterminate, disabled = state == _disabled, callback = indeterminate ? _determinate : checked ? _unchecked : 'enabled', regular = option(input, callback + capitalize(node[_type])), specific = option(input, state + capitalize(node[_type])); // Prevent unnecessary actions if (node[state] !== true) { // Toggle assigned radio buttons if (!keep && state == _checked && node[_type] == _radio && node.name) { var form = input.closest('form'), inputs = 'input[name="' + node.name + '"]'; inputs = form.length ? form.find(inputs) : $(inputs); inputs.each(function() { if (this !== node && $(this).data(_iCheck)) { off($(this), state); } }); } // Indeterminate state if (indeterminate) { // Add indeterminate state node[state] = true; // Remove checked state if (node[_checked]) { off(input, _checked, 'force'); } // Checked or disabled state } else { // Add checked or disabled state if (!keep) { node[state] = true; } // Remove indeterminate state if (checked && node[_indeterminate]) { off(input, _indeterminate, false); } } // Trigger callbacks callbacks(input, checked, state, keep); } // Add proper cursor if (node[_disabled] && !!option(input, _cursor, true)) { parent.find('.' + _iCheckHelper).css(_cursor, 'default'); } // Add state class parent[_add](specific || option(input, state) || ''); // Set ARIA attribute if (!!parent.attr('role') && !indeterminate) { parent.attr('aria-' + (disabled ? _disabled : _checked), 'true'); } // Remove regular state class parent[_remove](regular || option(input, callback) || ''); } // Remove checked, disabled or indeterminate state function off(input, state, keep) { var node = input[0], parent = input.parent(), checked = state == _checked, indeterminate = state == _indeterminate, disabled = state == _disabled, callback = indeterminate ? _determinate : checked ? _unchecked : 'enabled', regular = option(input, callback + capitalize(node[_type])), specific = option(input, state + capitalize(node[_type])); // Prevent unnecessary actions if (node[state] !== false) { // Toggle state if (indeterminate || !keep || keep == 'force') { node[state] = false; } // Trigger callbacks callbacks(input, checked, callback, keep); } // Add proper cursor if (!node[_disabled] && !!option(input, _cursor, true)) { parent.find('.' + _iCheckHelper).css(_cursor, 'pointer'); } // Remove state class parent[_remove](specific || option(input, state) || ''); // Set ARIA attribute if (!!parent.attr('role') && !indeterminate) { parent.attr('aria-' + (disabled ? _disabled : _checked), 'false'); } // Add regular state class parent[_add](regular || option(input, callback) || ''); } // Remove all traces function tidy(input, callback) { if (input.data(_iCheck)) { // Remove everything except input input.parent().html(input.attr('style', input.data(_iCheck).s || '')); // Callback if (callback) { input[_callback](callback); } // Unbind events input.off('.i').unwrap(); $(_label + '[for="' + input[0].id + '"]').add(input.closest(_label)).off('.i'); } } // Get some option function option(input, state, regular) { if (input.data(_iCheck)) { return input.data(_iCheck).o[state + (regular ? '' : 'Class')]; } } // Capitalize some string function capitalize(string) { return string.charAt(0).toUpperCase() + string.slice(1); } // Executable handlers function callbacks(input, checked, callback, keep) { if (!keep) { if (checked) { input[_callback]('ifToggled'); } input[_callback]('change')[_callback]('ifChanged')[_callback]('if' + capitalize(callback)); } } })(window.jQuery || window.Zepto); /** * WHMCS core JS library reference * * @copyright Copyright (c) WHMCS Limited 2005-2017 * @license http://www.whmcs.com/license/ WHMCS Eula */ (function (window, factory) { if (typeof window.WHMCS !== 'object') { window.WHMCS = factory; } }( window, { hasModule: function (name) { return (typeof WHMCS[name] !== 'undefined' && Object.getOwnPropertyNames(WHMCS[name]).length > 0); }, loadModule: function (name, module) { if (this.hasModule(name)) { return; } WHMCS[name] = {}; if (typeof module === 'function') { (module).apply(WHMCS[name]); } else { for (var key in module) { if (module.hasOwnProperty(key)) { WHMCS[name][key] = {}; (module[key]).apply(WHMCS[name][key]); } } } } } )); jQuery(document).ready(function() { jQuery(document).on('click', '.disable-on-click', function () { jQuery(this).addClass('disabled'); if (jQuery(this).hasClass('spinner-on-click')) { var icon = $(this).find('i.fas,i.far,i.fal,i.fab'); jQuery(icon) .removeAttr('class') .addClass('fas fa-spinner fa-spin'); } }) .on('click', '#openTicketSubmit.disabled', function () { return false; }); }); function scrollToGatewayInputError() { var displayError = jQuery('.gateway-errors,.assisted-cc-input-feedback').first(), frm = displayError.closest('form'); if (!frm) { frm = jQuery('form').first(); } frm.find('button[type="submit"],input[type="submit"]') .prop('disabled', false) .removeClass('disabled') .find('i.fas,i.far,i.fal,i.fab') .removeAttr('class') .addClass('fas fa-arrow-circle-right') .find('span').toggle(); if (displayError.length) { if (elementOutOfViewPort(displayError[0])) { jQuery('html, body').animate( { scrollTop: displayError.offset().top - 50 }, 500 ); } } } function elementOutOfViewPort(element) { // Get element's bounding var bounding = element.getBoundingClientRect(); // Check if it's out of the viewport on each side var out = {}; out.top = bounding.top < 0; out.left = bounding.left < 0; out.bottom = bounding.bottom > (window.innerHeight || document.documentElement.clientHeight); out.right = bounding.right > (window.innerWidth || document.documentElement.clientWidth); out.any = out.top || out.left || out.bottom || out.right; return out.any; }; /** * WHMCS authentication module * * @copyright Copyright (c) WHMCS Limited 2005-2017 * @license http://www.whmcs.com/license/ WHMCS Eula */ (function(module) { if (!WHMCS.hasModule('authn')) { WHMCS.loadModule('authn', module); } })({ provider: function () { var callbackFired = false; /** * @return {jQuery} */ this.feedbackContainer = function () { return jQuery(".providerLinkingFeedback"); }; /** * @returns {jQuery} */ this.btnContainer = function () { return jQuery(".providerPreLinking"); }; this.feedbackMessage = function (context) { if (typeof context === 'undefined') { context = 'complete_sign_in'; } var msgContainer = jQuery('p.providerLinkingMsg-preLink-' + context); if (msgContainer.length) { return msgContainer.first().html(); } return ''; }; this.showProgressMessage = function(callback) { this.feedbackContainer().fadeIn('fast', function () { if (typeof callback === 'function' && !callbackFired) { callbackFired = true; callback(); } }); }; this.preLinkInit = function (callback) { var icon = ' '; this.feedbackContainer() .removeClass('alert-danger alert-success') .addClass('alert alert-info') .html(icon + this.feedbackMessage()) .hide(); var btnContainer = this.btnContainer(); if (btnContainer.length) { if (btnContainer.data('hideOnPrelink')) { var self = this; btnContainer.fadeOut('false', function () { self.showProgressMessage(callback) }); } else if (btnContainer.data('disableOnPrelink')) { btnContainer.find('.btn').addClass('disabled'); this.showProgressMessage(callback); } else { this.showProgressMessage(callback); } } else { this.showProgressMessage(callback); } }; this.displayError = function (provider, errorCondition, providerErrorText){ jQuery('#providerLinkingMessages .provider-name').html(provider); var feedbackMsg = this.feedbackMessage('connect_error'); if (errorCondition) { var errorMsg = this.feedbackMessage(errorCondition); if (errorMsg) { feedbackMsg = errorMsg } } if (providerErrorText && $('.btn-logged-in-admin').length > 0) { feedbackMsg += ' Error: ' + providerErrorText; } this.feedbackContainer().removeClass('alert-info alert-success') .addClass('alert alert-danger') .html(feedbackMsg).slideDown(); }; this.displaySuccess = function (data, context, provider) { var icon = provider.icon; var htmlTarget = context.htmlTarget; var targetLogin = context.targetLogin; var targetRegister = context.targetRegister; var displayName = provider.name; var feedbackMsg = ''; switch (data.result) { case "logged_in": case "2fa_needed": feedbackMsg = this.feedbackMessage('2fa_needed'); this.feedbackContainer().removeClass('alert-danger alert-warning alert-success') .addClass('alert alert-info') .html(feedbackMsg); window.location = data.redirect_url ? decodeURIComponent(data.redirect_url) : decodeURIComponent(context.redirectUrl); break; case "linking_complete": var accountInfo = ''; if (data.remote_account.email) { accountInfo = data.remote_account.email; } else { accountInfo = data.remote_account.firstname + " " + data.remote_account.lastname; } accountInfo = accountInfo.trim(); feedbackMsg = this.feedbackMessage('linking_complete').trim().replace(':displayName', displayName); if (accountInfo) { feedbackMsg = feedbackMsg.replace(/\.$/, ' (' + accountInfo + ').'); } this.feedbackContainer().removeClass('alert-danger alert-warning alert-info') .addClass('alert alert-success') .html(icon + feedbackMsg); break; case "login_to_link": if (htmlTarget === targetLogin) { feedbackMsg = this.feedbackMessage('login_to_link-signin-required'); this.feedbackContainer().removeClass('alert-danger alert-success alert-info') .addClass('alert alert-warning') .html(icon + feedbackMsg); } else { var emailField = jQuery("input[name=email]"); var firstNameField = jQuery("input[name=firstname]"); var lastNameField = jQuery("input[name=lastname]"); if (emailField.val() === "") { emailField.val(data.remote_account.email); } if (firstNameField.val() === "") { firstNameField.val(data.remote_account.firstname); } if (lastNameField.val() === "") { lastNameField.val(data.remote_account.lastname); } if (htmlTarget === targetRegister) { if (typeof WHMCS.client.registration === 'object') { WHMCS.client.registration.prefillPassword(); } feedbackMsg = this.feedbackMessage('login_to_link-registration-required'); this.feedbackContainer().fadeOut('slow', function () { $(this).removeClass('alert-danger alert-success alert-info') .addClass('alert alert-warning') .html(icon + feedbackMsg).fadeIn('fast'); }); } else { // this is checkout if (typeof WHMCS.client.registration === 'object') { WHMCS.client.registration.prefillPassword(); } var self = this; this.feedbackContainer().each(function (i, el) { var container = $(el); var linkContext = container.siblings('div .providerPreLinking').data('linkContext'); container.fadeOut('slow', function () { if (linkContext === 'checkout-new') { feedbackMsg = self.feedbackMessage('checkout-new'); } else { feedbackMsg = self.feedbackMessage('login_to_link-signin-required'); } container.removeClass('alert-danger alert-success alert-info') .addClass('alert alert-warning') .html(icon + feedbackMsg).fadeIn('fast'); }); }); } } break; case "other_user_exists": feedbackMsg = this.feedbackMessage('other_user_exists'); this.feedbackContainer().removeClass('alert-info alert-success') .addClass('alert alert-danger') .html(icon + feedbackMsg).slideDown(); break; case "already_linked": feedbackMsg = this.feedbackMessage('already_linked'); this.feedbackContainer().removeClass('alert-info alert-success') .addClass('alert alert-danger') .html(icon + feedbackMsg).slideDown(); break; default: feedbackMsg = this.feedbackMessage('default'); this.feedbackContainer().removeClass('alert-info alert-success') .addClass('alert alert-danger') .html(icon + feedbackMsg).slideDown(); break; } }; this.signIn = function (config, context, provider, providerDone, providerError) { jQuery.ajax(config).done(function(data) { providerDone(); WHMCS.authn.provider.displaySuccess(data, context, provider); var table = jQuery('#tableLinkedAccounts'); if (table.length) { WHMCS.ui.dataTable.getTableById('tableLinkedAccounts').ajax.reload(); } }).error(function() { providerError(); WHMCS.authn.provider.displayError(); }); }; return this; }}); /** * WHMCS client module * * @copyright Copyright (c) WHMCS Limited 2005-2017 * @license http://www.whmcs.com/license/ WHMCS Eula */ (function(module) { if (!WHMCS.hasModule('client')) { WHMCS.loadModule('client', module); } })({ registration: function () { this.prefillPassword = function (params) { params = params || {}; if (typeof params.hideContainer === 'undefined') { var id = (jQuery('#inputSecurityQId').attr('id')) ? '#containerPassword' : '#containerNewUserSecurity'; params.hideContainer = jQuery(id); params.hideInputs = true; } else if (typeof params.hideContainer === 'string' && params.hideContainer.length) { params.hideContainer = jQuery(params.hideContainer); } if (typeof params.form === 'undefined') { params.form = { password: [ {id: 'inputNewPassword1'}, {id: 'inputNewPassword2'} ] }; } var prefillFunc = function () { var $randomPasswd = WHMCS.utils.simpleRNG(); for (var i = 0, len = params.form.password.length; i < len; i++) { jQuery('#' + params.form.password[i].id) .val($randomPasswd).trigger('keyup'); } }; if (params.hideInputs) { params.hideContainer.slideUp('fast', prefillFunc); } else { prefillFunc(); } }; return this; }}); /** * WHMCS HTTP module * * @copyright Copyright (c) WHMCS Limited 2005-2018 * @license http://www.whmcs.com/license/ WHMCS Eula */ (function(module) { if (!WHMCS.hasModule('http')) { WHMCS.loadModule('http', module); } })({ jqClient: function () { _getSettings = function (url, data, success, dataType) { if (typeof url === 'object') { /* Settings may be the only argument */ return url; } if (typeof data === 'function') { /* If 'data' is omitted, 'success' will come in its place */ success = data; data = null; } return { url: url, data: data, success: success, dataType: dataType }; }; /** * @param url * @param data * @param success * @param dataType * @returns {*} */ this.get = function (url, data, success, dataType) { return WHMCS.http.client.request( jQuery.extend( _getSettings(url, data, success, dataType), { type: 'GET' } ) ); }; /** * @param url * @param data * @param success * @param dataType * @returns {*} */ this.post = function (url, data, success, dataType) { return WHMCS.http.client.request( jQuery.extend( _getSettings(url, data, success, dataType), { type: 'POST' } ) ); }; /** * @param options * @returns {*} */ this.jsonGet = function (options) { options = options || {}; this.get(options.url, options.data, function(response) { if (response.warning) { console.log('[WHMCS] Warning: ' + response.warning); if (typeof options.warning === 'function') { options.warning(response.warning); } } else if (response.error) { console.log('[WHMCS] Error: ' + response.error); if (typeof options.error === 'function') { options.error(response.error); } } else { if (typeof options.success === 'function') { options.success(response); } } }, 'json').error(function(xhr, errorMsg){ console.log('[WHMCS] Error: ' + errorMsg); if (typeof options.fail === 'function') { options.fail(errorMsg); } }).always(function() { if (typeof options.always === 'function') { options.always(); } }); }; /** * @param options * @returns {*} */ this.jsonPost = function (options) { options = options || {}; this.post(options.url, options.data, function(response) { if (response.warning) { console.log('[WHMCS] Warning: ' + response.warning); if (typeof options.warning === 'function') { options.warning(response.warning); } } else if (response.error) { console.log('[WHMCS] Error: ' + response.error); if (typeof options.error === 'function') { options.error(response.error); } } else { if (typeof options.success === 'function') { options.success(response); } } }, 'json').fail(function(xhr, errorMsg){ console.log('[WHMCS] Fail: ' + errorMsg); if (typeof options.fail === 'function') { options.fail(errorMsg, xhr); } }).always(function() { if (typeof options.always === 'function') { options.always(); } }); }; return this; }, client: function () { var methods = ['get', 'post', 'put', 'delete']; var client = this; _beforeRequest = function (settings) { /* Enforcing dataType was found to break many invocations expecting HTML back. If/when those are refactored, this may be uncommented to enforce a safer data transit. */ /*if (typeof settings.dataType === 'undefined') { settings.dataType = 'json'; }*/ if (typeof settings.type === 'undefined') { // default request type is GET settings.type = 'GET'; } /* Add other preprocessing here if required */ return settings; }; this.request = function (settings) { settings = _beforeRequest(settings || {}); return jQuery.ajax(settings); }; /* Create shortcut methods for methods[] array above */ jQuery.each(methods, function(index, method) { client[method] = (function(method, client) { return function (settings) { settings = settings || {}; settings.type = method.toUpperCase(); return client.request(settings); } })(method, client); }); return this; } }); /** * WHMCS UI module * * @copyright Copyright (c) WHMCS Limited 2005-2017 * @license http://www.whmcs.com/license/ WHMCS Eula */ (function(module) { if (!WHMCS.hasModule('ui')) { WHMCS.loadModule('ui', module); } })({ /** * Confirmation PopUp */ confirmation: function () { /** * @type {Array} Registered confirmation root selectors */ var toggles = []; /** * Register/Re-Register all confirmation elements with jQuery * By default all elements of data toggle "confirmation" will be registered * * @param {(string|undefined)} rootSelector * @return {Array} array of registered toggles */ this.register = function (rootSelector) { if (typeof rootSelector === 'undefined') { rootSelector = '[data-toggle=confirmation]'; } if (toggles.indexOf(rootSelector) < 0) { toggles.push(rootSelector); } jQuery(rootSelector).confirmation({ rootSelector: rootSelector }); return toggles; }; return this; }, /** * Data Driven Table */ dataTable: function () { /** * @type {{}} */ this.tables = {}; /** * Register all tables on page with the class "data-driven" */ this.register = function () { var self = this; jQuery('table.data-driven').each(function (i, table) { self.getTableById(table.id, undefined); }); }; /** * Get a table by id; create table object on fly as necessary * * @param {string} id * @param {({}|undefined)} options * @returns {DataTable} */ this.getTableById = function (id, options) { var self = this; var el = jQuery('#' + id); if (typeof self.tables[id] === 'undefined') { if (typeof options === 'undefined') { options = { dom: '<"listtable"ift>pl', paging: false, lengthChange: false, searching: false, ordering: true, info: false, autoWidth: true, columns: [], lengthMenu: [10, 25, 50, 100, 500, 1000], language: { emptyTable: (el.data('langEmptyTable')) ? el.data('langEmptyTable') : "No records found" } }; } jQuery.each(el.data(), function (key, value) { if (typeof value === 'undefined') { return; } if (key === 'ajaxUrl') { options.ajax = { url: value }; return; } if (key === 'lengthChange') { options.lengthChange = value; return; } if (key === 'pageLength') { options.pageLength = value; return; } if (key === 'langEmptyTable') { if (typeof options.language === "undefined") { options.language = {}; } options.language.emptyTable = value; return } if (key === 'langZeroRecords') { if (typeof options.language === "undefined") { options.language = {}; } options.language.zeroRecords = value; return } options.key = value; }); jQuery.each(el.find('th'), function() { if (typeof options.columns === "undefined") { options.columns = []; } options.columns.push({data:jQuery(this).data('name')}); }); self.tables[id] = self.initTable(el, options); } else if (typeof options !== 'undefined') { var oldTable = self.tables[id]; var initOpts = oldTable.init(); var newOpts = jQuery.extend( initOpts, options); oldTable.destroy(); self.tables[id] = self.initTable(el, newOpts); } return self.tables[id]; }; this.initTable = function (el, options) { var table = el.DataTable(options); var self = this; if (el.data('on-draw')) { table.on('draw.dt', function (e, settings) { var namedCallback = el.data('on-draw'); if (typeof window[namedCallback] === 'function') { window[namedCallback](e, settings); } }); } else if (el.data('on-draw-rebind-confirmation')) { table.on('draw.dt', function (e) { self.rebindConfirmation(e); }); } return table; }; this.rebindConfirmation = function (e) { var self = this; var tableId = e.target.id; var toggles = WHMCS.ui.confirmation.register(); for(var i = 0, len = toggles.length; i < len; i++ ) { jQuery(toggles[i]).on( 'confirmed.bs.confirmation', function (e) { e.preventDefault(); WHMCS.http.jqClient.post( jQuery(e.target).data('target-url'), { 'token': csrfToken } ).done(function (data) { if (data.status === 'success' || data.status === 'okay') { self.getTableById(tableId, undefined).ajax.reload(); } }); } ); } }; return this; }, clipboard: function() { this.copy = function(e) { e.preventDefault(); var trigger = $(e.currentTarget); var contentElement = $(trigger).data('clipboard-target'); var container = $(contentElement).parent(); try { var tempElement = $('