PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 111017
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v111017
261011 261001 260927 260917 260913 260909 260829 260814 260805 110710 110731 110812 110815 110912 110913 110915 110926 110927 111002 111003 111011 111017 111029 111105 111206 All 192 releases
s2member / includes / menu-pages / menu-pages-s.js

menu-pages-s.js in s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions 111017, at includes/menu-pages/menu-pages-s.js

1,369 lines 88.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Core JavaScript routines for s2Member menu pages.
3 *
4 * Copyright: © 2009-2011
5 * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
6 * ( coded in the USA )
7 *
8 * Released under the terms of the GNU General Public License.
9 * You should have received a copy of the GNU General Public License,
10 * along with this software. In the main directory, see: /licensing/
11 * If not, see: {@link http://www.gnu.org/licenses/}.
12 *
13 * @package s2Member\Menu_Pages
14 * @since 3.0
15 */
16 /*
17 These JavaScript routines are all specific to this software.
18 */
19 jQuery(document).ready (function($)
20 {
21 var esc_attr = esc_html = function(str) /* Convert special characters. */
22 {
23 return String(str).replace (/"/g, '&quot;').replace (/\</g, '&lt;').replace (/\>/g, '&gt;');
24 };
25 /**/
26 if (location.href.match (/page\=ws-plugin--s2member/)) /* Always on. */
27 {
28 $('input.ws-plugin--s2member-update-roles-button, input.ws-plugin--s2member-reset-roles-button').click (function()
29 {
30 var $this = $(this); /* Save $(this) into $this. */
31 $this.val ('one moment please ...'); /* Indicate loading status ( please wait ). */
32 /**/
33 var levels = '<?php echo (int)$GLOBALS["WS_PLUGIN__"]["s2member"]["c"]["levels"]; ?>';
34 var resetUpdate = ($this.hasClass ('ws-plugin--s2member-reset-roles-button')) ? 'Reset' : 'Update';
35 /**/
36 $.post (ajaxurl, {action: 'ws_plugin__s2member_update_roles_via_ajax', ws_plugin__s2member_update_roles_via_ajax: '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (wp_create_nonce ("ws-plugin--s2member-update-roles-via-ajax")); ?>'}, function(response)
37 {
38 if (response === '1')
39 alert('s2Member\'s Roles/Capabilities ' + ((resetUpdate.toLowerCase () === 'reset') ? 'have been successfully reset' : 'updated successfully') + '.\nYour installation of s2Member has Membership Levels 0-' + levels + '.'), $this.val (resetUpdate + ' Roles/Capabilities');
40 /**/
41 else if (response === 'l' /* Locked? */)
42 alert('Sorry, your request failed.\ns2Member\'s Roles/Capabilities are locked by Filter:\nws_plugin__s2member_lock_roles_caps'), $this.val (resetUpdate + ' Roles/Capabilities');
43 /**/
44 else /* Default response message here. */
45 alert('Sorry, your request failed.\nAccess denied. Do you have the ability to `create_users`?'), $this.val (resetUpdate + ' Roles/Capabilities');
46 });
47 /**/
48 return false;
49 });
50 }
51 /**/
52 if (location.href.match (/page\=ws-plugin--s2member-mms-ops/))
53 {
54 $('select#ws-plugin--s2member-mms-registration-file').change (function()
55 {
56 if ($(this).val () === 'wp-signup') /* Expand/collapse relevant options; based on file selection. */
57 {
58 var gv = $('select#ws-plugin--s2member-mms-registration-grants').val (), l0v = $('input#ws-plugin--s2member-mms-registration-blogs-level0').val ();
59 $('div#ws-plugin--s2member-mms-registration-support-package-details-wrapper').show (), $('div.ws-plugin--s2member-mms-registration-wp-login, table.ws-plugin--s2member-mms-registration-wp-login').hide (), $('div.ws-plugin--s2member-mms-registration-wp-signup, table.ws-plugin--s2member-mms-registration-wp-signup').show ();
60 $('div.ws-plugin--s2member-mms-registration-wp-signup-blogs-level0, table.ws-plugin--s2member-mms-registration-wp-signup-blogs-level0')[((gv === 'all') ? 'show' : 'hide')] ();
61 $('input#ws-plugin--s2member-mms-registration-blogs-level0').val (((gv === 'all') ? ((l0v > 0) ? l0v : '1') : '0'));
62 }
63 else if ($(this).val () === 'wp-login') /* Expand/collapse relevant options. */
64 {
65 var gv = $('select#ws-plugin--s2member-mms-registration-grants').val (), l0v = $('input#ws-plugin--s2member-mms-registration-blogs-level0').val ();
66 $('div#ws-plugin--s2member-mms-registration-support-package-details-wrapper').hide (), $('div.ws-plugin--s2member-mms-registration-wp-login, table.ws-plugin--s2member-mms-registration-wp-login').show (), $('div.ws-plugin--s2member-mms-registration-wp-signup, table.ws-plugin--s2member-mms-registration-wp-signup').hide ();
67 $('div.ws-plugin--s2member-mms-registration-wp-signup-blogs-level0, table.ws-plugin--s2member-mms-registration-wp-signup-blogs-level0').hide ();
68 $('input#ws-plugin--s2member-mms-registration-blogs-level0').val ('0');
69 }
70 /**/
71 }).trigger ('change'); /* Fire on ready too. */
72 /**/
73 $('select#ws-plugin--s2member-mms-registration-grants').change (function()
74 {
75 $('select#ws-plugin--s2member-mms-registration-file').trigger ('change');
76 });
77 }
78 /**/
79 if (location.href.match (/page\=ws-plugin--s2member-gen-ops/))
80 {
81 ws_plugin__s2member_generateSecurityKey = function() /* Generates a unique Security Key. */
82 {
83 var mt_rand = function(min, max) /* The JS equivalent to mt_rand(). */
84 {
85 min = (arguments.length < 1) ? 0 : min;
86 max = (arguments.length < 2) ? 2147483647 : max;
87 /**/
88 return Math.floor (Math.random () * (max - min + 1)) + min;
89 };
90 /**/
91 var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789!@#$%^&*()';
92 for (var i = 0, key = ''; i < 64; i++) key += chars.substr (mt_rand(0, chars.length - 1), 1);
93 /**/
94 $('input#ws-plugin--s2member-sec-encryption-key').val (key);
95 /**/
96 return false;
97 };
98 /**/
99 ws_plugin__s2member_enableSecurityKey = function() /* Allow Security Key editing?? */
100 {
101 if (confirm('Edit Key? Are you sure?\nThis could break your installation!\n\n*Note* If you\'ve been testing s2Member, feel free to change this Key before you go live. Just don\'t go live, and then change it. You\'ll have unhappy Customers. Data corruption WILL occur! For your safety, s2Member keeps a history of the last 10 Keys that you\'ve used. If you get yourself into a real situation, s2Member will let you revert back to a previous Key.'))
102 $('input#ws-plugin--s2member-sec-encryption-key').removeAttr ('disabled');
103 /**/
104 return false;
105 };
106 /**/
107 ws_plugin__s2member_securityKeyHistory = function() /* Displays history of Keys. */
108 {
109 $('div#ws-plugin--s2member-sec-encryption-key-history').toggle ();
110 /**/
111 return false;
112 };
113 /**/
114 $('select#ws-plugin--s2member-new-user-emails-enabled').change (function()
115 {
116 var $pluggable = $('input#ws-plugin--s2member-pluggables-wp-new-user-notification'), $this = $(this), $newUserEmails = $('div#ws-plugin--s2member-new-user-emails');
117 /**/
118 if ($pluggable.val () === '0' || $this.val () === '0')
119 {
120 ($pluggable.val () === '0') ? $this.attr ('disabled', 'disabled') : $this.removeAttr ('disabled');
121 $(':input', $newUserEmails).attr ('disabled', 'disabled'), $newUserEmails.css ('opacity', '0.5');
122 }
123 else /* Else we allow the emails to be customized. */
124 $this.removeAttr ('disabled'), $(':input', $newUserEmails).removeAttr ('disabled'), $newUserEmails.css ('opacity', '');
125 /**/
126 }).trigger ('change'); /* Fire on ready too. */
127 /**/
128 if ($('input#ws-plugin--s2member-custom-reg-fields').length && $('div#ws-plugin--s2member-custom-reg-field-configuration').length)
129 {
130 (function() /* Wrap these routines inside a function to keep variables within relative scope. */
131 {
132 var i, fieldDefaults, tools, table, $tools, $table;
133 var $fields = $('input#ws-plugin--s2member-custom-reg-fields');
134 var $configuration = $('div#ws-plugin--s2member-custom-reg-field-configuration');
135 var fields = ($fields.val ()) ? $.JSON.parse ($fields.val ()) : [];
136 /**/
137 fields = (fields instanceof Array) ? fields : []; /* Force fields to an array. */
138 /**/
139 fieldDefaults = {section: 'no', sectitle: '', id: '', label: '', type: 'text', deflt: '', options: '', expected: '', required: 'yes', levels: 'all', editable: 'yes', classes: '', styles: '', attrs: ''};
140 /**/
141 for (i = 0; i < fields.length; i++) fields[i] = $.extend (true, {}, fieldDefaults, fields[i]); /* Extend, based on defaults ( for future proofing ). */
142 /**/
143 tools = '<div id="ws-plugin--s2member-custom-reg-field-configuration-tools"></div>', table = '<table id="ws-plugin--s2member-custom-reg-field-configuration-table"></table>';
144 /**/
145 $configuration.html (tools + table); /* Add tools div & table div to configuration div ( i.e. div#ws-plugin--s2member-custom-reg-field-configuration ). */
146 /**/
147 $tools = $('div#ws-plugin--s2member-custom-reg-field-configuration-tools'), $table = $('table#ws-plugin--s2member-custom-reg-field-configuration-table');
148 /**/
149 ws_plugin__s2member_customRegFieldSectionChange = function(select)
150 {
151 var section = $(select).val (); /* Current selection ( no|yes, selected by site owner ). */
152 /**/
153 var sectitle_trs = 'tr.ws-plugin--s2member-custom-reg-field-configuration-tools-form-sectitle';
154 /**/
155 (section === 'yes') ? $(sectitle_trs).css ('display', '') : $(sectitle_trs).css ('display', 'none');
156 };
157 /**/
158 ws_plugin__s2member_customRegFieldTypeChange = function(select) /* Handle change events here. */
159 {
160 var type = $(select).val (); /* Current selection ( type of Field, selected by site owner ). */
161 /**/
162 var deflt_trs = 'tr.ws-plugin--s2member-custom-reg-field-configuration-tools-form-deflt', options_trs = 'tr.ws-plugin--s2member-custom-reg-field-configuration-tools-form-options', expected_trs = 'tr.ws-plugin--s2member-custom-reg-field-configuration-tools-form-expected';
163 /**/
164 (type.match (/^(text|textarea)$/)) ? $(deflt_trs).css ('display', '') : $(deflt_trs).css ('display', 'none');
165 (type.match (/^(select|selects|checkboxes|radios)$/)) ? $(options_trs).css ('display', '') : $(options_trs).css ('display', 'none');
166 (type.match (/^(text|textarea)$/)) ? $(expected_trs).css ('display', '') : $(expected_trs).css ('display', 'none');
167 };
168 /**/
169 ws_plugin__s2member_customRegFieldDelete = function(index)
170 {
171 var newFields = new Array (); /* Build array. */
172 /**/
173 for (var i = 0; i < fields.length; i++)
174 if (i !== index) /* Omit index. */
175 newFields.push (fields[i]);
176 /**/
177 fields = newFields, updateFields (), buildTable ();
178 };
179 /**/
180 ws_plugin__s2member_customRegFieldMoveUp = function(index)
181 {
182 if (typeof fields[index] === 'object' && typeof fields[index - 1] === 'object')
183 {
184 var prevFieldObj = fields[index - 1], thisFieldObj = fields[index];
185 /**/
186 fields[index - 1] = thisFieldObj, fields[index] = prevFieldObj;
187 /**/
188 updateFields (), buildTable ();
189 }
190 };
191 /**/
192 ws_plugin__s2member_customRegFieldMoveDown = function(index)
193 {
194 if (typeof fields[index] === 'object' && typeof fields[index + 1] === 'object')
195 {
196 var nextFieldObj = fields[index + 1], thisFieldObj = fields[index];
197 /**/
198 fields[index + 1] = thisFieldObj, fields[index] = nextFieldObj;
199 /**/
200 updateFields (), buildTable ();
201 }
202 };
203 /**/
204 ws_plugin__s2member_customRegFieldCreate = function()
205 {
206 var $table = $('table#ws-plugin--s2member-custom-reg-field-configuration-tools-form'), field = {};
207 /**/
208 $(':input[property]', $table).each (function() /* Go through each property value. */
209 {
210 var $this = $(this), property = $this.attr ('property'), val = $.trim ($this.val ());
211 /**/
212 field[property] = val;
213 });
214 /**/
215 if ((field = validateField(field))) /* If it can be validated. */
216 {
217 fields.push (field), updateFields (), buildTools (), buildTable (), scrollReset ();
218 /**/
219 setTimeout(function() /* A momentary delay here for usability. */
220 {
221 var row = 'tr.ws-plugin--s2member-custom-reg-field-configuration-table-row-' + (fields.length - 1);
222 alert('Field created successfully.\n* Remember to "Save All Changes".');
223 $(row).effect ('highlight', 1500);
224 }, 500);
225 }
226 };
227 /**/
228 ws_plugin__s2member_customRegFieldUpdate = function(index)
229 {
230 var $table = $('table#ws-plugin--s2member-custom-reg-field-configuration-tools-form'), field = {};
231 /**/
232 $(':input[property]', $table).each (function() /* Go through each property value. */
233 {
234 var $this = $(this), property = $this.attr ('property'), val = $.trim ($this.val ());
235 /**/
236 field[property] = val;
237 });
238 /**/
239 if ((field = validateField(field, index))) /* If it validates. */
240 {
241 fields[index] = field, updateFields (), buildTools (), buildTable (), scrollReset ();
242 /**/
243 setTimeout(function() /* A momentary delay here for usability. */
244 {
245 var row = 'tr.ws-plugin--s2member-custom-reg-field-configuration-table-row-' + index;
246 alert('Field updated successfully.\n* Remember to "Save All Changes".');
247 $(row).effect ('highlight', 1500);
248 }, 500);
249 }
250 };
251 /**/
252 ws_plugin__s2member_customRegFieldAdd = function() /* Add new field links. */
253 {
254 buildTools(true); /* No need to reset scroll position. */
255 };
256 /**/
257 ws_plugin__s2member_customRegFieldEdit = function(index) /* Edit links. */
258 {
259 buildTools(false, index), scrollReset (); /* Reset scroll position. */
260 };
261 /**/
262 ws_plugin__s2member_customRegFieldCancel = function() /* Cancel form. */
263 {
264 buildTools (), scrollReset (); /* Re-build without the form. */
265 };
266 /**/
267 var validateField = function(field, index)
268 {
269 var editing = ( typeof index === 'number' && typeof fields[index] === 'object') ? true : false, errors = [], options, i;
270 /**/
271 if (typeof field !== 'object' || typeof (field = $.extend (true, {}, fieldDefaults, field)) !== 'object')
272 {
273 alert('Invalid field object. Please try again.');
274 return false;
275 }
276 /**/
277 field.sectitle = (field.section === 'yes') ? field.sectitle : '';
278 field.deflt = (field.type.match (/^(text|textarea)$/)) ? field.deflt : '';
279 field.deflt = (field.type.match (/^(text)$/)) ? field.deflt.replace (/[\r\n\t ]+/g, ' ') : field.deflt;
280 field.options = (field.type.match (/^(select|selects|checkboxes|radios)$/)) ? field.options : '';
281 field.expected = (field.type.match (/^(text|textarea)$/)) ? field.expected : '';
282 /**/
283 if (!field.id) /* Every Field must have a unique ID. */
284 {
285 errors.push ('Unique Field ID:\nThis is required. Please try again.');
286 }
287 else if (fieldIdExists(field.id) && (!editing || field.id !== fields[index].id))
288 {
289 errors.push ('Unique Field ID:\nThat Field ID already exists. Please try again.');
290 }
291 /**/
292 if (!field.label) /* Every Field must have a label. */
293 {
294 errors.push ('Field Label/Description:\nThis is required. Please try again.');
295 }
296 /**/
297 if (field.type.match (/^(select|selects|checkboxes|radios)$/) && !field.options)
298 {
299 errors.push ('Option Configuration File:\nThis is required. Please try again.');
300 }
301 else if (field.type.match (/^(select|selects|checkboxes|radios)$/))
302 {
303 for (i = 0; i < (options = field.options.split (/[\r\n]+/)).length; i++)
304 {
305 if (!(options[i] = $.trim (options[i])).match (/^([^\|]*)(\|)([^\|]*)(\|default)?$/))
306 {
307 errors.push ('Option Configuration File:\nInvalid configuration at line #' + (i + 1) + '.');
308 break; /* Break now. There could potentially be lots of lines with errors like this. */
309 }
310 }
311 /**/
312 field.options = $.trim (options.join ('\n')); /* Clean up. */
313 }
314 /**/
315 if (!(field.levels = field.levels.replace (/ /g, '')))
316 {
317 errors.push ('Applicable Levels:\nThis is required. Please try again.');
318 }
319 else if (!field.levels.match (/^(all|[0-9,]+)$/))
320 {
321 errors.push ('Applicable Levels:\nShould be comma-delimited Levels, or just type: all.\n( examples: 0,1,2,3,4 or type the word: all )');
322 }
323 /**/
324 if (field.classes && field.classes.match (/[^a-z 0-9 _ \-]/i))
325 {
326 errors.push ('CSS Classes:\nContains invalid characters. Please try again.\n( only: alphanumerics, underscores, hyphens, spaces )');
327 }
328 /**/
329 if (field.styles && field.styles.match (/["\=\>\<]/))
330 {
331 errors.push ('CSS Styles:\nContains invalid characters. Please try again.\n( do NOT use these characters: = " < > )');
332 }
333 /**/
334 if (field.attrs && field.attrs.match (/[\>\<]/))
335 {
336 errors.push ('Other Attributes:\nContains invalid characters. Please try again.\n( do NOT use these characters: < > )');
337 }
338 /**/
339 if (errors.length > 0) /* Errors? */
340 {
341 alert(errors.join ('\n\n'));
342 return false;
343 }
344 else /* Return. */
345 return field;
346 };
347 /**/
348 var updateFields = function() /* Update hidden input value. */
349 {
350 $fields.val (((fields.length > 0) ? $.JSON.stringify (fields) : ''));
351 };
352 /**/
353 var fieldId2Var = function(fieldId) /* Convert ids to variables. */
354 {
355 return ( typeof fieldId === 'string') ? $.trim (fieldId).toLowerCase ().replace (/[^a-z0-9]/g, '_') : '';
356 };
357 /**/
358 var fieldTypeDesc = function(type)
359 {
360 var types = {text: 'Text ( single line )', textarea: 'Textarea ( multi-line )', select: 'Select Menu ( drop-down )', selects: 'Select Menu ( multi-option )', checkbox: 'Checkbox ( single )', pre_checkbox: 'Checkbox ( pre-checked )', checkboxes: 'Checkboxes ( multi-option )', radios: 'Radio Buttons ( multi-option )'};
361 /**/
362 if (typeof types[type] === 'string')
363 return types[type];
364 /**/
365 return ''; /* Default. */
366 };
367 /**/
368 var fieldIdExists = function(fieldId) /* Already exists? */
369 {
370 for (var i = 0; i < fields.length; i++)
371 if (fields[i].id === fieldId)
372 return true;
373 };
374 /**/
375 var scrollReset = function() /* Return to Custom Fields section. */
376 {
377 scrollTo(0, $('div.ws-plugin--s2member-custom-reg-fields-section').offset ()['top'] - 100);
378 };
379 /**/
380 var buildTools = function(adding, index) /* This builds tools into the configuration. */
381 {
382 var i = 0, html = '', form = '', w = 0, h = 0, editing = ( typeof index === 'number' && typeof fields[index] === 'object') ? true : false, displayForm = (adding || editing) ? true : false, field = (editing) ? $.extend (true, {}, fieldDefaults, fields[index]) : fieldDefaults;
383 /**/
384 html += '<a href="#" onclick="ws_plugin__s2member_customRegFieldAdd(); return false;">Add New Field</a>'; /* Click to add a new Custom Registration/Profile Field. */
385 /**/
386 tb_remove (), $('div#ws-plugin--s2member-custom-reg-field-configuration-thickbox-tools-form').remove (); /* Remove an existing thickbox. */
387 /**/
388 if (displayForm) /* Do we need to display the adding/editing form at all?
389 *NOTE* This is NOT an actual <form>, because we're already inside another form tag. */
390 {
391 form += '<div id="ws-plugin--s2member-custom-reg-field-configuration-thickbox-tools-form">';
392 /**/
393 form += '<table id="ws-plugin--s2member-custom-reg-field-configuration-tools-form">';
394 form += '<tbody>';
395 /**/
396 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-section">';
397 form += '<td colspan="2">';
398 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-section">Starts A New Section?</label>';
399 form += '</td>';
400 form += '</tr>';
401 /**/
402 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-section">';
403 form += '<td colspan="2">';
404 form += '<select property="section" onchange="ws_plugin__s2member_customRegFieldSectionChange(this);" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-section">';
405 form += '<option value="no"' + ((field.section === 'no') ? ' selected="selected"' : '') + '">No ( this Field flows normally )</option>';
406 form += '<option value="yes"' + ((field.section === 'yes') ? ' selected="selected"' : '') + '">Yes ( this Field begins a new section )</option>';
407 form += '</select><br />';
408 form += '<small>Optional. Allows Fields to be grouped into sections.</small>';
409 form += '</td>';
410 form += '</tr>';
411 /**/
412 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-sectitle ws-plugin--s2member-custom-reg-field-configuration-tools-form-section"' + ((field.section === 'yes') ? '' : ' style="display:none;"') + '><td colspan="2"><hr /></td></tr>';
413 /**/
414 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-sectitle ws-plugin--s2member-custom-reg-field-configuration-tools-form-section"' + ((field.section === 'yes') ? '' : ' style="display:none;"') + '>';
415 form += '<td colspan="2">';
416 form += 'Title for this new section? ( optional )<br />';
417 form += '<input type="text" property="sectitle" value="' + esc_attr(field.sectitle) + '" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-sectitle" /><br />';
418 form += '<small>If empty, a simple divider will be used by default.</small>';
419 form += '</td>';
420 form += '</tr>';
421 /**/
422 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-type"><td colspan="2">&nbsp;</td></tr>';
423 /**/
424 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-type">';
425 form += '<td colspan="2">';
426 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-type">Form Field Type: *</label>';
427 form += '</td>';
428 form += '</tr>';
429 /**/
430 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-type">';
431 form += '<td colspan="2">';
432 form += '<select property="type" onchange="ws_plugin__s2member_customRegFieldTypeChange(this);" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-type">';
433 form += '<option value="text"' + ((field.type === 'text') ? ' selected="selected"' : '') + '">' + esc_html(fieldTypeDesc('text')) + '</option>';
434 form += '<option value="textarea"' + ((field.type === 'textarea') ? ' selected="selected"' : '') + '">' + esc_html(fieldTypeDesc('textarea')) + '</option>';
435 form += '<option value="select"' + ((field.type === 'select') ? ' selected="selected"' : '') + '">' + esc_html(fieldTypeDesc('select')) + '</option>';
436 form += '<option value="selects"' + ((field.type === 'selects') ? ' selected="selected"' : '') + '">' + esc_html(fieldTypeDesc('selects')) + '</option>';
437 form += '<option value="checkbox"' + ((field.type === 'checkbox') ? ' selected="selected"' : '') + '">' + esc_html(fieldTypeDesc('checkbox')) + '</option>';
438 form += '<option value="pre_checkbox"' + ((field.type === 'pre_checkbox') ? ' selected="selected"' : '') + '">' + esc_html(fieldTypeDesc('pre_checkbox')) + '</option>';
439 form += '<option value="checkboxes"' + ((field.type === 'checkboxes') ? ' selected="selected"' : '') + '">' + esc_html(fieldTypeDesc('checkboxes')) + '</option>';
440 form += '<option value="radios"' + ((field.type === 'radios') ? ' selected="selected"' : '') + '">' + esc_html(fieldTypeDesc('radios')) + '</option>';
441 form += '</select><br />';
442 form += '<small>The options below may change, based on the Field Type you choose here.</small>';
443 form += '</td>';
444 form += '</tr>';
445 /**/
446 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-label"><td colspan="2">&nbsp;</td></tr>';
447 /**/
448 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-label">';
449 form += '<td colspan="2">';
450 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-label">Field Label/Desc: *</label>';
451 form += '</td>';
452 form += '</tr>';
453 /**/
454 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-label">';
455 form += '<td colspan="2">';
456 form += '<input type="text" property="label" value="' + esc_attr(field.label) + '" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-label" /><br />';
457 form += '<small>Examples: <code>Choose Country</code>, <code>Street Address</code></small>';
458 form += '</td>';
459 form += '</tr>';
460 /**/
461 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-id"><td colspan="2">&nbsp;</td></tr>';
462 /**/
463 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-id">';
464 form += '<td colspan="2">';
465 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-id">Unique Field ID: *</label></label>';
466 form += '</td>';
467 form += '</tr>';
468 /**/
469 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-id">';
470 form += '<td colspan="2">';
471 form += '<input type="text" property="id" value="' + esc_attr(field.id) + '" maxlength="25" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-id" /><br />';
472 form += '<small>Examples: <code>country_code</code>, <code>street_address</code></small><br />';
473 form += '<small>e.g. <code>[s2Get user_field="country_code" /]</code></small>';
474 form += '</td>';
475 form += '</tr>';
476 /**/
477 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-required"><td colspan="2">&nbsp;</td></tr>';
478 /**/
479 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-required">';
480 form += '<td colspan="2">';
481 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-required">Field Required: *</label>';
482 form += '</td>';
483 form += '</tr>';
484 /**/
485 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-required">';
486 form += '<td colspan="2">';
487 form += '<select property="required" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-required">';
488 form += '<option value="yes"' + ((field.required === 'yes') ? ' selected="selected"' : '') + '">Yes ( required )</option>';
489 form += '<option value="no"' + ((field.required === 'no') ? ' selected="selected"' : '') + '">No ( optional )</option>';
490 form += '</select><br />';
491 form += '<small>If <code>yes</code>, only Users/Members will be "required" to enter this field.</small><br />';
492 form += '<small>* Administrators are exempt from this requirement.</small>';
493 form += '</td>';
494 form += '</tr>';
495 /**/
496 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-deflt"' + ((field.type.match (/^(text|textarea)$/)) ? '' : ' style="display:none;"') + '><td colspan="2">&nbsp;</td></tr>';
497 /**/
498 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-deflt"' + ((field.type.match (/^(text|textarea)$/)) ? '' : ' style="display:none;"') + '>';
499 form += '<td colspan="2">';
500 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-deflt">Default Text Value: ( optional )</label>';
501 form += '</td>';
502 form += '</tr>';
503 /**/
504 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-deflt"' + ((field.type.match (/^(text|textarea)$/)) ? '' : ' style="display:none;"') + '>';
505 form += '<td colspan="2">';
506 form += '<textarea property="deflt" rows="1" wrap="off" spellcheck="false" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-deflt">' + esc_html(field.deflt) + '</textarea><br />';
507 form += '<small>Default value before user input is received.</small>';
508 form += '</td>';
509 form += '</tr>';
510 /**/
511 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-options"' + ((field.type.match (/^(select|selects|checkboxes|radios)$/)) ? '' : ' style="display:none;"') + '><td colspan="2">&nbsp;</td></tr>';
512 /**/
513 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-options"' + ((field.type.match (/^(select|selects|checkboxes|radios)$/)) ? '' : ' style="display:none;"') + '>';
514 form += '<td colspan="2">';
515 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-options">Option Configuration File: * ( one option per line )</label><br />';
516 form += '<small>Use a pipe <code>|</code> delimited format: <code>option value|option label</code></small>';
517 form += '</td>';
518 form += '</tr>';
519 /**/
520 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-options"' + ((field.type.match (/^(select|selects|checkboxes|radios)$/)) ? '' : ' style="display:none;"') + '>';
521 form += '<td colspan="2">';
522 form += '<textarea property="options" rows="3" wrap="off" spellcheck="false" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-options">' + esc_html(field.options) + '</textarea><br />';
523 form += 'Here is a quick example:<br />';
524 form += '<small>You can also specify a <em>default</em> option:</small><br />';
525 form += '<code>US|United States|default</code><br />';
526 form += '<code>CA|Canada</code><br />';
527 form += '<code>VI|Virgin Islands (U.S.)</code>';
528 form += '</td>';
529 form += '</tr>';
530 /**/
531 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-expected"' + ((field.type.match (/^(text|textarea)$/)) ? '' : ' style="display:none;"') + '><td colspan="2">&nbsp;</td></tr>';
532 /**/
533 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-expected"' + ((field.type.match (/^(text|textarea)$/)) ? '' : ' style="display:none;"') + '>';
534 form += '<td colspan="2">';
535 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-expected">Expected Format: *</label>';
536 form += '</td>';
537 form += '</tr>';
538 /**/
539 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-expected"' + ((field.type.match (/^(text|textarea)$/)) ? '' : ' style="display:none;"') + '>';
540 form += '<td colspan="2">';
541 form += '<select property="expected" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-expected">';
542 /**/
543 form += '<option value=""' + ((field.expected === '') ? ' selected="selected"' : '') + '">Anything Goes</option>';
544 form += '<option disabled="disabled"></option>';
545 /**/
546 form += '<optgroup label="Specific Input Types">';
547 form += '<option value="numeric-wp-commas"' + ((field.expected === 'numeric-wp-commas') ? ' selected="selected"' : '') + '">Numeric ( with or without decimals, commas allowed )</option>';
548 form += '<option value="numeric"' + ((field.expected === 'numeric') ? ' selected="selected"' : '') + '">Numeric ( with or without decimals, no commas )</option>';
549 form += '<option value="integer"' + ((field.expected === 'integer') ? ' selected="selected"' : '') + '">Integer ( whole number, without any decimals )</option>';
550 form += '<option value="integer-gt-0"' + ((field.expected === 'integer-gt-0') ? ' selected="selected"' : '') + '">Integer > 0 ( whole number, no decimals, greater than 0 )</option>';
551 form += '<option value="float"' + ((field.expected === 'float') ? ' selected="selected"' : '') + '">Float ( floating point number, decimals required )</option>';
552 form += '<option value="float-gt-0"' + ((field.expected === 'float-gt-0') ? ' selected="selected"' : '') + '">Float > 0 ( floating point number, decimals required, greater than 0 )</option>';
553 form += '<option value="date"' + ((field.expected === 'date') ? ' selected="selected"' : '') + '">Date ( required date format: dd/mm/yyyy )</option>';
554 form += '<option value="email"' + ((field.expected === 'email') ? ' selected="selected"' : '') + '">Email ( require valid email )</option>';
555 form += '<option value="url"' + ((field.expected === 'url') ? ' selected="selected"' : '') + '">Full URL ( starting with http or https )</option>';
556 form += '<option value="domain"' + ((field.expected === 'domain') ? ' selected="selected"' : '') + '">Domain Name ( domain name only, without http )</option>';
557 form += '<option value="phone"' + ((field.expected === 'phone') ? ' selected="selected"' : '') + '">Phone # ( 10 digits w/possible hyphens,spaces,brackets )</option>';
558 form += '<option value="uszip"' + ((field.expected === 'uszip') ? ' selected="selected"' : '') + '">US Zipcode ( 5-9 digits w/possible hyphen )</option>';
559 form += '<option value="cazip"' + ((field.expected === 'cazip') ? ' selected="selected"' : '') + '">Canadian Zipcode ( 6 alpha-numerics w/possible space )</option>';
560 form += '<option value="uczip"' + ((field.expected === 'uczip') ? ' selected="selected"' : '') + '">US/Canadian Zipcode ( either a US or Canadian zipcode )</option>';
561 form += '</optgroup>';
562 /**/
563 form += '<option disabled="disabled"></option>';
564 /**/
565 form += '<optgroup label="Any Character Combination">';
566 for (i = 1; i <= 25; i++)
567 {
568 form += '<option value="any-' + i + '"' + ((field.expected === 'any-' + i) ? ' selected="selected"' : '') + '">Any Character Combination ( ' + i + ' character minimum )</option>';
569 form += '<option value="any-' + i + '-e"' + ((field.expected === 'any-' + i + '-e') ? ' selected="selected"' : '') + '">Any Character Combination ( exactly ' + i + ' character' + ((i > 1) ? 's' : '') + ' )</option>';
570 }
571 form += '</optgroup>';
572 /**/
573 form += '<option disabled="disabled"></option>';
574 /**/
575 form += '<optgroup label="Alphanumerics, Spaces &amp; Punctuation Only">';
576 for (i = 1; i <= 25; i++)
577 {
578 form += '<option value="alphanumerics-spaces-punctuation-' + i + '"' + ((field.expected === 'alphanumerics-spaces-punctuation-' + i) ? ' selected="selected"' : '') + '">Alphanumerics, Spaces &amp; Punctuation ( ' + i + ' character minimum )</option>';
579 form += '<option value="alphanumerics-spaces-punctuation-' + i + '-e"' + ((field.expected === 'alphanumerics-spaces-punctuation-' + i + '-e') ? ' selected="selected"' : '') + '">Alphanumerics, Spaces &amp; Punctuation ( exactly ' + i + ' character' + ((i > 1) ? 's' : '') + ' )</option>';
580 }
581 form += '</optgroup>';
582 /**/
583 form += '<option disabled="disabled"></option>';
584 /**/
585 form += '<optgroup label="Alphanumerics &amp; Spaces Only">';
586 for (i = 1; i <= 25; i++)
587 {
588 form += '<option value="alphanumerics-spaces-' + i + '"' + ((field.expected === 'alphanumerics-spaces-' + i) ? ' selected="selected"' : '') + '">Alphanumerics &amp; Spaces ( ' + i + ' character minimum )</option>';
589 form += '<option value="alphanumerics-spaces-' + i + '-e"' + ((field.expected === 'alphanumerics-spaces-' + i + '-e') ? ' selected="selected"' : '') + '">Alphanumerics &amp; Spaces ( exactly ' + i + ' character' + ((i > 1) ? 's' : '') + ' )</option>';
590 }
591 form += '</optgroup>';
592 /**/
593 form += '<option disabled="disabled"></option>';
594 /**/
595 form += '<optgroup label="Alphanumerics &amp; Punctuation Only">';
596 for (i = 1; i <= 25; i++)
597 {
598 form += '<option value="alphanumerics-punctuation-' + i + '"' + ((field.expected === 'alphanumerics-punctuation-' + i) ? ' selected="selected"' : '') + '">Alphanumerics &amp; Punctuation ( ' + i + ' character minimum )</option>';
599 form += '<option value="alphanumerics-punctuation-' + i + '-e"' + ((field.expected === 'alphanumerics-punctuation-' + i + '-e') ? ' selected="selected"' : '') + '">Alphanumerics &amp; Punctuation ( exactly ' + i + ' character' + ((i > 1) ? 's' : '') + ' )</option>';
600 }
601 form += '</optgroup>';
602 /**/
603 form += '<option disabled="disabled"></option>';
604 /**/
605 form += '<optgroup label="Alphanumerics Only">';
606 for (i = 1; i <= 25; i++)
607 {
608 form += '<option value="alphanumerics-' + i + '"' + ((field.expected === 'alphanumerics-' + i) ? ' selected="selected"' : '') + '">Alphanumerics ( ' + i + ' character minimum )</option>';
609 form += '<option value="alphanumerics-' + i + '-e"' + ((field.expected === 'alphanumerics-' + i + '-e') ? ' selected="selected"' : '') + '">Alphanumerics ( exactly ' + i + ' character' + ((i > 1) ? 's' : '') + ' )</option>';
610 }
611 form += '</optgroup>';
612 /**/
613 form += '<option disabled="disabled"></option>';
614 /**/
615 form += '<optgroup label="Alphabetics Only">';
616 for (i = 1; i <= 25; i++)
617 {
618 form += '<option value="alphabetics-' + i + '"' + ((field.expected === 'alphabetics-' + i) ? ' selected="selected"' : '') + '">Alphabetics ( ' + i + ' character minimum )</option>';
619 form += '<option value="alphabetics-' + i + '-e"' + ((field.expected === 'alphabetics-' + i + '-e') ? ' selected="selected"' : '') + '">Alphabetics ( exactly ' + i + ' character' + ((i > 1) ? 's' : '') + ' )</option>';
620 }
621 form += '</optgroup>';
622 /**/
623 form += '<option disabled="disabled"></option>';
624 /**/
625 form += '<optgroup label="Numeric Digits Only">';
626 for (i = 1; i <= 25; i++)
627 {
628 form += '<option value="numerics-' + i + '"' + ((field.expected === 'numerics-' + i) ? ' selected="selected"' : '') + '">Numeric Digits ( ' + i + ' digit minimum )</option>';
629 form += '<option value="numerics-' + i + '-e"' + ((field.expected === 'numerics-' + i + '-e') ? ' selected="selected"' : '') + '">Numeric Digits ( exactly ' + i + ' digit' + ((i > 1) ? 's' : '') + ' )</option>';
630 }
631 form += '</optgroup>';
632 /**/
633 form += '</select><br />';
634 form += '<small>Only Users/Members will be required to meet this criteria.</small><br />';
635 form += '<small>* Administrators are exempt from this.</small>';
636 form += '</td>';
637 form += '</tr>';
638 /**/
639 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-levels"><td colspan="2">&nbsp;</td></tr>';
640 /**/
641 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-levels">';
642 form += '<td colspan="2">';
643 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-levels">Applicable Membership Levels: *</label>';
644 form += '</td>';
645 form += '</tr>';
646 /**/
647 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-levels">';
648 form += '<td colspan="2">';
649 form += '<input type="text" property="levels" value="' + esc_attr(field.levels) + '" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-levels" /><br />';
650 form += '<small>Please use comma-delimited Level #\'s: <code>0,1,2,3,4</code> or type: <code>all</code>.</small><br />';
651 form += '<small>This allows you to enable this field - only at specific Membership Levels.</small>';
652 form += '</td>';
653 form += '</tr>';
654 /**/
655 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-editable"><td colspan="2">&nbsp;</td></tr>';
656 /**/
657 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-editable">';
658 form += '<td colspan="2">';
659 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-editable">Allow Profile Edits: *</label>';
660 form += '</td>';
661 form += '</tr>';
662 /**/
663 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-editable">';
664 form += '<td colspan="2">';
665 form += '<select property="editable" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-editable">';
666 form += '<option value="yes"' + ((field.editable === 'yes') ? ' selected="selected"' : '') + '">Yes ( editable )</option>';
667 form += '<option value="no"' + ((field.editable === 'no') ? ' selected="selected"' : '') + '">No ( uneditable after registration )</option>';
668 form += '<option value="no-invisible"' + ((field.editable === 'no-invisible') ? ' selected="selected"' : '') + '">No ( uneditable &amp; totally invisible after registration )</option>';
669 form += '<option value="yes-invisible"' + ((field.editable === 'yes-invisible') ? ' selected="selected"' : '') + '">Yes ( editable after registration / invisible during registration )</option>';
670 form += '</select><br />';
671 form += '<small>If <code>No</code>, this field will be un-editable after registration.</small><br />';
672 form += '<small>* Administrators are exempt from this.</small>';
673 form += '</td>';
674 form += '</tr>';
675 /**/
676 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-classes"><td colspan="2">&nbsp;</td></tr>';
677 /**/
678 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-classes">';
679 form += '<td colspan="2">';
680 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-classes">CSS Classes: ( optional )</label>';
681 form += '</td>';
682 form += '</tr>';
683 /**/
684 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-classes">';
685 form += '<td colspan="2">';
686 form += '<input type="text" property="classes" value="' + esc_attr(field.classes) + '" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-classes" /><br />';
687 form += '<small>Example: <code>my-style-1 my-style-2</code></small>';
688 form += '</td>';
689 form += '</tr>';
690 /**/
691 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-styles"><td colspan="2">&nbsp;</td></tr>';
692 /**/
693 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-styles">';
694 form += '<td colspan="2">';
695 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-styles">CSS Styles: ( optional )</label>';
696 form += '</td>';
697 form += '</tr>';
698 /**/
699 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-styles">';
700 form += '<td colspan="2">';
701 form += '<input type="text" property="styles" value="' + esc_attr(field.styles) + '" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-styles" /><br />';
702 form += '<small>Example: <code>color:#000000; background:#FFFFFF;</code></small>';
703 form += '</td>';
704 form += '</tr>';
705 /**/
706 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-attrs"><td colspan="2">&nbsp;</td></tr>';
707 /**/
708 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-attrs">';
709 form += '<td colspan="2">';
710 form += '<label for="ws-plugin--s2member-custom-reg-field-configuration-tools-form-attrs">Other Attributes: ( optional )</label>';
711 form += '</td>';
712 form += '</tr>';
713 /**/
714 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-attrs">';
715 form += '<td colspan="2">';
716 form += '<input type="text" property="attrs" value="' + esc_attr(field.attrs) + '" id="ws-plugin--s2member-custom-reg-field-configuration-tools-form-attrs" /><br />';
717 form += '<small>Example: <code>onkeyup="" onblur=""</code></small>';
718 form += '</td>';
719 form += '</tr>';
720 /**/
721 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-spacer ws-plugin--s2member-custom-reg-field-configuration-tools-form-buttons"><td colspan="2">&nbsp;</td></tr>';
722 /**/
723 form += '<tr class="ws-plugin--s2member-custom-reg-field-configuration-tools-form-buttons">';
724 form += '<td align="left">';
725 form += '<input type="button" value="Cancel" onclick="ws_plugin__s2member_customRegFieldCancel();" />';
726 form += '</td>';
727 form += '<td align="right">';
728 form += '<input type="button" value="' + ((editing) ? 'Update This Field' : 'Create Registration Field') + '" onclick="' + ((editing) ? 'ws_plugin__s2member_customRegFieldUpdate(' + index + ');' : 'ws_plugin__s2member_customRegFieldCreate();') + '" />';
729 form += '</td>';
730 form += '</tr>';
731 /**/
732 form += '</tbody>';
733 form += '</table>';
734 /**/
735 form += '<div>';
736 /**/
737 $('body').append (form);
738 /**/
739 tb_show(((editing) ? 'Editing Registration/Profile Field' : 'New Custom Registration/Profile Field'), '#TB_inline?inlineId=ws-plugin--s2member-custom-reg-field-configuration-thickbox-tools-form'), $(window).trigger ('resize');
740 /**/
741 $('table#ws-plugin--s2member-custom-reg-field-configuration-tools-form').show ();
742 }
743 /**/
744 $tools.html (html);
745 };
746 /**/
747 var attachTBResizer = function() /* Resize inline #TB_ajaxContent. */
748 {
749 $(window).resize (function()
750 {
751 var w, h; /* Initialize width/height vars. */
752 w = $(window).width (), h = $(window).height (), w = (w > 720) ? 720 : w;
753 $('#TB_ajaxContent').css ({'width': w - 50, 'height': h - 75, 'margin': 0, 'padding': 0});
754 });
755 };
756 /**/
757 var buildTable = function() /* This builds the table of existing fields. */
758 {
759 var l = fields.length, i = 0, html = '', eo = 'o';
760 /**/
761 html += '<tbody>';
762 /**/
763 html += '<tr>';
764 html += '<th>Order</th>';
765 html += '<th>Field Type</th>';
766 html += '<th>Unique ID</th>';
767 html += '<th>Required</th>';
768 html += '<th>Levels</th>';
769 html += '<th>- Tools -</th>';
770 html += '</tr>';
771 /**/
772 if (fields.length > 0) /* Any fields? */
773 {
774 for (i = 0; i < fields.length; i++)
775 {
776 html += '<tr class="' + esc_attr((eo = (eo === 'o') ? 'e' : 'o')) + ((fields[i].section === 'yes') ? ' s' : '') + ' ws-plugin--s2member-custom-reg-field-configuration-table-row-' + i + '">'; /* Odd/even + row identifier. */
777 html += '<td nowrap="nowrap"><a class="ws-plugin--s2member-custom-reg-field-configuration-move-up" href="#" onclick="ws_plugin__s2member_customRegFieldMoveUp(' + i + '); return false;"></a><a class="ws-plugin--s2member-custom-reg-field-configuration-move-down" href="#" onclick="ws_plugin__s2member_customRegFieldMoveDown(' + i + '); return false;"></a></td>';
778 html += '<td nowrap="nowrap">' + esc_html(fieldTypeDesc(fields[i].type)) + '</td>';
779 html += '<td nowrap="nowrap">' + esc_html(fields[i].id) + '</td>';
780 html += '<td nowrap="nowrap">' + esc_html(fields[i].required) + '</td>';
781 html += '<td nowrap="nowrap">' + esc_html(fields[i].levels) + '</td>';
782 html += '<td nowrap="nowrap"><a class="ws-plugin--s2member-custom-reg-field-configuration-edit" href="#" onclick="ws_plugin__s2member_customRegFieldEdit(' + i + '); return false;"></a><a class="ws-plugin--s2member-custom-reg-field-configuration-delete" href="#" onclick="ws_plugin__s2member_customRegFieldDelete(' + i + '); return false;"></a></td>';
783 html += '</tr>';
784 }
785 }
786 else /* Otherwise, there are no fields configured yet. */
787 {
788 html += '<tr>'; /* There are no fields yet. */
789 html += '<td colspan="6">No Custom Fields are configured.</td>';
790 html += '</tr>';
791 }
792 /**/
793 html += '</tbody>';
794 /**/
795 $table.html (html);
796 };
797 /* Initialize configuration. */
798 buildTools (), attachTBResizer (), buildTable ();
799 /**/
800 }) ();
801 }
802 }
803 /**/
804 if (location.href.match (/page\=ws-plugin--s2member-res-ops/))
805 {
806 $('input#ws-plugin--s2member-brute-force-restrictions-reset-button').click (function()
807 {
808 var $this = $(this); /* Save $(this) into $this. */
809 $this.val ('one moment please ...'); /* Indicate loading status ( please wait ). */
810 /**/
811 $.post (ajaxurl, {action: 'ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax', ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax: '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (wp_create_nonce ("ws-plugin--s2member-delete-reset-all-ip-restrictions-via-ajax")); ?>'}, function(response)
812 {
813 alert('s2Member\'s Brute Force Restriction Logs have all been reset.'), $this.val ('Reset Brute Force Logs');
814 });
815 /**/
816 return false;
817 });
818 /**/
819 $('input#ws-plugin--s2member-ip-restrictions-reset-button').click (function()
820 {
821 var $this = $(this); /* Save $(this) into $this. */
822 $this.val ('one moment please ...'); /* Indicate loading status ( please wait ). */
823 /**/
824 $.post (ajaxurl, {action: 'ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax', ws_plugin__s2member_delete_reset_all_ip_restrictions_via_ajax: '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (wp_create_nonce ("ws-plugin--s2member-delete-reset-all-ip-restrictions-via-ajax")); ?>'}, function(response)
825 {
826 alert('s2Member\'s IP Restriction Logs have all been reset.'), $this.val ('Reset IP Restriction Logs');
827 });
828 /**/
829 return false;
830 });
831 /**/
832 $('div.ws-plugin--s2member-query-level-access-section input[type="checkbox"][name="ws_plugin__s2member_filter_wp_query\[\]"]').change (function()
833 {
834 var thisChange = $(this).val (); /* Record value associated with change event. Allows for intutitive unchecking. */
835 /**/
836 $('div.ws-plugin--s2member-query-level-access-section input[type="checkbox"][name="ws_plugin__s2member_filter_wp_query\[\]"]').each (function()
837 {
838 var $this = $(this), val = $this.val (), checkboxes = 'input[type="checkbox"]';
839 /**/
840 if (val === 'all' && this.checked) /* All sub-items get checked/disabled. */
841 $this.nextAll (checkboxes).attr ({'checked': 'checked', 'disabled': 'disabled'});
842 /**/
843 else if (val === 'all' && !this.checked)
844 {
845 $this.nextAll (checkboxes).removeAttr ('disabled');
846 (thisChange === 'all') ? $this.nextAll (checkboxes).removeAttr ('checked') : null;
847 }
848 });
849 /**/
850 }).last ().trigger ('change');
851 }
852 /**/
853 if (location.href.match (/page\=ws-plugin--s2member-down-ops/))
854 {
855 var updateCloudFrontPrivateKey = function() /* Attaches to events below. */
856 {
857 var $hiddenPrivateKey = $('input#ws-plugin--s2member-amazon-cf-files-private-key');
858 var $visiblePrivateKeyEntry = $('textarea#ws-plugin--s2member-amazon-cf-files-private-key-entry');
859 var hiddenPrivateKeyValue = $.trim ($hiddenPrivateKey.val ()), visiblePrivateKeyEntryValue = $.trim ($visiblePrivateKeyEntry.val ());
860 /**/
861 if ((hiddenPrivateKeyValue && !visiblePrivateKeyEntryValue) || visiblePrivateKeyEntryValue.match (/[^\r\n\u25CF]/)) /* 9679.toString(16).toUpperCase() = 25CF. */
862 $hiddenPrivateKey.val (visiblePrivateKeyEntryValue), $visiblePrivateKeyEntry.val (visiblePrivateKeyEntryValue.replace (/[^\r\n]/g, String.fromCharCode (9679)));
863 };
864 /**/
865 $('form#ws-plugin--s2member-options-form').submit (updateCloudFrontPrivateKey);
866 $('textarea#ws-plugin--s2member-amazon-cf-files-private-key-entry').change (updateCloudFrontPrivateKey).trigger ('change');
867 /**/
868 var updateCloudFrontDistroCfgs = function() /* Attaches to events below. */
869 {
870 var $hiddenPrivateKey = $('input#ws-plugin--s2member-amazon-cf-files-private-key');
871 var $visiblePrivateKeyId = $('input#ws-plugin--s2member-amazon-cf-files-private-key-id');
872 /**/
873 var $autoConfigDistros = $('input#ws-plugin--s2member-amazon-cf-files-auto-configure-distros');
874 var $autoConfigDistrosStatus = $('input#ws-plugin--s2member-amazon-cf-files-distros-auto-config-status');
875 /**/
876 var autoConfigDistrosStatusValue = $.trim ($autoConfigDistrosStatus.val ());
877 var hiddenPrivateKeyValue = $.trim ($hiddenPrivateKey.val ()), visiblePrivateKeyIdValue = $.trim ($visiblePrivateKeyId.val ());
878 var hiddenPrivateKeyPrevConfigValue = $.trim ($hiddenPrivateKey.attr ('data-s-prev-config-value')), visiblePrivateKeyIdPrevConfigValue = $.trim ($visiblePrivateKeyId.attr ('data-s-prev-config-value'));
879 /**/
880 if (autoConfigDistrosStatusValue === 'configured' && ((visiblePrivateKeyIdPrevConfigValue && visiblePrivateKeyIdValue !== visiblePrivateKeyIdPrevConfigValue) || (hiddenPrivateKeyPrevConfigValue && hiddenPrivateKeyValue !== hiddenPrivateKeyPrevConfigValue)))
881 {
882 alert('s2Member will need to delete and re-configure your Amazon® CloudFront distributions if you change this. When you\'re done editing, click (Save All Changes) below.');
883 $autoConfigDistros.attr ('checked', 'checked'); /* Forcibly check. */
884 }
885 else if (autoConfigDistrosStatusValue !== 'configured' && visiblePrivateKeyIdValue && hiddenPrivateKeyValue)
886 {
887 alert('s2Member will need to auto-configure your Amazon® CloudFront distributions for you. When you\'re done editing, click (Save All Changes) below.');
888 $autoConfigDistros.attr ('checked', 'checked'); /* Forcibly check. */
889 }
890 };
891 /**/
892 $('input#ws-plugin--s2member-amazon-cf-files-private-key-id').change (updateCloudFrontDistroCfgs);
893 $('textarea#ws-plugin--s2member-amazon-cf-files-private-key-entry').change (updateCloudFrontDistroCfgs);
894 /**/
895 $('input#ws-plugin--s2member-amazon-cf-files-auto-configure-distros-w-cnames').change (function()
896 {
897 var $this = $(this), thisChecked = (this.checked) ? true : false;
898 var $autoConfigDistros = $('input#ws-plugin--s2member-amazon-cf-files-auto-configure-distros');
899 var $autoConfigDistroCnames = $('div#ws-plugin--s2member-amazon-cf-files-auto-configure-distro-cnames');
900 /**/
901 (thisChecked) ? $autoConfigDistroCnames.show () : $autoConfigDistroCnames.hide ();
902 (thisChecked) ? $autoConfigDistros.attr ('checked', 'checked') : null;
903 /**/
904 }).trigger ('change');
905 }
906 /**/
907 if (location.href.match (/page\=ws-plugin--s2member-paypal-ops/))
908 {
909 $('select#ws-plugin--s2member-auto-eot-system-enabled').change (function()
910 {
911 var $this = $(this), val = $this.val ();
912 var $viaCron = $('p#ws-plugin--s2member-auto-eot-system-enabled-via-cron');
913 /**/
914 if (val == 2) /* Display Cron instructions. */
915 $viaCron.show ()
916 else /* Hide instructions. */
917 $viaCron.hide ();
918 });
919 }
920 /**/
921 if (location.href.match (/page\=ws-plugin--s2member-paypal-buttons/))
922 {
923 $('div.ws-menu-page select[id]').filter (function() /* Filter all select elements with an id. */
924 {
925 return this.id.match (/^ws-plugin--s2member-(level[1-9][0-9]*|modification)-term$/);
926 }).change (function()
927 {
928 var button = this.id.replace (/^ws-plugin--s2member-(.+?)-term$/g, '$1');
929 var trialDisabled = ($(this).val ().split ('-')[2].replace (/[^0-1BN]/g, '') === 'BN') ? 1 : 0;
930 /**/
931 $('p#ws-plugin--s2member-' + button + '-trial-line').css ('display', (trialDisabled ? 'none' : ''));
932 $('span#ws-plugin--s2member-' + button + '-trial-then').css ('display', (trialDisabled ? 'none' : ''));
933 $('span#ws-plugin--s2member-' + button + '-20p-rule').css ('display', (trialDisabled ? 'none' : ''));
934 /**/
935 (trialDisabled) ? $('input#ws-plugin--s2member-' + button + '-trial-period').val (0) : null;
936 (trialDisabled) ? $('input#ws-plugin--s2member-' + button + '-trial-amount').val ('0.00') : null;
937 });
938 /**/
939 $('div.ws-menu-page input[id]').filter (function() /* Filter all input elements with an id. */
940 {
941 return this.id.match (/^ws-plugin--s2member-(level[1-9][0-9]*|modification|ccap)-ccaps$/);
942 }).keyup (function()
943 {
944 var value = this.value.replace (/^(-all|-al|-a|-)[;,]*/gi, ''), _all = (this.value.match (/^(-all|-al|-a|-)[;,]*/i)) ? '-all,' : '';
945 if (value.match (/[^a-z_0-9,]/)) /* Only if there is a problem with the actual values; because this causes interruptions. */
946 this.value = _all + $.trim ($.trim (value).replace (/[ \-]/g, '_').replace (/[^a-z_0-9,]/gi, '').toLowerCase ());
947 });
948 /**/
949 ws_plugin__s2member_paypalButtonGenerate = function(button) /* Handles PayPal® Button Generation. */
950 {
951 var shortCodeTemplate = '[s2Member-PayPal-Button %%attrs%% image="default" output="button" /]', shortCodeTemplateAttrs = '', labels = {};
952 /**/
953 eval("<?php echo c_ws_plugin__s2member_utils_strings::esc_dq($labels); ?>");
954 /**/
955 var shortCode = $('input#ws-plugin--s2member-' + button + '-shortcode');
956 var code = $('textarea#ws-plugin--s2member-' + button + '-button');
957 var modLevel = $('select#ws-plugin--s2member-modification-level');
958 /**/
959 var level = (button === 'modification') ? modLevel.val ().split (':', 2)[1] : button.replace (/^level/, '');
960 var label = labels['level' + level].replace (/"/g, ''); /* Labels may NOT contain any double-quotes. */
961 var desc = $.trim ($('input#ws-plugin--s2member-' + button + '-desc').val ().replace (/"/g, ""));
962 /**/
963 var trialAmount = $('input#ws-plugin--s2member-' + button + '-trial-amount').val ().replace (/[^0-9\.]/g, '');
964 var trialPeriod = $('input#ws-plugin--s2member-' + button + '-trial-period').val ().replace (/[^0-9]/g, '');
965 var trialTerm = $('select#ws-plugin--s2member-' + button + '-trial-term').val ().replace (/[^A-Z]/g, '');
966 /**/
967 var regAmount = $('input#ws-plugin--s2member-' + button + '-amount').val ().replace (/[^0-9\.]/g, '');
968 var regPeriod = $('select#ws-plugin--s2member-' + button + '-term').val ().split ('-')[0].replace (/[^0-9]/g, '');
969 var regTerm = $('select#ws-plugin--s2member-' + button + '-term').val ().split ('-')[1].replace (/[^A-Z]/g, '');
970 var regRecur = $('select#ws-plugin--s2member-' + button + '-term').val ().split ('-')[2].replace (/[^0-1BN]/g, '');
971 var regRecurTimes = '', regRecurRetry = '1'; /* These options are NOT yet configurable. */
972 /**/
973 var localeCode = '', digital = '0', noShipping = '1'; /* NOT yet configurable. */
974 var pageStyle = $.trim ($('input#ws-plugin--s2member-' + button + '-page-style').val ().replace (/"/g, ''));
975 var currencyCode = $('select#ws-plugin--s2member-' + button + '-currency').val ().replace (/[^A-Z]/g, '');
976 /**/
977 var cCaps = $.trim ($.trim ($('input#ws-plugin--s2member-' + button + '-ccaps').val ()).replace (/^(-all|-al|-a|-)[;,]*/gi, '').replace (/[ \-]/g, '_').replace (/[^a-z_0-9,]/gi, '').toLowerCase ());
978 cCaps = ($.trim ($('input#ws-plugin--s2member-' + button + '-ccaps').val ()).match (/^(-all|-al|-a|-)[;,]*/i)) ? ((cCaps) ? '-all,' : '-all') + cCaps.toLowerCase () : cCaps.toLowerCase ();
979 /**/
980 trialPeriod = (regRecur === 'BN') ? '0' : trialPeriod; /* Lifetime ( 1-L-BN ) and Buy Now ( BN ) access is absolutely NOT compatible w/ Trial Periods. */
981 trialAmount = (!trialAmount || isNaN(trialAmount) || trialAmount < 0.01 || trialPeriod <= 0) ? '0' : trialAmount; /* Validate Trial Amount. */
982 /**/
983 var levelCcapsPer = (regRecur === 'BN' && regTerm !== 'L') ? level + ':' + cCaps + ':' + regPeriod + ' ' + regTerm : level + ':' + cCaps;
984 levelCcapsPer = levelCcapsPer.replace (/\:+$/g, ''); /* Clean any trailing separators from this string. */
985 /**/
986 if (trialAmount !== '0' && (isNaN(trialAmount) || trialAmount < 0.00))
987 {
988 alert('— Oops, a slight problem: —\n\nWhen provided, Trial Amount must be >= 0.00');
989 return false;
990 }
991 else if (trialAmount !== '0' && trialAmount > 10000.00) /* $10,000.00 maximum. */
992 {
993 alert('— Oops, a slight problem: —\n\nMaximum Trial Amount is: 10000.00');
994 return false;
995 }
996 else if (trialTerm === 'D' && trialPeriod > 7) /* Some validation on the Trial Period. Max days: 7. */
997 {
998 alert('— Oops, a slight problem: —\n\nMaximum Trial Days is: 7.\nIf you want to offer more than 7 days, please choose Weeks or Months from the drop-down.');
999 return false;
1000 }
1001 else if (trialTerm === 'W' && trialPeriod > 52) /* Some validation on the Trial Period. 52 max. */
1002 {
1003 alert('— Oops, a slight problem: —\n\nMaximum Trial Weeks is: 52.\nIf you want to offer more than 52 weeks, please choose Months from the drop-down.');
1004 return false;
1005 }
1006 else if (trialTerm === 'M' && trialPeriod > 12) /* Some validation on the Trial Period. 12 max. */
1007 {
1008 alert('— Oops, a slight problem: —\n\nMaximum Trial Months is: 12.\nIf you want to offer more than 12 months, please choose Years from the drop-down.');
1009 return false;
1010 }
1011 else if (trialTerm === 'Y' && trialPeriod > 1) /* 1 year max. */
1012 {
1013 alert('— Oops, a slight problem: —\n\nMax Trial Period Years is: 1.');
1014 return false;
1015 }
1016 else if (!regAmount || isNaN(regAmount) || regAmount < 0.01)
1017 {
1018 alert('— Oops, a slight problem: —\n\nAmount must be >= 0.01');
1019 return false;
1020 }
1021 else if (regAmount > 10000.00) /* $10,000.00 maximum. */
1022 {
1023 alert('— Oops, a slight problem: —\n\nMaximum Amount is: 10000.00');
1024 return false;
1025 }
1026 else if (!desc) /* Each Button should have a Description. */
1027 {
1028 alert('— Oops, a slight problem: —\n\nPlease type a Description for this Button.');
1029 return false;
1030 }
1031 /**/
1032 code.html (code.val ().replace (/ \<\!--(\<input type\="hidden" name\="(amount|src|srt|sra|a1|p1|t1|a3|p3|t3)" value\="(.*?)" \/\>)--\>/g, " $1"));
1033 (parseInt(trialPeriod) <= 0) ? code.html (code.val ().replace (/ (\<input type\="hidden" name\="(a1|p1|t1)" value\="(.*?)" \/\>)/g, " <!--$1-->")) : null;
1034 (regRecur === 'BN') ? code.html (code.val ().replace (/ (\<input type\="hidden" name\="cmd" value\=")(.*?)(" \/\>)/g, " $1_xclick$3")) : null;
1035 (regRecur === 'BN') ? code.html (code.val ().replace (/ (\<input type\="hidden" name\="(src|srt|sra|a1|p1|t1|a3|p3|t3)" value\="(.*?)" \/\>)/g, " <!--$1-->")) : null;
1036 (regRecur !== 'BN') ? code.html (code.val ().replace (/ (\<input type\="hidden" name\="cmd" value\=")(.*?)(" \/\>)/g, " $1_xclick-subscriptions$3")) : null;
1037 (regRecur !== 'BN') ? code.html (code.val ().replace (/ (\<input type\="hidden" name\="amount" value\="(.*?)" \/\>)/g, " <!--$1-->")) : null;
1038 /**/
1039 shortCodeTemplateAttrs += (button === 'modification') ? 'modify="1" ' : ''; /* For Modification Buttons. */
1040 shortCodeTemplateAttrs += 'level="' + esc_attr(level) + '" ccaps="' + esc_attr(cCaps) + '" desc="' + esc_attr(desc) + '" ps="' + esc_attr(pageStyle) + '" lc="' + esc_attr(localeCode) + '" cc="' + esc_attr(currencyCode) + '" dg="' + esc_attr(digital) + '" ns="' + esc_attr(noShipping) + '" custom="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["HTTP_HOST"])); ?>"';
1041 shortCodeTemplateAttrs += ' ta="' + esc_attr(trialAmount) + '" tp="' + esc_attr(trialPeriod) + '" tt="' + esc_attr(trialTerm) + '" ra="' + esc_attr(regAmount) + '" rp="' + esc_attr(regPeriod) + '" rt="' + esc_attr(regTerm) + '" rr="' + esc_attr(regRecur) + '" rrt="' + esc_attr(regRecurTimes) + '" rra="' + esc_attr(regRecurRetry) + '"';
1042 shortCode.val (shortCodeTemplate.replace (/%%attrs%%/, shortCodeTemplateAttrs));
1043 /**/
1044 code.html (code.val ().replace (/ name\="lc" value\="(.*?)"/, ' name="lc" value="' + esc_attr(localeCode) + '"'));
1045 code.html (code.val ().replace (/ name\="no_shipping" value\="(.*?)"/, ' name="no_shipping" value="' + esc_attr(noShipping) + '"'));
1046 code.html (code.val ().replace (/ name\="item_name" value\="(.*?)"/, ' name="item_name" value="' + esc_attr(desc) + '"'));
1047 code.html (code.val ().replace (/ name\="item_number" value\="(.*?)"/, ' name="item_number" value="' + esc_attr(levelCcapsPer) + '"'));
1048 code.html (code.val ().replace (/ name\="page_style" value\="(.*?)"/, ' name="page_style" value="' + esc_attr(pageStyle) + '"'));
1049 code.html (code.val ().replace (/ name\="currency_code" value\="(.*?)"/, ' name="currency_code" value="' + esc_attr(currencyCode) + '"'));
1050 code.html (code.val ().replace (/ name\="custom" value\="(.*?)"/, ' name="custom" value="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["HTTP_HOST"])); ?>"'));
1051 /**/
1052 code.html (code.val ().replace (/ name\="modify" value\="(.*?)"/, ' name="modify" value="' + ((button === 'modification') ? '1' : '0') + '"'));
1053 /**/
1054 code.html (code.val ().replace (/ name\="amount" value\="(.*?)"/, ' name="amount" value="' + esc_attr(regAmount) + '"'));
1055 /**/
1056 code.html (code.val ().replace (/ name\="src" value\="(.*?)"/, ' name="src" value="' + esc_attr(regRecur) + '"'));
1057 code.html (code.val ().replace (/ name\="srt" value\="(.*?)"/, ' name="srt" value="' + esc_attr(regRecurTimes) + '"'));
1058 code.html (code.val ().replace (/ name\="sra" value\="(.*?)"/, ' name="sra" value="' + esc_attr(regRecurRetry) + '"'));
1059 /**/
1060 code.html (code.val ().replace (/ name\="a1" value\="(.*?)"/, ' name="a1" value="' + esc_attr(trialAmount) + '"'));
1061 code.html (code.val ().replace (/ name\="p1" value\="(.*?)"/, ' name="p1" value="' + esc_attr(trialPeriod) + '"'));
1062 code.html (code.val ().replace (/ name\="t1" value\="(.*?)"/, ' name="t1" value="' + esc_attr(trialTerm) + '"'));
1063 code.html (code.val ().replace (/ name\="a3" value\="(.*?)"/, ' name="a3" value="' + esc_attr(regAmount) + '"'));
1064 code.html (code.val ().replace (/ name\="p3" value\="(.*?)"/, ' name="p3" value="' + esc_attr(regPeriod) + '"'));
1065 code.html (code.val ().replace (/ name\="t3" value\="(.*?)"/, ' name="t3" value="' + esc_attr(regTerm) + '"'));
1066 /**/
1067 $('div#ws-plugin--s2member-' + button + '-button-prev').html (code.val ().replace (/\<form/, '<form target="_blank"').replace (/\<\?php echo S2MEMBER_VALUE_FOR_PP_INV\(\); \?\>/g, Math.round (new Date ().getTime ()) + '~<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["REMOTE_ADDR"])); ?>').replace (/\<\?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_(ON0|OS0|ON1|OS1); \?\>/g, ''));
1068 /**/
1069 (button === 'modification') ? alert('Your Modification Button has been generated.\nPlease copy/paste the Shortcode Format into your Login Welcome Page, or wherever you feel it would be most appropriate.\n\n* Remember, Modification Buttons should be displayed to existing Users/Members, and they should be logged-in, BEFORE clicking this Button.') : alert('Your Button has been generated.\nPlease copy/paste the Shortcode Format into your Membership Options Page.');
1070 /**/
1071 shortCode.each (function() /* Focus and select the recommended Shortcode. */
1072 {
1073 this.focus (), this.select ();
1074 });
1075 /**/
1076 return false;
1077 };
1078 /**/
1079 ws_plugin__s2member_paypalCcapButtonGenerate = function() /* Handles PayPal® Button Generation for Independent Capabilities. */
1080 {
1081 var shortCodeTemplate = '[s2Member-PayPal-Button %%attrs%% image="default" output="button" /]', shortCodeTemplateAttrs = '';
1082 /**/
1083 var shortCode = $('input#ws-plugin--s2member-ccap-shortcode');
1084 var code = $('textarea#ws-plugin--s2member-ccap-button');
1085 /**/
1086 var desc = $.trim ($('input#ws-plugin--s2member-ccap-desc').val ().replace (/"/g, ''));
1087 /**/
1088 var regAmount = $('input#ws-plugin--s2member-ccap-amount').val ().replace (/[^0-9\.]/g, '');
1089 var regPeriod = $('select#ws-plugin--s2member-ccap-term').val ().split ('-')[0].replace (/[^0-9]/g, '');
1090 var regTerm = $('select#ws-plugin--s2member-ccap-term').val ().split ('-')[1].replace (/[^A-Z]/g, '');
1091 var regRecur = $('select#ws-plugin--s2member-ccap-term').val ().split ('-')[2].replace (/[^0-1BN]/g, '');
1092 /**/
1093 var localeCode = '', digital = '0', noShipping = '1'; /* NOT yet configurable. */
1094 var pageStyle = $.trim ($('input#ws-plugin--s2member-ccap-page-style').val ().replace (/"/g, ''));
1095 var currencyCode = $('select#ws-plugin--s2member-ccap-currency').val ().replace (/[^A-Z]/g, '');
1096 /**/
1097 var cCaps = $.trim ($.trim ($('input#ws-plugin--s2member-ccap-ccaps').val ()).replace (/^(-all|-al|-a|-)[;,]*/gi, '').replace (/[ \-]/g, '_').replace (/[^a-z_0-9,]/gi, '').toLowerCase ());
1098 cCaps = ($.trim ($('input#ws-plugin--s2member-ccap-ccaps').val ()).match (/^(-all|-al|-a|-)[;,]*/i)) ? ((cCaps) ? '-all,' : '-all') + cCaps.toLowerCase () : cCaps.toLowerCase ();
1099 /**/
1100 var levelCcapsPer = (regRecur === 'BN' && regTerm !== 'L') ? '*:' + cCaps + ':' + regPeriod + ' ' + regTerm : '*:' + cCaps;
1101 levelCcapsPer = levelCcapsPer.replace (/\:+$/g, ''); /* Clean any trailing separators from this string. */
1102 /**/
1103 if (!cCaps || cCaps === '-all') /* Must have some Independent Custom Capabilities. */
1104 {
1105 alert('— Oops, a slight problem: —\n\nPlease provide at least one Custom Capability.');
1106 return false;
1107 }
1108 else if (!regAmount || isNaN(regAmount) || regAmount < 0.01)
1109 {
1110 alert('— Oops, a slight problem: —\n\nAmount must be >= 0.01');
1111 return false;
1112 }
1113 else if (regAmount > 10000.00) /* $10,000.00 maximum. */
1114 {
1115 alert('— Oops, a slight problem: —\n\nMaximum Amount is: 10000.00');
1116 return false;
1117 }
1118 else if (!desc) /* Each Button should have a Description. */
1119 {
1120 alert('— Oops, a slight problem: —\n\nPlease type a Description for this Button.');
1121 return false;
1122 }
1123 /**/
1124 shortCodeTemplateAttrs += 'level="*" ccaps="' + esc_attr(cCaps) + '" desc="' + esc_attr(desc) + '" ps="' + esc_attr(pageStyle) + '" lc="' + esc_attr(localeCode) + '" cc="' + esc_attr(currencyCode) + '" dg="' + esc_attr(digital) + '" ns="' + esc_attr(noShipping) + '"';
1125 shortCodeTemplateAttrs += ' custom="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["HTTP_HOST"])); ?>" ra="' + esc_attr(regAmount) + '" rp="' + esc_attr(regPeriod) + '" rt="' + esc_attr(regTerm) + '" rr="' + esc_attr(regRecur) + '"';
1126 shortCode.val (shortCodeTemplate.replace (/%%attrs%%/, shortCodeTemplateAttrs));
1127 /**/
1128 code.html (code.val ().replace (/ name\="lc" value\="(.*?)"/, ' name="lc" value="' + esc_attr(localeCode) + '"'));
1129 code.html (code.val ().replace (/ name\="no_shipping" value\="(.*?)"/, ' name="no_shipping" value="' + esc_attr(noShipping) + '"'));
1130 code.html (code.val ().replace (/ name\="item_name" value\="(.*?)"/, ' name="item_name" value="' + esc_attr(desc) + '"'));
1131 code.html (code.val ().replace (/ name\="item_number" value\="(.*?)"/, ' name="item_number" value="' + esc_attr(levelCcapsPer) + '"'));
1132 code.html (code.val ().replace (/ name\="page_style" value\="(.*?)"/, ' name="page_style" value="' + esc_attr(pageStyle) + '"'));
1133 code.html (code.val ().replace (/ name\="currency_code" value\="(.*?)"/, ' name="currency_code" value="' + esc_attr(currencyCode) + '"'));
1134 code.html (code.val ().replace (/ name\="custom" value\="(.*?)"/, ' name="custom" value="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["HTTP_HOST"])); ?>"'));
1135 /**/
1136 code.html (code.val ().replace (/ name\="amount" value\="(.*?)"/, ' name="amount" value="' + esc_attr(regAmount) + '"'));
1137 /**/
1138 $('div#ws-plugin--s2member-ccap-button-prev').html (code.val ().replace (/\<form/, '<form target="_blank"').replace (/\<\?php echo S2MEMBER_VALUE_FOR_PP_INV\(\); \?\>/g, Math.round (new Date ().getTime ()) + '~<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["REMOTE_ADDR"])); ?>').replace (/\<\?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_(ON0|OS0|ON1|OS1); \?\>/g, ''));
1139 /**/
1140 alert('Your Button has been generated.\nPlease copy/paste the Shortcode Format into your Login Welcome Page, or wherever you feel it would be most appropriate.\n\n* Remember, Independent Custom Capability Buttons should ONLY be displayed to existing Users/Members, and they MUST be logged-in, BEFORE clicking this Button.');
1141 /**/
1142 shortCode.each (function() /* Focus and select the recommended Shortcode. */
1143 {
1144 this.focus (), this.select ();
1145 });
1146 /**/
1147 return false;
1148 };
1149 /**/
1150 ws_plugin__s2member_paypalSpButtonGenerate = function() /* Handles PayPal® Button Generation for Specific Post/Page Access. */
1151 {
1152 var shortCodeTemplate = '[s2Member-PayPal-Button %%attrs%% image="default" output="button" /]', shortCodeTemplateAttrs = '';
1153 /**/
1154 var shortCode = $('input#ws-plugin--s2member-sp-shortcode');
1155 var code = $('textarea#ws-plugin--s2member-sp-button');
1156 /**/
1157 var leading = $('select#ws-plugin--s2member-sp-leading-id').val ().replace (/[^0-9]/g, '');
1158 var additionals = $('select#ws-plugin--s2member-sp-additional-ids').val () || [];
1159 var hours = $('select#ws-plugin--s2member-sp-hours').val ().replace (/[^0-9]/g, '');
1160 /**/
1161 var regAmount = $('input#ws-plugin--s2member-sp-amount').val ().replace (/[^0-9\.]/g, '');
1162 var desc = $.trim ($('input#ws-plugin--s2member-sp-desc').val ().replace (/"/g, ''));
1163 /**/
1164 var localeCode = '', digital = '0', noShipping = '1'; /* NOT yet configurable. */
1165 var pageStyle = $.trim ($('input#ws-plugin--s2member-sp-page-style').val ().replace (/"/g, ''));
1166 var currencyCode = $('select#ws-plugin--s2member-sp-currency').val ().replace (/[^A-Z]/g, '');
1167 /**/
1168 if (!leading) /* Must have a Leading Post/Page ID to work with. Otherwise, Link generation will fail. */
1169 {
1170 alert('— Oops, a slight problem: —\n\nPlease select a Leading Post/Page.\n\n*Tip* If there are no Posts/Pages in the menu, it\'s because you\'ve not configured s2Member for Specific Post/Page Access yet. See: s2Member -> Restriction Options -> Specific Post/Page Access.');
1171 return false;
1172 }
1173 else if (!regAmount || isNaN(regAmount) || regAmount < 0.01)
1174 {
1175 alert('— Oops, a slight problem: —\n\nAmount must be >= 0.01');
1176 return false;
1177 }
1178 else if (regAmount > 10000.00) /* $10,000.00 maximum. */
1179 {
1180 alert('— Oops, a slight problem: —\n\nMaximum Amount is: 10000.00');
1181 return false;
1182 }
1183 else if (!desc) /* Each Button should have a Description. */
1184 {
1185 alert('— Oops, a slight problem: —\n\nPlease type a Description for this Button.');
1186 return false;
1187 }
1188 /**/
1189 for (var i = 0, ids = leading; i < additionals.length; i++)
1190 if (additionals[i] && additionals[i] !== leading)
1191 ids += ',' + additionals[i];
1192 /**/
1193 var spIdsHours = 'sp:' + ids + ':' + hours; /* Combined sp:ids:expiration hours. */
1194 /**/
1195 shortCodeTemplateAttrs += 'sp="1" ids="' + esc_attr(ids) + '" exp="' + esc_attr(hours) + '" desc="' + esc_attr(desc) + '" ps="' + esc_attr(pageStyle) + '" lc="' + esc_attr(localeCode) + '" cc="' + esc_attr(currencyCode) + '" dg="' + esc_attr(digital) + '" ns="' + esc_attr(noShipping) + '"';
1196 shortCodeTemplateAttrs += ' custom="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["HTTP_HOST"])); ?>" ra="' + esc_attr(regAmount) + '"';
1197 shortCode.val (shortCodeTemplate.replace (/%%attrs%%/, shortCodeTemplateAttrs));
1198 /**/
1199 code.html (code.val ().replace (/ name\="lc" value\="(.*?)"/, ' name="lc" value="' + esc_attr(localeCode) + '"'));
1200 code.html (code.val ().replace (/ name\="no_shipping" value\="(.*?)"/, ' name="no_shipping" value="' + esc_attr(noShipping) + '"'));
1201 code.html (code.val ().replace (/ name\="item_name" value\="(.*?)"/, ' name="item_name" value="' + esc_attr(desc) + '"'));
1202 code.html (code.val ().replace (/ name\="item_number" value\="(.*?)"/, ' name="item_number" value="' + esc_attr(spIdsHours) + '"'));
1203 code.html (code.val ().replace (/ name\="page_style" value\="(.*?)"/, ' name="page_style" value="' + esc_attr(pageStyle) + '"'));
1204 code.html (code.val ().replace (/ name\="currency_code" value\="(.*?)"/, ' name="currency_code" value="' + esc_attr(currencyCode) + '"'));
1205 code.html (code.val ().replace (/ name\="custom" value\="(.*?)"/, ' name="custom" value="<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["HTTP_HOST"])); ?>"'));
1206 /**/
1207 code.html (code.val ().replace (/ name\="amount" value\="(.*?)"/, ' name="amount" value="' + esc_attr(regAmount) + '"'));
1208 /**/
1209 $('div#ws-plugin--s2member-sp-button-prev').html (code.val ().replace (/\<form/, '<form target="_blank"').replace (/\<\?php echo S2MEMBER_VALUE_FOR_PP_INV\(\); \?\>/g, Math.round (new Date ().getTime ()) + '~<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (esc_attr ($_SERVER["REMOTE_ADDR"])); ?>').replace (/\<\?php echo S2MEMBER_CURRENT_USER_VALUE_FOR_PP_(ON0|OS0|ON1|OS1); \?\>/g, ''));
1210 /**/
1211 alert('Your Button has been generated.\nPlease copy/paste the Shortcode Format into your WordPress® Editor.');
1212 /**/
1213 shortCode.each (function() /* Focus and select the recommended Shortcode. */
1214 {
1215 this.focus (), this.select ();
1216 });
1217 /**/
1218 return false;
1219 };
1220 /**/
1221 ws_plugin__s2member_paypalRegLinkGenerate = function() /* Handles PayPal® Link Generation. */
1222 {
1223 var level = $('select#ws-plugin--s2member-reg-link-level').val ().replace (/[^0-9]/g, '');
1224 var subscrID = $.trim ($('input#ws-plugin--s2member-reg-link-subscr-id').val ());
1225 var custom = $.trim ($('input#ws-plugin--s2member-reg-link-custom').val ());
1226 var cCaps = $.trim ($.trim ($('input#ws-plugin--s2member-reg-link-ccaps').val ()).replace (/[ \-]/g, '_').replace (/[^a-z_0-9,]/gi, '').toLowerCase ());
1227 var fixedTerm = $.trim ($('input#ws-plugin--s2member-reg-link-fixed-term').val ().replace (/[^A-Z 0-9]/gi, '').toUpperCase ());
1228 var $link = $('p#ws-plugin--s2member-reg-link'), $loading = $('img#ws-plugin--s2member-reg-link-loading');
1229 /**/
1230 var levelCcapsPer = (fixedTerm && !fixedTerm.match (/L$/)) ? level + ':' + cCaps + ':' + fixedTerm : level + ':' + cCaps;
1231 levelCcapsPer = levelCcapsPer.replace (/\:+$/g, ''); /* Clean any trailing separators from this string. */
1232 /**/
1233 if (!subscrID) /* We must have a Paid Subscr. ID value. */
1234 {
1235 alert('— Oops, a slight problem: —\n\nPaid Subscr. ID is a required value.');
1236 return false;
1237 }
1238 else if (!custom || custom.indexOf ('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq ($_SERVER["HTTP_HOST"]); ?>') !== 0)
1239 {
1240 alert('— Oops, a slight problem: —\n\nThe Custom Value MUST start with your domain name.');
1241 return false;
1242 }
1243 else if (fixedTerm && !fixedTerm.match (/^[1-9]+ (D|W|M|Y|L)$/)) /* Check format. */
1244 {
1245 alert('— Oops, a slight problem: —\n\nThe Fixed Term Length is not formatted properly.');
1246 return false;
1247 }
1248 /**/
1249 $link.hide (), $loading.show (), $.post (ajaxurl, {action: 'ws_plugin__s2member_reg_access_link_via_ajax', ws_plugin__s2member_reg_access_link_via_ajax: '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (wp_create_nonce ("ws-plugin--s2member-reg-access-link-via-ajax")); ?>', s2member_reg_access_link_subscr_gateway: 'paypal', s2member_reg_access_link_subscr_id: subscrID, s2member_reg_access_link_custom: custom, s2member_reg_access_link_item_number: levelCcapsPer}, function(response)
1250 {
1251 $link.show ().html ('<a href="' + esc_attr(response) + '" target="_blank" rel="external">' + esc_html(response) + '</a>'), $loading.hide ();
1252 });
1253 /**/
1254 return false;
1255 };
1256 /**/
1257 ws_plugin__s2member_paypalSpLinkGenerate = function() /* Handles PayPal® Link Generation. */
1258 {
1259 var leading = $('select#ws-plugin--s2member-sp-link-leading-id').val ().replace (/[^0-9]/g, '');
1260 var additionals = $('select#ws-plugin--s2member-sp-link-additional-ids').val () || [];
1261 var hours = $('select#ws-plugin--s2member-sp-link-hours').val ().replace (/[^0-9]/g, '');
1262 var $link = $('p#ws-plugin--s2member-sp-link'), $loading = $('img#ws-plugin--s2member-sp-link-loading');
1263 /**/
1264 if (!leading) /* Must have a Leading Post/Page ID to work with. Otherwise, Link generation will fail. */
1265 {
1266 alert('— Oops, a slight problem: —\n\nPlease select a Leading Post/Page.\n\n*Tip* If there are no Posts/Pages in the menu, it\'s because you\'ve not configured s2Member for Specific Post/Page Access yet. See: s2Member -> Restriction Options -> Specific Post/Page Access.');
1267 return false;
1268 }
1269 /**/
1270 for (var i = 0, ids = leading; i < additionals.length; i++)
1271 if (additionals[i] && additionals[i] !== leading)
1272 ids += ',' + additionals[i];
1273 /**/
1274 $link.hide (), $loading.show (), $.post (ajaxurl, {action: 'ws_plugin__s2member_sp_access_link_via_ajax', ws_plugin__s2member_sp_access_link_via_ajax: '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (wp_create_nonce ("ws-plugin--s2member-sp-access-link-via-ajax")); ?>', s2member_sp_access_link_ids: ids, s2member_sp_access_link_hours: hours}, function(response)
1275 {
1276 $link.show ().html ('<a href="' + esc_attr(response) + '" target="_blank" rel="external">' + esc_html(response) + '</a>'), $loading.hide ();
1277 });
1278 /**/
1279 return false;
1280 };
1281 }
1282 /**/
1283 if (location.href.match (/page\=ws-plugin--s2member-els-ops/))
1284 {
1285 $('select#ws-plugin--s2member-custom-reg-opt-in').change (function()
1286 {
1287 var $this = $(this), val = $this.val ();
1288 var $rows = $('tr.ws-plugin--s2member-custom-reg-opt-in-label-row');
1289 var $prevImg = $('img.ws-plugin--s2member-custom-reg-opt-in-label-prev-img');
1290 /**/
1291 if (val <= 0) /* Checkbox disabled. */
1292 $rows.css ('display', 'none'), $prevImg.attr ('src', $prevImg.attr ('src').replace (/\/checked\.png$/, '/unchecked.png'));
1293 /**/
1294 else if (val == 1) /* Enabled, checked by default. */
1295 $rows.css ('display', ''), $prevImg.attr ('src', $prevImg.attr ('src').replace (/\/unchecked\.png$/, '/checked.png'));
1296 /**/
1297 else if (val == 2) /* Enabled, unchecked by default. */
1298 $rows.css ('display', ''), $prevImg.attr ('src', $prevImg.attr ('src').replace (/\/checked\.png$/, '/unchecked.png'));
1299 });
1300 /**/
1301 $('div.ws-plugin--s2member-opt-out-section input[type="checkbox"][name="ws_plugin__s2member_custom_reg_auto_opt_outs\[\]"]').change (function()
1302 {
1303 var thisChange = $(this).val (), checkedIndexes = []; /* Record value associated with change event. Also initialize checkedIndexes array. */
1304 /**/
1305 $('div.ws-plugin--s2member-opt-out-section input[type="checkbox"][name="ws_plugin__s2member_custom_reg_auto_opt_outs\[\]"]').each (function()
1306 {
1307 var $this = $(this), val = $this.val (), checkboxes = 'input[type="checkbox"]';
1308 /**/
1309 if (val === 'removal-deletion' && this.checked) /* All sub-items get checked/disabled too. */
1310 $this.nextAll (checkboxes).slice (0, 2).attr ({'checked': 'checked', 'disabled': 'disabled'});
1311 /**/
1312 else if (val === 'removal-deletion' && !this.checked)
1313 {
1314 $this.nextAll (checkboxes).slice (0, 2).removeAttr ('disabled');
1315 (thisChange === 'removal-deletion') ? $this.nextAll (checkboxes).slice (0, 2).removeAttr ('checked') : null;
1316 }
1317 /**/
1318 else if (val === 'modification' && this.checked) /* All sub-items get checked/disabled too. */
1319 $this.nextAll (checkboxes).slice (0, 3).attr ({'checked': 'checked', 'disabled': 'disabled'});
1320 /**/
1321 else if (val === 'modification' && !this.checked)
1322 {
1323 (thisChange === 'modification') ? $this.nextAll (checkboxes).slice (0, 3).removeAttr ('checked') : null;
1324 $this.nextAll (checkboxes).slice (0, 3).removeAttr ('disabled');
1325 }
1326 })
1327 /**/
1328 .each (function(index) /* Now, which ones are checked? */
1329 {
1330 (this.checked) ? checkedIndexes.push (index) : null;
1331 });
1332 /**/
1333 $('select#ws-plugin--s2member-custom-reg-auto-opt-out-transitions').removeAttr ('disabled');
1334 if ($.inArray (3, checkedIndexes) === -1 && $.inArray (4, checkedIndexes) === -1 && $.inArray (5, checkedIndexes) === -1 && $.inArray (6, checkedIndexes) === -1)
1335 $('select#ws-plugin--s2member-custom-reg-auto-opt-out-transitions').attr ('disabled', 'disabled');
1336 /**/
1337 }).last ().trigger ('change');
1338 }
1339 /**/
1340 if (location.href.match (/page\=ws-plugin--s2member-integrations/))
1341 {
1342 $('select#ws-plugin--s2member-bbpress-ovg').change (function()
1343 {
1344 if ($(this).val () === '0') /* Expand/collapse notation; based on selection. */
1345 {
1346 $('span#ws-plugin--s2member-bbpress-ovg-off-note').css ('display', 'inline');
1347 /**/
1348 var l = 'form#ws-plugin--s2member-bridge-bbpress-form label[for="ws_plugin--s2member-bridge-bbpress-min-level"]';
1349 /**/
1350 $(l).text ($(l).text ().replace (/to (read\/)?participate/i, 'to read/participate')), $('select#ws-plugin--s2member-bbpress-min-level option').each (function()
1351 {
1352 $(this).text ($(this).text ().replace (/\( to( read and)? participate \)/i, '( to read and participate )'));
1353 });
1354 }
1355 else if ($(this).val () === '1') /* Expand/collapse notation. */
1356 {
1357 $('span#ws-plugin--s2member-bbpress-ovg-off-note').css ('display', 'none');
1358 /**/
1359 var l = 'form#ws-plugin--s2member-bridge-bbpress-form label[for="ws_plugin--s2member-bridge-bbpress-min-level"]';
1360 /**/
1361 $(l).text ($(l).text ().replace (/to (read\/)?participate/i, 'to participate')), $('select#ws-plugin--s2member-bbpress-min-level option').each (function()
1362 {
1363 $(this).text ($(this).text ().replace (/\( to( read and)? participate \)/i, '( to participate )'));
1364 });
1365 }
1366 /**/
1367 }).trigger ('change'); /* Fire on ready too. */
1368 }
1369 });