PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 111003
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v111003
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 111003, at includes/menu-pages/menu-pages-s.js

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