PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 120213
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v120213
260917 260913 260909 260829 260814 260805 110710 110731 110812 110815 110912 110913 110915 110926 110927 111002 111003 111011 111017 111029 111105 111206 111216 111220 120213 All 189 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 120213, at includes/menu-pages/menu-pages-s.js

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