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