PluginProbe
TablePress – Tables in WordPress made easy / 3.4
TablePress – Tables in WordPress made easy v3.4
3.4 3.3.4 3.3.3 3.3.2 3.3.1 trunk 1.12 1.14 1.9.2 2.0.4 2.1.7 2.1.8 2.2 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3 2.3.1 2.3.2 2.4 2.4.1 2.4.2 2.4.3 All 45 releases
← All changes | admin/js/add.js +11 -51 1.12 → 3.4 View file →
@@ -1,59 +1,19 @@
1 1 /**
2 - * JavaScript code for the "Add New" screen
2 + * JavaScript code for the "Add New" screen.
3 3 *
4 4 * @package TablePress
5 5 * @subpackage Views JavaScript
6 6 * @author Tobias Bäthge
7 - * @since 1.0.0
7 + * @since 3.0.0
8 8 */
9 9
10 -/* global validateForm */
10 +/**
11 + * Internal dependencies.
12 + */
13 +import { initializeReactComponent } from './common/react-loader';
14 +import Screen from './add/screen';
11 15
12 -jQuery( document ).ready( function( $ ) {
13 -
14 - 'use strict';
15 -
16 - /**
17 - * Check, whether entered numbers for rows and columns are valid
18 - *
19 - * @since 1.0.0
20 - */
21 - $( '#tablepress-page' ).find( 'form' ).on( 'submit', function( /* event */ ) {
22 - var valid_form = true;
23 -
24 - // WordPress validation function, checks if required fields (.form-required) are non-empty
25 - if ( ! validateForm( $(this) ) ) {
26 - valid_form = false;
27 - }
28 -
29 - // validate numerical values (.form-field-numbers-only): only 1 < x < 9...9 (up to maxlength) are allowed
30 - $( '#tablepress-page' ).find( '.form-field-numbers-only' ).find( 'input' ).each( function() {
31 - var $field = $(this),
32 - maxlength = parseInt( $field.attr( 'maxlength' ), 10 ),
33 - regexp_number;
34 -
35 - if ( ! isNaN( maxlength ) ) {
36 - maxlength += -1; // first number is handled already in RegExp
37 - } else {
38 - maxlength = '';
39 - }
40 -
41 - regexp_number = new RegExp( '^[1-9][0-9]{0,' + maxlength + '}$' );
42 - if ( regexp_number.test( $field.val() ) ) {
43 - return; // field is valid
44 - }
45 -
46 - $field
47 - .one( 'change', function() { $(this).closest( '.form-invalid' ).removeClass( 'form-invalid' ); } )
48 - .focus().select()
49 - .closest( '.form-field' ).addClass( 'form-invalid' );
50 - valid_form = false;
51 - } );
52 -
53 - // Don't submit the form if it's not valid.
54 - if ( ! valid_form ) {
55 - return false;
56 - }
57 - } );
58 -
59 -} );
16 +initializeReactComponent(
17 + 'tablepress-add-screen',
18 + <Screen />
19 +);