Version Description
- 2022-03-01 =
- Field
background
andfile_input
: support showing image thumbnail - Add
link
param in helper functions fortaxonomy
,post
,user
fields to showview
,edit
link or plain text (false
) - Add support for float values for range field
- Add
minlength
as a common props for fields - Remove FILTER_SANITIZE_STRING to compatible with PHP 8
- Fix PHP notice when run rwmb_the_value() for taxonomy field with no values
Download this release
Release Info
Developer | rilwis |
Plugin | Meta Box |
Version | 5.6.0 |
Comparing to | |
See all releases |
Code changes from version 5.5.1 to 5.6.0
- css/file-input.css +13 -1
- inc/fields/file-input.php +9 -2
- inc/fields/file.php +6 -6
- inc/fields/input.php +2 -0
- inc/fields/post.php +24 -17
- inc/fields/range.php +3 -3
- inc/fields/taxonomy.php +24 -13
- inc/fields/textarea.php +2 -0
- inc/fields/user.php +22 -5
- inc/loader.php +1 -1
- inc/meta-box.php +1 -1
- js/file-input.js +17 -0
- js/validation.min.js +2 -2
- meta-box.php +1 -1
- readme.txt +10 -2
css/file-input.css
CHANGED
@@ -9,4 +9,16 @@
|
|
9 |
}
|
10 |
.rwmb-file-input-inner .button {
|
11 |
margin: 0;
|
12 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
}
|
10 |
.rwmb-file-input-inner .button {
|
11 |
margin: 0;
|
12 |
+
}
|
13 |
+
.rwmb-file-input-image {
|
14 |
+
width: 150px;
|
15 |
+
height: auto;
|
16 |
+
margin-bottom: 4px;
|
17 |
+
}
|
18 |
+
.rwmb-file-input-image img{
|
19 |
+
max-width: 100%;
|
20 |
+
height: auto;
|
21 |
+
}
|
22 |
+
.rwmb-file-input-hidden{
|
23 |
+
display: none;
|
24 |
+
}
|
inc/fields/file-input.php
CHANGED
@@ -35,16 +35,23 @@ class RWMB_File_Input_Field extends RWMB_Input_Field {
|
|
35 |
*/
|
36 |
public static function html( $meta, $field ) {
|
37 |
$attributes = self::get_attributes( $field, $meta );
|
|
|
|
|
38 |
return sprintf(
|
39 |
-
'<div class="rwmb-file-input-
|
|
|
|
|
|
|
40 |
<input %s>
|
41 |
<a href="#" class="rwmb-file-input-select button">%s</a>
|
42 |
<a href="#" class="rwmb-file-input-remove button %s">%s</a>
|
43 |
</div>',
|
|
|
|
|
44 |
self::render_attributes( $attributes ),
|
45 |
esc_html__( 'Select', 'meta-box' ),
|
46 |
$meta ? '' : 'hidden',
|
47 |
-
esc_html__( 'Remove', 'meta-box' )
|
48 |
);
|
49 |
}
|
50 |
|
35 |
*/
|
36 |
public static function html( $meta, $field ) {
|
37 |
$attributes = self::get_attributes( $field, $meta );
|
38 |
+
$file_ext = strtolower( end( explode( '.', $meta ) ) );
|
39 |
+
$extensions = [ 'jpeg', 'jpg', 'png', 'gif' ];
|
40 |
return sprintf(
|
41 |
+
'<div class="rwmb-file-input-image %s">
|
42 |
+
<img src="%s">
|
43 |
+
</div>
|
44 |
+
<div class="rwmb-file-input-inner">
|
45 |
<input %s>
|
46 |
<a href="#" class="rwmb-file-input-select button">%s</a>
|
47 |
<a href="#" class="rwmb-file-input-remove button %s">%s</a>
|
48 |
</div>',
|
49 |
+
in_array( $file_ext, $extensions ) ? '' : 'rwmb-file-input-hidden',
|
50 |
+
$meta,
|
51 |
self::render_attributes( $attributes ),
|
52 |
esc_html__( 'Select', 'meta-box' ),
|
53 |
$meta ? '' : 'hidden',
|
54 |
+
esc_html__( 'Remove', 'meta-box' ),
|
55 |
);
|
56 |
}
|
57 |
|
inc/fields/file.php
CHANGED
@@ -48,24 +48,24 @@ class RWMB_File_Field extends RWMB_Field {
|
|
48 |
*/
|
49 |
public static function ajax_delete_file() {
|
50 |
$request = rwmb_request();
|
51 |
-
$field_id = $request->filter_post( 'field_id'
|
52 |
-
$type = false !== strpos( $request->filter_post( 'field_name'
|
53 |
check_ajax_referer( "rwmb-delete-file_{$field_id}" );
|
54 |
|
55 |
if ( 'child' === $type ) {
|
56 |
-
$field_group = explode( '[', $request->filter_post( 'field_name'
|
57 |
$field_id = $field_group[0]; //this is top parent field_id
|
58 |
}
|
59 |
// Make sure the file to delete is in the custom field.
|
60 |
$attachment = $request->post( 'attachment_id' );
|
61 |
-
$object_id = $request->filter_post( 'object_id'
|
62 |
-
$object_type = $request->filter_post( 'object_type'
|
63 |
$field = rwmb_get_field_settings( $field_id, array( 'object_type' => $object_type ), $object_id );
|
64 |
$field_value = self::raw_meta( $object_id, $field );
|
65 |
$field_value = $field['clone'] ? call_user_func_array( 'array_merge', $field_value ) : $field_value;
|
66 |
|
67 |
if ( ( 'child' !== $type && ! in_array( $attachment, $field_value ) ) ||
|
68 |
-
( 'child' === $type && ! in_array( $attachment, self::get_sub_values( $field_value, $request->filter_post( 'field_id'
|
69 |
wp_send_json_error( __( 'Error: Invalid file', 'meta-box' ) );
|
70 |
}
|
71 |
// Delete the file.
|
48 |
*/
|
49 |
public static function ajax_delete_file() {
|
50 |
$request = rwmb_request();
|
51 |
+
$field_id = (string) $request->filter_post( 'field_id' );
|
52 |
+
$type = false !== strpos( $request->filter_post( 'field_name' ), '[' ) ? 'child' : 'top';
|
53 |
check_ajax_referer( "rwmb-delete-file_{$field_id}" );
|
54 |
|
55 |
if ( 'child' === $type ) {
|
56 |
+
$field_group = explode( '[', $request->filter_post( 'field_name' ) );
|
57 |
$field_id = $field_group[0]; //this is top parent field_id
|
58 |
}
|
59 |
// Make sure the file to delete is in the custom field.
|
60 |
$attachment = $request->post( 'attachment_id' );
|
61 |
+
$object_id = $request->filter_post( 'object_id' );
|
62 |
+
$object_type = (string) $request->filter_post( 'object_type' );
|
63 |
$field = rwmb_get_field_settings( $field_id, array( 'object_type' => $object_type ), $object_id );
|
64 |
$field_value = self::raw_meta( $object_id, $field );
|
65 |
$field_value = $field['clone'] ? call_user_func_array( 'array_merge', $field_value ) : $field_value;
|
66 |
|
67 |
if ( ( 'child' !== $type && ! in_array( $attachment, $field_value ) ) ||
|
68 |
+
( 'child' === $type && ! in_array( $attachment, self::get_sub_values( $field_value, $request->filter_post( 'field_id' ) ) ) ) ) {
|
69 |
wp_send_json_error( __( 'Error: Invalid file', 'meta-box' ) );
|
70 |
}
|
71 |
// Delete the file.
|
inc/fields/input.php
CHANGED
@@ -63,6 +63,7 @@ abstract class RWMB_Input_Field extends RWMB_Field {
|
|
63 |
'datalist' => false,
|
64 |
'readonly' => false,
|
65 |
'maxlength' => false,
|
|
|
66 |
'pattern' => false,
|
67 |
'prepend' => '',
|
68 |
'append' => '',
|
@@ -96,6 +97,7 @@ abstract class RWMB_Input_Field extends RWMB_Field {
|
|
96 |
'list' => $field['datalist'] ? $field['datalist']['id'] : false,
|
97 |
'readonly' => $field['readonly'],
|
98 |
'maxlength' => $field['maxlength'],
|
|
|
99 |
'pattern' => $field['pattern'],
|
100 |
'value' => $value,
|
101 |
'placeholder' => $field['placeholder'],
|
63 |
'datalist' => false,
|
64 |
'readonly' => false,
|
65 |
'maxlength' => false,
|
66 |
+
'minlength' => false,
|
67 |
'pattern' => false,
|
68 |
'prepend' => '',
|
69 |
'append' => '',
|
97 |
'list' => $field['datalist'] ? $field['datalist']['id'] : false,
|
98 |
'readonly' => $field['readonly'],
|
99 |
'maxlength' => $field['maxlength'],
|
100 |
+
'minlength' => $field['minlength'],
|
101 |
'pattern' => $field['pattern'],
|
102 |
'value' => $value,
|
103 |
'placeholder' => $field['placeholder'],
|
inc/fields/post.php
CHANGED
@@ -32,10 +32,10 @@ class RWMB_Post_Field extends RWMB_Object_Choice_Field {
|
|
32 |
$field['_original_id'] = $field['id'];
|
33 |
|
34 |
// Search.
|
35 |
-
$field['query_args']['s'] = $request->filter_post( 'term'
|
36 |
|
37 |
// Pagination.
|
38 |
-
if ( 'query:append' === $request->filter_post( '_type'
|
39 |
$field['query_args']['paged'] = $request->filter_post( 'page', FILTER_SANITIZE_NUMBER_INT );
|
40 |
}
|
41 |
|
@@ -220,24 +220,31 @@ class RWMB_Post_Field extends RWMB_Object_Choice_Field {
|
|
220 |
/**
|
221 |
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
|
222 |
*
|
223 |
-
* @param array
|
224 |
-
* @param string
|
225 |
-
* @param array
|
226 |
-
* @param int
|
227 |
*
|
228 |
* @return string
|
229 |
*/
|
230 |
public static function format_single_value( $field, $value, $args, $post_id ) {
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
242 |
}
|
243 |
}
|
32 |
$field['_original_id'] = $field['id'];
|
33 |
|
34 |
// Search.
|
35 |
+
$field['query_args']['s'] = $request->filter_post( 'term' );
|
36 |
|
37 |
// Pagination.
|
38 |
+
if ( 'query:append' === $request->filter_post( '_type' ) ) {
|
39 |
$field['query_args']['paged'] = $request->filter_post( 'page', FILTER_SANITIZE_NUMBER_INT );
|
40 |
}
|
41 |
|
220 |
/**
|
221 |
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
|
222 |
*
|
223 |
+
* @param array $field Field parameters.
|
224 |
+
* @param string $value The value.
|
225 |
+
* @param array $args Additional arguments. Rarely used. See specific fields for details.
|
226 |
+
* @param ?int $post_id Post ID. null for current post. Optional.
|
227 |
*
|
228 |
* @return string
|
229 |
*/
|
230 |
public static function format_single_value( $field, $value, $args, $post_id ) {
|
231 |
+
if ( empty( $value ) ) {
|
232 |
+
return '';
|
233 |
+
}
|
234 |
+
|
235 |
+
$link = isset( $args['link'] ) ? $args['link'] : 'view';
|
236 |
+
$text = get_the_title( $value );
|
237 |
+
|
238 |
+
if ( false === $link ) {
|
239 |
+
return $text;
|
240 |
+
}
|
241 |
+
if ( 'view' === $link ) {
|
242 |
+
$url = get_permalink( $value );
|
243 |
+
}
|
244 |
+
if ( 'edit' === $link ) {
|
245 |
+
$url = get_edit_post_link( $value );
|
246 |
+
}
|
247 |
+
|
248 |
+
return sprintf( '<a href="%s">%s</a>', esc_url( $url ), wp_kses_post( $text ) );
|
249 |
}
|
250 |
}
|
inc/fields/range.php
CHANGED
@@ -63,9 +63,9 @@ class RWMB_Range_Field extends RWMB_Number_Field {
|
|
63 |
* @return int
|
64 |
*/
|
65 |
public static function value( $new, $old, $post_id, $field ) {
|
66 |
-
$new =
|
67 |
-
$min =
|
68 |
-
$max =
|
69 |
|
70 |
if ( $new < $min ) {
|
71 |
return $min;
|
63 |
* @return int
|
64 |
*/
|
65 |
public static function value( $new, $old, $post_id, $field ) {
|
66 |
+
$new = (float) $new;
|
67 |
+
$min = (float) $field['min'];
|
68 |
+
$max = (float) $field['max'];
|
69 |
|
70 |
if ( $new < $min ) {
|
71 |
return $min;
|
inc/fields/taxonomy.php
CHANGED
@@ -32,11 +32,11 @@ class RWMB_Taxonomy_Field extends RWMB_Object_Choice_Field {
|
|
32 |
$field['_original_id'] = $field['id'];
|
33 |
|
34 |
// Search.
|
35 |
-
$field['query_args']['name__like'] = $request->filter_post( 'term'
|
36 |
|
37 |
// Pagination.
|
38 |
$limit = isset( $field['query_args']['number'] ) ? (int) $field['query_args']['number'] : 0;
|
39 |
-
if ( 'query:append' === $request->filter_post( '_type'
|
40 |
$page = $request->filter_post( 'page', FILTER_SANITIZE_NUMBER_INT );
|
41 |
$field['query_args']['offset'] = $limit * ( $page - 1 );
|
42 |
}
|
@@ -280,21 +280,32 @@ class RWMB_Taxonomy_Field extends RWMB_Object_Choice_Field {
|
|
280 |
/**
|
281 |
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
|
282 |
*
|
283 |
-
* @param array
|
284 |
-
* @param
|
285 |
-
* @param array
|
286 |
-
* @param int
|
287 |
*
|
288 |
* @return string
|
289 |
*/
|
290 |
public static function format_single_value( $field, $value, $args, $post_id ) {
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
298 |
}
|
299 |
|
300 |
/**
|
32 |
$field['_original_id'] = $field['id'];
|
33 |
|
34 |
// Search.
|
35 |
+
$field['query_args']['name__like'] = $request->filter_post( 'term' );
|
36 |
|
37 |
// Pagination.
|
38 |
$limit = isset( $field['query_args']['number'] ) ? (int) $field['query_args']['number'] : 0;
|
39 |
+
if ( 'query:append' === $request->filter_post( '_type' ) ) {
|
40 |
$page = $request->filter_post( 'page', FILTER_SANITIZE_NUMBER_INT );
|
41 |
$field['query_args']['offset'] = $limit * ( $page - 1 );
|
42 |
}
|
280 |
/**
|
281 |
* Format a single value for the helper functions. Sub-fields should overwrite this method if necessary.
|
282 |
*
|
283 |
+
* @param array $field Field parameters.
|
284 |
+
* @param object|array $value The value.
|
285 |
+
* @param array $args Additional arguments. Rarely used. See specific fields for details.
|
286 |
+
* @param ?int $post_id Post ID. null for current post. Optional.
|
287 |
*
|
288 |
* @return string
|
289 |
*/
|
290 |
public static function format_single_value( $field, $value, $args, $post_id ) {
|
291 |
+
if ( empty( $value ) ) {
|
292 |
+
return '';
|
293 |
+
}
|
294 |
+
|
295 |
+
$link = isset( $args['link'] ) ? $args['link'] : 'view';
|
296 |
+
$text = $value->name;
|
297 |
+
|
298 |
+
if ( false === $link ) {
|
299 |
+
return $text;
|
300 |
+
}
|
301 |
+
if ( 'view' === $link ) {
|
302 |
+
$url = get_term_link( $value );
|
303 |
+
}
|
304 |
+
if ( 'edit' === $link ) {
|
305 |
+
$url = get_edit_term_link( $value );
|
306 |
+
}
|
307 |
+
|
308 |
+
return sprintf( '<a href="%s">%s</a>', esc_url( $url ), esc_html( $text ) );
|
309 |
}
|
310 |
|
311 |
/**
|
inc/fields/textarea.php
CHANGED
@@ -41,6 +41,7 @@ class RWMB_Textarea_Field extends RWMB_Field {
|
|
41 |
'cols' => false,
|
42 |
'rows' => 3,
|
43 |
'maxlength' => false,
|
|
|
44 |
'wrap' => false,
|
45 |
'readonly' => false,
|
46 |
)
|
@@ -66,6 +67,7 @@ class RWMB_Textarea_Field extends RWMB_Field {
|
|
66 |
'cols' => $field['cols'],
|
67 |
'rows' => $field['rows'],
|
68 |
'maxlength' => $field['maxlength'],
|
|
|
69 |
'wrap' => $field['wrap'],
|
70 |
'readonly' => $field['readonly'],
|
71 |
'placeholder' => $field['placeholder'],
|
41 |
'cols' => false,
|
42 |
'rows' => 3,
|
43 |
'maxlength' => false,
|
44 |
+
'minlength' => false,
|
45 |
'wrap' => false,
|
46 |
'readonly' => false,
|
47 |
)
|
67 |
'cols' => $field['cols'],
|
68 |
'rows' => $field['rows'],
|
69 |
'maxlength' => $field['maxlength'],
|
70 |
+
'minlength' => $field['minlength'],
|
71 |
'wrap' => $field['wrap'],
|
72 |
'readonly' => $field['readonly'],
|
73 |
'placeholder' => $field['placeholder'],
|
inc/fields/user.php
CHANGED
@@ -33,14 +33,14 @@ class RWMB_User_Field extends RWMB_Object_Choice_Field {
|
|
33 |
$field['_original_id'] = $field['id'];
|
34 |
|
35 |
// Search.
|
36 |
-
$term = $request->filter_post( 'term'
|
37 |
if ( $term ) {
|
38 |
$field['query_args']['search'] = "*{$term}*";
|
39 |
}
|
40 |
|
41 |
// Pagination.
|
42 |
$limit = isset( $field['query_args']['number'] ) ? (int) $field['query_args']['number'] : 0;
|
43 |
-
if ( $limit && 'query:append' === $request->filter_post( '_type'
|
44 |
$field['query_args']['paged'] = $request->filter_post( 'page', FILTER_SANITIZE_NUMBER_INT );
|
45 |
}
|
46 |
|
@@ -81,7 +81,7 @@ class RWMB_User_Field extends RWMB_Object_Choice_Field {
|
|
81 |
$field = wp_parse_args(
|
82 |
$field,
|
83 |
array(
|
84 |
-
'placeholder' => __( 'Select
|
85 |
'query_args' => array(),
|
86 |
'display_field' => 'display_name',
|
87 |
)
|
@@ -166,8 +166,25 @@ class RWMB_User_Field extends RWMB_Object_Choice_Field {
|
|
166 |
* @return string
|
167 |
*/
|
168 |
public static function format_single_value( $field, $value, $args, $post_id ) {
|
169 |
-
$
|
|
|
|
|
|
|
|
|
170 |
$user = get_userdata( $value );
|
171 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
}
|
173 |
}
|
33 |
$field['_original_id'] = $field['id'];
|
34 |
|
35 |
// Search.
|
36 |
+
$term = (string) $request->filter_post( 'term' );
|
37 |
if ( $term ) {
|
38 |
$field['query_args']['search'] = "*{$term}*";
|
39 |
}
|
40 |
|
41 |
// Pagination.
|
42 |
$limit = isset( $field['query_args']['number'] ) ? (int) $field['query_args']['number'] : 0;
|
43 |
+
if ( $limit && 'query:append' === $request->filter_post( '_type' ) ) {
|
44 |
$field['query_args']['paged'] = $request->filter_post( 'page', FILTER_SANITIZE_NUMBER_INT );
|
45 |
}
|
46 |
|
81 |
$field = wp_parse_args(
|
82 |
$field,
|
83 |
array(
|
84 |
+
'placeholder' => __( 'Select a user', 'meta-box' ),
|
85 |
'query_args' => array(),
|
86 |
'display_field' => 'display_name',
|
87 |
)
|
166 |
* @return string
|
167 |
*/
|
168 |
public static function format_single_value( $field, $value, $args, $post_id ) {
|
169 |
+
if ( empty( $value ) ) {
|
170 |
+
return '';
|
171 |
+
}
|
172 |
+
|
173 |
+
$link = isset( $args['link'] ) ? $args['link'] : 'view';
|
174 |
$user = get_userdata( $value );
|
175 |
+
$display_field = $field['display_field'];
|
176 |
+
$text = $user->$display_field;
|
177 |
+
|
178 |
+
if ( false === $link ) {
|
179 |
+
return $text;
|
180 |
+
}
|
181 |
+
if ( 'view' === $link ) {
|
182 |
+
$url = get_author_posts_url( $value );
|
183 |
+
}
|
184 |
+
if ( 'edit' === $link ) {
|
185 |
+
$url = get_edit_user_link( $value );
|
186 |
+
}
|
187 |
+
|
188 |
+
return sprintf( '<a href="%s">%s</a>', esc_url( $url ), esc_html( $text ) );
|
189 |
}
|
190 |
}
|
inc/loader.php
CHANGED
@@ -18,7 +18,7 @@ class RWMB_Loader {
|
|
18 |
*/
|
19 |
protected function constants() {
|
20 |
// Script version, used to add version for scripts and styles.
|
21 |
-
define( 'RWMB_VER', '5.
|
22 |
|
23 |
list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
|
24 |
|
18 |
*/
|
19 |
protected function constants() {
|
20 |
// Script version, used to add version for scripts and styles.
|
21 |
+
define( 'RWMB_VER', '5.6.0' );
|
22 |
|
23 |
list( $path, $url ) = self::get_path( dirname( dirname( __FILE__ ) ) );
|
24 |
|
inc/meta-box.php
CHANGED
@@ -324,7 +324,7 @@ class RW_Meta_Box {
|
|
324 |
* @return bool
|
325 |
*/
|
326 |
public function validate() {
|
327 |
-
$nonce = rwmb_request()->filter_post( "nonce_{$this->id}"
|
328 |
|
329 |
return ! $this->saved
|
330 |
&& ( ! defined( 'DOING_AUTOSAVE' ) || $this->autosave )
|
324 |
* @return bool
|
325 |
*/
|
326 |
public function validate() {
|
327 |
+
$nonce = rwmb_request()->filter_post( "nonce_{$this->id}" );
|
328 |
|
329 |
return ! $this->saved
|
330 |
&& ( ! defined( 'DOING_AUTOSAVE' ) || $this->autosave )
|
js/file-input.js
CHANGED
@@ -29,9 +29,25 @@
|
|
29 |
} );
|
30 |
}
|
31 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
function clearSelection( e ) {
|
33 |
e.preventDefault();
|
34 |
$( this ).addClass( 'hidden' ).siblings( 'input' ).val( '' ).trigger( 'change' );
|
|
|
35 |
}
|
36 |
|
37 |
function hideRemoveButtonWhenCloning() {
|
@@ -40,6 +56,7 @@
|
|
40 |
|
41 |
rwmb.$document
|
42 |
.on( 'click', '.rwmb-file-input-select', openSelectPopup )
|
|
|
43 |
.on( 'click', '.rwmb-file-input-remove', clearSelection )
|
44 |
.on( 'clone', '.rwmb-file_input', hideRemoveButtonWhenCloning );
|
45 |
} )( jQuery, rwmb );
|
29 |
} );
|
30 |
}
|
31 |
|
32 |
+
function changeValueInput( e ) {
|
33 |
+
e.preventDefault();
|
34 |
+
var $el = $( this ),
|
35 |
+
url = $el.val(),
|
36 |
+
fileType = url.split( '.' ).pop().toLowerCase(),
|
37 |
+
imageTypes = [ 'gif', 'jpeg', 'png', 'jpg' ],
|
38 |
+
validImageTypes = imageTypes.includes( fileType );
|
39 |
+
|
40 |
+
if ( validImageTypes ) {
|
41 |
+
$el.closest( '.rwmb-file-input-inner' ).siblings( '.rwmb-file-input-image' ).removeClass( 'rwmb-file-input-hidden' ).find( 'img' ).attr( 'src', url );
|
42 |
+
} else {
|
43 |
+
$el.closest( '.rwmb-file-input-inner' ).siblings( '.rwmb-file-input-image' ).addClass( 'rwmb-file-input-hidden' );
|
44 |
+
}
|
45 |
+
}
|
46 |
+
|
47 |
function clearSelection( e ) {
|
48 |
e.preventDefault();
|
49 |
$( this ).addClass( 'hidden' ).siblings( 'input' ).val( '' ).trigger( 'change' );
|
50 |
+
$( this ).closest( '.rwmb-file-input-inner' ).siblings( '.rwmb-file-input-image' ).addClass( 'rwmb-file-input-hidden' );
|
51 |
}
|
52 |
|
53 |
function hideRemoveButtonWhenCloning() {
|
56 |
|
57 |
rwmb.$document
|
58 |
.on( 'click', '.rwmb-file-input-select', openSelectPopup )
|
59 |
+
.on( 'input change', '.rwmb-file_input', changeValueInput )
|
60 |
.on( 'click', '.rwmb-file-input-remove', clearSelection )
|
61 |
.on( 'clone', '.rwmb-file_input', hideRemoveButtonWhenCloning );
|
62 |
} )( jQuery, rwmb );
|
js/validation.min.js
CHANGED
@@ -6,7 +6,7 @@
|
|
6 |
* Copyright (c) 2019 Jörn Zaefferer
|
7 |
* Released under the MIT license
|
8 |
*/
|
9 |
-
function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return(_setPrototypeOf=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function _createSuper(t){var e=_isNativeReflectConstruct();return function(){var i,a=_getPrototypeOf(t);if(e){var n=_getPrototypeOf(this).constructor;i=Reflect.construct(a,arguments,n)}else i=a.apply(this,arguments);return _possibleConstructorReturn(this,i)}}function _possibleConstructorReturn(t,e){return!e||"object"!==_typeof(e)&&"function"!=typeof e?_assertThisInitialized(t):e}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(t){return!1}}function _getPrototypeOf(t){return(_getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var i=0;i<e.length;i++){var a=e[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function _createClass(t,e,i){return e&&_defineProperties(t.prototype,e),i&&_defineProperties(t,i),t}!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}((function(t){var e;t.extend(t.fn,{validate:function(e){if(this.length){var i=t.data(this[0],"validator");return i||(this.attr("novalidate","novalidate"),i=new t.validator(e,this[0]),t.data(this[0],"validator",i),i.settings.onsubmit&&(this.on("click.validate",":submit",(function(e){i.submitButton=e.currentTarget,t(this).hasClass("cancel")&&(i.cancelSubmit=!0),void 0!==t(this).attr("formnovalidate")&&(i.cancelSubmit=!0)})),this.on("submit.validate",(function(e){function a(){var a,n;return i.submitButton&&(i.settings.submitHandler||i.formSubmitted)&&(a=t("<input type='hidden'/>").attr("name",i.submitButton.name).val(t(i.submitButton).val()).appendTo(i.currentForm)),!(i.settings.submitHandler&&!i.settings.debug)||(n=i.settings.submitHandler.call(i,i.currentForm,e),a&&a.remove(),void 0!==n&&n)}return i.settings.debug&&e.preventDefault(),i.cancelSubmit?(i.cancelSubmit=!1,a()):i.form()?i.pendingRequest?(i.formSubmitted=!0,!1):a():(i.focusInvalid(),!1)}))),i)}e&&e.debug&&window.console&&console.warn("Nothing selected, can't validate, returning nothing.")},valid:function(){var e,i,a;return t(this[0]).is("form")?e=this.validate().form():(a=[],e=!0,i=t(this[0].form).validate(),this.each((function(){(e=i.element(this)&&e)||(a=a.concat(i.errorList))})),i.errorList=a),e},rules:function(e,i){var a,n,r,s,o,d,l=this[0],u=void 0!==this.attr("contenteditable")&&"false"!==this.attr("contenteditable");if(null!=l&&(!l.form&&u&&(l.form=this.closest("form")[0],l.name=this.attr("name")),null!=l.form)){if(e)switch(n=(a=t.data(l.form,"validator").settings).rules,r=t.validator.staticRules(l),e){case"add":t.extend(r,t.validator.normalizeRule(i)),delete r.messages,n[l.name]=r,i.messages&&(a.messages[l.name]=t.extend(a.messages[l.name],i.messages));break;case"remove":return i?(d={},t.each(i.split(/\s/),(function(t,e){d[e]=r[e],delete r[e]})),d):(delete n[l.name],r)}return(s=t.validator.normalizeRules(t.extend({},t.validator.classRules(l),t.validator.attributeRules(l),t.validator.dataRules(l),t.validator.staticRules(l)),l)).required&&(o=s.required,delete s.required,s=t.extend({required:o},s)),s.remote&&(o=s.remote,delete s.remote,s=t.extend(s,{remote:o})),s}}}),t.extend(t.expr.pseudos||t.expr[":"],{blank:function(e){return!t.trim(""+t(e).val())},filled:function(e){var i=t(e).val();return null!==i&&!!t.trim(""+i)},unchecked:function(e){return!t(e).prop("checked")}}),t.validator=function(e,i){this.settings=t.extend(!0,{},t.validator.defaults,e),this.currentForm=i,this.init()},t.validator.format=function(e,i){return 1===arguments.length?function(){var i=t.makeArray(arguments);return i.unshift(e),t.validator.format.apply(this,i)}:(void 0===i||(arguments.length>2&&i.constructor!==Array&&(i=t.makeArray(arguments).slice(1)),i.constructor!==Array&&(i=[i]),t.each(i,(function(t,i){e=e.replace(new RegExp("\\{"+t+"\\}","g"),(function(){return i}))}))),e)},t.extend(t.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",pendingClass:"pending",validClass:"valid",errorElement:"label",focusCleanup:!1,focusInvalid:!0,errorContainer:t([]),errorLabelContainer:t([]),onsubmit:!0,ignore:":hidden",ignoreTitle:!1,onfocusin:function(t){this.lastActive=t,this.settings.focusCleanup&&(this.settings.unhighlight&&this.settings.unhighlight.call(this,t,this.settings.errorClass,this.settings.validClass),this.hideThese(this.errorsFor(t)))},onfocusout:function(t){this.checkable(t)||!(t.name in this.submitted)&&this.optional(t)||this.element(t)},onkeyup:function(e,i){9===i.which&&""===this.elementValue(e)||-1!==t.inArray(i.keyCode,[16,17,18,20,35,36,37,38,39,40,45,144,225])||(e.name in this.submitted||e.name in this.invalid)&&this.element(e)},onclick:function(t){t.name in this.submitted?this.element(t):t.parentNode.name in this.submitted&&this.element(t.parentNode)},highlight:function(e,i,a){"radio"===e.type?this.findByName(e.name).addClass(i).removeClass(a):t(e).addClass(i).removeClass(a)},unhighlight:function(e,i,a){"radio"===e.type?this.findByName(e.name).removeClass(i).addClass(a):t(e).removeClass(i).addClass(a)}},setDefaults:function(e){t.extend(t.validator.defaults,e)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",equalTo:"Please enter the same value again.",maxlength:t.validator.format("Please enter no more than {0} characters."),minlength:t.validator.format("Please enter at least {0} characters."),rangelength:t.validator.format("Please enter a value between {0} and {1} characters long."),range:t.validator.format("Please enter a value between {0} and {1}."),max:t.validator.format("Please enter a value less than or equal to {0}."),min:t.validator.format("Please enter a value greater than or equal to {0}."),step:t.validator.format("Please enter a multiple of {0}.")},autoCreateRanges:!1,prototype:{init:function(){this.labelContainer=t(this.settings.errorLabelContainer),this.errorContext=this.labelContainer.length&&this.labelContainer||t(this.currentForm),this.containers=t(this.settings.errorContainer).add(this.settings.errorLabelContainer),this.submitted={},this.valueCache={},this.pendingRequest=0,this.pending={},this.invalid={},this.reset();var e,i=this.currentForm,a=this.groups={};function n(e){var a=void 0!==t(this).attr("contenteditable")&&"false"!==t(this).attr("contenteditable");if(!this.form&&a&&(this.form=t(this).closest("form")[0],this.name=t(this).attr("name")),i===this.form){var n=t.data(this.form,"validator"),r="on"+e.type.replace(/^validate/,""),s=n.settings;s[r]&&!t(this).is(s.ignore)&&s[r].call(n,this,e)}}t.each(this.settings.groups,(function(e,i){"string"==typeof i&&(i=i.split(/\s/)),t.each(i,(function(t,i){a[i]=e}))})),e=this.settings.rules,t.each(e,(function(i,a){e[i]=t.validator.normalizeRule(a)})),t(this.currentForm).on("focusin.validate focusout.validate keyup.validate",":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'], [type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], [type='radio'], [type='checkbox'], [contenteditable], [type='button']",n).on("click.validate","select, option, [type='radio'], [type='checkbox']",n),this.settings.invalidHandler&&t(this.currentForm).on("invalid-form.validate",this.settings.invalidHandler)},form:function(){return this.checkForm(),t.extend(this.submitted,this.errorMap),this.invalid=t.extend({},this.errorMap),this.valid()||t(this.currentForm).triggerHandler("invalid-form",[this]),this.showErrors(),this.valid()},checkForm:function(){this.prepareForm();for(var t=0,e=this.currentElements=this.elements();e[t];t++)this.check(e[t]);return this.valid()},element:function(e){var i,a,n=this.clean(e),r=this.validationTargetFor(n),s=this,o=!0;return void 0===r?delete this.invalid[n.name]:(this.prepareElement(r),this.currentElements=t(r),(a=this.groups[r.name])&&t.each(this.groups,(function(t,e){e===a&&t!==r.name&&(n=s.validationTargetFor(s.clean(s.findByName(t))))&&n.name in s.invalid&&(s.currentElements.push(n),o=s.check(n)&&o)})),i=!1!==this.check(r),o=o&&i,this.invalid[r.name]=!i,this.numberOfInvalids()||(this.toHide=this.toHide.add(this.containers)),this.showErrors(),t(e).attr("aria-invalid",!i)),o},showErrors:function(e){if(e){var i=this;t.extend(this.errorMap,e),this.errorList=t.map(this.errorMap,(function(t,e){return{message:t,element:i.findByName(e)[0]}})),this.successList=t.grep(this.successList,(function(t){return!(t.name in e)}))}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){t.fn.resetForm&&t(this.currentForm).resetForm(),this.invalid={},this.submitted={},this.prepareForm(),this.hideErrors();var e=this.elements().removeData("previousValue").removeAttr("aria-invalid");this.resetElements(e)},resetElements:function(t){var e;if(this.settings.unhighlight)for(e=0;t[e];e++)this.settings.unhighlight.call(this,t[e],this.settings.errorClass,""),this.findByName(t[e].name).removeClass(this.settings.validClass);else t.removeClass(this.settings.errorClass).removeClass(this.settings.validClass)},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(t){var e,i=0;for(e in t)void 0!==t[e]&&null!==t[e]&&!1!==t[e]&&i++;return i},hideErrors:function(){this.hideThese(this.toHide)},hideThese:function(t){t.not(this.containers).text(""),this.addWrapper(t).hide()},valid:function(){return 0===this.size()},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{t(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").trigger("focus").trigger("focusin")}catch(t){}},findLastActive:function(){var e=this.lastActive;return e&&1===t.grep(this.errorList,(function(t){return t.element.name===e.name})).length&&e},elements:function(){var e=this,i={};return t(this.currentForm).find("input, select, textarea, [contenteditable]").not(":submit, :reset, :image, :disabled").not(this.settings.ignore).filter((function(){var a=this.name||t(this).attr("name"),n=void 0!==t(this).attr("contenteditable")&&"false"!==t(this).attr("contenteditable");return!a&&e.settings.debug&&window.console&&console.error("%o has no name assigned",this),n&&(this.form=t(this).closest("form")[0],this.name=a),this.form===e.currentForm&&(!(a in i||!e.objectLength(t(this).rules()))&&(i[a]=!0,!0))}))},clean:function(e){return t(e)[0]},errors:function(){var e=this.settings.errorClass.split(" ").join(".");return t(this.settings.errorElement+"."+e,this.errorContext)},resetInternals:function(){this.successList=[],this.errorList=[],this.errorMap={},this.toShow=t([]),this.toHide=t([])},reset:function(){this.resetInternals(),this.currentElements=t([])},prepareForm:function(){this.reset(),this.toHide=this.errors().add(this.containers)},prepareElement:function(t){this.reset(),this.toHide=this.errorsFor(t)},elementValue:function(e){var i,a,n=t(e),r=e.type,s=void 0!==n.attr("contenteditable")&&"false"!==n.attr("contenteditable");return"radio"===r||"checkbox"===r?this.findByName(e.name).filter(":checked").val():"number"===r&&void 0!==e.validity?e.validity.badInput?"NaN":n.val():(i=s?n.text():n.val(),"file"===r?"C:\\fakepath\\"===i.substr(0,12)?i.substr(12):(a=i.lastIndexOf("/"))>=0||(a=i.lastIndexOf("\\"))>=0?i.substr(a+1):i:"string"==typeof i?i.replace(/\r/g,""):i)},check:function(e){e=this.validationTargetFor(this.clean(e));var i,a,n,r,s=t(e).rules(),o=t.map(s,(function(t,e){return e})).length,d=!1,l=this.elementValue(e);for(a in"function"==typeof s.normalizer?r=s.normalizer:"function"==typeof this.settings.normalizer&&(r=this.settings.normalizer),r&&(l=r.call(e,l),delete s.normalizer),s){n={method:a,parameters:s[a]};try{if("dependency-mismatch"===(i=t.validator.methods[a].call(this,l,e,n.parameters))&&1===o){d=!0;continue}if(d=!1,"pending"===i)return void(this.toHide=this.toHide.not(this.errorsFor(e)));if(!i)return this.formatAndAdd(e,n),!1}catch(t){throw this.settings.debug&&window.console&&console.log("Exception occurred when checking element "+e.id+", check the '"+n.method+"' method.",t),t instanceof TypeError&&(t.message+=". Exception occurred when checking element "+e.id+", check the '"+n.method+"' method."),t}}if(!d)return this.objectLength(s)&&this.successList.push(e),!0},customDataMessage:function(e,i){return t(e).data("msg"+i.charAt(0).toUpperCase()+i.substring(1).toLowerCase())||t(e).data("msg")},customMessage:function(t,e){var i=this.settings.messages[t];return i&&(i.constructor===String?i:i[e])},findDefined:function(){for(var t=0;t<arguments.length;t++)if(void 0!==arguments[t])return arguments[t]},defaultMessage:function(e,i){"string"==typeof i&&(i={method:i});var a=this.findDefined(this.customMessage(e.name,i.method),this.customDataMessage(e,i.method),!this.settings.ignoreTitle&&e.title||void 0,t.validator.messages[i.method],"<strong>Warning: No message defined for "+e.name+"</strong>"),n=/\$?\{(\d+)\}/g;return"function"==typeof a?a=a.call(this,i.parameters,e):n.test(a)&&(a=t.validator.format(a.replace(n,"{$1}"),i.parameters)),a},formatAndAdd:function(t,e){var i=this.defaultMessage(t,e);this.errorList.push({message:i,element:t,method:e.method}),this.errorMap[t.name]=i,this.submitted[t.name]=i},addWrapper:function(t){return this.settings.wrapper&&(t=t.add(t.parent(this.settings.wrapper))),t},defaultShowErrors:function(){var t,e,i;for(t=0;this.errorList[t];t++)i=this.errorList[t],this.settings.highlight&&this.settings.highlight.call(this,i.element,this.settings.errorClass,this.settings.validClass),this.showLabel(i.element,i.message);if(this.errorList.length&&(this.toShow=this.toShow.add(this.containers)),this.settings.success)for(t=0;this.successList[t];t++)this.showLabel(this.successList[t]);if(this.settings.unhighlight)for(t=0,e=this.validElements();e[t];t++)this.settings.unhighlight.call(this,e[t],this.settings.errorClass,this.settings.validClass);this.toHide=this.toHide.not(this.toShow),this.hideErrors(),this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return t(this.errorList).map((function(){return this.element}))},showLabel:function(e,i){var a,n,r,s,o=this.errorsFor(e),d=this.idOrName(e),l=t(e).attr("aria-describedby");o.length?(o.removeClass(this.settings.validClass).addClass(this.settings.errorClass),o.html(i)):(a=o=t("<"+this.settings.errorElement+">").attr("id",d+"-error").addClass(this.settings.errorClass).html(i||""),this.settings.wrapper&&(a=o.hide().show().wrap("<"+this.settings.wrapper+"/>").parent()),this.labelContainer.length?this.labelContainer.append(a):this.settings.errorPlacement?this.settings.errorPlacement.call(this,a,t(e)):a.insertAfter(e),o.is("label")?o.attr("for",d):0===o.parents("label[for='"+this.escapeCssMeta(d)+"']").length&&(r=o.attr("id"),l?l.match(new RegExp("\\b"+this.escapeCssMeta(r)+"\\b"))||(l+=" "+r):l=r,t(e).attr("aria-describedby",l),(n=this.groups[e.name])&&(s=this,t.each(s.groups,(function(e,i){i===n&&t("[name='"+s.escapeCssMeta(e)+"']",s.currentForm).attr("aria-describedby",o.attr("id"))}))))),!i&&this.settings.success&&(o.text(""),"string"==typeof this.settings.success?o.addClass(this.settings.success):this.settings.success(o,e)),this.toShow=this.toShow.add(o)},errorsFor:function(e){var i=this.escapeCssMeta(this.idOrName(e)),a=t(e).attr("aria-describedby"),n="label[for='"+i+"'], label[for='"+i+"'] *";return a&&(n=n+", #"+this.escapeCssMeta(a).replace(/\s+/g,", #")),this.errors().filter(n)},escapeCssMeta:function(t){return t.replace(/([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g,"\\$1")},idOrName:function(t){return this.groups[t.name]||(this.checkable(t)?t.name:t.id||t.name)},validationTargetFor:function(e){return this.checkable(e)&&(e=this.findByName(e.name)),t(e).not(this.settings.ignore)[0]},checkable:function(t){return/radio|checkbox/i.test(t.type)},findByName:function(e){return t(this.currentForm).find("[name='"+this.escapeCssMeta(e)+"']")},getLength:function(e,i){switch(i.nodeName.toLowerCase()){case"select":return t("option:selected",i).length;case"input":if(this.checkable(i))return this.findByName(i.name).filter(":checked").length}return e.length},depend:function(t,e){return!this.dependTypes[typeof t]||this.dependTypes[typeof t](t,e)},dependTypes:{boolean:function(t){return t},string:function(e,i){return!!t(e,i.form).length},function:function(t,e){return t(e)}},optional:function(e){var i=this.elementValue(e);return!t.validator.methods.required.call(this,i,e)&&"dependency-mismatch"},startRequest:function(e){this.pending[e.name]||(this.pendingRequest++,t(e).addClass(this.settings.pendingClass),this.pending[e.name]=!0)},stopRequest:function(e,i){this.pendingRequest--,this.pendingRequest<0&&(this.pendingRequest=0),delete this.pending[e.name],t(e).removeClass(this.settings.pendingClass),i&&0===this.pendingRequest&&this.formSubmitted&&this.form()?(t(this.currentForm).submit(),this.submitButton&&t("input:hidden[name='"+this.submitButton.name+"']",this.currentForm).remove(),this.formSubmitted=!1):!i&&0===this.pendingRequest&&this.formSubmitted&&(t(this.currentForm).triggerHandler("invalid-form",[this]),this.formSubmitted=!1)},previousValue:function(e,i){return i="string"==typeof i&&i||"remote",t.data(e,"previousValue")||t.data(e,"previousValue",{old:null,valid:!0,message:this.defaultMessage(e,{method:i})})},destroy:function(){this.resetForm(),t(this.currentForm).off(".validate").removeData("validator").find(".validate-equalTo-blur").off(".validate-equalTo").removeClass("validate-equalTo-blur").find(".validate-lessThan-blur").off(".validate-lessThan").removeClass("validate-lessThan-blur").find(".validate-lessThanEqual-blur").off(".validate-lessThanEqual").removeClass("validate-lessThanEqual-blur").find(".validate-greaterThanEqual-blur").off(".validate-greaterThanEqual").removeClass("validate-greaterThanEqual-blur").find(".validate-greaterThan-blur").off(".validate-greaterThan").removeClass("validate-greaterThan-blur")}},classRuleSettings:{required:{required:!0},email:{email:!0},url:{url:!0},date:{date:!0},dateISO:{dateISO:!0},number:{number:!0},digits:{digits:!0},creditcard:{creditcard:!0}},addClassRules:function(e,i){e.constructor===String?this.classRuleSettings[e]=i:t.extend(this.classRuleSettings,e)},classRules:function(e){var i={},a=t(e).attr("class");return a&&t.each(a.split(" "),(function(){this in t.validator.classRuleSettings&&t.extend(i,t.validator.classRuleSettings[this])})),i},normalizeAttributeRule:function(t,e,i,a){/min|max|step/.test(i)&&(null===e||/number|range|text/.test(e))&&(a=Number(a),isNaN(a)&&(a=void 0)),a||0===a?t[i]=a:e===i&&"range"!==e&&(t[i]=!0)},attributeRules:function(e){var i,a,n={},r=t(e),s=e.getAttribute("type");for(i in t.validator.methods)"required"===i?(""===(a=e.getAttribute(i))&&(a=!0),a=!!a):a=r.attr(i),this.normalizeAttributeRule(n,s,i,a);return n.maxlength&&/-1|2147483647|524288/.test(n.maxlength)&&delete n.maxlength,n},dataRules:function(e){var i,a,n={},r=t(e),s=e.getAttribute("type");for(i in t.validator.methods)""===(a=r.data("rule"+i.charAt(0).toUpperCase()+i.substring(1).toLowerCase()))&&(a=!0),this.normalizeAttributeRule(n,s,i,a);return n},staticRules:function(e){var i={},a=t.data(e.form,"validator");return a.settings.rules&&(i=t.validator.normalizeRule(a.settings.rules[e.name])||{}),i},normalizeRules:function(e,i){return t.each(e,(function(a,n){if(!1!==n){if(n.param||n.depends){var r=!0;switch(typeof n.depends){case"string":r=!!t(n.depends,i.form).length;break;case"function":r=n.depends.call(i,i)}r?e[a]=void 0===n.param||n.param:(t.data(i.form,"validator").resetElements(t(i)),delete e[a])}}else delete e[a]})),t.each(e,(function(a,n){e[a]=t.isFunction(n)&&"normalizer"!==a?n(i):n})),t.each(["minlength","maxlength"],(function(){e[this]&&(e[this]=Number(e[this]))})),t.each(["rangelength","range"],(function(){var i;e[this]&&(t.isArray(e[this])?e[this]=[Number(e[this][0]),Number(e[this][1])]:"string"==typeof e[this]&&(i=e[this].replace(/[\[\]]/g,"").split(/[\s,]+/),e[this]=[Number(i[0]),Number(i[1])]))})),t.validator.autoCreateRanges&&(null!=e.min&&null!=e.max&&(e.range=[e.min,e.max],delete e.min,delete e.max),null!=e.minlength&&null!=e.maxlength&&(e.rangelength=[e.minlength,e.maxlength],delete e.minlength,delete e.maxlength)),e},normalizeRule:function(e){if("string"==typeof e){var i={};t.each(e.split(/\s/),(function(){i[this]=!0})),e=i}return e},addMethod:function(e,i,a){t.validator.methods[e]=i,t.validator.messages[e]=void 0!==a?a:t.validator.messages[e],i.length<3&&t.validator.addClassRules(e,t.validator.normalizeRule(e))},methods:{required:function(e,i,a){if(!this.depend(a,i))return"dependency-mismatch";if("select"===i.nodeName.toLowerCase()){var n=t(i).val();return n&&n.length>0}return this.checkable(i)?this.getLength(e,i)>0:null!=e&&e.length>0},email:function(t,e){return this.optional(e)||/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(t)},url:function(t,e){return this.optional(e)||/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(t)},date:(e=!1,function(t,i){return e||(e=!0,this.settings.debug&&window.console&&console.warn("The `date` method is deprecated and will be removed in version '2.0.0'.\nPlease don't use it, since it relies on the Date constructor, which\nbehaves very differently across browsers and locales. Use `dateISO`\ninstead or one of the locale specific methods in `localizations/`\nand `additional-methods.js`.")),this.optional(i)||!/Invalid|NaN/.test(new Date(t).toString())}),dateISO:function(t,e){return this.optional(e)||/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(t)},number:function(t,e){return this.optional(e)||/^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(t)},digits:function(t,e){return this.optional(e)||/^\d+$/.test(t)},minlength:function(e,i,a){var n=t.isArray(e)?e.length:this.getLength(e,i);return this.optional(i)||n>=a},maxlength:function(e,i,a){var n=t.isArray(e)?e.length:this.getLength(e,i);return this.optional(i)||n<=a},rangelength:function(e,i,a){var n=t.isArray(e)?e.length:this.getLength(e,i);return this.optional(i)||n>=a[0]&&n<=a[1]},min:function(t,e,i){return this.optional(e)||t>=i},max:function(t,e,i){return this.optional(e)||t<=i},range:function(t,e,i){return this.optional(e)||t>=i[0]&&t<=i[1]},step:function(e,i,a){var n,r=t(i).attr("type"),s="Step attribute on input type "+r+" is not supported.",o=new RegExp("\\b"+r+"\\b"),d=function(t){var e=(""+t).match(/(?:\.(\d+))?$/);return e&&e[1]?e[1].length:0},l=function(t){return Math.round(t*Math.pow(10,n))},u=!0;if(r&&!o.test(["text","number","range"].join()))throw new Error(s);return n=d(a),(d(e)>n||l(e)%l(a)!=0)&&(u=!1),this.optional(i)||u},equalTo:function(e,i,a){var n=t(a);return this.settings.onfocusout&&n.not(".validate-equalTo-blur").length&&n.addClass("validate-equalTo-blur").on("blur.validate-equalTo",(function(){t(i).valid()})),e===n.val()},remote:function(e,i,a,n){if(this.optional(i))return"dependency-mismatch";n="string"==typeof n&&n||"remote";var r,s,o,d=this.previousValue(i,n);return this.settings.messages[i.name]||(this.settings.messages[i.name]={}),d.originalMessage=d.originalMessage||this.settings.messages[i.name][n],this.settings.messages[i.name][n]=d.message,a="string"==typeof a&&{url:a}||a,o=t.param(t.extend({data:e},a.data)),d.old===o?d.valid:(d.old=o,r=this,this.startRequest(i),(s={})[i.name]=e,t.ajax(t.extend(!0,{mode:"abort",port:"validate"+i.name,dataType:"json",data:s,context:r.currentForm,success:function(t){var a,s,o,l=!0===t||"true"===t;r.settings.messages[i.name][n]=d.originalMessage,l?(o=r.formSubmitted,r.resetInternals(),r.toHide=r.errorsFor(i),r.formSubmitted=o,r.successList.push(i),r.invalid[i.name]=!1,r.showErrors()):(a={},s=t||r.defaultMessage(i,{method:n,parameters:e}),a[i.name]=d.message=s,r.invalid[i.name]=!0,r.showErrors(a)),d.valid=l,r.stopRequest(i,l)}},a)),"pending")}}});var i,a={};return t.ajaxPrefilter?t.ajaxPrefilter((function(t,e,i){var n=t.port;"abort"===t.mode&&(a[n]&&a[n].abort(),a[n]=i)})):(i=t.ajax,t.ajax=function(e){var n=("mode"in e?e:t.ajaxSettings).mode,r=("port"in e?e:t.ajaxSettings).port;return"abort"===n?(a[r]&&a[r].abort(),a[r]=i.apply(this,arguments),a[r]):i.apply(this,arguments)}),t})),
|
10 |
/*!
|
11 |
* jQuery Validation Plugin v1.19.1
|
12 |
*
|
@@ -15,4 +15,4 @@ function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof S
|
|
15 |
* Copyright (c) 2019 Jörn Zaefferer
|
16 |
* Released under the MIT license
|
17 |
*/
|
18 |
-
function(t){"function"==typeof define&&define.amd?define(["jquery","./jquery.validate"],t):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}((function(t){return function(){function e(t){return t.replace(/<.[^<>]*?>/g," ").replace(/ | /gi," ").replace(/[.(),;:!?%#$'\"_+=\/\-“”’]*/g,"")}t.validator.addMethod("maxWords",(function(t,i,a){return this.optional(i)||e(t).match(/\b\w+\b/g).length<=a}),t.validator.format("Please enter {0} words or less.")),t.validator.addMethod("minWords",(function(t,i,a){return this.optional(i)||e(t).match(/\b\w+\b/g).length>=a}),t.validator.format("Please enter at least {0} words.")),t.validator.addMethod("rangeWords",(function(t,i,a){var n=e(t),r=/\b\w+\b/g;return this.optional(i)||n.match(r).length>=a[0]&&n.match(r).length<=a[1]}),t.validator.format("Please enter between {0} and {1} words."))}(),t.validator.addMethod("abaRoutingNumber",(function(t){var e=0,i=t.split(""),a=i.length;if(9!==a)return!1;for(var n=0;n<a;n+=3)e+=3*parseInt(i[n],10)+7*parseInt(i[n+1],10)+parseInt(i[n+2],10);return 0!==e&&e%10==0}),"Please enter a valid routing number."),t.validator.addMethod("accept",(function(e,i,a){var n,r,s="string"==typeof a?a.replace(/\s/g,""):"image/*",o=this.optional(i);if(o)return o;if("file"===t(i).attr("type")&&(s=s.replace(/[\-\[\]\/\{\}\(\)\+\?\.\\\^\$\|]/g,"\\$&").replace(/,/g,"|").replace(/\/\*/g,"/.*"),i.files&&i.files.length))for(r=new RegExp(".?("+s+")$","i"),n=0;n<i.files.length;n++)if(!i.files[n].type.match(r))return!1;return!0}),t.validator.format("Please enter a value with a valid mimetype.")),t.validator.addMethod("alphanumeric",(function(t,e){return this.optional(e)||/^\w+$/i.test(t)}),"Letters, numbers, and underscores only please"),t.validator.addMethod("bankaccountNL",(function(t,e){if(this.optional(e))return!0;if(!/^[0-9]{9}|([0-9]{2} ){3}[0-9]{3}$/.test(t))return!1;var i,a=t.replace(/ /g,""),n=0,r=a.length;for(i=0;i<r;i++)n+=(r-i)*a.substring(i,i+1);return n%11==0}),"Please specify a valid bank account number"),t.validator.addMethod("bankorgiroaccountNL",(function(e,i){return this.optional(i)||t.validator.methods.bankaccountNL.call(this,e,i)||t.validator.methods.giroaccountNL.call(this,e,i)}),"Please specify a valid bank or giro account number"),t.validator.addMethod("bic",(function(t,e){return this.optional(e)||/^([A-Z]{6}[A-Z2-9][A-NP-Z1-9])(X{3}|[A-WY-Z0-9][A-Z0-9]{2})?$/.test(t.toUpperCase())}),"Please specify a valid BIC code"),t.validator.addMethod("cifES",(function(t,e){"use strict";if(this.optional(e))return!0;var i,a,n,r,s=new RegExp(/^([ABCDEFGHJKLMNPQRSUVW])(\d{7})([0-9A-J])$/gi),o=t.substring(0,1),d=t.substring(1,8),l=t.substring(8,9),u=0,h=0;function c(t){return t%2==0}if(9!==t.length||!s.test(t))return!1;for(i=0;i<d.length;i++)a=parseInt(d[i],10),c(i)?h+=(a*=2)<10?a:a-9:u+=a;return n=(10-(u+h).toString().substr(-1)).toString(),n=parseInt(n,10)>9?"0":n,r="JABCDEFGHI".substr(n,1).toString(),o.match(/[ABEH]/)?l===n:o.match(/[KPQS]/)?l===r:l===n||l===r}),"Please specify a valid CIF number."),t.validator.addMethod("cnhBR",(function(t){if(11!==(t=t.replace(/([~!@#$%^&*()_+=`{}\[\]\-|\\:;'<>,.\/? ])+/g,"")).length)return!1;var e,i,a,n,r,s=0,o=0;if(e=t.charAt(0),new Array(12).join(e)===t)return!1;for(n=0,r=9,0;n<9;++n,--r)s+=+t.charAt(n)*r;for((i=s%11)>=10&&(i=0,o=2),s=0,n=0,r=1,0;n<9;++n,++r)s+=+t.charAt(n)*r;return(a=s%11)>=10?a=0:a-=o,String(i).concat(a)===t.substr(-2)}),"Please specify a valid CNH number"),t.validator.addMethod("cnpjBR",(function(t,e){"use strict";if(this.optional(e))return!0;if(14!==(t=t.replace(/[^\d]+/g,"")).length)return!1;if("00000000000000"===t||"11111111111111"===t||"22222222222222"===t||"33333333333333"===t||"44444444444444"===t||"55555555555555"===t||"66666666666666"===t||"77777777777777"===t||"88888888888888"===t||"99999999999999"===t)return!1;for(var i=t.length-2,a=t.substring(0,i),n=t.substring(i),r=0,s=i-7,o=i;o>=1;o--)r+=a.charAt(i-o)*s--,s<2&&(s=9);var d=r%11<2?0:11-r%11;if(d!==parseInt(n.charAt(0),10))return!1;i+=1,a=t.substring(0,i),r=0,s=i-7;for(var l=i;l>=1;l--)r+=a.charAt(i-l)*s--,s<2&&(s=9);return(d=r%11<2?0:11-r%11)===parseInt(n.charAt(1),10)}),"Please specify a CNPJ value number"),t.validator.addMethod("cpfBR",(function(t,e){"use strict";if(this.optional(e))return!0;if(11!==(t=t.replace(/([~!@#$%^&*()_+=`{}\[\]\-|\\:;'<>,.\/? ])+/g,"")).length)return!1;var i,a,n,r,s=0;if(i=parseInt(t.substring(9,10),10),a=parseInt(t.substring(10,11),10),n=function(t,e){var i=10*t%11;return 10!==i&&11!==i||(i=0),i===e},""===t||"00000000000"===t||"11111111111"===t||"22222222222"===t||"33333333333"===t||"44444444444"===t||"55555555555"===t||"66666666666"===t||"77777777777"===t||"88888888888"===t||"99999999999"===t)return!1;for(r=1;r<=9;r++)s+=parseInt(t.substring(r-1,r),10)*(11-r);if(n(s,i)){for(s=0,r=1;r<=10;r++)s+=parseInt(t.substring(r-1,r),10)*(12-r);return n(s,a)}return!1}),"Please specify a valid CPF number"),t.validator.addMethod("creditcard",(function(t,e){if(this.optional(e))return"dependency-mismatch";if(/[^0-9 \-]+/.test(t))return!1;var i,a,n=0,r=0,s=!1;if((t=t.replace(/\D/g,"")).length<13||t.length>19)return!1;for(i=t.length-1;i>=0;i--)a=t.charAt(i),r=parseInt(a,10),s&&(r*=2)>9&&(r-=9),n+=r,s=!s;return n%10==0}),"Please enter a valid credit card number."),t.validator.addMethod("creditcardtypes",(function(t,e,i){if(/[^0-9\-]+/.test(t))return!1;t=t.replace(/\D/g,"");var a=0;return i.mastercard&&(a|=1),i.visa&&(a|=2),i.amex&&(a|=4),i.dinersclub&&(a|=8),i.enroute&&(a|=16),i.discover&&(a|=32),i.jcb&&(a|=64),i.unknown&&(a|=128),i.all&&(a=255),1&a&&(/^(5[12345])/.test(t)||/^(2[234567])/.test(t))||2&a&&/^(4)/.test(t)?16===t.length:4&a&&/^(3[47])/.test(t)?15===t.length:8&a&&/^(3(0[012345]|[68]))/.test(t)?14===t.length:16&a&&/^(2(014|149))/.test(t)?15===t.length:32&a&&/^(6011)/.test(t)||64&a&&/^(3)/.test(t)?16===t.length:64&a&&/^(2131|1800)/.test(t)?15===t.length:!!(128&a)}),"Please enter a valid credit card number."),t.validator.addMethod("currency",(function(t,e,i){var a,n="string"==typeof i,r=n?i:i[0],s=!!n||i[1];return r=r.replace(/,/g,""),a="^["+(r=s?r+"]":r+"]?")+"([1-9]{1}[0-9]{0,2}(\\,[0-9]{3})*(\\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\\.[0-9]{0,2})?|0(\\.[0-9]{0,2})?|(\\.[0-9]{1,2})?)$",a=new RegExp(a),this.optional(e)||a.test(t)}),"Please specify a valid currency"),t.validator.addMethod("dateFA",(function(t,e){return this.optional(e)||/^[1-4]\d{3}\/((0?[1-6]\/((3[0-1])|([1-2][0-9])|(0?[1-9])))|((1[0-2]|(0?[7-9]))\/(30|([1-2][0-9])|(0?[1-9]))))$/.test(t)}),t.validator.messages.date),t.validator.addMethod("dateITA",(function(t,e){var i,a,n,r,s,o=!1;return/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(t)?(i=t.split("/"),a=parseInt(i[0],10),n=parseInt(i[1],10),r=parseInt(i[2],10),o=(s=new Date(Date.UTC(r,n-1,a,12,0,0,0))).getUTCFullYear()===r&&s.getUTCMonth()===n-1&&s.getUTCDate()===a):o=!1,this.optional(e)||o}),t.validator.messages.date),t.validator.addMethod("dateNL",(function(t,e){return this.optional(e)||/^(0?[1-9]|[12]\d|3[01])[\.\/\-](0?[1-9]|1[012])[\.\/\-]([12]\d)?(\d\d)$/.test(t)}),t.validator.messages.date),t.validator.addMethod("extension",(function(t,e,i){return i="string"==typeof i?i.replace(/,/g,"|"):"png|jpe?g|gif",this.optional(e)||t.match(new RegExp("\\.("+i+")$","i"))}),t.validator.format("Please enter a value with a valid extension.")),t.validator.addMethod("giroaccountNL",(function(t,e){return this.optional(e)||/^[0-9]{1,7}$/.test(t)}),"Please specify a valid giro account number"),t.validator.addMethod("greaterThan",(function(e,i,a){var n=t(a);return this.settings.onfocusout&&n.not(".validate-greaterThan-blur").length&&n.addClass("validate-greaterThan-blur").on("blur.validate-greaterThan",(function(){t(i).valid()})),e>n.val()}),"Please enter a greater value."),t.validator.addMethod("greaterThanEqual",(function(e,i,a){var n=t(a);return this.settings.onfocusout&&n.not(".validate-greaterThanEqual-blur").length&&n.addClass("validate-greaterThanEqual-blur").on("blur.validate-greaterThanEqual",(function(){t(i).valid()})),e>=n.val()}),"Please enter a greater value."),t.validator.addMethod("iban",(function(t,e){if(this.optional(e))return!0;var i,a,n,r,s,o=t.replace(/ /g,"").toUpperCase(),d="",l=!0,u="";if(o.length<5)return!1;if(void 0!==(n={AL:"\\d{8}[\\dA-Z]{16}",AD:"\\d{8}[\\dA-Z]{12}",AT:"\\d{16}",AZ:"[\\dA-Z]{4}\\d{20}",BE:"\\d{12}",BH:"[A-Z]{4}[\\dA-Z]{14}",BA:"\\d{16}",BR:"\\d{23}[A-Z][\\dA-Z]",BG:"[A-Z]{4}\\d{6}[\\dA-Z]{8}",CR:"\\d{17}",HR:"\\d{17}",CY:"\\d{8}[\\dA-Z]{16}",CZ:"\\d{20}",DK:"\\d{14}",DO:"[A-Z]{4}\\d{20}",EE:"\\d{16}",FO:"\\d{14}",FI:"\\d{14}",FR:"\\d{10}[\\dA-Z]{11}\\d{2}",GE:"[\\dA-Z]{2}\\d{16}",DE:"\\d{18}",GI:"[A-Z]{4}[\\dA-Z]{15}",GR:"\\d{7}[\\dA-Z]{16}",GL:"\\d{14}",GT:"[\\dA-Z]{4}[\\dA-Z]{20}",HU:"\\d{24}",IS:"\\d{22}",IE:"[\\dA-Z]{4}\\d{14}",IL:"\\d{19}",IT:"[A-Z]\\d{10}[\\dA-Z]{12}",KZ:"\\d{3}[\\dA-Z]{13}",KW:"[A-Z]{4}[\\dA-Z]{22}",LV:"[A-Z]{4}[\\dA-Z]{13}",LB:"\\d{4}[\\dA-Z]{20}",LI:"\\d{5}[\\dA-Z]{12}",LT:"\\d{16}",LU:"\\d{3}[\\dA-Z]{13}",MK:"\\d{3}[\\dA-Z]{10}\\d{2}",MT:"[A-Z]{4}\\d{5}[\\dA-Z]{18}",MR:"\\d{23}",MU:"[A-Z]{4}\\d{19}[A-Z]{3}",MC:"\\d{10}[\\dA-Z]{11}\\d{2}",MD:"[\\dA-Z]{2}\\d{18}",ME:"\\d{18}",NL:"[A-Z]{4}\\d{10}",NO:"\\d{11}",PK:"[\\dA-Z]{4}\\d{16}",PS:"[\\dA-Z]{4}\\d{21}",PL:"\\d{24}",PT:"\\d{21}",RO:"[A-Z]{4}[\\dA-Z]{16}",SM:"[A-Z]\\d{10}[\\dA-Z]{12}",SA:"\\d{2}[\\dA-Z]{18}",RS:"\\d{18}",SK:"\\d{20}",SI:"\\d{15}",ES:"\\d{20}",SE:"\\d{20}",CH:"\\d{5}[\\dA-Z]{12}",TN:"\\d{20}",TR:"\\d{5}[\\dA-Z]{17}",AE:"\\d{3}\\d{16}",GB:"[A-Z]{4}\\d{14}",VG:"[\\dA-Z]{4}\\d{16}"}[o.substring(0,2)])&&!new RegExp("^[A-Z]{2}\\d{2}"+n+"$","").test(o))return!1;for(i=o.substring(4,o.length)+o.substring(0,4),r=0;r<i.length;r++)"0"!==(a=i.charAt(r))&&(l=!1),l||(d+="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(a));for(s=0;s<d.length;s++)u=(""+u+d.charAt(s))%97;return 1===u}),"Please specify a valid IBAN"),t.validator.addMethod("integer",(function(t,e){return this.optional(e)||/^-?\d+$/.test(t)}),"A positive or negative non-decimal number please"),t.validator.addMethod("ipv4",(function(t,e){return this.optional(e)||/^(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)$/i.test(t)}),"Please enter a valid IP v4 address."),t.validator.addMethod("ipv6",(function(t,e){return this.optional(e)||/^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/i.test(t)}),"Please enter a valid IP v6 address."),t.validator.addMethod("lessThan",(function(e,i,a){var n=t(a);return this.settings.onfocusout&&n.not(".validate-lessThan-blur").length&&n.addClass("validate-lessThan-blur").on("blur.validate-lessThan",(function(){t(i).valid()})),e<n.val()}),"Please enter a lesser value."),t.validator.addMethod("lessThanEqual",(function(e,i,a){var n=t(a);return this.settings.onfocusout&&n.not(".validate-lessThanEqual-blur").length&&n.addClass("validate-lessThanEqual-blur").on("blur.validate-lessThanEqual",(function(){t(i).valid()})),e<=n.val()}),"Please enter a lesser value."),t.validator.addMethod("lettersonly",(function(t,e){return this.optional(e)||/^[a-z]+$/i.test(t)}),"Letters only please"),t.validator.addMethod("letterswithbasicpunc",(function(t,e){return this.optional(e)||/^[a-z\-.,()'"\s]+$/i.test(t)}),"Letters or punctuation only please"),t.validator.addMethod("maxfiles",(function(e,i,a){return!!this.optional(i)||!("file"===t(i).attr("type")&&i.files&&i.files.length>a)}),t.validator.format("Please select no more than {0} files.")),t.validator.addMethod("maxsize",(function(e,i,a){if(this.optional(i))return!0;if("file"===t(i).attr("type")&&i.files&&i.files.length)for(var n=0;n<i.files.length;n++)if(i.files[n].size>a)return!1;return!0}),t.validator.format("File size must not exceed {0} bytes each.")),t.validator.addMethod("maxsizetotal",(function(e,i,a){if(this.optional(i))return!0;if("file"===t(i).attr("type")&&i.files&&i.files.length)for(var n=0,r=0;r<i.files.length;r++)if((n+=i.files[r].size)>a)return!1;return!0}),t.validator.format("Total size of all files must not exceed {0} bytes.")),t.validator.addMethod("mobileNL",(function(t,e){return this.optional(e)||/^((\+|00(\s|\s?\-\s?)?)31(\s|\s?\-\s?)?(\(0\)[\-\s]?)?|0)6((\s|\s?\-\s?)?[0-9]){8}$/.test(t)}),"Please specify a valid mobile number"),t.validator.addMethod("mobileRU",(function(t,e){var i=t.replace(/\(|\)|\s+|-/g,"");return this.optional(e)||i.length>9&&/^((\+7|7|8)+([0-9]){10})$/.test(i)}),"Please specify a valid mobile number"),t.validator.addMethod("mobileUK",(function(t,e){return t=t.replace(/\(|\)|\s+|-/g,""),this.optional(e)||t.length>9&&t.match(/^(?:(?:(?:00\s?|\+)44\s?|0)7(?:[1345789]\d{2}|624)\s?\d{3}\s?\d{3})$/)}),"Please specify a valid mobile number"),t.validator.addMethod("netmask",(function(t,e){return this.optional(e)||/^(254|252|248|240|224|192|128)\.0\.0\.0|255\.(254|252|248|240|224|192|128|0)\.0\.0|255\.255\.(254|252|248|240|224|192|128|0)\.0|255\.255\.255\.(254|252|248|240|224|192|128|0)/i.test(t)}),"Please enter a valid netmask."),t.validator.addMethod("nieES",(function(t,e){"use strict";if(this.optional(e))return!0;var i,a=new RegExp(/^[MXYZ]{1}[0-9]{7,8}[TRWAGMYFPDXBNJZSQVHLCKET]{1}$/gi),n=t.substr(t.length-1).toUpperCase();return!((t=t.toString().toUpperCase()).length>10||t.length<9||!a.test(t))&&(i=9===(t=t.replace(/^[X]/,"0").replace(/^[Y]/,"1").replace(/^[Z]/,"2")).length?t.substr(0,8):t.substr(0,9),"TRWAGMYFPDXBNJZSQVHLCKET".charAt(parseInt(i,10)%23)===n)}),"Please specify a valid NIE number."),t.validator.addMethod("nifES",(function(t,e){"use strict";return!!this.optional(e)||!!(t=t.toUpperCase()).match("((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)")&&(/^[0-9]{8}[A-Z]{1}$/.test(t)?"TRWAGMYFPDXBNJZSQVHLCKE".charAt(t.substring(8,0)%23)===t.charAt(8):!!/^[KLM]{1}/.test(t)&&t[8]==="TRWAGMYFPDXBNJZSQVHLCKE".charAt(t.substring(8,1)%23))}),"Please specify a valid NIF number."),t.validator.addMethod("nipPL",(function(t){"use strict";if(10!==(t=t.replace(/[^0-9]/g,"")).length)return!1;for(var e=[6,5,7,2,3,4,5,6,7],i=0,a=0;a<9;a++)i+=e[a]*t[a];var n=i%11;return(10===n?0:n)===parseInt(t[9],10)}),"Please specify a valid NIP number."),t.validator.addMethod("nisBR",(function(t){var e,i,a,n,r,s=0;if(11!==(t=t.replace(/([~!@#$%^&*()_+=`{}\[\]\-|\\:;'<>,.\/? ])+/g,"")).length)return!1;for(i=parseInt(t.substring(10,11),10),e=parseInt(t.substring(0,10),10),n=2;n<12;n++)r=n,10===n&&(r=2),11===n&&(r=3),s+=e%10*r,e=parseInt(e/10,10);return i===(a=(a=s%11)>1?11-a:0)}),"Please specify a valid NIS/PIS number"),t.validator.addMethod("notEqualTo",(function(e,i,a){return this.optional(i)||!t.validator.methods.equalTo.call(this,e,i,a)}),"Please enter a different value, values must not be the same."),t.validator.addMethod("nowhitespace",(function(t,e){return this.optional(e)||/^\S+$/i.test(t)}),"No white space please"),t.validator.addMethod("pattern",(function(t,e,i){return!!this.optional(e)||("string"==typeof i&&(i=new RegExp("^(?:"+i+")$")),i.test(t))}),"Invalid format."),t.validator.addMethod("phoneNL",(function(t,e){return this.optional(e)||/^((\+|00(\s|\s?\-\s?)?)31(\s|\s?\-\s?)?(\(0\)[\-\s]?)?|0)[1-9]((\s|\s?\-\s?)?[0-9]){8}$/.test(t)}),"Please specify a valid phone number."),t.validator.addMethod("phonePL",(function(t,e){t=t.replace(/\s+/g,"");return this.optional(e)||/^(?:(?:(?:\+|00)?48)|(?:\(\+?48\)))?(?:1[2-8]|2[2-69]|3[2-49]|4[1-68]|5[0-9]|6[0-35-9]|[7-8][1-9]|9[145])\d{7}$/.test(t)}),"Please specify a valid phone number"),t.validator.addMethod("phonesUK",(function(t,e){return t=t.replace(/\(|\)|\s+|-/g,""),this.optional(e)||t.length>9&&t.match(/^(?:(?:(?:00\s?|\+)44\s?|0)(?:1\d{8,9}|[23]\d{9}|7(?:[1345789]\d{8}|624\d{6})))$/)}),"Please specify a valid uk phone number"),t.validator.addMethod("phoneUK",(function(t,e){return t=t.replace(/\(|\)|\s+|-/g,""),this.optional(e)||t.length>9&&t.match(/^(?:(?:(?:00\s?|\+)44\s?)|(?:\(?0))(?:\d{2}\)?\s?\d{4}\s?\d{4}|\d{3}\)?\s?\d{3}\s?\d{3,4}|\d{4}\)?\s?(?:\d{5}|\d{3}\s?\d{3})|\d{5}\)?\s?\d{4,5})$/)}),"Please specify a valid phone number"),t.validator.addMethod("phoneUS",(function(t,e){return t=t.replace(/\s+/g,""),this.optional(e)||t.length>9&&t.match(/^(\+?1-?)?(\([2-9]([02-9]\d|1[02-9])\)|[2-9]([02-9]\d|1[02-9]))-?[2-9]\d{2}-?\d{4}$/)}),"Please specify a valid phone number"),t.validator.addMethod("postalcodeBR",(function(t,e){return this.optional(e)||/^\d{2}.\d{3}-\d{3}?$|^\d{5}-?\d{3}?$/.test(t)}),"Informe um CEP válido."),t.validator.addMethod("postalCodeCA",(function(t,e){return this.optional(e)||/^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ] *\d[ABCEGHJKLMNPRSTVWXYZ]\d$/i.test(t)}),"Please specify a valid postal code"),t.validator.addMethod("postalcodeIT",(function(t,e){return this.optional(e)||/^\d{5}$/.test(t)}),"Please specify a valid postal code"),t.validator.addMethod("postalcodeNL",(function(t,e){return this.optional(e)||/^[1-9][0-9]{3}\s?[a-zA-Z]{2}$/.test(t)}),"Please specify a valid postal code"),t.validator.addMethod("postcodeUK",(function(t,e){return this.optional(e)||/^((([A-PR-UWYZ][0-9])|([A-PR-UWYZ][0-9][0-9])|([A-PR-UWYZ][A-HK-Y][0-9])|([A-PR-UWYZ][A-HK-Y][0-9][0-9])|([A-PR-UWYZ][0-9][A-HJKSTUW])|([A-PR-UWYZ][A-HK-Y][0-9][ABEHMNPRVWXY]))\s?([0-9][ABD-HJLNP-UW-Z]{2})|(GIR)\s?(0AA))$/i.test(t)}),"Please specify a valid UK postcode"),t.validator.addMethod("require_from_group",(function(e,i,a){var n=t(a[1],i.form),r=n.eq(0),s=r.data("valid_req_grp")?r.data("valid_req_grp"):t.extend({},this),o=n.filter((function(){return s.elementValue(this)})).length>=a[0];return r.data("valid_req_grp",s),t(i).data("being_validated")||(n.data("being_validated",!0),n.each((function(){s.element(this)})),n.data("being_validated",!1)),o}),t.validator.format("Please fill at least {0} of these fields.")),t.validator.addMethod("skip_or_fill_minimum",(function(e,i,a){var n=t(a[1],i.form),r=n.eq(0),s=r.data("valid_skip")?r.data("valid_skip"):t.extend({},this),o=n.filter((function(){return s.elementValue(this)})).length,d=0===o||o>=a[0];return r.data("valid_skip",s),t(i).data("being_validated")||(n.data("being_validated",!0),n.each((function(){s.element(this)})),n.data("being_validated",!1)),d}),t.validator.format("Please either skip these fields or fill at least {0} of them.")),t.validator.addMethod("stateUS",(function(t,e,i){var a,n=void 0===i,r=!n&&void 0!==i.caseSensitive&&i.caseSensitive,s=!n&&void 0!==i.includeTerritories&&i.includeTerritories,o=!n&&void 0!==i.includeMilitary&&i.includeMilitary;return a=s||o?s&&o?"^(A[AEKLPRSZ]|C[AOT]|D[CE]|FL|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEINOPST]|N[CDEHJMVY]|O[HKR]|P[AR]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])$":s?"^(A[KLRSZ]|C[AOT]|D[CE]|FL|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEINOPST]|N[CDEHJMVY]|O[HKR]|P[AR]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])$":"^(A[AEKLPRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])$":"^(A[KLRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])$",a=r?new RegExp(a):new RegExp(a,"i"),this.optional(e)||a.test(t)}),"Please specify a valid state"),t.validator.addMethod("strippedminlength",(function(e,i,a){return t(e).text().length>=a}),t.validator.format("Please enter at least {0} characters")),t.validator.addMethod("time",(function(t,e){return this.optional(e)||/^([01]\d|2[0-3]|[0-9])(:[0-5]\d){1,2}$/.test(t)}),"Please enter a valid time, between 00:00 and 23:59"),t.validator.addMethod("time12h",(function(t,e){return this.optional(e)||/^((0?[1-9]|1[012])(:[0-5]\d){1,2}(\ ?[AP]M))$/i.test(t)}),"Please enter a valid time in 12-hour am/pm format"),t.validator.addMethod("url2",(function(t,e){return this.optional(e)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)*(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(t)}),t.validator.messages.url),t.validator.addMethod("vinUS",(function(t){if(17!==t.length)return!1;var e,i,a,n,r,s,o=["A","B","C","D","E","F","G","H","J","K","L","M","N","P","R","S","T","U","V","W","X","Y","Z"],d=[1,2,3,4,5,6,7,8,1,2,3,4,5,7,9,2,3,4,5,6,7,8,9],l=[8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2],u=0;for(e=0;e<17;e++){if(n=l[e],a=t.slice(e,e+1),8===e&&(s=a),isNaN(a)){for(i=0;i<o.length;i++)if(a.toUpperCase()===o[i]){a=d[i],a*=n,isNaN(s)&&8===i&&(s=o[i]);break}}else a*=n;u+=a}return 10===(r=u%11)&&(r="X"),r===s}),"The specified vehicle identification number (VIN) is invalid."),t.validator.addMethod("zipcodeUS",(function(t,e){return this.optional(e)||/^\d{5}(-\d{4})?$/.test(t)}),"The specified US ZIP Code is invalid"),t.validator.addMethod("ziprange",(function(t,e){return this.optional(e)||/^90[2-5]\d\{2\}-\d{4}$/.test(t)}),"Your ZIP-code must be in the range 902xx-xxxx to 905xx-xxxx"),t})),function(t,e,i){"use strict";var a=function(){function e(i){_classCallCheck(this,e),this.$form=t(i),this.validationElements=this.$form.find(".rwmb-validation"),this.showAsterisks(),this.getSettings()}return _createClass(e,[{key:"init",value:function(){this.$form.on("submit",(function(){"undefined"!=typeof tinyMCE&&tinyMCE.triggerSave()})).validate(this.settings)}},{key:"showAsterisks",value:function(){this.validationElements.each((function(){var e=t(this).data("validation");t.each(e.rules,(function(e,i){if(i.required){var a=t('[name="'+e+'"]');a.length&&a.closest(".rwmb-input").siblings(".rwmb-label").find("label").append('<span class="rwmb-required">*</span>')}}))}))}},{key:"getSettings",value:function(){this.settings={ignore:':not(.rwmb-media,.rwmb-image_select,.rwmb-wysiwyg,.rwmb-color,.rwmb-map,.rwmb-osm,.rwmb-switch,[class|="rwmb"]:visible)',errorPlacement:function(t,e){t.appendTo(e.closest(".rwmb-input"))},errorClass:"rwmb-error",errorElement:"p",invalidHandler:this.invalidHandler.bind(this)};var e=this;this.validationElements.each((function(){t.extend(!0,e.settings,t(this).data("validation"))}))}},{key:"invalidHandler",value:function(){this.showMessage();var t=this;setTimeout((function(){t.$form.trigger("after_validate")}),200)}},{key:"showMessage",value:function(){t("#publish").removeClass("button-primary-disabled"),t("#ajax-loading").attr("style",""),t("#rwmb-validation-message").remove(),this.$form.before('<div id="rwmb-validation-message" class="notice notice-error is-dismissible"><p>'+i.message+"</p></div>")}}]),e}(),n=function(t){_inherits(a,t);var e=_createSuper(a);function a(){return _classCallCheck(this,a),e.apply(this,arguments)}return _createClass(a,[{key:"init",value:function(){var t=this,e=wp.data.dispatch("core/editor"),i=e.savePost;e.savePost=function(e){"object"===_typeof(e)&&e.isPreview?i(e):(t.$form.validate(t.settings),t.$form.valid()&&i(e))}}},{key:"showMessage",value:function(){wp.data.dispatch("core/notices").createErrorNotice(i.message,{id:"meta-box-validation",isDismissible:!0})}}]),a}(a);t((function(){if(e.isGutenberg){var i=new n(".metabox-location-advanced"),r=new n(".metabox-location-normal");return new n(".metabox-location-side").init(),r.init(),void i.init()}t("#post, #edittag, #your-profile, .rwmb-form").each((function(){new a(this).init()}))}))}(jQuery,rwmb,rwmbValidation);
|
6 |
* Copyright (c) 2019 Jörn Zaefferer
|
7 |
* Released under the MIT license
|
8 |
*/
|
9 |
+
function _typeof(t){return _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_typeof(t)}function _inherits(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");Object.defineProperty(t,"prototype",{value:Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),writable:!1}),e&&_setPrototypeOf(t,e)}function _setPrototypeOf(t,e){return _setPrototypeOf=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t},_setPrototypeOf(t,e)}function _createSuper(t){var e=_isNativeReflectConstruct();return function(){var i,a=_getPrototypeOf(t);if(e){var r=_getPrototypeOf(this).constructor;i=Reflect.construct(a,arguments,r)}else i=a.apply(this,arguments);return _possibleConstructorReturn(this,i)}}function _possibleConstructorReturn(t,e){if(e&&("object"===_typeof(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return _assertThisInitialized(t)}function _assertThisInitialized(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function _isNativeReflectConstruct(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function _getPrototypeOf(t){return _getPrototypeOf=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)},_getPrototypeOf(t)}function _classCallCheck(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function _defineProperties(t,e){for(var i=0;i<e.length;i++){var a=e[i];a.enumerable=a.enumerable||!1,a.configurable=!0,"value"in a&&(a.writable=!0),Object.defineProperty(t,a.key,a)}}function _createClass(t,e,i){return e&&_defineProperties(t.prototype,e),i&&_defineProperties(t,i),Object.defineProperty(t,"prototype",{writable:!1}),t}!function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}((function(t){var e;t.extend(t.fn,{validate:function(e){if(this.length){var i=t.data(this[0],"validator");return i||(this.attr("novalidate","novalidate"),i=new t.validator(e,this[0]),t.data(this[0],"validator",i),i.settings.onsubmit&&(this.on("click.validate",":submit",(function(e){i.submitButton=e.currentTarget,t(this).hasClass("cancel")&&(i.cancelSubmit=!0),void 0!==t(this).attr("formnovalidate")&&(i.cancelSubmit=!0)})),this.on("submit.validate",(function(e){function a(){var a,r;return i.submitButton&&(i.settings.submitHandler||i.formSubmitted)&&(a=t("<input type='hidden'/>").attr("name",i.submitButton.name).val(t(i.submitButton).val()).appendTo(i.currentForm)),!(i.settings.submitHandler&&!i.settings.debug)||(r=i.settings.submitHandler.call(i,i.currentForm,e),a&&a.remove(),void 0!==r&&r)}return i.settings.debug&&e.preventDefault(),i.cancelSubmit?(i.cancelSubmit=!1,a()):i.form()?i.pendingRequest?(i.formSubmitted=!0,!1):a():(i.focusInvalid(),!1)}))),i)}e&&e.debug&&window.console&&console.warn("Nothing selected, can't validate, returning nothing.")},valid:function(){var e,i,a;return t(this[0]).is("form")?e=this.validate().form():(a=[],e=!0,i=t(this[0].form).validate(),this.each((function(){(e=i.element(this)&&e)||(a=a.concat(i.errorList))})),i.errorList=a),e},rules:function(e,i){var a,r,n,s,o,d,l=this[0],u=void 0!==this.attr("contenteditable")&&"false"!==this.attr("contenteditable");if(null!=l&&(!l.form&&u&&(l.form=this.closest("form")[0],l.name=this.attr("name")),null!=l.form)){if(e)switch(r=(a=t.data(l.form,"validator").settings).rules,n=t.validator.staticRules(l),e){case"add":t.extend(n,t.validator.normalizeRule(i)),delete n.messages,r[l.name]=n,i.messages&&(a.messages[l.name]=t.extend(a.messages[l.name],i.messages));break;case"remove":return i?(d={},t.each(i.split(/\s/),(function(t,e){d[e]=n[e],delete n[e]})),d):(delete r[l.name],n)}return(s=t.validator.normalizeRules(t.extend({},t.validator.classRules(l),t.validator.attributeRules(l),t.validator.dataRules(l),t.validator.staticRules(l)),l)).required&&(o=s.required,delete s.required,s=t.extend({required:o},s)),s.remote&&(o=s.remote,delete s.remote,s=t.extend(s,{remote:o})),s}}}),t.extend(t.expr.pseudos||t.expr[":"],{blank:function(e){return!t.trim(""+t(e).val())},filled:function(e){var i=t(e).val();return null!==i&&!!t.trim(""+i)},unchecked:function(e){return!t(e).prop("checked")}}),t.validator=function(e,i){this.settings=t.extend(!0,{},t.validator.defaults,e),this.currentForm=i,this.init()},t.validator.format=function(e,i){return 1===arguments.length?function(){var i=t.makeArray(arguments);return i.unshift(e),t.validator.format.apply(this,i)}:(void 0===i||(arguments.length>2&&i.constructor!==Array&&(i=t.makeArray(arguments).slice(1)),i.constructor!==Array&&(i=[i]),t.each(i,(function(t,i){e=e.replace(new RegExp("\\{"+t+"\\}","g"),(function(){return i}))}))),e)},t.extend(t.validator,{defaults:{messages:{},groups:{},rules:{},errorClass:"error",pendingClass:"pending",validClass:"valid",errorElement:"label",focusCleanup:!1,focusInvalid:!0,errorContainer:t([]),errorLabelContainer:t([]),onsubmit:!0,ignore:":hidden",ignoreTitle:!1,onfocusin:function(t){this.lastActive=t,this.settings.focusCleanup&&(this.settings.unhighlight&&this.settings.unhighlight.call(this,t,this.settings.errorClass,this.settings.validClass),this.hideThese(this.errorsFor(t)))},onfocusout:function(t){this.checkable(t)||!(t.name in this.submitted)&&this.optional(t)||this.element(t)},onkeyup:function(e,i){9===i.which&&""===this.elementValue(e)||-1!==t.inArray(i.keyCode,[16,17,18,20,35,36,37,38,39,40,45,144,225])||(e.name in this.submitted||e.name in this.invalid)&&this.element(e)},onclick:function(t){t.name in this.submitted?this.element(t):t.parentNode.name in this.submitted&&this.element(t.parentNode)},highlight:function(e,i,a){"radio"===e.type?this.findByName(e.name).addClass(i).removeClass(a):t(e).addClass(i).removeClass(a)},unhighlight:function(e,i,a){"radio"===e.type?this.findByName(e.name).removeClass(i).addClass(a):t(e).removeClass(i).addClass(a)}},setDefaults:function(e){t.extend(t.validator.defaults,e)},messages:{required:"This field is required.",remote:"Please fix this field.",email:"Please enter a valid email address.",url:"Please enter a valid URL.",date:"Please enter a valid date.",dateISO:"Please enter a valid date (ISO).",number:"Please enter a valid number.",digits:"Please enter only digits.",equalTo:"Please enter the same value again.",maxlength:t.validator.format("Please enter no more than {0} characters."),minlength:t.validator.format("Please enter at least {0} characters."),rangelength:t.validator.format("Please enter a value between {0} and {1} characters long."),range:t.validator.format("Please enter a value between {0} and {1}."),max:t.validator.format("Please enter a value less than or equal to {0}."),min:t.validator.format("Please enter a value greater than or equal to {0}."),step:t.validator.format("Please enter a multiple of {0}.")},autoCreateRanges:!1,prototype:{init:function(){this.labelContainer=t(this.settings.errorLabelContainer),this.errorContext=this.labelContainer.length&&this.labelContainer||t(this.currentForm),this.containers=t(this.settings.errorContainer).add(this.settings.errorLabelContainer),this.submitted={},this.valueCache={},this.pendingRequest=0,this.pending={},this.invalid={},this.reset();var e,i=this.currentForm,a=this.groups={};function r(e){var a=void 0!==t(this).attr("contenteditable")&&"false"!==t(this).attr("contenteditable");if(!this.form&&a&&(this.form=t(this).closest("form")[0],this.name=t(this).attr("name")),i===this.form){var r=t.data(this.form,"validator"),n="on"+e.type.replace(/^validate/,""),s=r.settings;s[n]&&!t(this).is(s.ignore)&&s[n].call(r,this,e)}}t.each(this.settings.groups,(function(e,i){"string"==typeof i&&(i=i.split(/\s/)),t.each(i,(function(t,i){a[i]=e}))})),e=this.settings.rules,t.each(e,(function(i,a){e[i]=t.validator.normalizeRule(a)})),t(this.currentForm).on("focusin.validate focusout.validate keyup.validate",":text, [type='password'], [type='file'], select, textarea, [type='number'], [type='search'], [type='tel'], [type='url'], [type='email'], [type='datetime'], [type='date'], [type='month'], [type='week'], [type='time'], [type='datetime-local'], [type='range'], [type='color'], [type='radio'], [type='checkbox'], [contenteditable], [type='button']",r).on("click.validate","select, option, [type='radio'], [type='checkbox']",r),this.settings.invalidHandler&&t(this.currentForm).on("invalid-form.validate",this.settings.invalidHandler)},form:function(){return this.checkForm(),t.extend(this.submitted,this.errorMap),this.invalid=t.extend({},this.errorMap),this.valid()||t(this.currentForm).triggerHandler("invalid-form",[this]),this.showErrors(),this.valid()},checkForm:function(){this.prepareForm();for(var t=0,e=this.currentElements=this.elements();e[t];t++)this.check(e[t]);return this.valid()},element:function(e){var i,a,r=this.clean(e),n=this.validationTargetFor(r),s=this,o=!0;return void 0===n?delete this.invalid[r.name]:(this.prepareElement(n),this.currentElements=t(n),(a=this.groups[n.name])&&t.each(this.groups,(function(t,e){e===a&&t!==n.name&&(r=s.validationTargetFor(s.clean(s.findByName(t))))&&r.name in s.invalid&&(s.currentElements.push(r),o=s.check(r)&&o)})),i=!1!==this.check(n),o=o&&i,this.invalid[n.name]=!i,this.numberOfInvalids()||(this.toHide=this.toHide.add(this.containers)),this.showErrors(),t(e).attr("aria-invalid",!i)),o},showErrors:function(e){if(e){var i=this;t.extend(this.errorMap,e),this.errorList=t.map(this.errorMap,(function(t,e){return{message:t,element:i.findByName(e)[0]}})),this.successList=t.grep(this.successList,(function(t){return!(t.name in e)}))}this.settings.showErrors?this.settings.showErrors.call(this,this.errorMap,this.errorList):this.defaultShowErrors()},resetForm:function(){t.fn.resetForm&&t(this.currentForm).resetForm(),this.invalid={},this.submitted={},this.prepareForm(),this.hideErrors();var e=this.elements().removeData("previousValue").removeAttr("aria-invalid");this.resetElements(e)},resetElements:function(t){var e;if(this.settings.unhighlight)for(e=0;t[e];e++)this.settings.unhighlight.call(this,t[e],this.settings.errorClass,""),this.findByName(t[e].name).removeClass(this.settings.validClass);else t.removeClass(this.settings.errorClass).removeClass(this.settings.validClass)},numberOfInvalids:function(){return this.objectLength(this.invalid)},objectLength:function(t){var e,i=0;for(e in t)void 0!==t[e]&&null!==t[e]&&!1!==t[e]&&i++;return i},hideErrors:function(){this.hideThese(this.toHide)},hideThese:function(t){t.not(this.containers).text(""),this.addWrapper(t).hide()},valid:function(){return 0===this.size()},size:function(){return this.errorList.length},focusInvalid:function(){if(this.settings.focusInvalid)try{t(this.findLastActive()||this.errorList.length&&this.errorList[0].element||[]).filter(":visible").trigger("focus").trigger("focusin")}catch(t){}},findLastActive:function(){var e=this.lastActive;return e&&1===t.grep(this.errorList,(function(t){return t.element.name===e.name})).length&&e},elements:function(){var e=this,i={};return t(this.currentForm).find("input, select, textarea, [contenteditable]").not(":submit, :reset, :image, :disabled").not(this.settings.ignore).filter((function(){var a=this.name||t(this).attr("name"),r=void 0!==t(this).attr("contenteditable")&&"false"!==t(this).attr("contenteditable");return!a&&e.settings.debug&&window.console&&console.error("%o has no name assigned",this),r&&(this.form=t(this).closest("form")[0],this.name=a),this.form===e.currentForm&&(!(a in i||!e.objectLength(t(this).rules()))&&(i[a]=!0,!0))}))},clean:function(e){return t(e)[0]},errors:function(){var e=this.settings.errorClass.split(" ").join(".");return t(this.settings.errorElement+"."+e,this.errorContext)},resetInternals:function(){this.successList=[],this.errorList=[],this.errorMap={},this.toShow=t([]),this.toHide=t([])},reset:function(){this.resetInternals(),this.currentElements=t([])},prepareForm:function(){this.reset(),this.toHide=this.errors().add(this.containers)},prepareElement:function(t){this.reset(),this.toHide=this.errorsFor(t)},elementValue:function(e){var i,a,r=t(e),n=e.type,s=void 0!==r.attr("contenteditable")&&"false"!==r.attr("contenteditable");return"radio"===n||"checkbox"===n?this.findByName(e.name).filter(":checked").val():"number"===n&&void 0!==e.validity?e.validity.badInput?"NaN":r.val():(i=s?r.text():r.val(),"file"===n?"C:\\fakepath\\"===i.substr(0,12)?i.substr(12):(a=i.lastIndexOf("/"))>=0||(a=i.lastIndexOf("\\"))>=0?i.substr(a+1):i:"string"==typeof i?i.replace(/\r/g,""):i)},check:function(e){e=this.validationTargetFor(this.clean(e));var i,a,r,n,s=t(e).rules(),o=t.map(s,(function(t,e){return e})).length,d=!1,l=this.elementValue(e);for(a in"function"==typeof s.normalizer?n=s.normalizer:"function"==typeof this.settings.normalizer&&(n=this.settings.normalizer),n&&(l=n.call(e,l),delete s.normalizer),s){r={method:a,parameters:s[a]};try{if("dependency-mismatch"===(i=t.validator.methods[a].call(this,l,e,r.parameters))&&1===o){d=!0;continue}if(d=!1,"pending"===i)return void(this.toHide=this.toHide.not(this.errorsFor(e)));if(!i)return this.formatAndAdd(e,r),!1}catch(t){throw this.settings.debug&&window.console&&console.log("Exception occurred when checking element "+e.id+", check the '"+r.method+"' method.",t),t instanceof TypeError&&(t.message+=". Exception occurred when checking element "+e.id+", check the '"+r.method+"' method."),t}}if(!d)return this.objectLength(s)&&this.successList.push(e),!0},customDataMessage:function(e,i){return t(e).data("msg"+i.charAt(0).toUpperCase()+i.substring(1).toLowerCase())||t(e).data("msg")},customMessage:function(t,e){var i=this.settings.messages[t];return i&&(i.constructor===String?i:i[e])},findDefined:function(){for(var t=0;t<arguments.length;t++)if(void 0!==arguments[t])return arguments[t]},defaultMessage:function(e,i){"string"==typeof i&&(i={method:i});var a=this.findDefined(this.customMessage(e.name,i.method),this.customDataMessage(e,i.method),!this.settings.ignoreTitle&&e.title||void 0,t.validator.messages[i.method],"<strong>Warning: No message defined for "+e.name+"</strong>"),r=/\$?\{(\d+)\}/g;return"function"==typeof a?a=a.call(this,i.parameters,e):r.test(a)&&(a=t.validator.format(a.replace(r,"{$1}"),i.parameters)),a},formatAndAdd:function(t,e){var i=this.defaultMessage(t,e);this.errorList.push({message:i,element:t,method:e.method}),this.errorMap[t.name]=i,this.submitted[t.name]=i},addWrapper:function(t){return this.settings.wrapper&&(t=t.add(t.parent(this.settings.wrapper))),t},defaultShowErrors:function(){var t,e,i;for(t=0;this.errorList[t];t++)i=this.errorList[t],this.settings.highlight&&this.settings.highlight.call(this,i.element,this.settings.errorClass,this.settings.validClass),this.showLabel(i.element,i.message);if(this.errorList.length&&(this.toShow=this.toShow.add(this.containers)),this.settings.success)for(t=0;this.successList[t];t++)this.showLabel(this.successList[t]);if(this.settings.unhighlight)for(t=0,e=this.validElements();e[t];t++)this.settings.unhighlight.call(this,e[t],this.settings.errorClass,this.settings.validClass);this.toHide=this.toHide.not(this.toShow),this.hideErrors(),this.addWrapper(this.toShow).show()},validElements:function(){return this.currentElements.not(this.invalidElements())},invalidElements:function(){return t(this.errorList).map((function(){return this.element}))},showLabel:function(e,i){var a,r,n,s,o=this.errorsFor(e),d=this.idOrName(e),l=t(e).attr("aria-describedby");o.length?(o.removeClass(this.settings.validClass).addClass(this.settings.errorClass),o.html(i)):(a=o=t("<"+this.settings.errorElement+">").attr("id",d+"-error").addClass(this.settings.errorClass).html(i||""),this.settings.wrapper&&(a=o.hide().show().wrap("<"+this.settings.wrapper+"/>").parent()),this.labelContainer.length?this.labelContainer.append(a):this.settings.errorPlacement?this.settings.errorPlacement.call(this,a,t(e)):a.insertAfter(e),o.is("label")?o.attr("for",d):0===o.parents("label[for='"+this.escapeCssMeta(d)+"']").length&&(n=o.attr("id"),l?l.match(new RegExp("\\b"+this.escapeCssMeta(n)+"\\b"))||(l+=" "+n):l=n,t(e).attr("aria-describedby",l),(r=this.groups[e.name])&&(s=this,t.each(s.groups,(function(e,i){i===r&&t("[name='"+s.escapeCssMeta(e)+"']",s.currentForm).attr("aria-describedby",o.attr("id"))}))))),!i&&this.settings.success&&(o.text(""),"string"==typeof this.settings.success?o.addClass(this.settings.success):this.settings.success(o,e)),this.toShow=this.toShow.add(o)},errorsFor:function(e){var i=this.escapeCssMeta(this.idOrName(e)),a=t(e).attr("aria-describedby"),r="label[for='"+i+"'], label[for='"+i+"'] *";return a&&(r=r+", #"+this.escapeCssMeta(a).replace(/\s+/g,", #")),this.errors().filter(r)},escapeCssMeta:function(t){return t.replace(/([\\!"#$%&'()*+,./:;<=>?@\[\]^`{|}~])/g,"\\$1")},idOrName:function(t){return this.groups[t.name]||(this.checkable(t)?t.name:t.id||t.name)},validationTargetFor:function(e){return this.checkable(e)&&(e=this.findByName(e.name)),t(e).not(this.settings.ignore)[0]},checkable:function(t){return/radio|checkbox/i.test(t.type)},findByName:function(e){return t(this.currentForm).find("[name='"+this.escapeCssMeta(e)+"']")},getLength:function(e,i){switch(i.nodeName.toLowerCase()){case"select":return t("option:selected",i).length;case"input":if(this.checkable(i))return this.findByName(i.name).filter(":checked").length}return e.length},depend:function(t,e){return!this.dependTypes[typeof t]||this.dependTypes[typeof t](t,e)},dependTypes:{boolean:function(t){return t},string:function(e,i){return!!t(e,i.form).length},function:function(t,e){return t(e)}},optional:function(e){var i=this.elementValue(e);return!t.validator.methods.required.call(this,i,e)&&"dependency-mismatch"},startRequest:function(e){this.pending[e.name]||(this.pendingRequest++,t(e).addClass(this.settings.pendingClass),this.pending[e.name]=!0)},stopRequest:function(e,i){this.pendingRequest--,this.pendingRequest<0&&(this.pendingRequest=0),delete this.pending[e.name],t(e).removeClass(this.settings.pendingClass),i&&0===this.pendingRequest&&this.formSubmitted&&this.form()?(t(this.currentForm).submit(),this.submitButton&&t("input:hidden[name='"+this.submitButton.name+"']",this.currentForm).remove(),this.formSubmitted=!1):!i&&0===this.pendingRequest&&this.formSubmitted&&(t(this.currentForm).triggerHandler("invalid-form",[this]),this.formSubmitted=!1)},previousValue:function(e,i){return i="string"==typeof i&&i||"remote",t.data(e,"previousValue")||t.data(e,"previousValue",{old:null,valid:!0,message:this.defaultMessage(e,{method:i})})},destroy:function(){this.resetForm(),t(this.currentForm).off(".validate").removeData("validator").find(".validate-equalTo-blur").off(".validate-equalTo").removeClass("validate-equalTo-blur").find(".validate-lessThan-blur").off(".validate-lessThan").removeClass("validate-lessThan-blur").find(".validate-lessThanEqual-blur").off(".validate-lessThanEqual").removeClass("validate-lessThanEqual-blur").find(".validate-greaterThanEqual-blur").off(".validate-greaterThanEqual").removeClass("validate-greaterThanEqual-blur").find(".validate-greaterThan-blur").off(".validate-greaterThan").removeClass("validate-greaterThan-blur")}},classRuleSettings:{required:{required:!0},email:{email:!0},url:{url:!0},date:{date:!0},dateISO:{dateISO:!0},number:{number:!0},digits:{digits:!0},creditcard:{creditcard:!0}},addClassRules:function(e,i){e.constructor===String?this.classRuleSettings[e]=i:t.extend(this.classRuleSettings,e)},classRules:function(e){var i={},a=t(e).attr("class");return a&&t.each(a.split(" "),(function(){this in t.validator.classRuleSettings&&t.extend(i,t.validator.classRuleSettings[this])})),i},normalizeAttributeRule:function(t,e,i,a){/min|max|step/.test(i)&&(null===e||/number|range|text/.test(e))&&(a=Number(a),isNaN(a)&&(a=void 0)),a||0===a?t[i]=a:e===i&&"range"!==e&&(t[i]=!0)},attributeRules:function(e){var i,a,r={},n=t(e),s=e.getAttribute("type");for(i in t.validator.methods)"required"===i?(""===(a=e.getAttribute(i))&&(a=!0),a=!!a):a=n.attr(i),this.normalizeAttributeRule(r,s,i,a);return r.maxlength&&/-1|2147483647|524288/.test(r.maxlength)&&delete r.maxlength,r},dataRules:function(e){var i,a,r={},n=t(e),s=e.getAttribute("type");for(i in t.validator.methods)""===(a=n.data("rule"+i.charAt(0).toUpperCase()+i.substring(1).toLowerCase()))&&(a=!0),this.normalizeAttributeRule(r,s,i,a);return r},staticRules:function(e){var i={},a=t.data(e.form,"validator");return a.settings.rules&&(i=t.validator.normalizeRule(a.settings.rules[e.name])||{}),i},normalizeRules:function(e,i){return t.each(e,(function(a,r){if(!1!==r){if(r.param||r.depends){var n=!0;switch(typeof r.depends){case"string":n=!!t(r.depends,i.form).length;break;case"function":n=r.depends.call(i,i)}n?e[a]=void 0===r.param||r.param:(t.data(i.form,"validator").resetElements(t(i)),delete e[a])}}else delete e[a]})),t.each(e,(function(a,r){e[a]=t.isFunction(r)&&"normalizer"!==a?r(i):r})),t.each(["minlength","maxlength"],(function(){e[this]&&(e[this]=Number(e[this]))})),t.each(["rangelength","range"],(function(){var i;e[this]&&(t.isArray(e[this])?e[this]=[Number(e[this][0]),Number(e[this][1])]:"string"==typeof e[this]&&(i=e[this].replace(/[\[\]]/g,"").split(/[\s,]+/),e[this]=[Number(i[0]),Number(i[1])]))})),t.validator.autoCreateRanges&&(null!=e.min&&null!=e.max&&(e.range=[e.min,e.max],delete e.min,delete e.max),null!=e.minlength&&null!=e.maxlength&&(e.rangelength=[e.minlength,e.maxlength],delete e.minlength,delete e.maxlength)),e},normalizeRule:function(e){if("string"==typeof e){var i={};t.each(e.split(/\s/),(function(){i[this]=!0})),e=i}return e},addMethod:function(e,i,a){t.validator.methods[e]=i,t.validator.messages[e]=void 0!==a?a:t.validator.messages[e],i.length<3&&t.validator.addClassRules(e,t.validator.normalizeRule(e))},methods:{required:function(e,i,a){if(!this.depend(a,i))return"dependency-mismatch";if("select"===i.nodeName.toLowerCase()){var r=t(i).val();return r&&r.length>0}return this.checkable(i)?this.getLength(e,i)>0:null!=e&&e.length>0},email:function(t,e){return this.optional(e)||/^[a-zA-Z0-9.!#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(t)},url:function(t,e){return this.optional(e)||/^(?:(?:(?:https?|ftp):)?\/\/)(?:\S+(?::\S*)?@)?(?:(?!(?:10|127)(?:\.\d{1,3}){3})(?!(?:169\.254|192\.168)(?:\.\d{1,3}){2})(?!172\.(?:1[6-9]|2\d|3[0-1])(?:\.\d{1,3}){2})(?:[1-9]\d?|1\d\d|2[01]\d|22[0-3])(?:\.(?:1?\d{1,2}|2[0-4]\d|25[0-5])){2}(?:\.(?:[1-9]\d?|1\d\d|2[0-4]\d|25[0-4]))|(?:(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)(?:\.(?:[a-z\u00a1-\uffff0-9]-*)*[a-z\u00a1-\uffff0-9]+)*(?:\.(?:[a-z\u00a1-\uffff]{2,})).?)(?::\d{2,5})?(?:[/?#]\S*)?$/i.test(t)},date:(e=!1,function(t,i){return e||(e=!0,this.settings.debug&&window.console&&console.warn("The `date` method is deprecated and will be removed in version '2.0.0'.\nPlease don't use it, since it relies on the Date constructor, which\nbehaves very differently across browsers and locales. Use `dateISO`\ninstead or one of the locale specific methods in `localizations/`\nand `additional-methods.js`.")),this.optional(i)||!/Invalid|NaN/.test(new Date(t).toString())}),dateISO:function(t,e){return this.optional(e)||/^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(t)},number:function(t,e){return this.optional(e)||/^(?:-?\d+|-?\d{1,3}(?:,\d{3})+)?(?:\.\d+)?$/.test(t)},digits:function(t,e){return this.optional(e)||/^\d+$/.test(t)},minlength:function(e,i,a){var r=t.isArray(e)?e.length:this.getLength(e,i);return this.optional(i)||r>=a},maxlength:function(e,i,a){var r=t.isArray(e)?e.length:this.getLength(e,i);return this.optional(i)||r<=a},rangelength:function(e,i,a){var r=t.isArray(e)?e.length:this.getLength(e,i);return this.optional(i)||r>=a[0]&&r<=a[1]},min:function(t,e,i){return this.optional(e)||t>=i},max:function(t,e,i){return this.optional(e)||t<=i},range:function(t,e,i){return this.optional(e)||t>=i[0]&&t<=i[1]},step:function(e,i,a){var r,n=t(i).attr("type"),s="Step attribute on input type "+n+" is not supported.",o=new RegExp("\\b"+n+"\\b"),d=function(t){var e=(""+t).match(/(?:\.(\d+))?$/);return e&&e[1]?e[1].length:0},l=function(t){return Math.round(t*Math.pow(10,r))},u=!0;if(n&&!o.test(["text","number","range"].join()))throw new Error(s);return r=d(a),(d(e)>r||l(e)%l(a)!=0)&&(u=!1),this.optional(i)||u},equalTo:function(e,i,a){var r=t(a);return this.settings.onfocusout&&r.not(".validate-equalTo-blur").length&&r.addClass("validate-equalTo-blur").on("blur.validate-equalTo",(function(){t(i).valid()})),e===r.val()},remote:function(e,i,a,r){if(this.optional(i))return"dependency-mismatch";r="string"==typeof r&&r||"remote";var n,s,o,d=this.previousValue(i,r);return this.settings.messages[i.name]||(this.settings.messages[i.name]={}),d.originalMessage=d.originalMessage||this.settings.messages[i.name][r],this.settings.messages[i.name][r]=d.message,a="string"==typeof a&&{url:a}||a,o=t.param(t.extend({data:e},a.data)),d.old===o?d.valid:(d.old=o,n=this,this.startRequest(i),(s={})[i.name]=e,t.ajax(t.extend(!0,{mode:"abort",port:"validate"+i.name,dataType:"json",data:s,context:n.currentForm,success:function(t){var a,s,o,l=!0===t||"true"===t;n.settings.messages[i.name][r]=d.originalMessage,l?(o=n.formSubmitted,n.resetInternals(),n.toHide=n.errorsFor(i),n.formSubmitted=o,n.successList.push(i),n.invalid[i.name]=!1,n.showErrors()):(a={},s=t||n.defaultMessage(i,{method:r,parameters:e}),a[i.name]=d.message=s,n.invalid[i.name]=!0,n.showErrors(a)),d.valid=l,n.stopRequest(i,l)}},a)),"pending")}}});var i,a={};return t.ajaxPrefilter?t.ajaxPrefilter((function(t,e,i){var r=t.port;"abort"===t.mode&&(a[r]&&a[r].abort(),a[r]=i)})):(i=t.ajax,t.ajax=function(e){var r=("mode"in e?e:t.ajaxSettings).mode,n=("port"in e?e:t.ajaxSettings).port;return"abort"===r?(a[n]&&a[n].abort(),a[n]=i.apply(this,arguments),a[n]):i.apply(this,arguments)}),t})),
|
10 |
/*!
|
11 |
* jQuery Validation Plugin v1.19.1
|
12 |
*
|
15 |
* Copyright (c) 2019 Jörn Zaefferer
|
16 |
* Released under the MIT license
|
17 |
*/
|
18 |
+
function(t){"function"==typeof define&&define.amd?define(["jquery","./jquery.validate"],t):"object"==typeof module&&module.exports?module.exports=t(require("jquery")):t(jQuery)}((function(t){return function(){function e(t){return t.replace(/<.[^<>]*?>/g," ").replace(/ | /gi," ").replace(/[.(),;:!?%#$'\"_+=\/\-“”’]*/g,"")}t.validator.addMethod("maxWords",(function(t,i,a){return this.optional(i)||e(t).match(/\b\w+\b/g).length<=a}),t.validator.format("Please enter {0} words or less.")),t.validator.addMethod("minWords",(function(t,i,a){return this.optional(i)||e(t).match(/\b\w+\b/g).length>=a}),t.validator.format("Please enter at least {0} words.")),t.validator.addMethod("rangeWords",(function(t,i,a){var r=e(t),n=/\b\w+\b/g;return this.optional(i)||r.match(n).length>=a[0]&&r.match(n).length<=a[1]}),t.validator.format("Please enter between {0} and {1} words."))}(),t.validator.addMethod("abaRoutingNumber",(function(t){var e=0,i=t.split(""),a=i.length;if(9!==a)return!1;for(var r=0;r<a;r+=3)e+=3*parseInt(i[r],10)+7*parseInt(i[r+1],10)+parseInt(i[r+2],10);return 0!==e&&e%10==0}),"Please enter a valid routing number."),t.validator.addMethod("accept",(function(e,i,a){var r,n,s="string"==typeof a?a.replace(/\s/g,""):"image/*",o=this.optional(i);if(o)return o;if("file"===t(i).attr("type")&&(s=s.replace(/[\-\[\]\/\{\}\(\)\+\?\.\\\^\$\|]/g,"\\$&").replace(/,/g,"|").replace(/\/\*/g,"/.*"),i.files&&i.files.length))for(n=new RegExp(".?("+s+")$","i"),r=0;r<i.files.length;r++)if(!i.files[r].type.match(n))return!1;return!0}),t.validator.format("Please enter a value with a valid mimetype.")),t.validator.addMethod("alphanumeric",(function(t,e){return this.optional(e)||/^\w+$/i.test(t)}),"Letters, numbers, and underscores only please"),t.validator.addMethod("bankaccountNL",(function(t,e){if(this.optional(e))return!0;if(!/^[0-9]{9}|([0-9]{2} ){3}[0-9]{3}$/.test(t))return!1;var i,a=t.replace(/ /g,""),r=0,n=a.length;for(i=0;i<n;i++)r+=(n-i)*a.substring(i,i+1);return r%11==0}),"Please specify a valid bank account number"),t.validator.addMethod("bankorgiroaccountNL",(function(e,i){return this.optional(i)||t.validator.methods.bankaccountNL.call(this,e,i)||t.validator.methods.giroaccountNL.call(this,e,i)}),"Please specify a valid bank or giro account number"),t.validator.addMethod("bic",(function(t,e){return this.optional(e)||/^([A-Z]{6}[A-Z2-9][A-NP-Z1-9])(X{3}|[A-WY-Z0-9][A-Z0-9]{2})?$/.test(t.toUpperCase())}),"Please specify a valid BIC code"),t.validator.addMethod("cifES",(function(t,e){"use strict";if(this.optional(e))return!0;var i,a,r,n,s=new RegExp(/^([ABCDEFGHJKLMNPQRSUVW])(\d{7})([0-9A-J])$/gi),o=t.substring(0,1),d=t.substring(1,8),l=t.substring(8,9),u=0,h=0;function c(t){return t%2==0}if(9!==t.length||!s.test(t))return!1;for(i=0;i<d.length;i++)a=parseInt(d[i],10),c(i)?h+=(a*=2)<10?a:a-9:u+=a;return r=(10-(u+h).toString().substr(-1)).toString(),r=parseInt(r,10)>9?"0":r,n="JABCDEFGHI".substr(r,1).toString(),o.match(/[ABEH]/)?l===r:o.match(/[KPQS]/)?l===n:l===r||l===n}),"Please specify a valid CIF number."),t.validator.addMethod("cnhBR",(function(t){if(11!==(t=t.replace(/([~!@#$%^&*()_+=`{}\[\]\-|\\:;'<>,.\/? ])+/g,"")).length)return!1;var e,i,a,r,n,s=0,o=0;if(e=t.charAt(0),new Array(12).join(e)===t)return!1;for(r=0,n=9,0;r<9;++r,--n)s+=+t.charAt(r)*n;for((i=s%11)>=10&&(i=0,o=2),s=0,r=0,n=1,0;r<9;++r,++n)s+=+t.charAt(r)*n;return(a=s%11)>=10?a=0:a-=o,String(i).concat(a)===t.substr(-2)}),"Please specify a valid CNH number"),t.validator.addMethod("cnpjBR",(function(t,e){"use strict";if(this.optional(e))return!0;if(14!==(t=t.replace(/[^\d]+/g,"")).length)return!1;if("00000000000000"===t||"11111111111111"===t||"22222222222222"===t||"33333333333333"===t||"44444444444444"===t||"55555555555555"===t||"66666666666666"===t||"77777777777777"===t||"88888888888888"===t||"99999999999999"===t)return!1;for(var i=t.length-2,a=t.substring(0,i),r=t.substring(i),n=0,s=i-7,o=i;o>=1;o--)n+=a.charAt(i-o)*s--,s<2&&(s=9);var d=n%11<2?0:11-n%11;if(d!==parseInt(r.charAt(0),10))return!1;i+=1,a=t.substring(0,i),n=0,s=i-7;for(var l=i;l>=1;l--)n+=a.charAt(i-l)*s--,s<2&&(s=9);return(d=n%11<2?0:11-n%11)===parseInt(r.charAt(1),10)}),"Please specify a CNPJ value number"),t.validator.addMethod("cpfBR",(function(t,e){"use strict";if(this.optional(e))return!0;if(11!==(t=t.replace(/([~!@#$%^&*()_+=`{}\[\]\-|\\:;'<>,.\/? ])+/g,"")).length)return!1;var i,a,r,n,s=0;if(i=parseInt(t.substring(9,10),10),a=parseInt(t.substring(10,11),10),r=function(t,e){var i=10*t%11;return 10!==i&&11!==i||(i=0),i===e},""===t||"00000000000"===t||"11111111111"===t||"22222222222"===t||"33333333333"===t||"44444444444"===t||"55555555555"===t||"66666666666"===t||"77777777777"===t||"88888888888"===t||"99999999999"===t)return!1;for(n=1;n<=9;n++)s+=parseInt(t.substring(n-1,n),10)*(11-n);if(r(s,i)){for(s=0,n=1;n<=10;n++)s+=parseInt(t.substring(n-1,n),10)*(12-n);return r(s,a)}return!1}),"Please specify a valid CPF number"),t.validator.addMethod("creditcard",(function(t,e){if(this.optional(e))return"dependency-mismatch";if(/[^0-9 \-]+/.test(t))return!1;var i,a,r=0,n=0,s=!1;if((t=t.replace(/\D/g,"")).length<13||t.length>19)return!1;for(i=t.length-1;i>=0;i--)a=t.charAt(i),n=parseInt(a,10),s&&(n*=2)>9&&(n-=9),r+=n,s=!s;return r%10==0}),"Please enter a valid credit card number."),t.validator.addMethod("creditcardtypes",(function(t,e,i){if(/[^0-9\-]+/.test(t))return!1;t=t.replace(/\D/g,"");var a=0;return i.mastercard&&(a|=1),i.visa&&(a|=2),i.amex&&(a|=4),i.dinersclub&&(a|=8),i.enroute&&(a|=16),i.discover&&(a|=32),i.jcb&&(a|=64),i.unknown&&(a|=128),i.all&&(a=255),1&a&&(/^(5[12345])/.test(t)||/^(2[234567])/.test(t))||2&a&&/^(4)/.test(t)?16===t.length:4&a&&/^(3[47])/.test(t)?15===t.length:8&a&&/^(3(0[012345]|[68]))/.test(t)?14===t.length:16&a&&/^(2(014|149))/.test(t)?15===t.length:32&a&&/^(6011)/.test(t)||64&a&&/^(3)/.test(t)?16===t.length:64&a&&/^(2131|1800)/.test(t)?15===t.length:!!(128&a)}),"Please enter a valid credit card number."),t.validator.addMethod("currency",(function(t,e,i){var a,r="string"==typeof i,n=r?i:i[0],s=!!r||i[1];return n=n.replace(/,/g,""),a="^["+(n=s?n+"]":n+"]?")+"([1-9]{1}[0-9]{0,2}(\\,[0-9]{3})*(\\.[0-9]{0,2})?|[1-9]{1}[0-9]{0,}(\\.[0-9]{0,2})?|0(\\.[0-9]{0,2})?|(\\.[0-9]{1,2})?)$",a=new RegExp(a),this.optional(e)||a.test(t)}),"Please specify a valid currency"),t.validator.addMethod("dateFA",(function(t,e){return this.optional(e)||/^[1-4]\d{3}\/((0?[1-6]\/((3[0-1])|([1-2][0-9])|(0?[1-9])))|((1[0-2]|(0?[7-9]))\/(30|([1-2][0-9])|(0?[1-9]))))$/.test(t)}),t.validator.messages.date),t.validator.addMethod("dateITA",(function(t,e){var i,a,r,n,s,o=!1;return/^\d{1,2}\/\d{1,2}\/\d{4}$/.test(t)?(i=t.split("/"),a=parseInt(i[0],10),r=parseInt(i[1],10),n=parseInt(i[2],10),o=(s=new Date(Date.UTC(n,r-1,a,12,0,0,0))).getUTCFullYear()===n&&s.getUTCMonth()===r-1&&s.getUTCDate()===a):o=!1,this.optional(e)||o}),t.validator.messages.date),t.validator.addMethod("dateNL",(function(t,e){return this.optional(e)||/^(0?[1-9]|[12]\d|3[01])[\.\/\-](0?[1-9]|1[012])[\.\/\-]([12]\d)?(\d\d)$/.test(t)}),t.validator.messages.date),t.validator.addMethod("extension",(function(t,e,i){return i="string"==typeof i?i.replace(/,/g,"|"):"png|jpe?g|gif",this.optional(e)||t.match(new RegExp("\\.("+i+")$","i"))}),t.validator.format("Please enter a value with a valid extension.")),t.validator.addMethod("giroaccountNL",(function(t,e){return this.optional(e)||/^[0-9]{1,7}$/.test(t)}),"Please specify a valid giro account number"),t.validator.addMethod("greaterThan",(function(e,i,a){var r=t(a);return this.settings.onfocusout&&r.not(".validate-greaterThan-blur").length&&r.addClass("validate-greaterThan-blur").on("blur.validate-greaterThan",(function(){t(i).valid()})),e>r.val()}),"Please enter a greater value."),t.validator.addMethod("greaterThanEqual",(function(e,i,a){var r=t(a);return this.settings.onfocusout&&r.not(".validate-greaterThanEqual-blur").length&&r.addClass("validate-greaterThanEqual-blur").on("blur.validate-greaterThanEqual",(function(){t(i).valid()})),e>=r.val()}),"Please enter a greater value."),t.validator.addMethod("iban",(function(t,e){if(this.optional(e))return!0;var i,a,r,n,s,o=t.replace(/ /g,"").toUpperCase(),d="",l=!0,u="";if(o.length<5)return!1;if(void 0!==(r={AL:"\\d{8}[\\dA-Z]{16}",AD:"\\d{8}[\\dA-Z]{12}",AT:"\\d{16}",AZ:"[\\dA-Z]{4}\\d{20}",BE:"\\d{12}",BH:"[A-Z]{4}[\\dA-Z]{14}",BA:"\\d{16}",BR:"\\d{23}[A-Z][\\dA-Z]",BG:"[A-Z]{4}\\d{6}[\\dA-Z]{8}",CR:"\\d{17}",HR:"\\d{17}",CY:"\\d{8}[\\dA-Z]{16}",CZ:"\\d{20}",DK:"\\d{14}",DO:"[A-Z]{4}\\d{20}",EE:"\\d{16}",FO:"\\d{14}",FI:"\\d{14}",FR:"\\d{10}[\\dA-Z]{11}\\d{2}",GE:"[\\dA-Z]{2}\\d{16}",DE:"\\d{18}",GI:"[A-Z]{4}[\\dA-Z]{15}",GR:"\\d{7}[\\dA-Z]{16}",GL:"\\d{14}",GT:"[\\dA-Z]{4}[\\dA-Z]{20}",HU:"\\d{24}",IS:"\\d{22}",IE:"[\\dA-Z]{4}\\d{14}",IL:"\\d{19}",IT:"[A-Z]\\d{10}[\\dA-Z]{12}",KZ:"\\d{3}[\\dA-Z]{13}",KW:"[A-Z]{4}[\\dA-Z]{22}",LV:"[A-Z]{4}[\\dA-Z]{13}",LB:"\\d{4}[\\dA-Z]{20}",LI:"\\d{5}[\\dA-Z]{12}",LT:"\\d{16}",LU:"\\d{3}[\\dA-Z]{13}",MK:"\\d{3}[\\dA-Z]{10}\\d{2}",MT:"[A-Z]{4}\\d{5}[\\dA-Z]{18}",MR:"\\d{23}",MU:"[A-Z]{4}\\d{19}[A-Z]{3}",MC:"\\d{10}[\\dA-Z]{11}\\d{2}",MD:"[\\dA-Z]{2}\\d{18}",ME:"\\d{18}",NL:"[A-Z]{4}\\d{10}",NO:"\\d{11}",PK:"[\\dA-Z]{4}\\d{16}",PS:"[\\dA-Z]{4}\\d{21}",PL:"\\d{24}",PT:"\\d{21}",RO:"[A-Z]{4}[\\dA-Z]{16}",SM:"[A-Z]\\d{10}[\\dA-Z]{12}",SA:"\\d{2}[\\dA-Z]{18}",RS:"\\d{18}",SK:"\\d{20}",SI:"\\d{15}",ES:"\\d{20}",SE:"\\d{20}",CH:"\\d{5}[\\dA-Z]{12}",TN:"\\d{20}",TR:"\\d{5}[\\dA-Z]{17}",AE:"\\d{3}\\d{16}",GB:"[A-Z]{4}\\d{14}",VG:"[\\dA-Z]{4}\\d{16}"}[o.substring(0,2)])&&!new RegExp("^[A-Z]{2}\\d{2}"+r+"$","").test(o))return!1;for(i=o.substring(4,o.length)+o.substring(0,4),n=0;n<i.length;n++)"0"!==(a=i.charAt(n))&&(l=!1),l||(d+="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ".indexOf(a));for(s=0;s<d.length;s++)u=(""+u+d.charAt(s))%97;return 1===u}),"Please specify a valid IBAN"),t.validator.addMethod("integer",(function(t,e){return this.optional(e)||/^-?\d+$/.test(t)}),"A positive or negative non-decimal number please"),t.validator.addMethod("ipv4",(function(t,e){return this.optional(e)||/^(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)\.(25[0-5]|2[0-4]\d|[01]?\d\d?)$/i.test(t)}),"Please enter a valid IP v4 address."),t.validator.addMethod("ipv6",(function(t,e){return this.optional(e)||/^((([0-9A-Fa-f]{1,4}:){7}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}:[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){5}:([0-9A-Fa-f]{1,4}:)?[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){4}:([0-9A-Fa-f]{1,4}:){0,2}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){3}:([0-9A-Fa-f]{1,4}:){0,3}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){2}:([0-9A-Fa-f]{1,4}:){0,4}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){6}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(([0-9A-Fa-f]{1,4}:){0,5}:((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|(::([0-9A-Fa-f]{1,4}:){0,5}((\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b)\.){3}(\b((25[0-5])|(1\d{2})|(2[0-4]\d)|(\d{1,2}))\b))|([0-9A-Fa-f]{1,4}::([0-9A-Fa-f]{1,4}:){0,5}[0-9A-Fa-f]{1,4})|(::([0-9A-Fa-f]{1,4}:){0,6}[0-9A-Fa-f]{1,4})|(([0-9A-Fa-f]{1,4}:){1,7}:))$/i.test(t)}),"Please enter a valid IP v6 address."),t.validator.addMethod("lessThan",(function(e,i,a){var r=t(a);return this.settings.onfocusout&&r.not(".validate-lessThan-blur").length&&r.addClass("validate-lessThan-blur").on("blur.validate-lessThan",(function(){t(i).valid()})),e<r.val()}),"Please enter a lesser value."),t.validator.addMethod("lessThanEqual",(function(e,i,a){var r=t(a);return this.settings.onfocusout&&r.not(".validate-lessThanEqual-blur").length&&r.addClass("validate-lessThanEqual-blur").on("blur.validate-lessThanEqual",(function(){t(i).valid()})),e<=r.val()}),"Please enter a lesser value."),t.validator.addMethod("lettersonly",(function(t,e){return this.optional(e)||/^[a-z]+$/i.test(t)}),"Letters only please"),t.validator.addMethod("letterswithbasicpunc",(function(t,e){return this.optional(e)||/^[a-z\-.,()'"\s]+$/i.test(t)}),"Letters or punctuation only please"),t.validator.addMethod("maxfiles",(function(e,i,a){return!!this.optional(i)||!("file"===t(i).attr("type")&&i.files&&i.files.length>a)}),t.validator.format("Please select no more than {0} files.")),t.validator.addMethod("maxsize",(function(e,i,a){if(this.optional(i))return!0;if("file"===t(i).attr("type")&&i.files&&i.files.length)for(var r=0;r<i.files.length;r++)if(i.files[r].size>a)return!1;return!0}),t.validator.format("File size must not exceed {0} bytes each.")),t.validator.addMethod("maxsizetotal",(function(e,i,a){if(this.optional(i))return!0;if("file"===t(i).attr("type")&&i.files&&i.files.length)for(var r=0,n=0;n<i.files.length;n++)if((r+=i.files[n].size)>a)return!1;return!0}),t.validator.format("Total size of all files must not exceed {0} bytes.")),t.validator.addMethod("mobileNL",(function(t,e){return this.optional(e)||/^((\+|00(\s|\s?\-\s?)?)31(\s|\s?\-\s?)?(\(0\)[\-\s]?)?|0)6((\s|\s?\-\s?)?[0-9]){8}$/.test(t)}),"Please specify a valid mobile number"),t.validator.addMethod("mobileRU",(function(t,e){var i=t.replace(/\(|\)|\s+|-/g,"");return this.optional(e)||i.length>9&&/^((\+7|7|8)+([0-9]){10})$/.test(i)}),"Please specify a valid mobile number"),t.validator.addMethod("mobileUK",(function(t,e){return t=t.replace(/\(|\)|\s+|-/g,""),this.optional(e)||t.length>9&&t.match(/^(?:(?:(?:00\s?|\+)44\s?|0)7(?:[1345789]\d{2}|624)\s?\d{3}\s?\d{3})$/)}),"Please specify a valid mobile number"),t.validator.addMethod("netmask",(function(t,e){return this.optional(e)||/^(254|252|248|240|224|192|128)\.0\.0\.0|255\.(254|252|248|240|224|192|128|0)\.0\.0|255\.255\.(254|252|248|240|224|192|128|0)\.0|255\.255\.255\.(254|252|248|240|224|192|128|0)/i.test(t)}),"Please enter a valid netmask."),t.validator.addMethod("nieES",(function(t,e){"use strict";if(this.optional(e))return!0;var i,a=new RegExp(/^[MXYZ]{1}[0-9]{7,8}[TRWAGMYFPDXBNJZSQVHLCKET]{1}$/gi),r=t.substr(t.length-1).toUpperCase();return!((t=t.toString().toUpperCase()).length>10||t.length<9||!a.test(t))&&(i=9===(t=t.replace(/^[X]/,"0").replace(/^[Y]/,"1").replace(/^[Z]/,"2")).length?t.substr(0,8):t.substr(0,9),"TRWAGMYFPDXBNJZSQVHLCKET".charAt(parseInt(i,10)%23)===r)}),"Please specify a valid NIE number."),t.validator.addMethod("nifES",(function(t,e){"use strict";return!!this.optional(e)||!!(t=t.toUpperCase()).match("((^[A-Z]{1}[0-9]{7}[A-Z0-9]{1}$|^[T]{1}[A-Z0-9]{8}$)|^[0-9]{8}[A-Z]{1}$)")&&(/^[0-9]{8}[A-Z]{1}$/.test(t)?"TRWAGMYFPDXBNJZSQVHLCKE".charAt(t.substring(8,0)%23)===t.charAt(8):!!/^[KLM]{1}/.test(t)&&t[8]==="TRWAGMYFPDXBNJZSQVHLCKE".charAt(t.substring(8,1)%23))}),"Please specify a valid NIF number."),t.validator.addMethod("nipPL",(function(t){"use strict";if(10!==(t=t.replace(/[^0-9]/g,"")).length)return!1;for(var e=[6,5,7,2,3,4,5,6,7],i=0,a=0;a<9;a++)i+=e[a]*t[a];var r=i%11;return(10===r?0:r)===parseInt(t[9],10)}),"Please specify a valid NIP number."),t.validator.addMethod("nisBR",(function(t){var e,i,a,r,n,s=0;if(11!==(t=t.replace(/([~!@#$%^&*()_+=`{}\[\]\-|\\:;'<>,.\/? ])+/g,"")).length)return!1;for(i=parseInt(t.substring(10,11),10),e=parseInt(t.substring(0,10),10),r=2;r<12;r++)n=r,10===r&&(n=2),11===r&&(n=3),s+=e%10*n,e=parseInt(e/10,10);return i===(a=(a=s%11)>1?11-a:0)}),"Please specify a valid NIS/PIS number"),t.validator.addMethod("notEqualTo",(function(e,i,a){return this.optional(i)||!t.validator.methods.equalTo.call(this,e,i,a)}),"Please enter a different value, values must not be the same."),t.validator.addMethod("nowhitespace",(function(t,e){return this.optional(e)||/^\S+$/i.test(t)}),"No white space please"),t.validator.addMethod("pattern",(function(t,e,i){return!!this.optional(e)||("string"==typeof i&&(i=new RegExp("^(?:"+i+")$")),i.test(t))}),"Invalid format."),t.validator.addMethod("phoneNL",(function(t,e){return this.optional(e)||/^((\+|00(\s|\s?\-\s?)?)31(\s|\s?\-\s?)?(\(0\)[\-\s]?)?|0)[1-9]((\s|\s?\-\s?)?[0-9]){8}$/.test(t)}),"Please specify a valid phone number."),t.validator.addMethod("phonePL",(function(t,e){t=t.replace(/\s+/g,"");return this.optional(e)||/^(?:(?:(?:\+|00)?48)|(?:\(\+?48\)))?(?:1[2-8]|2[2-69]|3[2-49]|4[1-68]|5[0-9]|6[0-35-9]|[7-8][1-9]|9[145])\d{7}$/.test(t)}),"Please specify a valid phone number"),t.validator.addMethod("phonesUK",(function(t,e){return t=t.replace(/\(|\)|\s+|-/g,""),this.optional(e)||t.length>9&&t.match(/^(?:(?:(?:00\s?|\+)44\s?|0)(?:1\d{8,9}|[23]\d{9}|7(?:[1345789]\d{8}|624\d{6})))$/)}),"Please specify a valid uk phone number"),t.validator.addMethod("phoneUK",(function(t,e){return t=t.replace(/\(|\)|\s+|-/g,""),this.optional(e)||t.length>9&&t.match(/^(?:(?:(?:00\s?|\+)44\s?)|(?:\(?0))(?:\d{2}\)?\s?\d{4}\s?\d{4}|\d{3}\)?\s?\d{3}\s?\d{3,4}|\d{4}\)?\s?(?:\d{5}|\d{3}\s?\d{3})|\d{5}\)?\s?\d{4,5})$/)}),"Please specify a valid phone number"),t.validator.addMethod("phoneUS",(function(t,e){return t=t.replace(/\s+/g,""),this.optional(e)||t.length>9&&t.match(/^(\+?1-?)?(\([2-9]([02-9]\d|1[02-9])\)|[2-9]([02-9]\d|1[02-9]))-?[2-9]\d{2}-?\d{4}$/)}),"Please specify a valid phone number"),t.validator.addMethod("postalcodeBR",(function(t,e){return this.optional(e)||/^\d{2}.\d{3}-\d{3}?$|^\d{5}-?\d{3}?$/.test(t)}),"Informe um CEP válido."),t.validator.addMethod("postalCodeCA",(function(t,e){return this.optional(e)||/^[ABCEGHJKLMNPRSTVXY]\d[ABCEGHJKLMNPRSTVWXYZ] *\d[ABCEGHJKLMNPRSTVWXYZ]\d$/i.test(t)}),"Please specify a valid postal code"),t.validator.addMethod("postalcodeIT",(function(t,e){return this.optional(e)||/^\d{5}$/.test(t)}),"Please specify a valid postal code"),t.validator.addMethod("postalcodeNL",(function(t,e){return this.optional(e)||/^[1-9][0-9]{3}\s?[a-zA-Z]{2}$/.test(t)}),"Please specify a valid postal code"),t.validator.addMethod("postcodeUK",(function(t,e){return this.optional(e)||/^((([A-PR-UWYZ][0-9])|([A-PR-UWYZ][0-9][0-9])|([A-PR-UWYZ][A-HK-Y][0-9])|([A-PR-UWYZ][A-HK-Y][0-9][0-9])|([A-PR-UWYZ][0-9][A-HJKSTUW])|([A-PR-UWYZ][A-HK-Y][0-9][ABEHMNPRVWXY]))\s?([0-9][ABD-HJLNP-UW-Z]{2})|(GIR)\s?(0AA))$/i.test(t)}),"Please specify a valid UK postcode"),t.validator.addMethod("require_from_group",(function(e,i,a){var r=t(a[1],i.form),n=r.eq(0),s=n.data("valid_req_grp")?n.data("valid_req_grp"):t.extend({},this),o=r.filter((function(){return s.elementValue(this)})).length>=a[0];return n.data("valid_req_grp",s),t(i).data("being_validated")||(r.data("being_validated",!0),r.each((function(){s.element(this)})),r.data("being_validated",!1)),o}),t.validator.format("Please fill at least {0} of these fields.")),t.validator.addMethod("skip_or_fill_minimum",(function(e,i,a){var r=t(a[1],i.form),n=r.eq(0),s=n.data("valid_skip")?n.data("valid_skip"):t.extend({},this),o=r.filter((function(){return s.elementValue(this)})).length,d=0===o||o>=a[0];return n.data("valid_skip",s),t(i).data("being_validated")||(r.data("being_validated",!0),r.each((function(){s.element(this)})),r.data("being_validated",!1)),d}),t.validator.format("Please either skip these fields or fill at least {0} of them.")),t.validator.addMethod("stateUS",(function(t,e,i){var a,r=void 0===i,n=!r&&void 0!==i.caseSensitive&&i.caseSensitive,s=!r&&void 0!==i.includeTerritories&&i.includeTerritories,o=!r&&void 0!==i.includeMilitary&&i.includeMilitary;return a=s||o?s&&o?"^(A[AEKLPRSZ]|C[AOT]|D[CE]|FL|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEINOPST]|N[CDEHJMVY]|O[HKR]|P[AR]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])$":s?"^(A[KLRSZ]|C[AOT]|D[CE]|FL|G[AU]|HI|I[ADLN]|K[SY]|LA|M[ADEINOPST]|N[CDEHJMVY]|O[HKR]|P[AR]|RI|S[CD]|T[NX]|UT|V[AIT]|W[AIVY])$":"^(A[AEKLPRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])$":"^(A[KLRZ]|C[AOT]|D[CE]|FL|GA|HI|I[ADLN]|K[SY]|LA|M[ADEINOST]|N[CDEHJMVY]|O[HKR]|PA|RI|S[CD]|T[NX]|UT|V[AT]|W[AIVY])$",a=n?new RegExp(a):new RegExp(a,"i"),this.optional(e)||a.test(t)}),"Please specify a valid state"),t.validator.addMethod("strippedminlength",(function(e,i,a){return t(e).text().length>=a}),t.validator.format("Please enter at least {0} characters")),t.validator.addMethod("time",(function(t,e){return this.optional(e)||/^([01]\d|2[0-3]|[0-9])(:[0-5]\d){1,2}$/.test(t)}),"Please enter a valid time, between 00:00 and 23:59"),t.validator.addMethod("time12h",(function(t,e){return this.optional(e)||/^((0?[1-9]|1[012])(:[0-5]\d){1,2}(\ ?[AP]M))$/i.test(t)}),"Please enter a valid time in 12-hour am/pm format"),t.validator.addMethod("url2",(function(t,e){return this.optional(e)||/^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)*(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(t)}),t.validator.messages.url),t.validator.addMethod("vinUS",(function(t){if(17!==t.length)return!1;var e,i,a,r,n,s,o=["A","B","C","D","E","F","G","H","J","K","L","M","N","P","R","S","T","U","V","W","X","Y","Z"],d=[1,2,3,4,5,6,7,8,1,2,3,4,5,7,9,2,3,4,5,6,7,8,9],l=[8,7,6,5,4,3,2,10,0,9,8,7,6,5,4,3,2],u=0;for(e=0;e<17;e++){if(r=l[e],a=t.slice(e,e+1),8===e&&(s=a),isNaN(a)){for(i=0;i<o.length;i++)if(a.toUpperCase()===o[i]){a=d[i],a*=r,isNaN(s)&&8===i&&(s=o[i]);break}}else a*=r;u+=a}return 10===(n=u%11)&&(n="X"),n===s}),"The specified vehicle identification number (VIN) is invalid."),t.validator.addMethod("zipcodeUS",(function(t,e){return this.optional(e)||/^\d{5}(-\d{4})?$/.test(t)}),"The specified US ZIP Code is invalid"),t.validator.addMethod("ziprange",(function(t,e){return this.optional(e)||/^90[2-5]\d\{2\}-\d{4}$/.test(t)}),"Your ZIP-code must be in the range 902xx-xxxx to 905xx-xxxx"),t})),function(t,e,i){"use strict";var a=function(){function e(i){_classCallCheck(this,e),this.$form=t(i),this.validationElements=this.$form.find(".rwmb-validation"),this.showAsterisks(),this.getSettings()}return _createClass(e,[{key:"init",value:function(){this.$form.on("submit",(function(){"undefined"!=typeof tinyMCE&&tinyMCE.triggerSave()})).validate(this.settings)}},{key:"showAsterisks",value:function(){this.validationElements.each((function(){var e=t(this).data("validation");t.each(e.rules,(function(e,i){if(i.required){var a=t('[name="'+e+'"]');a.length&&a.closest(".rwmb-input").siblings(".rwmb-label").find("label").append('<span class="rwmb-required">*</span>')}}))}))}},{key:"getSettings",value:function(){this.settings={ignore:':not(.rwmb-media,.rwmb-image_select,.rwmb-wysiwyg,.rwmb-color,.rwmb-map,.rwmb-osm,.rwmb-switch,[class|="rwmb"]:visible)',errorPlacement:function(t,e){t.appendTo(e.closest(".rwmb-input"))},errorClass:"rwmb-error",errorElement:"p",invalidHandler:this.invalidHandler.bind(this)};var e=this;this.validationElements.each((function(){t.extend(!0,e.settings,t(this).data("validation"))}))}},{key:"invalidHandler",value:function(){this.showMessage();var t=this;setTimeout((function(){t.$form.trigger("after_validate")}),200)}},{key:"showMessage",value:function(){t("#publish").removeClass("button-primary-disabled"),t("#ajax-loading").attr("style",""),t("#rwmb-validation-message").remove(),this.$form.before('<div id="rwmb-validation-message" class="notice notice-error is-dismissible"><p>'+i.message+"</p></div>")}}]),e}(),r=function(t){_inherits(a,t);var e=_createSuper(a);function a(){return _classCallCheck(this,a),e.apply(this,arguments)}return _createClass(a,[{key:"init",value:function(){var t=this,e=wp.data.dispatch("core/editor"),i=e.savePost;e.savePost=function(e){"object"===_typeof(e)&&e.isPreview?i(e):(t.$form.validate(t.settings),t.$form.valid()&&i(e))}}},{key:"showMessage",value:function(){wp.data.dispatch("core/notices").createErrorNotice(i.message,{id:"meta-box-validation",isDismissible:!0})}}]),a}(a);t((function(){if(e.isGutenberg){var i=new r(".metabox-location-advanced"),n=new r(".metabox-location-normal");return new r(".metabox-location-side").init(),n.init(),void i.init()}t("#post, #edittag, #your-profile, .rwmb-form").each((function(){new a(this).init()}))}))}(jQuery,rwmb,rwmbValidation);
|
meta-box.php
CHANGED
@@ -3,7 +3,7 @@
|
|
3 |
* Plugin Name: Meta Box
|
4 |
* Plugin URI: https://metabox.io
|
5 |
* Description: Create custom meta boxes and custom fields in WordPress.
|
6 |
-
* Version: 5.
|
7 |
* Author: MetaBox.io
|
8 |
* Author URI: https://metabox.io
|
9 |
* License: GPL2+
|
3 |
* Plugin Name: Meta Box
|
4 |
* Plugin URI: https://metabox.io
|
5 |
* Description: Create custom meta boxes and custom fields in WordPress.
|
6 |
+
* Version: 5.6.0
|
7 |
* Author: MetaBox.io
|
8 |
* Author URI: https://metabox.io
|
9 |
* License: GPL2+
|
readme.txt
CHANGED
@@ -4,8 +4,8 @@ Donate link: https://metabox.io/pricing/
|
|
4 |
Tags: meta box, custom fields, custom post types, custom taxonomies, cpt, meta boxes, custom field, post type, taxonomy, meta, admin, advanced, custom, edit, field, file, image, magic fields, post types, more fields, post, repeater, simple fields, text, textarea, type, cms, fields post
|
5 |
Requires at least: 4.3
|
6 |
Requires PHP: 5.6
|
7 |
-
Tested up to: 5.
|
8 |
-
Stable tag: 5.5.
|
9 |
License: GPLv2 or later
|
10 |
|
11 |
Meta Box plugin is a powerful, professional developer toolkit to create custom meta boxes and custom fields for your custom post types in WordPress.
|
@@ -168,6 +168,14 @@ To getting started with the plugin, please read the [Quick Start Guide](https://
|
|
168 |
|
169 |
== Changelog ==
|
170 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
= 5.5.1 - 2021-12-15 =
|
172 |
- Fix warning for post field caused by the search by post title
|
173 |
|
4 |
Tags: meta box, custom fields, custom post types, custom taxonomies, cpt, meta boxes, custom field, post type, taxonomy, meta, admin, advanced, custom, edit, field, file, image, magic fields, post types, more fields, post, repeater, simple fields, text, textarea, type, cms, fields post
|
5 |
Requires at least: 4.3
|
6 |
Requires PHP: 5.6
|
7 |
+
Tested up to: 5.9.1
|
8 |
+
Stable tag: 5.5.2
|
9 |
License: GPLv2 or later
|
10 |
|
11 |
Meta Box plugin is a powerful, professional developer toolkit to create custom meta boxes and custom fields for your custom post types in WordPress.
|
168 |
|
169 |
== Changelog ==
|
170 |
|
171 |
+
= 5.6.0 - 2022-03-01 =
|
172 |
+
- Field `background` and `file_input`: support showing image thumbnail
|
173 |
+
- Add `link` param in helper functions for `taxonomy`, `post`, `user` fields to show `view`, `edit` link or plain text (`false`)
|
174 |
+
- Add support for float values for range field
|
175 |
+
- Add `minlength` as a common props for fields
|
176 |
+
- Remove FILTER_SANITIZE_STRING to compatible with PHP 8
|
177 |
+
- Fix PHP notice when run rwmb_the_value() for taxonomy field with no values
|
178 |
+
|
179 |
= 5.5.1 - 2021-12-15 =
|
180 |
- Fix warning for post field caused by the search by post title
|
181 |
|