| 1 |
/** |
| 2 |
* WP-Members Admin JavaScript Functions |
| 3 |
* |
| 4 |
* Contains the JavaScript functions for WP-Members admin. |
| 5 |
* |
| 6 |
* This file is part of the WP-Members plugin by Chad Butler |
| 7 |
* You can find out more about this plugin at https://rocketgeek.com |
| 8 |
* Copyright (c) 2006-2026 Chad Butler |
| 9 |
* WP-Members(tm) is a trademark of butlerblog.com |
| 10 |
* |
| 11 |
* @package WP-Members |
| 12 |
* @author Chad Butler |
| 13 |
* @copyright 2006-2026 |
| 14 |
*/ |
| 15 |
|
| 16 |
|
| 17 |
/** |
| 18 |
* JS for forms field table. |
| 19 |
* Enables drag-and-drop resorting |
| 20 |
* and select/deslect all. |
| 21 |
* |
| 22 |
* @since 3.1.2 |
| 23 |
* @since 3.4.7 Adds select/deselect all support. |
| 24 |
*/ |
| 25 |
(function($) { |
| 26 |
$(document).ready(function($) { |
| 27 |
var nonce = wpmem_get_settings_vars.nonce; |
| 28 |
$("#the-list").sortable({ |
| 29 |
items: '.list_item', |
| 30 |
opacity: 0.6, |
| 31 |
cursor: 'move', |
| 32 |
axis: 'y', |
| 33 |
update: function() { |
| 34 |
var order = $(this).sortable('serialize') + '&action=wpmem_do_field_reorder&nonce=' + nonce; |
| 35 |
$.post(ajaxurl, order, function(response) { |
| 36 |
alert(response); |
| 37 |
}); |
| 38 |
$('.list_item').each(function(i) { |
| 39 |
$(this).data('id', i + 1); // updates the data object |
| 40 |
$(this).attr('list_item', i + 1); // updates the attribute |
| 41 |
}); |
| 42 |
} |
| 43 |
}); |
| 44 |
}); |
| 45 |
|
| 46 |
$(function() { |
| 47 |
$('[id^="wpmem_all_fields_"]').on('change', function() { |
| 48 |
var type = this.id.split('_')[3]; |
| 49 |
|
| 50 |
$('[id^="wpmem_fields_'+type+'"]').prop('checked', this.checked); |
| 51 |
}); |
| 52 |
}); |
| 53 |
})(jQuery); |
| 54 |
|
| 55 |
|
| 56 |
/** |
| 57 |
* JS for displaying custom url for: |
| 58 |
* - Profile page |
| 59 |
* - Register page |
| 60 |
* - Custom stylesheet |
| 61 |
* |
| 62 |
* @since 2.9.6 |
| 63 |
*/ |
| 64 |
(function($) { |
| 65 |
$(document).ready(function() { |
| 66 |
if ($("#wpmem_logpage_select").val() == 'use_custom') |
| 67 |
$("#wpmem_logpage_custom").show(); |
| 68 |
else |
| 69 |
$("#wpmem_logpage_custom").hide(); |
| 70 |
if ($("#wpmem_regpage_select").val() == 'use_custom') |
| 71 |
$("#wpmem_regpage_custom").show(); |
| 72 |
else |
| 73 |
$("#wpmem_regpage_custom").hide(); |
| 74 |
if ($("#wpmem_mspage_select").val() == 'use_custom') |
| 75 |
$("#wpmem_mspage_custom").show(); |
| 76 |
else |
| 77 |
$("#wpmem_mspage_custom").hide(); |
| 78 |
$("#wpmem_logpage_select").change(function() { |
| 79 |
if ($("#wpmem_logpage_select").val() == 'use_custom') |
| 80 |
$("#wpmem_logpage_custom").show(); |
| 81 |
else |
| 82 |
$("#wpmem_logpage_custom").hide(); |
| 83 |
}); |
| 84 |
$("#wpmem_regpage_select").change(function() { |
| 85 |
if ($("#wpmem_regpage_select").val() == 'use_custom') |
| 86 |
$("#wpmem_regpage_custom").show(); |
| 87 |
else |
| 88 |
$("#wpmem_regpage_custom").hide(); |
| 89 |
}); |
| 90 |
$("#wpmem_mspage_select").change(function() { |
| 91 |
if ($("#wpmem_mspage_select").val() == 'use_custom') |
| 92 |
$("#wpmem_mspage_custom").show(); |
| 93 |
else |
| 94 |
$("#wpmem_mspage_custom").hide(); |
| 95 |
}); |
| 96 |
}); |
| 97 |
})(jQuery); |
| 98 |
|
| 99 |
|
| 100 |
/** |
| 101 |
* JS for displaying additional info for checkbox/dropdowns |
| 102 |
* |
| 103 |
* @since 2.9.6 |
| 104 |
*/ |
| 105 |
(function($) { |
| 106 |
$(document).ready(function() { |
| 107 |
$("#wpmem_allowhtml").hide(); |
| 108 |
$("#wpmem_rows_cols").hide(); |
| 109 |
$("#wpmem_min_max").hide(); |
| 110 |
$("#wpmem_checkbox_info").hide(); |
| 111 |
$("#wpmem_dropdown_info").hide(); |
| 112 |
$("#wpmem_file_info").hide(); |
| 113 |
$("#wpmem_delimiter_info").hide(); |
| 114 |
$("#wpmem_hidden_info").hide(); |
| 115 |
$("#wpmem_date_format").hide(); |
| 116 |
}); |
| 117 |
$(document).ready(function() { |
| 118 |
$("#wpmem_field_type_select").change(function() { |
| 119 |
if ($("#wpmem_field_type_select").val() == 'text' |
| 120 |
|| $("#wpmem_field_type_select").val() == 'password' |
| 121 |
|| $("#wpmem_field_type_select").val() == 'email' |
| 122 |
|| $("#wpmem_field_type_select").val() == 'url' |
| 123 |
|| $("#wpmem_field_type_select").val() == 'number' |
| 124 |
|| $("#wpmem_field_type_select").val() == 'date' |
| 125 |
|| $("#wpmem_field_type_select").val() == 'textarea' |
| 126 |
|| $("#wpmem_field_type_select").val() == 'timestamp' ) |
| 127 |
$("#wpmem_placeholder").show(); |
| 128 |
else |
| 129 |
$("#wpmem_placeholder").hide(); |
| 130 |
if ($("#wpmem_field_type_select").val() == 'text' |
| 131 |
|| $("#wpmem_field_type_select").val() == 'password' |
| 132 |
|| $("#wpmem_field_type_select").val() == 'email' |
| 133 |
|| $("#wpmem_field_type_select").val() == 'url' |
| 134 |
|| $("#wpmem_field_type_select").val() == 'date' |
| 135 |
|| $("#wpmem_field_type_select").val() == 'timestamp' ) { |
| 136 |
$("#wpmem_pattern").show(); |
| 137 |
$("#wpmem_title").show(); |
| 138 |
} else { |
| 139 |
$("#wpmem_pattern").hide(); |
| 140 |
$("#wpmem_title").hide(); |
| 141 |
} |
| 142 |
if ($("#wpmem_field_type_select").val() == 'textarea' ) { |
| 143 |
$("#wpmem_allowhtml").show(); |
| 144 |
$("#wpmem_rows_cols").show(); |
| 145 |
} else { |
| 146 |
$("#wpmem_allowhtml").hide(); |
| 147 |
$("#wpmem_rows_cols").hide(); |
| 148 |
} |
| 149 |
if ($("#wpmem_field_type_select").val() == 'number' || $("#wpmem_field_type_select").val() == 'date' ) |
| 150 |
$("#wpmem_min_max").show(); |
| 151 |
else |
| 152 |
$("#wpmem_min_max").hide(); |
| 153 |
if ($("#wpmem_field_type_select").val() == 'checkbox') { |
| 154 |
$("#wpmem_checkbox_info").show(); |
| 155 |
$("#add_checked_value").prop('required',true); |
| 156 |
} else { |
| 157 |
$("#wpmem_checkbox_info").hide(); |
| 158 |
$("#add_checked_value").prop('required',false); |
| 159 |
} |
| 160 |
if ( $("#wpmem_field_type_select").val() == 'select' |
| 161 |
|| $("#wpmem_field_type_select").val() == 'multiselect' |
| 162 |
|| $("#wpmem_field_type_select").val() == 'radio' |
| 163 |
|| $("#wpmem_field_type_select").val() == 'multicheckbox' |
| 164 |
) { |
| 165 |
$("#wpmem_dropdown_info").show(); |
| 166 |
if ( $("#wpmem_field_type_select").val() == 'radio' |
| 167 |
|| $("#wpmem_field_type_select").val() == 'multicheckbox' |
| 168 |
) { |
| 169 |
$("#add_dropdown_value").hide(); |
| 170 |
$("#add_radio_value").show(); |
| 171 |
$("#add_radio_value").prop('required',true); |
| 172 |
} else { |
| 173 |
$("#add_radio_value").hide(); |
| 174 |
$("#add_dropdown_value").show(); |
| 175 |
$("#add_dropdown_value").prop('required',true); |
| 176 |
} |
| 177 |
} else { |
| 178 |
$("#wpmem_dropdown_info").hide(); |
| 179 |
$("#add_radio_value").hide(); |
| 180 |
$("#add_dropdown_value").hide(); |
| 181 |
$("#add_dropdown_value").prop('required',false); |
| 182 |
$("#add_radio_value").prop('required',false); |
| 183 |
} |
| 184 |
if ( $("#wpmem_field_type_select").val() == 'multiselect' || $("#wpmem_field_type_select").val() == 'multicheckbox' |
| 185 |
) |
| 186 |
$("#wpmem_delimiter_info").show(); |
| 187 |
else |
| 188 |
$("#wpmem_delimiter_info").hide(); |
| 189 |
if ($("#wpmem_field_type_select").val() == 'file' || $("#wpmem_field_type_select").val() == 'image' ) |
| 190 |
$("#wpmem_file_info").show(); |
| 191 |
else |
| 192 |
$("#wpmem_file_info").hide(); |
| 193 |
if ($("#wpmem_field_type_select").val() == 'hidden') { |
| 194 |
$("#wpmem_hidden_info").show(); |
| 195 |
$("#wpmem_href").hide(); |
| 196 |
$("#add_hidden_value").prop('required',true); |
| 197 |
} else { |
| 198 |
$("#wpmem_hidden_info").hide(); |
| 199 |
$("#wpmem_href").show(); |
| 200 |
$("#add_hidden_value").prop('required',false); |
| 201 |
} |
| 202 |
if ($("#wpmem_field_type_select").val() == 'timestamp' ) |
| 203 |
$("#wpmem_date_format").show(); |
| 204 |
else |
| 205 |
$("#wpmem_date_format").hide(); |
| 206 |
}); |
| 207 |
}); |
| 208 |
})(jQuery); |
| 209 |
|
| 210 |
/** |
| 211 |
* JS for post block status meta box |
| 212 |
* |
| 213 |
* @since 3.2.1 |
| 214 |
*/ |
| 215 |
(function($) { |
| 216 |
$(document).ready(function() { |
| 217 |
$("#wpmem_block").hide(); |
| 218 |
}); |
| 219 |
$(document).ready(function() { |
| 220 |
$("#wpmem_edit_block_status").click(function() { |
| 221 |
$("#wpmem_block").show('normal'); |
| 222 |
$("#wpmem_edit_block_status").hide(); |
| 223 |
}); |
| 224 |
$("#wpmem_cancel_block_status").click(function() { |
| 225 |
$("#wpmem_block").hide('normal'); |
| 226 |
$("#wpmem_edit_block_status").show(); |
| 227 |
$("#wpmem_post_block_status").text($("input[name=wpmem_block_original_label]").val()); |
| 228 |
$('#wpmem_post_block_status_' + $('input[name=wpmem_block_original_value]')).val().prop("checked", true); |
| 229 |
}); |
| 230 |
$("#wpmem_ok_block_status").click(function() { |
| 231 |
$("#wpmem_block").hide('normal'); |
| 232 |
$("#wpmem_edit_block_status").show(); |
| 233 |
$("#wpmem_post_block_status").text($("input[name=wpmem_block]:checked + label").text()); |
| 234 |
if($('#wpmem_block_status_0').is(':checked')) { |
| 235 |
$("#wpmem_post_icon_0").show(); |
| 236 |
$("#wpmem_post_icon_1").hide(); |
| 237 |
$("#wpmem_post_icon_2").hide(); |
| 238 |
} |
| 239 |
if($('#wpmem_block_status_1').is(':checked')) { |
| 240 |
$("#wpmem_post_icon_0").hide(); |
| 241 |
$("#wpmem_post_icon_1").show(); |
| 242 |
$("#wpmem_post_icon_2").hide(); |
| 243 |
} |
| 244 |
if($('#wpmem_block_status_2').is(':checked')) { |
| 245 |
$("#wpmem_post_icon_0").hide(); |
| 246 |
$("#wpmem_post_icon_1").hide(); |
| 247 |
$("#wpmem_post_icon_2").show(); |
| 248 |
} |
| 249 |
}); |
| 250 |
}); |
| 251 |
})(jQuery); |
| 252 |
|
| 253 |
/** |
| 254 |
* Shows the WP-Members settings. |
| 255 |
*/ |
| 256 |
(function($) { |
| 257 |
$(document).ready(function($){ |
| 258 |
var close_button = wpmem_get_settings_vars.close_btn; |
| 259 |
$("#dialog-message" ).dialog({ |
| 260 |
autoOpen: false, |
| 261 |
modal: true, |
| 262 |
height: "auto", |
| 263 |
width: 600, |
| 264 |
buttons: { |
| 265 |
Close : function() { |
| 266 |
$( this ).dialog( "close" ); |
| 267 |
} |
| 268 |
} |
| 269 |
}); |
| 270 |
$( "#opener" ).on( "click", function() { |
| 271 |
$( "#dialog-message" ).dialog( "open" ); |
| 272 |
}); |
| 273 |
$("#select_all").click(function(){ |
| 274 |
$("textarea").select(); |
| 275 |
document.execCommand('copy'); |
| 276 |
}); |
| 277 |
$(window).resize(function() { |
| 278 |
$("#dialog-message").dialog("option", "position", {my: "center", at: "center", of: window}); |
| 279 |
}); |
| 280 |
}); |
| 281 |
})(jQuery); |
| 282 |
|