-
Notifications
You must be signed in to change notification settings - Fork 121
/
Copy pathnginx-helper-admin.js
130 lines (107 loc) · 3 KB
/
nginx-helper-admin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**
* File to add JavaScript for nginx-helper.
*
* @package nginx-helper
*/
(function ($) {
'use strict';
/**
* All of the code for your admin-specific JavaScript source
* should reside in this file.
*
* Note that this assume you're going to use jQuery, so it prepares
* the $ function reference to be used within the scope of this
* function.
*
* From here, you're able to define handlers for when the DOM is
* ready:
*
* $(function() {
*
* });
*
* Or when the window is loaded:
*
* $( window ).load(function() {
*
* });
*
* ...and so on.
*
* Remember that ideally, we should not attach any more than a single DOM-ready or window-load handler
* for any particular page. Though other scripts in WordPress core, other plugins, and other themes may
* be doing this, we should try to minimize doing that in our own work.
*/
$(
function () {
var news_section = jQuery( '#latest_news' );
if ( news_section.length > 0 ) {
var args = {
'action': 'rt_get_feeds'
};
jQuery.get(
ajaxurl,
args,
function( data ) {
/**
* Received markup is safe and escaped appropriately.
*
* File: admin/class-nginx-helper-admin.php
* Method: nginx_helper_get_feeds();
*/
// phpcs:ignore -- WordPressVIPMinimum.JS.HTMLExecutingFunctions.append
news_section.find( '.inside' ).empty().append( data );
}
);
}
jQuery( "form#purgeall a" ).click(
function (e) {
if ( confirm( nginx_helper.purge_confirm_string ) === true ) {
// Continue submitting form.
} else {
e.preventDefault();
}
}
);
jQuery('.password-show-hide-btn').on('click', function() {
var passwordInput = $(this).siblings('.password-input');
var icon = $(this).find('.password-input-icon');
if (passwordInput.attr('type') === 'password') {
passwordInput.attr('type', 'text');
icon.removeClass('dashicons-hidden').addClass('dashicons-visibility');
} else {
passwordInput.attr('type', 'password');
icon.removeClass('dashicons-visibility').addClass('dashicons-hidden');
}
});
/**
* Show OR Hide options on option checkbox
*
* @param {type} selector Selector of Checkbox and PostBox
*/
function nginx_show_option( selector ) {
jQuery( '#' + selector ).on(
'change',
function () {
if ( jQuery( this ).is( ':checked' ) ) {
jQuery( '.' + selector ).show();
if ( 'cache_method_redis' === selector ) {
jQuery( '.cache_method_fastcgi' ).hide();
} else if ( selector === 'cache_method_fastcgi' ) {
jQuery( '.cache_method_redis' ).hide();
}
} else {
jQuery( '.' + selector ).hide();
}
}
);
}
/* Function call with parameter */
nginx_show_option( 'cache_method_fastcgi' );
nginx_show_option( 'cache_method_redis' );
nginx_show_option( 'enable_map' );
nginx_show_option( 'enable_log' );
nginx_show_option( 'enable_purge' );
}
);
})( jQuery );