// App
const App = function () {
/**
*
* @param issetlet
* @param caselet
* @returns {*}
*/
const handleIsset = function (issetlet, caselet) {
return issetlet !== undefined && issetlet !== null ? issetlet : caselet;
};
/**
*
* @param el
* @returns {boolean}
*/
const handleExists = function (el) {
return el.length > 0;
}
/**
*
* @param text
* @param title
* @param type
* @returns {*|void}
*/
const handleAlert = function (text, title, type) {
return swal.fire({
type: handleIsset(type, 'error'),
title: handleIsset(title, Messages.valid.error()),
html: handleIsset(text, Messages.valid.emptyData())
});
};
/**
*
* @param config
* @returns {*|void}
*/
const handleAlertConfirm = function (config) {
return swal.fire({
type: handleIsset(config.type, 'warning'),
title: handleIsset(config.title, Messages.valid.confirmTitle()),
html: handleIsset(config.text, Messages.valid.confirmText()),
showCancelButton: handleIsset(config.showCancelButton, true),
cancelButtonText: 'nie',
confirmButtonText: 'tak',
}).then(function (result) {
if (result.value) {
if (config.yes && typeof (config.yes) === 'function') {
config.yes.call(this);
}
}
});
};
/**
*
* @param text
* @param type
*/
const handleAlertFormValid = function (text, type) {
$('.form-valid-alert').remove();
let view =
'
';
$('form').append(view);
$('.form-valid-alert').fadeIn();
};
/**
*
* @param mixedlet
* @returns {boolean}
*/
const handleEmpty = function (mixedlet) {
let undef, key, i, len, emptyValues = [undef, null, false, 0, '', '0']
for (i = 0, len = emptyValues.length; i < len; i++) {
if (mixedlet === emptyValues[i]) return true
}
if (typeof mixedlet === 'object') {
for (key in mixedlet) {
if (mixedlet.hasOwnProperty(key)) return false;
}
return true
}
return false
};
/**
*
* @param needle
* @param haystack
* @param argStrict
* @returns {boolean}
*/
const handleInArray = function (needle, haystack, argStrict) {
let key = ''
let strict = !!argStrict;
// we prevent the double check (strict && arr[key] === ndl) || (!strict && arr[key] === ndl)
// in just one for, in order to improve the performance
// deciding wich type of comparation will do before walk array
if (strict) {
for (key in haystack) {
if (haystack[key] === needle) {
return true
}
}
} else {
for (key in haystack) {
if (haystack[key] == needle) { // eslint-disable-line eqeqeq
return true
}
}
}
return false
};
/**
*
* @param path
* @returns {string}
*/
const handleGetUrl = function (path) {
return handleGetHost(window.location.pathname.substring(1) + '/' + path);
};
/**
*
* @param path
* @returns {string}
*/
const handleGetHost = function (path) {
return window.location.protocol + '//' + window.location.hostname + '/' + path;
};
/**
*
* @param path
* @returns {string}
*/
const handleGetAsset = function (path) {
return handleGetHost('assets/' + path);
};
/**
*
* @returns {*|string[]|null}
*/
const handleGetPageData = function () {
let $container = $('.n2i7xgqFWq');
if ($container.length > 0) {
let data = $container.data('data').toString();
if (data.indexOf(',') !== -1) {
data = data.split(',');
}
return data;
}
return null;
};
/**
*
* @param config
* @returns {*|void}
*/
const handleCswal = function (config) {
return swal.fire({
title: config.title,
html: config.text,
type: config.type,
allowOutsideClick: false
});
};
/**
*
* @returns {URLSearchParams}
*/
const handleGetURLParams = function () {
return (new URL(document.location)).searchParams;
};
/**
*
* @param toArray
* @returns {string|string[]}
*/
const handleGetUrlPathName = function (toArray) {
let pathname = window.location.pathname.substring(1);
if (toArray === true) {
return pathname.split('/');
}
return pathname;
};
/**
*
* @param config
*/
const handleAjaxProblem = function (config) {
swal.fire({
title: config.title,
type: 'error',
html: !handleEmpty(config.info) ? config.text + '
' + config.info : config.text,
showCancelButton: handleIsset(config.cancelButton, true),
showConfirmButton: handleIsset(config.confirmButton, true),
cancelButtonText: !handleEmpty(config.cancelButtonText) ? config.cancelButtonText : 'Zamknij',
confirmButtonText: 'Ponów',
allowOutsideClick: false
}).then(function (result) {
if (result.value) {
if (config.callbackValue && typeof (config.callbackValue) === 'function') {
config.callbackValue.call(this);
}
} else {
if (config.reload) {
location.reload();
} else if (config.callback && typeof (config.callback) === 'function') {
config.callback.call(this);
}
}
});
};
/**
*
* @param email
* @returns {boolean}
*/
const handleValidEmail = function (email) {
const regex_email = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return regex_email.test(email);
};
/**
*
* @param phone
* @returns {boolean}
*/
const handleValidPhone = function (phone) {
const regex_phone = /^([0-9]{9})$/;
return regex_phone.test(phone);
};
/**
*
* @param config
*/
const handleAjaxStandard = function (config) {
let $btn = config.btn;
let $form = $('.auth-forms');
let isAlertValidForm = handleIsset(config.isAlertFormValid, true);
let preloaderButton = handleIsset(config.preloaderButton, false);
let preloader = handleIsset(config.preloader, true);
let preloaderType = handleIsset(config.preloaderType, 'normal');
$().Ajax().load({
preloader: {
show: false,
},
source: {
method: config.method,
routeName: config.routeName,
routeParam: config.routeParam,
cache: config.cache,
processData: config.processData,
contentType: config.contentType,
data: config.data,
before: function () {
if (preloader) {
preloaderButton ? $btn.preloaderButton(preloaderType).show() : $form.preloaderForm().show();
}
},
done: function (response) {
if ($btn !== undefined) {
$btn.removeClass('stoped');
}
switch (response.status) {
case true :
if (preloader) {
preloaderButton ? $btn.preloaderButton(preloaderType).hide() : $form.preloaderForm().hide();
}
if (config.success && typeof (config.success) === 'function') {
return config.success.call(this, response.data);
}
break;
case false:
if (preloader) {
preloaderButton ? $btn.preloaderButton(preloaderType).hide() : $form.preloaderForm().hide();
}
isAlertValidForm ?
App.AlertFormValid(response.error, 'danger') :
App.alert(response.error);
if (config.errorDone && typeof (config.errorDone) === 'function') {
return config.errorDone.call(this, response);
}
break;
default :
if (preloader) {
preloaderButton ? $btn.preloaderButton(preloaderType).hide() : $form.preloaderForm().hide();
}
App.alert('Wystąpił nieoczekiwany problem! Odswież stronę i spróbuj ponownie!');
}
},
fail: function () {
if ($btn !== undefined) {
$btn.removeClass('stoped');
}
if (preloader) {
preloaderButton ? $btn.preloaderButton(preloaderType).hide() : $form.preloaderForm().hide();
}
if (config.fail && typeof (config.fail) === 'function') {
return config.fail.call(this);
}
}
}
});
};
const handleToPrevPage = function () {
window.history.back();
};
/**
*
* @returns {string}
*/
const handlePrevPage = function () {
return document.referrer;
};
/**
*
* @returns {string}
*/
const handleRand = function () {
return Math.random().toString(36).slice(2);
};
/**
*
* @param str
* @returns {number}
*/
const handleHashCode = function (str) {
let hash = 0, i, chr;
for (i = 0; i < str.length; i++) {
chr = str.charCodeAt(i);
hash = ((hash << 5) - hash) + chr;
hash |= 0; // Convert to 32bit integer
}
return hash;
};
/**
*
* @param name
* @param data
* @param value
*/
const handleAppendToStorage = function (name, data, value) {
let old = localStorage.getItem(name);
if (old === null) {
old = ''
}
let array = JSON.parse(old) || [];
if (array.indexOf(value) === -1) {
array.push(data);
}
localStorage.setItem(name, array + data);
};
/**
*
* @param key
* @param value
*/
const handleToggleStorage = function (key, value) {
localStorage.removeItem(key);
localStorage.setItem(key, value);
};
/**
*
* @param config
* @returns {*}
*/
const handleBootbox = function () {
let dialog = null;
/**
*
* @param config
* @returns {*}
*/
const handleLoad = function (config) {
let bugfix = handleIsset(config.bugfix, false);
let zIndex = handleIsset(config.zIndex, false);
let extendFooter = handleIsset(config.extendFooter, false);
let options = {
title: config.title,
message: config.message,
size: config.size,
buttons: {
cancel: {
label: 'Zamknij',
className: 'btn-secondary btn',
callback: function () {
if (config.cancel && typeof (config.cancel) === 'function') {
return config.cancel.call(this);
}
}
},
}
};
if (config.ok !== undefined) {
options.buttons.ok = {
label: config.ok.label,
className: config.ok.class + ' btn',
callback: function () {
if (config.ok.callback && typeof (config.ok.callback) === 'function') {
return config.ok.callback.call(this);
}
}
}
}
if (config.noclose !== undefined) {
options.buttons.noclose = {
label: config.noclose.label,
className: config.noclose.class + ' btn',
callback: function () {
if (config.noclose.callback && typeof (config.noclose.callback) === 'function') {
return config.noclose.callback.call(this);
}
}
}
}
let isLoad = config.load !== undefined && config.load === true;
if (isLoad) {
options.message = '';
}
dialog = bootbox.dialog(options);
if (bugfix) {
dialog.find('div.modal-dialog').find('.bootbox-close-button').text('');
}
if (zIndex) {
dialog.css('z-index', zIndex);
dialog.next($('.modal-backdrop')).css('z-index', (zIndex - 10));
}
if (extendFooter !== false) {
const $modalFooter = dialog.find('.modal-footer');
const $buttons = $modalFooter.find('button').clone();
$modalFooter.addClass('modal-footer-extend');
$modalFooter.prepend('');
$modalFooter.append('');
$modalFooter.find('#buttons').html($buttons);
$modalFooter.find('#extend').html(extendFooter);
$modalFooter.find('> button').remove();
$modalFooter.find('#buttons > button').on('click', function () {
const isCancel = $(this).hasClass('bootbox-cancel');
dialog.modal('hide');
if (isCancel) {
if (config.cancel && typeof (config.cancel) === 'function') {
return config.cancel.call(this);
}
} else {
if (config.ok.callback && typeof (config.ok.callback) === 'function') {
return config.ok.callback.call(this);
}
}
});
}
return dialog;
};
/**
*
* @param callback
*/
const handleInit = function (callback) {
$('.bootbox-loader').fadeOut(300, function () {
$(this).remove();
dialog.init(function () {
if (callback && typeof (callback) === 'function') {
return callback.call(this, dialog);
}
});
});
};
return {
/**
*
* @param config
* @returns {*}
*/
load: function (config) {
return handleLoad(config);
},
/**
*
* @param callback
*/
init: function (callback) {
return handleInit(callback);
}
}
}();
/**
*
* @param $el
*/
const handleMaginificGallery = function ($el) {
$el.magnificPopup({
delegate: 'a',
type: 'image',
preloader: true,
gallery: {
enabled: true
},
removalDelay: 500, //delay removal by X to allow out-animation
callbacks: {
beforeOpen: function () {
// just a hack that adds mfp-anim class to markup
this.st.image.markup = this.st.image.markup.replace('mfp-figure', 'mfp-figure mfp-with-anim');
this.st.mainClass = this.st.el.attr('data-effect');
}
},
closeOnContentClick: true,
midClick: true // allow opening popup on middle mouse click. Always set it to true if you don't provide alternative source.
});
};
const handleAnchor = function () {
let $root = $('html, body');
$('.anchor').on('click', function (e) {
e.preventDefault();
const $btn = $(this);
const target = $btn.attr('href');
const offset = $btn.attr('data-offset') || 0;
const clipboard = $btn.attr('data-clipboard') || false;
$root.animate({
scrollTop: $(target).offset().top - offset,
}, 500);
window.history.pushState(target, '', target);
if (clipboard !== false) {
App.clipboard(location.href);
}
return false;
});
if (window.location.hash) {
const $el = $(window.location.hash);
const offAnimation = $el.attr('data-off-animation') || true;
const offset = $el.attr('data-offset') || 0;
if ($el.length > 0) {
$root.animate({
scrollTop: $el.offset().top - offset
}, 500);
if (offAnimation) {
$el.find('figure').addClass('shadow-pulse preview-product');
}
}
}
};
/**
*
* @param html
* @returns {string | string}
*/
const handleStripHtml = function (html) {
let tmp = document.createElement('DIV');
tmp.innerHTML = html;
let value = tmp.textContent || tmp.innerText;
return value.replace(/(\r\n|\n|\r)/gm, '') || '';
};
/**
*
* @param val
* @returns {number}
*/
const handleBoolToInt = function (val) {
return val ? 1 : 0;
};
/**
*
* @param val
* @returns {number}
*/
const handleToInt = function (val) {
return parseInt(val, 10);
};
const handleRefreshPage = function () {
(function (seconds) {
let refresh,
intvrefresh = function () {
clearInterval(refresh);
refresh = setTimeout(function () {
location.href = location.href;
}, seconds * 1000);
};
$(document).on('keypress click mousemove', function () {
intvrefresh()
});
intvrefresh();
}(300));
};
/**
*
* @param $el
* @param index
* @returns {any}
*/
const replaceValue = function ($el, index) {
let replace = $el.attr('data-replace');
let attr = $el.attr('data-replace-attr');
let parse = JSON.parse(replace);
let value = parse[index];
attr ? $el.attr(attr, value) : $el.text(value);
};
/**
*
* @param attr
* @param callback
*/
const handleCreateScript = function (attr, callback) {
let script = document.createElement('script');
$.each(attr, function (k, v) {
script.setAttribute(k, v);
});
if (callback && typeof (callback) === 'function') {
callback.call(this);
}
document.body.appendChild(script);
};
/**
*
* @param text
*/
const handleClipboard = function (text) {
const $temp = $("");
$('body').append($temp);
$temp.val(text).select();
document.execCommand('copy');
$temp.remove();
};
/**
*
* @returns string
*/
const handleCurrentLang = function () {
return $('#currentLang').attr('data-current-lang') || 'en';
};
/**
*
* @param index
* @returns {*|jQuery}
*/
const handleGetData = function (index) {
return $('#data').attr('data-' + index);
};
return {
/**
*
* @param text
* @param title
* @param type
* @returns {*|void}
*/
alert: function (text, title, type) {
return handleAlert(text, title, type);
},
/**
*
* @param config
* @returns {*|void}
*/
alertConfirm: function (config) {
return handleAlertConfirm(config);
},
/**
*
* @param text
* @param type
* @constructor
*/
AlertFormValid: function (text, type) {
return handleAlertFormValid(text, type);
},
/**
*
* @param mixedlet
* @returns {boolean}
*/
empty: function (mixedlet) {
return handleEmpty(mixedlet);
},
/**
*
* @param needle
* @param haystack
* @param argStrict
* @returns {boolean}
*/
inArray: function (needle, haystack, argStrict) {
return handleInArray(needle, haystack, argStrict);
},
/**
*
* @param issetlet
* @param caselet
* @returns {*}
*/
isset: function (issetlet, caselet) {
return handleIsset(issetlet, caselet);
},
/**
*
* @param el
* @returns {boolean}
*/
exists: function (el) {
return handleExists(el);
},
/**
*
* @param path
* @returns {string}
*/
getUrl: function (path) {
return handleGetUrl(path);
},
/**
*
* @param path
* @returns {string}
*/
getHost: function (path) {
return handleGetHost(path);
},
/**
*
* @param path
* @returns {string}
*/
getAsset: function (path) {
return handleGetAsset(path);
},
/**
*
* @returns {*|string[]|null}
*/
getPageData: function () {
return handleGetPageData();
},
/**
*
* @param config
* @returns {*|void}
*/
cswal: function (config) {
return handleCswal(config);
},
/**
*
* @returns {URLSearchParams}
*/
getURLParams: function () {
return handleGetURLParams();
},
/**
*
* @param toArray
* @returns {string|string[]}
*/
getUrlPathName: function (toArray) {
return handleGetUrlPathName(toArray);
},
/**
*
* @param config
* @constructor
*/
AjaxProblem: function (config) {
return handleAjaxProblem(config);
},
/**
*
* @param email
* @returns {boolean}
*/
ValidEmail: function (email) {
return handleValidEmail(email);
},
/**
*
* @param phone
* @returns {boolean}
*/
ValidPhone: function (phone) {
return handleValidPhone(phone);
},
/**
*
* @param config
* @constructor
*/
AjaxStandard: function (config) {
return handleAjaxStandard(config);
},
toPrevPage: function () {
return handleToPrevPage();
},
/**
*
* @returns {string}
*/
prevPage: function () {
return handlePrevPage();
},
/**
*
* @param name
* @param data
*/
appendToStorage: function (name, data) {
handleAppendToStorage(name, data);
},
/**
*
* @param key
* @param value
*/
toggleStorage: function (key, value) {
handleToggleStorage(key, value);
},
/**
*
* @returns {*}
*/
bootbox: function () {
return handleBootbox;
},
/**
*
* @param $el
*/
maginificGallery: function ($el) {
handleMaginificGallery($el);
},
/**
*
* @returns {string}
*/
rand: function () {
return handleRand();
},
/**
*
* @param str
* @returns {number}
*/
hashCode: function (str) {
return handleHashCode(str);
},
anchor: function () {
handleAnchor();
},
/**
*
* @param html
* @returns {string}
*/
stripHtml: function (html) {
return handleStripHtml(html);
},
/**
*
* @param val
* @returns {number}
*/
boolToInt: function (val) {
return handleBoolToInt(val);
},
/**
*
* @param val
* @returns {number}
*/
toInt: function (val) {
return handleToInt(val);
},
refreshPage: function () {
handleRefreshPage();
},
/**
*
* @param $el
* @param index
* @returns {*}
*/
replaceValue: function ($el, index) {
return replaceValue($el, index);
},
/**
*
* @param attr
* @param callback
*/
createScript: function (attr, callback) {
handleCreateScript(attr, callback);
},
/**
*
* @param $el
*/
clipboard: function (text) {
handleClipboard(text);
},
/**
*
* @returns string
*/
currentLang: function () {
return handleCurrentLang();
},
/**
*
* @param index
* @returns {*}
*/
getData: function(index) {
return handleGetData(index);
}
}
}();
//------------------------------------------------------------------
// PLUGINS
//------------------------------------------------------------------
(function ($) {
$.fn.preloaderButton = function (type) {
const $t = $(this);
const $parent = $t.parent();
return {
show: function (callback) {
if (type === 'normal') {
let view = '';
$parent.append(view);
$parent.css({
display: 'flex',
'align-items': 'center',
});
} else {
$t.find('span').hide();
$t.append('');
}
if (callback && typeof (callback) === 'function') {
callback.call(this);
}
},
hide: function (callback) {
if (type === 'normal') {
$parent.find('.preloader-button').fadeOut(300, function () {
if (callback && typeof (callback) === 'function') {
callback.call(this);
}
$(this).remove();
});
} else {
$('.preloader-button').fadeOut(300, function () {
if (callback && typeof (callback) === 'function') {
callback.call(this);
}
$t.find('span').show();
$(this).remove();
});
}
}
}
};
/**
*
* @returns {{hide: hide, show: show}}
*/
$.fn.preloaderData = function () {
const $t = $(this);
const $preloader = $('#preloader');
const sleep = function (milliseconds) {
let start = new Date().getTime();
for (let i = 0; i < 1e7; i++) {
if ((new Date().getTime() - start) > milliseconds) break;
}
};
return {
show: function (fadeIn, callback) {
if (App.empty($preloader)) {
let $view = '';
if (fadeIn == true) {
$view = $($view);
$view.hide().fadeIn(300);
}
if ($t.is('body')) $('body').addClass('overflow-hidden');
$t.prepend($view);
}
if (callback && typeof (callback) === 'function') {
callback.call(this);
}
},
hide: function (callback) {
sleep(300);
if (!App.empty($preloader)) {
$preloader.fadeOut(300, function () {
$(this).remove();
if ($t.is('body')) $('body').removeClass('overflow-hidden');
if (callback && typeof (callback) === 'function') {
callback.call(this);
}
});
}
}
};
};
/**
*
* @returns {{hide: hide, show: show}}
*/
$.fn.preloaderForm = function () {
const $t = $(this);
return {
show: function (callback) {
let view = '';
$t.append(view);
if (callback && typeof (callback) === 'function') {
callback.call(this);
}
},
hide: function (callback) {
$t.find('.preloader').fadeOut(300, function () {
if (callback && typeof (callback) === 'function') {
callback.call(this);
}
});
}
}
};
/**
*
* @returns {{reload: reload, load: load, params: params}}
* @constructor
*/
$.fn.Ajax = function () {
let $t = $(this);
// Temp Ajax Data
let loadSettings = {};
const load = function (config) {
let settings = $.extend({
preloader: true,
failName: null,
statutes: {},
source: {},
text: {}
}, config);
let success = false;
let preloader = App.isset(settings.preloader.show, true);
let routeName = App.isset(settings.source.routeName, '');
let routeParam = App.isset(settings.source.routeParam, {});
let url = App.isset(settings.source.url, laroute.route(routeName, routeParam));
let cache = App.isset(settings.source.cache, true);
let processData = App.isset(settings.source.processData, true);
let dataType = App.isset(settings.source.dataType, 'json');
let contentType = App.isset(settings.source.contentType, 'application/x-www-form-urlencoded;charset=UTF-8');
let method = App.isset(settings.source.method, 'POST');
let allowed = App.isset(settings.statutes.allowed, [true, null]);
let getStatus = App.isset(settings.statutes.getStatus, false);
let none_data = App.isset(settings.text.none_data, 'Brak danych do wyświetlenia.');
loadSettings = {
preloader: {
show: preloader,
before: settings.preloader.before
},
failName: settings.failName,
statutes: {
allowed: allowed,
getStatus: getStatus
},
source: {
url: url,
dataType: dataType,
contentType: contentType,
processData: processData,
cache: cache,
method: method,
data: settings.source.data,
before: settings.source.before,
done: settings.source.done,
fail: settings.source.fail,
reload: settings.source.reload
},
text: {
none_data: none_data
}
};
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
$.ajax({
url: url,
method: method,
dataType: dataType,
contentType: contentType,
processData: processData,
cache: cache,
data: settings.source.data,
beforeSend: function () {
// Reload Ajax
if (settings.source.reload && typeof (settings.source.reload) === 'function') {
settings.source.reload.call(this);
}
// Preloader
if (settings.source.before && typeof (settings.source.before) === 'function') {
return settings.source.before.call(this);
} else if (preloader == true) {
$t.preloaderData().show(true);
}
},
}).done(function (response) {
$('.form-valid-alert').remove();
if (response.status == -10) {
App.cswal({
title: 'Twoja sesja wygasła!',
text: 'Musisz ponownie się zalogować, aby kontynuuować operację.',
type: 'error'
}).then(function () {
location.reload()
});
} else if (allowed.indexOf(response.status) != -1) {
if (preloader == true) {
if (settings.preloader.before && typeof (settings.preloader.before) === 'function') {
return settings.preloader.before.call(this);
}
$t.preloaderData().hide(function () {
if ((response.status == null || (App.empty(response.data) && response.data !== undefined)) && none_data != false) {
$t.append('');
}
if (settings.source.done && typeof (settings.source.done) === 'function') {
return settings.source.done.call(this, !getStatus ? response.data : response);
}
});
} else {
if (settings.source.done && typeof (settings.source.done) === 'function') {
return settings.source.done.call(this, !getStatus ? response.data : response);
}
}
success = true;
} else {
App.AjaxProblem({
title: 'Wystąpił nieoczekiwany problem',
text: 'Wystąpił nieoczekiwany problem, spróbuj ponownie wysłać żądanie badź skontaktuj się z adnimistratorem.',
callbackValue: function () {
reload();
},
callback: function () {
$t.preloaderData().hide();
}
});
}
}).fail(function (jqXHR, textStatus, errorThrown) {
App.AjaxProblem({
title: 'Bład połączenia z serwerem!',
text: window.navigator.onLine ?
'Wystąpił problem z serwerem i Twoje żądanie nie może zostać obsłużone! Spróbuj ponownie wysłać żądanie, bądź skontakuj się z administratorem.' :
'Sprawdź swoje połączenie z internetem.',
callbackValue: function () {
reload();
},
callback: function () {
$t.preloaderData().hide();
}
});
if (settings.source.fail && typeof (settings.source.fail) === 'function') {
return settings.source.fail.call(this, jqXHR, textStatus, errorThrown);
}
});
return success;
};
/**
*
* Overloading the load method.
*
* @return void
* @package GetAjaxDataInfo
*
*/
const reload = function () {
load(loadSettings);
};
/**
*
* Sets of new parameters
* to the load method.
*
* @return void
*
* @package GetAjaxDataInfo
*
* @param config
*/
const params = function (config) {
for (let key in config) loadSettings.data[key] = config[key];
reload();
};
return {
load: function (settings) {
load(settings)
},
params: function (settings) {
params(settings)
},
reload: function () {
reload()
}
};
}
})(jQuery);