From 5f271c82c6140a0701a1676083378ca6fe75788f Mon Sep 17 00:00:00 2001 From: yuriinalivaiko Date: Sun, 31 Jul 2022 19:06:55 +0300 Subject: [PATCH] - fixed privacy policy toggler --- assets/js/um-gdpr.js | 32 ++++++++++++++++---------------- assets/js/um-gdpr.min.js | 2 +- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/assets/js/um-gdpr.js b/assets/js/um-gdpr.js index 31c0fde9..f06d5907 100644 --- a/assets/js/um-gdpr.js +++ b/assets/js/um-gdpr.js @@ -1,22 +1,22 @@ -(function( $ ) { +(function ( $ ) { 'use strict'; - $(document).on('click', "a.um-toggle-gdpr" ,function() { - - var me = jQuery(this); + $( document ).on( 'click', 'a.um-toggle-gdpr', function ( e ) { + let $a = jQuery( e.currentTarget ); + let $area = $a.closest( '.um-field-area' ); + let $content = $area.find( '.um-gdpr-content' ); - $( ".um-gdpr-content" ).toggle( "fast", function() { - if( $( ".um-gdpr-content" ).is(':visible') ){ - me.text( me.data('toggle-hide') ); - } - - if( $( ".um-gdpr-content" ).is(':hidden') ){ - me.text( me.data('toggle-show') ); - } - - }); - - }); + if ( $content.is( ':visible' ) ) { + $area.find( 'a.um-toggle-gdpr' ).text( $a.data( 'toggle-show' ) ); + $content.hide().find( 'a.um-toggle-gdpr' ).remove(); + if ( $a.length ) { + $a.get( 0 ).scrollIntoView(); + } + } else { + $area.find( 'a.um-toggle-gdpr' ).text( $a.data( 'toggle-hide' ) ); + $content.show().prepend( $a.clone() ); + } + } ); })( jQuery ); diff --git a/assets/js/um-gdpr.min.js b/assets/js/um-gdpr.min.js index f3e35c42..d862d028 100644 --- a/assets/js/um-gdpr.min.js +++ b/assets/js/um-gdpr.min.js @@ -1 +1 @@ -!function(e){"use strict";e(document).on("click","a.um-toggle-gdpr",function(){var t=jQuery(this);e(".um-gdpr-content").toggle("fast",function(){e(".um-gdpr-content").is(":visible")&&t.text(t.data("toggle-hide")),e(".um-gdpr-content").is(":hidden")&&t.text(t.data("toggle-show"))})})}(jQuery); \ No newline at end of file +!function(){"use strict";jQuery(document).on("click","a.um-toggle-gdpr",function(e){let t=jQuery(e.currentTarget),g=t.closest(".um-field-area"),o=g.find(".um-gdpr-content");o.is(":visible")?(g.find("a.um-toggle-gdpr").text(t.data("toggle-show")),o.hide().find("a.um-toggle-gdpr").remove(),t.length&&t.get(0).scrollIntoView()):(g.find("a.um-toggle-gdpr").text(t.data("toggle-hide")),o.show().prepend(t.clone()))})}(); \ No newline at end of file