: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
SGPBModals.prototype.changeModalContent = function (modal, newContent, targetId)
this.moveContentBeforeModalDestroy(targetId, modal);
const header = newContent.find(`#${targetId}Header`),
body = newContent.find(`#${targetId}Body`),
footer = newContent.find(`#${targetId}Footer`);
modal.find('.sgpb-modal-header').text(header.text());
modal.find('.sgpb-modal-body').html(body.children());
modal.find('#sgpb-modal-footer-action-btn').html(footer.children());
modal.data('target', newContent.attr('id'));
modal.find('select').sgpbselect2();
/* TODO fix and remove this function */
SGPBModals.prototype.modalInit = function ()
jQuery('.sgpb-modal-btn').on('click', function () {
const targetId = jQuery(this).data('target'),
target = jQuery('#' + targetId),
header = target.find(`#${targetId}Header`),
body = target.find(`#${targetId}Body`),
footer = target.find(`#${targetId}Footer`);
const content = that.modalContent(targetId, header.text(), body.children(), footer.children());
jQuery(content).appendTo(document.body);
that.actionsCloseModal();
SGPBModals.prototype.actionsCloseModal = function (closeOnBackDropClick = false, handleCloseEvent = undefined, handleEventArguments = null)
jQuery('.sgpb-close-icon, .sgpb-modal-cancel').on('click', function () {
if (typeof handleCloseEvent != 'undefined') {
handleCloseEvent(handleEventArguments)
that.moveContentBeforeModalDestroy(jQuery('.sgpb-modal').data('target'), jQuery('.sgpb-modal'));
that.destroyModal('cancel');
/* handle backdrop click and close */
if (closeOnBackDropClick){
jQuery('.sgpb.sgpb-modal').on('click', function (e) {
if(e.target !== this) return;
if (typeof handleCloseEvent != 'undefined') {
handleCloseEvent(handleEventArguments)
that.moveContentBeforeModalDestroy(jQuery('.sgpb-modal').data('target'), jQuery('.sgpb-modal'));
that.destroyModal('cancel');
jQuery(document).keyup(function (e) {
if (jQuery('.sgpb-modal')) {
if (typeof handleCloseEvent != 'undefined') {
handleCloseEvent(handleEventArguments)
that.moveContentBeforeModalDestroy(jQuery('.sgpb-modal').data('target'), jQuery('.sgpb-modal'));
that.destroyModal('cancel');
SGPBModals.prototype.openModal = function (content)
jQuery(content).appendTo(document.body);
/* TODO add reason logic callback for full control modal destroy moment */
SGPBModals.prototype.destroyModal = function (reason)
jQuery('.sgpb-modal').remove();
jQuery(document.body).removeClass('sgpb-overflow-hidden');
SGPBModals.prototype.moveContentBeforeModalDestroy = function (id, modal)
let target = jQuery('#' + id),
body = target.find(`#${id}Body`),
footer = target.find(`#${id}Footer`);
target.append(modal.find('.sgpb-modal-body').children());
body.append(modal.find('.sgpb-modal-body').children());
footer.append(modal.find('#sgpb-modal-footer-action-btn').children());
SGPBModals.prototype.modalContent = function (targetId, header = '', body = '', footerConfirmBtn = '', hideFooter = false, styles = '', hideCloseBtn = false)
jQuery(document.body).addClass('sgpb-overflow-hidden');
return jQuery('<div/>', {
"class": 'sgpb sgpb-modal',
"class": 'sgpb-modal-main',
"class": `sgpb-close-icon ${hideCloseBtn ? 'sgpb-display-none' : ''}`,
"class": 'sgpb-modal-header',
"class": 'sgpb-modal-body sgpb-width-100',
"class": `sgpb-modal-footer ${hideFooter ? 'sgpb-display-none' : ''}`,
"class": "sgpb-btn sgpb-btn-dark-outline sgpb-modal-cancel sgpb-margin-right-10",
id: 'sgpb-modal-footer-action-btn',
"class": "sgpb-display-inline-block",
/*this action is to pass already opened modal new content for each part of source code*/
SGPBModals.prototype.changeModalContentAdvanced = function (modal, header = '', body = '', confirmBtn = '', oldTargetId, newTargetId)
this.moveContentBeforeModalDestroy(oldTargetId, modal);
modal.find('.sgpb-modal-header').text(header);
modal.find('.sgpb-modal-body').html(body);
modal.find('#sgpb-modal-footer-action-btn').html(confirmBtn);
modal.data('target', newTargetId);
jQuery(document).ready(function () {
sgpbModalsObj = new SGPBModals();