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