PluginProbe
WP-Stateless – Google Cloud Storage / 2.2.6
WP-Stateless – Google Cloud Storage v2.2.6
4.4.3 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.3.0 2.3.1 2.3.2 3.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.2.0 3.2.1 3.2.2 All 62 releases
wp-stateless / static / scripts / jquery.validation.js

jquery.validation.js in WP-Stateless – Google Cloud Storage 2.2.6, at static/scripts/jquery.validation.js

73 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 (function( $ ) {
2
3 $.fn.wppStatelessValidate = function(options, response) {
4
5 var input = jQuery(this);
6
7 if (typeof input.data('settings') == 'undefined'){
8 var _settings = $.extend({
9 name: {},
10 id: {},
11 }, options );
12
13 input.data('settings', _settings);
14 }
15
16 var pName = input.val();
17 var settings = _settings || input.data('settings');
18 if(pName){
19 pName = pName.trim().replace(/-$/, '');
20 }
21 response = response || {};
22
23 response.id = '';
24 response.pName = pName;
25 response.success = true;
26 response.existing = false;
27 response.message = '';
28
29 var isExisting = /(.+)\((.+)\)/.exec(pName);
30
31 if(isExisting != null && isExisting.length){
32 response.id = isExisting[2].trim();
33 response.pName = isExisting[1].trim();
34 pName = response.pName;
35 }
36
37 if(input.parent().wpStatelessComboBox({has: response.id || response.pName})){
38 response.existing = true;
39 return response;
40 }
41
42 jQuery.each(settings.name, function(index, item) {
43 if(!item.regex.test(pName)){
44 response.success = false;
45 response.message += item.errorMessage + '<br />';
46 if(typeof item.break != 'undefined' && item.break == true)
47 return false;
48 }
49 });
50
51 if(response.success == false || typeof settings.id == 'undefined' || typeof settings.id.regex == 'undefined'){
52 return response;
53 }
54
55 var _id = settings.id.regex.exec(pName.toLowerCase());
56 if(_id && typeof _id[0] != 'undefined'){
57 response.id = _id[0];
58 }
59
60 jQuery.each(settings.id.replace, function(index, array) {
61 var search = array[1];
62 var replace = array[0];
63 response.id = response.id.replace(search, replace);
64 });
65
66 response.id = response.id.slice(0, 23).replace(/-$/, '') + '-' + Math.floor((Math.random() * 100000) + 100000);
67
68 return response;
69
70 };
71
72 }( jQuery ));
73