(function( $ ) { 'use strict'; $(function () { /* Setting Page -> Tab Menu */ $('.nav-tab-wrapper a').on("click", function (e) { var id = $(e.target).attr("href").substr(1); window.location.hash = id; $('.amp-wp-admin-settings').hide(); $('.nav-tab-active').removeClass('nav-tab-active'); $($(this).attr('href')).show(); $(this).addClass('nav-tab-active'); return false; }); /* Display Settings Tabs Previous State on Form Submit */ if (window.location.hash.length > 0) { $('.amp-wp-admin-settings').hide(); $('.nav-tab-active').removeClass('nav-tab-active'); $(window.location.hash).show(); $('a[href="' + window.location.hash + '"]').addClass('nav-tab-active'); } /** Analytics **/ $(".analytic-switch").on('click', function () { if ( $(this).is(":checked") ) { $('.'+$(this).data('id')).animate({ width: [ "toggle", "swing" ], height: [ "toggle", "swing" ], opacity: "toggle" }, 500, "linear", function() { $('.'+$(this).data('id')).css('display', 'table-row') ; }); } else { $('.'+$(this).data('id')).animate({ width: [ "toggle", "swing" ], height: [ "toggle", "swing" ], opacity: "toggle" }, 500, "linear", function() { $('.'+$(this).data('id')).css('display', 'none') ; }); } }); $(".analytic-switch").on('change', function () { if( $(".analytic-switch:checked").length > 0 ) { $('#section_analytics_settings').show('slow'); } else { $('#section_analytics_settings').hide('slow'); } }); /** Notice Bar & GDPR **/ $(".noticebar-gdpr-switch").on('click', function () { if ( $(this).is(":checked") ) { $('.'+$(this).data('id')).animate({ width: [ "toggle", "swing" ], height: [ "toggle", "swing" ], opacity: "toggle" }, 500, "linear", function() { $('.'+$(this).data('id')).css('display', 'table-row') ; }); } else { $('.'+$(this).data('id')).animate({ width: [ "toggle", "swing" ], height: [ "toggle", "swing" ], opacity: "toggle" }, 500, "linear", function() { $('.'+$(this).data('id')).css('display', 'none') ; }); } }); }); })( jQuery );