PATH:
home
/
lab2454c
/
foreclass.com
/
wp-content
/
plugins
/
search-replace-for-elementor
/
assets
/
dev
/
js
var ELEMSNR = ELEMSNR || {}; var $ = jQuery || {}; ELEMSNR.pluginURL = elemsnr.plugin_url; ELEMSNR.ajaxURL = elemsnr.ajax_url; ELEMSNR.ajaxNonce = elemsnr.ajax_nonce; /** * Switch between Text-only and Links search methods. */ ELEMSNR.toggleSearchMethod = function( event ) { var $elem = $( event.target ); if ( 'elemsnr-text-only' === $elem.prop( 'id' ) ) { $( 'input[name="elemsnr-case-sensitive"]' ) .prop( 'disabled', false ); $( 'input[name="elemsnr-search-phrase"]' ) .prop( { 'type' : 'text', 'placeholder' : 'Enter your search phrase...', 'readonly': false, 'class' : 'regular-text' } ) $( '.elemsnr-search-phrase .description small' ) .html( 'Search phrase is required with minimum of 3 characters, no HTML allowed.' ); $( 'input[name="elemsnr-replace-with-phrase"]' ) .prop( { 'type' : 'text', 'placeholder' :'Enter your replace with phrase...', 'readonly': false, 'class' : 'regular-text' } ) $( '.elemsnr-replace-with-phrase .description small' ) .html( 'Search phrase is required with minimum of 3 characters, no HTML allowed.' ); } if ( 'elemsnr-links' === $elem.prop( 'id' ) ) { $( 'input[name="elemsnr-case-sensitive"]' ) .prop( 'checked', false ); $( 'input[name="elemsnr-case-sensitive"]' ) .prop( 'disabled', true ); $( 'input[name="elemsnr-search-phrase"]' ) .prop( { 'type' : 'url', 'placeholder' : 'Enter your search URL...', 'readonly': false, 'class' : 'regular-text' } ) $( '.elemsnr-search-phrase .description small' ) .html( 'Search URL is required, starting with http(s)://.' ); $( 'input[name="elemsnr-replace-with-phrase"]' ) .prop( { 'type' : 'url', 'placeholder' : 'Enter your replace with URL...', 'readonly': false, 'class' : 'regular-text' } ) $( '.elemsnr-replace-with-phrase .description small' ) .html( 'Replace with URL is required, starting with http(s)://.' ); } if ( 'elemsnr-images' === $elem.prop( 'id' ) ) { $( 'input[name="elemsnr-case-sensitive"]' ) .prop( 'checked', false ); $( 'input[name="elemsnr-case-sensitive"]' ) .prop( 'disabled', true ); $( 'input[name="elemsnr-search-phrase"]' ) .prop( { 'type' : 'url', 'placeholder' : 'Select your search Image...', 'readonly': true, 'class' : 'regular-text elemsnr-media-modal' } ) $( '.elemsnr-search-phrase .description small' ) .html( 'Search Image is required.' ); $( 'input[name="elemsnr-replace-with-phrase"]' ) .prop( { 'type' : 'url', 'placeholder' : 'Select your replace with Image...', 'readonly': true, 'class' : 'regular-text elemsnr-media-modal' } ) $( '.elemsnr-replace-with-phrase .description small' ) .html( 'Replace with Image is required.' ); } }; /** * Toggle post types containers. */ ELEMSNR.togglePostTypesCont = function( event ) { var $elem = $( event.target ); var postCont = $elem.closest( 'p' ).next(); postCont.toggle(); }; /** * Auto-check all Elementor pages ready for search & replace. */ ELEMSNR.toggleAllPosts = function( event ) { var $elem = $( event.target ); var postCont = $elem.closest( '.elemsnr-scroll-container' ); postCont.find( 'p input:checkbox' ).each( function () { this.checked = !this.checked; } ); }; /** * Toggle widget data field keys and auto-check all. */ ELEMSNR.toggleWidgets = function( event ) { var $elem = $( event.target ); var dataFieldsCont = $elem.closest( 'p' ).next(); dataFieldsCont.toggle(); dataFieldsCont.find( 'input:checkbox' ).each( function () { if ( !this.disabled ) { this.checked = !this.checked; } } ); }; /** * Toggle between dry-run and actual search and replace fields. */ ELEMSNR.toggleDryRun = function( event ) { var $elem = $( event.target ); var $cont = $( '.elemsnr-admin' ); if ( 'yes' === $elem.val() ) { $cont.find( '.elemsnr-dry-run-button' ).show(); $cont.find( '.elemsnr-replace-with-phrase' ).hide(); $cont.find( '.elemsnr-submit-button' ).hide(); } else { $cont.find( '.elemsnr-dry-run-button' ).hide(); $cont.find( '.elemsnr-replace-with-phrase' ).show(); $cont.find( '.elemsnr-submit-button' ).show(); } }; /** * Toggle between HTML regular expression search and replace fields. */ ELEMSNR.toggleHTMLRegex = function( event ) { var $elem = $( event.target ); var $cont = $( '.elemsnr-admin' ); if ( true === $elem.prop( 'checked' ) ) { $cont.find( '.elemsnr-dry-run' ).hide(); $cont.find( 'input[name="elemsnr-dry-run"]') .prop( 'disabled', true ); $cont.find( '.elemsnr-text-and-link' ).hide(); $cont.find( 'input[name="elemsnr-text-and-link"]') .prop( 'disabled', true ); $cont.find( 'input[name="elemsnr-case-sensitive"]') .prop( 'disabled', true ); $cont.find( '.elemsnr-replace-with-phrase' ).show(); $cont.find( '.elemsnr-submit-button' ).show(); $cont.find( 'input[name="elemsnr-search-phrase"]' ) .prop( { 'type' : 'text', 'placeholder' : 'Enter your regular expression...', 'readonly' : false, 'class' : 'regular-text' } ); $cont.find( 'input[name="elemsnr-replace-with-phrase"]' ) .prop( { 'type' : 'text', 'placeholder' : 'Enter your replace with phrase or HTML...', 'readonly' : false, 'class' : 'regular-text' } ); $cont.find( '#elemsnr-output' ) .addClass( 'elemsnr-output-active' ) .html( ` <strong>Important:</strong> It is strongly recommended to <a href="/wp-admin/admin.php?page=elemsnr-backup">backup your database</a> before you run the search and replace. Learn how to use regular expressions at <a href="https://www.regular-expressions.info/" target="_blank">Regular Expressions</a>. ` ); $cont.find( '.elemsnr-search-phrase small' ).hide(); $cont.find( '.elemsnr-replace-with-phrase small' ).hide(); $cont.find( '.elemsnr-html-regexp-button' ).show(); $cont.find( '.elemsnr-dry-run-button' ).hide(); $cont.find( '.elemsnr-submit-button' ).hide(); } else { $cont.find( '.elemsnr-dry-run' ).show(); $cont.find( 'input[name="elemsnr-dry-run"]') .prop( 'disabled', false ); $cont.find( '.elemsnr-text-and-link' ).show(); $cont.find( 'input[name="elemsnr-text-and-link"]') .prop( 'disabled', false ); $cont.find( 'input[name="elemsnr-case-sensitive"]') .prop( 'disabled', false ); if ( true === $cont.find( 'input#elemsnr-text-only' ).prop( 'checked' ) ) { $cont.find( 'input[name="elemsnr-search-phrase"]' ) .prop( { 'type' : 'text', 'placeholder' : 'Enter your search phrase...', 'readonly' : false, 'class' : 'regular-text' } ); $cont.find( 'input[name="elemsnr-replace-with-phrase"]' ) .prop( { 'type' : 'text', 'placeholder' : 'Enter your replace with phrase...', 'readonly' : false, 'class' : 'regular-text' } ); } if ( true === $cont.find( 'input#elemsnr-links' ).prop( 'checked' ) ) { $cont.find( 'input[name="elemsnr-search-phrase"]' ) .prop( { 'type' : 'text', 'placeholder' : 'Enter your search URL...', 'readonly' : false, 'class' : 'regular-text' } ); $cont.find( 'input[name="elemsnr-replace-with-phrase"]' ) .prop( { 'type' : 'text', 'placeholder' : 'Enter your replace with URL...', 'readonly' : false, 'class' : 'regular-text' } ); $cont.find( 'input#elemsnr-case-sensitive' ) .prop( 'disabled', true ) } if ( true === $cont.find( 'input#elemsnr-images' ).prop( 'checked' ) ) { $cont.find( 'input[name="elemsnr-search-phrase"]' ) .prop( { 'type' : 'text', 'placeholder' : 'Select your search Image...', 'readonly' : true, 'class' : 'regular-text elemsnr-media-modal' } ); $cont.find( 'input[name="elemsnr-replace-with-phrase"]' ) .prop( { 'type' : 'text', 'placeholder' : 'Select your replace with Image...', 'readonly' : true, 'class' : 'regular-text elemsnr-media-modal' } ); $cont.find( 'input#elemsnr-case-sensitive' ) .prop( 'disabled', true ) } $cont.find( '#elemsnr-output' ) .removeClass( 'elemsnr-output-active' ) .empty(); $cont.find( '.elemsnr-search-phrase small' ).show(); $cont.find( '.elemsnr-replace-with-phrase small' ).show(); $cont.find( '.elemsnr-replace-with-phrase ' ).hide(); $cont.find( 'input#elemsnr-dry-run-no' ) .prop( 'checked', false ); $cont.find( 'input#elemsnr-dry-run-yes' ) .prop( 'checked', true ); $cont.find( '.elemsnr-html-regexp-button' ).hide(); $cont.find( '.elemsnr-dry-run-button' ).show(); $cont.find( '.elemsnr-submit-button' ).hide(); } } /** * Actions. */ ;( function ( $, _ ) { $( document ).on( 'click', 'input[name="elemsnr-text-and-link"]', ELEMSNR.toggleSearchMethod ); $( document ).on( 'click', 'input[name="elemsnr-post-type[]"]', ELEMSNR.togglePostTypesCont ); $( document ).on( 'click', 'input[name="elemsnr-toggle-posts"]', ELEMSNR.toggleAllPosts ); $( document ).on( 'click', 'input[name="elemsnr-dry-run"]', ELEMSNR.toggleDryRun ); $( document ).on( 'click', 'input[name="elemsnr-html-regexp"]', ELEMSNR.toggleHTMLRegex ); } )( jQuery );
[-] elemsnr-admin.js
[edit]
[+]
..
[-] elemsnr-search-replace.js
[edit]