PluginProbe
Customify / 2.10.1
Customify v2.10.1
2.10.9 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.7.1 1.3.0 1.3.1 1.4.0 1.4.1 1.4.2 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.5.5 1.5.6 1.5.7 1.6.0 1.6.0.1 1.6.5 1.7.0 1.7.1 All 77 releases
customify / js / settings-page.js

settings-page.js in Customify 2.10.1, at js/settings-page.js

90 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function ($) {
2
3 'use strict'
4 $(function () {
5
6 $(document).ready(function () {
7 $('#reset_theme_mods').on('click', function () {
8 let confirm = window.confirm('Are you sure?');
9
10 if ( ! confirm ) {
11 return false;
12 }
13
14 $.ajax({
15 url: customify.config.wp_rest.root + 'customify/v1/delete_theme_mod',
16 method: 'POST',
17 beforeSend: function (xhr) {
18 xhr.setRequestHeader('X-WP-Nonce', customify.config.wp_rest.nonce);
19 },
20 data: {
21 'customify_settings_nonce': customify.config.wp_rest.customify_settings_nonce
22 }
23 }).done(function (response) {
24 if ( response.success ) {
25 alert( 'Success: ' + response.data );
26 } else {
27 alert( 'No luck: ' + response.data );
28 }
29 }).error(function (e) {
30 console.log(e);
31 });
32 });
33
34 /* Ensure groups visibility */
35 $('.switch input[type=checkbox], .select select').each(function () {
36
37 if ($(this).data('show_group')) {
38
39 let show = false
40 if ($(this).attr('checked')) {
41 show = true
42 } else if (typeof $(this).data('display_option') !== 'undefined' && $(this).data('display_option') === $(this).val()) {
43 show = true
44 }
45
46 toggleGroup($(this).data('show_group'), show)
47 }
48 })
49
50 $('.switch, .select ').on('change', 'input[type=checkbox], select', function () {
51 if ($(this).data('show_group')) {
52 let show = false
53 if ($(this).attr('checked')) {
54 show = true
55 } else if (typeof $(this).data('display_option') !== 'undefined' && $(this).data('display_option') === $(this).val()) {
56 show = true
57 }
58 toggleGroup($(this).data('show_group'), show)
59 }
60 })
61 });
62
63 const toggleGroup = function (name, show) {
64 const $group = $('#' + name)
65
66 if (show) {
67 $group.show()
68 } else {
69 $group.hide()
70 }
71 }
72 })
73
74 $.fn.check_for_extended_options = function () {
75 const extended_options = $(this).siblings('fieldset.group')
76 if ($(this).data('show-next')) {
77 if (extended_options.data('extended') === true) {
78 extended_options
79 .data('extended', false)
80 .css('height', '0')
81 } else if ((typeof extended_options.data('extended') === 'undefined' && $(this).attr('checked') === 'checked') || extended_options.data('extended') === false) {
82 extended_options
83 .data('extended', true)
84 .css('height', 'auto')
85 }
86 }
87 }
88
89 }(jQuery))
90