| @@ -1,95 +1,97 @@ | ||
| 1 | -(function( $ ) { | |
| 2 | - 'use strict'; | |
| 1 | +(function ($) { | |
| 2 | + "use strict"; | |
| 3 | 3 | |
| 4 | - $(function() { | |
| 4 | + $(function () { | |
| 5 | + /* For Input Switch */ | |
| 6 | + $(".input-switch").on("click", function () { | |
| 7 | + var loader = $(this).parent().next(); | |
| 5 | 8 | |
| 6 | - /* For Input Switch */ | |
| 7 | - $( '.input-switch' ).on( 'click', function() { | |
| 8 | - var loader = $( this ).parent().next(); | |
| 9 | - | |
| 10 | - loader.show(); | |
| 11 | - | |
| 12 | - var main_control = $( this ); | |
| 13 | - var data = { | |
| 14 | - 'action' : 'ew_switch', | |
| 15 | - 'value' : this.checked, | |
| 16 | - 'option_name' : main_control.attr( 'rel' ) | |
| 17 | - }; | |
| 9 | + loader.show(); | |
| 18 | 10 | |
| 19 | - $.post( ajaxurl, data, function( response ) { | |
| 20 | - response = $.trim( response ); | |
| 11 | + var main_control = $(this); | |
| 12 | + var ew_nonce = main_control.prev("input").val(); | |
| 13 | + var data = { | |
| 14 | + action: "ew_switch", | |
| 15 | + value: this.checked, | |
| 16 | + security: ew_nonce, | |
| 17 | + option_name: main_control.attr("rel"), | |
| 18 | + }; | |
| 21 | 19 | |
| 22 | - if ( '1' == response ) { | |
| 23 | - main_control.parent().parent().addClass( 'active' ); | |
| 24 | - main_control.parent().parent().removeClass( 'inactive' ); | |
| 25 | - } else if( '0' == response ) { | |
| 26 | - main_control.parent().parent().addClass( 'inactive' ); | |
| 27 | - main_control.parent().parent().removeClass( 'active' ); | |
| 28 | - } else { | |
| 29 | - alert( response ); | |
| 30 | - } | |
| 31 | - | |
| 32 | - loader.hide(); | |
| 33 | - }); | |
| 34 | - }); | |
| 35 | - /* For Input Switch End */ | |
| 36 | - }); | |
| 20 | + $.post(ajaxurl, data, function (response) { | |
| 21 | + response = $.trim(response); | |
| 37 | 22 | |
| 38 | - $(function() { | |
| 23 | + if ("1" == response) { | |
| 24 | + main_control.parent().parent().addClass("active"); | |
| 25 | + main_control.parent().parent().removeClass("inactive"); | |
| 26 | + } else if ("0" == response) { | |
| 27 | + main_control.parent().parent().addClass("inactive"); | |
| 28 | + main_control.parent().parent().removeClass("active"); | |
| 29 | + } else { | |
| 30 | + alert(response); | |
| 31 | + } | |
| 39 | 32 | |
| 40 | - // Tabs | |
| 41 | - $('.catchp_widget_settings .nav-tab-wrapper a').on('click', function(e){ | |
| 42 | - e.preventDefault(); | |
| 33 | + loader.hide(); | |
| 34 | + }); | |
| 35 | + }); | |
| 36 | + /* For Input Switch End */ | |
| 37 | + }); | |
| 43 | 38 | |
| 44 | - if( !$(this).hasClass('ui-state-active') ){ | |
| 45 | - $('.nav-tab').removeClass('nav-tab-active'); | |
| 46 | - $('.wpcatchtab').removeClass('active').fadeOut(0); | |
| 39 | + $(function () { | |
| 40 | + // Tabs | |
| 41 | + $(".catchp_widget_settings .nav-tab-wrapper a").on("click", function (e) { | |
| 42 | + e.preventDefault(); | |
| 47 | 43 | |
| 48 | - $(this).addClass('nav-tab-active'); | |
| 44 | + if (!$(this).hasClass("ui-state-active")) { | |
| 45 | + $(".nav-tab").removeClass("nav-tab-active"); | |
| 46 | + $(".wpcatchtab").removeClass("active").fadeOut(0); | |
| 49 | 47 | |
| 50 | - var anchorAttr = $(this).attr('href'); | |
| 48 | + $(this).addClass("nav-tab-active"); | |
| 51 | 49 | |
| 52 | - $(anchorAttr).addClass('active').fadeOut(0).fadeIn(500); | |
| 53 | - } | |
| 50 | + var anchorAttr = $(this).attr("href"); | |
| 54 | 51 | |
| 55 | - }); | |
| 52 | + $(anchorAttr).addClass("active").fadeOut(0).fadeIn(500); | |
| 53 | + } | |
| 56 | 54 | }); |
| 55 | + }); | |
| 57 | 56 | |
| 58 | - // jQuery Match Height init for sidebar spots | |
| 59 | - $(document).ready(function() { | |
| 60 | - $('.catchp-sidebar-spot .sidebar-spot-inner, .col-2 .catchp-lists li, .col-3 .catchp-lists li, .catch-modules').matchHeight(); | |
| 61 | - }); | |
| 57 | + // jQuery Match Height init for sidebar spots | |
| 58 | + $(document).ready(function () { | |
| 59 | + $( | |
| 60 | + ".catchp-sidebar-spot .sidebar-spot-inner, .col-2 .catchp-lists li, .col-3 .catchp-lists li, .catch-modules", | |
| 61 | + ).matchHeight(); | |
| 62 | + }); | |
| 62 | 63 | |
| 63 | - $(function(){ | |
| 64 | - /* CPT switch */ | |
| 65 | - $( '.ctp-switch' ).on( 'click', function() { | |
| 66 | - var loader = $( this ).parent().next(); | |
| 67 | - | |
| 68 | - loader.show(); | |
| 69 | - | |
| 70 | - var main_control = $( this ); | |
| 71 | - var data = { | |
| 72 | - 'action' : 'ctp_switch', | |
| 73 | - 'value' : this.checked, | |
| 74 | - 'option_name' : main_control.attr( 'rel' ) | |
| 75 | - }; | |
| 64 | + $(function () { | |
| 65 | + /* CPT switch */ | |
| 66 | + $(".ctp-switch").on("click", function () { | |
| 67 | + var loader = $(this).parent().next(); | |
| 76 | 68 | |
| 77 | - $.post( ajaxurl, data, function( response ) { | |
| 78 | - response = $.trim( response ); | |
| 69 | + loader.show(); | |
| 79 | 70 | |
| 80 | - if ( '1' == response ) { | |
| 81 | - main_control.parent().parent().addClass( 'active' ); | |
| 82 | - main_control.parent().parent().removeClass( 'inactive' ); | |
| 83 | - } else if( '0' == response ) { | |
| 84 | - main_control.parent().parent().addClass( 'inactive' ); | |
| 85 | - main_control.parent().parent().removeClass( 'active' ); | |
| 86 | - } else { | |
| 87 | - alert( response ); | |
| 88 | - } | |
| 89 | - loader.hide(); | |
| 90 | - }); | |
| 91 | - }); | |
| 92 | - /* CPT switch End */ | |
| 71 | + var main_control = $(this); | |
| 72 | + var ew_switch_tabs_nonce = main_control.prev("input").val(); | |
| 73 | + var data = { | |
| 74 | + action: "ctp_switch", | |
| 75 | + value: this.checked, | |
| 76 | + security: ew_switch_tabs_nonce, | |
| 77 | + option_name: main_control.attr("rel"), | |
| 78 | + }; | |
| 79 | + | |
| 80 | + $.post(ajaxurl, data, function (response) { | |
| 81 | + response = $.trim(response); | |
| 82 | + | |
| 83 | + if ("1" == response) { | |
| 84 | + main_control.parent().parent().addClass("active"); | |
| 85 | + main_control.parent().parent().removeClass("inactive"); | |
| 86 | + } else if ("0" == response) { | |
| 87 | + main_control.parent().parent().addClass("inactive"); | |
| 88 | + main_control.parent().parent().removeClass("active"); | |
| 89 | + } else { | |
| 90 | + alert(response); | |
| 91 | + } | |
| 92 | + loader.hide(); | |
| 93 | + }); | |
| 93 | 94 | }); |
| 94 | - | |
| 95 | -})( jQuery ); | |
| 95 | + /* CPT switch End */ | |
| 96 | + }); | |
| 97 | +})(jQuery); | |