PluginProbe
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions / 111206
s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions v111206
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 / s2member.js

s2member.js in s2Member – Excellent for All Kinds of Memberships, Content Restriction Paywalls & Member Access Subscriptions 111206, at includes/s2member.js

516 lines 30.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /**
2 * Core JavaScript file for the s2Member plugin.
3 *
4 * This is the development version of the code.
5 * Which ultimately produces s2member-min.js.
6 *
7 * Copyright: © 2009-2011
8 * {@link http://www.websharks-inc.com/ WebSharks, Inc.}
9 * ( coded in the USA )
10 *
11 * Released under the terms of the GNU General Public License.
12 * You should have received a copy of the GNU General Public License,
13 * along with this software. In the main directory, see: /licensing/
14 * If not, see: {@link http://www.gnu.org/licenses/}.
15 *
16 * @package s2Member
17 * @since 3.0
18 */
19 jQuery(document).ready (function($)
20 {
21 ws_plugin__s2member_uniqueFilesDownloaded = /* Real-time counts. */ [];
22 /**/
23 var runningBuddyPress = '<?php echo c_ws_plugin__s2member_utils_conds::bp_is_installed ("query-active-plugins") ? "1" : ""; ?>';
24 /**/
25 if (S2MEMBER_CURRENT_USER_IS_LOGGED_IN && S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY < S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED)
26 {
27 $('a[href*="s2member_file_download"], a[href*="s2member-file"').click (function()
28 {
29 if (!this.href.match (/s2member_file_download_key\=(.+)/i))
30 {
31 var c = '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Confirm File Download —", "s2member-front", "s2member")); ?>' + '\n\n';
32 c += $.sprintf ('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("You`ve downloaded %s protected %s in the last %s.", "s2member-front", "s2member")); ?>', S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY, ((S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY === 1) ? '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("file", "s2member-front", "s2member")); ?>' : '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("files", "s2member-front", "s2member")); ?>'), ((S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS === 1) ? '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("24 hours", "s2member-front", "s2member")); ?>' : $.sprintf ('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("%s days", "s2member-front", "s2member")); ?>', S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS))) + '\n\n';
33 c += (S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_IS_UNLIMITED) ? '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("You`re entitled to UNLIMITED downloads though ( so, no worries ).", "s2member-front", "s2member")); ?>' : $.sprintf ('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("You`re entitled to %s unique %s %s.", "s2member-front", "s2member")); ?>', S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED, ((S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED === 1) ? '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("download", "s2member-front", "s2member")); ?>' : '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("downloads", "s2member-front", "s2member")); ?>'), ((S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS === 1) ? '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("each day", "s2member-front", "s2member")); ?>' : $.sprintf ('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("every %s-day period", "s2member-front", "s2member")); ?>', S2MEMBER_CURRENT_USER_DOWNLOADS_ALLOWED_DAYS)));
34 /**/
35 if (this.href.match (/s2member[_\-]skip[_\-]confirmation/i) && !this.href.match (/s2member[_\-]skip[_\-]confirmation[\=\-](0|no|false)/i) || confirm(c))
36 {
37 if ($.inArray (this.href, ws_plugin__s2member_uniqueFilesDownloaded) === -1)
38 ws_plugin__s2member_uniqueFilesDownloaded.push (this.href), S2MEMBER_CURRENT_USER_DOWNLOADS_CURRENTLY++;
39 return /* Allow. */ true;
40 }
41 else /* Disallow. */
42 return false;
43 }
44 else /* Allow. */
45 return true;
46 });
47 }
48 /**/
49 if (!location.href.match (/\/wp-admin(\/|\?|$)/))
50 {
51 $('input#ws-plugin--s2member-profile-password1, input#ws-plugin--s2member-profile-password2').keyup (function()
52 {
53 ws_plugin__s2member_passwordStrength($('input#ws-plugin--s2member-profile-login'), $('input#ws-plugin--s2member-profile-password1'), $('input#ws-plugin--s2member-profile-password2'), $('div#ws-plugin--s2member-profile-password-strength'));
54 });
55 /**/
56 $('form#ws-plugin--s2member-profile').submit ( /* Validate Profile. */function()
57 {
58 var context = this, label = '', error = '', errors = '';
59 /**/
60 var $password1 = $('input#ws-plugin--s2member-profile-password1', context);
61 var $password2 = $('input#ws-plugin--s2member-profile-password2', context);
62 /**/
63 var $submissionButton = $('input#ws-plugin--s2member-profile-submit', context);
64 /**/
65 $(':input', context).each ( /* Go through them all together. */function()
66 {
67 var id = /* Remove numeric suffixes. */ $.trim ($(this).attr ('id')).replace (/-[0-9]+$/g, '');
68 /**/
69 if (id && (label = $.trim ($('label[for="' + id + '"]', context).first ().children ('strong').first ().text ().replace (/[\r\n\t]+/g, ' '))))
70 {
71 if (error = ws_plugin__s2member_validationErrors(label, this, context))
72 errors += /* Collect errors. */ error + '\n\n';
73 }
74 });
75 /**/
76 if (errors = $.trim (errors))
77 {
78 alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + errors);
79 /**/
80 return false;
81 }
82 /**/
83 else if ($.trim ($password1.val ()) && $.trim ($password1.val ()) !== $.trim ($password2.val ()))
84 {
85 alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Passwords do not match up. Please try again.", "s2member-front", "s2member")); ?>');
86 /**/
87 return false;
88 }
89 /**/
90 else if ($.trim ($password1.val ()) && /* Enforce minimum length requirement here. */ $.trim ($password1.val ()).length < 6)
91 {
92 alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Password MUST be at least 6 characters. Please try again.", "s2member-front", "s2member")); ?>');
93 /**/
94 return false;
95 }
96 /**/
97 ws_plugin__s2member_animateProcessing($submissionButton);
98 /**/
99 return true;
100 });
101 }
102 /**/
103 if (location.href.match (/\/wp-signup\.php/))
104 {
105 $('div#content > div.mu_register > form#setupform').submit (function()
106 {
107 var context = this, label = '', error = '', errors = '';
108 /**/
109 $('input#user_email', context).attr ('data-expected', 'email');
110 /**/
111 var $submissionButton = $('p.submit input[type="submit"]', context);
112 /**/
113 $('input#user_name, input#user_email, input#blogname, input#blog_title, input#captcha_code', context).attr ({'aria-required': 'true'});
114 /**/
115 $(':input', context).each ( /* Go through them all together. */function()
116 {
117 var id = /* Remove numeric suffixes. */ $.trim ($(this).attr ('id')).replace (/-[0-9]+$/g, '');
118 /**/
119 if (id && (label = $.trim ($('label[for="' + id + '"]', context).first ().text ().replace (/[\r\n\t]+/g, ' '))))
120 {
121 if (error = ws_plugin__s2member_validationErrors(label, this, context))
122 errors += /* Collect errors. */ error + '\n\n';
123 }
124 });
125 /**/
126 if (errors = $.trim (errors))
127 {
128 alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + errors);
129 /**/
130 return false;
131 }
132 /**/
133 ws_plugin__s2member_animateProcessing($submissionButton);
134 /**/
135 return true;
136 });
137 }
138 /**/
139 if (location.href.match (/\/wp-login\.php/))
140 {
141 $('input#ws-plugin--s2member-custom-reg-field-user-pass1, input#ws-plugin--s2member-custom-reg-field-user-pass2').keyup (function()
142 {
143 ws_plugin__s2member_passwordStrength($('input#user_login'), $('input#ws-plugin--s2member-custom-reg-field-user-pass1'), $('input#ws-plugin--s2member-custom-reg-field-user-pass2'), $('div#ws-plugin--s2member-custom-reg-field-user-pass-strength'));
144 });
145 /**/
146 $('div#login > form#registerform input#wp-submit').attr /* Makes plenty of room ( i.e. tab indexes ) for Custom Registration Fields. */ ('tabindex', '1000');
147 /**/
148 $('div#login > form#registerform').submit (function()
149 {
150 var context = this, label = '', error = '', errors = '';
151 /**/
152 $('input#user_email', context).attr ('data-expected', 'email');
153 /**/
154 var $pass1 = $('input#ws-plugin--s2member-custom-reg-field-user-pass1[aria-required="true"]', context);
155 var $pass2 = $('input#ws-plugin--s2member-custom-reg-field-user-pass2', context);
156 /**/
157 var $submissionButton = /* Registration submission button. */ $('input#wp-submit', context);
158 /**/
159 $('input#user_login, input#user_email, input#captcha_code', context).attr ({'aria-required': 'true'});
160 /**/
161 $(':input', context).each ( /* Go through them all together. */function()
162 {
163 var id = /* Remove numeric suffixes. */ $.trim ($(this).attr ('id')).replace (/-[0-9]+$/g, '');
164 /**/
165 if /* No for="" attribute on these fields. */ ($.inArray (id, ['user_login', 'user_email', 'captcha_code']) !== -1)
166 {
167 if /* Use label. */ ((label = $.trim ($(this).parent ('label').text ().replace (/[\r\n\t]+/g, ' '))))
168 {
169 if (error = ws_plugin__s2member_validationErrors(label, this, context))
170 errors += /* Collect errors. */ error + '\n\n';
171 }
172 }
173 else if (id && (label = $.trim ($('label[for="' + id + '"]', context).first ().children ('span').first ().text ().replace (/[\r\n\t]+/g, ' '))))
174 {
175 if (error = ws_plugin__s2member_validationErrors(label, this, context))
176 errors += /* Collect errors. */ error + '\n\n';
177 }
178 });
179 /**/
180 if (errors = $.trim (errors))
181 {
182 alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + errors);
183 /**/
184 return false;
185 }
186 /**/
187 else if ($pass1.length && $.trim ($pass1.val ()) !== $.trim ($pass2.val ()))
188 {
189 alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Passwords do not match up. Please try again.", "s2member-front", "s2member")); ?>');
190 /**/
191 return false;
192 }
193 /**/
194 else if /* Enforce minimum length requirement here. */ ($pass1.length && $.trim ($pass1.val ()).length < 6)
195 {
196 alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Password MUST be at least 6 characters. Please try again.", "s2member-front", "s2member")); ?>');
197 /**/
198 return false;
199 }
200 /**/
201 ws_plugin__s2member_animateProcessing($submissionButton);
202 /**/
203 return true;
204 });
205 }
206 /**/
207 if (location.href.match (/\/wp-admin\/(user\/)?profile\.php/))
208 {
209 $('form#your-profile').submit ( /* Validation. */function()
210 {
211 var context = this, label = '', error = '', errors = '';
212 /**/
213 $('input#email', context).attr ('data-expected', 'email');
214 /**/
215 $(':input[id^="ws-plugin--s2member-profile-"]', context).each ( /* Go through them all together. */function()
216 {
217 var id = /* Remove numeric suffixes. */ $.trim ($(this).attr ('id')).replace (/-[0-9]+$/g, '');
218 /**/
219 if (id && (label = $.trim ($('label[for="' + id + '"]', context).first ().text ().replace (/[\r\n\t]+/g, ' '))))
220 {
221 if (error = ws_plugin__s2member_validationErrors(label, this, context))
222 errors += /* Collect errors. */ error + '\n\n';
223 }
224 });
225 /**/
226 if (errors = $.trim (errors))
227 {
228 alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + errors);
229 /**/
230 return false;
231 }
232 /**/
233 return true;
234 });
235 }
236 /**/
237 if /* Attach form submission handler to `/register` for BuddyPress. */ (runningBuddyPress)
238 {
239 $('body.registration form div#ws-plugin--s2member-custom-reg-fields-4bp-section').closest ('form').submit (function()
240 {
241 var context = this, label = '', error = '', errors = '';
242 /**/
243 $('input#signup_email', context).attr ('data-expected', 'email');
244 /**/
245 $('input#signup_username, input#signup_email, input#signup_password, input#field_1', context).attr ({'aria-required': 'true'});
246 /**/
247 $(':input', context).each ( /* Go through them all together. */function()
248 {
249 var id = /* Remove numeric suffixes. */ $.trim ($(this).attr ('id')).replace (/-[0-9]+$/g, '');
250 /**/
251 if (id && (label = $.trim ($('label[for="' + id + '"]', context).first ().text ().replace (/[\r\n\t]+/g, ' '))))
252 {
253 if (error = ws_plugin__s2member_validationErrors(label, this, context))
254 errors += /* Collect errors. */ error + '\n\n';
255 }
256 });
257 /**/
258 if (errors = $.trim (errors))
259 {
260 alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + errors);
261 /**/
262 return false;
263 }
264 /**/
265 return true;
266 });
267 /**/
268 $('body.logged-in.profile.profile-edit :input.ws-plugin--s2member-profile-field-4bp').closest ('form').submit (function()
269 {
270 var context = this, label = '', error = '', errors = '';
271 /**/
272 $('input#field_1', context).attr ({'aria-required': 'true'});
273 /**/
274 $(':input', context).each ( /* Go through them all together. */function()
275 {
276 var id = /* Remove numeric suffixes. */ $.trim ($(this).attr ('id')).replace (/-[0-9]+$/g, '');
277 /**/
278 if (id && (label = $.trim ($('label[for="' + id + '"]', context).first ().text ().replace (/[\r\n\t]+/g, ' '))))
279 {
280 if (error = ws_plugin__s2member_validationErrors(label, this, context))
281 errors += /* Collect errors. */ error + '\n\n';
282 }
283 });
284 /**/
285 if (errors = $.trim (errors))
286 {
287 alert('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("— Oops, you missed something: —", "s2member-front", "s2member")); ?>' + '\n\n' + errors);
288 /**/
289 return false;
290 }
291 /**/
292 return true;
293 });
294 }
295 /**/
296 ws_plugin__s2member_passwordStrength = function($username, $pass1, $pass2, $result)
297 {
298 if ($username instanceof jQuery && $pass1 instanceof jQuery && $pass2 instanceof jQuery && $result instanceof jQuery && typeof passwordStrength === 'function' && typeof pwsL10n === 'object')
299 {
300 $result.removeClass ('ws-plugin--s2member-password-strength-short ws-plugin--s2member-password-strength-bad ws-plugin--s2member-password-strength-good ws-plugin--s2member-password-strength-strong ws-plugin--s2member-password-strength-mismatch');
301 /**/
302 switch /* Uses WordPress® script: `password-strength-meter` and `pwsL10n`. */ (passwordStrength($pass1.val (), $username.val (), $pass2.val ()))
303 {
304 case 1:
305 $result.addClass ('ws-plugin--s2member-password-strength-short').html (pwsL10n['short']);
306 break;
307 case 2:
308 $result.addClass ('ws-plugin--s2member-password-strength-bad').html (pwsL10n['bad']);
309 break;
310 case 3:
311 $result.addClass ('ws-plugin--s2member-password-strength-good').html (pwsL10n['good']);
312 break;
313 case 4:
314 $result.addClass ('ws-plugin--s2member-password-strength-strong').html (pwsL10n['strong']);
315 break;
316 case 5:
317 $result.addClass ('ws-plugin--s2member-password-strength-mismatch').html (pwsL10n['mismatch']);
318 break;
319 default:
320 $result.addClass ('ws-plugin--s2member-password-strength-short').html (pwsL10n['short']);
321 }
322 }
323 /**/
324 return;
325 };
326 /**/
327 ws_plugin__s2member_validationErrors = function(label, field, context, required, expected)
328 {
329 if (typeof label === 'string' && label && typeof field === 'object' && typeof context === 'object')
330 if (typeof field.tagName === 'string' && field.tagName.match (/^(input|textarea|select)$/i) && !field.disabled)
331 {
332 var tag = field.tagName.toLowerCase (), $field = $(field), type = $.trim ($field.attr ('type')).toLowerCase (), name = $.trim ($field.attr ('name')), value = $field.val ();
333 var required = ( typeof required === 'boolean') ? required : ($field.attr ('aria-required') === 'true'), expected = ( typeof expected === 'string') ? expected : $.trim ($field.attr ('data-expected'));
334 /**/
335 var forcePersonalEmails = ('<?php echo strlen($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_force_personal_emails"]); ?>' > 0) ? true : false;
336 var nonPersonalEmailUsers = new RegExp('^(<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (implode ("|", preg_split ("/[\r\n\t ;,]+/", preg_quote ($GLOBALS["WS_PLUGIN__"]["s2member"]["o"]["custom_reg_force_personal_emails"], "/")))); ?>)@', 'i');
337 /**/
338 if (tag === 'input' && type === 'checkbox' && name.match (/\[\]$/))
339 {
340 if (typeof field.id === 'string' && field.id.match (/-0$/))
341 if (required && !$('input[name="' + name.replace (/([\[\]])/g, '\$1') + '"]:checked', context).length)
342 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Please check at least one of the boxes.", "s2member-front", "s2member")); ?>';
343 }
344 else if (tag === 'input' && type === 'checkbox')
345 {
346 if (required && !field.checked)
347 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Required. This box must be checked.", "s2member-front", "s2member")); ?>';
348 }
349 else if (tag === 'input' && type === 'radio')
350 {
351 if (typeof field.id === 'string' && field.id.match (/-0$/))
352 if (required && !$('input[name="' + name.replace (/([\[\]])/g, '\$1') + '"]:checked', context).length)
353 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Please select one of the options.", "s2member-front", "s2member")); ?>';
354 }
355 else if (tag === 'select' && $field.attr ('multiple'))
356 {
357 if (required && (!(value instanceof Array) || !value.length))
358 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Please select at least one of the options.", "s2member-front", "s2member")); ?>';
359 }
360 else if (typeof value !== 'string' || (required && !(value = $.trim (value)).length))
361 {
362 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("This is a required field, please try again.", "s2member-front", "s2member")); ?>';
363 }
364 else if ((value = $.trim (value)).length && ((tag === 'input' && type.match (/^(text|password)$/i)) || tag === 'textarea') && typeof expected === 'string' && expected.length)
365 {
366 if (expected === 'numeric-wp-commas' && (!value.match (/^[0-9\.,]+$/) || isNaN(value.replace (/,/g, ''))))
367 {
368 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Must be numeric ( with or without decimals, commas allowed ).", "s2member-front", "s2member")); ?>';
369 }
370 else if (expected === 'numeric' && (!value.match (/^[0-9\.]+$/) || isNaN(value)))
371 {
372 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Must be numeric ( with or without decimals, no commas ).", "s2member-front", "s2member")); ?>';
373 }
374 else if (expected === 'integer' && (!value.match (/^[0-9]+$/) || isNaN(value)))
375 {
376 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Must be an integer ( a whole number, without any decimals ).", "s2member-front", "s2member")); ?>';
377 }
378 else if (expected === 'integer-gt-0' && (!value.match (/^[0-9]+$/) || isNaN(value) || value <= 0))
379 {
380 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Must be an integer > 0 ( whole number, no decimals, greater than 0 ).", "s2member-front", "s2member")); ?>';
381 }
382 else if (expected === 'float' && (!value.match (/^[0-9\.]+$/) || !value.match (/[0-9]/) || !value.match (/\./) || isNaN(value)))
383 {
384 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Must be a float ( floating point number, decimals required ).", "s2member-front", "s2member")); ?>';
385 }
386 else if (expected === 'float-gt-0' && (!value.match (/^[0-9\.]+$/) || !value.match (/[0-9]/) || !value.match (/\./) || isNaN(value) || value <= 0))
387 {
388 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Must be a float > 0 ( floating point number, decimals required, greater than 0 ).", "s2member-front", "s2member")); ?>';
389 }
390 else if (expected === 'date' && !value.match (/^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/))
391 {
392 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Must be a date ( required date format: dd/mm/yyyy ).", "s2member-front", "s2member")); ?>';
393 }
394 else if (expected === 'email' && !value.match (/^([a-z_~0-9\+\-]+)(((\.?)([a-z_~0-9\+\-]+))*)(@)([a-z0-9]+)(((-*)([a-z0-9]+))*)(((\.)([a-z0-9]+)(((-*)([a-z0-9]+))*))*)(\.)([a-z]{2,6})$/i))
395 {
396 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Must be a valid email address.", "s2member-front", "s2member")); ?>';
397 }
398 else if (expected === 'email' && forcePersonalEmails && value.match (nonPersonalEmailUsers))
399 {
400 return label + '\n' + $.sprintf ('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Please use a personal email address.\nAddresses like <%s@> are problematic.", "s2member-front", "s2member")); ?>', value.split ('@')[0]);
401 }
402 else if (expected === 'url' && !value.match (/^http(s?)\:\/\/(.{5,})$/i))
403 {
404 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Must be a full URL ( starting with http or https ).", "s2member-front", "s2member")); ?>';
405 }
406 else if (expected === 'domain' && !value.match (/^([a-z0-9]+)(((-*)([a-z0-9]+))*)(((\.)([a-z0-9]+)(((-*)([a-z0-9]+))*))*)(\.)([a-z]{2,6})$/i))
407 {
408 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Must be a domain name ( domain name only, without http ).", "s2member-front", "s2member")); ?>';
409 }
410 else if (expected === 'phone' && (!value.match (/^[0-9 \(\)\-]+$/) || value.replace (/[^0-9]/g, '').length !== 10))
411 {
412 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Must be a phone # ( 10 digits w/possible hyphens,spaces,brackets ).", "s2member-front", "s2member")); ?>';
413 }
414 else if (expected === 'uszip' && !value.match (/^[0-9]{5}(-[0-9]{4})?$/))
415 {
416 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Must be a US zipcode ( 5-9 digits w/possible hyphen ).", "s2member-front", "s2member")); ?>';
417 }
418 else if (expected === 'cazip' && !value.match (/^[0-9A-Z]{3}( ?)[0-9A-Z]{3}$/i))
419 {
420 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Must be a Canadian zipcode ( 6 alpha-numerics w/possible space ).", "s2member-front", "s2member")); ?>';
421 }
422 else if (expected === 'uczip' && !value.match (/^[0-9]{5}(-[0-9]{4})?$/) && !value.match (/^[0-9A-Z]{3}( ?)[0-9A-Z]{3}$/i))
423 {
424 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Must be a zipcode ( either a US or Canadian zipcode ).", "s2member-front", "s2member")); ?>';
425 }
426 else if (expected.match (/^alphanumerics-spaces-punctuation-([0-9]+)(-e)?$/) && !value.match (/^[a-z 0-9,\.\/\?\:;"'\{\}\[\]\|\\\+\=_\-\(\)\*&\^%\$#@\!`~]+$/i))
427 {
428 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Please use alphanumerics, spaces & punctuation only.", "s2member-front", "s2member")); ?>';
429 }
430 else if (expected.match (/^alphanumerics-spaces-([0-9]+)(-e)?$/) && !value.match (/^[a-z 0-9]+$/i))
431 {
432 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Please use alphanumerics & spaces only.", "s2member-front", "s2member")); ?>';
433 }
434 else if (expected.match (/^alphanumerics-punctuation-([0-9]+)(-e)?$/) && !value.match (/^[a-z0-9,\.\/\?\:;"'\{\}\[\]\|\\\+\=_\-\(\)\*&\^%\$#@\!`~]+$/i))
435 {
436 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Please use alphanumerics & punctuation only ( no spaces ).", "s2member-front", "s2member")); ?>';
437 }
438 else if (expected.match (/^alphanumerics-([0-9]+)(-e)?$/) && !value.match (/^[a-z0-9]+$/i))
439 {
440 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Please use alphanumerics only ( no spaces/punctuation ).", "s2member-front", "s2member")); ?>';
441 }
442 else if (expected.match (/^alphabetics-([0-9]+)(-e)?$/) && !value.match (/^[a-z]+$/i))
443 {
444 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Please use alphabetics only ( no digits/spaces/punctuation ).", "s2member-front", "s2member")); ?>';
445 }
446 else if (expected.match (/^numerics-([0-9]+)(-e)?$/) && !value.match (/^[0-9]+$/i))
447 {
448 return label + '\n' + '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Please use numeric digits only.", "s2member-front", "s2member")); ?>';
449 }
450 else if (expected.match (/^(any|alphanumerics-spaces-punctuation|alphanumerics-spaces|alphanumerics-punctuation|alphanumerics|alphabetics|numerics)-([0-9]+)(-e)?$/))
451 {
452 var split = expected.split ('-'), length = Number(split[1]), exactLength = (split.length > 2 && split[2] === 'e') ? true : false;
453 /**/
454 if /* An exact length is required? */ (exactLength && value.length !== length)
455 return label + '\n' + $.sprintf ('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Must be exactly %s %s.", "s2member-front", "s2member")); ?>', length, ((split[0] === 'numerics') ? ((length === 1) ? '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("digit", "s2member-front", "s2member")); ?>' : '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("digits", "s2member-front", "s2member")); ?>') : ((length === 1) ? '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("character", "s2member-front", "s2member")); ?>' : '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("characters", "s2member-front", "s2member")); ?>')));
456 /**/
457 else if /* Otherwise, we interpret as the minimum length. */ (value.length < length)
458 return label + '\n' + $.sprintf ('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Must be at least %s %s.", "s2member-front", "s2member")); ?>', length, ((split[0] === 'numerics') ? ((length === 1) ? '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("digit", "s2member-front", "s2member")); ?>' : '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("digits", "s2member-front", "s2member")); ?>') : ((length === 1) ? '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("character", "s2member-front", "s2member")); ?>' : '<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("characters", "s2member-front", "s2member")); ?>')));
459 }
460 }
461 }
462 /**/
463 return '';
464 };
465 /**/
466 ws_plugin__s2member_animateProcessingConfig = {originalText: '', interval: null, speed: 100}, ws_plugin__s2member_animateProcessing = function($obj, reset)
467 {
468 if /* This function expects a valid jQuery object. */ ($obj instanceof jQuery)
469 {
470 if /* Resets back to originalText value ( also clears interval ). */ (reset)
471 {
472 clearInterval(ws_plugin__s2member_animateProcessingConfig.interval);
473 /**/
474 if (ws_plugin__s2member_animateProcessingConfig.originalText) /* ? */
475 $obj.val (ws_plugin__s2member_animateProcessingConfig.originalText);
476 /**/
477 return; /* No need to proceed any further. */
478 }
479 /**/
480 $obj.first ().each ( /* Interval routine configured here. */function()
481 {
482 var $this = $(this), i = 0, dir = 'r', dots = ['.', '..', '...'];
483 /**/
484 ws_plugin__s2member_animateProcessingConfig.originalText = $this.val ();
485 /**/
486 clearInterval(ws_plugin__s2member_animateProcessingConfig.interval);
487 /**/
488 ws_plugin__s2member_animateProcessingConfig.interval = setInterval(function()
489 {
490 if /* Right... */ (dir === 'r')
491 {
492 if (i + 1 <= dots.length - 1)
493 i = i + 1, dir = 'r';
494 else /* Switch direction. */
495 i = i - 1, dir = 'l';
496 }
497 /**/
498 else if /* Left.. */ (dir === 'l')
499 {
500 if (i - 1 >= 0)
501 i = i - 1, dir = 'l';
502 else /* Switch direction. */
503 i = i + 1, dir = 'r';
504 }
505 /**/
506 for (var _dots = dots[i], l = dots[i].length; l < dots.length; l++)
507 {
508 _dots += /* Prevents jumping. */ ' ';
509 }
510 /**/
511 $this.val ('<?php echo c_ws_plugin__s2member_utils_strings::esc_js_sq (_x ("Processing", "s2member-front", "s2member")); ?>' + _dots);
512 }, ws_plugin__s2member_animateProcessingConfig.speed);
513 });
514 }
515 };
516 });