WP Table Builder – WordPress Table Plugin - Version 1.1.3

Version Description

ADD: Custom HTML Element. ADD: Shortcode Element. ADD: Double Click On Cell to Add Text Element. ADD: Option to Change/Replace Image in Image Element. ADD: Option to Change Button Text Size. ADD: Frontend Link to Edit Table When Logged in. FIX: Image Height Issue / Image getting stretched. FIX: Bug in Cell Width Change function.

Download this release

Release Info

Developer imtiazrayhan
Plugin Icon 128x128 WP Table Builder – WordPress Table Plugin
Version 1.1.3
Comparing to
See all releases

Code changes from version 1.1.2 to 1.1.3

Files changed (41) hide show
  1. inc/admin/base/base-object.php +61 -0
  2. inc/admin/base/controls-stack.php +87 -0
  3. inc/admin/class-admin-menu.php +16 -4
  4. inc/admin/class-tables.php +55 -6
  5. inc/admin/class-wptb-listing.php +3 -0
  6. inc/admin/{element-classes/controls → controls}/base-control.php +1 -1
  7. inc/admin/{element-classes/controls → controls}/control-alignment.php +1 -1
  8. inc/admin/controls/control-button.php +94 -0
  9. inc/admin/{element-classes/controls → controls}/control-change-attribute.php +1 -1
  10. inc/admin/{element-classes/controls → controls}/control-checkbox.php +1 -1
  11. inc/admin/controls/control-color.php +234 -0
  12. inc/admin/controls/control-color2.php +312 -0
  13. inc/admin/{element-classes/controls → controls}/control-number.php +1 -1
  14. inc/admin/controls/control-section-header.php +95 -0
  15. inc/admin/{element-classes/controls → controls}/control-select.php +1 -1
  16. inc/admin/{element-classes/controls → controls}/control-size.php +24 -4
  17. inc/admin/{element-classes/controls → controls}/control-text.php +1 -1
  18. inc/admin/{element-classes/controls → controls}/control-textarea.php +7 -2
  19. inc/admin/{element-classes/controls → controls}/control-toggle.php +50 -11
  20. inc/admin/{element-classes/controls → controls}/control-url.php +1 -1
  21. inc/admin/css/admin.css +27 -7
  22. inc/admin/element-classes/base/element-base-object.php +3 -108
  23. inc/admin/element-classes/controls/control-color.php +0 -124
  24. inc/admin/element-classes/controls/control-section-header.php +0 -72
  25. inc/admin/element-classes/element-scripts/button-element.js +7 -6
  26. inc/admin/element-classes/element-scripts/custom-html-element.js +77 -0
  27. inc/admin/element-classes/element-scripts/image-element.js +81 -54
  28. inc/admin/element-classes/element-scripts/list-element.js +7 -7
  29. inc/admin/element-classes/element-scripts/shortcode-element.js +63 -0
  30. inc/admin/element-classes/element-scripts/star-rating-element.js +21 -6
  31. inc/admin/element-classes/element-scripts/text-element.js +22 -5
  32. inc/admin/element-classes/elements/button-element.php +26 -10
  33. inc/admin/element-classes/elements/custom-html-element.php +127 -0
  34. inc/admin/element-classes/elements/image-element.php +30 -2
  35. inc/admin/element-classes/elements/list-element.php +5 -4
  36. inc/admin/element-classes/elements/shortcode-element.php +125 -0
  37. inc/admin/element-classes/elements/star-rating-element.php +6 -9
  38. inc/admin/element-classes/elements/text-element.php +2 -1
  39. inc/admin/js/admin.js +962 -833
  40. inc/admin/js/admin.js.map +1 -1
  41. inc/admin/js/admin.min.js +1 -1
inc/admin/base/base-object.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace WP_Table_Builder\Inc\Admin\Base;
3
+ use WP_Table_Builder\Inc\Core\Init as Init;
4
+ use WP_Table_Builder as NS;
5
+
6
+ // If this file is called directly, abort.
7
+ if ( ! defined( 'WPINC' ) ) {
8
+ die;
9
+ }
10
+
11
+
12
+ /**
13
+ * WP Table Builder Base Object.
14
+ *
15
+ * @since 1.1.2
16
+ * @abstract
17
+ */
18
+ abstract class Base_Object {
19
+
20
+ /**
21
+ * Get element name.
22
+ *
23
+ * Retrieve the element name.
24
+ *
25
+ * @since 1.1.2
26
+ * @access public
27
+ * @abstract
28
+ *
29
+ * @return string The name.
30
+ */
31
+ abstract public function get_name();
32
+
33
+ /**
34
+ * Get unique name.
35
+ *
36
+ * Some classes need to use unique names, this method allows you to create
37
+ * them. By default it returns the regular name.
38
+ *
39
+ * @since 1.1.2
40
+ * @access public
41
+ *
42
+ * @return string Unique name.
43
+ */
44
+ public function get_unique_name() {
45
+ return $this->get_name();
46
+ }
47
+
48
+ /**
49
+ * Get element title.
50
+ *
51
+ * Retrieve the element title.
52
+ *
53
+ * @since 1.1.2
54
+ * @access public
55
+ *
56
+ * @return string element title.
57
+ */
58
+ public function get_title() {
59
+ return '';
60
+ }
61
+ }
inc/admin/base/controls-stack.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace WP_Table_Builder\Inc\Admin\Base;
3
+ use WP_Table_Builder\Inc\Admin\Base\Base_Object;
4
+ use WP_Table_Builder\Inc\Core\Init as Init;
5
+ use WP_Table_Builder as NS;
6
+
7
+ // If this file is called directly, abort.
8
+ if ( ! defined( 'WPINC' ) ) {
9
+ die;
10
+ }
11
+
12
+
13
+ /**
14
+ * WP Table Builder control stack.
15
+ *
16
+ * An abstract class that provides the needed properties and methods to
17
+ * manage and handle controls.
18
+ *
19
+ * @since 1.1.2
20
+ * @abstract
21
+ */
22
+ abstract class Controls_Stack extends Base_Object {
23
+
24
+ /**
25
+ * Get stack.
26
+ *
27
+ * Returns the stack of controls.
28
+ *
29
+ * @since 1.1.2
30
+ * @access public
31
+ *
32
+ * @return array Stack of controls.
33
+ */
34
+ public function get_stack() {
35
+ $stack = NS::init()->controls_manager->get_item_stack( $this );
36
+
37
+ if ( null === $stack ) {
38
+ $this->init_controls();
39
+
40
+ return NS::init()->controls_manager->get_item_stack( $this );
41
+ }
42
+
43
+ return $stack;
44
+ }
45
+
46
+ /**
47
+ * Register controls.
48
+ *
49
+ * Used to add new controls group to stack
50
+ *
51
+ * @since 1.1.2
52
+ * @access protected
53
+ */
54
+ protected function _register_controls() {}
55
+
56
+ /**
57
+ * Initialize controls.
58
+ *
59
+ * Register the all controls added by `_register_controls()`.
60
+ *
61
+ * @since 1.1.2
62
+ * @access protected
63
+ */
64
+ public function init_controls() {
65
+ $this->_register_controls();
66
+ }
67
+
68
+ /**
69
+ * Add new control to stack.
70
+ *
71
+ * Register a single control to allow the user to set/update data.
72
+ *
73
+ * This method should be used inside `_register_controls()`.
74
+ *
75
+ * @since 1.1.2
76
+ * @access public
77
+ *
78
+ * @param string $id Control ID.
79
+ * @param array $args Control arguments.
80
+ *
81
+ * @return bool True if control added, False otherwise.
82
+ */
83
+
84
+ public function add_control( $id, array $args ) {
85
+ return Init::instance()->controls_manager->add_control_to_stack( $this, $id, $args );
86
+ }
87
+ }
inc/admin/class-admin-menu.php CHANGED
@@ -45,6 +45,7 @@ class Admin_Menu {
45
  $params = json_decode( file_get_contents( 'php://input' ) );
46
 
47
  if( wp_verify_nonce( $params->security_code, 'wptb-security-nonce' ) ) {
 
48
  if( ! isset( $params->id ) || ! absint( $params->id ) || ! get_post_meta( absint( $params->id ) , '_wptb_content_', true ) ) {
49
  $id = wp_insert_post([
50
  'post_title' => sanitize_text_field( $params->title ),
@@ -52,9 +53,11 @@ class Admin_Menu {
52
  'post_type' => 'wptb-tables',
53
  'post_status' => 'draft'
54
  ]);
 
55
  add_post_meta( $id, '_wptb_content_', $params->content );
56
  add_post_meta( $id, '_wptb_table_elements_datas_', $params->elements_datas );
57
- wp_die( json_encode( ['saved',$id] ) );
 
58
  } else {
59
  wp_update_post([
60
  'ID' => absint( $params->id ),
@@ -63,9 +66,18 @@ class Admin_Menu {
63
  'post_type' => 'wptb-tables',
64
  'post_status' => 'draft'
65
  ]);
66
- update_post_meta( absint( $params->id ), '_wptb_content_', $params->content );
67
- update_post_meta( absint( $params->id ), '_wptb_table_elements_datas_', $params->elements_datas );
68
- wp_die( json_encode( ['edited',''] ) );
 
 
 
 
 
 
 
 
 
69
  }
70
  } else {
71
  wp_die( json_encode( ['security_problem', ''] ) );
45
  $params = json_decode( file_get_contents( 'php://input' ) );
46
 
47
  if( wp_verify_nonce( $params->security_code, 'wptb-security-nonce' ) ) {
48
+
49
  if( ! isset( $params->id ) || ! absint( $params->id ) || ! get_post_meta( absint( $params->id ) , '_wptb_content_', true ) ) {
50
  $id = wp_insert_post([
51
  'post_title' => sanitize_text_field( $params->title ),
53
  'post_type' => 'wptb-tables',
54
  'post_status' => 'draft'
55
  ]);
56
+
57
  add_post_meta( $id, '_wptb_content_', $params->content );
58
  add_post_meta( $id, '_wptb_table_elements_datas_', $params->elements_datas );
59
+
60
+ wp_die( json_encode( ['saved', $id] ) );
61
  } else {
62
  wp_update_post([
63
  'ID' => absint( $params->id ),
66
  'post_type' => 'wptb-tables',
67
  'post_status' => 'draft'
68
  ]);
69
+
70
+ if( isset( $params->preview_saving ) && ! empty( (int)$params->preview_saving ) ) {
71
+ update_post_meta( absint( $params->id ), '_wptb_preview_id_', $params->preview_saving );
72
+ update_post_meta( absint( $params->id ), '_wptb_content_preview_', $params->content );
73
+
74
+ wp_die( json_encode( ['preview_edited'] ) );
75
+ } else {
76
+ update_post_meta( absint( $params->id ), '_wptb_content_', $params->content );
77
+ update_post_meta( absint( $params->id ), '_wptb_table_elements_datas_', $params->elements_datas );
78
+
79
+ wp_die( json_encode( ['edited', absint( $params->id )] ) );
80
+ }
81
  }
82
  } else {
83
  wp_die( json_encode( ['security_problem', ''] ) );
inc/admin/class-tables.php CHANGED
@@ -94,23 +94,72 @@ class Tables {
94
  // Register the post type
95
  register_post_type( 'wptb-tables', $args );
96
  add_shortcode( 'wptb', array( $this, 'get_table' ) );
97
-
98
  }
99
 
100
  public function get_table( $args ) {
101
  do_action( 'wptb_frontend_enqueue_style' );
102
  do_action( 'wptb_frontend_enqueue_script' );
103
- //$uniqueSequence = 't'.substr( md5(time()),0,8 );
104
  $html = get_post_meta( $args['id'] , '_wptb_content_', true );
105
- //$html = json_decode( $html );
106
- $html = '<div class="wptb-table-container wptb-table-' . $args['id'] . '"><div class="wptb-table-container-matrix">' . $html . '</div></div>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
107
  $html .= '<script>'
108
  . 'var wptbContainer = document.getElementsByClassName( "wptb-table-' . $args['id'] . '" );'
109
  . 'if( wptbContainer.length > 0 ) {'
110
  . ' wptbContainer = wptbContainer[0];'
111
  . ' var wptbPreviewTable = wptbContainer.getElementsByClassName( "wptb-preview-table" );'
112
- . ' wptbPreviewTable[0].classList.remove( "wptb-table-preview-static-indic" );'
113
- . ' wptbPreviewTable[0].style.display = "none";'
 
 
114
  . '}'
115
  . '</script>';
116
  return ( $html );
94
  // Register the post type
95
  register_post_type( 'wptb-tables', $args );
96
  add_shortcode( 'wptb', array( $this, 'get_table' ) );
 
97
  }
98
 
99
  public function get_table( $args ) {
100
  do_action( 'wptb_frontend_enqueue_style' );
101
  do_action( 'wptb_frontend_enqueue_script' );
 
102
  $html = get_post_meta( $args['id'] , '_wptb_content_', true );
103
+
104
+ // prepating html encoding for looking for shortcodes using DOMDocument
105
+ $html_encoding = mb_detect_encoding( $html );
106
+ if( $html_encoding != 'UTF-8' ) {
107
+ $html = mb_convert_encoding( $html, "UTF-8", $html_encoding );
108
+ }
109
+
110
+ $html = mb_convert_encoding( $html, 'HTML-ENTITIES', 'utf-8' );
111
+
112
+ $dom = new \DOMDocument( '1.0', 'UTF-8' );
113
+ $dom->validateOnParse = true;
114
+ $dom->encoding="UTF-8";
115
+ $dom->loadHTML( $html );
116
+ $divs = $dom->getElementsByTagName( 'div' );
117
+ $shortcodes = array();
118
+ foreach ( $divs as $div ) {
119
+ $classes = $div->getAttribute( 'class' );
120
+ if ( strpos( $classes, 'wptb-shortcode-container' ) !== false ) {
121
+ $div_outer_html = trim( $div->ownerDocument->saveHTML( $div ) );
122
+
123
+ if( ! isset( $args['internal_shortcodes_stop'] ) && $div_outer_html ) {
124
+ $pattern = get_shortcode_regex();
125
+
126
+ if ( preg_match_all( '/'. $pattern .'/s', $div_outer_html, $matches ) ) {
127
+
128
+ for( $i = 0; $i < count( $matches[0] ); $i++ ) {
129
+ $shortcode = $matches[0][$i];
130
+ if( $matches[2][$i] == 'wptb' ) {
131
+
132
+ $shortcode = str_replace( ']' , ' internal_shortcodes_stop="1"]' , $matches[0][$i] );
133
+
134
+ $div_outer_html_new = str_replace( $matches[0][$i] , $shortcode , $div_outer_html );
135
+
136
+ $html = str_replace( $div_outer_html, $div_outer_html_new, $html );
137
+
138
+ $html = str_replace( $div_outer_html_new, do_shortcode( $div_outer_html_new ), $html );
139
+ } else {
140
+ $html = str_replace( $div_outer_html, do_shortcode( $div_outer_html ), $html );
141
+ }
142
+ }
143
+ }
144
+ }
145
+ }
146
+ }
147
+
148
+ $post_edit_link;
149
+ if( current_user_can( 'manage_options' ) ){
150
+ $post_edit_link = '<div class="wptb-frontend-table-edit-link">'
151
+ . '<a href="' . admin_url( 'admin.php?page=wptb-builder&table=' . $args['id'] ) . '">' . __( "Edit Table", 'wp-table-builder' ) . '</a></div>';
152
+ }
153
+ $html = '<div class="wptb-table-container wptb-table-' . $args['id'] . '"><div class="wptb-table-container-matrix">' . $html . '</div></div>'. $post_edit_link;
154
  $html .= '<script>'
155
  . 'var wptbContainer = document.getElementsByClassName( "wptb-table-' . $args['id'] . '" );'
156
  . 'if( wptbContainer.length > 0 ) {'
157
  . ' wptbContainer = wptbContainer[0];'
158
  . ' var wptbPreviewTable = wptbContainer.getElementsByClassName( "wptb-preview-table" );'
159
+ . ' if( wptbPreviewTable.length > 0 ) {'
160
+ . ' wptbPreviewTable[0].classList.remove( "wptb-table-preview-static-indic" );'
161
+ . ' wptbPreviewTable[0].style.display = "none";'
162
+ . ' }'
163
  . '}'
164
  . '</script>';
165
  return ( $html );
inc/admin/class-wptb-listing.php CHANGED
@@ -58,9 +58,11 @@ class WPTB_Listing extends \WP_List_Table{
58
  ]);
59
  $table = get_post_meta( absint( $id ) , '_wptb_content_', true );
60
  $elements_datas = get_post_meta( absint( $id ) , '_wptb_table_elements_datas_', true );
 
61
 
62
  $table_new = add_post_meta( $id_new, '_wptb_content_', $table );
63
  $elements_datas_new = add_post_meta( $id_new , '_wptb_table_elements_datas_', $elements_datas );
 
64
 
65
  if( $id_new && $table_new ) {
66
  wp_update_post([
@@ -147,6 +149,7 @@ class WPTB_Listing extends \WP_List_Table{
147
  array(
148
  'post_type' => 'wptb-tables',
149
  'p' => absint( $item->ID ),
 
150
  ),
151
  home_url()
152
  );
58
  ]);
59
  $table = get_post_meta( absint( $id ) , '_wptb_content_', true );
60
  $elements_datas = get_post_meta( absint( $id ) , '_wptb_table_elements_datas_', true );
61
+ $elements_styles = get_post_meta( absint( $id ) , '_wptb_table_elements_styles_', true );
62
 
63
  $table_new = add_post_meta( $id_new, '_wptb_content_', $table );
64
  $elements_datas_new = add_post_meta( $id_new , '_wptb_table_elements_datas_', $elements_datas );
65
+ $elements_datas_new = add_post_meta( $id_new , '_wptb_table_elements_styles_', $elements_styles );
66
 
67
  if( $id_new && $table_new ) {
68
  wp_update_post([
149
  array(
150
  'post_type' => 'wptb-tables',
151
  'p' => absint( $item->ID ),
152
+ '_wpnonce' => $nonce,
153
  ),
154
  home_url()
155
  );
inc/admin/{element-classes/controls → controls}/base-control.php RENAMED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace WP_Table_Builder\Inc\Admin\Element_Classes\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
1
  <?php
2
+ namespace WP_Table_Builder\Inc\Admin\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
inc/admin/{element-classes/controls → controls}/control-alignment.php RENAMED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace WP_Table_Builder\Inc\Admin\Element_Classes\Controls;
3
  use WP_Table_Builder as NS;
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
1
  <?php
2
+ namespace WP_Table_Builder\Inc\Admin\Controls;
3
  use WP_Table_Builder as NS;
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
inc/admin/controls/control-button.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace WP_Table_Builder\Inc\Admin\Controls;
3
+
4
+ // If this file is called directly, abort.
5
+ if ( ! defined( 'WPINC' ) ) {
6
+ die;
7
+ }
8
+
9
+ /**
10
+ * WP Table Builder "Button" control.
11
+ *
12
+ * A control class for creating "button" control object
13
+ *
14
+ * @since 1.1.2
15
+ */
16
+ class Control_Button extends Base_Control {
17
+ /**
18
+ * Get "Button" control type.
19
+ *
20
+ * @since 1.1.2
21
+ * @access public
22
+ *
23
+ * @return string Control type.
24
+ */
25
+ public function get_type() {
26
+ return 'button';
27
+ }
28
+
29
+ /**
30
+ * Enqueue "button" control scripts and styles.
31
+ *
32
+ * Used to register and enqueue custom scripts and styles used by the control.
33
+ *
34
+ * @since 1.1.2
35
+ * @access public
36
+ */
37
+ public function enqueue() {
38
+
39
+ }
40
+
41
+ /**
42
+ * Render "button" control output in the editor.
43
+ *
44
+ * Used to generate the control HTML in the editor wp js template
45
+ *
46
+ * @since 1.1.2
47
+ * @access public
48
+ */
49
+ public function content_template() {
50
+ ?>
51
+ <#
52
+ let label,
53
+ elemContainer;
54
+
55
+ if( data.label ) {
56
+ label = data.label;
57
+ }
58
+
59
+ if( data.elemContainer ) {
60
+ elemContainer = data.elemContainer;
61
+ }
62
+
63
+ targetInputAddClass = data.elementControlTargetUnicClass;
64
+ #>
65
+
66
+ <div class="wptb-settings-row wptb-settings-middle-xs">
67
+ <div class="wptb-settings-col-xs-12" style="margin: auto; text-align: center;">
68
+ <input type="button" class="wptb-button {{{targetInputAddClass}}}" data-element="{{{elemContainer}}}" value="{{{label}}}" title="{{{label}}}">
69
+ </div>
70
+ </div>
71
+
72
+ <wptb-template-script>
73
+ ( function() {
74
+ let targetInputs = document.getElementsByClassName( '{{{targetInputAddClass}}}' );
75
+ if( targetInputs.length > 0 ) {
76
+ targetInput = targetInputs[0];
77
+ let dataSelectorElement = targetInput.dataset.element;
78
+ if( dataSelectorElement ) {
79
+ let selectorElement = document.querySelector( '.' + dataSelectorElement );
80
+ if( selectorElement ) {
81
+ targetInput.onclick = function( event ) {
82
+ WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement );
83
+ };
84
+
85
+ WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}' );
86
+ }
87
+ }
88
+ }
89
+ } )();
90
+ </wptb-template-script>
91
+
92
+ <?php
93
+ }
94
+ }
inc/admin/{element-classes/controls → controls}/control-change-attribute.php RENAMED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace WP_Table_Builder\Inc\Admin\Element_Classes\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
1
  <?php
2
+ namespace WP_Table_Builder\Inc\Admin\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
inc/admin/{element-classes/controls → controls}/control-checkbox.php RENAMED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace WP_Table_Builder\Inc\Admin\Element_Classes\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
1
  <?php
2
+ namespace WP_Table_Builder\Inc\Admin\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
inc/admin/controls/control-color.php ADDED
@@ -0,0 +1,234 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace WP_Table_Builder\Inc\Admin\Controls;
3
+
4
+ // If this file is called directly, abort.
5
+ if ( ! defined( 'WPINC' ) ) {
6
+ die;
7
+ }
8
+
9
+ /**
10
+ * WP Table Builder color control.
11
+ *
12
+ * A Control class for creating color control. Displays a color picker field.
13
+ * When this control adds to element there is opportunity to point css type (color, backgroundColor ...)
14
+ *
15
+ * @since 1.1.2
16
+ */
17
+ class Control_Color extends Base_Control {
18
+ /**
19
+ * Get control type.
20
+ *
21
+ * @since 1.1.2
22
+ * @access public
23
+ *
24
+ * @return string Control type.
25
+ */
26
+ public function get_type() {
27
+ return 'color';
28
+ }
29
+
30
+ /**
31
+ * Enqueue color control scripts and styles.
32
+ *
33
+ * Used to register and enqueue custom scripts and styles used by the color
34
+ * control.
35
+ *
36
+ * @since 1.1.2
37
+ * @access public
38
+ */
39
+ public function enqueue() {
40
+
41
+ }
42
+
43
+ /**
44
+ * Render color control output in the editor.
45
+ *
46
+ * Used to generate the control HTML in the editor wp js template
47
+ *
48
+ * @since 1.1.2
49
+ * @access public
50
+ */
51
+ public function content_template() {
52
+ ?>
53
+ <#
54
+ let label,
55
+ name,
56
+ selectors = [],
57
+ elemContainer,
58
+ targetInputAddClass;
59
+
60
+ if( data.label ) {
61
+ label = data.label;
62
+ }
63
+
64
+ if( data.name ) {
65
+ name = data.name;
66
+ }
67
+
68
+ let i = 0;
69
+ for ( let prop in data.selectors ) {
70
+ selectors[i] = [];
71
+ selectors[i][0] = prop;
72
+ selectors[i][1] = data.selectors[prop];
73
+ i++;
74
+ }
75
+
76
+ if( selectors && Array.isArray( selectors ) ) {
77
+ selectorsJson = JSON.stringify( selectors );
78
+ }
79
+
80
+ if( data.elemContainer ) {
81
+ elemContainer = data.elemContainer;
82
+ }
83
+
84
+ targetInputAddClass = data.elementControlTargetUnicClass;
85
+ let dataJson = JSON.stringify( data );
86
+ #>
87
+ <div class='wptb-settings-item-header' >
88
+ <p class="wptb-settings-item-title">{{{label}}}</p>
89
+ </div>
90
+ <div class="wptb-settings-row wptb-settings-middle-xs" style="padding-top: 25px; padding-bottom: 10px;">
91
+ <div class='wptb-settings-col-xs-8'>
92
+ <input type="text" class="wptb-element-property wptb-color-picker {{{targetInputAddClass}}}"
93
+ data-element="{{{elemContainer}}}" data-type="color" value=""/>
94
+ </div>
95
+ </div>
96
+
97
+ <wptb-template-script>
98
+ ( function() {
99
+ let targetInput = document.querySelector( '.{{{targetInputAddClass}}}' );
100
+ let dataSelectorElement = targetInput.dataset.element;
101
+ let selectorElement = document.querySelector( '.' + dataSelectorElement );
102
+
103
+ function wpColorPickerCheckChangeForTableStateSaving( event ) {
104
+ if( event.originalEvent.type == 'external' ||
105
+ ( event.originalEvent.type == 'click' && event.target.value == 'Clear' ) ) {
106
+ let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
107
+ wptbTableStateSaveManager.tableStateSet();
108
+ } else {
109
+ let wpPickerContainer = WPTB_Helper.findAncestor( event.target, 'wp-picker-container' );
110
+ if( wpPickerContainer ) {
111
+ if( event.originalEvent.type == 'square' || event.originalEvent.type == 'strip' ) {
112
+ let body = document.getElementsByTagName( 'body' )[0];
113
+ body.removeEventListener( 'mouseup', WPTB_Helper.irisStripMouseUpStateSaveManager, false );
114
+ body.addEventListener( 'mouseup', WPTB_Helper.irisStripMouseUpStateSaveManager, false );
115
+ }
116
+ }
117
+ }
118
+ }
119
+
120
+ if( targetInput && selectorElement ) {
121
+ if( '{{{selectorsJson}}}' ) {
122
+ let selectors = JSON.parse( '{{{selectorsJson}}}' );
123
+
124
+ let thisColorCss;
125
+ for( let i = 0; i < selectors.length; i++ ) {
126
+ if( selectors[i] && Array.isArray( selectors[i] ) && selectors[i][0] && selectors[i][1] ) {
127
+ let selectorElements = document.querySelectorAll( selectors[i][0] );
128
+ if( selectorElements.length > 0 ) {
129
+ for( let j = 0; j < selectorElements.length; j++ ) {
130
+ if( selectors[i][1] ) {
131
+ if( Array.isArray( selectors[i][1] ) ) {
132
+ for( let k = 0; k < selectors[i][1].length; k++ ) {
133
+ if( selectorElements[j].style[selectors[i][1][k]] ) {
134
+ thisColorCss = selectorElements[j].style[selectors[i][1][k]];
135
+ thisColorCssHex = WPTB_Helper.rgbToHex( thisColorCss );
136
+ if( thisColorCssHex ) {
137
+ thisColorCss = thisColorCssHex;
138
+ }
139
+ if( ! WPTB_Helper.isHex( thisColorCss ) ) {
140
+ thisColorCss = '';
141
+ }
142
+ selectorElements[j].style[selectors[i][1][k]] = thisColorCss;
143
+ }
144
+ }
145
+ } else {
146
+ if( selectorElements[j].style[selectors[i][1]] ) {
147
+ thisColorCss = selectorElements[j].style[selectors[i][1]];
148
+ thisColorCssHex = WPTB_Helper.rgbToHex( thisColorCss );
149
+ if( thisColorCssHex ) {
150
+ thisColorCss = thisColorCssHex;
151
+ }
152
+ if( ! WPTB_Helper.isHex( thisColorCss ) ) {
153
+ thisColorCss = '';
154
+ }
155
+ selectorElements[j].style[selectors[i][1]] = thisColorCss;
156
+ }
157
+ }
158
+
159
+ if( thisColorCss ) {
160
+ targetInput.value = thisColorCss;
161
+ }
162
+ }
163
+ }
164
+ }
165
+ }
166
+ }
167
+
168
+ jQuery( '.{{{targetInputAddClass}}}' ).wpColorPicker({
169
+ change: function ( event, ui ) {
170
+ let uiColor;
171
+ if( ui ) {
172
+ uiColor = ui.color.toString();
173
+ } else {
174
+ uiColor = '';
175
+ }
176
+
177
+ for( let i = 0; i < selectors.length; i++ ) {
178
+ if( selectors[i] && Array.isArray( selectors[i] ) && selectors[i][0] && selectors[i][1] ) {
179
+ let selectorElements = document.querySelectorAll( selectors[i][0] );
180
+ if( selectorElements.length > 0 ) {
181
+ for( let j = 0; j < selectorElements.length; j++ ) {
182
+ if( selectors[i][1] ) {
183
+ if( Array.isArray( selectors[i][1] ) ) {
184
+ for( let k = 0; k < selectors[i][1].length; k++ ) {
185
+ selectorElements[j].style[selectors[i][1][k]] = uiColor;
186
+ }
187
+ } else {
188
+ selectorElements[j].style[selectors[i][1]] = uiColor;
189
+ }
190
+ }
191
+ }
192
+ }
193
+ }
194
+ }
195
+
196
+ let targetInput = document.getElementsByClassName( '{{{targetInputAddClass}}}' );
197
+ if( targetInput.length > 0 ) {
198
+ targetInput = targetInput[0];
199
+ targetInput.value = uiColor;
200
+ }
201
+ WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement );
202
+ wpColorPickerCheckChangeForTableStateSaving( event );
203
+ },
204
+ clear: function( event ) {
205
+ for( let i = 0; i < selectors.length; i++ ) {
206
+ if( selectors[i] && Array.isArray( selectors[i] ) && selectors[i][0] && selectors[i][1] ) {
207
+ let selectorElements = document.querySelectorAll( selectors[i][0] );
208
+ if( selectorElements.length > 0 ) {
209
+ for( let j = 0; j < selectorElements.length; j++ ) {
210
+ if( selectors[i][1] ) {
211
+ if( Array.isArray( selectors[i][1] ) ) {
212
+ for( let k = 0; k < selectors[i][1].length; k++ ) {
213
+ selectorElements[j].style[selectors[i][1][k]] = '';
214
+ }
215
+ } else {
216
+ selectorElements[j].style[selectors[i][1]] = '';
217
+ }
218
+ }
219
+ }
220
+ }
221
+ }
222
+ }
223
+
224
+ WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement );
225
+ wpColorPickerCheckChangeForTableStateSaving( event );
226
+ }
227
+ });
228
+ }
229
+ }
230
+ } )();
231
+ </wptb-template-script>
232
+ <?php
233
+ }
234
+ }
inc/admin/controls/control-color2.php ADDED
@@ -0,0 +1,312 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace WP_Table_Builder\Inc\Admin\Controls;
3
+
4
+ // If this file is called directly, abort.
5
+ if ( ! defined( 'WPINC' ) ) {
6
+ die;
7
+ }
8
+
9
+ /**
10
+ * WP Table Builder color control.
11
+ *
12
+ * A Control class for creating color control. Displays a color picker field.
13
+ * When this control adds to element there is opportunity to point css type (color, backgroundColor ...)
14
+ *
15
+ * @since 1.1.2
16
+ */
17
+ class Control_Color extends Base_Control {
18
+ /**
19
+ * Get control type.
20
+ *
21
+ * @since 1.1.2
22
+ * @access public
23
+ *
24
+ * @return string Control type.
25
+ */
26
+ public function get_type() {
27
+ return 'color';
28
+ }
29
+
30
+ /**
31
+ * Enqueue color control scripts and styles.
32
+ *
33
+ * Used to register and enqueue custom scripts and styles used by the color
34
+ * control.
35
+ *
36
+ * @since 1.1.2
37
+ * @access public
38
+ */
39
+ public function enqueue() {
40
+
41
+ }
42
+
43
+ /**
44
+ * Render color control output in the editor.
45
+ *
46
+ * Used to generate the control HTML in the editor wp js template
47
+ *
48
+ * @since 1.1.2
49
+ * @access public
50
+ */
51
+ public function content_template() {
52
+ ?>
53
+ <#
54
+ let label,
55
+ name,
56
+ selectors = [],
57
+ elemContainer,
58
+ targetInputAddClass;
59
+
60
+ if( data.label ) {
61
+ label = data.label;
62
+ }
63
+
64
+ if( data.name ) {
65
+ name = data.name;
66
+ }
67
+
68
+ let i = 0;
69
+ for ( let prop in data.selectors ) {
70
+ selectors[i] = [];
71
+ selectors[i][0] = prop;
72
+ selectors[i][1] = data.selectors[prop];
73
+ i++;
74
+ }
75
+
76
+ if( selectors && Array.isArray( selectors ) ) {
77
+ selectorsJson = JSON.stringify( selectors );
78
+ }
79
+
80
+ if( data.elemContainer ) {
81
+ elemContainer = data.elemContainer;
82
+ }
83
+
84
+ targetInputAddClass = data.elementControlTargetUnicClass;
85
+ let dataJson = JSON.stringify( data );
86
+ #>
87
+ <div class='wptb-settings-item-header' >
88
+ <p class="wptb-settings-item-title">{{{label}}}</p>
89
+ </div>
90
+ <div class="wptb-settings-row wptb-settings-middle-xs" style="padding-top: 25px; padding-bottom: 10px;">
91
+ <div class='wptb-settings-col-xs-8'>
92
+ <input type="text" class="wptb-element-property wptb-color-picker {{{targetInputAddClass}}}"
93
+ data-element="{{{elemContainer}}}" data-type="color" value=""/>
94
+ </div>
95
+ </div>
96
+
97
+ <wptb-template-script>
98
+ ( function() {
99
+ let targetInput = document.querySelector( '.{{{targetInputAddClass}}}' );
100
+ let dataSelectorElement = targetInput.dataset.element;
101
+ let selectorElement = document.querySelector( '.' + dataSelectorElement );
102
+
103
+ function wpColorPickerCheckChangeForTableStateSaving( event ) {
104
+ if( event.originalEvent.type == 'external' ||
105
+ ( event.originalEvent.type == 'click' && event.target.value == 'Clear' ) ) {
106
+ let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
107
+ wptbTableStateSaveManager.tableStateSet();
108
+ } else {
109
+ let wpPickerContainer = WPTB_Helper.findAncestor( event.target, 'wp-picker-container' );
110
+ if( wpPickerContainer ) {
111
+ if( event.originalEvent.type == 'square' || event.originalEvent.type == 'strip' ) {
112
+ let body = document.getElementsByTagName( 'body' )[0];
113
+ body.removeEventListener( 'mouseup', WPTB_Helper.irisStripMouseUpStateSaveManager, false );
114
+ body.addEventListener( 'mouseup', WPTB_Helper.irisStripMouseUpStateSaveManager, false );
115
+ }
116
+ }
117
+ }
118
+ }
119
+
120
+ if( targetInput && selectorElement ) {
121
+ WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}' );
122
+ if( '{{{selectorsJson}}}' ) {
123
+ let selectors = JSON.parse( '{{{selectorsJson}}}' );
124
+
125
+ let thisColorCss;
126
+ let targetInputSetColorIndic = false;
127
+ for( let i = 0; i < selectors.length; i++ ) {
128
+ if( selectors[i] && Array.isArray( selectors[i] ) && selectors[i][0] && selectors[i][1] ) {
129
+ let selectorElements = document.querySelectorAll( selectors[i][0] );
130
+ if( selectorElements.length > 0 ) {
131
+ for( let j = 0; j < selectorElements.length; j++ ) {
132
+ if( selectors[i][1] ) {
133
+ if( Array.isArray( selectors[i][1] ) ) {
134
+ for( let k = 0; k < selectors[i][1].length; k++ ) {
135
+ if( selectorElements[j].style[selectors[i][1][k]] ) {
136
+ thisColorCss = selectorElements[j].style[selectors[i][1][k]];
137
+ console.log(thisColorCss);
138
+ thisColorCssHex = WPTB_Helper.rgbToHex( thisColorCss );
139
+ if( thisColorCssHex ) {
140
+ thisColorCss = thisColorCssHex;
141
+
142
+ }
143
+ if( ! WPTB_Helper.isHex( thisColorCss ) ) {
144
+ thisColorCss = '';
145
+ }
146
+ WPTB_Helper.managerExternalCssStyles( dataSelectorElement, selectors[i][0], selectors[i][1][k], thisColorCss );
147
+ selectorElements[j].style[selectors[i][1][k]] = '';
148
+ }
149
+ }
150
+ } else {
151
+ if( selectorElements[j].style[selectors[i][1]] ) {
152
+ thisColorCss = selectorElements[j].style[selectors[i][1]];
153
+ thisColorCssHex = WPTB_Helper.rgbToHex( thisColorCss );
154
+ if( thisColorCssHex ) {
155
+ thisColorCss = thisColorCssHex;
156
+ }
157
+ WPTB_Helper.managerExternalCssStyles( dataSelectorElement, selectors[i][0], selectors[i][1], thisColorCss );
158
+ selectorElements[j].style[selectors[i][1]] = '';
159
+ }
160
+ }
161
+
162
+ if( thisColorCss && ! targetInputSetColorIndic ) {
163
+ targetInput.value = thisColorCss;
164
+ WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}', true );
165
+ console.log("Hello");
166
+ targetInputSetColorIndic = true;
167
+ }
168
+ }
169
+ }
170
+ }
171
+ }
172
+ }
173
+
174
+ WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}' );
175
+ if( targetInputSetColorIndic ) {
176
+ let wptbDlementDatas = document.getElementsByClassName( 'wptb-element-datas' );
177
+ if( wptbDlementDatas.length > 0 ) {
178
+ wptbDlementDatas = wptbDlementDatas.innerHTML;
179
+ } else {
180
+ wptbDlementDatas = '';
181
+ }
182
+ if( window.wptbTableStateSaving && Array.isArray( window.wptbTableStateSaving ) ) {
183
+ let lastElem = window.wptbTableStateSaving[window.wptbTableStateSaving.length - 1];
184
+ let wptbPreviewTable = document.getElementsByClassName( 'wptb-preview-table' );
185
+ if( wptbPreviewTable.length > 0 ) {
186
+ wptbPreviewTable = wptbPreviewTable[0];
187
+
188
+ let wptbNewPreviewTable = wptbPreviewTable.cloneNode( true );
189
+ let mceContentBodys = wptbNewPreviewTable.querySelectorAll( '.mce-content-body' );
190
+ if( mceContentBodys.length > 0 ) {
191
+ for ( let k = 0; k < mceContentBodys.length; k++ ) {
192
+ mceContentBodys[k].classList.remove( 'mce-content-body' );
193
+ }
194
+ }
195
+
196
+ let dataMceStyle = wptbNewPreviewTable.querySelectorAll( '[data-mce-style]' );
197
+ if ( dataMceStyle.length > 0 ) {
198
+ for ( let k = 0; k < dataMceStyle.length; k++ ) {
199
+ dataMceStyle[k].removeAttribute( 'data-mce-style' );
200
+ }
201
+ }
202
+
203
+ let mceIds = wptbNewPreviewTable.querySelectorAll( '[id^=mce_]' );
204
+ if ( mceIds.length > 0 ) {
205
+ for ( let k = 0; k < mceIds.length; k++ ) {
206
+ mceIds[k].removeAttribute( 'id' );
207
+ }
208
+ }
209
+
210
+ lastElem[0] = wptbNewPreviewTable;
211
+ }
212
+
213
+ lastElem[2] = wptbDlementDatas;
214
+ let styleObjJson = WPTB_Helper.elementsStylesConvertToObject();
215
+ lastElem[3] = styleObjJson;
216
+ window.wptbTableStateSaving[window.wptbTableStateSaving.length - 1] = lastElem;
217
+ }
218
+ }
219
+
220
+ jQuery( '.{{{targetInputAddClass}}}' ).wpColorPicker({
221
+ change: function ( event, ui ) {
222
+ let uiColor;
223
+ if( ui ) {
224
+ uiColor = ui.color.toString();
225
+ } else {
226
+ uiColor = '';
227
+ }
228
+
229
+ for( let i = 0; i < selectors.length; i++ ) {
230
+ if( selectors[i] && Array.isArray( selectors[i] ) && selectors[i][0] && selectors[i][1] ) {
231
+ let selectorElements = document.querySelectorAll( selectors[i][0] );
232
+ if( selectorElements.length > 0 ) {
233
+ for( let j = 0; j < selectorElements.length; j++ ) {
234
+ if( selectors[i][1] ) {
235
+ if( Array.isArray( selectors[i][1] ) ) {
236
+ for( let k = 0; k < selectors[i][1].length; k++ ) {
237
+ selectorElements[j].style[selectors[i][1][k]] = '';
238
+ WPTB_Helper.managerExternalCssStyles( dataSelectorElement, selectors[i][0], selectors[i][1][k], uiColor );
239
+ }
240
+ } else {
241
+ selectorElements[j].style[selectors[i][1]] = '';
242
+ WPTB_Helper.managerExternalCssStyles( dataSelectorElement, selectors[i][0], selectors[i][1], uiColor );
243
+ }
244
+ }
245
+ }
246
+ } else {
247
+ if( selectors[i][0] && selectors[i][1] ) {
248
+ if( Array.isArray( selectors[i][1] ) ) {
249
+ for( let k = 0; k < selectors[i][1].length; k++ ) {
250
+ WPTB_Helper.managerExternalCssStyles( dataSelectorElement, selectors[i][0], selectors[i][1][k], uiColor );
251
+ }
252
+ } else {
253
+ WPTB_Helper.managerExternalCssStyles( dataSelectorElement, selectors[i][0], selectors[i][1], uiColor );
254
+ }
255
+ }
256
+ }
257
+ }
258
+ }
259
+
260
+ let targetInput = document.getElementsByClassName( '{{{targetInputAddClass}}}' );
261
+ if( targetInput.length > 0 ) {
262
+ targetInput = targetInput[0];
263
+ targetInput.value = uiColor;
264
+ }
265
+ WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement );
266
+ WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}', true );
267
+ wpColorPickerCheckChangeForTableStateSaving( event );
268
+ },
269
+ clear: function( event ) {
270
+ for( let i = 0; i < selectors.length; i++ ) {
271
+ if( selectors[i] && Array.isArray( selectors[i] ) && selectors[i][0] && selectors[i][1] ) {
272
+ let selectorElements = document.querySelectorAll( selectors[i][0] );
273
+ if( selectorElements.length > 0 ) {
274
+ for( let j = 0; j < selectorElements.length; j++ ) {
275
+ if( selectors[i][1] ) {
276
+ if( Array.isArray( selectors[i][1] ) ) {
277
+ for( let k = 0; k < selectors[i][1].length; k++ ) {
278
+ selectorElements[j].style[selectors[i][1][k]] = '';
279
+ WPTB_Helper.managerExternalCssStyles( dataSelectorElement, selectors[i][0], selectors[i][1][k], '' );
280
+ }
281
+ } else {
282
+ selectorElements[j].style[selectors[i][1]] = '';
283
+ WPTB_Helper.managerExternalCssStyles( dataSelectorElement, selectors[i][0], selectors[i][1], '' );
284
+ }
285
+ }
286
+ }
287
+ } else {
288
+ if( selectors[i][0] && selectors[i][1] ) {
289
+ if( Array.isArray( selectors[i][1] ) ) {
290
+ for( let k = 0; k < selectors[i][1].length; k++ ) {
291
+ WPTB_Helper.managerExternalCssStyles( dataSelectorElement, selectors[i][0], selectors[i][1][k], '' );
292
+ }
293
+ } else {
294
+ WPTB_Helper.managerExternalCssStyles( dataSelectorElement, selectors[i][0], selectors[i][1], '' );
295
+ }
296
+ }
297
+ }
298
+ }
299
+ }
300
+
301
+ WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement );
302
+ WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}', true );
303
+ wpColorPickerCheckChangeForTableStateSaving( event );
304
+ }
305
+ });
306
+ }
307
+ }
308
+ } )();
309
+ </wptb-template-script>
310
+ <?php
311
+ }
312
+ }
inc/admin/{element-classes/controls → controls}/control-number.php RENAMED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace WP_Table_Builder\Inc\Admin\Element_Classes\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
1
  <?php
2
+ namespace WP_Table_Builder\Inc\Admin\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
inc/admin/controls/control-section-header.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace WP_Table_Builder\Inc\Admin\Controls;
3
+
4
+ // If this file is called directly, abort.
5
+ if ( ! defined( 'WPINC' ) ) {
6
+ die;
7
+ }
8
+
9
+ /**
10
+ * WP Table Builder section header control.
11
+ *
12
+ * A control class for creating a Section Header control object to show the header of the control panel of the element.
13
+ *
14
+ * @since 1.1.2
15
+ */
16
+ class Control_Section_Header extends Base_Control {
17
+ /**
18
+ * Get control type.
19
+ *
20
+ * @since 1.1.2
21
+ * @access public
22
+ *
23
+ * @return string Control type.
24
+ */
25
+ public function get_type() {
26
+ return 'section_header';
27
+ }
28
+
29
+ /**
30
+ * Enqueue control scripts and styles.
31
+ *
32
+ * Used to register and enqueue custom scripts and styles used by the section header control.
33
+ *
34
+ * @since 1.1.2
35
+ * @access public
36
+ */
37
+ public function enqueue() {
38
+
39
+ }
40
+
41
+ /**
42
+ * Render section header control output in the editor.
43
+ *
44
+ * Used to generate the control HTML in the editor wp js template
45
+ *
46
+ * @since 1.1.2
47
+ * @access public
48
+ */
49
+ public function content_template() {
50
+ ?>
51
+ <#
52
+ let label,
53
+ buttonBack;
54
+ if( data.label ) {
55
+ label = data.label;
56
+ }
57
+
58
+ if( data.buttonBack ) {
59
+ buttonBack = data.buttonBack;
60
+ }
61
+ #>
62
+ <div class="wptb-settings-dropdown">
63
+ <#
64
+ if( buttonBack ) {
65
+ #>
66
+ <div class="wptb-back-button">
67
+ <a href="javascript:void(0)" title="Back" class="wptb-exit-options" >
68
+ <svg pointer-events="none" width="12px" height="12px" x="0px" y="0px" viewBox="0 0 477.175 477.175"
69
+ style="enable-background:new 0 0 477.175 477.175;" xml:space="preserve">
70
+ <g>
71
+ <path d="M145.188,238.575l215.5-215.5c5.3-5.3,5.3-13.8,0-19.1s-13.8-5.3-19.1,0l-225.1,225.1c-5.3,5.3-5.3,13.8,0,19.1l225.1,225
72
+ c2.6,2.6,6.1,4,9.5,4s6.9-1.3,9.5-4c5.3-5.3,5.3-13.8,0-19.1L145.188,238.575z"/>
73
+ </g>
74
+ </svg>
75
+ </a>
76
+ </div>
77
+ <#
78
+ }
79
+ #>
80
+ <div class="wptb-option-text">{{{label}}}</div>
81
+ </div>
82
+
83
+ <wptb-template-script>
84
+ ( function() {
85
+ if( '{{{buttonBack}}}' && '{{{buttonBack}}}' == 'true' ) {
86
+ document.querySelector('.wptb-back-button').addEventListener('click', function (event) {
87
+ WPTB_Helper.clickOnFreeSpace();
88
+ });
89
+ }
90
+ } )();
91
+ </wptb-template-script>
92
+
93
+ <?php
94
+ }
95
+ }
inc/admin/{element-classes/controls → controls}/control-select.php RENAMED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace WP_Table_Builder\Inc\Admin\Element_Classes\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
1
  <?php
2
+ namespace WP_Table_Builder\Inc\Admin\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
inc/admin/{element-classes/controls → controls}/control-size.php RENAMED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace WP_Table_Builder\Inc\Admin\Element_Classes\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
@@ -59,7 +59,9 @@ class Control_Size extends Base_Control {
59
  max,
60
  min,
61
  defaultValue,
62
- dimension;
 
 
63
 
64
  if( data.selectors && typeof data.selectors === 'object' ) {
65
  for ( let prop in data.selectors ) {
@@ -92,6 +94,14 @@ class Control_Size extends Base_Control {
92
  dimension = 'px';
93
  }
94
 
 
 
 
 
 
 
 
 
95
  targetInputAddClass = data.elementControlTargetUnicClass;
96
  #>
97
 
@@ -135,7 +145,12 @@ class Control_Size extends Base_Control {
135
  if( selectorElements.length > 0 ) {
136
  for( let i = 0; i < selectorElements.length; i++ ) {
137
  for( let j = 0; j < cssSettingArr.length; j++ ) {
138
- selectorElements[i].style[cssSettingArr[j]] = this.value + '{{{dimension}}}';
 
 
 
 
 
139
  }
140
  }
141
  };
@@ -146,8 +161,13 @@ class Control_Size extends Base_Control {
146
  }
147
  };
148
  } else if( targetInputs[i].classList.contains( 'wptb-number-input' ) ) {
149
- WPTB_Helper.numberImputSize( targetInputs[i], '{{{max}}}'.length - 1, '{{{max}}}' );
150
  targetInputs[i].oninput = function( event ) {
 
 
 
 
 
 
151
  this.parentNode.parentNode.getElementsByClassName('wptb-size-slider')[0].value = this.value;
152
  this.parentNode.parentNode.getElementsByClassName('wptb-size-slider')[0].oninput( event );
153
  }
1
  <?php
2
+ namespace WP_Table_Builder\Inc\Admin\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
59
  max,
60
  min,
61
  defaultValue,
62
+ dimension,
63
+ addText,
64
+ whenZero;
65
 
66
  if( data.selectors && typeof data.selectors === 'object' ) {
67
  for ( let prop in data.selectors ) {
94
  dimension = 'px';
95
  }
96
 
97
+ if( data.addText ) {
98
+ addText = data.addText;
99
+ }
100
+
101
+ if( data.whenZero ) {
102
+ whenZero = data.whenZero;
103
+ }
104
+
105
  targetInputAddClass = data.elementControlTargetUnicClass;
106
  #>
107
 
145
  if( selectorElements.length > 0 ) {
146
  for( let i = 0; i < selectorElements.length; i++ ) {
147
  for( let j = 0; j < cssSettingArr.length; j++ ) {
148
+ if( this.value == 0 && '{{{whenZero}}}' ) {
149
+ selectorElements[i].style[cssSettingArr[j]] = '{{{whenZero}}}';
150
+ continue;
151
+ }
152
+
153
+ selectorElements[i].style[cssSettingArr[j]] = this.value + '{{{dimension}}}' + '{{{addText}}}';
154
  }
155
  }
156
  };
161
  }
162
  };
163
  } else if( targetInputs[i].classList.contains( 'wptb-number-input' ) ) {
 
164
  targetInputs[i].oninput = function( event ) {
165
+ if( parseInt( this.value ) < parseInt( '{{{min}}}' ) ) {
166
+ this.value = parseInt( '{{{min}}}' );
167
+ } else if( parseInt( this.value ) > parseInt( '{{{max}}}' ) ) {
168
+ this.value = parseInt ( '{{{max}}}' );
169
+ }
170
+
171
  this.parentNode.parentNode.getElementsByClassName('wptb-size-slider')[0].value = this.value;
172
  this.parentNode.parentNode.getElementsByClassName('wptb-size-slider')[0].oninput( event );
173
  }
inc/admin/{element-classes/controls → controls}/control-text.php RENAMED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace WP_Table_Builder\Inc\Admin\Element_Classes\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
1
  <?php
2
+ namespace WP_Table_Builder\Inc\Admin\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
inc/admin/{element-classes/controls → controls}/control-textarea.php RENAMED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace WP_Table_Builder\Inc\Admin\Element_Classes\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
@@ -54,6 +54,7 @@ class Control_Textarea extends Base_Control {
54
  placeholder,
55
  rows,
56
  cols,
 
57
  elemContainer,
58
  targetTextareaAddClass = '';
59
 
@@ -69,6 +70,10 @@ class Control_Textarea extends Base_Control {
69
  cols = data.cols;
70
  }
71
 
 
 
 
 
72
  if( data.placeholder ) {
73
  placeholder = data.placeholder;
74
  }
@@ -86,7 +91,7 @@ class Control_Textarea extends Base_Control {
86
  <div class="wptb-settings-row wptb-settings-middle-xs" style="padding-bottom: 12px; padding-top: 23px;">
87
  <div class="wptb-settings-col-xs-12">
88
  <textarea class="wptb-number wptb-element-property {{{targetTextareaAddClass}}}"
89
- rows="{{{rows}}}" cols="{{{cols}}}" placeholder="{{{placeholder}}}" data-element="{{{elemContainer}}}" style="width: 100%"></textarea>
90
  </div>
91
  </div>
92
 
1
  <?php
2
+ namespace WP_Table_Builder\Inc\Admin\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
54
  placeholder,
55
  rows,
56
  cols,
57
+ defaultValue,
58
  elemContainer,
59
  targetTextareaAddClass = '';
60
 
70
  cols = data.cols;
71
  }
72
 
73
+ if( data.defaultValue ) {
74
+ defaultValue = data.defaultValue;
75
+ }
76
+
77
  if( data.placeholder ) {
78
  placeholder = data.placeholder;
79
  }
91
  <div class="wptb-settings-row wptb-settings-middle-xs" style="padding-bottom: 12px; padding-top: 23px;">
92
  <div class="wptb-settings-col-xs-12">
93
  <textarea class="wptb-number wptb-element-property {{{targetTextareaAddClass}}}"
94
+ rows="{{{rows}}}" cols="{{{cols}}}" placeholder="{{{placeholder}}}" data-element="{{{elemContainer}}}" style="width: 100%">{{{defaultValue}}}</textarea>
95
  </div>
96
  </div>
97
 
inc/admin/{element-classes/controls → controls}/control-toggle.php RENAMED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace WP_Table_Builder\Inc\Admin\Element_Classes\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
@@ -49,16 +49,10 @@ class Control_Toggle extends Base_Control {
49
  public function content_template() {
50
  ?>
51
  <#
52
- let selector,
53
- cssSetting,
54
- elemContainer,
55
- label,
56
  selectors = [],
57
- selectorsJson;
58
-
59
- if( data.elemContainer ) {
60
- elemContainer = data.elemContainer;
61
- }
62
 
63
  if( data.label ) {
64
  label = data.label;
@@ -76,6 +70,10 @@ class Control_Toggle extends Base_Control {
76
  selectorsJson = JSON.stringify( selectors );
77
  }
78
 
 
 
 
 
79
  targetInputAddClass = data.elementControlTargetUnicClass;
80
  #>
81
 
@@ -106,7 +104,48 @@ class Control_Toggle extends Base_Control {
106
  }
107
 
108
  WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement, details );
109
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}', true );
111
 
112
  let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
1
  <?php
2
+ namespace WP_Table_Builder\Inc\Admin\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
49
  public function content_template() {
50
  ?>
51
  <#
52
+ let label,
53
+ selector,
 
 
54
  selectors = [],
55
+ elemContainer;
 
 
 
 
56
 
57
  if( data.label ) {
58
  label = data.label;
70
  selectorsJson = JSON.stringify( selectors );
71
  }
72
 
73
+ if( data.elemContainer ) {
74
+ elemContainer = data.elemContainer;
75
+ }
76
+
77
  targetInputAddClass = data.elementControlTargetUnicClass;
78
  #>
79
 
104
  }
105
 
106
  WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement, details );
107
+
108
+ if( '{{{selectorsJson}}}' ) {
109
+ let selectors = JSON.parse( '{{{selectorsJson}}}' );
110
+
111
+ if( selectors && Array.isArray( selectors ) ) {
112
+ for( let i = 0; i < selectors.length; i++ ) {
113
+ if( selectors[i] && Array.isArray( selectors[i] ) && selectors[i][0] && selectors[i][1] ) {
114
+ let selectorElements = document.querySelectorAll( selectors[i][0] );
115
+ if( selectorElements.length > 0 ) {
116
+ for( let j = 0; j < selectorElements.length; j++ ) {
117
+ if( selectors[i][1] && Array.isArray( selectors[i][1] ) ) {
118
+ if( selectors[i][1][0] && Array.isArray( selectors[i][1][0] ) ) {
119
+ for( let k = 0; k < selectors[i][1].length; k++ ) {
120
+ if( selectors[i][1][k][0] && selectors[i][1][k][1] && selectors[i][1][k][2] ) {
121
+ let styleValue;
122
+ if( details.value == 'checked' ) {
123
+ styleValue = selectors[i][1][k][1];
124
+ } else {
125
+ styleValue = selectors[i][1][k][2];
126
+ }
127
+ selectorElements[j].style[selectors[i][1][k][0]] = styleValue;
128
+ }
129
+ }
130
+ } else {
131
+ if( selectors[i][1][0] && selectors[i][1][1] && selectors[i][1][2] ) {
132
+ let styleValue;
133
+ if( details.value == 'checked' ) {
134
+ styleValue = selectors[i][1][1];
135
+ } else {
136
+ styleValue = selectors[i][1][2];
137
+ }
138
+ selectorElements[j].style[selectors[i][1][0]] = styleValue;
139
+ }
140
+ }
141
+ }
142
+ }
143
+ }
144
+ }
145
+ }
146
+ }
147
+ }
148
+
149
  WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}', true );
150
 
151
  let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
inc/admin/{element-classes/controls → controls}/control-url.php RENAMED
@@ -1,5 +1,5 @@
1
  <?php
2
- namespace WP_Table_Builder\Inc\Admin\Element_Classes\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
1
  <?php
2
+ namespace WP_Table_Builder\Inc\Admin\Controls;
3
 
4
  // If this file is called directly, abort.
5
  if ( ! defined( 'WPINC' ) ) {
inc/admin/css/admin.css CHANGED
@@ -16,7 +16,7 @@ body>img {
16
  .wptb-admin-container {
17
  background: #fff;
18
  color: #444;
19
- z-index: 100099;
20
  position: fixed;
21
  top: 0;
22
  bottom: 0;
@@ -1229,6 +1229,7 @@ table.wptb-table {
1229
  right: 0;
1230
  left: 0;
1231
  bottom: 0;
 
1232
  }
1233
 
1234
  .wptb-preview-table-manage-cells td:hover::after {
@@ -1350,7 +1351,7 @@ table.wptb-table {
1350
  left: 2px;
1351
  }
1352
 
1353
- .wptb-table-head td:empty::before {
1354
  content: 'Header';
1355
  }
1356
 
@@ -1359,6 +1360,7 @@ table.wptb-table {
1359
  border: 1px solid #fff0;
1360
  margin-top: 15px;
1361
  margin-bottom: 15px;
 
1362
  }
1363
 
1364
 
@@ -1379,6 +1381,16 @@ table.wptb-table {
1379
  max-width: 100%;
1380
  position: relative;
1381
  margin: auto;
 
 
 
 
 
 
 
 
 
 
1382
  }
1383
 
1384
  .wptb-image-wrapper::after {
@@ -1547,6 +1559,10 @@ table.wptb-table {
1547
 
1548
  /* customize tinymce Editor */
1549
 
 
 
 
 
1550
  .mce-tinymce.mce-tinymce-inline.mce-container.mce-panel {
1551
  left: 50% !important;
1552
  transform: translate(-50%, 0) !important;
@@ -1577,6 +1593,10 @@ table.wptb-table {
1577
  background: transparent !important;
1578
  }
1579
 
 
 
 
 
1580
  .wptb-droppable.wptb-cell ul,
1581
  .wptb-droppable.wptb-cell ol {
1582
  border: 1px solid transparent;
@@ -1695,7 +1715,7 @@ table.wptb-table {
1695
  font-size: 9pt;
1696
  display: none;
1697
  max-width: 70px;
1698
- z-index: 100101;
1699
  box-sizing: border-box;
1700
  }
1701
 
@@ -1764,7 +1784,7 @@ table.wptb-table {
1764
  .wptb-drop-handle {
1765
  height: 11px;
1766
  position: absolute;
1767
- z-index: 100100;
1768
  display: none;
1769
  }
1770
 
@@ -1788,7 +1808,7 @@ table.wptb-table {
1788
  position: absolute;
1789
  width: 1px;
1790
  height: 1px;
1791
- z-index: 100100;
1792
  }
1793
 
1794
  .wptb-drop-handle.wptb-moving-into-same-elem,
@@ -1864,7 +1884,7 @@ table.wptb-table {
1864
  transition: all 0.2s ease;
1865
  transition-property: left, top;
1866
  width: auto;
1867
- z-index: 110000;
1868
  }
1869
 
1870
  .wptb-range-input {
@@ -1895,7 +1915,7 @@ table.wptb-table {
1895
  z-index: 1;
1896
  }
1897
 
1898
- .wptb-table-head td.wptb-drop-here-empty:empty::before,
1899
  .wptb-row td.wptb-drop-here-empty:empty::before {
1900
  background-color: dodgerblue;
1901
  border: 1px solid dodgerblue;
16
  .wptb-admin-container {
17
  background: #fff;
18
  color: #444;
19
+ z-index: 10099;
20
  position: fixed;
21
  top: 0;
22
  bottom: 0;
1229
  right: 0;
1230
  left: 0;
1231
  bottom: 0;
1232
+ z-index: 100;
1233
  }
1234
 
1235
  .wptb-preview-table-manage-cells td:hover::after {
1351
  left: 2px;
1352
  }
1353
 
1354
+ .wptb-preview-table.wptb-table-preview-head .wptb-row:first-child td:empty::before {
1355
  content: 'Header';
1356
  }
1357
 
1360
  border: 1px solid #fff0;
1361
  margin-top: 15px;
1362
  margin-bottom: 15px;
1363
+ min-height: 15px;
1364
  }
1365
 
1366
 
1381
  max-width: 100%;
1382
  position: relative;
1383
  margin: auto;
1384
+ text-decoration: none;
1385
+ }
1386
+
1387
+ .wptb-icon-image-button {
1388
+ display: block;
1389
+ padding: 5px;
1390
+ background: #747d84;
1391
+ border-radius: 5px;
1392
+ color: black;
1393
+ cursor: pointer;
1394
  }
1395
 
1396
  .wptb-image-wrapper::after {
1559
 
1560
  /* customize tinymce Editor */
1561
 
1562
+ .mce-content-body {
1563
+ min-height: 19px;
1564
+ }
1565
+
1566
  .mce-tinymce.mce-tinymce-inline.mce-container.mce-panel {
1567
  left: 50% !important;
1568
  transform: translate(-50%, 0) !important;
1593
  background: transparent !important;
1594
  }
1595
 
1596
+ br[data-mce-bogus="1"] {
1597
+ display:none;
1598
+ }
1599
+
1600
  .wptb-droppable.wptb-cell ul,
1601
  .wptb-droppable.wptb-cell ol {
1602
  border: 1px solid transparent;
1715
  font-size: 9pt;
1716
  display: none;
1717
  max-width: 70px;
1718
+ z-index: 10101;
1719
  box-sizing: border-box;
1720
  }
1721
 
1784
  .wptb-drop-handle {
1785
  height: 11px;
1786
  position: absolute;
1787
+ z-index: 10100;
1788
  display: none;
1789
  }
1790
 
1808
  position: absolute;
1809
  width: 1px;
1810
  height: 1px;
1811
+ z-index: 10100;
1812
  }
1813
 
1814
  .wptb-drop-handle.wptb-moving-into-same-elem,
1884
  transition: all 0.2s ease;
1885
  transition-property: left, top;
1886
  width: auto;
1887
+ z-index: 11000;
1888
  }
1889
 
1890
  .wptb-range-input {
1915
  z-index: 1;
1916
  }
1917
 
1918
+ .wptb-preview-table.wptb-table-preview-head .wptb-row:first-child td.wptb-drop-here-empty:empty::before,
1919
  .wptb-row td.wptb-drop-here-empty:empty::before {
1920
  background-color: dodgerblue;
1921
  border: 1px solid dodgerblue;
inc/admin/element-classes/base/element-base-object.php CHANGED
@@ -1,5 +1,6 @@
1
  <?php
2
  namespace WP_Table_Builder\Inc\Admin\Element_Classes\Base;
 
3
  use WP_Table_Builder\Inc\Core\Init as Init;
4
  use WP_Table_Builder as NS;
5
 
@@ -19,49 +20,7 @@ if ( ! defined( 'WPINC' ) ) {
19
  * @since 1.1.2
20
  * @abstract
21
  */
22
- abstract class Element_Base_Object {
23
-
24
- /**
25
- * Get element name.
26
- *
27
- * Retrieve the element name.
28
- *
29
- * @since 1.1.2
30
- * @access public
31
- * @abstract
32
- *
33
- * @return string The name.
34
- */
35
- abstract public function get_name();
36
-
37
- /**
38
- * Get unique name.
39
- *
40
- * Some classes need to use unique names, this method allows you to create
41
- * them. By default it returns the regular name.
42
- *
43
- * @since 1.1.2
44
- * @access public
45
- *
46
- * @return string Unique name.
47
- */
48
- public function get_unique_name() {
49
- return $this->get_name();
50
- }
51
-
52
- /**
53
- * Get element title.
54
- *
55
- * Retrieve the item title.
56
- *
57
- * @since 1.1.2
58
- * @access public
59
- *
60
- * @return string Element title.
61
- */
62
- public function get_title() {
63
- return '';
64
- }
65
 
66
  /**
67
  * Get directory icon.
@@ -96,71 +55,7 @@ abstract class Element_Base_Object {
96
  public function element_script() {}
97
 
98
  /**
99
- * Get stack.
100
- *
101
- * Returns the stack of controls.
102
- *
103
- * @since 1.1.2
104
- * @access public
105
- *
106
- * @return array Stack of controls.
107
- */
108
- public function get_stack() {
109
- $stack = NS::init()->controls_manager->get_item_stack( $this );
110
-
111
- if ( null === $stack ) {
112
- $this->init_controls();
113
-
114
- return NS::init()->controls_manager->get_item_stack( $this );
115
- }
116
-
117
- return $stack;
118
- }
119
-
120
- /**
121
- * Register controls.
122
- *
123
- * Used to add new controls group to stack
124
- *
125
- * @since 1.1.2
126
- * @access protected
127
- */
128
- protected function _register_controls() {}
129
-
130
- /**
131
- * Initialize controls.
132
- *
133
- * Register the all controls added by `_register_controls()`.
134
- *
135
- * @since 1.1.2
136
- * @access protected
137
- */
138
- public function init_controls() {
139
- $this->_register_controls();
140
- }
141
-
142
- /**
143
- * Add new control to stack.
144
- *
145
- * Register a single control to allow the user to set/update data.
146
- *
147
- * This method should be used inside `_register_controls()`.
148
- *
149
- * @since 1.1.2
150
- * @access public
151
- *
152
- * @param string $id Control ID.
153
- * @param array $args Control arguments.
154
- *
155
- * @return bool True if control added, False otherwise.
156
- */
157
-
158
- public function add_control( $id, array $args ) {
159
- return Init::instance()->controls_manager->add_control_to_stack( $this, $id, $args );
160
- }
161
-
162
- /**
163
- * Render item output in the editor.
164
  *
165
  * Used to generate the live preview, using a wp js template
166
  *
1
  <?php
2
  namespace WP_Table_Builder\Inc\Admin\Element_Classes\Base;
3
+ use WP_Table_Builder\Inc\Admin\Base\Controls_Stack;
4
  use WP_Table_Builder\Inc\Core\Init as Init;
5
  use WP_Table_Builder as NS;
6
 
20
  * @since 1.1.2
21
  * @abstract
22
  */
23
+ abstract class Element_Base_Object extends Controls_Stack {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  /**
26
  * Get directory icon.
55
  public function element_script() {}
56
 
57
  /**
58
+ * Render element output in the editor.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  *
60
  * Used to generate the live preview, using a wp js template
61
  *
inc/admin/element-classes/controls/control-color.php DELETED
@@ -1,124 +0,0 @@
1
- <?php
2
- namespace WP_Table_Builder\Inc\Admin\Element_Classes\Controls;
3
-
4
- // If this file is called directly, abort.
5
- if ( ! defined( 'WPINC' ) ) {
6
- die;
7
- }
8
-
9
- /**
10
- * WP Table Builder color control.
11
- *
12
- * A Control class for creating color control. Displays a color picker field.
13
- * When this control adds to element there is opportunity to point css type (color, backgroundColor ...)
14
- *
15
- * @since 1.1.2
16
- */
17
- class Control_Color extends Base_Control {
18
- /**
19
- * Get control type.
20
- *
21
- * @since 1.1.2
22
- * @access public
23
- *
24
- * @return string Control type.
25
- */
26
- public function get_type() {
27
- return 'color';
28
- }
29
-
30
- /**
31
- * Enqueue color control scripts and styles.
32
- *
33
- * Used to register and enqueue custom scripts and styles used by the color
34
- * control.
35
- *
36
- * @since 1.1.2
37
- * @access public
38
- */
39
- public function enqueue() {
40
-
41
- }
42
-
43
- /**
44
- * Render color control output in the editor.
45
- *
46
- * Used to generate the control HTML in the editor wp js template
47
- *
48
- * @since 1.1.2
49
- * @access public
50
- */
51
- public function content_template() {
52
- ?>
53
- <#
54
- let label,
55
- selector,
56
- cssSetting,
57
- targetInputAddClass;
58
-
59
- if( data.label ) {
60
- label = data.label;
61
- }
62
-
63
- for ( let prop in data.selectors ) {
64
- selector = prop;
65
- cssSetting = data.selectors[prop];
66
- }
67
-
68
- targetInputAddClass = data.elementControlTargetUnicClass;
69
- #>
70
- <div class='wptb-settings-item-header' >
71
- <p class="wptb-settings-item-title">{{{label}}}</p>
72
- </div>
73
- <div class="wptb-settings-row wptb-settings-middle-xs" style="padding-top: 25px; padding-bottom: 10px;">
74
- <div class='wptb-settings-col-xs-8'>
75
- <input type="text" class="wptb-element-property wptb-color-picker {{{targetInputAddClass}}}" data-type="color" value=""/>
76
- </div>
77
- </div>
78
-
79
- <wptb-template-script>
80
- ( function() {
81
- let selectorElement = document.querySelector( '{{{selector}}}' );
82
- let targetInput = document.querySelector( '.{{{targetInputAddClass}}}' );
83
-
84
- if( selectorElement && targetInput ) {
85
- let selectorElementCss = selectorElement.style['{{{cssSetting}}}'];
86
- if( selectorElementCss ) {
87
- targetInput.value = WPTB_Helper.rgbToHex( selectorElementCss );
88
- }
89
- }
90
-
91
- jQuery( '.{{{targetInputAddClass}}}' ).wpColorPicker({
92
- change: function ( event, ui ) {
93
- let uiColor;
94
- if( ui ) {
95
- uiColor = ui.color.toString();
96
- } else {
97
- uiColor = '';
98
- }
99
-
100
- let selectorElements = document.querySelectorAll( '{{{selector}}}' );
101
- if( selectorElements.length > 0 ) {
102
- for( let i = 0; i < selectorElements.length; i++ ) {
103
- selectorElements[i].style['{{{cssSetting}}}'] = uiColor;
104
- }
105
- }
106
-
107
- WPTB_Helper.wpColorPickerCheckChangeForTableStateSaving( event );
108
- },
109
- clear: function( event ) {
110
- let selectorElements = document.querySelectorAll( '{{{selector}}}' );
111
- if( selectorElements.length > 0 ) {
112
- for( let i = 0; i < selectorElements.length; i++ ) {
113
- selectorElements[i].style['{{{cssSetting}}}'] = '';
114
- }
115
- }
116
-
117
- WPTB_Helper.wpColorPickerCheckChangeForTableStateSaving( event );
118
- }
119
- });
120
- } )();
121
- </wptb-template-script>
122
- <?php
123
- }
124
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/admin/element-classes/controls/control-section-header.php DELETED
@@ -1,72 +0,0 @@
1
- <?php
2
- namespace WP_Table_Builder\Inc\Admin\Element_Classes\Controls;
3
-
4
- // If this file is called directly, abort.
5
- if ( ! defined( 'WPINC' ) ) {
6
- die;
7
- }
8
-
9
- /**
10
- * WP Table Builder section header control.
11
- *
12
- * A control class for creating a Section Header control object to show the header of the control panel of the element.
13
- *
14
- * @since 1.1.2
15
- */
16
- class Control_Section_Header extends Base_Control {
17
- /**
18
- * Get control type.
19
- *
20
- * @since 1.1.2
21
- * @access public
22
- *
23
- * @return string Control type.
24
- */
25
- public function get_type() {
26
- return 'section_header';
27
- }
28
-
29
- /**
30
- * Enqueue control scripts and styles.
31
- *
32
- * Used to register and enqueue custom scripts and styles used by the section header control.
33
- *
34
- * @since 1.1.2
35
- * @access public
36
- */
37
- public function enqueue() {
38
-
39
- }
40
-
41
- /**
42
- * Render section header control output in the editor.
43
- *
44
- * Used to generate the control HTML in the editor wp js template
45
- *
46
- * @since 1.1.2
47
- * @access public
48
- */
49
- public function content_template() {
50
- ?>
51
- <#
52
- let label;
53
- if( data.label ) {
54
- label = data.label;
55
- }
56
- #>
57
- <div class="wptb-settings-dropdown">
58
- <div class="wptb-back-button">
59
- <a href="javascript:void(0)" title="Back" class="wptb-exit-options" >
60
- <svg pointer-events="none" width="12px" height="12px" x="0px" y="0px" viewBox="0 0 477.175 477.175"
61
- style="enable-background:new 0 0 477.175 477.175;" xml:space="preserve">
62
- <g>
63
- <path d="M145.188,238.575l215.5-215.5c5.3-5.3,5.3-13.8,0-19.1s-13.8-5.3-19.1,0l-225.1,225.1c-5.3,5.3-5.3,13.8,0,19.1l225.1,225
64
- c2.6,2.6,6.1,4,9.5,4s6.9-1.3,9.5-4c5.3-5.3,5.3-13.8,0-19.1L145.188,238.575z"/>
65
- </g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g><g></g></svg>
66
- </a>
67
- </div>
68
- <div class="wptb-option-text">{{{label}}}</div>
69
- </div>
70
- <?php
71
- }
72
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/admin/element-classes/element-scripts/button-element.js CHANGED
@@ -47,7 +47,7 @@ if( target ) {
47
  },
48
  init_instance_callback: function (editor) {
49
  window.currentEditor = editor;
50
- editor.on('focus', function (e) {
51
  var totalWidth = document.getElementsByClassName('wptb-builder-panel')[0].offsetWidth;
52
  if (window.currentEditor &&
53
  document.getElementById('wptb_builder').scrollTop >= 55 &&
@@ -60,6 +60,7 @@ if( target ) {
60
  delete document.getElementById('wpcd_fixed_toolbar').style.right;
61
  delete document.getElementById('wpcd_fixed_toolbar').style.top;
62
  }
 
63
  });
64
  }
65
  });
@@ -114,8 +115,8 @@ if( elementsSettingsTemplateJs.length > 0 ) {
114
  elementsSettings = elementsSettingsTemplateJs.innerHTML;
115
  if( elementsSettings ) {
116
  elementsSettings = JSON.parse( elementsSettings );
117
- if( typeof elementsSettings === 'object' && ( 'tmpl-wptb-element-datas-' + infArrEl[1] ) in elementsSettings ) {
118
- elementSettings = elementsSettings['tmpl-wptb-element-datas-' + infArrEl[1]];
119
  }
120
  }
121
  } else {
@@ -133,7 +134,7 @@ if( ! elementSettings ) {
133
  elementsSettings = {};
134
  }
135
 
136
- elementsSettings['tmpl-wptb-element-datas-' + infArrEl[1]] = {};
137
  let buttonId;
138
  let a = element.getElementsByTagName( 'a' );
139
  if( a.length > 0 ) {
@@ -141,9 +142,9 @@ if( ! elementSettings ) {
141
 
142
  if( a.hasAttribute( 'id' ) ) {
143
  buttonId = a.getAttribute( 'id' );
144
- elementsSettings['tmpl-wptb-element-datas-' + infArrEl[1]]['data-wptb-el-' + infArrEl[1] + '-button-id'] = buttonId;
145
  } else {
146
- elementsSettings['tmpl-wptb-element-datas-' + infArrEl[1]]['data-wptb-el-' + infArrEl[1] + '-button-id'] = '';
147
  }
148
 
149
  if( elementsSettings ) {
47
  },
48
  init_instance_callback: function (editor) {
49
  window.currentEditor = editor;
50
+ editor.on( 'focus', function (e) {
51
  var totalWidth = document.getElementsByClassName('wptb-builder-panel')[0].offsetWidth;
52
  if (window.currentEditor &&
53
  document.getElementById('wptb_builder').scrollTop >= 55 &&
60
  delete document.getElementById('wpcd_fixed_toolbar').style.right;
61
  delete document.getElementById('wpcd_fixed_toolbar').style.top;
62
  }
63
+ console.log('Hello555');
64
  });
65
  }
66
  });
115
  elementsSettings = elementsSettingsTemplateJs.innerHTML;
116
  if( elementsSettings ) {
117
  elementsSettings = JSON.parse( elementsSettings );
118
+ if( typeof elementsSettings === 'object' && ( 'tmpl-wptb-el-datas-' + infArrEl[1] ) in elementsSettings ) {
119
+ elementSettings = elementsSettings['tmpl-wptb-el-datas-' + infArrEl[1]];
120
  }
121
  }
122
  } else {
134
  elementsSettings = {};
135
  }
136
 
137
+ elementsSettings['tmpl-wptb-el-datas-' + infArrEl[1]] = {};
138
  let buttonId;
139
  let a = element.getElementsByTagName( 'a' );
140
  if( a.length > 0 ) {
142
 
143
  if( a.hasAttribute( 'id' ) ) {
144
  buttonId = a.getAttribute( 'id' );
145
+ elementsSettings['tmpl-wptb-el-datas-' + infArrEl[1]]['data-wptb-el-' + infArrEl[1] + '-button-id'] = buttonId;
146
  } else {
147
+ elementsSettings['tmpl-wptb-el-datas-' + infArrEl[1]]['data-wptb-el-' + infArrEl[1] + '-button-id'] = '';
148
  }
149
 
150
  if( elementsSettings ) {
inc/admin/element-classes/element-scripts/custom-html-element.js ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ let infArr = element.className.match( /wptb-element-((.+-)\d+)/i );
2
+ let controlKey = 'textarea';
3
+ let elementControlTargetUnicClass = 'wptb-el-' + infArr[1] + '-' + controlKey;
4
+
5
+ tinyMCE.init({
6
+ target: element.childNodes[0],
7
+ inline: true,
8
+ plugins: "code",
9
+ //dialog_type: "modal",
10
+ //theme: 'modern',
11
+ menubar: false,
12
+ force_br_newlines : false,
13
+ force_p_newlines : false,
14
+ forced_root_block : '',
15
+ paste_as_text: false,
16
+ toolbar: false,
17
+ extended_valid_elements: "svg[*],defs[*],pattern[*],desc[*],metadata[*],g[*],\n\
18
+ mask[*],path[*],line[*],marker[*],rect[*],circle[*],\n\
19
+ ellipse[*],polygon[*],polyline[*],linearGradient[*],\n\
20
+ radialGradient[*],stop[*],image[*],view[*],text[*],\n\
21
+ textPath[*],title[*],tspan[*],glyph[*],symbol[*],switch[*],use[*]",
22
+ setup: function ( ed ) {
23
+
24
+ ed.on( 'input', function( e ) {
25
+ let elementControlTextarea = document.getElementsByClassName( elementControlTargetUnicClass );
26
+ if( elementControlTextarea.length > 0 ) {
27
+ elementControlTextarea = elementControlTextarea[0];
28
+ elementControlTextarea.value = ed.targetElm.textContent;
29
+ }
30
+ WPTB_Helper.controlsStateManager( elementControlTargetUnicClass, true );
31
+ });
32
+
33
+ ed.on( 'focus', function( ) {
34
+ ed.targetElm.innerText = ed.targetElm.innerHTML;
35
+ });
36
+
37
+ ed.on( 'blur', function( ) {
38
+ ed.targetElm.innerHTML = ed.targetElm.innerText;
39
+ });
40
+
41
+ ed.on( 'keydown', function( e ) {
42
+ let div = e.target;
43
+ let divText = div.innerHTML.replace( /\s+/g, ' ' ).trim();
44
+ divText = divText.replace( /&nbsp;/g, '').trim();
45
+
46
+ if( ! window.htmlElemKeyDown ) {
47
+ window.htmlElemKeyDown = divText;
48
+ }
49
+ });
50
+
51
+ ed.on( 'keyup', function(e) {
52
+ console.log('keyup');
53
+ let div = e.target;
54
+ let divText = div.innerHTML.replace( /\s+/g, ' ' ).trim();
55
+ divText = divText.replace( /&nbsp;/g, '').trim();
56
+ if( divText !== window.htmlElemKeyDown ) {
57
+ e.target.onblur = function() {
58
+ let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
59
+ wptbTableStateSaveManager.tableStateSet();
60
+
61
+ window.htmlElemKeyDown = '';
62
+ e.target.onblur = '';
63
+ }
64
+ } else {
65
+ e.target.onblur = '';
66
+ }
67
+ });
68
+ }
69
+ });
70
+
71
+ element.addEventListener( 'wptb-control:' + elementControlTargetUnicClass, function( event ) {
72
+ let targetElm = element.getElementsByClassName( 'mce-content-body' );
73
+ if( targetElm.length > 0 ) {
74
+ targetElm = targetElm[0];
75
+ targetElm.innerHTML = event.detail.value;
76
+ }
77
+ }, false );
inc/admin/element-classes/element-scripts/image-element.js CHANGED
@@ -6,59 +6,84 @@ a.onclick = function( e ) {
6
  e.preventDefault();
7
  };
8
 
9
- let img = element.getElementsByTagName( 'img' );
10
- if( img.length > 0 ) {
11
- img = img[0];
12
- }
13
-
14
- let src;
15
- if( img.src ) {
16
- src = img.src;
17
- }
18
 
19
- file_frame = wp.media.frames.file_frame = wp.media({
20
- title: 'Select a image to upload',
21
- button: {
22
- text: 'Use this image'
23
- },
24
- multiple: false,
25
- frame: 'post'
26
- });
27
-
28
- let imageSetting = function( img, attachment ) {
29
- let imgSrc = attachment.url;
30
- let linkArr = imgSrc.split( ':' ),
31
- linkClean;
32
- if ( Array.isArray( linkArr ) && linkArr.length > 0 ) {
33
- linkClean = linkArr[linkArr.length - 1];
34
  }
35
- img.src = linkClean;
36
- img.height = attachment.height;
37
- img.width = attachment.width;
38
- img.style.width = '100%';
39
 
40
- let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
41
- wptbTableStateSaveManager.tableStateSet();
42
- };
 
 
 
 
 
43
 
44
- file_frame.on( 'select', function() {
45
- attachment = file_frame.state().props.toJSON();
46
- imageSetting( img, attachment );
47
- });
48
-
49
- file_frame.on( 'insert', function () {
50
- attachment = file_frame.state().get( 'selection' ).first().toJSON();
51
- imageSetting( img, attachment );
52
- });
53
-
54
- if ( src == undefined ) {
55
- file_frame.open();
56
- file_frame.menuItemVisibility( 'gallery', 'hide' );
57
- file_frame.menuItemVisibility( 'playlist', 'hide' ),
58
- file_frame.menuItemVisibility( 'video-playlist', 'hide' ),
59
- file_frame.menuItemVisibility( 'audio-playlist', 'hide' )
60
- } else {
61
- img.src = src;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  }
63
 
64
  function controlsChange( inputs, element ) {
@@ -70,6 +95,8 @@ function controlsChange( inputs, element ) {
70
  img = img[0];
71
  img.setAttribute( 'alt', imageAltValue );
72
  }
 
 
73
  }
74
  }
75
  }
@@ -86,8 +113,8 @@ if( elementsSettingsTemplateJs.length > 0 ) {
86
  elementsSettings = elementsSettingsTemplateJs.innerHTML;
87
  if( elementsSettings ) {
88
  elementsSettings = JSON.parse( elementsSettings );
89
- if( typeof elementsSettings === 'object' && ( 'tmpl-wptb-element-datas-' + infArrEl[1] ) in elementsSettings ) {
90
- elementSettings = elementsSettings['tmpl-wptb-element-datas-' + infArrEl[1]];
91
  }
92
  }
93
  } else {
@@ -103,7 +130,7 @@ if( ! elementSettings ) {
103
  elementsSettings = {};
104
  }
105
 
106
- elementsSettings['tmpl-wptb-element-datas-' + infArrEl[1]] = {};
107
  let imageAltText;
108
  let img = element.getElementsByTagName( 'img' );
109
  if( img.length > 0 ) {
@@ -111,9 +138,9 @@ if( ! elementSettings ) {
111
 
112
  if( img.hasAttribute( 'alt' ) ) {
113
  imageAltText = img.getAttribute( 'alt' );
114
- elementsSettings['tmpl-wptb-element-datas-' + infArrEl[1]]['data-wptb-el-' + infArrEl[1] + '-imageAlternativeText'] = imageAltText;
115
  } else {
116
- elementsSettings['tmpl-wptb-element-datas-' + infArrEl[1]]['data-wptb-el-' + infArrEl[1] + '-imageAlternativeText'] = '';
117
  }
118
  }
119
 
6
  e.preventDefault();
7
  };
8
 
9
+ let addMedia = function( element, imageChange = false ) {
10
+ let img = element.querySelector( 'img' );
 
 
 
 
 
 
 
11
 
12
+ let src;
13
+ if( img && img.src ) {
14
+ src = img.src;
 
 
 
 
 
 
 
 
 
 
 
 
15
  }
 
 
 
 
16
 
17
+ file_frame = wp.media.frames.file_frame = wp.media({
18
+ title: 'Select a image to upload',
19
+ button: {
20
+ text: 'Use this image'
21
+ },
22
+ multiple: false,
23
+ frame: 'post'
24
+ });
25
 
26
+ let imageSetting = function( img, attachment ) {
27
+ if( ! img ) {
28
+ img = document.createElement( 'img' );
29
+
30
+ let a = element.getElementsByTagName( 'a' );
31
+ if( a.length > 0 ) {
32
+ a = a[0];
33
+ a.innerHTML = '';
34
+
35
+ a.appendChild( img );
36
+ }
37
+ }
38
+ let imgSrc = attachment.url;
39
+ let linkArr = imgSrc.split( ':' ),
40
+ linkClean;
41
+ if ( Array.isArray( linkArr ) && linkArr.length > 0 ) {
42
+ linkClean = linkArr[linkArr.length - 1];
43
+ }
44
+ img.src = linkClean;
45
+ img.height = attachment.height;
46
+ img.width = attachment.width;
47
+ img.style.width = '100%';
48
+
49
+ element.classList.remove( 'wptb-elem-placeholder' );
50
+
51
+ let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
52
+ wptbTableStateSaveManager.tableStateSet();
53
+ };
54
+
55
+ file_frame.on( 'select', function() {
56
+ attachment = file_frame.state().props.toJSON();
57
+ imageSetting( img, attachment );
58
+ });
59
+
60
+ file_frame.on( 'insert', function () {
61
+ attachment = file_frame.state().get( 'selection' ).first().toJSON();
62
+ imageSetting( img, attachment );
63
+ });
64
+
65
+ if ( src == undefined || imageChange == true ) {
66
+ file_frame.open();
67
+ console.log(file_frame);
68
+ file_frame.menuItemVisibility( 'gallery', 'hide' );
69
+ file_frame.menuItemVisibility( 'playlist', 'hide' ),
70
+ file_frame.menuItemVisibility( 'video-playlist', 'hide' ),
71
+ file_frame.menuItemVisibility( 'audio-playlist', 'hide' )
72
+ } else {
73
+ img.src = src;
74
+ }
75
+ }
76
+
77
+ let iconImageButton = element.querySelector( '.wptb-icon-image-button' );
78
+ if( iconImageButton ) {
79
+ iconImageButton.onclick = function() {
80
+ addMedia( element, true );
81
+ }
82
+ }
83
+
84
+ if( iconImageButton && ! element.classList.contains( 'wptb-elem-placeholder' ) ) {
85
+ element.classList.add( 'wptb-elem-placeholder' );
86
+ addMedia( element );
87
  }
88
 
89
  function controlsChange( inputs, element ) {
95
  img = img[0];
96
  img.setAttribute( 'alt', imageAltValue );
97
  }
98
+ } else if( inputs.hasOwnProperty( 'imageReplaceButton' ) ) {
99
+ addMedia( element, true );
100
  }
101
  }
102
  }
113
  elementsSettings = elementsSettingsTemplateJs.innerHTML;
114
  if( elementsSettings ) {
115
  elementsSettings = JSON.parse( elementsSettings );
116
+ if( typeof elementsSettings === 'object' && ( 'tmpl-wptb-el-datas-' + infArrEl[1] ) in elementsSettings ) {
117
+ elementSettings = elementsSettings['tmpl-wptb-el-datas-' + infArrEl[1]];
118
  }
119
  }
120
  } else {
130
  elementsSettings = {};
131
  }
132
 
133
+ elementsSettings['tmpl-wptb-el-datas-' + infArrEl[1]] = {};
134
  let imageAltText;
135
  let img = element.getElementsByTagName( 'img' );
136
  if( img.length > 0 ) {
138
 
139
  if( img.hasAttribute( 'alt' ) ) {
140
  imageAltText = img.getAttribute( 'alt' );
141
+ elementsSettings['tmpl-wptb-el-datas-' + infArrEl[1]]['data-wptb-el-' + infArrEl[1] + '-imageAlternativeText'] = imageAltText;
142
  } else {
143
+ elementsSettings['tmpl-wptb-el-datas-' + infArrEl[1]]['data-wptb-el-' + infArrEl[1] + '-imageAlternativeText'] = '';
144
  }
145
  }
146
 
inc/admin/element-classes/element-scripts/list-element.js CHANGED
@@ -196,8 +196,8 @@ if( elementsSettingsTemplateJs.length > 0 ) {
196
  elementsSettings = elementsSettingsTemplateJs.innerHTML;
197
  if( elementsSettings ) {
198
  elementsSettings = JSON.parse( elementsSettings );
199
- if( typeof elementsSettings === 'object' && ( 'tmpl-wptb-element-datas-' + infArr[1] ) in elementsSettings ) {
200
- elementSettings = elementsSettings['tmpl-wptb-element-datas-' + infArr[1]];
201
  }
202
  }
203
  } else {
@@ -220,16 +220,16 @@ if( ! elementSettings ) {
220
  elementsSettings = {};
221
  }
222
 
223
- elementsSettings['tmpl-wptb-element-datas-' + infArr[1]] = {};
224
 
225
  let classAttr = p.className.match( /wptb-list-style-type-(.+)/i );
226
  if( classAttr && Array.isArray( classAttr ) ) {
227
  let listType = classAttr[0].replace( 'wptb-list-style-type-', '' );
228
- elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-select1'] = 'unordered';
229
- elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-select2'] = listType;
230
  } else {
231
- elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-select1'] = 'numbered';
232
- elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-select2'] = 'disc';
233
  }
234
 
235
  if( elementsSettings ) {
196
  elementsSettings = elementsSettingsTemplateJs.innerHTML;
197
  if( elementsSettings ) {
198
  elementsSettings = JSON.parse( elementsSettings );
199
+ if( typeof elementsSettings === 'object' && ( 'tmpl-wptb-el-datas-' + infArr[1] ) in elementsSettings ) {
200
+ elementSettings = elementsSettings['tmpl-wptb-el-datas-' + infArr[1]];
201
  }
202
  }
203
  } else {
220
  elementsSettings = {};
221
  }
222
 
223
+ elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] = {};
224
 
225
  let classAttr = p.className.match( /wptb-list-style-type-(.+)/i );
226
  if( classAttr && Array.isArray( classAttr ) ) {
227
  let listType = classAttr[0].replace( 'wptb-list-style-type-', '' );
228
+ elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-select1'] = 'unordered';
229
+ elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-select2'] = listType;
230
  } else {
231
+ elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-select1'] = 'numbered';
232
+ elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-select2'] = 'disc';
233
  }
234
 
235
  if( elementsSettings ) {
inc/admin/element-classes/element-scripts/shortcode-element.js ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ let infArr = element.className.match( /wptb-element-((.+-)\d+)/i );
2
+ let controlKey = 'textarea';
3
+ let elementControlTargetUnicClass = 'wptb-el-' + infArr[1] + '-' + controlKey;
4
+
5
+ tinyMCE.init({
6
+ target: element.childNodes[0],
7
+ inline: true,
8
+ plugins: "link, paste",
9
+ dialog_type: "modal",
10
+ theme: 'modern',
11
+ menubar: false,
12
+ force_br_newlines : false,
13
+ force_p_newlines : false,
14
+ forced_root_block : '',
15
+ paste_as_text: true,
16
+ toolbar: false,
17
+ setup : function( ed ) {
18
+
19
+ ed.on( 'input', function( e ) {
20
+ let elementControlTextarea = document.getElementsByClassName( elementControlTargetUnicClass );
21
+ if( elementControlTextarea.length > 0 ) {
22
+ elementControlTextarea = elementControlTextarea[0];
23
+ elementControlTextarea.value = ed.targetElm.textContent;
24
+ }
25
+ WPTB_Helper.controlsStateManager( elementControlTargetUnicClass, true );
26
+ });
27
+
28
+ ed.on( 'keydown', function( e ) {
29
+ let div = e.target;
30
+ let divText = div.innerHTML.replace( /\s+/g, ' ' ).trim();
31
+ divText = divText.replace( /&nbsp;/g, '').trim();
32
+
33
+ if( ! window.shortcodeElemKeyDown ) {
34
+ window.shortcodeElemKeyDown = divText;
35
+ }
36
+ });
37
+
38
+ ed.on( 'keyup', function(e) {
39
+ let div = e.target;
40
+ let divText = div.innerHTML.replace( /\s+/g, ' ' ).trim();
41
+ divText = divText.replace( /&nbsp;/g, '').trim();
42
+ if( divText !== window.shortcodeElemKeyDown ) {
43
+ e.target.onblur = function() {
44
+ let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
45
+ wptbTableStateSaveManager.tableStateSet();
46
+
47
+ window.shortcodeElemKeyDown = '';
48
+ e.target.onblur = '';
49
+ }
50
+ } else {
51
+ e.target.onblur = '';
52
+ }
53
+ });
54
+ }
55
+ });
56
+
57
+ element.addEventListener( 'wptb-control:' + elementControlTargetUnicClass, function( event ) {
58
+ let targetElm = element.getElementsByClassName( 'mce-content-body' );
59
+ if( targetElm.length > 0 ) {
60
+ targetElm = targetElm[0];
61
+ targetElm.innerText = event.detail.value;
62
+ }
63
+ }, false );
inc/admin/element-classes/element-scripts/star-rating-element.js CHANGED
@@ -153,6 +153,8 @@ function starRatingEventHandlersAdd( ratingStar ) {
153
  starRatingSelectHoverSet( event );
154
 
155
  let wptbStarRatingContainer = WPTB_Helper.findAncestor( event.target, 'wptb-star_rating-container' );
 
 
156
 
157
  starRatingNumberRatingChenge( wptbStarRatingContainer );
158
 
@@ -183,6 +185,19 @@ function starRatingNumberRatingChenge( starRatingContainer ) {
183
  };
184
 
185
  // for old elements which were before the change of structure of the plugin
 
 
 
 
 
 
 
 
 
 
 
 
 
186
  let infArr = element.className.match( /wptb-element-((.+-)\d+)/i );
187
  let elementsSettingsTemplateJs = document.getElementsByClassName( 'wptb-element-datas' );
188
  let elementsSettings;
@@ -192,8 +207,8 @@ if( elementsSettingsTemplateJs.length > 0 ) {
192
  elementsSettings = elementsSettingsTemplateJs.innerHTML;
193
  if( elementsSettings ) {
194
  elementsSettings = JSON.parse( elementsSettings );
195
- if( typeof elementsSettings === 'object' && ( 'tmpl-wptb-element-datas-' + infArr[1] ) in elementsSettings ) {
196
- elementSettings = elementsSettings['tmpl-wptb-element-datas-' + infArr[1]];
197
  }
198
  }
199
  } else {
@@ -211,12 +226,12 @@ if( ! elementSettings ) {
211
  elementsSettings = {};
212
  }
213
 
214
- elementsSettings['tmpl-wptb-element-datas-' + infArr[1]] = {};
215
 
216
  let listItems = element.querySelectorAll( 'li' );
217
  let listItemsNumber = listItems.length;
218
  if( listItemsNumber > 0 ) {
219
- elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-starCount'] = listItemsNumber;
220
  }
221
 
222
  let wptbSuccessBox = element.querySelector( '.wptb-success-box' );
@@ -229,9 +244,9 @@ if( ! elementSettings ) {
229
  }
230
 
231
  if( wptbSuccessBox.style.display == 'block' ) {
232
- elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-numberRatingShowHide'] = 'checked';
233
  } else if( wptbSuccessBox.style.display == 'none' ) {
234
- elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-numberRatingShowHide'] = 'unchecked';
235
  }
236
  }
237
 
153
  starRatingSelectHoverSet( event );
154
 
155
  let wptbStarRatingContainer = WPTB_Helper.findAncestor( event.target, 'wptb-star_rating-container' );
156
+
157
+
158
 
159
  starRatingNumberRatingChenge( wptbStarRatingContainer );
160
 
185
  };
186
 
187
  // for old elements which were before the change of structure of the plugin
188
+
189
+ let spans = element.querySelectorAll( 'li span' );
190
+ for( let i = 0; i < spans.length; i++ ) {
191
+ if( spans[i].style.fill ) {
192
+ let svgElem = spans[i].querySelector( 'svg' );
193
+ if( svgElem && ! svgElem.style.fill ) {
194
+ svgElem.style.fill = spans[i].style.fill;
195
+ }
196
+
197
+ spans[i].style.fill = '';
198
+ }
199
+ }
200
+
201
  let infArr = element.className.match( /wptb-element-((.+-)\d+)/i );
202
  let elementsSettingsTemplateJs = document.getElementsByClassName( 'wptb-element-datas' );
203
  let elementsSettings;
207
  elementsSettings = elementsSettingsTemplateJs.innerHTML;
208
  if( elementsSettings ) {
209
  elementsSettings = JSON.parse( elementsSettings );
210
+ if( typeof elementsSettings === 'object' && ( 'tmpl-wptb-el-datas-' + infArr[1] ) in elementsSettings ) {
211
+ elementSettings = elementsSettings['tmpl-wptb-el-datas-' + infArr[1]];
212
  }
213
  }
214
  } else {
226
  elementsSettings = {};
227
  }
228
 
229
+ elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] = {};
230
 
231
  let listItems = element.querySelectorAll( 'li' );
232
  let listItemsNumber = listItems.length;
233
  if( listItemsNumber > 0 ) {
234
+ elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-starCount'] = listItemsNumber;
235
  }
236
 
237
  let wptbSuccessBox = element.querySelector( '.wptb-success-box' );
244
  }
245
 
246
  if( wptbSuccessBox.style.display == 'block' ) {
247
+ elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-numberRatingShowHide'] = 'checked';
248
  } else if( wptbSuccessBox.style.display == 'none' ) {
249
+ elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-numberRatingShowHide'] = 'unchecked';
250
  }
251
  }
252
 
inc/admin/element-classes/element-scripts/text-element.js CHANGED
@@ -14,12 +14,15 @@ tinyMCE.init({
14
  setup : function( ed ) {
15
  ed.on( 'change', function(e) {
16
  let row = WPTB_Helper.findAncestor( element, 'wptb-row' );
17
- if( row.classList.contains( 'wptb-table-head' ) ) {
18
  let table = WPTB_Helper.findAncestor( row, 'wptb-preview-table' );
19
- WPTB_Helper.dataTitleColumnSet( table );
 
 
 
20
  }
21
  });
22
- console.log("12345");
23
  ed.on( 'keydown', function( e ) {
24
  let p = e.target.querySelector( 'p' );
25
  let pText = p.innerHTML.replace( /\s+/g, ' ' ).trim();
@@ -29,6 +32,7 @@ tinyMCE.init({
29
  window.textElemPTextKeyDown = pText;
30
  }
31
  });
 
32
  ed.on( 'keyup', function(e) {
33
  let p = e.target.querySelector( 'p' );
34
  let pText = p.innerHTML.replace( /\s+/g, ' ' ).trim();
@@ -45,7 +49,6 @@ tinyMCE.init({
45
  e.target.onblur = '';
46
  }
47
  });
48
-
49
  },
50
  init_instance_callback: function (editor) {
51
  window.currentEditor = editor;
@@ -74,4 +77,18 @@ var observer = new MutationObserver( function( mutations ) {
74
  }
75
  });
76
  var config = { attributes: true, attributeFilter: ['style'] };
77
- observer.observe( element, config );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  setup : function( ed ) {
15
  ed.on( 'change', function(e) {
16
  let row = WPTB_Helper.findAncestor( element, 'wptb-row' );
17
+ if( WPTB_Helper.rowIsTop( row ) ) {
18
  let table = WPTB_Helper.findAncestor( row, 'wptb-preview-table' );
19
+
20
+ if( table.classList.contains( 'wptb-table-preview-head' ) ) {
21
+ WPTB_Helper.dataTitleColumnSet( table );
22
+ }
23
  }
24
  });
25
+
26
  ed.on( 'keydown', function( e ) {
27
  let p = e.target.querySelector( 'p' );
28
  let pText = p.innerHTML.replace( /\s+/g, ' ' ).trim();
32
  window.textElemPTextKeyDown = pText;
33
  }
34
  });
35
+
36
  ed.on( 'keyup', function(e) {
37
  let p = e.target.querySelector( 'p' );
38
  let pText = p.innerHTML.replace( /\s+/g, ' ' ).trim();
49
  e.target.onblur = '';
50
  }
51
  });
 
52
  },
53
  init_instance_callback: function (editor) {
54
  window.currentEditor = editor;
77
  }
78
  });
79
  var config = { attributes: true, attributeFilter: ['style'] };
80
+ observer.observe( element, config );
81
+
82
+ function controlsChange( inputs, element ) {
83
+ if( inputs && typeof inputs === 'object' ) {
84
+ if( inputs.hasOwnProperty( 'color' ) ) {
85
+ let row = WPTB_Helper.findAncestor( element, 'wptb-row' );
86
+ let table = WPTB_Helper.findAncestor( row, 'wptb-preview-table' );
87
+ if( WPTB_Helper.rowIsTop( row ) && table.classList.contains( 'wptb-table-preview-head' ) ) {
88
+ WPTB_Helper.dataTitleColumnSet( table );
89
+ }
90
+ }
91
+ }
92
+ }
93
+
94
+ WPTB_Helper.controlsInclude( element, controlsChange );
inc/admin/element-classes/elements/button-element.php CHANGED
@@ -2,7 +2,7 @@
2
  namespace WP_Table_Builder\Inc\Admin\Element_Classes\Elements;
3
 
4
  use WP_Table_Builder\Inc\Admin\Element_Classes\Base\Element_Base_Object as Element_Base_Object;
5
- use WP_Table_Builder\Inc\Admin\Element_Classes\Managers\Controls_Manager as Controls_Manager;
6
  use WP_Table_Builder as NS;
7
 
8
  // If this file is called directly, abort.
@@ -93,6 +93,7 @@ class Button_Element extends Element_Base_Object {
93
  [
94
  'label' => __( 'Button Options', 'wp_table_builder' ),
95
  'type' => Controls_Manager::SECTION_HEADER,
 
96
  ]
97
  );
98
 
@@ -109,25 +110,40 @@ class Button_Element extends Element_Base_Object {
109
  'buttonViews' => ['S', 'M', 'L', 'XL']
110
  ]
111
  );
112
-
113
- $this->add_control(
114
- 'textColor',
115
  [
116
- 'label' => __( 'Button Text Color', 'wp_table_builder' ),
117
  'type' => Controls_Manager::COLOR,
118
  'selectors' => [
119
- '{{{data.container}}} .wptb-button-wrapper a div' => 'color',
120
  ]
121
  ]
122
  );
123
 
124
- $this->add_control(
125
- 'buttonColor',
126
  [
127
- 'label' => __( 'Button Color', 'wp_table_builder' ),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128
  'type' => Controls_Manager::COLOR,
129
  'selectors' => [
130
- '{{{data.container}}} .wptb-button-wrapper a div' => 'backgroundColor',
131
  ]
132
  ]
133
  );
2
  namespace WP_Table_Builder\Inc\Admin\Element_Classes\Elements;
3
 
4
  use WP_Table_Builder\Inc\Admin\Element_Classes\Base\Element_Base_Object as Element_Base_Object;
5
+ use WP_Table_Builder\Inc\Admin\Managers\Controls_Manager as Controls_Manager;
6
  use WP_Table_Builder as NS;
7
 
8
  // If this file is called directly, abort.
93
  [
94
  'label' => __( 'Button Options', 'wp_table_builder' ),
95
  'type' => Controls_Manager::SECTION_HEADER,
96
+ 'buttonBack' => true
97
  ]
98
  );
99
 
110
  'buttonViews' => ['S', 'M', 'L', 'XL']
111
  ]
112
  );
113
+
114
+ $this->add_control(
115
+ 'buttonColor',
116
  [
117
+ 'label' => __( 'Button Color', 'wp_table_builder' ),
118
  'type' => Controls_Manager::COLOR,
119
  'selectors' => [
120
+ '{{{data.container}}} .wptb-button-wrapper a div' => 'background-color',
121
  ]
122
  ]
123
  );
124
 
125
+ $this->add_control(
126
+ 'buttonTextSize',
127
  [
128
+ 'label' => __( 'Button Text Size', 'wp_table_builder' ),
129
+ 'type' => Controls_Manager::SIZE,
130
+ 'selectors' => [
131
+ '{{{data.container}}} .wptb-button-wrapper p' => 'fontSize',
132
+ ],
133
+ 'min' => 10,
134
+ 'max' => 50,
135
+ 'defaultValue' => 15,
136
+ 'dimension' => 'px'
137
+ ]
138
+ );
139
+
140
+ $this->add_control(
141
+ 'textColor',
142
+ [
143
+ 'label' => __( 'Button Text Color', 'wp_table_builder' ),
144
  'type' => Controls_Manager::COLOR,
145
  'selectors' => [
146
+ '{{{data.container}}} .wptb-button-wrapper a div' => 'color',
147
  ]
148
  ]
149
  );
inc/admin/element-classes/elements/custom-html-element.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace WP_Table_Builder\Inc\Admin\Element_Classes\Elements;
3
+
4
+ use WP_Table_Builder\Inc\Admin\Element_Classes\Base\Element_Base_Object as Element_Base_Object;
5
+ use WP_Table_Builder\Inc\Admin\Managers\Controls_Manager as Controls_Manager;
6
+ use WP_Table_Builder as NS;
7
+
8
+ // If this file is called directly, abort.
9
+ if ( ! defined( 'WPINC' ) ) {
10
+ die;
11
+ }
12
+
13
+ class Custom_Html_Element extends Element_Base_Object {
14
+
15
+ /**
16
+ * Get element name.
17
+ *
18
+ * Retrieve custom html editor element name.
19
+ *
20
+ * @since 1.1.2
21
+ * @access public
22
+ *
23
+ * @return string element name.
24
+ */
25
+ public function get_name() {
26
+ return 'custom_html';
27
+ }
28
+
29
+ /**
30
+ * Get element title.
31
+ *
32
+ * Retrieve custom html editor element title.
33
+ *
34
+ * @since 1.1.2
35
+ * @access public
36
+ *
37
+ * @return string Element title.
38
+ */
39
+ public function get_title() {
40
+ return esc_html_e( 'Custom HTML', 'wp-table-builder' );
41
+ }
42
+
43
+ /**
44
+ * Get directory icon.
45
+ *
46
+ * Return directory custom html editor element icon.
47
+ *
48
+ * @since 1.1.2
49
+ * @access public
50
+ *
51
+ * @return string directory Element icon.
52
+ */
53
+ public function get_directory_icon() {
54
+ return NS\WP_TABLE_BUILDER_DIR . 'inc/admin/views/builder/icons/custom-html.svg'; ;
55
+ }
56
+
57
+ /**
58
+ * Get url icon.
59
+ *
60
+ * Return url custom html icon
61
+ *
62
+ * @since 1.1.2
63
+ * @access public
64
+ *
65
+ * @return string Url Element icon.
66
+ */
67
+ public function get_url_icon() {
68
+ return wp_normalize_path ( NS\WP_TABLE_BUILDER_URL . 'inc/admin/views/builder/icons/custom-html.svg' );
69
+ }
70
+
71
+ /**
72
+ * Include file with js script for element custom html
73
+ *
74
+ * @since 1.1.2
75
+ * @access protected
76
+ */
77
+ public function element_script() {
78
+ return wp_normalize_path ( NS\WP_TABLE_BUILDER_DIR . 'inc/admin/element-classes/element-scripts/custom-html-element.js' );
79
+ }
80
+
81
+ /**
82
+ * Register the element controls.
83
+ *
84
+ * Adds different fields to allow the user to change and customize the element settings.
85
+ *
86
+ * @since 1.1.2
87
+ *
88
+ * @access protected
89
+ */
90
+ protected function _register_controls() {
91
+ $this->add_control(
92
+ 'section_header',
93
+ [
94
+ 'label' => __( 'Custom HTML Options', 'wp_table_builder' ),
95
+ 'type' => Controls_Manager::SECTION_HEADER,
96
+ 'buttonBack' => true
97
+ ]
98
+ );
99
+
100
+ $this->add_control(
101
+ 'textarea',
102
+ [
103
+ 'label' => __( 'Insert HTML', 'wp_table_builder' ),
104
+ 'type' => Controls_Manager::TEXTAREA,
105
+ 'placeholder' => __( 'Insert HTML Code Here', 'wp_table_builder' ),
106
+ 'rows' => 5,
107
+ 'defaultValue' => 'Insert Custom HTML'
108
+ ]
109
+ );
110
+ }
111
+
112
+ /**
113
+ * Render custom html editor element output in the editor.
114
+ *
115
+ * Written as a wp js template and used to generate the live preview.
116
+ *
117
+ * @since 1.1.2
118
+ * @access protected
119
+ */
120
+ protected function _content_template() {
121
+ ?>
122
+ <div class="wptb-custom-html-wrapper" data-wptb-new-element="1">
123
+ <span>Insert Custom HTML</span>
124
+ </div>
125
+ <?php
126
+ }
127
+ }
inc/admin/element-classes/elements/image-element.php CHANGED
@@ -2,7 +2,7 @@
2
  namespace WP_Table_Builder\Inc\Admin\Element_Classes\Elements;
3
 
4
  use WP_Table_Builder\Inc\Admin\Element_Classes\Base\Element_Base_Object as Element_Base_Object;
5
- use WP_Table_Builder\Inc\Admin\Element_Classes\Managers\Controls_Manager as Controls_Manager;
6
  use WP_Table_Builder as NS;
7
 
8
  // If this file is called directly, abort.
@@ -93,6 +93,15 @@ class Image_Element extends Element_Base_Object {
93
  [
94
  'label' => __( 'Image Options', 'wp_table_builder' ),
95
  'type' => Controls_Manager::SECTION_HEADER,
 
 
 
 
 
 
 
 
 
96
  ]
97
  );
98
 
@@ -153,7 +162,26 @@ class Image_Element extends Element_Base_Object {
153
  protected function _content_template() {
154
  ?>
155
  <div class="wptb-image-wrapper">
156
- <a style="display: block;"><img></a>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  </div>
158
  <?php
159
  }
2
  namespace WP_Table_Builder\Inc\Admin\Element_Classes\Elements;
3
 
4
  use WP_Table_Builder\Inc\Admin\Element_Classes\Base\Element_Base_Object as Element_Base_Object;
5
+ use WP_Table_Builder\Inc\Admin\Managers\Controls_Manager as Controls_Manager;
6
  use WP_Table_Builder as NS;
7
 
8
  // If this file is called directly, abort.
93
  [
94
  'label' => __( 'Image Options', 'wp_table_builder' ),
95
  'type' => Controls_Manager::SECTION_HEADER,
96
+ 'buttonBack' => true
97
+ ]
98
+ );
99
+
100
+ $this->add_control(
101
+ 'imageReplaceButton',
102
+ [
103
+ 'label' => __( 'Replace Image', 'wp_table_builder' ),
104
+ 'type' => Controls_Manager::BUTTON,
105
  ]
106
  );
107
 
162
  protected function _content_template() {
163
  ?>
164
  <div class="wptb-image-wrapper">
165
+ <a style="display: block;">
166
+ <span class="wptb-icon-image-button">
167
+ <svg class="wptb-draggable-prototype" xmlns="http://www.w3.org/2000/svg"
168
+ viewBox="0 0 489.4 489.4" width="40px" height="50px">
169
+ <path d="M0 437.8c0 28.5 23.2 51.6 51.6 51.6h386.2c28.5 0 51.6-23.2
170
+ 51.6-51.6V51.6c0-28.5-23.2-51.6-51.6-51.6H51.6C23.1 0 0 23.2 0
171
+ 51.6 0 51.6 0 437.8 0 437.8zM437.8 464.9H51.6c-14.9
172
+ 0-27.1-12.2-27.1-27.1v-64.5l92.8-92.8 79.3 79.3c4.8 4.8
173
+ 12.5 4.8 17.3 0l143.2-143.2 107.8 107.8v113.4C464.9 452.7 452.7
174
+ 464.9 437.8 464.9zM51.6 24.5h386.2c14.9 0 27.1 12.2 27.1
175
+ 27.1v238.1l-99.2-99.1c-4.8-4.8-12.5-4.8-17.3 0L205.2
176
+ 333.8l-79.3-79.3c-4.8-4.8-12.5-4.8-17.3 0l-84.1 84.1v-287C24.5
177
+ 36.7 36.7 24.5 51.6 24.5z"/>
178
+ <path d="M151.7 196.1c34.4 0 62.3-28 62.3-62.3s-28-62.3-62.3-62.3 -62.3
179
+ 28-62.3 62.3S117.3 196.1 151.7 196.1zM151.7 96c20.9 0 37.8 17 37.8
180
+ 37.8s-17 37.8-37.8 37.8 -37.8-17-37.8-37.8S130.8 96 151.7 96z"/>
181
+ </svg>
182
+ <span>Insert Image</span>
183
+ </span>
184
+ </a>
185
  </div>
186
  <?php
187
  }
inc/admin/element-classes/elements/list-element.php CHANGED
@@ -2,7 +2,7 @@
2
  namespace WP_Table_Builder\Inc\Admin\Element_Classes\Elements;
3
 
4
  use WP_Table_Builder\Inc\Admin\Element_Classes\Base\Element_Base_Object as Element_Base_Object;
5
- use WP_Table_Builder\Inc\Admin\Element_Classes\Managers\Controls_Manager as Controls_Manager;
6
  use WP_Table_Builder as NS;
7
 
8
  // If this file is called directly, abort.
@@ -93,6 +93,7 @@ class List_Element extends Element_Base_Object {
93
  [
94
  'label' => __( 'List Options', 'wp_table_builder' ),
95
  'type' => Controls_Manager::SECTION_HEADER,
 
96
  ]
97
  );
98
 
@@ -121,7 +122,7 @@ class List_Element extends Element_Base_Object {
121
  ['None', 'none']
122
  ],
123
  'selectedDefault' => 2,
124
- 'appearDependOn' => ['select1', ['unordered'], ['numbered']]
125
  ]
126
  );
127
 
@@ -135,7 +136,7 @@ class List_Element extends Element_Base_Object {
135
  // ['Name 2', 'value 2', 'off'],
136
  // ['Name 3', 'value 3', 'on']
137
  // ],
138
- // 'appearDependOn' => ['select1', ['unordered'], ['numbered']]
139
  // ]
140
  // );
141
  //
@@ -146,7 +147,7 @@ class List_Element extends Element_Base_Object {
146
  // 'type' => Controls_Manager::TEXTAREA,
147
  // 'placeholder' => __( 'Insert Button ID Here', 'wp_table_builder' ),
148
  // 'rows' => 5,
149
- // 'appearDependOn' => ['select1', ['unordered'], ['numbered']]
150
  // ]
151
  // );
152
 
2
  namespace WP_Table_Builder\Inc\Admin\Element_Classes\Elements;
3
 
4
  use WP_Table_Builder\Inc\Admin\Element_Classes\Base\Element_Base_Object as Element_Base_Object;
5
+ use WP_Table_Builder\Inc\Admin\Managers\Controls_Manager as Controls_Manager;
6
  use WP_Table_Builder as NS;
7
 
8
  // If this file is called directly, abort.
93
  [
94
  'label' => __( 'List Options', 'wp_table_builder' ),
95
  'type' => Controls_Manager::SECTION_HEADER,
96
+ 'buttonBack' => true
97
  ]
98
  );
99
 
122
  ['None', 'none']
123
  ],
124
  'selectedDefault' => 2,
125
+ 'appearDependOnControl' => ['select1', ['unordered'], ['numbered']]
126
  ]
127
  );
128
 
136
  // ['Name 2', 'value 2', 'off'],
137
  // ['Name 3', 'value 3', 'on']
138
  // ],
139
+ // 'appearDependOnControl' => ['select1', ['unordered'], ['numbered']]
140
  // ]
141
  // );
142
  //
147
  // 'type' => Controls_Manager::TEXTAREA,
148
  // 'placeholder' => __( 'Insert Button ID Here', 'wp_table_builder' ),
149
  // 'rows' => 5,
150
+ // 'appearDependOnControl' => ['select1', ['unordered'], ['numbered']]
151
  // ]
152
  // );
153
 
inc/admin/element-classes/elements/shortcode-element.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace WP_Table_Builder\Inc\Admin\Element_Classes\Elements;
3
+
4
+ use WP_Table_Builder\Inc\Admin\Element_Classes\Base\Element_Base_Object as Element_Base_Object;
5
+ use WP_Table_Builder\Inc\Admin\Managers\Controls_Manager as Controls_Manager;
6
+ use WP_Table_Builder as NS;
7
+
8
+ // If this file is called directly, abort.
9
+ if ( ! defined( 'WPINC' ) ) {
10
+ die;
11
+ }
12
+
13
+ class Shortcode_Element extends Element_Base_Object {
14
+
15
+ /**
16
+ * Get element name.
17
+ *
18
+ * Retrieve shortcode editor element name.
19
+ *
20
+ * @since 1.1.2
21
+ * @access public
22
+ *
23
+ * @return string element name.
24
+ */
25
+ public function get_name() {
26
+ return 'shortcode';
27
+ }
28
+
29
+ /**
30
+ * Get element title.
31
+ *
32
+ * Retrieve shortcode editor element title.
33
+ *
34
+ * @since 1.1.2
35
+ * @access public
36
+ *
37
+ * @return string Element title.
38
+ */
39
+ public function get_title() {
40
+ return esc_html_e( 'Shortcode', 'wp-table-builder' );
41
+ }
42
+
43
+ /**
44
+ * Get directory icon.
45
+ *
46
+ * Return directory shortcode editor element icon.
47
+ *
48
+ * @since 1.1.2
49
+ * @access public
50
+ *
51
+ * @return string directory Element icon.
52
+ */
53
+ public function get_directory_icon() {
54
+ return NS\WP_TABLE_BUILDER_DIR . 'inc/admin/views/builder/icons/shortcode.svg'; ;
55
+ }
56
+
57
+ /**
58
+ * Get url icon.
59
+ *
60
+ * Return url shortcode icon
61
+ *
62
+ * @since 1.1.2
63
+ * @access public
64
+ *
65
+ * @return string Url Element icon.
66
+ */
67
+ public function get_url_icon() {
68
+ return wp_normalize_path ( NS\WP_TABLE_BUILDER_URL . 'inc/admin/views/builder/icons/shortcode.svg' );
69
+ }
70
+
71
+ /**
72
+ * Include file with js script for element shortcode
73
+ *
74
+ * @since 1.1.2
75
+ * @access protected
76
+ */
77
+ public function element_script() {
78
+ return wp_normalize_path ( NS\WP_TABLE_BUILDER_DIR . 'inc/admin/element-classes/element-scripts/shortcode-element.js' );
79
+ }
80
+
81
+ /**
82
+ * Register the element controls.
83
+ *
84
+ * Adds different fields to allow the user to change and customize the element settings.
85
+ *
86
+ * @since 1.1.2
87
+ *
88
+ * @access protected
89
+ */
90
+ protected function _register_controls() {
91
+ $this->add_control(
92
+ 'section_header',
93
+ [
94
+ 'label' => __( 'Element Shortcode Options', 'wp_table_builder' ),
95
+ 'type' => Controls_Manager::SECTION_HEADER,
96
+ 'buttonBack' => true
97
+ ]
98
+ );
99
+
100
+ $this->add_control(
101
+ 'textarea',
102
+ [
103
+ 'label' => __( 'Insert Shortcode', 'wp_table_builder' ),
104
+ 'type' => Controls_Manager::TEXTAREA,
105
+ 'placeholder' => __( 'Insert Shortcode Here', 'wp_table_builder' ),
106
+ 'rows' => 5,
107
+ 'defaultValue' => '[Shortcode]'
108
+ ]
109
+ );
110
+ }
111
+
112
+ /**
113
+ * Render shortcode editor element output in the editor.
114
+ *
115
+ * Written as a wp js template and used to generate the live preview.
116
+ *
117
+ * @since 1.1.2
118
+ * @access protected
119
+ */
120
+ protected function _content_template() {
121
+ ?>
122
+ <div>[Shortcode]</div>
123
+ <?php
124
+ }
125
+ }
inc/admin/element-classes/elements/star-rating-element.php CHANGED
@@ -2,7 +2,7 @@
2
  namespace WP_Table_Builder\Inc\Admin\Element_Classes\Elements;
3
 
4
  use WP_Table_Builder\Inc\Admin\Element_Classes\Base\Element_Base_Object as Element_Base_Object;
5
- use WP_Table_Builder\Inc\Admin\Element_Classes\Managers\Controls_Manager as Controls_Manager;
6
  use WP_Table_Builder as NS;
7
 
8
  // If this file is called directly, abort.
@@ -93,6 +93,7 @@ class Star_Rating_Element extends Element_Base_Object {
93
  [
94
  'label' => __( 'Star Rating Options', 'wp_table_builder' ),
95
  'type' => Controls_Manager::SECTION_HEADER,
 
96
  ]
97
  );
98
 
@@ -149,11 +150,7 @@ class Star_Rating_Element extends Element_Base_Object {
149
  'numberRatingShowHide',
150
  [
151
  'label' => __( 'Show Number Rating', 'wp_table_builder' ),
152
- 'type' => Controls_Manager::TOGGLE,
153
- 'selectors' => [
154
- '{{{data.container}}} .wptb-number-rating-box' => 'display',
155
- '.wptb-numeral-star-rating-option' => 'display'
156
- ]
157
  ]
158
  );
159
 
@@ -163,7 +160,7 @@ class Star_Rating_Element extends Element_Base_Object {
163
  'label' => __( 'Number Rating Size', 'wp_table_builder' ),
164
  'type' => Controls_Manager::SIZE,
165
  'selectors' => [
166
- '{{{data.container}}} .wptb-number-rating' => ['fontSize', 'lineHeight']
167
  ],
168
  'min' => 10,
169
  'max' => 50,
@@ -171,7 +168,7 @@ class Star_Rating_Element extends Element_Base_Object {
171
  'dimension' => 'px',
172
  'customClassForContainer' => 'wptb-numeral-star-rating-option',
173
  'containerAdditionalStyles' => 'display:none;',
174
- 'appearDependOn' => ['numberRatingShowHide', ['checked'], ['unchecked']]
175
  ]
176
  );
177
 
@@ -185,7 +182,7 @@ class Star_Rating_Element extends Element_Base_Object {
185
  ],
186
  'customClassForContainer' => 'wptb-numeral-star-rating-option',
187
  'containerAdditionalStyles' => 'display:none;',
188
- 'appearDependOn' => ['numberRatingShowHide', ['checked'], ['unchecked']]
189
  ]
190
  );
191
  }
2
  namespace WP_Table_Builder\Inc\Admin\Element_Classes\Elements;
3
 
4
  use WP_Table_Builder\Inc\Admin\Element_Classes\Base\Element_Base_Object as Element_Base_Object;
5
+ use WP_Table_Builder\Inc\Admin\Managers\Controls_Manager as Controls_Manager;
6
  use WP_Table_Builder as NS;
7
 
8
  // If this file is called directly, abort.
93
  [
94
  'label' => __( 'Star Rating Options', 'wp_table_builder' ),
95
  'type' => Controls_Manager::SECTION_HEADER,
96
+ 'buttonBack' => true
97
  ]
98
  );
99
 
150
  'numberRatingShowHide',
151
  [
152
  'label' => __( 'Show Number Rating', 'wp_table_builder' ),
153
+ 'type' => Controls_Manager::TOGGLE
 
 
 
 
154
  ]
155
  );
156
 
160
  'label' => __( 'Number Rating Size', 'wp_table_builder' ),
161
  'type' => Controls_Manager::SIZE,
162
  'selectors' => [
163
+ '{{{data.container}}} .wptb-number-rating' => ['fontSize', 'lineHeight', 'height']
164
  ],
165
  'min' => 10,
166
  'max' => 50,
168
  'dimension' => 'px',
169
  'customClassForContainer' => 'wptb-numeral-star-rating-option',
170
  'containerAdditionalStyles' => 'display:none;',
171
+ 'appearDependOnControl' => ['numberRatingShowHide', ['checked'], ['unchecked']]
172
  ]
173
  );
174
 
182
  ],
183
  'customClassForContainer' => 'wptb-numeral-star-rating-option',
184
  'containerAdditionalStyles' => 'display:none;',
185
+ 'appearDependOnControl' => ['numberRatingShowHide', ['checked'], ['unchecked']]
186
  ]
187
  );
188
  }
inc/admin/element-classes/elements/text-element.php CHANGED
@@ -2,7 +2,7 @@
2
  namespace WP_Table_Builder\Inc\Admin\Element_Classes\Elements;
3
 
4
  use WP_Table_Builder\Inc\Admin\Element_Classes\Base\Element_Base_Object as Element_Base_Object;
5
- use WP_Table_Builder\Inc\Admin\Element_Classes\Managers\Controls_Manager as Controls_Manager;
6
  use WP_Table_Builder as NS;
7
 
8
  // If this file is called directly, abort.
@@ -93,6 +93,7 @@ class Text_Element extends Element_Base_Object {
93
  [
94
  'label' => __( 'Text Options', 'wp_table_builder' ),
95
  'type' => Controls_Manager::SECTION_HEADER,
 
96
  ]
97
  );
98
 
2
  namespace WP_Table_Builder\Inc\Admin\Element_Classes\Elements;
3
 
4
  use WP_Table_Builder\Inc\Admin\Element_Classes\Base\Element_Base_Object as Element_Base_Object;
5
+ use WP_Table_Builder\Inc\Admin\Managers\Controls_Manager as Controls_Manager;
6
  use WP_Table_Builder as NS;
7
 
8
  // If this file is called directly, abort.
93
  [
94
  'label' => __( 'Text Options', 'wp_table_builder' ),
95
  'type' => Controls_Manager::SECTION_HEADER,
96
+ 'buttonBack' => true
97
  ]
98
  );
99
 
inc/admin/js/admin.js CHANGED
@@ -47,9 +47,10 @@ var WPTB_ActionsField = function WPTB_ActionsField() {
47
  btnDelete.onclick = function (event) {
48
  var act = event.target.parentNode.activeElem,
49
  el = act.parentNode;
50
-
51
- if (act && act.className.match(/wptb-element-(.+)-(\d+)/i)) {
52
  WPTB_Helper.elementControlsStateDelete(act);
 
53
  }
54
 
55
  if (act) {
@@ -58,9 +59,13 @@ var WPTB_ActionsField = function WPTB_ActionsField() {
58
 
59
  if (act && (typeof act === 'undefined' ? 'undefined' : _typeof(act)) === 'object' && act.hasOwnProperty('kind') && act.kind == 'text') {
60
  var thisRow = el.parentNode;
61
- if (thisRow.classList.contains('wptb-table-head')) {
 
62
  var table = WPTB_Helper.findAncestor(thisRow, 'wptb-preview-table');
63
- WPTB_Helper.dataTitleColumnSet(table);
 
 
 
64
  }
65
  }
66
 
@@ -76,7 +81,7 @@ var WPTB_ActionsField = function WPTB_ActionsField() {
76
  infArr = void 0,
77
  type = void 0;
78
  var activeElement = event.target.parentNode.activeElem;
79
- var td = activeElement.parentNode;
80
  infArr = activeElement.className.match(/wptb-element-(.+)-(\d+)/i);
81
  if (infArr && Array.isArray(infArr)) {
82
  type = infArr[1];
@@ -86,9 +91,10 @@ var WPTB_ActionsField = function WPTB_ActionsField() {
86
  data.tinyMceClear = true;
87
  copy = new WPTB_ElementObject(data);
88
  WPTB_Helper.elementControlsStateCopy(activeElement, copy.getDOMElement());
 
89
  //WPTB_Helper.elementStartScript( copy.getDOMElement() );
90
 
91
- td.insertBefore(copy.getDOMElement(), activeElement.nextSibling);
92
  } else {
93
  copy = {};
94
  var elementCopy = activeElement.cloneNode(true);
@@ -100,7 +106,7 @@ var WPTB_ActionsField = function WPTB_ActionsField() {
100
 
101
  applyGenericItemSettings(copy);
102
 
103
- td.insertBefore(copy.getDOMElement(), activeElement.nextSibling);
104
 
105
  WPTB_Helper.wptbDocumentEventGenerate('wptb-inner-element:copy', activeElement, copy.getDOMElement());
106
  }
@@ -150,9 +156,13 @@ var WPTB_ActionsField = function WPTB_ActionsField() {
150
  var act = event.target.parentNode.activeElem;
151
  if (act.kind == 'text') {
152
  var thisRow = act.parentNode.parentNode;
153
- if (thisRow.classList.contains('wptb-table-head')) {
 
154
  var table = WPTB_Helper.findAncestor(thisRow, 'wptb-preview-table');
155
- WPTB_Helper.dataTitleColumnSet(table);
 
 
 
156
  }
157
  }
158
  } else {
@@ -321,11 +331,21 @@ var WPTB_ActionsField = function WPTB_ActionsField() {
321
  }
322
 
323
  WPTB_Table();
 
 
 
 
 
 
 
 
324
  WPTB_LeftPanel();
325
  WPTB_Settings();
326
 
327
  var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
328
  wptbTableStateSaveManager.tableStateSet();
 
 
329
  } else {
330
  document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';
331
  }
@@ -398,6 +418,7 @@ var WPTB_Cell = function WPTB_Cell(callback, DOMElement) {
398
  }
399
 
400
  DOMElement.classList.add('wptb-droppable', 'wptb-cell');
 
401
  }
402
 
403
  DOMElement.draggable = false;
@@ -405,6 +426,22 @@ var WPTB_Cell = function WPTB_Cell(callback, DOMElement) {
405
  DOMElement.onclick = callback;
406
  }
407
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
408
  WPTB_innerElementSet(DOMElement);
409
 
410
  var wptbPhElement = DOMElement.getElementsByClassName('wptb-ph-element');
@@ -470,6 +507,7 @@ var WPTB_Cell = function WPTB_Cell(callback, DOMElement) {
470
  };
471
 
472
  DOMElement.getCellDimensions = function () {
 
473
  var tdStyleObj = window.getComputedStyle(this, null);
474
 
475
  var tdPaddingLeft = tdStyleObj.getPropertyValue('padding-left');
@@ -484,13 +522,52 @@ var WPTB_Cell = function WPTB_Cell(callback, DOMElement) {
484
  var tdBorderTopWidth = tdStyleObj.getPropertyValue('border-top-width');
485
  var tdBorderBottomWidth = tdStyleObj.getPropertyValue('border-bottom-width');
486
 
487
- var width = parseFloat(this.offsetWidth, 10) - parseFloat(tdPaddingLeft, 10) - parseFloat(tdPaddingRight, 10) - parseFloat(tdBorderLeftWidth, 10) - parseFloat(tdBorderRightWidth, 10);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
488
 
489
- var height = parseFloat(this.offsetHeight, 10) - parseFloat(tdPaddingTop, 10) - parseFloat(tdPaddingBottom, 10) - parseFloat(tdBorderTopWidth, 10) - parseFloat(tdBorderBottomWidth, 10);
 
 
 
 
 
 
 
490
 
491
  return {
492
- width: width,
493
- height: height
494
  };
495
  };
496
 
@@ -569,9 +646,12 @@ var WPTB_DropHandle = function WPTB_DropHandle(thisElem, e) {
569
  }
570
 
571
  var thisRow = td.parentNode;
572
- if (thisRow.classList.contains('wptb-table-head')) {
573
  var table = WPTB_Helper.findAncestor(thisRow, 'wptb-preview-table');
574
- WPTB_Helper.dataTitleColumnSet(table);
 
 
 
575
  }
576
 
577
  // start item javascript if item is new
@@ -610,18 +690,23 @@ var WPTB_DropHandle = function WPTB_DropHandle(thisElem, e) {
610
  } else if (thisElem.localName == 'div' && thisElem.classList.contains('wptb-ph-element')) {
611
  thisRow = thisElem.parentNode.parentNode;
612
  }
613
- if (thisRow.classList.contains('wptb-table-head')) {
614
- var indics = e.dataTransfer.types;
615
- var notDragEnter = false;
616
- for (var i = 0; i < indics.length; i++) {
617
- var infArr = indics[i].match(/wptbelindic-([a-z]+)/i);
618
- if (infArr && infArr[1] != 'text') {
619
- notDragEnter = true;
620
- break;
 
 
 
 
 
 
 
 
621
  }
622
- }
623
- if (notDragEnter) {
624
- return;
625
  }
626
  }
627
 
@@ -763,127 +848,16 @@ var WPTB_ElementObject = function WPTB_ElementObject(data) {
763
  };
764
  var WPTB_ElementOptions = function WPTB_ElementOptions(element, index, kindIndexProt) {
765
 
766
- var node = element.getDOMElement(),
767
- elemIdClass;
768
 
769
  node.onclick = function () {
770
- var children = document.getElementById("element-options-group").childNodes;
771
- for (var _i = 0; _i < children.length; _i++) {
772
- if (children[_i].style) children[_i].style.display = 'none';
773
- }
774
-
775
- var infArr = this.className.match(/wptb-element-((.+-)\d+)/i);
776
- // get controls config for this item
777
- var wptbContrlStacksConfigId = 'wptb-' + element.kind + '-control-stack';
778
- var tmplControlsConfig = wp.template(wptbContrlStacksConfigId);
779
- var data = {
780
- container: '.' + infArr[0]
781
- };
782
- var jsonControlsConfigJson = tmplControlsConfig(data);
783
- var jsonControlsConfig = JSON.parse(jsonControlsConfigJson);
784
-
785
- // create a container for inserting controls of this item
786
- var wptbElementOptionsContainer = document.createElement('div');
787
- wptbElementOptionsContainer.classList.add('wptb-element-options', 'wptb-options-' + infArr[1]);
788
-
789
- // clear elements from options group
790
- //document.getElementById( 'element-options-group' ).innerHTML = '';
791
- var elementOptionsGroup = document.getElementById('element-options-group');
792
- var elementOptionsGroupChildren = elementOptionsGroup.children;
793
- for (var _i2 = 0; _i2 < elementOptionsGroupChildren.length; _i2++) {
794
- var regularText = new RegExp('wptb-options-' + element.kind + '-(\\d+)', "i");
795
- var elem = elementOptionsGroupChildren[_i2].className.match(regularText);
796
- if (elem) {
797
- elementOptionsGroup.removeChild(elementOptionsGroupChildren[_i2]);
798
- }
799
- }
800
-
801
- // hide wptb-elements-container and wptb-settings-section
802
- document.getElementsByClassName('wptb-elements-container')[0].style.display = 'none';
803
- document.getElementsByClassName('wptb-settings-section')[0].style.display = 'none';
804
-
805
- // show element-options-group
806
- document.getElementById("element-options-group").style.display = 'block';
807
-
808
- // insert created container into element-option-group tag
809
- document.getElementById('element-options-group').appendChild(wptbElementOptionsContainer);
810
-
811
- // show created container
812
- wptbElementOptionsContainer.style.display = 'block';
813
-
814
- // array for save all scrips for each controls
815
- var controlScriptsArr = [];
816
-
817
- // array for keep "appear depend on" parametrs
818
- var controlAppearDependOn = [];
819
-
820
- // create controls
821
- var i = 0;
822
- Object.keys(jsonControlsConfig).forEach(function (key) {
823
- var data = jsonControlsConfig[key];
824
- data.controlKey = key;
825
-
826
- // get necessary wp js template
827
- var tmplControlTemplate = wp.template('wptb-' + data.type + '-control');
828
-
829
- data.elemContainer = infArr[0];
830
- data.elementControlTargetUnicClass = 'wptb-el-' + infArr[1] + '-' + data.controlKey;
831
- var controlTemplate = tmplControlTemplate(data);
832
-
833
- if ('appearDependOn' in data) {
834
- if (Array.isArray(data.appearDependOn)) {
835
- controlAppearDependOn.push([data.appearDependOn, data.elementControlTargetUnicClass]);
836
- }
837
- }
838
-
839
- //console.log( controlTemplate );
840
-
841
- var wptbElementOptionContainer = document.createElement('div');
842
- wptbElementOptionContainer.classList.add('wptb-element-option', 'wptb-settings-items');
843
-
844
- if (data.customClassForContainer) {
845
- wptbElementOptionContainer.classList.add(data.customClassForContainer);
846
- }
847
-
848
- if (data.containerAdditionalStyles) {
849
- wptbElementOptionContainer.setAttribute('style', data.containerAdditionalStyles);
850
- }
851
-
852
- wptbElementOptionContainer.innerHTML = controlTemplate;
853
-
854
- wptbElementOptionsContainer.appendChild(wptbElementOptionContainer);
855
-
856
- var helperJavascriptElem = wptbElementOptionContainer.getElementsByTagName('wptb-template-script');
857
- if (helperJavascriptElem.length > 0) {
858
- helperJavascriptElem = helperJavascriptElem[0];
859
- var helperJavascriptCode = helperJavascriptElem.innerText;
860
- wptbElementOptionContainer.removeChild(helperJavascriptElem);
861
- var script = document.createElement('script');
862
- script.setAttribute('type', 'text/javascript');
863
- script.innerHTML = helperJavascriptCode.replace(/\r|\n|\t/g, '').trim();
864
- controlScriptsArr.push(script);
865
- }
866
-
867
- i++;
868
- });
869
-
870
- // run the scripts of controls
871
- if (controlScriptsArr.length > 0) {
872
- for (var _i3 = 0; _i3 < controlScriptsArr.length; _i3++) {
873
- wptbElementOptionsContainer.appendChild(controlScriptsArr[_i3]);
874
- }
875
- }
876
-
877
- // run appearDependOn function
878
- for (var _i4 = 0; _i4 < controlAppearDependOn.length; _i4++) {
879
- WPTB_Helper.appearDependOn(controlAppearDependOn[_i4][0], controlAppearDependOn[_i4][1]);
880
- }
881
-
882
- WPTB_Helper.wptbDocumentEventGenerate('controlPanel:added:leftPanel');
883
  };
884
  };
885
  var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
886
 
 
 
887
  var WPTB_Helper = {
888
  hexToRgb: function hexToRgb(hex) {
889
  var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
@@ -894,6 +868,10 @@ var WPTB_Helper = {
894
 
895
  return rgb && rgb.length === 4 ? "#" + ("0" + parseInt(rgb[1], 10).toString(16)).slice(-2) + ("0" + parseInt(rgb[2], 10).toString(16)).slice(-2) + ("0" + parseInt(rgb[3], 10).toString(16)).slice(-2) : '';
896
  },
 
 
 
 
897
  getElementIcon: function getElementIcon(icon_directory) {
898
  var hostName = location.protocol + '//' + location.hostname;
899
  var img = document.createElement('img');
@@ -947,6 +925,7 @@ var WPTB_Helper = {
947
  var contentsForHeader = {};
948
  for (var i = 0; i < rowHeadChildren.length; i++) {
949
  var tdElements = rowHeadChildren[i].children;
 
950
  for (var j = 0; j < tdElements.length; j++) {
951
  var element = tdElements[j];
952
  if (element.classList.contains('wptb-ph-element')) {
@@ -988,6 +967,14 @@ var WPTB_Helper = {
988
  while ((el = el.parentElement) && !el.classList.contains(cls)) {}
989
  return el;
990
  },
 
 
 
 
 
 
 
 
991
  getSelectionText: function getSelectionText() {
992
  var txt = '';
993
  if (txt = window.getSelection) {
@@ -997,27 +984,6 @@ var WPTB_Helper = {
997
  }
998
  return txt;
999
  },
1000
- settingsPanelClear: function settingsPanelClear() {
1001
- document.getElementById('wptb-adaptive-table-checkbox').checked = false;
1002
- document.getElementById('wptb-top-row-as-header').checked = false;
1003
- document.getElementById('wptb-table-border-slider').value = 0;
1004
- document.getElementById('wptb-table-border-number').value = 0;
1005
- document.getElementById('wptb-inner-border-check').checked = false;
1006
- document.getElementById('wptb-apply-inner-border').classList.remove('visible');
1007
- document.getElementById('wptb-table-inner-border-slider').value = 1;
1008
- document.getElementById('wptb-table-inner-border-number').value = 1;
1009
-
1010
- WPTB_Helper.wpColorPickerClear('wptb-table-border-color', true);
1011
-
1012
- WPTB_Helper.wpColorPickerClear('wptb-table-header-bg', true);
1013
-
1014
- WPTB_Helper.wpColorPickerClear('wptb-even-row-bg', true);
1015
-
1016
- WPTB_Helper.wpColorPickerClear('wptb-odd-row-bg', true);
1017
-
1018
- document.getElementById('wptb-table-cell-slider').value = 15;
1019
- document.getElementById('wptb-table-cell-number').value = 15;
1020
- },
1021
  elementOptionsPanelClear: function elementOptionsPanelClear() {
1022
  var elementOptionsGroup = document.getElementById('element-options-group');
1023
  if (elementOptionsGroup) {
@@ -1315,7 +1281,7 @@ var WPTB_Helper = {
1315
  // function which set handler for event of changes of control
1316
  controlsInclude: function controlsInclude(element, functionHandler) {
1317
  if (element && (typeof element === 'undefined' ? 'undefined' : _typeof(element)) === 'object' && typeof functionHandler === 'function') {
1318
- element.addEventListener('click', function () {
1319
  var infArr = element.className.match(/wptb-element-(.+)-(\d+)/i),
1320
  elementKind = void 0;
1321
 
@@ -1334,8 +1300,8 @@ var WPTB_Helper = {
1334
  if (elementsSettings) {
1335
  elementsSettings = JSON.parse(elementsSettings);
1336
  if (elementsSettings && (typeof elementsSettings === 'undefined' ? 'undefined' : _typeof(elementsSettings)) === 'object') {
1337
- if ('tmpl-wptb-element-datas-' + infArr[1] + '-' + infArr[2] in elementsSettings) {
1338
- var elementSettings = elementsSettings['tmpl-wptb-element-datas-' + infArr[1] + '-' + infArr[2]];
1339
  if (elementSettings && (typeof elementSettings === 'undefined' ? 'undefined' : _typeof(elementSettings)) === 'object') {
1340
  Object.keys(elementSettings).forEach(function (key) {
1341
  var regularText = new RegExp('data-wptb-el-' + elementKind + '-(\\d+)-(.+)', "i");
@@ -1422,7 +1388,7 @@ var WPTB_Helper = {
1422
  }
1423
  },
1424
  //
1425
- appearDependOn: function appearDependOn(dependOn, targetControlElementClass) {
1426
  if (Array.isArray(dependOn)) {
1427
  var dependOnControlName = dependOn[0];
1428
  var infArr = targetControlElementClass.match(/wptb-el-((.+-)\d+)-(.+)/i);
@@ -1451,8 +1417,8 @@ var WPTB_Helper = {
1451
  var elementsSettings = elementsSettingsTemplateJs.innerHTML;
1452
  if (elementsSettings) {
1453
  elementsSettings = JSON.parse(elementsSettings);
1454
- if (elementsSettings && (typeof elementsSettings === 'undefined' ? 'undefined' : _typeof(elementsSettings)) === 'object' && 'tmpl-wptb-element-datas-' + dependOnControlElementKind in elementsSettings) {
1455
- var elementSettings = elementsSettings['tmpl-wptb-element-datas-' + dependOnControlElementKind];
1456
  if (elementSettings && (typeof elementSettings === 'undefined' ? 'undefined' : _typeof(elementSettings)) === 'object' && 'data-wptb-el-' + dependOnControlElementKind + '-' + dependOnControlName in elementSettings) {
1457
  var elementSettingValue = elementSettings['data-wptb-el-' + dependOnControlElementKind + '-' + dependOnControlName];
1458
 
@@ -1489,7 +1455,9 @@ var WPTB_Helper = {
1489
  var infArr = targetControlClass.match(/wptb-el-((.+-)\d+)-(.+)/i);
1490
 
1491
  if (infArr && Array.isArray(infArr)) {
1492
- var selectorElement = document.querySelector('.wptb-element-' + infArr[1]);
 
 
1493
  if (selectorElement) {
1494
  var elementsSettingsTemplatesJs = void 0;
1495
  var elementSettings = {};
@@ -1500,7 +1468,7 @@ var WPTB_Helper = {
1500
  elementSettings['data-' + targetControlClass] = targetControlValue;
1501
 
1502
  elementsSettings = {};
1503
- elementsSettings['tmpl-wptb-element-datas-' + infArr[1]] = elementSettings;
1504
  elementsSettings = JSON.stringify(elementsSettings);
1505
 
1506
  if (elementsSettingsTemplatesJs.length == 0) {
@@ -1525,26 +1493,26 @@ var WPTB_Helper = {
1525
 
1526
  if (controlChangeIndic) {
1527
  var _targetControlValue = WPTB_Helper.targetControlValueGet(targetControls);
1528
- if (!('tmpl-wptb-element-datas-' + infArr[1] in elementsSettings) || _typeof(elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]) !== 'object') {
1529
- elementsSettings['tmpl-wptb-element-datas-' + infArr[1]] = {};
1530
  }
1531
- elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]['data-' + targetControlClass] = _targetControlValue;
1532
  elementsSettingsTemplatesJs.innerHTML = JSON.stringify(elementsSettings);
1533
- } else if (!('tmpl-wptb-element-datas-' + infArr[1] in elementsSettings && _typeof(elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]) === 'object' && 'data-' + targetControlClass in elementsSettings['tmpl-wptb-element-datas-' + infArr[1]])) {
1534
  var _targetControlValue2 = WPTB_Helper.targetControlValueGet(targetControls);
1535
- if (!('tmpl-wptb-element-datas-' + infArr[1] in elementsSettings) || _typeof(elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]) !== 'object') {
1536
- elementsSettings['tmpl-wptb-element-datas-' + infArr[1]] = {};
1537
  }
1538
- elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]['data-' + targetControlClass] = _targetControlValue2;
1539
  elementsSettingsTemplatesJs.innerHTML = JSON.stringify(elementsSettings);
1540
- } else if ('tmpl-wptb-element-datas-' + infArr[1] in elementsSettings && _typeof(elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]) === 'object' && 'data-' + targetControlClass in elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]) {
1541
  for (var i = 0; i < targetControls.length; i++) {
1542
  if (targetControls[i].type == 'checkbox') {
1543
  var _targetControlValue3 = void 0;
1544
  if (targetControls[i].name) {
1545
- _targetControlValue3 = elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]['data-' + targetControlClass][targetControls[i].name];
1546
  } else {
1547
- _targetControlValue3 = elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]['data-' + targetControlClass];
1548
  }
1549
 
1550
  if (_targetControlValue3 == 'checked') {
@@ -1553,7 +1521,7 @@ var WPTB_Helper = {
1553
  targetControls[i].checked = false;
1554
  }
1555
  } else {
1556
- targetControls[i].value = elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]['data-' + targetControlClass];
1557
  }
1558
  }
1559
  }
@@ -1604,7 +1572,7 @@ var WPTB_Helper = {
1604
  elementsSettings = JSON.parse(elementsSettings);
1605
 
1606
  if (elementsSettings && (typeof elementsSettings === 'undefined' ? 'undefined' : _typeof(elementsSettings)) === 'object') {
1607
- var elementSettingsProt = elementsSettings['tmpl-wptb-element-datas-' + elemProtKind];
1608
  if (elementSettingsProt && (typeof elementSettingsProt === 'undefined' ? 'undefined' : _typeof(elementSettingsProt)) === 'object') {
1609
  var elementSettingsCopy = {};
1610
 
@@ -1615,7 +1583,7 @@ var WPTB_Helper = {
1615
  });
1616
 
1617
  if (Object.keys(elementSettingsCopy).length > 0) {
1618
- elementsSettings['tmpl-wptb-element-datas-' + elemCopyKind] = elementSettingsCopy;
1619
 
1620
  elementsSettings = JSON.stringify(elementsSettings);
1621
  elementsSettingsTemplateJs.innerHTML = elementsSettings;
@@ -1628,7 +1596,7 @@ var WPTB_Helper = {
1628
  }
1629
  },
1630
  //
1631
- elementControlsStateDelete: function elementControlsStateDelete(element) {
1632
  var infArr = element.className.match(/wptb-element-(.+)-(\d+)/i);
1633
  var body = document.getElementsByTagName('body')[0];
1634
  var wptbElementDatas = body.getElementsByClassName('wptb-element-datas');
@@ -1637,8 +1605,14 @@ var WPTB_Helper = {
1637
  var elementsSettings = wptbElementDatas.innerHTML;
1638
  if (elementsSettings) {
1639
  elementsSettings = JSON.parse(elementsSettings);
1640
- if (elementsSettings && (typeof elementsSettings === 'undefined' ? 'undefined' : _typeof(elementsSettings)) === 'object' && 'tmpl-wptb-element-datas-' + infArr[1] + '-' + infArr[2] in elementsSettings) {
1641
- delete elementsSettings['tmpl-wptb-element-datas-' + infArr[1] + '-' + infArr[2]];
 
 
 
 
 
 
1642
 
1643
  if (Object.keys(elementsSettings).length == 0) {
1644
  body.removeChild(wptbElementDatas);
@@ -1649,420 +1623,583 @@ var WPTB_Helper = {
1649
  }
1650
  }
1651
  }
1652
- }
1653
- };
1654
- var WPTB_Initializer = function WPTB_Initializer() {
1655
-
1656
- var MIN_COLUMNS = 1,
1657
- MIN_ROWS = 1,
1658
- MAX_COLUMNS = 30,
1659
- MAX_ROWS = 30;
1660
-
1661
- var tableGenerator = document.body;
1662
- columnsDecrementButton = tableGenerator.getElementsByClassName('wptb-input-number-decrement')[0], columnsIncrementButton = tableGenerator.getElementsByClassName('wptb-input-number-increment')[0], rowsDecrementButton = tableGenerator.getElementsByClassName('wptb-input-number-decrement')[1], rowsIncrementButton = tableGenerator.getElementsByClassName('wptb-input-number-increment')[1], columnsInput = document.getElementById('wptb-columns-number'), rowsInput = document.getElementById('wptb-rows-number');
1663
-
1664
- columnsDecrementButton.onclick = function () {
1665
- if (columnsInput.value > MIN_COLUMNS) {
1666
- columnsInput.value--;
1667
- }
1668
- };
1669
 
1670
- columnsIncrementButton.onclick = function () {
1671
- if (columnsInput.value < MAX_COLUMNS) {
1672
- columnsInput.value++;
1673
- }
1674
- };
1675
 
1676
- rowsDecrementButton.onclick = function () {
1677
- if (rowsInput.value > MIN_ROWS) {
1678
- rowsInput.value--;
1679
- }
 
 
 
 
1680
  };
1681
 
1682
- rowsIncrementButton.onclick = function () {
1683
- if (rowsInput.value < MAX_ROWS) {
1684
- rowsInput.value++;
1685
- }
1686
- };
1687
 
1688
- document.getElementById('wptb-generate-table').onclick = function () {
1689
- var columns = document.getElementById('wptb-columns-number').value,
1690
- rows = document.getElementById('wptb-rows-number').value;
 
 
1691
 
1692
- WPTB_Table(columns, rows);
1693
 
1694
- var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
1695
- wptbTableStateSaveManager.tableStateSet();
1696
- };
1697
- };
1698
- var WPTB_LeftPanel = function WPTB_LeftPanel() {
1699
 
1700
- var table = document.getElementsByClassName('wptb-preview-table')[0],
1701
- wptbElementButtons = document.getElementsByClassName('wptb-element');
1702
 
1703
- function wptbTdBgColorSavedSet(inputId, trNumber) {
1704
- if (trNumber > 3) return;
1705
- if (table) {
1706
- var tableRows = table.getElementsByTagName('tr');
1707
- if (tableRows.length > trNumber) {
1708
- var trBackgroundColor = tableRows[trNumber].style.backgroundColor;
1709
- var wptbEvenRowBg = document.getElementById(inputId);
1710
- if (wptbEvenRowBg && trBackgroundColor) {
1711
- wptbEvenRowBg.value = WPTB_Helper.rgbToHex(trBackgroundColor);
1712
- }
1713
- }
1714
  }
1715
- }
1716
 
1717
- wptbTdBgColorSavedSet('wptb-even-row-bg', 1);
1718
- jQuery('#wptb-even-row-bg').wpColorPicker({
1719
- change: function change(event, ui) {
1720
- var tableRows = table.getElementsByTagName('tr');
1721
- for (var _i = 1; _i < tableRows.length; _i += 2) {
1722
- tableRows[_i].style.backgroundColor = ui.color.toString();
1723
- }
1724
- WPTB_Helper.wpColorPickerCheckChangeForTableStateSaving(event);
1725
- },
1726
- clear: function clear() {
1727
- var tableRows = table.getElementsByTagName('tr');
1728
- for (var _i2 = 1; _i2 < tableRows.length; _i2 += 2) {
1729
- tableRows[_i2].style.backgroundColor = '';
1730
- var tds = tableRows[_i2].getElementsByTagName('td');
1731
- for (var j = 0; j < tds.length; j++) {
1732
- tds[j].style.backgroundColor = '';
1733
- }
1734
- }
1735
 
1736
- var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
1737
- wptbTableStateSaveManager.tableStateSet();
 
 
 
 
1738
  }
1739
 
1740
- });
1741
-
1742
- wptbTdBgColorSavedSet('wptb-odd-row-bg', 2);
1743
- jQuery('#wptb-odd-row-bg').wpColorPicker({
1744
- change: function change(event, ui) {
1745
- var tableRows = table.getElementsByTagName('tr');
1746
- for (var _i3 = 2; _i3 < tableRows.length; _i3 += 2) {
1747
- tableRows[_i3].style.backgroundColor = ui.color.toString();
1748
- }
1749
-
1750
- WPTB_Helper.wpColorPickerCheckChangeForTableStateSaving(event);
1751
- },
1752
- clear: function clear() {
1753
- var tableRows = table.getElementsByTagName('tr');
1754
- for (var _i4 = 2; _i4 < tableRows.length; _i4 += 2) {
1755
- tableRows[_i4].style.backgroundColor = '';
1756
- var tds = tableRows[_i4].getElementsByTagName('td');
1757
- for (var j = 0; j < tds.length; j++) {
1758
- tds[j].style.backgroundColor = '';
1759
- }
1760
- }
1761
 
1762
- var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
1763
- wptbTableStateSaveManager.tableStateSet();
1764
- }
1765
- });
1766
 
1767
- wptbTdBgColorSavedSet('wptb-table-header-bg', 0);
1768
- jQuery('#wptb-table-header-bg').wpColorPicker({
1769
- change: function change(event, ui) {
1770
- var tableHeader = table.getElementsByTagName('tr')[0];
1771
- tableHeader.style.backgroundColor = ui.color.toString();
1772
 
1773
- var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
1774
- wptbTableStateSaveManager.tableStateSet();
1775
- },
1776
- clear: function clear() {
1777
- var tableHeader = table.getElementsByTagName('tr')[0];
1778
- tableHeader.style.backgroundColor = '';
1779
- var tds = tableHeader.getElementsByTagName('td');
1780
- for (var j = 0; j < tds.length; j++) {
1781
- tds[j].style.backgroundColor = '';
1782
- }
1783
 
1784
- WPTB_Helper.wpColorPickerCheckChangeForTableStateSaving(event);
1785
- }
1786
- });
 
 
1787
 
1788
- function tableAdaptiveForMobile(table) {
1789
- var wptbAdaptiveTableCheckbox = document.getElementById('wptb-adaptive-table-checkbox');
1790
- if (table && table.dataset.wptbAdaptiveTable && table.dataset.wptbAdaptiveTable == "1") {
1791
- wptbAdaptiveTableCheckbox.checked = true;
1792
- } else {
1793
- wptbAdaptiveTableCheckbox.checked = false;
1794
- }
1795
- }
1796
- tableAdaptiveForMobile(table);
1797
 
1798
- function tableTopRowAsHeadSavedSet(table) {
1799
- var wptbTopRowAsHeader = document.getElementById('wptb-top-row-as-header');
 
1800
 
1801
- if (table && table.classList.contains('wptb-table-preview-head')) {
1802
- wptbTopRowAsHeader.checked = true;
1803
- } else {
1804
- wptbTopRowAsHeader.checked = false;
1805
- }
1806
- }
1807
- tableTopRowAsHeadSavedSet(table);
1808
-
1809
- function tableBorderColorWidthSavedSet() {
1810
- var table = document.getElementsByClassName('wptb-preview-table');
1811
- if (table.length > 0) {
1812
- var tableBorderColor = table[0].style.borderColor;
1813
- if (tableBorderColor) {
1814
- var tableBorderColorInput = document.getElementById('wptb-table-border-color');
1815
- if (tableBorderColorInput) {
1816
- tableBorderColorInput.value = WPTB_Helper.rgbToHex(tableBorderColor);
1817
  }
1818
  }
1819
 
1820
- var tableBorderWidth = table[0].style.borderWidth;
1821
- if (tableBorderWidth) {
1822
- var wptbTableBorderWidthSlider = document.getElementById('wptb-table-border-slider'),
1823
- wptbTableBorderWidthNumber = document.getElementById('wptb-table-border-number');
1824
 
1825
- if (wptbTableBorderWidthSlider) {
1826
- wptbTableBorderWidthSlider.value = parseInt(tableBorderWidth);
1827
- }
1828
- if (wptbTableBorderWidthNumber) {
1829
- wptbTableBorderWidthNumber.value = parseInt(tableBorderWidth);
1830
- }
1831
- }
1832
 
1833
- var tableTd = table[0].querySelector('td');
1834
- var applyInnerBorder = tableTd.style.borderWidth;
1835
- if (applyInnerBorder) {
1836
- var innerBorderCheckInput = document.getElementById('wptb-inner-border-check');
1837
- var wptbApplyInnerBorder = document.getElementById('wptb-apply-inner-border');
1838
- if (applyInnerBorder && parseInt(applyInnerBorder) > 0) {
1839
- if (innerBorderCheckInput) {
1840
- innerBorderCheckInput.checked = true;
1841
-
1842
- if (wptbApplyInnerBorder) {
1843
- wptbApplyInnerBorder.classList.add('visible');
1844
- var wptbTableInnerBorderSlider = document.getElementById('wptb-table-inner-border-slider');
1845
- var _wptbTableInnerBorderNumber = document.getElementById('wptb-table-inner-border-number');
1846
- wptbTableInnerBorderSlider.value = parseInt(applyInnerBorder);
1847
- _wptbTableInnerBorderNumber.value = parseInt(applyInnerBorder);
1848
- }
1849
- }
1850
- } else {
1851
- innerBorderCheckInput.checked = false;
1852
- }
1853
  }
1854
 
1855
- if (tableBorderWidth && parseInt(tableBorderWidth) > 0 || applyInnerBorder && parseInt(applyInnerBorder) > 0) {
1856
- document.getElementById('wptb-table-border-color-set-area').style.display = '';
1857
  }
1858
- }
1859
- }
1860
 
1861
- tableBorderColorWidthSavedSet();
1862
 
1863
- jQuery('#wptb-table-border-color').wpColorPicker({
1864
- change: function change(event, ui) {
1865
- var tableCells = table.getElementsByTagName('td');
1866
- table.style.border = document.querySelector('#wptb-table-border-number').value + 'px solid ' + ui.color.toString();
1867
 
1868
- for (var i = 0; i < tableCells.length; i++) {
1869
- var tableInnerborderNumber = document.querySelector('#wptb-table-inner-border-number').value;
1870
- if (document.getElementById('wptb-inner-border-check').checked) {
1871
- tableCells[i].style.border = (tableInnerborderNumber != 0 ? tableInnerborderNumber : 1) + 'px solid ' + ui.color.toString();
1872
- }
 
 
 
 
1873
  }
1874
- WPTB_Helper.wpColorPickerCheckChangeForTableStateSaving(event);
1875
- },
1876
- clear: function clear() {
1877
- var tableCells = table.getElementsByTagName('td');
1878
- table.style.borderColor = '';
1879
 
1880
- for (var i = 0; i < tableCells.length; i++) {
1881
- tableCells[i].style.borderColor = '';
1882
- }
1883
 
1884
- var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
1885
- wptbTableStateSaveManager.tableStateSet();
 
 
 
1886
  }
1887
- });
1888
 
1889
- function addInnerBorderSize(value) {
1890
- var tableCells = table.getElementsByTagName('td');
1891
- for (var i = 0; i < tableCells.length; i++) {
1892
- tableCells[i].style.borderWidth = document.querySelector('#wptb-table-inner-border-number').value + 'px';
1893
- tableCells[i].style.borderStyle = 'solid';
1894
  }
1895
- }
1896
 
1897
- function addCellPadding(value) {
1898
- var tableCells = table.getElementsByTagName('td');
1899
- for (var i = 0; i < tableCells.length; i++) {
1900
- tableCells[i].style.padding = value + 'px';
 
 
 
 
 
 
 
 
 
 
 
 
1901
  }
1902
- }
1903
 
1904
- function addInnerBorder(checked) {
1905
- var styles,
1906
- color = document.querySelector('#wptb-table-border-color').value != undefined ? document.querySelector('#wptb-table-border-color').value : 'rgb(0,0,0)';
1907
- if (document.querySelector('#wptb-table-inner-border-slider').value == 0 || document.querySelector('#wptb-table-inner-border-number').value == 0) {
1908
- document.querySelector('#wptb-table-inner-border-slider').value = 1;
1909
- document.querySelector('#wptb-table-inner-border-number').value = 1;
1910
- }
1911
- var width = document.querySelector('#wptb-table-inner-border-slider').value + 'px';
1912
- var wptbPreviewTable = document.getElementsByClassName('wptb-preview-table');
1913
- if (wptbPreviewTable.length > 0) {
1914
- if (checked == 'checked') {
1915
- document.getElementById('wptb-apply-inner-border').style.marginBottom = '0px';
1916
- var tableCells = wptbPreviewTable[0].getElementsByTagName('td');
1917
- for (var i = 0; i < tableCells.length; i++) {
1918
- tableCells[i].style.border = width + ' solid ' + color;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1919
  }
1920
- document.getElementById('wptb-apply-inner-border').classList.add('visible');
1921
  } else {
1922
- document.getElementById('wptb-apply-inner-border').classList.remove('visible');
1923
- var tableCells = wptbPreviewTable[0].getElementsByTagName('td');
1924
- for (var i = 0; i < tableCells.length; i++) {
1925
- tableCells[i].style.border = '0px solid ' + color;
1926
- tableCells[i].style.border = null;
 
1927
  }
1928
  }
1929
  }
1930
- }
1931
-
1932
- function addBorderSize(value) {
1933
- table.style.borderWidth = value + 'px';
1934
- table.style.borderStyle = 'solid';
1935
- }
1936
 
1937
- function cellPaddingSavedSet() {
1938
- var table = document.getElementsByClassName('wptb-preview-table');
 
 
 
 
 
 
 
 
 
1939
 
1940
- if (table.length > 0) {
1941
- var td = table[0].querySelector('td');
 
1942
 
1943
- if (td) {
1944
- var padding = td.style.padding;
1945
 
1946
- if (padding) {
1947
- var wptbTableCellSlider = document.getElementById('wptb-table-cell-slider'),
1948
- _wptbTableCellNumber = document.getElementById('wptb-table-cell-number');
1949
 
1950
- if (wptbTableCellSlider) {
1951
- wptbTableCellSlider.value = parseInt(padding);
1952
- }
1953
- if (_wptbTableCellNumber) {
1954
- _wptbTableCellNumber.value = parseInt(padding);
 
 
 
1955
  }
1956
  }
1957
  }
1958
  }
1959
- }
 
 
 
 
 
 
 
 
 
 
 
1960
 
1961
- cellPaddingSavedSet();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1962
 
1963
- var wptbTableBorderNumber = document.getElementById('wptb-table-border-number');
1964
- WPTB_Helper.numberImputSize(wptbTableBorderNumber, 1, 50);
 
 
 
 
 
1965
 
1966
- var wptbTableInnerBorderNumber = document.getElementById('wptb-table-inner-border-number');
1967
- WPTB_Helper.numberImputSize(wptbTableInnerBorderNumber, 1, 50);
 
 
 
 
1968
 
1969
- var wptbTableCellNumber = document.getElementById('wptb-table-cell-number');
1970
- WPTB_Helper.numberImputSize(wptbTableCellNumber, 1, 50);
1971
 
1972
- // let wptbTextfontSizeNumber = document.getElementById( 'wptb-size-number' );
1973
- // WPTB_Helper.numberImputSize( wptbTextfontSizeNumber, 1, 50 );
1974
- //
1975
- // let wptbImageWidthNumber = document.getElementById( 'wptb-size-number' );
1976
- // WPTB_Helper.numberImputSize( wptbImageWidthNumber, 2, 100 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1977
 
1978
- var wptbTableColumnWidthNumber = document.getElementById('wptb-table-column-width-number');
1979
- WPTB_Helper.numberImputSize(wptbTableColumnWidthNumber, 2, 500);
 
1980
 
1981
- var wptbTableRowHeightNumber = document.getElementById('wptb-table-row-height-number');
1982
- WPTB_Helper.numberImputSize(wptbTableRowHeightNumber, 2, 200);
 
1983
 
1984
- document.getElementById('wptb-table-cell-slider').oninput = function () {
1985
- document.getElementById('wptb-table-cell-number').value = this.value;
1986
- addCellPadding(this.value);
1987
- table.tdDefaultWidth();
1988
- };
1989
 
1990
- document.getElementById('wptb-table-cell-slider').onchange = function () {
1991
- var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
1992
- wptbTableStateSaveManager.tableStateSet();
1993
- };
 
1994
 
1995
- document.getElementById('wptb-table-cell-number').onchange = function () {
1996
- document.getElementById('wptb-table-cell-slider').value = this.value;
1997
- addCellPadding(this.value);
1998
- table.tdDefaultWidth();
1999
 
2000
- var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
2001
- wptbTableStateSaveManager.tableStateSet();
2002
- };
 
 
 
 
 
 
 
 
 
2003
 
2004
- document.getElementById('wptb-table-border-slider').oninput = function () {
2005
- document.getElementById('wptb-table-border-number').value = this.value;
2006
- addBorderSize(this.value);
2007
- table.tdDefaultWidth();
 
 
 
2008
 
2009
- var wptbInnerBorderCheck = document.getElementById('wptb-inner-border-check').checked,
2010
- tableBorderColorSetArea = document.getElementById('wptb-table-border-color-set-area');
2011
- if (this.value == 0 && wptbInnerBorderCheck == false) {
2012
- tableBorderColorSetArea.style.display = 'none';
2013
- } else {
2014
- tableBorderColorSetArea.style.display = '';
2015
  }
2016
- };
2017
 
2018
- document.getElementById('wptb-table-border-slider').onchange = function () {
2019
- var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
2020
- wptbTableStateSaveManager.tableStateSet();
2021
- };
2022
 
2023
- document.getElementById('wptb-table-border-number').onchange = function () {
2024
- document.getElementById('wptb-table-border-slider').value = this.value;
2025
- addBorderSize(this.value);
2026
- table.tdDefaultWidth();
2027
- var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
2028
- wptbTableStateSaveManager.tableStateSet();
2029
- };
2030
 
2031
- document.getElementById('wptb-table-inner-border-slider').oninput = function () {
2032
- document.getElementById('wptb-table-inner-border-number').value = this.value;
2033
- addInnerBorderSize(this.value);
2034
- table.tdDefaultWidth();
2035
- };
2036
 
2037
- document.getElementById('wptb-table-inner-border-slider').onchange = function () {
2038
- var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
2039
- wptbTableStateSaveManager.tableStateSet();
2040
- };
2041
 
2042
- document.getElementById('wptb-table-inner-border-number').onchange = function () {
2043
- document.getElementById('wptb-table-inner-border-slider').value = this.value;
2044
- addInnerBorderSize(this.value);
2045
- table.tdDefaultWidth();
2046
- var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
2047
- wptbTableStateSaveManager.tableStateSet();
2048
- };
 
 
 
 
 
 
 
 
 
2049
 
2050
- document.getElementById('wptb-inner-border-check').onchange = function () {
2051
- if (table) {
2052
- var val = this.checked ? 'checked' : 'unchecked';
2053
- addInnerBorder(val);
2054
- var borderWidth = document.getElementById('wptb-table-border-slider').value,
2055
- tableBorderColorSetArea = document.getElementById('wptb-table-border-color-set-area');
2056
- if (val == 'unchecked' && borderWidth == 0) {
2057
- tableBorderColorSetArea.style.display = 'none';
2058
- } else {
2059
- tableBorderColorSetArea.style.display = '';
2060
- }
2061
 
2062
- var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
2063
- wptbTableStateSaveManager.tableStateSet();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2064
  }
2065
- };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2066
 
2067
  document.getElementById('wptb-table-column-width-slider').oninput = function () {
2068
  document.getElementById('wptb-table-column-width-number').value = this.value;
@@ -2132,59 +2269,52 @@ var WPTB_LeftPanel = function WPTB_LeftPanel() {
2132
 
2133
  var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
2134
  wptbTableStateSaveManager.tableStateSet();
2135
- };
2136
-
2137
- document.getElementById('wptb-adaptive-table-checkbox').onchange = function () {
2138
- if (this.checked) {
2139
- table.dataset.wptbAdaptiveTable = 1;
2140
- } else {
2141
- table.dataset.wptbAdaptiveTable = 0;
2142
- }
2143
- var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
2144
- wptbTableStateSaveManager.tableStateSet();
2145
- };
2146
-
2147
- function createMobileHeadForTable(table, thisEvent) {
2148
-
2149
- if (thisEvent.checked) {
2150
- WPTB_Helper.dataTitleColumnSet(table);
2151
 
2152
- table.classList.add('wptb-table-preview-head');
2153
- table.rows[0].classList.add('wptb-table-head');
2154
- } else {
2155
- var rows = table.rows;
2156
- table.classList.remove('wptb-table-preview-head');
2157
- rows[0].classList.remove('wptb-table-head');
2158
-
2159
- for (var _i5 = 1; _i5 < rows.length; _i5++) {
2160
- var thisRow = rows[_i5],
2161
- thisRowChildren = thisRow.children;
2162
- for (var j = 0; j < thisRowChildren.length; j++) {
2163
- thisRowChildren[j].removeAttribute('data-wptb-title-column');
2164
- thisRowChildren[j].removeAttribute('data-wptb-title-column-font-size');
2165
- thisRowChildren[j].removeAttribute('data-wptb-title-column-color');
2166
- thisRowChildren[j].removeAttribute('data-wptb-title-background-color');
2167
- thisRowChildren[j].removeAttribute('data-wptb-title-align');
 
 
 
 
 
2168
  }
 
 
 
 
 
 
 
 
2169
  }
2170
  }
2171
  }
2172
 
2173
- document.getElementById('wptb-top-row-as-header').onchange = function () {
2174
- createMobileHeadForTable(table, this);
2175
- var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
2176
- wptbTableStateSaveManager.tableStateSet();
2177
- };
2178
 
2179
  for (var i = 0; i < wptbElementButtons.length; i++) {
2180
  wptbElementButtons[i].ondragstart = function (e) {
2181
  e.dataTransfer.setData('wptbElement', this.dataset.wptbElement);
2182
  e.dataTransfer.setData('wptbElIndic-' + this.dataset.wptbElement, 'wptbElIndic-' + this.dataset.wptbElement);
2183
  };
2184
- }
2185
 
2186
  if (table) {
2187
- document.getElementById('wptb-activate-cell-management-mode').onclick = table.toggleTableEditMode;
2188
  document.getElementById('wptb-table-edit-mode-close').onclick = table.toggleTableEditMode;
2189
  document.getElementById('wptb-left-scroll-panel-curtain-close').onclick = table.toggleTableEditMode;
2190
  document.getElementById('wptb-add-end-row').onclick = table.addRowToTheEnd;
@@ -2199,7 +2329,7 @@ var WPTB_LeftPanel = function WPTB_LeftPanel() {
2199
  document.getElementById('wptb-delete-row').onclick = table.deleteRow;
2200
  document.getElementById('wptb-merge-cells').onclick = table.mergeCells;
2201
  document.getElementById('wptb-split-cell').onclick = table.splitCell;
2202
- }
2203
 
2204
  document.querySelector('.wptb-left-panel-extend').onclick = function () {
2205
  var wptbContainer = document.querySelector('.wptb-container');
@@ -2217,30 +2347,15 @@ var WPTB_LeftPanel = function WPTB_LeftPanel() {
2217
  var wptbBuilderPanel = document.getElementsByClassName('wptb-builder-panel')[0];
2218
  wptbBuilderPanel.onclick = function (e) {
2219
  if (!e.target.classList.contains('wptb-ph-element') && !WPTB_Helper.findAncestor(e.target, 'wptb-ph-element') && !e.target.classList.contains('wptb-fixed-toolbar') && !WPTB_Helper.findAncestor(e.target, 'wptb-fixed-toolbar')) {
2220
- clickOnFreeSpace();
2221
  }
2222
  };
2223
 
2224
  var wptbHeader = document.getElementsByClassName('wptb-header');
2225
  if (wptbHeader.length > 0) wptbHeader = wptbHeader[0];
2226
  wptbHeader.onclick = function () {
2227
- clickOnFreeSpace();
2228
  };
2229
-
2230
- function clickOnFreeSpace() {
2231
- document.getElementsByClassName('wptb-elements-container')[0].style.display = 'table';
2232
- document.getElementsByClassName('wptb-settings-section')[0].style.display = 'block';
2233
- document.getElementById('element-options-group').style.display = 'none';
2234
- var wpcdFixedToolbar = document.getElementById('wpcd_fixed_toolbar');
2235
- if (wpcdFixedToolbar.hasAttribute('data-toolbar-active-id')) {
2236
- document.getElementById(wpcdFixedToolbar.getAttribute('data-toolbar-active-id')).classList.remove('toolbar-active');
2237
- }
2238
- }
2239
- document.querySelector('.wptb-panel-left').addEventListener('click', function (event) {
2240
- if (event.target.classList.contains('wptb-exit-options')) {
2241
- clickOnFreeSpace();
2242
- }
2243
- });
2244
  };
2245
  var MultipleSelect = function MultipleSelect() {
2246
 
@@ -2390,7 +2505,7 @@ var WPTB_Settings = function WPTB_Settings() {
2390
  WPTB_Helper.elementDragEndClear();
2391
  };
2392
  };
2393
-
2394
  var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
2395
  var wptbUndo = document.getElementsByClassName('wptb-undo');
2396
  if (wptbUndo.length > 0) {
@@ -2400,7 +2515,7 @@ var WPTB_Settings = function WPTB_Settings() {
2400
  if (!this.classList.contains('wptb-undoredo-disabled')) {
2401
  wptbTableStateSaveManager.tableStateGet(this.dataset.wptbUndoredo);
2402
  var wptbUndoRedoContainer = document.getElementsByClassName('wptb-undo-redo-container');
2403
- if (wptbUndoRedoContainer.length > 0) {
2404
  wptbUndoRedoContainer = wptbUndoRedoContainer[0];
2405
  wptbUndoRedoContainer.onmouseleave = function (event) {
2406
  event.target.onmouseleave = '';
@@ -2419,7 +2534,7 @@ var WPTB_Settings = function WPTB_Settings() {
2419
  if (!this.classList.contains('wptb-undoredo-disabled')) {
2420
  wptbTableStateSaveManager.tableStateGet(this.dataset.wptbUndoredo);
2421
  var wptbUndoRedoContainer = document.getElementsByClassName('wptb-undo-redo-container');
2422
- if (wptbUndoRedoContainer.length > 0) {
2423
  wptbUndoRedoContainer = wptbUndoRedoContainer[0];
2424
  wptbUndoRedoContainer.onmouseleave = function (event) {
2425
  event.target.onmouseleave = '';
@@ -2454,111 +2569,27 @@ var WPTB_Settings = function WPTB_Settings() {
2454
  shortcodePopupWindow.classList.remove('wptb-popup-show');
2455
  };
2456
 
2457
- document.getElementsByClassName('wptb-preview-btn')[0].onclick = function (e) {
2458
  if (this.classList.contains('wptb-button-disable')) {
2459
- e.preventDefault();
2460
- }
2461
- };
2462
-
2463
- document.getElementsByClassName('wptb-save-btn')[0].onclick = function (event) {
2464
- if (!event.target.dataset.wptbTableStateNumberSave && window.wptbTableStateNumberShow == 0 || window.wptbTableStateNumberShow == event.target.dataset.wptbTableStateNumberSave) {
2465
  return;
2466
  }
2467
- var bar = document.querySelector('.wptb-edit-bar');
2468
- if (bar && bar.classList.contains('visible')) {
2469
- var table = document.getElementsByClassName('wptb-preview-table')[0];
2470
- table.toggleTableEditMode();
2471
- }
2472
-
2473
- var http = new XMLHttpRequest(),
2474
- url = (wptb_admin_object ? wptb_admin_object.ajaxurl : ajaxurl) + "?action=save_table",
2475
- t = document.getElementById('wptb-setup-name').value.trim(),
2476
- messagingArea = void 0,
2477
- code = void 0,
2478
- datas = void 0;
2479
- code = document.getElementsByClassName('wptb-preview-table');
2480
- if (code.length > 0) {
2481
- code = WPTB_Stringifier(code[0]);
2482
- code = code.outerHTML;
2483
- } else {
2484
- code = '';
2485
- }
2486
-
2487
- datas = '';
2488
- var datas_containers = document.getElementsByClassName('wptb-element-datas');
2489
 
2490
- if (datas_containers.length > 0) {
2491
- if (datas_containers[0].innerHTML) {
2492
- datas = datas_containers[0].innerHTML;
2493
- }
2494
- }
2495
 
2496
- if (t === '' || code === '') {
2497
- var messagingAreaText = '';
2498
- if (t === '') messagingAreaText += 'You must assign a name to the table before saving it.</br>';
2499
- if (code === '') messagingAreaText += 'Table wasn\'t created';
2500
- messagingArea = document.getElementById('wptb-messaging-area');
2501
- messagingArea.innerHTML = '<div class="wptb-error wptb-message">Error: ' + messagingAreaText + '</div>';
2502
- messagingArea.classList.add('wptb-warning');
2503
- setTimeout(function () {
2504
- messagingArea.removeChild(messagingArea.firstChild);
2505
- }, 4000);
2506
- return;
2507
- }
2508
 
2509
- var params = {
2510
- title: t,
2511
- content: code,
2512
- elements_datas: datas,
2513
- security_code: wptb_admin_object.security_code
2514
- };
2515
- if ((rs = WPTB_Helper.detectMode()) || (rs = document.wptbId)) {
2516
- params.id = rs;
2517
  }
2518
- params = JSON.stringify(params);
2519
-
2520
- http.open('POST', url, true);
2521
- http.setRequestHeader('Content-type', 'application/json; charset=utf-8');
2522
-
2523
- http.onreadystatechange = function (action) {
2524
- if (this.readyState == 4 && this.status == 200) {
2525
- var data = JSON.parse(http.responseText);
2526
- messagingArea = document.getElementById('wptb-messaging-area');
2527
-
2528
- if (data[0] == 'saved') {
2529
- document.wptbId = data[1];
2530
- messagingArea.innerHTML = '<div class="wptb-success wptb-message">Table "' + t + '" was successfully saved.</div>';
2531
- document.getElementsByClassName('wptb-embed-btn')[0].classList.remove('wptb-button-disable');
2532
- document.getElementById('wptb-embed-shortcode').value = '[wptb id=' + data[1] + ']';
2533
- var wptbPreviewBtn = document.getElementsByClassName('wptb-preview-btn');
2534
- if (wptbPreviewBtn.length > 0) {
2535
- wptbPreviewBtn = wptbPreviewBtn[0];
2536
- wptbPreviewBtn.classList.remove('wptb-button-disable');
2537
- var wptbPreviewBtnHref = wptbPreviewBtn.dataset.previewHref;
2538
- wptbPreviewBtnHref = wptbPreviewBtnHref.replace('empty', data[1]);
2539
- wptbPreviewBtn.setAttribute('href', wptbPreviewBtnHref);
2540
- }
2541
- } else if (data[0] == 'edited') {
2542
- messagingArea.innerHTML = '<div class="wptb-success wptb-message">Table "' + t + '" was successfully updated.</div>';
2543
- event.target.dataset.wptbTableStateNumberSave = window.wptbTableStateNumberShow;
2544
-
2545
- var wptbSaveBtn = document.getElementsByClassName('wptb-save-btn');
2546
- if (wptbSaveBtn.length > 0) {
2547
- wptbSaveBtn = wptbSaveBtn[0];
2548
- wptbSaveBtn.classList.add('wptb-save-disabled');
2549
- }
2550
- } else {
2551
- messagingArea.innerHTML = '<div class="wptb-error wptb-message">Safety problems</div>';
2552
- }
2553
- messagingArea.classList.add('wptb-success');
2554
- setTimeout(function () {
2555
- messagingArea.removeChild(messagingArea.firstChild);
2556
- }, 4000);
2557
- }
2558
- };
2559
- http.send(params);
2560
  };
2561
  };
 
 
2562
  var WPTB_Stringifier = function WPTB_Stringifier(codeMain) {
2563
  if (codeMain) {
2564
  var code = codeMain.cloneNode(true);
@@ -2628,6 +2659,16 @@ var WPTB_Stringifier = function WPTB_Stringifier(codeMain) {
2628
  break;
2629
  }
2630
  }
 
 
 
 
 
 
 
 
 
 
2631
  }
2632
  }
2633
 
@@ -3034,12 +3075,7 @@ var array = [],
3034
  }
3035
  };
3036
 
3037
- jQuery('#wptb-table-header-bg').val('');
3038
- jQuery('#wptb-even-row-bg').val('');
3039
- jQuery('#wptb-odd-row-bg').val('');
3040
  jQuery('#wptb-table-border-color').val('');
3041
- jQuery('#wptb-table-inner-border-number,#wptb-table-inner-border-slider').val('0');
3042
- jQuery('#wptb-table-border-number,#wptb-table-border-slider').val('0');
3043
  jQuery('#wptb-table-padding-number,#wptb-table-padding-slider').val('15');
3044
 
3045
  if (columns || rows) {
@@ -3052,7 +3088,8 @@ var array = [],
3052
 
3053
  //Create a HTML Table element.
3054
  table = document.createElement('table');
3055
- table.classList.add('wptb-preview-table');
 
3056
  table.dataset.reconstraction = 1;
3057
  table.dataset.wptbAdaptiveTable = 1;
3058
  //Add the data rows.
@@ -3064,6 +3101,7 @@ var array = [],
3064
  for (var j = 0; j < columns; j++) {
3065
  cell = new WPTB_Cell(mark);
3066
  cell.setCoords(i, j);
 
3067
  row.appendChild(cell.getDOMElement());
3068
  }
3069
  }
@@ -3080,6 +3118,8 @@ var array = [],
3080
  WPTB_Cell(mark, cells[_i]);
3081
  }
3082
  }
 
 
3083
  }
3084
  }
3085
 
@@ -3135,37 +3175,28 @@ var array = [],
3135
  maxCols = 0,
3136
  maxColsFull = 0,
3137
  tdsArr = [];
3138
- var wptbTopRowAsHeader = document.getElementById('wptb-top-row-as-header');
3139
 
3140
  for (var i = 0; i < trs.length; i++) {
3141
  if (i == 0) {
3142
- if (start == undefined) {
3143
- trs[i].style.backgroundColor = jQuery('#wptb-table-header-bg').val();
3144
- }
3145
- if (wptbTopRowAsHeader.checked) {
3146
- if (start == undefined) {
3147
- this.classList.add('wptb-table-preview-head');
3148
- trs[i].classList.add('wptb-table-head');
3149
- };
3150
- } else {
3151
- if (start == undefined) {
3152
- this.classList.remove('wptb-table-preview-head');
3153
- trs[i].classList.remove('wptb-table-head');
3154
- }
3155
- }
3156
  } else {
3157
- if (i % 2 == 0) {
3158
- if (start == undefined) {
3159
- trs[i].style.backgroundColor = jQuery('#wptb-odd-row-bg').val();
3160
- }
3161
- trs[i].classList.remove('wptb-table-head');
3162
- } else {
3163
- if (start == undefined) {
3164
- trs[i].style.backgroundColor = jQuery('#wptb-even-row-bg').val();
3165
- }
3166
- trs[i].classList.remove('wptb-table-head');
3167
  }
3168
- }
3169
 
3170
  tdsArr[i];
3171
  tds = trs[i].getElementsByTagName('td');
@@ -3304,18 +3335,23 @@ var array = [],
3304
  var tableTdBorderCommonWidth = 0;
3305
  var cssForTdsWidthAuto = '';
3306
 
 
 
 
 
 
3307
  for (var _i5 = 0; _i5 < rows.length; _i5++) {
3308
  var tds = rows[_i5].children;
3309
  for (var _j2 = 0; _j2 < tds.length; _j2++) {
3310
  var td = tds[_j2];
3311
 
3312
- if (!arrayCellsWidthFixedHelper[parseInt(td.dataset.xIndex)] && !arrayCellsWidthAutoHelper[parseInt(td.dataset.xIndex)]) {
3313
  if (td.style.width) {
3314
- arrayCellsWidthFixedHelper[parseInt(td.dataset.xIndex)] = parseFloat(td.style.width);
3315
  td.removeAttribute('data-wptb-css-td-auto-width');
3316
  } else {
3317
  if (!td.dataset.wptbFixedWidth) {
3318
- arrayCellsWidthAutoHelper[parseInt(td.dataset.xIndex)] = 100;
3319
  td.dataset.wptbCssTdAutoWidth = true;
3320
  }
3321
  }
@@ -3329,19 +3365,45 @@ var array = [],
3329
  var tableTdBorderLeftWidth = tdStyleObj.getPropertyValue('border-left-width');
3330
  var tableTdBorderRightWidth = tdStyleObj.getPropertyValue('border-right-width');
3331
  tableTdBorderCommonWidth = parseFloat(tableTdBorderLeftWidth, 10) + parseFloat(tableTdBorderRightWidth, 10);
3332
- if (arrayCellsWidthFixedHelper[parseInt(td.dataset.xIndex)]) {
3333
- arrayCellsWidthFixedHelper[parseInt(td.dataset.xIndex)] += tdPaddingCommon;
3334
- arrayCellsWidthFixedHelper[parseInt(td.dataset.xIndex)] += tableTdBorderCommonWidth;
3335
- } else {
3336
- arrayCellsWidthAutoHelper[parseInt(td.dataset.xIndex)] += tdPaddingCommon;
3337
- arrayCellsWidthAutoHelper[parseInt(td.dataset.xIndex)] += tableTdBorderCommonWidth;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3338
  }
3339
  }
3340
- } else if (arrayCellsWidthAutoHelper[parseInt(td.dataset.xIndex)]) {
3341
  if (!td.dataset.wptbFixedWidth) {
3342
  td.dataset.wptbCssTdAutoWidth = true;
3343
  }
3344
- } else if (arrayCellsWidthFixedHelper[parseInt(td.dataset.xIndex)]) {
3345
  td.removeAttribute('data-wptb-css-td-auto-width');
3346
  }
3347
  }
@@ -3361,17 +3423,13 @@ var array = [],
3361
  }
3362
  }
3363
 
3364
- var tableFullStyleObj = window.getComputedStyle(table, null);
3365
- var borderLeftWidth = tableFullStyleObj.getPropertyValue('border-left-width');
3366
- var borderRightWidth = tableFullStyleObj.getPropertyValue('border-right-width');
3367
- var tableBorderCommon = parseFloat(borderLeftWidth, 10) + parseFloat(borderRightWidth, 10);
3368
- tableTdsSumMaxWidth = tableTdsSumMaxWidthFixed + tableTdsSumMaxWidthAuto + tableBorderCommon;
3369
 
3370
  table.dataset.wptbTableTdsSumMaxWidth = tableTdsSumMaxWidth;
3371
  if (CellsWidthAutoCount) {
3372
  table.dataset.wptbCellsWidthAutoCount = CellsWidthAutoCount;
3373
  if (table.mergingСellsHorizontally) {
3374
- table.dataset.wptbFixedWidthSize = tableTdsSumMaxWidthFixed - tableBorderCommon;
3375
  } else {
3376
  table.removeAttribute('data-wptb-fixed-width-size');
3377
  }
@@ -3387,7 +3445,7 @@ var array = [],
3387
  table.style.minWidth = '100%';
3388
  if (table.mergingСellsHorizontally) {
3389
  table.style.width = null;
3390
- var tableTdsWidthAutoCommon = wptbTableSetupWidth - tableTdsSumMaxWidthFixed - tableBorderCommon;
3391
  tableTdWidthAuto = tableTdsWidthAutoCommon / CellsWidthAutoCount;
3392
  tableTdWidthAuto = tableTdWidthAuto - tdPaddingCommon - tableTdBorderCommonWidth;
3393
  styleElementCreate = true;
@@ -3397,7 +3455,7 @@ var array = [],
3397
  } else {
3398
  table.style.width = null;
3399
  table.style.minWidth = null;
3400
- table.style.maxWidth = tableTdsSumMaxWidth + 'px';
3401
  }
3402
  } else {
3403
  table.style.maxWidth = null;
@@ -3491,26 +3549,19 @@ var array = [],
3491
 
3492
  table.reconstraction = function () {
3493
  var tds = table.getElementsByTagName('td');
3494
- var wptbAdaptiveTableChoseBlock = document.getElementsByClassName('wptb-adaptive-table-chose-block');
3495
- if (wptbAdaptiveTableChoseBlock.length > 0) {
3496
- wptbAdaptiveTableChoseBlock = wptbAdaptiveTableChoseBlock[0];
3497
- }
3498
  table.mergingСellsHorizontally = false;
3499
  table.mergingCellsVertically = false;
3500
  table.dataset.reconstraction = 1;
3501
- wptbAdaptiveTableChoseBlock.style.display = 'block';
3502
  var forBreak = 0;
3503
  for (var _i9 = 0; _i9 < tds.length; _i9++) {
3504
  if (tds[_i9].colSpan > 1) {
3505
  table.dataset.reconstraction = 0;
3506
- wptbAdaptiveTableChoseBlock.style.display = 'none';
3507
  table.mergingСellsHorizontally = true;
3508
  forBreak++;
3509
  }
3510
 
3511
  if (tds[_i9].rowSpan > 1) {
3512
  table.dataset.reconstraction = 0;
3513
- wptbAdaptiveTableChoseBlock.style.display = 'none';
3514
  table.mergingCellsVertically = true;
3515
  forBreak++;
3516
  }
@@ -4254,12 +4305,17 @@ var array = [],
4254
  if (table.rows.length == 0) {
4255
  table.toggleTableEditMode();
4256
  wptbTableSetup.innerHTML = '';
4257
- WPTB_Helper.settingsPanelClear();
4258
  document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';
4259
- }
 
 
4260
 
4261
- table.recalculateIndexes();
4262
- WPTB_Helper.dataTitleColumnSet(table);
 
 
 
 
4263
  }
4264
 
4265
  undoSelect();
@@ -4310,13 +4366,18 @@ var array = [],
4310
  if (table.querySelectorAll('td').length == 0) {
4311
  table.toggleTableEditMode();
4312
  wptbTableSetup.innerHTML = '';
4313
- WPTB_Helper.settingsPanelClear();
4314
  document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';
4315
- }
 
 
4316
 
4317
- table.recalculateIndexes();
4318
- table.tdDefaultWidth();
4319
- WPTB_Helper.dataTitleColumnSet(table);
 
 
 
 
4320
  }
4321
 
4322
  undoSelect();
@@ -4378,27 +4439,39 @@ var array = [],
4378
  // }, false );
4379
  // }
4380
  };
 
 
4381
  var WPTB_TableStateSaveManager = function WPTB_TableStateSaveManager() {
4382
- this.tableStateSet = function () {
 
 
 
 
 
4383
  // get preview table
4384
  var wptbPreviewTable = document.getElementsByClassName('wptb-preview-table');
4385
  if (wptbPreviewTable.length > 0) {
4386
  wptbPreviewTable = wptbPreviewTable[0];
 
 
 
4387
 
4388
- // check if a global array doesn't exist with saved versions of the table
4389
- // them create it
4390
- if (!window.wptbTableStateSaving) {
4391
- window.wptbTableStateSaving = [];
4392
- }
4393
 
4394
- // remove the extra part of the array after changing the table
4395
- // when it is showed in the not last modified version
4396
- if (window.wptbTableStateSaving.length > window.wptbTableStateNumberShow + 1) {
4397
- window.wptbTableStateSaving = window.wptbTableStateSaving.slice(0, window.wptbTableStateNumberShow + 1);
4398
- }
4399
 
4400
- //add new state of table
4401
- var wptbNewPreviewTable = wptbPreviewTable.cloneNode(true);
 
 
4402
  var wptbHighlighted = wptbNewPreviewTable.getElementsByClassName('wptb-highlighted');
4403
  for (var i = 0; i < wptbHighlighted.length; i++) {
4404
  wptbHighlighted[i].classList.remove('wptb-highlighted');
@@ -4407,81 +4480,81 @@ var WPTB_TableStateSaveManager = function WPTB_TableStateSaveManager() {
4407
  for (var _i = 0; _i < wptbDirectlyhovered.length; _i++) {
4408
  wptbDirectlyhovered[_i].classList.remove('wptb-directlyhovered');
4409
  }
4410
-
4411
- var cssForTdsWidthAutoValue = '';
4412
- var head = document.head;
4413
- if (head) {
4414
- var cssForTdsWidthAuto = head.querySelector('style[data-wptb-td-auto-width="true"]');
4415
- if (cssForTdsWidthAuto) {
4416
- cssForTdsWidthAutoValue = cssForTdsWidthAuto.innerHTML;
4417
- }
4418
- }
4419
-
4420
- var wptbDlementDatas = document.getElementsByClassName('wptb-element-datas');
4421
- if (wptbDlementDatas.length > 0) {
4422
- wptbDlementDatas = wptbDlementDatas.innerHTML;
4423
- } else {
4424
- wptbDlementDatas = '';
4425
- }
4426
-
4427
  var mceContentBodys = wptbNewPreviewTable.querySelectorAll('.mce-content-body');
4428
  if (mceContentBodys.length > 0) {
4429
  for (var k = 0; k < mceContentBodys.length; k++) {
4430
  mceContentBodys[k].classList.remove('mce-content-body');
4431
  }
4432
  }
4433
-
4434
  var dataMceStyle = wptbNewPreviewTable.querySelectorAll('[data-mce-style]');
4435
  if (dataMceStyle.length > 0) {
4436
  for (var _k = 0; _k < dataMceStyle.length; _k++) {
4437
  dataMceStyle[_k].removeAttribute('data-mce-style');
4438
  }
4439
  }
4440
-
4441
  var mceIds = wptbNewPreviewTable.querySelectorAll('[id^=mce_]');
4442
  if (mceIds.length > 0) {
4443
  for (var _k2 = 0; _k2 < mceIds.length; _k2++) {
4444
  mceIds[_k2].removeAttribute('id');
4445
  }
4446
  }
 
4447
 
4448
- window.wptbTableStateSaving.push([wptbNewPreviewTable, cssForTdsWidthAutoValue, wptbDlementDatas]);
 
 
 
 
 
 
 
4449
 
4450
- // set new number of state which is showed now
4451
- window.wptbTableStateNumberShow = window.wptbTableStateSaving.length - 1;
 
 
 
 
 
4452
 
4453
- // make undo arrow active when the table was changed
4454
- if (window.wptbTableStateSaving.length > 1) {
4455
- var wptbUndo = document.getElementsByClassName('wptb-undo');
4456
- if (wptbUndo.length > 0) {
4457
- wptbUndo = wptbUndo[0];
4458
 
4459
- wptbUndo.classList.remove('wptb-undoredo-disabled');
4460
- }
4461
- }
4462
 
4463
- // make redo arrow not active when the table was changed
4464
- var wptbRedo = document.getElementsByClassName('wptb-redo');
4465
- if (wptbRedo.length > 0) {
4466
- wptbRedo = wptbRedo[0];
 
 
 
 
4467
 
4468
- wptbRedo.classList.add('wptb-undoredo-disabled');
4469
  }
 
4470
 
4471
- var wptbSaveBtn = document.getElementsByClassName('wptb-save-btn');
4472
- if (wptbSaveBtn.length > 0) {
4473
- wptbSaveBtn = wptbSaveBtn[0];
4474
- if (!wptbSaveBtn.dataset.wptbTableStateNumberSave && window.wptbTableStateNumberShow == 0 || window.wptbTableStateNumberShow == wptbSaveBtn.dataset.wptbTableStateNumberSave) {
4475
- wptbSaveBtn.classList.add('wptb-save-disabled');
4476
- } else {
4477
- wptbSaveBtn.classList.remove('wptb-save-disabled');
4478
- }
 
 
 
 
 
 
 
4479
  }
4480
  }
4481
  };
4482
 
4483
  this.tableStateGet = function (datawptbUndoredo) {
4484
- if (datawptbUndoredo && window.wptbTableStateSaving && window.wptbTableStateSaving.length > 1) {
4485
 
4486
  // changes the number of the state which displays now
4487
  if (datawptbUndoredo == 'undo') {
@@ -4491,7 +4564,7 @@ var WPTB_TableStateSaveManager = function WPTB_TableStateSaveManager() {
4491
  return false;
4492
  }
4493
  } else if (datawptbUndoredo == 'redo') {
4494
- if (window.wptbTableStateNumberShow < window.wptbTableStateSaving.length - 1) {
4495
  window.wptbTableStateNumberShow++;
4496
  } else {
4497
  return false;
@@ -4502,14 +4575,15 @@ var WPTB_TableStateSaveManager = function WPTB_TableStateSaveManager() {
4502
  var wptbUndo = document.getElementsByClassName('wptb-undo');
4503
  if (wptbUndo.length > 0) {
4504
  wptbUndo = wptbUndo[0];
4505
- }
4506
- if (window.wptbTableStateNumberShow == 0) {
4507
- if (wptbUndo) {
4508
- wptbUndo.classList.add('wptb-undoredo-disabled');
4509
- }
4510
- } else if (window.wptbTableStateNumberShow > 0) {
4511
- if (wptbUndo) {
4512
- wptbUndo.classList.remove('wptb-undoredo-disabled');
 
4513
  }
4514
  }
4515
 
@@ -4517,17 +4591,19 @@ var WPTB_TableStateSaveManager = function WPTB_TableStateSaveManager() {
4517
  var wptbRedo = document.getElementsByClassName('wptb-redo');
4518
  if (wptbRedo.length > 0) {
4519
  wptbRedo = wptbRedo[0];
4520
- }
4521
- if (window.wptbTableStateNumberShow == window.wptbTableStateSaving.length - 1) {
4522
- if (wptbRedo) {
4523
- wptbRedo.classList.add('wptb-undoredo-disabled');
4524
- }
4525
- } else if (window.wptbTableStateNumberShow < window.wptbTableStateSaving.length - 1) {
4526
- if (wptbRedo) {
4527
- wptbRedo.classList.remove('wptb-undoredo-disabled');
 
4528
  }
4529
  }
4530
 
 
4531
  var wptbSaveBtn = document.getElementsByClassName('wptb-save-btn');
4532
  if (wptbSaveBtn.length > 0) {
4533
  wptbSaveBtn = wptbSaveBtn[0];
@@ -4544,37 +4620,56 @@ var WPTB_TableStateSaveManager = function WPTB_TableStateSaveManager() {
4544
  wptbTableSetup = wptbTableSetup[0];
4545
 
4546
  wptbTableSetup.innerHTML = '';
4547
- wptbTableSetup.innerHTML = window.wptbTableStateSaving[window.wptbTableStateNumberShow][0].outerHTML;
 
 
 
 
 
4548
 
4549
- if (window.wptbTableStateSaving[window.wptbTableStateNumberShow][1]) {
4550
- var cssForTdsWidthAuto = document.createElement('style');
4551
- cssForTdsWidthAuto.setAttribute('data-wptb-td-auto-width', true);
4552
- cssForTdsWidthAuto.innerHTML = window.wptbTableStateSaving[window.wptbTableStateNumberShow][1];
 
 
 
 
 
4553
  var head = document.head;
4554
  if (head) {
4555
  var cssForTdsWidthAutoOld = head.querySelector('style[data-wptb-td-auto-width="true"]');
4556
  if (cssForTdsWidthAutoOld) {
4557
  head.removeChild(cssForTdsWidthAutoOld);
4558
  }
4559
- head.appendChild(cssForTdsWidthAuto);
 
 
 
 
 
 
4560
  }
4561
  }
4562
 
4563
- var wptbElementDatas = document.getElementsByClassName('wptb-element-datas');
4564
  var body = document.getElementsByTagName('body');
4565
  if (body.length > 0) {
4566
  body = body[0];
4567
  }
4568
- if (window.wptbTableStateSaving[window.wptbTableStateNumberShow][2]) {
4569
- wptbElementDatas.innerHTML = window.wptbTableStateSaving[window.wptbTableStateNumberShow][2];
 
 
4570
 
4571
  if (wptbElementDatas.length > 0) {
4572
  wptbElementDatas = wptbElementDatas[0];
4573
  } else {
4574
- wptbElementDatas = document.createElement('div');
4575
  wptbElementDatas.classList.add('wptb-element-datas');
4576
  body.appendChild(wptbElementDatas);
4577
  }
 
 
4578
  } else {
4579
  if (wptbElementDatas.length > 0) {
4580
  wptbElementDatas = wptbElementDatas[0];
@@ -4582,7 +4677,11 @@ var WPTB_TableStateSaveManager = function WPTB_TableStateSaveManager() {
4582
  }
4583
  }
4584
 
4585
- WPTB_Helper.settingsPanelClear();
 
 
 
 
4586
  WPTB_Helper.elementOptionsPanelClear();
4587
  WPTB_LeftPanel();
4588
 
@@ -4593,6 +4692,32 @@ var WPTB_TableStateSaveManager = function WPTB_TableStateSaveManager() {
4593
  }
4594
  }
4595
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4596
  };
4597
  var WPTB_innerElementSet = function WPTB_innerElementSet(element) {
4598
 
@@ -4654,10 +4779,14 @@ var WPTB_innerElementSet = function WPTB_innerElementSet(element) {
4654
  td.insertBefore(element, innerElementNext);
4655
  }
4656
  }
 
4657
  var thisRow = td.parentNode;
4658
- if (thisRow.classList.contains('wptb-table-head')) {
4659
  var table = WPTB_Helper.findAncestor(thisRow, 'wptb-preview-table');
4660
- WPTB_Helper.dataTitleColumnSet(table);
 
 
 
4661
  }
4662
 
4663
  // start item javascript if item is new
47
  btnDelete.onclick = function (event) {
48
  var act = event.target.parentNode.activeElem,
49
  el = act.parentNode;
50
+ var infArr = act.className.match(/wptb-element-(.+)-(\d+)/i);
51
+ if (act && infArr && Array.isArray(infArr)) {
52
  WPTB_Helper.elementControlsStateDelete(act);
53
+ WPTB_Helper.externalCssStylesDelete(infArr[0]);
54
  }
55
 
56
  if (act) {
59
 
60
  if (act && (typeof act === 'undefined' ? 'undefined' : _typeof(act)) === 'object' && act.hasOwnProperty('kind') && act.kind == 'text') {
61
  var thisRow = el.parentNode;
62
+
63
+ if (WPTB_Helper.rowIsTop(thisRow)) {
64
  var table = WPTB_Helper.findAncestor(thisRow, 'wptb-preview-table');
65
+
66
+ if (table.classList.contains('wptb-table-preview-head')) {
67
+ WPTB_Helper.dataTitleColumnSet(table);
68
+ }
69
  }
70
  }
71
 
81
  infArr = void 0,
82
  type = void 0;
83
  var activeElement = event.target.parentNode.activeElem;
84
+ var activeElemParent = activeElement.parentNode;
85
  infArr = activeElement.className.match(/wptb-element-(.+)-(\d+)/i);
86
  if (infArr && Array.isArray(infArr)) {
87
  type = infArr[1];
91
  data.tinyMceClear = true;
92
  copy = new WPTB_ElementObject(data);
93
  WPTB_Helper.elementControlsStateCopy(activeElement, copy.getDOMElement());
94
+ WPTB_Helper.externalCssStylesCopy(activeElement, copy.getDOMElement());
95
  //WPTB_Helper.elementStartScript( copy.getDOMElement() );
96
 
97
+ activeElemParent.insertBefore(copy.getDOMElement(), activeElement.nextSibling);
98
  } else {
99
  copy = {};
100
  var elementCopy = activeElement.cloneNode(true);
106
 
107
  applyGenericItemSettings(copy);
108
 
109
+ activeElemParent.insertBefore(copy.getDOMElement(), activeElement.nextSibling);
110
 
111
  WPTB_Helper.wptbDocumentEventGenerate('wptb-inner-element:copy', activeElement, copy.getDOMElement());
112
  }
156
  var act = event.target.parentNode.activeElem;
157
  if (act.kind == 'text') {
158
  var thisRow = act.parentNode.parentNode;
159
+
160
+ if (WPTB_Helper.rowIsTop(thisRow)) {
161
  var table = WPTB_Helper.findAncestor(thisRow, 'wptb-preview-table');
162
+
163
+ if (table.classList.contains('wptb-table-preview-head')) {
164
+ WPTB_Helper.dataTitleColumnSet(table);
165
+ }
166
  }
167
  }
168
  } else {
331
  }
332
 
333
  WPTB_Table();
334
+ var element = document.querySelector('.wptb-preview-table');
335
+ if (element) {
336
+ var infArr = element.className.match(/wptb-element-((.+-)\d+)/i);
337
+ if (!infArr) {
338
+ element.classList.add('wptb-element-main-table_setting-' + table_id);
339
+ }
340
+ }
341
+
342
  WPTB_LeftPanel();
343
  WPTB_Settings();
344
 
345
  var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
346
  wptbTableStateSaveManager.tableStateSet();
347
+
348
+ WPTB_Helper.elementOptionsSet('table_setting', element);
349
  } else {
350
  document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';
351
  }
418
  }
419
 
420
  DOMElement.classList.add('wptb-droppable', 'wptb-cell');
421
+ console.log('wptb_cell_test');
422
  }
423
 
424
  DOMElement.draggable = false;
426
  DOMElement.onclick = callback;
427
  }
428
 
429
+ // Cell double click handler
430
+ DOMElement.ondblclick = function (event) {
431
+ event.stopPropagation();
432
+ if (!WPTB_Helper.findAncestor(DOMElement, 'wptb-preview-table-manage-cells') && event.target == event.currentTarget) {
433
+
434
+ WPTB_Helper.wptbDocumentEventGenerate('table:cell:dblclick', event.target);
435
+
436
+ var element = WPTB_Helper.newElementProxy('text');
437
+ element = element.getDOMElement();
438
+
439
+ DOMElement.appendChild(element);
440
+
441
+ WPTB_innerElementSet(element);
442
+ }
443
+ };
444
+
445
  WPTB_innerElementSet(DOMElement);
446
 
447
  var wptbPhElement = DOMElement.getElementsByClassName('wptb-ph-element');
507
  };
508
 
509
  DOMElement.getCellDimensions = function () {
510
+
511
  var tdStyleObj = window.getComputedStyle(this, null);
512
 
513
  var tdPaddingLeft = tdStyleObj.getPropertyValue('padding-left');
522
  var tdBorderTopWidth = tdStyleObj.getPropertyValue('border-top-width');
523
  var tdBorderBottomWidth = tdStyleObj.getPropertyValue('border-bottom-width');
524
 
525
+ var width = parseInt(this.offsetWidth, 10) - parseInt(tdPaddingLeft, 10) - parseInt(tdPaddingRight, 10) - parseInt(tdBorderLeftWidth, 10) / 2 - parseInt(tdBorderRightWidth, 10) / 2;
526
+
527
+ var height = parseInt(this.offsetHeight, 10) - parseInt(tdPaddingTop, 10) - parseInt(tdPaddingBottom, 10) - parseInt(tdBorderTopWidth, 10) / 2 - parseInt(tdBorderBottomWidth, 10) / 2;
528
+
529
+ var table = WPTB_Helper.findAncestor(this, 'wptb-preview-table');
530
+ if (table) {
531
+ var tableFullStyleObj = window.getComputedStyle(table, null);
532
+ var tableBorderLeft = tableFullStyleObj.getPropertyValue('border-left-width');
533
+ var tableBorderRight = tableFullStyleObj.getPropertyValue('border-right-width');
534
+ var tableBorderTop = tableFullStyleObj.getPropertyValue('border-top-width');
535
+ var tableBorderBottom = tableFullStyleObj.getPropertyValue('border-bottom-width');
536
+
537
+ var tr = this.parentNode;
538
+ if (tr && tr.nodeName.toLowerCase() === 'tr') {
539
+ if (tr.firstChild && tr.firstChild.dataset.xIndex === this.dataset.xIndex) {
540
+ if (parseInt(tableBorderLeft, 10) > parseInt(tdBorderLeftWidth, 10)) {
541
+ width += -(parseInt(tableBorderLeft, 10) - parseInt(tdBorderLeftWidth, 10)) / 2;
542
+ }
543
+ }
544
+
545
+ if (tr.lastChild && tr.lastChild.dataset.xIndex === this.dataset.xIndex) {
546
+ if (parseInt(tableBorderRight, 10) > parseInt(tdBorderRightWidth, 10)) {
547
+ width += -(parseInt(tableBorderRight, 10) - parseInt(tdBorderRightWidth, 10)) / 2;
548
+ }
549
+ }
550
+
551
+ var body = tr.parentNode;
552
+ if (body && body.nodeName.toLowerCase() === 'body') {
553
+ if (body.firstChild && body.firstChild.firstChild.dataset.yIndex === this.dataset.yIndex) {
554
+ if (parseInt(tableBorderTop, 10) > parseInt(tdBorderTopWidth, 10)) {
555
+ height += (parseInt(tableBorderTop, 10) - parseInt(tdBorderTopWidth, 10)) / 2;
556
+ }
557
+ }
558
 
559
+ if (body.lastChild && body.lastChild.firstChild.dataset.yIndex === this.dataset.yIndex) {
560
+ if (parseInt(tableBorderBottom, 10) > parseInt(tdBorderBottomWidth, 10)) {
561
+ height += (parseInt(tableBorderBottom, 10) - parseInt(tdBorderBottomWidth, 10)) / 2;
562
+ }
563
+ }
564
+ }
565
+ }
566
+ }
567
 
568
  return {
569
+ width: parseInt(width),
570
+ height: parseInt(height)
571
  };
572
  };
573
 
646
  }
647
 
648
  var thisRow = td.parentNode;
649
+ if (WPTB_Helper.rowIsTop(thisRow)) {
650
  var table = WPTB_Helper.findAncestor(thisRow, 'wptb-preview-table');
651
+
652
+ if (table.classList.contains('wptb-table-preview-head')) {
653
+ WPTB_Helper.dataTitleColumnSet(table);
654
+ }
655
  }
656
 
657
  // start item javascript if item is new
690
  } else if (thisElem.localName == 'div' && thisElem.classList.contains('wptb-ph-element')) {
691
  thisRow = thisElem.parentNode.parentNode;
692
  }
693
+
694
+ if (WPTB_Helper.rowIsTop(thisRow)) {
695
+ var table = WPTB_Helper.findAncestor(thisRow, 'wptb-preview-table');
696
+
697
+ if (table.classList.contains('wptb-table-preview-head')) {
698
+ var indics = e.dataTransfer.types;
699
+ var notDragEnter = false;
700
+ for (var i = 0; i < indics.length; i++) {
701
+ var infArr = indics[i].match(/wptbelindic-([a-z]+)/i);
702
+ if (infArr && infArr[1] != 'text') {
703
+ notDragEnter = true;
704
+ break;
705
+ }
706
+ }
707
+ if (notDragEnter) {
708
+ return;
709
  }
 
 
 
710
  }
711
  }
712
 
848
  };
849
  var WPTB_ElementOptions = function WPTB_ElementOptions(element, index, kindIndexProt) {
850
 
851
+ var node = element.getDOMElement();
 
852
 
853
  node.onclick = function () {
854
+ WPTB_Helper.elementOptionsSet(element.kind, this);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
855
  };
856
  };
857
  var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
858
 
859
+ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
860
+
861
  var WPTB_Helper = {
862
  hexToRgb: function hexToRgb(hex) {
863
  var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
868
 
869
  return rgb && rgb.length === 4 ? "#" + ("0" + parseInt(rgb[1], 10).toString(16)).slice(-2) + ("0" + parseInt(rgb[2], 10).toString(16)).slice(-2) + ("0" + parseInt(rgb[3], 10).toString(16)).slice(-2) : '';
870
  },
871
+ isHex: function isHex(hex) {
872
+ var regex = new RegExp('^#(?:[A-Fa-f0-9]{3}){1,2}$');
873
+ return regex.test(hex);
874
+ },
875
  getElementIcon: function getElementIcon(icon_directory) {
876
  var hostName = location.protocol + '//' + location.hostname;
877
  var img = document.createElement('img');
925
  var contentsForHeader = {};
926
  for (var i = 0; i < rowHeadChildren.length; i++) {
927
  var tdElements = rowHeadChildren[i].children;
928
+
929
  for (var j = 0; j < tdElements.length; j++) {
930
  var element = tdElements[j];
931
  if (element.classList.contains('wptb-ph-element')) {
967
  while ((el = el.parentElement) && !el.classList.contains(cls)) {}
968
  return el;
969
  },
970
+ rowIsTop: function rowIsTop(row) {
971
+ var parent = row.parentNode;
972
+ if (parent.children[0] == row) {
973
+ return true;
974
+ } else {
975
+ return false;
976
+ }
977
+ },
978
  getSelectionText: function getSelectionText() {
979
  var txt = '';
980
  if (txt = window.getSelection) {
984
  }
985
  return txt;
986
  },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
987
  elementOptionsPanelClear: function elementOptionsPanelClear() {
988
  var elementOptionsGroup = document.getElementById('element-options-group');
989
  if (elementOptionsGroup) {
1281
  // function which set handler for event of changes of control
1282
  controlsInclude: function controlsInclude(element, functionHandler) {
1283
  if (element && (typeof element === 'undefined' ? 'undefined' : _typeof(element)) === 'object' && typeof functionHandler === 'function') {
1284
+ element.addEventListener('element:control:active', function () {
1285
  var infArr = element.className.match(/wptb-element-(.+)-(\d+)/i),
1286
  elementKind = void 0;
1287
 
1300
  if (elementsSettings) {
1301
  elementsSettings = JSON.parse(elementsSettings);
1302
  if (elementsSettings && (typeof elementsSettings === 'undefined' ? 'undefined' : _typeof(elementsSettings)) === 'object') {
1303
+ if ('tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2] in elementsSettings) {
1304
+ var elementSettings = elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]];
1305
  if (elementSettings && (typeof elementSettings === 'undefined' ? 'undefined' : _typeof(elementSettings)) === 'object') {
1306
  Object.keys(elementSettings).forEach(function (key) {
1307
  var regularText = new RegExp('data-wptb-el-' + elementKind + '-(\\d+)-(.+)', "i");
1388
  }
1389
  },
1390
  //
1391
+ appearDependOnControl: function appearDependOnControl(dependOn, targetControlElementClass) {
1392
  if (Array.isArray(dependOn)) {
1393
  var dependOnControlName = dependOn[0];
1394
  var infArr = targetControlElementClass.match(/wptb-el-((.+-)\d+)-(.+)/i);
1417
  var elementsSettings = elementsSettingsTemplateJs.innerHTML;
1418
  if (elementsSettings) {
1419
  elementsSettings = JSON.parse(elementsSettings);
1420
+ if (elementsSettings && (typeof elementsSettings === 'undefined' ? 'undefined' : _typeof(elementsSettings)) === 'object' && 'tmpl-wptb-el-datas-' + dependOnControlElementKind in elementsSettings) {
1421
+ var elementSettings = elementsSettings['tmpl-wptb-el-datas-' + dependOnControlElementKind];
1422
  if (elementSettings && (typeof elementSettings === 'undefined' ? 'undefined' : _typeof(elementSettings)) === 'object' && 'data-wptb-el-' + dependOnControlElementKind + '-' + dependOnControlName in elementSettings) {
1423
  var elementSettingValue = elementSettings['data-wptb-el-' + dependOnControlElementKind + '-' + dependOnControlName];
1424
 
1455
  var infArr = targetControlClass.match(/wptb-el-((.+-)\d+)-(.+)/i);
1456
 
1457
  if (infArr && Array.isArray(infArr)) {
1458
+ var selectorElement = void 0;
1459
+ selectorElement = document.querySelector('.wptb-element-' + infArr[1]);
1460
+
1461
  if (selectorElement) {
1462
  var elementsSettingsTemplatesJs = void 0;
1463
  var elementSettings = {};
1468
  elementSettings['data-' + targetControlClass] = targetControlValue;
1469
 
1470
  elementsSettings = {};
1471
+ elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] = elementSettings;
1472
  elementsSettings = JSON.stringify(elementsSettings);
1473
 
1474
  if (elementsSettingsTemplatesJs.length == 0) {
1493
 
1494
  if (controlChangeIndic) {
1495
  var _targetControlValue = WPTB_Helper.targetControlValueGet(targetControls);
1496
+ if (!('tmpl-wptb-el-datas-' + infArr[1] in elementsSettings) || _typeof(elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]) !== 'object') {
1497
+ elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] = {};
1498
  }
1499
+ elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-' + targetControlClass] = _targetControlValue;
1500
  elementsSettingsTemplatesJs.innerHTML = JSON.stringify(elementsSettings);
1501
+ } else if (!('tmpl-wptb-el-datas-' + infArr[1] in elementsSettings && _typeof(elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]) === 'object' && 'data-' + targetControlClass in elementsSettings['tmpl-wptb-el-datas-' + infArr[1]])) {
1502
  var _targetControlValue2 = WPTB_Helper.targetControlValueGet(targetControls);
1503
+ if (!('tmpl-wptb-el-datas-' + infArr[1] in elementsSettings) || _typeof(elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]) !== 'object') {
1504
+ elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] = {};
1505
  }
1506
+ elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-' + targetControlClass] = _targetControlValue2;
1507
  elementsSettingsTemplatesJs.innerHTML = JSON.stringify(elementsSettings);
1508
+ } else if ('tmpl-wptb-el-datas-' + infArr[1] in elementsSettings && _typeof(elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]) === 'object' && 'data-' + targetControlClass in elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]) {
1509
  for (var i = 0; i < targetControls.length; i++) {
1510
  if (targetControls[i].type == 'checkbox') {
1511
  var _targetControlValue3 = void 0;
1512
  if (targetControls[i].name) {
1513
+ _targetControlValue3 = elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-' + targetControlClass][targetControls[i].name];
1514
  } else {
1515
+ _targetControlValue3 = elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-' + targetControlClass];
1516
  }
1517
 
1518
  if (_targetControlValue3 == 'checked') {
1521
  targetControls[i].checked = false;
1522
  }
1523
  } else {
1524
+ targetControls[i].value = elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-' + targetControlClass];
1525
  }
1526
  }
1527
  }
1572
  elementsSettings = JSON.parse(elementsSettings);
1573
 
1574
  if (elementsSettings && (typeof elementsSettings === 'undefined' ? 'undefined' : _typeof(elementsSettings)) === 'object') {
1575
+ var elementSettingsProt = elementsSettings['tmpl-wptb-el-datas-' + elemProtKind];
1576
  if (elementSettingsProt && (typeof elementSettingsProt === 'undefined' ? 'undefined' : _typeof(elementSettingsProt)) === 'object') {
1577
  var elementSettingsCopy = {};
1578
 
1583
  });
1584
 
1585
  if (Object.keys(elementSettingsCopy).length > 0) {
1586
+ elementsSettings['tmpl-wptb-el-datas-' + elemCopyKind] = elementSettingsCopy;
1587
 
1588
  elementsSettings = JSON.stringify(elementsSettings);
1589
  elementsSettingsTemplateJs.innerHTML = elementsSettings;
1596
  }
1597
  },
1598
  //
1599
+ elementControlsStateDelete: function elementControlsStateDelete(element, nameControl) {
1600
  var infArr = element.className.match(/wptb-element-(.+)-(\d+)/i);
1601
  var body = document.getElementsByTagName('body')[0];
1602
  var wptbElementDatas = body.getElementsByClassName('wptb-element-datas');
1605
  var elementsSettings = wptbElementDatas.innerHTML;
1606
  if (elementsSettings) {
1607
  elementsSettings = JSON.parse(elementsSettings);
1608
+ if (elementsSettings && (typeof elementsSettings === 'undefined' ? 'undefined' : _typeof(elementsSettings)) === 'object' && 'tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2] in elementsSettings) {
1609
+ if (!nameControl) {
1610
+ delete elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]];
1611
+ } else {
1612
+ if (elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]] && _typeof(elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]]) === 'object' && 'data-wptb-el-' + infArr[1] + '-' + infArr[2] + '-' + nameControl in elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]]) {
1613
+ delete elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]]['data-wptb-el-' + infArr[1] + '-' + infArr[2] + '-' + nameControl];
1614
+ }
1615
+ }
1616
 
1617
  if (Object.keys(elementsSettings).length == 0) {
1618
  body.removeChild(wptbElementDatas);
1623
  }
1624
  }
1625
  }
1626
+ },
1627
+ //
1628
+ elementOptionsSet: function elementOptionsSet(kind, element) {
1629
+ // get controls config for this element
1630
+ var wptbContrlStacksConfigId = 'wptb-' + kind + '-control-stack';
1631
+ var tmplControlsConfig = wp.template(wptbContrlStacksConfigId);
1632
+ var data = void 0;
1633
+ var elementContainerClass = void 0;
1634
+ var elementOptionClassIndic = void 0;
1635
+ var elementOptionsGroup = void 0;
1636
+ var elementOptionsGroupId = void 0;
1637
+ var wptbelementOptionClass = void 0;
 
 
 
 
 
1638
 
1639
+ // create a container for inserting controls of this item
1640
+ var wptbelementOptionsContainer = document.createElement('div');
 
 
 
1641
 
1642
+ var infArr = element.className.match(/wptb-element-((.+-)\d+)/i);
1643
+ if (!infArr && element.classList.contains('wptb-preview-table')) {
1644
+ var table_id = WPTB_Helper.detectMode();
1645
+ element.classList.add('wptb-element-main-table_setting-' + table_id);
1646
+ infArr = element.className.match(/wptb-element-((.+-)\d+)/i);
1647
+ }
1648
+ data = {
1649
+ container: '.' + infArr[0]
1650
  };
1651
 
1652
+ elementContainerClass = infArr[0];
1653
+ elementOptionClassIndic = infArr[1];
 
 
 
1654
 
1655
+ if (!element.classList.contains('wptb-preview-table')) {
1656
+ var children = document.getElementById('element-options-group').childNodes;
1657
+ for (var _i5 = 0; _i5 < children.length; _i5++) {
1658
+ if (children[_i5].style) children[_i5].style.display = 'none';
1659
+ }
1660
 
1661
+ wptbelementOptionsContainer.classList.add('wptb-element-options', 'wptb-options-' + infArr[1]);
1662
 
1663
+ // hide wptb-elements-container and wptb-settings-section
1664
+ document.getElementsByClassName('wptb-elements-container')[0].style.display = 'none';
1665
+ document.getElementsByClassName('wptb-settings-section')[0].style.display = 'none';
 
 
1666
 
1667
+ // show element-options-group
1668
+ document.getElementById('element-options-group').style.display = 'block';
1669
 
1670
+ elementOptionsGroupId = 'element-options-group';
1671
+ wptbelementOptionClass = 'wptb-element-option';
1672
+ } else {
1673
+ elementOptionsGroupId = 'table-settings-group';
1674
+ wptbelementOptionClass = 'wptb-element-option';
 
 
 
 
 
 
1675
  }
 
1676
 
1677
+ var jsonControlsConfigJson = tmplControlsConfig(data);
1678
+ var jsonControlsConfig = JSON.parse(jsonControlsConfigJson);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1679
 
1680
+ // clear elements from options group
1681
+ //document.getElementById( 'element-options-group' ).innerHTML = '';
1682
+ elementOptionsGroup = document.getElementById(elementOptionsGroupId);
1683
+ var elementOptionsGroupChildren = elementOptionsGroup.children;
1684
+ for (var _i6 = 0; _i6 < elementOptionsGroupChildren.length; _i6++) {
1685
+ elementOptionsGroup.removeChild(elementOptionsGroupChildren[_i6]);
1686
  }
1687
 
1688
+ // insert created container into element-option-group tag
1689
+ document.getElementById(elementOptionsGroupId).appendChild(wptbelementOptionsContainer);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1690
 
1691
+ // show created container
1692
+ wptbelementOptionsContainer.style.display = 'block';
 
 
1693
 
1694
+ // array for save all scrips for each controls
1695
+ var controlScriptsArr = [];
 
 
 
1696
 
1697
+ // array for keep "appear depend on" parametrs
1698
+ var controlappearDependOnControl = [];
 
 
 
 
 
 
 
 
1699
 
1700
+ // create controls
1701
+ var i = 0;
1702
+ Object.keys(jsonControlsConfig).forEach(function (key) {
1703
+ var data = jsonControlsConfig[key];
1704
+ data.controlKey = key;
1705
 
1706
+ // get necessary wp js template
1707
+ var tmplControlTemplate = wp.template('wptb-' + data.type + '-control');
 
 
 
 
 
 
 
1708
 
1709
+ data.elemContainer = elementContainerClass;
1710
+ data.elementControlTargetUnicClass = 'wptb-el-' + elementOptionClassIndic + '-' + data.controlKey;
1711
+ var controlTemplate = tmplControlTemplate(data);
1712
 
1713
+ if ('appearDependOnControl' in data) {
1714
+ if (Array.isArray(data.appearDependOnControl)) {
1715
+ controlappearDependOnControl.push([data.appearDependOnControl, data.elementControlTargetUnicClass]);
 
 
 
 
 
 
 
 
 
 
 
 
 
1716
  }
1717
  }
1718
 
1719
+ //console.log( controlTemplate );
 
 
 
1720
 
1721
+ var wptbElementOptionContainer = document.createElement('div');
1722
+ wptbElementOptionContainer.classList.add(wptbelementOptionClass, 'wptb-settings-items');
 
 
 
 
 
1723
 
1724
+ if (data.customClassForContainer) {
1725
+ wptbElementOptionContainer.classList.add(data.customClassForContainer);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1726
  }
1727
 
1728
+ if (data.containerAdditionalStyles) {
1729
+ wptbElementOptionContainer.setAttribute('style', data.containerAdditionalStyles);
1730
  }
 
 
1731
 
1732
+ wptbElementOptionContainer.innerHTML = controlTemplate;
1733
 
1734
+ wptbelementOptionsContainer.appendChild(wptbElementOptionContainer);
 
 
 
1735
 
1736
+ var helperJavascriptElem = wptbElementOptionContainer.getElementsByTagName('wptb-template-script');
1737
+ if (helperJavascriptElem.length > 0) {
1738
+ helperJavascriptElem = helperJavascriptElem[0];
1739
+ var helperJavascriptCode = helperJavascriptElem.innerText;
1740
+ wptbElementOptionContainer.removeChild(helperJavascriptElem);
1741
+ var script = document.createElement('script');
1742
+ script.setAttribute('type', 'text/javascript');
1743
+ script.innerHTML = helperJavascriptCode.replace(/\r|\n|\t/g, '').trim();
1744
+ controlScriptsArr.push(script);
1745
  }
 
 
 
 
 
1746
 
1747
+ i++;
1748
+ });
 
1749
 
1750
+ // run the scripts of controls
1751
+ if (controlScriptsArr.length > 0) {
1752
+ for (var _i7 = 0; _i7 < controlScriptsArr.length; _i7++) {
1753
+ wptbelementOptionsContainer.appendChild(controlScriptsArr[_i7]);
1754
+ }
1755
  }
 
1756
 
1757
+ // run appearDependOnControl function
1758
+ for (var _i8 = 0; _i8 < controlappearDependOnControl.length; _i8++) {
1759
+ WPTB_Helper.appearDependOnControl(controlappearDependOnControl[_i8][0], controlappearDependOnControl[_i8][1]);
 
 
1760
  }
 
1761
 
1762
+ WPTB_Helper.wptbDocumentEventGenerate('element:control:active', element);
1763
+ },
1764
+ // function for create, update css for element
1765
+ managerExternalCssStyles: function managerExternalCssStyles(elementContainer, selector, cssName, cssValue) {
1766
+ var infArr = elementContainer.match(/wptb-element-main(.+)-(\d+)/i);
1767
+ if (!infArr || !Array.isArray(infArr)) {
1768
+ var table = document.getElementsByClassName('wptb-preview-table');
1769
+
1770
+ if (table.length > 0) {
1771
+ table = table[0];
1772
+
1773
+ var _infArr = table.className.match(/wptb-element-main(.+)-(\d+)/i);
1774
+ if (_infArr && Array.isArray(_infArr)) {
1775
+ selector = '.' + _infArr[0] + ' ' + selector;
1776
+ }
1777
+ }
1778
  }
 
1779
 
1780
+ var head = document.head;
1781
+ if (head) {
1782
+ var cssForThisElement = head.querySelector('#styles-' + elementContainer);
1783
+ if (cssForThisElement) {
1784
+ var cssText = cssForThisElement.innerHTML;
1785
+ if (cssText) {
1786
+ var cssTextArrFirst = cssText.split('}');
1787
+ cssTextArrFirst.pop();
1788
+ var selectorExists = false;
1789
+ for (var i = 0; i < cssTextArrFirst.length; i++) {
1790
+ var cssTextArrSecond = cssTextArrFirst[i].split('{');
1791
+ if (cssTextArrSecond[0] === selector) {
1792
+ var cssTextArrThird = cssTextArrSecond[1].split(';');
1793
+ cssTextArrThird.pop();
1794
+ var cssNameExists = false;
1795
+ for (var j = 0; j < cssTextArrThird.length; j++) {
1796
+ var cssTextArrFourth = cssTextArrThird[j].split(':');
1797
+ if (cssTextArrFourth[0] === cssName) {
1798
+ if (cssValue) {
1799
+ cssTextArrThird[j] = cssName + ':' + cssValue;
1800
+ } else {
1801
+ cssTextArrThird.splice(j, 1);
1802
+ }
1803
+
1804
+ cssTextArrSecond[1] = cssTextArrThird.join(';') ? cssTextArrThird.join(';') + ';' : '';
1805
+ cssNameExists = true;
1806
+ break;
1807
+ }
1808
+ }
1809
+ if (!cssNameExists) {
1810
+ if (cssValue) {
1811
+ cssTextArrSecond[1] += cssName + ':' + cssValue + ';';
1812
+ }
1813
+ }
1814
+ if (cssTextArrSecond[1]) {
1815
+ cssTextArrFirst[i] = cssTextArrSecond[0] + '{' + cssTextArrSecond[1];
1816
+ } else {
1817
+ cssTextArrFirst.splice(i, 1);
1818
+ }
1819
+ if (cssTextArrFirst.join('}')) {
1820
+ cssForThisElement.innerHTML = cssTextArrFirst.join('}') + '}';
1821
+ } else {
1822
+ head.removeChild(cssForThisElement);
1823
+ }
1824
+
1825
+ selectorExists = true;
1826
+ break;
1827
+ }
1828
+ }
1829
+
1830
+ if (!selectorExists) {
1831
+ if (cssValue) {
1832
+ cssForThisElement.innerHTML = cssText + selector + '{' + cssName + ':' + cssValue + ';}';
1833
+ } else {
1834
+ cssForThisElement.innerHTML = cssText;
1835
+ }
1836
+ }
1837
+ } else {
1838
+ if (cssValue) {
1839
+ cssForThisElement.innerHTML = selector + '{' + cssName + ':' + cssValue + ';}';
1840
+ } else {
1841
+ head.removeChild(cssForThisElement);
1842
+ }
1843
  }
 
1844
  } else {
1845
+ if (cssValue) {
1846
+ var _cssForThisElement = document.createElement('style');
1847
+ _cssForThisElement.setAttribute('id', 'styles-' + elementContainer);
1848
+ _cssForThisElement.classList.add('styles-wptb-elements');
1849
+ _cssForThisElement.innerHTML = selector + '{' + cssName + ':' + cssValue + ';}';
1850
+ head.appendChild(_cssForThisElement);
1851
  }
1852
  }
1853
  }
1854
+ },
1855
+ // function for deleting all external CSS for the element
1856
+ externalCssStylesDelete: function externalCssStylesDelete(elementContainerClass) {
1857
+ var head = document.head;
1858
+ if (head) {
1859
+ var cssForThisElement = head.querySelector('#styles-' + elementContainerClass);
1860
 
1861
+ if (cssForThisElement) {
1862
+ head.removeChild(cssForThisElement);
1863
+ }
1864
+ }
1865
+ },
1866
+ // function for copy all external CSS for the element
1867
+ externalCssStylesCopy: function externalCssStylesCopy(activeElement, copyElement) {
1868
+ if (activeElement) {
1869
+ var infArr = activeElement.className.match(/wptb-element-(.+)-(\d+)/i);
1870
+ if (infArr && Array.isArray(infArr)) {
1871
+ var activeElemClass = infArr[0];
1872
 
1873
+ var head = document.head;
1874
+ if (head) {
1875
+ var cssForActiveElement = head.querySelector('#styles-' + activeElemClass);
1876
 
1877
+ if (cssForActiveElement) {
1878
+ var cssForNewElement = cssForActiveElement.cloneNode(true);
1879
 
1880
+ cssForNewElement.removeAttribute('id', 'styles-' + activeElemClass);
 
 
1881
 
1882
+ var infArrCopyEl = copyElement.className.match(/wptb-element-(.+)-(\d+)/i);
1883
+ if (infArrCopyEl && Array.isArray(infArrCopyEl)) {
1884
+ cssForNewElement.setAttribute('id', 'styles-' + infArrCopyEl[0]);
1885
+ var cssForActiveElementInnerHTML = cssForActiveElement.innerHTML;
1886
+ var cssForNewElementInnerHTML = WPTB_Helper.replaceAll(cssForActiveElementInnerHTML, activeElemClass, infArrCopyEl[0]);
1887
+ cssForNewElement.innerHTML = cssForNewElementInnerHTML;
1888
+ head.appendChild(cssForNewElement);
1889
+ }
1890
  }
1891
  }
1892
  }
1893
  }
1894
+ },
1895
+ // function for convertation elements stiles in json
1896
+ elementsStylesConvertToObject: function elementsStylesConvertToObject() {
1897
+ var head = document.head;
1898
+ var stylesElements = head.querySelectorAll('.styles-wptb-elements');
1899
+ var stylesObj = {};
1900
+ for (var i = 0; i < stylesElements.length; i++) {
1901
+ var styleElemId = stylesElements[i].getAttribute('id');
1902
+ if (styleElemId && stylesElements[i].innerHTML) {
1903
+ stylesObj[styleElemId] = stylesElements[i].innerHTML;
1904
+ }
1905
+ }
1906
 
1907
+ if (Object.keys(stylesObj).length != 0) {
1908
+ return JSON.stringify(stylesObj);
1909
+ }
1910
+ return '';
1911
+ },
1912
+ // function for set scc styles tags to head
1913
+ elementsStylesSetFromObject: function elementsStylesSetFromObject(jsonObject) {
1914
+ var head = document.head;
1915
+ if (head) {
1916
+ var stylesElements = head.querySelectorAll('.styles-wptb-elements');
1917
+ if (stylesElements.length > 0) {
1918
+ stylesElements = [].concat(_toConsumableArray(stylesElements));
1919
+ for (var i = 0; i < stylesElements.length; i++) {
1920
+ head.removeChild(stylesElements[i]);
1921
+ }
1922
+ }
1923
+ if (jsonObject) {
1924
+ var stylesObj = JSON.parse(jsonObject);
1925
+ if (Object.keys(stylesObj).length != 0) {
1926
+ Object.keys(stylesObj).forEach(function (key) {
1927
+ var cssText = stylesObj[key];
1928
+ var styleCss = document.createElement('style');
1929
+ styleCss.setAttribute('id', key);
1930
+ styleCss.classList.add('styles-wptb-elements');
1931
+ styleCss.innerHTML = cssText;
1932
+ head.appendChild(styleCss);
1933
+ });
1934
+ }
1935
+ }
1936
+ }
1937
+ },
1938
+ // function for table saving
1939
+ saveTable: function saveTable(event, startSaving, previewSaving) {
1940
+ if (!previewSaving && !startSaving) {
1941
+ if (!event.target.dataset.wptbTableStateNumberSave && window.wptbTableStateNumberShow == 0 || window.wptbTableStateNumberShow == event.target.dataset.wptbTableStateNumberSave) {
1942
+ //return;
1943
+ }
1944
+ }
1945
 
1946
+ if (!previewSaving) {
1947
+ var bar = document.querySelector('.wptb-edit-bar');
1948
+ if (bar && bar.classList.contains('visible')) {
1949
+ var table = document.getElementsByClassName('wptb-preview-table')[0];
1950
+ table.toggleTableEditMode();
1951
+ }
1952
+ }
1953
 
1954
+ var http = new XMLHttpRequest(),
1955
+ url = (wptb_admin_object ? wptb_admin_object.ajaxurl : ajaxurl) + "?action=save_table",
1956
+ t = document.getElementById('wptb-setup-name').value.trim(),
1957
+ messagingArea = void 0,
1958
+ code = void 0,
1959
+ datas = void 0;
1960
 
1961
+ code = document.getElementsByClassName('wptb-preview-table');
 
1962
 
1963
+ var postId = void 0;
1964
+ if ((rs = WPTB_Helper.detectMode()) || (rs = document.wptbId)) {
1965
+ postId = rs;
1966
+ }
1967
+ var paramIdsNecessaryChange = false;
1968
+ if (code.length > 0) {
1969
+ code = code[0];
1970
+ var codeClone = code.cloneNode(true);
1971
+ if (postId) {
1972
+ if (codeClone.classList.contains('wptb-element-main-table_setting-startedid-0')) {
1973
+ codeClone.classList.remove('wptb-element-main-table_setting-startedid-0');
1974
+ codeClone.classList.add('wptb-element-main-table_setting-' + postId);
1975
+ paramIdsNecessaryChange = true;
1976
+ }
1977
+ }
1978
+ codeClone.columns = code.columns;
1979
+ code = WPTB_Stringifier(codeClone);
1980
+ code = code.outerHTML;
1981
+ } else {
1982
+ code = '';
1983
+ }
1984
 
1985
+ if (!previewSaving) {
1986
+ datas = '';
1987
+ var datas_containers = document.getElementsByClassName('wptb-element-datas');
1988
 
1989
+ if (datas_containers.length > 0) {
1990
+ if (datas_containers[0].innerHTML) {
1991
+ datas = datas_containers[0].innerHTML;
1992
 
1993
+ if (paramIdsNecessaryChange) {
1994
+ datas = WPTB_Helper.replaceAll(datas, 'tmpl-wptb-el-datas-main-table_setting-startedid-0', 'tmpl-wptb-el-datas-main-table_setting-' + postId);
 
 
 
1995
 
1996
+ datas = WPTB_Helper.replaceAll(datas, 'data-wptb-el-main-table_setting-startedid-0', 'data-wptb-el-main-table_setting-' + postId);
1997
+ }
1998
+ }
1999
+ }
2000
+ }
2001
 
2002
+ var styleObjJson = WPTB_Helper.elementsStylesConvertToObject();
2003
+ if (paramIdsNecessaryChange) {
2004
+ styleObjJson = WPTB_Helper.replaceAll(styleObjJson, '.wptb-element-main-table_setting-startedid-0', '.wptb-element-main-table_setting-' + postId);
2005
+ }
2006
 
2007
+ if (t === '' && code === '') {
2008
+ var messagingAreaText = '';
2009
+ if (t === '') messagingAreaText += 'You must assign a name to the table before saving it.</br>';
2010
+ if (code === '') messagingAreaText += 'Table wasn\'t created';
2011
+ messagingArea = document.getElementById('wptb-messaging-area');
2012
+ messagingArea.innerHTML = '<div class="wptb-error wptb-message">Error: ' + messagingAreaText + '</div>';
2013
+ messagingArea.classList.add('wptb-warning');
2014
+ setTimeout(function () {
2015
+ messagingArea.removeChild(messagingArea.firstChild);
2016
+ }, 4000);
2017
+ return;
2018
+ }
2019
 
2020
+ var params = {
2021
+ title: t,
2022
+ content: code,
2023
+ elements_datas: datas,
2024
+ elements_styles: styleObjJson,
2025
+ security_code: wptb_admin_object.security_code
2026
+ };
2027
 
2028
+ if (previewSaving) {
2029
+ params.preview_saving = previewSaving;
 
 
 
 
2030
  }
 
2031
 
2032
+ if (postId) {
2033
+ params.id = postId;
2034
+ }
2035
+ params = JSON.stringify(params);
2036
 
2037
+ http.open('POST', url, true);
2038
+ http.setRequestHeader('Content-type', 'application/json; charset=utf-8');
 
 
 
 
 
2039
 
2040
+ http.onreadystatechange = function (action) {
2041
+ if (this.readyState == 4 && this.status == 200) {
2042
+ var data = JSON.parse(http.responseText);
2043
+ messagingArea = document.getElementById('wptb-messaging-area');
 
2044
 
2045
+ if (data[0] == 'saved') {
2046
+ console.log(window.wptbTableStateSaving);
2047
+ window.history.pushState(null, null, document.location.href.replace('#', '') + '&table=' + data[1]);
 
2048
 
2049
+ WPTB_Helper.saveTable(event, true);
2050
+ return;
2051
+ } else if (data[0] == 'edited' && startSaving) {
2052
+ document.wptbId = data[1];
2053
+ messagingArea.innerHTML = '<div class="wptb-success wptb-message">Table "' + t + '" was successfully saved.</div>';
2054
+ document.getElementsByClassName('wptb-embed-btn')[0].classList.remove('wptb-button-disable');
2055
+ document.getElementById('wptb-embed-shortcode').value = '[wptb id=' + data[1] + ']';
2056
+ var wptbPreviewTable = document.querySelector('.wptb-preview-table');
2057
+ var wptbPreviewBtn = document.getElementsByClassName('wptb-preview-btn');
2058
+ if (wptbPreviewBtn.length > 0) {
2059
+ wptbPreviewBtn = wptbPreviewBtn[0];
2060
+ wptbPreviewBtn.classList.remove('wptb-button-disable');
2061
+ var wptbPreviewBtnHref = wptbPreviewBtn.dataset.previewHref;
2062
+ wptbPreviewBtnHref = wptbPreviewBtnHref.replace('empty', data[1]);
2063
+ wptbPreviewBtn.setAttribute('href', wptbPreviewBtnHref);
2064
+ }
2065
 
2066
+ event.target.dataset.wptbTableStateNumberSave = window.wptbTableStateNumberShow;
2067
+ var wptbSaveBtn = document.getElementsByClassName('wptb-save-btn');
2068
+ if (wptbSaveBtn.length > 0) {
2069
+ wptbSaveBtn = wptbSaveBtn[0];
2070
+ wptbSaveBtn.classList.add('wptb-save-disabled');
2071
+ }
2072
+ } else if (data[0] == 'edited') {
2073
+ messagingArea.innerHTML = '<div class="wptb-success wptb-message">Table "' + t + '" was successfully updated.</div>';
2074
+ event.target.dataset.wptbTableStateNumberSave = window.wptbTableStateNumberShow;
 
 
2075
 
2076
+ var _wptbSaveBtn = document.getElementsByClassName('wptb-save-btn');
2077
+ if (_wptbSaveBtn.length > 0) {
2078
+ _wptbSaveBtn = _wptbSaveBtn[0];
2079
+ _wptbSaveBtn.classList.add('wptb-save-disabled');
2080
+ }
2081
+ } else if (data[0] == 'preview_edited') {
2082
+ return;
2083
+ } else {
2084
+ messagingArea.innerHTML = '<div class="wptb-error wptb-message">Safety problems</div>';
2085
+ }
2086
+ messagingArea.classList.add('wptb-success');
2087
+ setTimeout(function () {
2088
+ messagingArea.removeChild(messagingArea.firstChild);
2089
+ }, 4000);
2090
+ }
2091
+ };
2092
+ http.send(params);
2093
+ },
2094
+ //
2095
+ clickOnFreeSpace: function clickOnFreeSpace() {
2096
+ document.getElementsByClassName('wptb-elements-container')[0].style.display = 'table';
2097
+ document.getElementsByClassName('wptb-settings-section')[0].style.display = 'block';
2098
+ document.getElementById('element-options-group').style.display = 'none';
2099
+ var wpcdFixedToolbar = document.getElementById('wpcd_fixed_toolbar');
2100
+ if (wpcdFixedToolbar.hasAttribute('data-toolbar-active-id')) {
2101
+ document.getElementById(wpcdFixedToolbar.getAttribute('data-toolbar-active-id')).classList.remove('toolbar-active');
2102
+ }
2103
+ var element = document.querySelector('.wptb-preview-table');
2104
+ if (element) {
2105
+ WPTB_Helper.elementOptionsSet('table_setting', element);
2106
+ }
2107
+ },
2108
+ // function for sending of element ajax request
2109
+ elementAjax: function elementAjax(dataAjaxData, element) {
2110
+ var http = new XMLHttpRequest(),
2111
+ url = (wptb_admin_object ? wptb_admin_object.ajaxurl : ajaxurl) + "?action=wptb_element_ajax";
2112
+ var element_name = void 0;
2113
+ var infArr = element.className.match(/wptb-element-(.+)-(\d+)/i);
2114
+ if (infArr && Array.isArray(infArr)) {
2115
+ element_name = infArr[1];
2116
  }
2117
+
2118
+ var params = {
2119
+ element_ajax_data: dataAjaxData,
2120
+ element_name: element_name,
2121
+ security_code: wptb_admin_object.security_code
2122
+ };
2123
+ params = JSON.stringify(params);
2124
+
2125
+ http.open('POST', url, true);
2126
+ http.setRequestHeader('Content-type', 'application/json; charset=utf-8');
2127
+
2128
+ http.onreadystatechange = function (action) {
2129
+ if (this.readyState == 4 && this.status == 200) {
2130
+ var data = JSON.parse(http.responseText);
2131
+ var detail = void 0;
2132
+ if (data && Array.isArray(data) && data[0] == 'element_ajax_responce') {
2133
+ detail = { value: data[1] };
2134
+ } else {
2135
+ detail = '';
2136
+ }
2137
+ WPTB_Helper.wptbDocumentEventGenerate('wptb-element:ajax-response', element, detail);
2138
+ }
2139
+ };
2140
+ http.send(params);
2141
+ }
2142
+ };
2143
+ var WPTB_Initializer = function WPTB_Initializer() {
2144
+
2145
+ var MIN_COLUMNS = 1,
2146
+ MIN_ROWS = 1,
2147
+ MAX_COLUMNS = 30,
2148
+ MAX_ROWS = 30;
2149
+
2150
+ var tableGenerator = document.body;
2151
+ columnsDecrementButton = tableGenerator.getElementsByClassName('wptb-input-number-decrement')[0], columnsIncrementButton = tableGenerator.getElementsByClassName('wptb-input-number-increment')[0], rowsDecrementButton = tableGenerator.getElementsByClassName('wptb-input-number-decrement')[1], rowsIncrementButton = tableGenerator.getElementsByClassName('wptb-input-number-increment')[1], columnsInput = document.getElementById('wptb-columns-number'), rowsInput = document.getElementById('wptb-rows-number');
2152
+
2153
+ columnsDecrementButton.onclick = function () {
2154
+ if (columnsInput.value > MIN_COLUMNS) {
2155
+ columnsInput.value--;
2156
+ }
2157
+ };
2158
+
2159
+ columnsIncrementButton.onclick = function () {
2160
+ if (columnsInput.value < MAX_COLUMNS) {
2161
+ columnsInput.value++;
2162
+ }
2163
+ };
2164
+
2165
+ rowsDecrementButton.onclick = function () {
2166
+ if (rowsInput.value > MIN_ROWS) {
2167
+ rowsInput.value--;
2168
+ }
2169
+ };
2170
+
2171
+ rowsIncrementButton.onclick = function () {
2172
+ if (rowsInput.value < MAX_ROWS) {
2173
+ rowsInput.value++;
2174
+ }
2175
+ };
2176
+
2177
+ document.getElementById('wptb-generate-table').onclick = function () {
2178
+ var columns = document.getElementById('wptb-columns-number').value,
2179
+ rows = document.getElementById('wptb-rows-number').value;
2180
+
2181
+ var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
2182
+ //wptbTableStateSaveManager.tableStateClear();
2183
+
2184
+ wptbTableStateSaveManager.tableStateSet(true);
2185
+
2186
+ WPTB_Table(columns, rows);
2187
+
2188
+ wptbTableStateSaveManager.tableStateSet();
2189
+ };
2190
+ };
2191
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
2192
+
2193
+ var WPTB_LeftPanel = function WPTB_LeftPanel() {
2194
+
2195
+ var table = document.getElementsByClassName('wptb-preview-table')[0],
2196
+ wptbElementButtons = document.getElementsByClassName('wptb-element');
2197
+
2198
+ var wptbTableColumnWidthNumber = document.getElementById('wptb-table-column-width-number');
2199
+ WPTB_Helper.numberImputSize(wptbTableColumnWidthNumber, 2, 500);
2200
+
2201
+ var wptbTableRowHeightNumber = document.getElementById('wptb-table-row-height-number');
2202
+ WPTB_Helper.numberImputSize(wptbTableRowHeightNumber, 2, 200);
2203
 
2204
  document.getElementById('wptb-table-column-width-slider').oninput = function () {
2205
  document.getElementById('wptb-table-column-width-number').value = this.value;
2269
 
2270
  var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
2271
  wptbTableStateSaveManager.tableStateSet();
2272
+ };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2273
 
2274
+ function controlsChange(inputs, table) {
2275
+ if (inputs && (typeof inputs === 'undefined' ? 'undefined' : _typeof(inputs)) === 'object') {
2276
+ if (inputs.hasOwnProperty('tableTopRowsAsHeader')) {
2277
+ if (inputs.tableTopRowsAsHeader == 'checked') {
2278
+ var rows = table.rows;
2279
+ table.classList.add('wptb-table-preview-head');
2280
+ } else if (inputs.tableTopRowsAsHeader == 'unchecked') {
2281
+ var _rows = table.rows;
2282
+ table.classList.remove('wptb-table-preview-head');
2283
+
2284
+ for (var _i = 1; _i < _rows.length; _i++) {
2285
+ var thisRow = _rows[_i],
2286
+ thisRowChildren = thisRow.children;
2287
+ for (var j = 0; j < thisRowChildren.length; j++) {
2288
+ thisRowChildren[j].removeAttribute('data-wptb-title-column');
2289
+ thisRowChildren[j].removeAttribute('data-wptb-title-column-font-size');
2290
+ thisRowChildren[j].removeAttribute('data-wptb-title-column-color');
2291
+ thisRowChildren[j].removeAttribute('data-wptb-title-background-color');
2292
+ thisRowChildren[j].removeAttribute('data-wptb-title-align');
2293
+ }
2294
+ }
2295
  }
2296
+ } else if (inputs.hasOwnProperty('makeTableResponsive')) {
2297
+ if (inputs.makeTableResponsive == 'checked') {
2298
+ table.dataset.wptbAdaptiveTable = 1;
2299
+ } else if (inputs.makeTableResponsive == 'unchecked') {
2300
+ table.dataset.wptbAdaptiveTable = 0;
2301
+ }
2302
+ } else if (inputs.hasOwnProperty('tableManageCells')) {
2303
+ table.toggleTableEditMode();
2304
  }
2305
  }
2306
  }
2307
 
2308
+ WPTB_Helper.controlsInclude(table, controlsChange);
 
 
 
 
2309
 
2310
  for (var i = 0; i < wptbElementButtons.length; i++) {
2311
  wptbElementButtons[i].ondragstart = function (e) {
2312
  e.dataTransfer.setData('wptbElement', this.dataset.wptbElement);
2313
  e.dataTransfer.setData('wptbElIndic-' + this.dataset.wptbElement, 'wptbElIndic-' + this.dataset.wptbElement);
2314
  };
2315
+ };
2316
 
2317
  if (table) {
 
2318
  document.getElementById('wptb-table-edit-mode-close').onclick = table.toggleTableEditMode;
2319
  document.getElementById('wptb-left-scroll-panel-curtain-close').onclick = table.toggleTableEditMode;
2320
  document.getElementById('wptb-add-end-row').onclick = table.addRowToTheEnd;
2329
  document.getElementById('wptb-delete-row').onclick = table.deleteRow;
2330
  document.getElementById('wptb-merge-cells').onclick = table.mergeCells;
2331
  document.getElementById('wptb-split-cell').onclick = table.splitCell;
2332
+ };
2333
 
2334
  document.querySelector('.wptb-left-panel-extend').onclick = function () {
2335
  var wptbContainer = document.querySelector('.wptb-container');
2347
  var wptbBuilderPanel = document.getElementsByClassName('wptb-builder-panel')[0];
2348
  wptbBuilderPanel.onclick = function (e) {
2349
  if (!e.target.classList.contains('wptb-ph-element') && !WPTB_Helper.findAncestor(e.target, 'wptb-ph-element') && !e.target.classList.contains('wptb-fixed-toolbar') && !WPTB_Helper.findAncestor(e.target, 'wptb-fixed-toolbar')) {
2350
+ WPTB_Helper.clickOnFreeSpace();
2351
  }
2352
  };
2353
 
2354
  var wptbHeader = document.getElementsByClassName('wptb-header');
2355
  if (wptbHeader.length > 0) wptbHeader = wptbHeader[0];
2356
  wptbHeader.onclick = function () {
2357
+ WPTB_Helper.clickOnFreeSpace();
2358
  };
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2359
  };
2360
  var MultipleSelect = function MultipleSelect() {
2361
 
2505
  WPTB_Helper.elementDragEndClear();
2506
  };
2507
  };
2508
+ var table = document.getElementsByClassName('wptb-preview-table');
2509
  var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
2510
  var wptbUndo = document.getElementsByClassName('wptb-undo');
2511
  if (wptbUndo.length > 0) {
2515
  if (!this.classList.contains('wptb-undoredo-disabled')) {
2516
  wptbTableStateSaveManager.tableStateGet(this.dataset.wptbUndoredo);
2517
  var wptbUndoRedoContainer = document.getElementsByClassName('wptb-undo-redo-container');
2518
+ if (wptbUndoRedoContainer.length > 0 && table.length > 0) {
2519
  wptbUndoRedoContainer = wptbUndoRedoContainer[0];
2520
  wptbUndoRedoContainer.onmouseleave = function (event) {
2521
  event.target.onmouseleave = '';
2534
  if (!this.classList.contains('wptb-undoredo-disabled')) {
2535
  wptbTableStateSaveManager.tableStateGet(this.dataset.wptbUndoredo);
2536
  var wptbUndoRedoContainer = document.getElementsByClassName('wptb-undo-redo-container');
2537
+ if (wptbUndoRedoContainer.length > 0 && table.length > 0) {
2538
  wptbUndoRedoContainer = wptbUndoRedoContainer[0];
2539
  wptbUndoRedoContainer.onmouseleave = function (event) {
2540
  event.target.onmouseleave = '';
2569
  shortcodePopupWindow.classList.remove('wptb-popup-show');
2570
  };
2571
 
2572
+ document.getElementsByClassName('wptb-preview-btn')[0].onclick = function (event) {
2573
  if (this.classList.contains('wptb-button-disable')) {
 
 
 
 
 
 
2574
  return;
2575
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2576
 
2577
+ var previewId = Math.floor(Math.random() * 10000);
 
 
 
 
2578
 
2579
+ var newHref = new URL(event.target.href);
2580
+ newHref.searchParams.set('preview_id', previewId);
2581
+ event.target.href = newHref.toString();
2582
+ WPTB_Helper.saveTable(event, false, previewId);
2583
+ };
 
 
 
 
 
 
 
2584
 
2585
+ document.getElementsByClassName('wptb-save-btn')[0].onclick = function (event) {
2586
+ if (!this.classList.contains('wptb-save-disabled')) {
2587
+ WPTB_Helper.saveTable(event);
 
 
 
 
 
2588
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2589
  };
2590
  };
2591
+ function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
2592
+
2593
  var WPTB_Stringifier = function WPTB_Stringifier(codeMain) {
2594
  if (codeMain) {
2595
  var code = codeMain.cloneNode(true);
2659
  break;
2660
  }
2661
  }
2662
+
2663
+ var dataMceBogus = innerElements[j].querySelectorAll('[data-mce-bogus]');
2664
+ if (dataMceBogus.length > 0) {
2665
+ dataMceBogus = [].concat(_toConsumableArray(dataMceBogus));
2666
+ for (var _k5 = 0; _k5 < dataMceBogus.length; _k5++) {
2667
+ if (dataMceBogus[_k5] && dataMceBogus[_k5].parentNode) {
2668
+ dataMceBogus[_k5].parentNode.removeChild(dataMceBogus[_k5]);
2669
+ }
2670
+ }
2671
+ }
2672
  }
2673
  }
2674
 
3075
  }
3076
  };
3077
 
 
 
 
3078
  jQuery('#wptb-table-border-color').val('');
 
 
3079
  jQuery('#wptb-table-padding-number,#wptb-table-padding-slider').val('15');
3080
 
3081
  if (columns || rows) {
3088
 
3089
  //Create a HTML Table element.
3090
  table = document.createElement('table');
3091
+ table.classList.add('wptb-preview-table', 'wptb-element-main-table_setting-startedid-0');
3092
+ table.style.border = '0px solid';
3093
  table.dataset.reconstraction = 1;
3094
  table.dataset.wptbAdaptiveTable = 1;
3095
  //Add the data rows.
3101
  for (var j = 0; j < columns; j++) {
3102
  cell = new WPTB_Cell(mark);
3103
  cell.setCoords(i, j);
3104
+ cell.getDOMElement().style.borderWidth = '1px';
3105
  row.appendChild(cell.getDOMElement());
3106
  }
3107
  }
3118
  WPTB_Cell(mark, cells[_i]);
3119
  }
3120
  }
3121
+ } else {
3122
+ return;
3123
  }
3124
  }
3125
 
3175
  maxCols = 0,
3176
  maxColsFull = 0,
3177
  tdsArr = [];
3178
+ //let wptbTopRowAsHeader = document.getElementById( 'wptb-top-row-as-header' );
3179
 
3180
  for (var i = 0; i < trs.length; i++) {
3181
  if (i == 0) {
3182
+ // if( wptbTopRowAsHeader.checked ) {
3183
+ // if( start == undefined ) {
3184
+ // this.classList.add( 'wptb-table-preview-head' );
3185
+ // trs[i].classList.add( 'wptb-table-head' )
3186
+ // } ;
3187
+ // } else {
3188
+ // if( start == undefined ) {
3189
+ // this.classList.remove( 'wptb-table-preview-head' );
3190
+ // trs[i].classList.remove( 'wptb-table-head' );
3191
+ // }
3192
+ // }
 
 
 
3193
  } else {
3194
+ // if (i % 2 == 0) {
3195
+ // trs[i].classList.remove( 'wptb-table-head' );
3196
+ // } else {
3197
+ // trs[i].classList.remove( 'wptb-table-head' );
3198
+ // }
 
 
 
 
 
3199
  }
 
3200
 
3201
  tdsArr[i];
3202
  tds = trs[i].getElementsByTagName('td');
3335
  var tableTdBorderCommonWidth = 0;
3336
  var cssForTdsWidthAuto = '';
3337
 
3338
+ var tableFullStyleObj = window.getComputedStyle(table, null);
3339
+ var borderLeftWidth = tableFullStyleObj.getPropertyValue('border-left-width');
3340
+ var borderRightWidth = tableFullStyleObj.getPropertyValue('border-right-width');
3341
+ var tableBorderCommon = parseFloat(borderLeftWidth, 10) + parseFloat(borderRightWidth, 10);
3342
+
3343
  for (var _i5 = 0; _i5 < rows.length; _i5++) {
3344
  var tds = rows[_i5].children;
3345
  for (var _j2 = 0; _j2 < tds.length; _j2++) {
3346
  var td = tds[_j2];
3347
 
3348
+ if (!arrayCellsWidthFixedHelper[parseFloat(td.dataset.xIndex)] && !arrayCellsWidthAutoHelper[parseFloat(td.dataset.xIndex)]) {
3349
  if (td.style.width) {
3350
+ arrayCellsWidthFixedHelper[parseFloat(td.dataset.xIndex)] = parseFloat(td.style.width);
3351
  td.removeAttribute('data-wptb-css-td-auto-width');
3352
  } else {
3353
  if (!td.dataset.wptbFixedWidth) {
3354
+ arrayCellsWidthAutoHelper[parseFloat(td.dataset.xIndex)] = 100;
3355
  td.dataset.wptbCssTdAutoWidth = true;
3356
  }
3357
  }
3365
  var tableTdBorderLeftWidth = tdStyleObj.getPropertyValue('border-left-width');
3366
  var tableTdBorderRightWidth = tdStyleObj.getPropertyValue('border-right-width');
3367
  tableTdBorderCommonWidth = parseFloat(tableTdBorderLeftWidth, 10) + parseFloat(tableTdBorderRightWidth, 10);
3368
+ tableTdBorderCommonWidth = tableTdBorderCommonWidth / 2;
3369
+
3370
+ if (arrayCellsWidthFixedHelper[parseFloat(td.dataset.xIndex)]) {
3371
+ arrayCellsWidthFixedHelper[parseFloat(td.dataset.xIndex)] += tdPaddingCommon;
3372
+ arrayCellsWidthFixedHelper[parseFloat(td.dataset.xIndex)] += tableTdBorderCommonWidth;
3373
+
3374
+ if (_j2 == 0 && tableBorderCommon / 2 <= parseFloat(tableTdBorderLeftWidth, 10)) {
3375
+ arrayCellsWidthFixedHelper[parseFloat(td.dataset.xIndex)] += parseFloat(tableTdBorderLeftWidth, 10) / 2;
3376
+ } else if (_j2 == 0 && tableBorderCommon / 2 > parseFloat(tableTdBorderLeftWidth, 10)) {
3377
+ arrayCellsWidthFixedHelper[parseFloat(td.dataset.xIndex)] += tableBorderCommon / 2 - parseFloat(tableTdBorderRightWidth, 10) / 2;
3378
+ }
3379
+
3380
+ if (_j2 == tds.length - 1 && tableBorderCommon / 2 <= parseFloat(tableTdBorderRightWidth, 10)) {
3381
+ arrayCellsWidthFixedHelper[parseFloat(td.dataset.xIndex)] += parseFloat(tableTdBorderRightWidth, 10) / 2;
3382
+ } else if (_j2 == tds.length - 1 && tableBorderCommon / 2 > parseFloat(tableTdBorderRightWidth, 10)) {
3383
+ arrayCellsWidthFixedHelper[parseFloat(td.dataset.xIndex)] += tableBorderCommon / 2 - parseFloat(tableTdBorderRightWidth, 10) / 2;
3384
+ }
3385
+ } else if (arrayCellsWidthAutoHelper[parseFloat(td.dataset.xIndex)]) {
3386
+ arrayCellsWidthAutoHelper[parseFloat(td.dataset.xIndex)] += tdPaddingCommon;
3387
+ arrayCellsWidthAutoHelper[parseFloat(td.dataset.xIndex)] += tableTdBorderCommonWidth;
3388
+
3389
+ if (_j2 == 0 && tableBorderCommon / 2 <= parseFloat(tableTdBorderLeftWidth, 10)) {
3390
+ arrayCellsWidthAutoHelper[parseFloat(td.dataset.xIndex)] += parseFloat(tableTdBorderLeftWidth, 10) / 2;
3391
+ } else if (_j2 == 0 && tableBorderCommon / 2 > parseFloat(tableTdBorderLeftWidth, 10)) {
3392
+ arrayCellsWidthAutoHelper[parseFloat(td.dataset.xIndex)] += tableBorderCommon / 2 - parseFloat(tableTdBorderLeftWidth, 10) / 2;
3393
+ }
3394
+
3395
+ if (_j2 == tds.length - 1 && tableBorderCommon / 2 <= parseFloat(tableTdBorderRightWidth, 10)) {
3396
+ arrayCellsWidthAutoHelper[parseFloat(td.dataset.xIndex)] += parseFloat(tableTdBorderRightWidth, 10) / 2;
3397
+ } else if (_j2 == tds.length - 1 && tableBorderCommon / 2 > parseFloat(tableTdBorderRightWidth, 10)) {
3398
+ arrayCellsWidthAutoHelper[parseFloat(td.dataset.xIndex)] += tableBorderCommon / 2 - parseFloat(tableTdBorderLeftWidth, 10) / 2;
3399
+ }
3400
  }
3401
  }
3402
+ } else if (arrayCellsWidthAutoHelper[parseFloat(td.dataset.xIndex)]) {
3403
  if (!td.dataset.wptbFixedWidth) {
3404
  td.dataset.wptbCssTdAutoWidth = true;
3405
  }
3406
+ } else if (arrayCellsWidthFixedHelper[parseFloat(td.dataset.xIndex)]) {
3407
  td.removeAttribute('data-wptb-css-td-auto-width');
3408
  }
3409
  }
3423
  }
3424
  }
3425
 
3426
+ tableTdsSumMaxWidth = tableTdsSumMaxWidthFixed + tableTdsSumMaxWidthAuto;
 
 
 
 
3427
 
3428
  table.dataset.wptbTableTdsSumMaxWidth = tableTdsSumMaxWidth;
3429
  if (CellsWidthAutoCount) {
3430
  table.dataset.wptbCellsWidthAutoCount = CellsWidthAutoCount;
3431
  if (table.mergingСellsHorizontally) {
3432
+ table.dataset.wptbFixedWidthSize = tableTdsSumMaxWidthFixed;
3433
  } else {
3434
  table.removeAttribute('data-wptb-fixed-width-size');
3435
  }
3445
  table.style.minWidth = '100%';
3446
  if (table.mergingСellsHorizontally) {
3447
  table.style.width = null;
3448
+ var tableTdsWidthAutoCommon = wptbTableSetupWidth - tableTdsSumMaxWidthFixed;
3449
  tableTdWidthAuto = tableTdsWidthAutoCommon / CellsWidthAutoCount;
3450
  tableTdWidthAuto = tableTdWidthAuto - tdPaddingCommon - tableTdBorderCommonWidth;
3451
  styleElementCreate = true;
3455
  } else {
3456
  table.style.width = null;
3457
  table.style.minWidth = null;
3458
+ table.style.maxWidth = null;
3459
  }
3460
  } else {
3461
  table.style.maxWidth = null;
3549
 
3550
  table.reconstraction = function () {
3551
  var tds = table.getElementsByTagName('td');
 
 
 
 
3552
  table.mergingСellsHorizontally = false;
3553
  table.mergingCellsVertically = false;
3554
  table.dataset.reconstraction = 1;
 
3555
  var forBreak = 0;
3556
  for (var _i9 = 0; _i9 < tds.length; _i9++) {
3557
  if (tds[_i9].colSpan > 1) {
3558
  table.dataset.reconstraction = 0;
 
3559
  table.mergingСellsHorizontally = true;
3560
  forBreak++;
3561
  }
3562
 
3563
  if (tds[_i9].rowSpan > 1) {
3564
  table.dataset.reconstraction = 0;
 
3565
  table.mergingCellsVertically = true;
3566
  forBreak++;
3567
  }
4305
  if (table.rows.length == 0) {
4306
  table.toggleTableEditMode();
4307
  wptbTableSetup.innerHTML = '';
 
4308
  document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';
4309
+ var wptbSaveBtn = document.getElementsByClassName('wptb-save-btn');
4310
+ if (wptbSaveBtn.length > 0) {
4311
+ wptbSaveBtn = wptbSaveBtn[0];
4312
 
4313
+ wptbSaveBtn.classList.add('wptb-save-disabled');
4314
+ }
4315
+ } else {
4316
+ table.recalculateIndexes();
4317
+ WPTB_Helper.dataTitleColumnSet(table);
4318
+ }
4319
  }
4320
 
4321
  undoSelect();
4366
  if (table.querySelectorAll('td').length == 0) {
4367
  table.toggleTableEditMode();
4368
  wptbTableSetup.innerHTML = '';
 
4369
  document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';
4370
+ var wptbSaveBtn = document.getElementsByClassName('wptb-save-btn');
4371
+ if (wptbSaveBtn.length > 0) {
4372
+ wptbSaveBtn = wptbSaveBtn[0];
4373
 
4374
+ wptbSaveBtn.classList.add('wptb-save-disabled');
4375
+ }
4376
+ } else {
4377
+ table.recalculateIndexes();
4378
+ table.tdDefaultWidth();
4379
+ WPTB_Helper.dataTitleColumnSet(table);
4380
+ }
4381
  }
4382
 
4383
  undoSelect();
4439
  // }, false );
4440
  // }
4441
  };
4442
+ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
4443
+
4444
  var WPTB_TableStateSaveManager = function WPTB_TableStateSaveManager() {
4445
+ this.tableStateSet = function (generate) {
4446
+
4447
+ if (generate && window.wptbTableStateSaving && Array.isArray(window.wptbTableStateSaving)) {
4448
+ return;
4449
+ }
4450
+
4451
  // get preview table
4452
  var wptbPreviewTable = document.getElementsByClassName('wptb-preview-table');
4453
  if (wptbPreviewTable.length > 0) {
4454
  wptbPreviewTable = wptbPreviewTable[0];
4455
+ } else {
4456
+ wptbPreviewTable = '';
4457
+ }
4458
 
4459
+ // check if a global array doesn't exist with saved versions of the table
4460
+ // them create it
4461
+ if (!window.wptbTableStateSaving && !Array.isArray(window.wptbTableStateSaving)) {
4462
+ window.wptbTableStateSaving = [];
4463
+ }
4464
 
4465
+ // remove the extra part of the array after changing the table
4466
+ // when it is showed in the not last modified version
4467
+ if (window.wptbTableStateSaving.length > window.wptbTableStateNumberShow) {
4468
+ window.wptbTableStateSaving = window.wptbTableStateSaving.slice(0, window.wptbTableStateNumberShow + 1);
4469
+ }
4470
 
4471
+ //add new state of table
4472
+ var wptbNewPreviewTable = '';
4473
+ if (wptbPreviewTable) {
4474
+ wptbNewPreviewTable = wptbPreviewTable.cloneNode(true);
4475
  var wptbHighlighted = wptbNewPreviewTable.getElementsByClassName('wptb-highlighted');
4476
  for (var i = 0; i < wptbHighlighted.length; i++) {
4477
  wptbHighlighted[i].classList.remove('wptb-highlighted');
4480
  for (var _i = 0; _i < wptbDirectlyhovered.length; _i++) {
4481
  wptbDirectlyhovered[_i].classList.remove('wptb-directlyhovered');
4482
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4483
  var mceContentBodys = wptbNewPreviewTable.querySelectorAll('.mce-content-body');
4484
  if (mceContentBodys.length > 0) {
4485
  for (var k = 0; k < mceContentBodys.length; k++) {
4486
  mceContentBodys[k].classList.remove('mce-content-body');
4487
  }
4488
  }
 
4489
  var dataMceStyle = wptbNewPreviewTable.querySelectorAll('[data-mce-style]');
4490
  if (dataMceStyle.length > 0) {
4491
  for (var _k = 0; _k < dataMceStyle.length; _k++) {
4492
  dataMceStyle[_k].removeAttribute('data-mce-style');
4493
  }
4494
  }
 
4495
  var mceIds = wptbNewPreviewTable.querySelectorAll('[id^=mce_]');
4496
  if (mceIds.length > 0) {
4497
  for (var _k2 = 0; _k2 < mceIds.length; _k2++) {
4498
  mceIds[_k2].removeAttribute('id');
4499
  }
4500
  }
4501
+ }
4502
 
4503
+ var cssForTdsWidthAutoValue = '';
4504
+ var head = document.head;
4505
+ if (head) {
4506
+ var cssForTdsWidthAuto = head.querySelector('style[data-wptb-td-auto-width="true"]');
4507
+ if (cssForTdsWidthAuto) {
4508
+ cssForTdsWidthAutoValue = cssForTdsWidthAuto.innerHTML;
4509
+ }
4510
+ }
4511
 
4512
+ var wptbElementDatas = document.getElementsByClassName('wptb-element-datas');
4513
+ if (wptbElementDatas.length > 0) {
4514
+ wptbElementDatas = wptbElementDatas[0];
4515
+ wptbElementDatas = wptbElementDatas.innerHTML;
4516
+ } else {
4517
+ wptbElementDatas = '';
4518
+ }
4519
 
4520
+ var styleObjJson = WPTB_Helper.elementsStylesConvertToObject();
 
 
 
 
4521
 
4522
+ window.wptbTableStateSaving.push([wptbNewPreviewTable, cssForTdsWidthAutoValue, wptbElementDatas, styleObjJson]);
 
 
4523
 
4524
+ // set new number of state which is showed now
4525
+ window.wptbTableStateNumberShow = window.wptbTableStateSaving.length - 1;
4526
+
4527
+ // make undo arrow active when the table was changed
4528
+ if (window.wptbTableStateSaving.length - 1 > 0) {
4529
+ var wptbUndo = document.getElementsByClassName('wptb-undo');
4530
+ if (wptbUndo.length > 0) {
4531
+ wptbUndo = wptbUndo[0];
4532
 
4533
+ wptbUndo.classList.remove('wptb-undoredo-disabled');
4534
  }
4535
+ }
4536
 
4537
+ // make redo arrow not active when the table was changed
4538
+ var wptbRedo = document.getElementsByClassName('wptb-redo');
4539
+ if (wptbRedo.length > 0) {
4540
+ wptbRedo = wptbRedo[0];
4541
+
4542
+ wptbRedo.classList.add('wptb-undoredo-disabled');
4543
+ }
4544
+
4545
+ var wptbSaveBtn = document.getElementsByClassName('wptb-save-btn');
4546
+ if (wptbSaveBtn.length > 0) {
4547
+ wptbSaveBtn = wptbSaveBtn[0];
4548
+ if (!wptbSaveBtn.dataset.wptbTableStateNumberSave && window.wptbTableStateNumberShow == 0 || window.wptbTableStateNumberShow == wptbSaveBtn.dataset.wptbTableStateNumberSave || !wptbPreviewTable) {
4549
+ wptbSaveBtn.classList.add('wptb-save-disabled');
4550
+ } else {
4551
+ wptbSaveBtn.classList.remove('wptb-save-disabled');
4552
  }
4553
  }
4554
  };
4555
 
4556
  this.tableStateGet = function (datawptbUndoredo) {
4557
+ if (datawptbUndoredo && window.wptbTableStateSaving && window.wptbTableStateSaving.length > 0) {
4558
 
4559
  // changes the number of the state which displays now
4560
  if (datawptbUndoredo == 'undo') {
4564
  return false;
4565
  }
4566
  } else if (datawptbUndoredo == 'redo') {
4567
+ if (window.wptbTableStateNumberShow < window.wptbTableStateSaving.length) {
4568
  window.wptbTableStateNumberShow++;
4569
  } else {
4570
  return false;
4575
  var wptbUndo = document.getElementsByClassName('wptb-undo');
4576
  if (wptbUndo.length > 0) {
4577
  wptbUndo = wptbUndo[0];
4578
+
4579
+ if (window.wptbTableStateNumberShow == 0) {
4580
+ if (wptbUndo) {
4581
+ wptbUndo.classList.add('wptb-undoredo-disabled');
4582
+ }
4583
+ } else if (window.wptbTableStateNumberShow > 0) {
4584
+ if (wptbUndo) {
4585
+ wptbUndo.classList.remove('wptb-undoredo-disabled');
4586
+ }
4587
  }
4588
  }
4589
 
4591
  var wptbRedo = document.getElementsByClassName('wptb-redo');
4592
  if (wptbRedo.length > 0) {
4593
  wptbRedo = wptbRedo[0];
4594
+
4595
+ if (window.wptbTableStateNumberShow == window.wptbTableStateSaving.length - 1) {
4596
+ if (wptbRedo) {
4597
+ wptbRedo.classList.add('wptb-undoredo-disabled');
4598
+ }
4599
+ } else if (window.wptbTableStateNumberShow < window.wptbTableStateSaving.length - 1) {
4600
+ if (wptbRedo) {
4601
+ wptbRedo.classList.remove('wptb-undoredo-disabled');
4602
+ }
4603
  }
4604
  }
4605
 
4606
+ // add or delete class "wptb-save-disabled" for save button
4607
  var wptbSaveBtn = document.getElementsByClassName('wptb-save-btn');
4608
  if (wptbSaveBtn.length > 0) {
4609
  wptbSaveBtn = wptbSaveBtn[0];
4620
  wptbTableSetup = wptbTableSetup[0];
4621
 
4622
  wptbTableSetup.innerHTML = '';
4623
+ if (window.wptbTableStateSaving[window.wptbTableStateNumberShow]) {
4624
+ if (window.wptbTableStateSaving[window.wptbTableStateNumberShow][0] && _typeof(window.wptbTableStateSaving[window.wptbTableStateNumberShow][0]) === 'object') {
4625
+ if ('outerHTML' in window.wptbTableStateSaving[window.wptbTableStateNumberShow][0]) {
4626
+ wptbTableSetup.innerHTML = window.wptbTableStateSaving[window.wptbTableStateNumberShow][0].outerHTML;
4627
+ }
4628
+ }
4629
 
4630
+ if (!wptbTableSetup.innerHTML) {
4631
+ document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';
4632
+ wptbSaveBtn.classList.add('wptb-save-disabled');
4633
+ } else {
4634
+ document.getElementsByClassName('wptb-table-generator')[0].style.display = 'none';
4635
+ }
4636
+ }
4637
+ // add or change or delete style element in the head for table cells who have auto width
4638
+ if (window.wptbTableStateSaving[window.wptbTableStateNumberShow]) {
4639
  var head = document.head;
4640
  if (head) {
4641
  var cssForTdsWidthAutoOld = head.querySelector('style[data-wptb-td-auto-width="true"]');
4642
  if (cssForTdsWidthAutoOld) {
4643
  head.removeChild(cssForTdsWidthAutoOld);
4644
  }
4645
+
4646
+ if (window.wptbTableStateSaving[window.wptbTableStateNumberShow][1]) {
4647
+ var cssForTdsWidthAuto = document.createElement('style');
4648
+ cssForTdsWidthAuto.setAttribute('data-wptb-td-auto-width', true);
4649
+ cssForTdsWidthAuto.innerHTML = window.wptbTableStateSaving[window.wptbTableStateNumberShow][1];
4650
+ head.appendChild(cssForTdsWidthAuto);
4651
+ }
4652
  }
4653
  }
4654
 
 
4655
  var body = document.getElementsByTagName('body');
4656
  if (body.length > 0) {
4657
  body = body[0];
4658
  }
4659
+
4660
+ // add or change or delete script element from the bottom page which have data for several control types
4661
+ var wptbElementDatas = document.getElementsByClassName('wptb-element-datas');
4662
+ if (window.wptbTableStateSaving[window.wptbTableStateNumberShow] && window.wptbTableStateSaving[window.wptbTableStateNumberShow][2]) {
4663
 
4664
  if (wptbElementDatas.length > 0) {
4665
  wptbElementDatas = wptbElementDatas[0];
4666
  } else {
4667
+ wptbElementDatas = document.createElement('sctipt');
4668
  wptbElementDatas.classList.add('wptb-element-datas');
4669
  body.appendChild(wptbElementDatas);
4670
  }
4671
+
4672
+ wptbElementDatas.innerHTML = window.wptbTableStateSaving[window.wptbTableStateNumberShow][2];
4673
  } else {
4674
  if (wptbElementDatas.length > 0) {
4675
  wptbElementDatas = wptbElementDatas[0];
4677
  }
4678
  }
4679
 
4680
+ // runs function which adds or create or delete CSS in the head for several element settings
4681
+ if (window.wptbTableStateSaving[window.wptbTableStateNumberShow]) {
4682
+ WPTB_Helper.elementsStylesSetFromObject(window.wptbTableStateSaving[window.wptbTableStateNumberShow][3]);
4683
+ }
4684
+
4685
  WPTB_Helper.elementOptionsPanelClear();
4686
  WPTB_LeftPanel();
4687
 
4692
  }
4693
  }
4694
  };
4695
+
4696
+ this.tableStateClear = function () {
4697
+ delete window.wptbTableStateSaving;
4698
+ delete window.wptbTableStateNumberShow;
4699
+
4700
+ var wptbSaveBtn = document.getElementsByClassName('wptb-save-btn');
4701
+ if (wptbSaveBtn.length > 0) {
4702
+ wptbSaveBtn = wptbSaveBtn[0];
4703
+
4704
+ wptbSaveBtn.removeAttribute('data-wptb-table-state-number-save');
4705
+ }
4706
+
4707
+ var wptbUndo = document.getElementsByClassName('wptb-undo');
4708
+ if (wptbUndo.length > 0) {
4709
+ wptbUndo = wptbUndo[0];
4710
+
4711
+ wptbUndo.classList.add('wptb-undoredo-disabled');
4712
+ }
4713
+
4714
+ var wptbRedo = document.getElementsByClassName('wptb-redo');
4715
+ if (wptbRedo.length > 0) {
4716
+ wptbRedo = wptbRedo[0];
4717
+
4718
+ wptbRedo.classList.add('wptb-undoredo-disabled');
4719
+ }
4720
+ };
4721
  };
4722
  var WPTB_innerElementSet = function WPTB_innerElementSet(element) {
4723
 
4779
  td.insertBefore(element, innerElementNext);
4780
  }
4781
  }
4782
+
4783
  var thisRow = td.parentNode;
4784
+ if (WPTB_Helper.rowIsTop(thisRow)) {
4785
  var table = WPTB_Helper.findAncestor(thisRow, 'wptb-preview-table');
4786
+
4787
+ if (table.classList.contains('wptb-table-preview-head')) {
4788
+ WPTB_Helper.dataTitleColumnSet(table);
4789
+ }
4790
  }
4791
 
4792
  // start item javascript if item is new
inc/admin/js/admin.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["WPTB_ActionsField.js","WPTB_Builder.js","WPTB_Cell.js","WPTB_DropHandle.js","WPTB_ElementCounters.js","WPTB_ElementObject.js","WPTB_ElementOptions.js","WPTB_Helper.js","WPTB_Initializer.js","WPTB_LeftPanel.js","WPTB_MultipleSelect.js","WPTB_Parser.js","WPTB_Polyfills.js","WPTB_Settings.js","WPTB_Stringifier.js","WPTB_Table.js","WPTB_TableStateSaveManager.js","WPTB_innerElementSet.js","applyGenericItemSettings.js"],"names":["WPTB_ActionsField","wptbActions","document","getElementsByClassName","length","addActionField","actionType","thisNode","body","getElementsByTagName","actions","previousNode","activeElem","classList","remove","parentNode","removeChild","btnDelete","btnCopy","createElement","add","appendChild","type","onclick","event","act","target","el","className","match","WPTB_Helper","elementControlsStateDelete","hasOwnProperty","kind","thisRow","contains","table","findAncestor","dataTitleColumnSet","wptbActionsField","actionsRemove","wptbTableStateSaveManager","WPTB_TableStateSaveManager","tableStateSet","copy","infArr","activeElement","td","Array","isArray","data","elemProt","tinyMceClear","WPTB_ElementObject","elementControlsStateCopy","getDOMElement","insertBefore","nextSibling","elementCopy","cloneNode","applyGenericItemSettings","wptbDocumentEventGenerate","WPTB_innerElementSet","setParameters","btnMove","draggable","ondragstart","wptbElementIconsDirectories","tmplIconsDirectories","wp","template","jsonIconsDirectories","IconsDirectories","JSON","parse","dragImages","getElementIcon","dataTransfer","effectAllowed","setDragImage","setData","style","display","console","log","actionsHide","ondragend","elementDragEndClear","coordinatesElement","getBoundingClientRect","wptbContainer","correctTop","top","parseFloat","removeEventListener","left","right","clientWidth","addEventListener","leaveFromField","node","relatedTarget","onmouseleave","opacity","WPTB_Builder","table_id","detectMode","http","XMLHttpRequest","urlSet","ajaxurl","open","setRequestHeader","onreadystatechange","d","readyState","status","ans","responseText","getElementById","value","wptbTableSetupEl","WPTB_Parser","elementsSettingTemplateJs","setAttribute","innerHTML","WPTB_Table","WPTB_LeftPanel","WPTB_Settings","send","counter","ElementCounters","select","MultipleSelect","initializer","WPTB_Initializer","settings","WPTB_Cell","callback","DOMElement","highlightRow","parentRow","columnCount","parseInt","tds","i","classToAdd","ttd","highlightColumn","index","rowCount","tr","padding","jQuery","val","innerBorderWidth","border","wptbPhElement","wptbElementTypeClass","wptbTypeElementArr","split","wptbInternalActiveElement","j","wptbInternalActiveElementObj","setCoords","y","x","dataset","yIndex","xIndex","getCoords","coords","appendElement","getCellDimensions","tdStyleObj","window","getComputedStyle","tdPaddingLeft","getPropertyValue","tdPaddingRight","tdBorderLeftWidth","tdBorderRightWidth","tdPaddingTop","tdPaddingBottom","tdBorderTopWidth","tdBorderBottomWidth","width","offsetWidth","height","offsetHeight","WPTB_DropHandle","thisElem","e","wptbDropHandle","wptbDropBorderMarker","wptbDropBorderMarkerTop","wptbDropBorderMarkerRight","wptbDropBorderMarkerBottom","wptbDropBorderMarkerLeft","ondragenter","ondragover","preventDefault","ondragleave","ondrop","element","getData","newElementProxy","wptbMovingMode","text","getDOMParentElement","nodeName","toLowerCase","innerElement","innerElementNext","elemKind","undefined","querySelector","onscroll","localName","indics","types","notDragEnter","indexOf","elementDrag","offsetY","layerY","bottom","priv","increment","key","nextIndex","kindIndexProt","wpTemplateId","itemHtml","replace","trim","wptbElementMutch","elementClearFromTinyMce","inElems","querySelectorAll","inElemObj","WPTB_ElementOptions","elemIdClass","children","childNodes","wptbContrlStacksConfigId","tmplControlsConfig","container","jsonControlsConfigJson","jsonControlsConfig","wptbElementOptionsContainer","elementOptionsGroup","elementOptionsGroupChildren","regularText","RegExp","elem","controlScriptsArr","controlAppearDependOn","Object","keys","forEach","controlKey","tmplControlTemplate","elemContainer","elementControlTargetUnicClass","controlTemplate","appearDependOn","push","wptbElementOptionContainer","customClassForContainer","containerAdditionalStyles","helperJavascriptElem","helperJavascriptCode","innerText","script","hexToRgb","hex","result","exec","rgbToHex","rgb","toString","slice","icon_directory","hostName","location","protocol","hostname","img","src","wptbDropHandles","wptbDropBorderMarkers","linkHttpCheckChange","link","linkArr","linkClean","rows","rowHead","computedStyleRowHead","rowHeadChildren","contentsForHeader","tdElements","p","textContent","textAlign","fontSize","color","backgroundColor","thisRowChildren","wptbTitleColumn","wptbTitleColumnFontSize","wptbTitleColumnColor","wptbTitleBackgroundColor","wptbTitleAlign","cls","parentElement","getSelectionText","txt","getSelection","selection","createRange","settingsPanelClear","checked","wpColorPickerClear","elementOptionsPanelClear","wpColorPickerCheckChangeForTableStateSaving","originalEvent","wpPickerContainer","irisStripMouseUpStateSaveManager","attribute","isId","input","parent","newInput","url","href","regex","results","decodeURIComponent","getColumnWidth","cell","xIndexes","cellWidth","getRowHeight","yIndexes","cellHeight","wpColorPickerChange","ui","uiColor","classe","ps","number","affectedEl","ratingStar","span","fill","wptbTextMessageSize","numberImputSize","wptbNumberInputs","maxCount","maxValue","onkeydown","thisValue","String","substring","onkeyup","ucfirst","str","charAt","toUpperCase","eventName","details","CustomEvent","detail","bubbles","dispatchEvent","elementStartScript","WPTB_ElementsScriptsLauncher","deleteEventHandlers","off","elementChildren","replaceAll","string","search","join","mceContentBodys","k","dataMceStyle","removeAttribute","mceEditFocus","contentEditable","spellCheck","mceIds","elementOptionContainerCustomClassSet","targetInput","containerElement","elementOptionContainerAdditionalStyles","containerStylesArrOne","containerStylesSet","containerStyleStr","containerStyleStrArr","controlsInclude","functionHandler","elementKind","сontrolsConnectIndic","elementsSettingsTemplateJs","elementsSettings","controlClassesNames","elementSettings","keyInfArr","controlClass","controls","controlName","control","targetControlValue","targetControlValueGet","oneControlInclude","controlClassName","innerElementCopyIncludeHandler","dependOn","targetControlElementClass","dependOnControlName","dependOnControlElementClass","dependOnControlElement","targetControlElement","controlContainerElem","showHideDependOnControlElement","dependOnControlElementKind","elementSettingValue","controlsStateManager","targetControlClass","controlChangeIndic","targetControls","selectorElement","elementsSettingsTemplatesJs","stringify","name","elementProt","copyElem","infArrProt","infArrCopy","elemProtKind","elemCopyKind","elementSettingsProt","elementSettingsCopy","elementSettingKeyCopy","wptbElementDatas","MIN_COLUMNS","MIN_ROWS","MAX_COLUMNS","MAX_ROWS","tableGenerator","columnsDecrementButton","columnsIncrementButton","rowsDecrementButton","rowsIncrementButton","columnsInput","rowsInput","columns","wptbElementButtons","wptbTdBgColorSavedSet","inputId","trNumber","tableRows","trBackgroundColor","wptbEvenRowBg","wpColorPicker","change","clear","tableHeader","tableAdaptiveForMobile","wptbAdaptiveTableCheckbox","wptbAdaptiveTable","tableTopRowAsHeadSavedSet","wptbTopRowAsHeader","tableBorderColorWidthSavedSet","tableBorderColor","borderColor","tableBorderColorInput","tableBorderWidth","borderWidth","wptbTableBorderWidthSlider","wptbTableBorderWidthNumber","tableTd","applyInnerBorder","innerBorderCheckInput","wptbApplyInnerBorder","wptbTableInnerBorderSlider","wptbTableInnerBorderNumber","tableCells","tableInnerborderNumber","addInnerBorderSize","borderStyle","addCellPadding","addInnerBorder","styles","wptbPreviewTable","marginBottom","addBorderSize","cellPaddingSavedSet","wptbTableCellSlider","wptbTableCellNumber","wptbTableBorderNumber","wptbTableColumnWidthNumber","wptbTableRowHeightNumber","oninput","tdDefaultWidth","onchange","wptbInnerBorderCheck","tableBorderColorSetArea","addColumnWidth","highlighted","addRowHeight","createMobileHeadForTable","thisEvent","wptbElement","toggleTableEditMode","addRowToTheEnd","addRowToTheStart","addRowBefore","addRowAfter","addColumnEnd","addColumnStart","addColumnBefore","addColumnAfter","deleteColumn","deleteRow","mergeCells","splitCell","wptbBuilderPanel","clickOnFreeSpace","wptbHeader","wpcdFixedToolbar","hasAttribute","getAttribute","selectedCells","multipleCellMode","activateMultipleSelectMode","deactivateMultipleSelectMode","isActivated","pushSelectedCell","flushSelectedCells","getFirst","minXIndex","minYIndex","first","getLast","maxXIndex","maxYIndex","last","removeAllButFirst","code","div","columnTitleMobile","prototype","hasDontEnumBug","propertyIsEnumerable","dontEnums","dontEnumsLength","obj","TypeError","prop","call","elems","wptbUndo","tableStateGet","wptbUndoredo","wptbUndoRedoContainer","wptbRedo","shortcodePopupWindow","onbeforeunload","wptbSaveDisabled","wptbTableStateNumberSave","wptbTableStateNumberShow","bar","wptb_admin_object","t","messagingArea","datas","WPTB_Stringifier","outerHTML","datas_containers","messagingAreaText","setTimeout","firstChild","params","title","content","elements_datas","security_code","rs","wptbId","id","action","wptbPreviewBtn","wptbPreviewBtnHref","previewHref","wptbSaveBtn","codeMain","tableColumns","minWidth","maxWidth","innerElements","wptbActionsLength","columnNameDivContainer","columnNameDiv","array","wptbTableSetup","row","maxAmountOfCells","maxAmountOfRows","mark","rowSpan","cs","colSpan","markedCells","noCells","singleCells","multipleCells","cellSettings","position","column","cellHighlighted","wptbTableColumnWidthSlider","tableColumnWidthAutoFixedCheckbox","wptbFixedWidth","wptbTableRowHeightSlider","tableRowHeightAutoFixedCheckbox","wptbFixedHeight","isSquare","realTimeArray","carried","cols","matriz","items","justAssigned","amount","carriedRowspans","cellsBuffer","cellPointer","xPosition","stepsToMove","celda","drawTable","a","undoSelect","fillTableArray","colspansSums","cells","colspanSumInRow","Math","max","apply","getActualPointsInRow","points","skipInCols","reconstraction","insertRow","wptb_preview_table","cellModeBackground","leftScrollPanelCurtain","leftScrollPanelCellSettings","wptbPreviewTableTds","recalculateIndexes","start","trs","maxCols","maxColsFull","tdsArr","jMainIter","z","cleaner","dataXIndex","tableTdsFor","colspan","widthIsSet","arrayTdsFromPreviousRow","tableTdsSumMaxWidth","tableTdsSumMaxWidthFixed","tableTdsSumMaxWidthAuto","wptbTableSetupWidth","arrayCellsWidthFixedHelper","arrayCellsWidthAutoHelper","tdPaddingCommon","tableTdBorderCommonWidth","cssForTdsWidthAuto","wptbCssTdAutoWidth","tableTdBorderLeftWidth","tableTdBorderRightWidth","CellsWidthAutoCount","tableFullStyleObj","borderLeftWidth","borderRightWidth","tableBorderCommon","wptbTableTdsSumMaxWidth","wptbCellsWidthAutoCount","mergingСellsHorizontally","wptbFixedWidthSize","styleElementCreate","tableTdWidthAuto","tableTdsWidthAutoCommon","head","cssForTdsWidthAutoOld","dataYIndex","rowspan","heightIsSet","arrayTdsPrevious","tableColumnHeightAutoFixedCheckbox","wptbAdaptiveTableChoseBlock","mergingCellsVertically","forBreak","currentTable","currentTableTd","currentTdStyle","firstCell","c_pos","cellStyle","pos","pendingInsertion","bro","currentCell","l","r","aux","from","cellNew","rowChildren","rowChildrenLength","cellRowSpan","rowAfter","cellsColSpan","tableRowsIChildren","tableRIChildrenLength","rowIRowSpan","rNext","rNextChildren","rNextChildrenLength","rowStart","columnStart","rowEnd","columnEnd","itemsEstimate","dimensions","tdsChildrenNew","tdsInternalElements","tdsIntElemLength","firstWidth","firstDataFixedWidth","firstHeight","firstDataFixedHeight","cellStyles","cellXIndex","rowChildInsertBefore","rowNext","Number","findRowspannedCells","difference","actualPoints","addLackingCells","sumRows","totalColspan","nextRow","nextRowChildren","nextRowChildrenLength","tdArr","nextRowChildrenK","jRowChildren","pop","onresize","wptbTableStateSaving","wptbNewPreviewTable","wptbHighlighted","wptbDirectlyhovered","cssForTdsWidthAutoValue","wptbDlementDatas","datawptbUndoredo","wptbLeftScrollPanelCellSetting","classId","stopPropagation","onmouseover","wptbElements","elementIndexesArr","elementIndexMax","wptbNodeattributes","attributes","attr","newDataAttributeName","newDataAttributeValue","nodeValue","kindIndexProtArr","node_wptb_element_kind_num","onmouseenter"],"mappings":";;AAAA,IAAIA,oBAAoB,SAApBA,iBAAoB,GAAW;AAAA;;AAC/B;AACA,SAAKC,WAAL;AACA,QAAIC,SAASC,sBAAT,CAAiC,cAAjC,EAAkDC,MAAlD,IAA4D,CAAhE,EAAoE;AAChE,aAAKH,WAAL,GAAmBC,SAASC,sBAAT,CAAiC,cAAjC,EAAkD,CAAlD,CAAnB;AACH;;AAED,SAAKE,cAAL,GAAsB,UAAEC,UAAF,EAAcC,QAAd,EAA4B;AAC9C,YAAIC,OAAON,SAASO,oBAAT,CAA+B,MAA/B,EAAwC,CAAxC,CAAX;;AAEA,YAAIC,UAAUR,SAASC,sBAAT,CAAiC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AApC;;AAEA7D,yBAAiBwB,aAAjB,CAAgCqC,IAAhC;;AAEAA,aAAKvF,SAAL,CAAeC,MAAf,CAAuB,kBAAvB;AACH,KAZD;;AAcAsF,SAAKE,YAAL,GAAoB,UAAW9E,KAAX,EAAmB;AACnC,YAAIe,mBAAmB,IAAIvC,iBAAJ,EAAvB;;AAEAuC,yBAAiB4D,cAAjB,CAAiC3E,KAAjC,EAAwC4E,IAAxC;AACH,KAJD;AAKH,CApFD","file":"admin.js","sourcesContent":["var WPTB_ActionsField = function() {\n //this.wptbBorderMarker;\n this.wptbActions;\n if( document.getElementsByClassName( 'wptb-actions' ).length != 0 ) {\n this.wptbActions = document.getElementsByClassName( 'wptb-actions' )[0];\n }\n \n this.addActionField = ( actionType, thisNode ) => {\n let body = document.getElementsByTagName( 'body' )[0];\n \n let actions = document.getElementsByClassName( 'wptb-actions' );\n if( actions.length != 0 ) {\n let previousNode = actions[0].activeElem;\n if( previousNode ) {\n previousNode.classList.remove( 'wptb-directlyhovered' );\n }\n \n while( actions.length != 0 ) {\n actions[0].parentNode.removeChild( actions[0] );\n }\n }\n \n if( actionType == 1 ) {\n \n let btnDelete, btnCopy;\n\n btnDelete = document.createElement( 'span' ),\n btnCopy = document.createElement( 'span' ),\n actions = document.createElement( 'div' );\n\n actions.classList.add( 'wptb-actions' );\n btnDelete.classList.add( 'dashicons', 'dashicons-trash', 'wptb-delete-action' );\n btnCopy.classList.add( 'dashicons', 'dashicons-admin-page', 'wptb-duplicate-action' );\n \n actions.appendChild( btnCopy );\n actions.appendChild( btnDelete );\n \n body.appendChild( actions );\n\n actions.activeElem = thisNode;\n\n actions.type = 1;\n\n btnDelete.onclick = function( event ) {\n let act = event.target.parentNode.activeElem,\n el = act.parentNode;\n \n if( act && act.className.match( /wptb-element-(.+)-(\\d+)/i ) ) {\n WPTB_Helper.elementControlsStateDelete( act );\n }\n \n if( act ) {\n el.removeChild( act );\n }\n\n if( act && typeof act === 'object' && act.hasOwnProperty( 'kind' ) && act.kind == 'text' ) {\n let thisRow = el.parentNode\n if( thisRow.classList.contains( 'wptb-table-head' ) ) {\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\n WPTB_Helper.dataTitleColumnSet( table );\n }\n }\n\n let wptbActionsField = new WPTB_ActionsField();\n wptbActionsField.actionsRemove();\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n btnCopy.onclick = ( event ) => {\n let copy,\n infArr,\n type;\n let activeElement = event.target.parentNode.activeElem;\n let td = activeElement.parentNode;\n infArr = activeElement.className.match( /wptb-element-(.+)-(\\d+)/i );\n if( infArr && Array.isArray( infArr ) ) {\n type = infArr[1];\n let data = {};\n data.kind = type;\n data.elemProt = activeElement;\n data.tinyMceClear = true;\n copy = new WPTB_ElementObject( data );\n WPTB_Helper.elementControlsStateCopy( activeElement, copy.getDOMElement() );\n //WPTB_Helper.elementStartScript( copy.getDOMElement() );\n \n td.insertBefore( copy.getDOMElement(), activeElement.nextSibling );\n } else {\n copy = {};\n let elementCopy = activeElement.cloneNode( true );\n elementCopy.classList.remove( 'wptb-directlyhovered' );\n \n copy.getDOMElement = function() {\n return elementCopy;\n }\n \n applyGenericItemSettings( copy );\n \n td.insertBefore( copy.getDOMElement(), activeElement.nextSibling );\n \n WPTB_Helper.wptbDocumentEventGenerate( 'wptb-inner-element:copy', activeElement, copy.getDOMElement() );\n }\n \n WPTB_innerElementSet( copy.getDOMElement() );\n\n let wptbActionsField = new WPTB_ActionsField( 1, activeElement );\n wptbActionsField.setParameters( activeElement );\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n \n \n if( thisNode.classList.contains( 'wptb-ph-element' ) ) {\n let btnMove;\n btnMove = document.createElement( 'span' );\n btnMove.classList.add( \"dashicons\", \"dashicons-move\", 'wptb-move-action' );\n btnMove.draggable = true;\n actions.appendChild( btnMove );\n \n btnMove.ondragstart = ( event ) => {\n let wptbElementIconsDirectories = 'wptb-element-icons-directories';\n let tmplIconsDirectories = wp.template( wptbElementIconsDirectories );\n let data = {};\n let jsonIconsDirectories = tmplIconsDirectories( data );\n let IconsDirectories = JSON.parse( jsonIconsDirectories );\n\n let dragImages,\n actions = event.target.parentNode,\n activeElem = actions.activeElem,\n infArr,\n type;\n infArr = activeElem.className.match( /wptb-element-(.+)-(\\d+)/i );\n if( infArr && Array.isArray( infArr ) ) {\n type = infArr[1];\n activeElem.classList.add( 'wptb-moving-mode' );\n\n if( IconsDirectories && typeof IconsDirectories === 'object' && IconsDirectories[type] ) {\n dragImages = WPTB_Helper.getElementIcon( IconsDirectories[type] );\n }\n\n event.dataTransfer.effectAllowed = 'move';\n event.dataTransfer.setDragImage( dragImages, 0, 0 );\n event.dataTransfer.setData( 'node', 'wptb-element-' + infArr[1] + '-' + infArr[2] );\n event.dataTransfer.setData( 'wptb-moving-mode', 'wptb-element-' + infArr[1] + '-' + infArr[2] );\n event.dataTransfer.setData( 'wptbElIndic-' + infArr[1], 'wptbElIndic-' + infArr[1] );\n let act = event.target.parentNode.activeElem;\n if( act.kind == 'text' ) {\n let thisRow = act.parentNode.parentNode;\n if( thisRow.classList.contains( 'wptb-table-head' ) ) {\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\n WPTB_Helper.dataTitleColumnSet( table );\n }\n }\n } else {\n this.style.display = 'none';\n console.log(this);\n }\n\n this.actionsHide();\n };\n\n btnMove.ondragend = ( event ) => {\n WPTB_Helper.elementDragEndClear();\n }\n }\n\n actions.style.display = 'block';\n\n this.wptbActions = actions;\n } \n }\n \n this.setParameters = ( thisNode ) => {\n \n if( ! this.wptbActions ) {\n let actions = document.getElementsByClassName( 'wptb-actions' );\n if( actions.length > 0 ) {\n this.wptbActions = actions[0];\n } else {\n this.wptbActions = false;\n }\n }\n \n if( this.wptbActions && this.wptbActions.classList.contains( 'wptb-actions' ) ) {\n this.wptbActions.style.display = 'block';\n } else {\n return;\n }\n \n let coordinatesElement = thisNode.getBoundingClientRect();\n \n let wptbContainer = document.getElementsByClassName( 'wptb-container' )[0];\n let correctTop = () => {\n let coordinatesElement = thisNode.getBoundingClientRect();\n this.wptbActions.style.top = parseFloat( coordinatesElement.top ) - 15 + 'px';\n }\n wptbContainer.removeEventListener( 'scroll', correctTop, false );\n \n this.wptbActions.style.top = parseFloat( coordinatesElement.top ) - 15 + 'px';\n this.wptbActions.style.left = ( parseFloat( coordinatesElement.right ) - parseFloat( this.wptbActions.clientWidth ) ) + 1 + 'px';\n \n this.wptbActions.style.display = 'block';\n thisNode.classList.add( 'wptb-directlyhovered' );\n \n wptbContainer.addEventListener( 'scroll', correctTop, false );\n }\n \n this.leaveFromField = ( event, node, actionType ) => {\n if( ! this.wptbActions ) {\n let actions = document.getElementsByClassName( 'wptb-actions' );\n if( actions.length > 0 ) {\n this.wptbActions = actions[0];\n } else {\n this.wptbActions = false;\n }\n }\n \n if( ! this.wptbActions ) {\n return;\n }\n \n if( event.relatedTarget ) {\n if ( event.relatedTarget.classList.contains( 'wptb-actions' ) ||\n event.relatedTarget.classList.contains( 'wptb-move-action' ) ||\n event.relatedTarget.classList.contains( 'wptb-duplicate-action' ) ||\n event.relatedTarget.classList.contains( 'wptb-delete-action' ) ) {\n if( ! this.wptbActions ) {\n this.wptbActions = document.getElementsByClassName( 'wptb-actions' )[0];\n }\n this.wptbActions.onmouseleave = ( event ) => {\n if( event.relatedTarget != null && ( event.relatedTarget.classList.contains( 'wptb-ph-element' ) || \n WPTB_Helper.findAncestor( event.relatedTarget, 'wptb-ph-element') ) && event.relatedTarget != this.wptbActions.activeElem &&\n WPTB_Helper.findAncestor( event.relatedTarget, 'wptb-directlyhovered' ) != this.wptbActions.activeElem ) {\n \n// this.wptbActions.style.display = 'none';\n// event.relatedTarget.parentNode.parentNode.classList.remove( 'wptb-directlyhovered' );\n//\n// let wptbActionsField = new WPTB_ActionsField();\n//\n// wptbActionsField.addActionField( 1, event.relatedTarget.parentNode.parentNode );\n//\n// wptbActionsField.setParameters( event.relatedTarget.parentNode.parentNode );\n } else {\n \n }\n \n let wptbActionsField = new WPTB_ActionsField();\n\n wptbActionsField.leaveFromField( event, event.relatedTarget.parentNode.parentNode );\n \n event.target.activeElem.classList.remove( 'wptb-directlyhovered' );\n }\n\n return;\n } \n }\n \n node.classList.remove( 'wptb-directlyhovered' );\n this.wptbActions.style.display = 'none';\n \n if( event.relatedTarget ) {\n if( event.relatedTarget.classList.contains( 'wptb-ph-element' ) || WPTB_Helper.findAncestor( event.relatedTarget, 'wptb-ph-element' ) ) {\n this.addActionField( 1, event.relatedTarget.parentNode );\n\n this.setParameters( event.relatedTarget.parentNode );\n }\n }\n }\n \n this.actionsRemove = () => {\n if( ! this.wptbActions ) {\n let actions = document.getElementsByClassName( 'wptb-actions' );\n if( actions.length > 0 ) {\n this.wptbActions = actions[0];\n }\n }\n \n if( this.wptbActions ) {\n this.wptbActions.parentNode.removeChild( this.wptbActions );\n }\n }\n \n this.actionsHide = () => {\n if( ! this.wptbActions ) {\n let actions = document.getElementsByClassName( 'wptb-actions' );\n if( actions.length > 0 ) {\n this.wptbActions = actions[0];\n }\n }\n \n if( this.wptbActions ) {\n this.wptbActions.style.opacity = 0;\n }\n }\n}","(function () {\n var WPTB_Builder = function () {\n var table_id = WPTB_Helper.detectMode();\n if ( table_id ) {\n var http = new XMLHttpRequest(),\n urlSet = ajaxurl + \"?action=get_table\" + '&id=' + table_id;\n http.open('GET', urlSet, true);\n http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');\n http.onreadystatechange = function (d) {\n if (this.readyState == 4 && this.status == 200) {\n var ans = JSON.parse(http.responseText);\n document.getElementById('wptb-setup-name').value = ans[0];\n \n if( ans[1] ) {\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'none';\n let wptbTableSetupEl = document.getElementsByClassName('wptb-table-setup')[0];\n wptbTableSetupEl.appendChild( WPTB_Parser( ans[1] ) );\n \n let body = document.getElementsByTagName('body')[0];\n \n if( ans[2] ) {\n let elementsSettingTemplateJs = document.createElement( 'script' );\n elementsSettingTemplateJs.setAttribute( 'type', 'text/html' );\n elementsSettingTemplateJs.setAttribute( 'class', 'wptb-element-datas' );\n\n elementsSettingTemplateJs.innerHTML = ans[2];\n\n body.appendChild( elementsSettingTemplateJs );\n }\n \n WPTB_Table();\n WPTB_LeftPanel();\n WPTB_Settings();\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n } else {\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\n }\n \n return;\n }\n };\n http.send(null);\n } else {\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\n }\n document.counter = new ElementCounters();\n document.select = new MultipleSelect();\n\n var initializer = WPTB_Initializer();\n settings = WPTB_Settings();\n };\n\n document.addEventListener('DOMContentLoaded', WPTB_Builder);\n})();","var WPTB_Cell = function (callback, DOMElement) {\n\n function highlightRow(td) {\n var parentRow = td.parentNode,\n columnCount = parseInt(document.getElementById('wptb-columns-number').value),\n tds = document.getElementsByClassName('wptb-preview-table')[0].getElementsByTagName('td');\n for (var i = 0; i < tds.length; i++) {\n tds[i].classList.remove('wptb-highlighted-row-first', 'wptb-highlighted-row-last', 'wptb-highlighted-row-inner', 'wptb-highlighted-column-first', 'wptb-highlighted-column-last', 'wptb-highlighted-column-inner');\n }\n for (var i = 0; i < columnCount; i++) {\n\n var classToAdd = i == 0 ? 'wptb-highlighted-row-first' : i == columnCount - 1 ? 'wptb-highlighted-row-last' : 'wptb-highlighted-row-inner';\n var ttd = parentRow.getElementsByTagName('td')[i];\n if (ttd !== td) {\n ttd.classList.add(classToAdd);\n }\n }\n }\n\n function highlightColumn(td) {\n\n var index,\n parentRow = td.parentNode;\n columnCount = parseInt(document.getElementById('wptb-columns-number').value), rowCount = parseInt(document.getElementById('wptb-rows-number').value), table = document.getElementsByClassName('wptb-preview-table')[0];\n for (var i = 0; i < columnCount; i++) {\n if (parentRow.getElementsByTagName('td')[i] === td) {\n index = i;\n break;\n }\n }\n\n for (var i = 0; i < rowCount; i++) {\n var classToAdd = i == 0 ? 'wptb-highlighted-column-first' : i == rowCount - 1 ? 'wptb-highlighted-column-last' : 'wptb-highlighted-column-inner';\n var tr = table.getElementsByTagName('tr')[i];\n if (tr.getElementsByTagName('td')[index] !== td) {\n tr.getElementsByTagName('td')[index].classList.add(classToAdd);\n }\n }\n }\n \n if( ! DOMElement ) {\n DOMElement = document.createElement(\"td\");\n\n DOMElement.style.padding = jQuery('#wptb-table-padding-number').val() + 'px';\n\n var innerBorderWidth = jQuery('#wptb-table-inner-border-number').val();\n\n if (innerBorderWidth != '' && parseInt(innerBorderWidth) != 0) {\n DOMElement.style.border = innerBorderWidth + 'px solid ' + jQuery('#wptb-table-border-color').val();\n } \n\n DOMElement.classList.add('wptb-droppable', 'wptb-cell');\n }\n\n DOMElement.draggable = false;\n if ( callback ) {\n DOMElement.onclick = callback;\n }\n \n WPTB_innerElementSet( DOMElement );\n \n let wptbPhElement = DOMElement.getElementsByClassName( 'wptb-ph-element' );\n \n if ( wptbPhElement.length > 0 ) {\n for( let i = 0; i < wptbPhElement.length; i++ ) {\n wptbPhElement[i].getDOMElement = function() {\n return wptbPhElement[i];\n }\n \n WPTB_innerElementSet( wptbPhElement[i] );\n \n let wptbElementTypeClass = wptbPhElement[i].className.match( /wptb-element-((.+-)\\d+)/i );\n if( wptbElementTypeClass && Array.isArray( wptbElementTypeClass ) ) {\n let wptbTypeElementArr = wptbElementTypeClass[1].split( '-' );\n wptbPhElement[i].kind = wptbTypeElementArr[0];\n applyGenericItemSettings( wptbPhElement[i], wptbElementTypeClass[1] );\n let wptbInternalActiveElement = wptbPhElement[i].getElementsByClassName( 'wptb-in-element' );\n if ( wptbInternalActiveElement.length > 0 ) {\n for ( let j = 0; j < wptbInternalActiveElement.length; j++ ) {\n let wptbInternalActiveElementObj = {};\n wptbInternalActiveElementObj.getDOMElement = function() {\n return wptbInternalActiveElement[j];\n }\n \n applyGenericItemSettings( wptbInternalActiveElementObj );\n }\n }\n }\n }\n }\n\n this.getDOMElement = function () {\n return DOMElement;\n };\n\n this.setCoords = function (y, x) {\n var el = this.getDOMElement();\n el.dataset.yIndex = y;\n el.dataset.xIndex = x;\n };\n\n this.getCoords = function () {\n var coords,\n el = this.getDOMElement();\n coords.x = el.dataset.xIndex;\n coords.y = el.dataset.yIndex;\n return coords;\n };\n\n this.appendElement = function (node) {\n getDOMElement().appendChild(node);\n };\n \n DOMElement.getCellDimensions = function() {\n let tdStyleObj = window.getComputedStyle( this, null );\n \n let tdPaddingLeft = tdStyleObj.getPropertyValue( 'padding-left' );\n let tdPaddingRight = tdStyleObj.getPropertyValue( 'padding-right' );\n \n let tdBorderLeftWidth = tdStyleObj.getPropertyValue( 'border-left-width' );\n let tdBorderRightWidth = tdStyleObj.getPropertyValue( 'border-right-width' );\n \n let tdPaddingTop = tdStyleObj.getPropertyValue( 'padding-top' );\n let tdPaddingBottom = tdStyleObj.getPropertyValue( 'padding-bottom' );\n \n let tdBorderTopWidth = tdStyleObj.getPropertyValue( 'border-top-width' );\n let tdBorderBottomWidth = tdStyleObj.getPropertyValue( 'border-bottom-width' );\n \n let width = parseFloat( this.offsetWidth, 10 ) - \n parseFloat( tdPaddingLeft, 10 ) - \n parseFloat( tdPaddingRight, 10 ) -\n parseFloat( tdBorderLeftWidth, 10 ) -\n parseFloat( tdBorderRightWidth, 10 );\n \n let height = parseFloat( this.offsetHeight, 10 ) - \n parseFloat( tdPaddingTop, 10 ) - \n parseFloat( tdPaddingBottom, 10 ) -\n parseFloat( tdBorderTopWidth, 10 ) -\n parseFloat( tdBorderBottomWidth, 10 );\n \n return {\n width: width, \n height: height\n };\n }\n\n return this;\n};","var WPTB_DropHandle = function (thisElem, e) {\n \n let wptbDropHandle,\n wptbDropBorderMarker;\n if ( document.getElementsByClassName( 'wptb-drop-handle' ).length == 0 ) {\n wptbDropHandle = document.createElement( 'div' );\n wptbDropHandle.classList.add( 'wptb-drop-handle' );\n \n wptbDropBorderMarker = document.createElement( 'div' );\n wptbDropBorderMarker.classList.add( 'wptb-drop-border-marker' );\n \n let wptbDropBorderMarkerTop = document.createElement( 'div' ),\n wptbDropBorderMarkerRight = document.createElement( 'div' ),\n wptbDropBorderMarkerBottom = document.createElement( 'div' ),\n wptbDropBorderMarkerLeft = document.createElement( 'div' );\n \n wptbDropBorderMarkerTop.classList.add( 'wptb-drop-border-marker-top' );\n wptbDropBorderMarkerRight.classList.add( 'wptb-drop-border-marker-right' );\n wptbDropBorderMarkerBottom.classList.add( 'wptb-drop-border-marker-bottom' );\n wptbDropBorderMarkerLeft.classList.add( 'wptb-drop-border-marker-left' );\n \n wptbDropBorderMarker.appendChild( wptbDropBorderMarkerTop );\n wptbDropBorderMarker.appendChild( wptbDropBorderMarkerRight );\n wptbDropBorderMarker.appendChild( wptbDropBorderMarkerBottom );\n wptbDropBorderMarker.appendChild( wptbDropBorderMarkerLeft );\n \n let body = document.getElementsByTagName( 'body' );\n if ( body.length > 0 ) {\n body[0].appendChild( wptbDropHandle );\n body[0].appendChild( wptbDropBorderMarker );\n }\n \n wptbDropHandle.ondragenter = function () {\n\n }\n\n wptbDropHandle.ondragover = function (e) {\n e.preventDefault();\n }\n\n wptbDropHandle.ondragleave = function () {\n\n }\n wptbDropHandle.ondrop = function (e) {\n e.preventDefault();\n let element;\n \n if ( e.dataTransfer.getData('wptbElement') ) {\n element = WPTB_Helper.newElementProxy( e.dataTransfer.getData('wptbElement') );\n element = element.getDOMElement();\n } else {\n element = document.getElementsByClassName( e.dataTransfer.getData('node') )[0];\n element.classList.remove( 'wptb-moving-mode' );\n element.classList.remove( 'wptb-moving-into-same-elem' );\n element.wptbMovingMode = 1;\n }\n \n let td;\n if( wptbDropHandle.dataset.text == 'Drop Here' ) {\n thisElem = wptbDropHandle.getDOMParentElement();\n if ( thisElem.nodeName.toLowerCase() == 'td' ) {\n td = wptbDropHandle.getDOMParentElement();\n td.appendChild( element );\n }\n } else {\n let innerElement = wptbDropHandle.getDOMParentElement();\n td = innerElement.parentNode;\n \n if( wptbDropHandle.dataset.text == 'Above Element' ) {\n td.insertBefore( element, innerElement );\n } else if( wptbDropHandle.dataset.text == 'Below Element' ) {\n let innerElementNext = innerElement.nextSibling;\n td.insertBefore( element, innerElementNext );\n }\n }\n \n let thisRow = td.parentNode\n if( thisRow.classList.contains( 'wptb-table-head' ) ) {\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\n WPTB_Helper.dataTitleColumnSet( table );\n }\n \n // start item javascript if item is new\n let infArr = element.className.match(/wptb-element-(.+)-(\\d+)/i);\n let elemKind = infArr[1];\n if ( e.dataTransfer.getData( 'wptbElement' ) && ( elemKind == 'text' || elemKind == 'button' || elemKind == 'image' || elemKind == 'star_rating' || elemKind == 'list' ) ) {\n //WPTB_Helper.elementStartScript( element );\n }\n \n wptbDropHandle.style.display = 'none';\n wptbDropBorderMarker.style.display = 'none';\n \n WPTB_innerElementSet(element);\n if( ! element.classList.contains( 'wptb-image-container' ) || element.wptbMovingMode == 1 ) {\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n element.wptbMovingMode == undefined;\n }\n }\n let wptbContainer = document.querySelector( '.wptb-container' );\n wptbContainer.onscroll = function() {\n wptbDropHandle.style.display = 'none';\n wptbDropBorderMarker.style.display = 'none';\n }\n } else {\n wptbDropHandle = document.getElementsByClassName( 'wptb-drop-handle' )[0];\n wptbDropBorderMarker = document.getElementsByClassName( 'wptb-drop-border-marker' )[0];\n }\n if( thisElem && thisElem.nodeName.toLowerCase() == 'td' && \n thisElem.getElementsByClassName( 'wptb-ph-element' ).length != 0 ) {\n return;\n }\n \n let thisRow;\n if ( thisElem.localName == 'td' ) {\n thisRow = thisElem.parentNode;\n } else if ( thisElem.localName == 'div' && thisElem.classList.contains( 'wptb-ph-element' ) ) {\n thisRow = thisElem.parentNode.parentNode;\n }\n if( thisRow.classList.contains( 'wptb-table-head' ) ) {\n let indics = e.dataTransfer.types;\n let notDragEnter = false;\n for ( let i = 0; i < indics.length; i++ ) {\n let infArr = indics[i].match( /wptbelindic-([a-z]+)/i );\n if ( infArr && infArr[1] != 'text' ) {\n notDragEnter = true;\n break;\n }\n }\n if( notDragEnter ) {\n return;\n }\n }\n \n wptbDropHandle.style.width = thisElem.offsetWidth + 'px';\n let height = thisElem.offsetHeight,\n coordinatesElement = thisElem.getBoundingClientRect(),\n left = parseFloat( coordinatesElement.left ),\n top;\n wptbDropHandle.style.left = left + 'px';\n \n if( e.dataTransfer.types.indexOf( 'wptb-moving-mode' ) != -1 ) {\n let elementDrag = document.getElementsByClassName( 'wptb-moving-mode' )[0];\n if( thisElem == elementDrag ) {\n wptbDropHandle.classList.add('wptb-moving-into-same-elem');\n wptbDropBorderMarker.classList.add('wptb-moving-into-same-elem');\n } else {\n wptbDropHandle.classList.remove('wptb-moving-into-same-elem');\n wptbDropBorderMarker.classList.remove('wptb-moving-into-same-elem');\n }\n }\n \n wptbDropHandle.getDOMParentElement = function() {\n return thisElem;\n }\n \n wptbDropHandle.style.display = 'block';\n wptbDropBorderMarker.style.display = 'block';\n if( thisElem.nodeName.toLowerCase() != 'td' ) {\n let y = e.offsetY==undefined?e.layerY:e.offsetY;\n top = parseFloat( coordinatesElement.top ) - parseFloat( 11 );\n wptbDropHandle.dataset.text = 'Above Element';\n if ( y > height/2 ) {\n top = parseFloat( coordinatesElement.top ) + height - 1;\n wptbDropHandle.dataset.text = 'Below Element';\n }\n } else {\n wptbDropHandle.dataset.text = 'Drop Here';\n top = parseFloat( coordinatesElement.top ) + height/2 - 5;\n }\n wptbDropHandle.style.top = top + 'px';\n\n wptbDropBorderMarker.style.top = coordinatesElement.top + 'px';\n wptbDropBorderMarker.style.left = coordinatesElement.left + 'px';\n\n wptbDropBorderMarkerTop = wptbDropBorderMarker.querySelector( '.wptb-drop-border-marker-top' );\n wptbDropBorderMarkerTop.style.width = ( parseFloat( thisElem.offsetWidth ) - parseFloat( 1 ) ) + 'px';\n\n wptbDropBorderMarkerRight = wptbDropBorderMarker.querySelector( '.wptb-drop-border-marker-right' );\n wptbDropBorderMarkerRight.style.height = ( parseFloat( coordinatesElement.bottom ) - parseFloat( coordinatesElement.top ) - 1 ) + 'px';\n wptbDropBorderMarkerRight.style.left = wptbDropBorderMarkerTop.style.width;\n\n wptbDropBorderMarkerBottom = wptbDropBorderMarker.querySelector( '.wptb-drop-border-marker-bottom' );\n wptbDropBorderMarkerBottom.style.width = wptbDropBorderMarkerTop.style.width;\n wptbDropBorderMarkerBottom.style.top = wptbDropBorderMarkerRight.style.height;\n\n wptbDropBorderMarkerLeft = wptbDropBorderMarker.querySelector( '.wptb-drop-border-marker-left' );\n wptbDropBorderMarkerLeft.style.height = wptbDropBorderMarkerRight.style.height;\n}","var ElementCounters = function () {\n\n\tvar priv = [];\n\tpriv['text'] = 0;\n\tpriv['image'] = 0;\n\tpriv['list'] = 0;\n\tpriv['button'] = 0;\n\n\tthis.increment = function (key) {\n\t\tif (!(key in priv)) {\n\t\t\treturn;\n\t\t}\n\t\tpriv[key]++;\n\t}\n\n\tthis.nextIndex = function (key) {\n\t\tif (!(key in priv)) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn priv[key] + 1;\n\t}\n\n\treturn this;\n\n};","var WPTB_ElementObject = function ( data ) {\n let DOMElement, kindIndexProt, copy;\n if( ! data.elemProt ) {\n DOMElement = document.createElement('div'),\n kindIndexProt = undefined,\n copy = false;\n DOMElement.classList.add( 'wptb-' + data.kind + '-container', 'wptb-ph-element', 'wptb-item-javascript-indic' );\n \n let wpTemplateId = 'wptb-' + data.kind + '-content';\n let template = wp.template( wpTemplateId );\n data.node = DOMElement;\n let itemHtml = template( data );\n\n itemHtml = itemHtml.replace(/\\r|\\n|\\t/g, '').trim();\n DOMElement.innerHTML = itemHtml;\n } else {\n DOMElement = data.elemProt.cloneNode( true );\n DOMElement.classList.remove( 'wptb-directlyhovered' );\n let wptbElementMutch = data.elemProt.className.match( /wptb-element-((.+-)\\d+)/i );\n if ( wptbElementMutch && Array.isArray( wptbElementMutch ) ) {\n kindIndexProt = wptbElementMutch[1];\n };\n copy = true;\n \n if( data.tinyMceClear ) {\n DOMElement = WPTB_Helper.elementClearFromTinyMce( DOMElement );\n }\n }\n \n let inElems = DOMElement.querySelectorAll( '.wptb-in-element' );\n if( inElems.length > 0 ) {\n for ( let i = 0; i < inElems.length; i++ ) {\n let inElemObj = {};\n inElemObj.getDOMElement = function() {\n return inElems[i];\n }\n \n applyGenericItemSettings( inElemObj );\n }\n }\n \n window.addEventListener( 'item:onmouseenter', function( event ) {\n //console.log( event );\n }, false);\n \n \n this.kind = data.kind;\n this.getDOMElement = function () {\n return DOMElement;\n };\n \n applyGenericItemSettings( this, kindIndexProt, copy );\n return this;\n}\n\n\n","var WPTB_ElementOptions = function ( element, index, kindIndexProt ) {\n\n var node = element.getDOMElement(), elemIdClass;\n\n node.onclick = function () {\n var children = document.getElementById(\"element-options-group\").childNodes;\n for ( let i = 0; i < children.length; i++) {\n if (children[i].style)\n children[i].style.display = 'none';\n }\n \n var infArr = this.className.match( /wptb-element-((.+-)\\d+)/i );\n // get controls config for this item\n let wptbContrlStacksConfigId = 'wptb-' + element.kind + '-control-stack';\n let tmplControlsConfig = wp.template( wptbContrlStacksConfigId );\n let data = {\n container: '.' + infArr[0]\n };\n let jsonControlsConfigJson = tmplControlsConfig( data );\n let jsonControlsConfig = JSON.parse( jsonControlsConfigJson );\n\n // create a container for inserting controls of this item\n let wptbElementOptionsContainer = document.createElement( 'div' );\n wptbElementOptionsContainer.classList.add( 'wptb-element-options', 'wptb-options-' + infArr[1] );\n\n // clear elements from options group\n //document.getElementById( 'element-options-group' ).innerHTML = '';\n let elementOptionsGroup = document.getElementById( 'element-options-group' );\n let elementOptionsGroupChildren = elementOptionsGroup.children;\n for( let i = 0; i < elementOptionsGroupChildren.length; i++ ) {\n let regularText = new RegExp( 'wptb-options-' + element.kind + '-(\\\\d+)', \"i\" );\n let elem = elementOptionsGroupChildren[i].className.match( regularText );\n if( elem ) {\n elementOptionsGroup.removeChild( elementOptionsGroupChildren[i] );\n }\n }\n\n // hide wptb-elements-container and wptb-settings-section\n document.getElementsByClassName('wptb-elements-container')[0].style.display = 'none';\n document.getElementsByClassName('wptb-settings-section')[0].style.display = 'none';\n\n // show element-options-group \n document.getElementById(\"element-options-group\").style.display = 'block';\n\n // insert created container into element-option-group tag\n document.getElementById( 'element-options-group' ).appendChild( wptbElementOptionsContainer );\n\n // show created container\n wptbElementOptionsContainer.style.display = 'block';\n\n // array for save all scrips for each controls\n let controlScriptsArr = [];\n\n // array for keep \"appear depend on\" parametrs\n let controlAppearDependOn = [];\n\n // create controls\n let i = 0;\n Object.keys( jsonControlsConfig ).forEach( function( key ) {\n let data = jsonControlsConfig[key];\n data.controlKey = key;\n\n // get necessary wp js template\n let tmplControlTemplate = wp.template( 'wptb-' + data.type + '-control' );\n\n data.elemContainer = infArr[0];\n data.elementControlTargetUnicClass = 'wptb-el-' + infArr[1] + '-' + data.controlKey;\n let controlTemplate = tmplControlTemplate( data );\n\n if( 'appearDependOn' in data ) {\n if( Array.isArray( data.appearDependOn ) ) {\n controlAppearDependOn.push( [data.appearDependOn, data.elementControlTargetUnicClass] );\n }\n }\n\n //console.log( controlTemplate );\n\n let wptbElementOptionContainer = document.createElement( 'div' );\n wptbElementOptionContainer.classList.add( 'wptb-element-option', 'wptb-settings-items' );\n\n if( data.customClassForContainer ) {\n wptbElementOptionContainer.classList.add( data.customClassForContainer );\n }\n\n if( data.containerAdditionalStyles ) {\n wptbElementOptionContainer.setAttribute( 'style', data.containerAdditionalStyles );\n }\n\n wptbElementOptionContainer.innerHTML = controlTemplate;\n\n wptbElementOptionsContainer.appendChild( wptbElementOptionContainer );\n\n let helperJavascriptElem = wptbElementOptionContainer.getElementsByTagName( 'wptb-template-script' );\n if( helperJavascriptElem.length > 0 ) {\n helperJavascriptElem = helperJavascriptElem[0];\n let helperJavascriptCode = helperJavascriptElem.innerText;\n wptbElementOptionContainer.removeChild( helperJavascriptElem );\n let script = document.createElement( 'script' );\n script.setAttribute( 'type', 'text/javascript' );\n script.innerHTML = helperJavascriptCode.replace(/\\r|\\n|\\t/g, '').trim();\n controlScriptsArr.push( script );\n }\n\n i++;\n });\n\n // run the scripts of controls\n if( controlScriptsArr.length > 0 ) {\n for( let i = 0; i < controlScriptsArr.length; i++ ) {\n wptbElementOptionsContainer.appendChild( controlScriptsArr[i] );\n }\n }\n\n // run appearDependOn function\n for ( let i = 0; i < controlAppearDependOn.length; i++ ) {\n WPTB_Helper.appearDependOn( controlAppearDependOn[i][0], controlAppearDependOn[i][1] );\n }\n\n WPTB_Helper.wptbDocumentEventGenerate( 'controlPanel:added:leftPanel' );\n };\n};","var WPTB_Helper = {\n hexToRgb: function( hex ) {\n var result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec( hex );\n return result ? 'rgb(' + parseInt( result[1], 16 ) + ',' + parseInt( result[2], 16 ) + ',' + parseInt( result[3], 16 ) + ')' : null;\n },\n rgbToHex: function ( rgb ) {\n var rgb = rgb.match( /^rgba?[\\s+]?\\([\\s+]?(\\d+)[\\s+]?,[\\s+]?(\\d+)[\\s+]?,[\\s+]?(\\d+)[\\s+]?/i );\n\n return ( rgb && rgb.length === 4 ) ? \"#\" +\n ( \"0\" + parseInt( rgb[1],10 ).toString( 16 )).slice( -2 ) +\n ( \"0\" + parseInt( rgb[2],10 ).toString( 16 )).slice( -2 ) +\n ( \"0\" + parseInt( rgb[3],10 ).toString( 16 )).slice( -2 ) : '';\n },\n getElementIcon: function ( icon_directory ) {\n let hostName = location.protocol + '//' + location.hostname;\n let img = document.createElement( 'img' );\n img.src = icon_directory;\n return img;\n },\n elementDragEndClear: function() {\n let wptbMovingMode = document.getElementsByClassName( 'wptb-moving-mode' );\n if ( wptbMovingMode.length > 0 ) {\n for( let i = 0; i < wptbMovingMode.length; i++ ) {\n wptbMovingMode[i].classList.remove( 'wptb-moving-mode' );\n }\n }\n\n let wptbDropHandles = document.getElementsByClassName( 'wptb-drop-handle' );\n if ( wptbDropHandles.length > 0 ) {\n for( let i = 0; i < wptbDropHandles.length; i++ ) {\n wptbDropHandles[i].style.display = 'none';\n }\n }\n\n let wptbDropBorderMarkers = document.getElementsByClassName( 'wptb-drop-border-marker' );\n if ( wptbDropBorderMarkers.length > 0 ) {\n for( let i = 0; i < wptbDropBorderMarkers.length; i++ ) {\n wptbDropBorderMarkers[i].style.display = 'none';\n }\n }\n },\n linkHttpCheckChange: function( link ) {\n if ( link ) {\n if ( link.indexOf( 'http://' ) == -1 && link.indexOf( 'https://' ) == -1 ) {\n let linkArr = link.split( '/' ),\n linkClean;\n if ( Array.isArray( linkArr ) && linkArr.length > 0 ) {\n linkClean = linkArr[linkArr.length - 1];\n }\n return document.location.protocol + '//' + linkClean;\n } else { \n return link;\n }\n } else {\n return '';\n }\n },\n dataTitleColumnSet: function( table ) {\n let rows = table.rows,\n rowHead = rows[0];\n let computedStyleRowHead = getComputedStyle(rowHead);\n \n let rowHeadChildren = rowHead.children;\n let contentsForHeader = {};\n for( let i = 0; i < rowHeadChildren.length; i++ ) {\n let tdElements = rowHeadChildren[i].children;\n for( let j = 0; j < tdElements.length; j++ ) {\n let element = tdElements[j];\n if( element.classList.contains( 'wptb-ph-element' ) ) {\n let infArr = element.className.match( /wptb-element-(.+)-(\\d+)/i );\n if( infArr[1] == 'text' ) {\n let p = element.querySelector( 'p' ),\n textContent = p.textContent,\n textAlign = p.style.textAlign;\n contentsForHeader[rowHeadChildren[i].dataset.xIndex] = [textContent, element.style.fontSize, \n element.style.color, computedStyleRowHead.backgroundColor, textAlign];\n break;\n }\n }\n }\n if( ! contentsForHeader[rowHeadChildren[i].dataset.xIndex] ) {\n contentsForHeader[rowHeadChildren[i].dataset.xIndex] = ['', '', \n '', computedStyleRowHead.backgroundColor, ''];\n }\n }\n for ( let i = 1; i < rows.length; i++ ) {\n let thisRow = rows[i],\n thisRowChildren = thisRow.children;\n for( let j = 0; j < thisRowChildren.length; j++ ) {\n if ( contentsForHeader[thisRowChildren[j].dataset.xIndex] ) {\n thisRowChildren[j].dataset.wptbTitleColumn = contentsForHeader[thisRowChildren[j].dataset.xIndex][0];\n thisRowChildren[j].dataset.wptbTitleColumnFontSize = contentsForHeader[thisRowChildren[j].dataset.xIndex][1];\n thisRowChildren[j].dataset.wptbTitleColumnColor = contentsForHeader[thisRowChildren[j].dataset.xIndex][2];\n thisRowChildren[j].dataset.wptbTitleBackgroundColor = contentsForHeader[thisRowChildren[j].dataset.xIndex][3];\n thisRowChildren[j].dataset.wptbTitleAlign = contentsForHeader[thisRowChildren[j].dataset.xIndex][4];\n } else {\n thisRowChildren[j].dataset.wptbTitleColumn = '';\n thisRowChildren[j].dataset.wptbTitleColumnFontSize = '';\n thisRowChildren[j].dataset.wptbTitleColumnColor = '';\n thisRowChildren[j].dataset.wptbTitleBackgroundColor = '';\n thisRowChildren[j].dataset.wptbTitleAlign = '';\n }\n }\n }\n },\n findAncestor: function(el, cls) {\n while ((el = el.parentElement) && !el.classList.contains(cls));\n return el;\n },\n getSelectionText: function() {\n var txt = '';\n if (txt = window.getSelection) {\n txt = window.getSelection().toString();\n } else {\n txt = document.selection.createRange().text;\n }\n return txt;\n },\n settingsPanelClear: function() {\n document.getElementById( 'wptb-adaptive-table-checkbox' ).checked = false;\n document.getElementById( 'wptb-top-row-as-header' ).checked = false;\n document.getElementById( 'wptb-table-border-slider' ).value = 0;\n document.getElementById( 'wptb-table-border-number' ).value = 0;\n document.getElementById( 'wptb-inner-border-check' ).checked = false;\n document.getElementById( 'wptb-apply-inner-border' ).classList.remove( 'visible' );\n document.getElementById( 'wptb-table-inner-border-slider' ).value = 1;\n document.getElementById( 'wptb-table-inner-border-number' ).value = 1;\n \n WPTB_Helper.wpColorPickerClear( 'wptb-table-border-color', true );\n \n WPTB_Helper.wpColorPickerClear( 'wptb-table-header-bg', true );\n \n WPTB_Helper.wpColorPickerClear( 'wptb-even-row-bg', true );\n \n WPTB_Helper.wpColorPickerClear( 'wptb-odd-row-bg', true );\n \n document.getElementById( 'wptb-table-cell-slider' ).value = 15;\n document.getElementById( 'wptb-table-cell-number' ).value = 15;\n },\n elementOptionsPanelClear: function() {\n let elementOptionsGroup = document.getElementById( 'element-options-group' );\n if( elementOptionsGroup ) {\n elementOptionsGroup.innerHTML = '';\n }\n },\n wpColorPickerCheckChangeForTableStateSaving: function( event ) {\n if( event.originalEvent.type == 'external' ) {\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n } else {\n let wpPickerContainer = WPTB_Helper.findAncestor( event.target, 'wp-picker-container' );\n if( wpPickerContainer ) {\n if( event.originalEvent.type == 'square' || event.originalEvent.type == 'strip' ) {\n let body = document.getElementsByTagName( 'body' )[0];\n body.removeEventListener( 'mouseup', WPTB_Helper.irisStripMouseUpStateSaveManager, false );\n body.addEventListener( 'mouseup', WPTB_Helper.irisStripMouseUpStateSaveManager, false );\n }\n }\n }\n },\n irisStripMouseUpStateSaveManager: function() {\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n \n let body = document.getElementsByTagName( 'body' )[0];\n body.removeEventListener( 'mouseup', WPTB_Helper.irisStripMouseUpStateSaveManager, false );\n },\n wpColorPickerClear: function( attribute, isId ) {\n let input;\n if( isId ) {\n input = [document.getElementById( attribute )];\n input.length = 1;\n } else {\n input = document.getElementsByClassName( attribute );\n }\n for( let i = 0; i < input.length; i++ ) {\n let wpPickerContainer = WPTB_Helper.findAncestor( input[i], 'wp-picker-container' );\n if( wpPickerContainer ) {\n let parent = wpPickerContainer.parentNode;\n parent.removeChild( wpPickerContainer );\n let newInput = document.createElement( 'input' );\n if( isId ) {\n newInput.setAttribute( 'id', attribute );\n } else {\n newInput.classList.add( 'wptb-element-property', attribute );\n }\n newInput.value = \"\";\n parent.appendChild( newInput );\n }\n }\n },\n detectMode: function() {\n var url = window.location.href,\n regex = new RegExp('[?&]table(=([^&#]*)|&|#|$)'),\n results = regex.exec(url);\n if (!results) return false;\n if (!results[2]) return '';\n return decodeURIComponent(results[2].replace(/\\+/g, ' '));\n },\n getColumnWidth: function( table, cell ) {\n let xIndex = cell.dataset.xIndex;\n let xIndexes = table.querySelectorAll( '[data-x-index=\"' + xIndex + '\"]' );\n let cellWidth = cell.getCellDimensions().width;\n for( let i = 0; i < xIndexes.length; i++ ) {\n if( cellWidth > xIndexes[i].getCellDimensions().width ) {\n cellWidth = xIndexes[i].getCellDimensions().width;\n }\n }\n return cellWidth;\n },\n getRowHeight: function( table, cell ) {\n let yIndex = cell.dataset.yIndex;\n let yIndexes = table.querySelectorAll( '[data-y-index=\"' + yIndex + '\"]' );\n let cellHeight = cell.getCellDimensions().height;\n for( let i = 0; i < yIndexes.length; i++ ) {\n if( cellHeight > yIndexes[i].getCellDimensions().height ) {\n cellHeight = yIndexes[i].getCellDimensions().height;\n }\n }\n return cellHeight;\n },\n newElementProxy: function( el ) {\n if( el ) {\n let data = {kind: el};\n return new WPTB_ElementObject( data );\n }\n },\n wpColorPickerChange: function( event, ui ) {\n let uiColor;\n if( ui ) {\n uiColor = ui.color.toString();\n } else {\n uiColor = '';\n }\n \n let parent = WPTB_Helper.findAncestor( event.target, 'wp-picker-input-wrap' ).getElementsByClassName( 'wptb-color-picker' )[0], classe, type, ps, number;\n classe = parent.dataset.element.match(/wptb-options-(.+)-(\\d+)/i);\n type = classe[1];\n number = classe[2];\n let affectedEl = document.getElementsByClassName( 'wptb-element-' + type + '-' + number )[0];\n if ( type == 'button' ) {\n if ( parent.dataset.type == 'button-text-color' ) {\n affectedEl.getElementsByClassName( 'wptb-button' )[0].style.color = uiColor;\n } else {\n affectedEl.getElementsByClassName( 'wptb-button' )[0].style.backgroundColor = uiColor;\n }\n } else if( type == 'list' ) {\n let ps = affectedEl.querySelectorAll( 'p' );\n if( ps.length > 0 ) {\n for ( let i = 0; i < ps.length; i++ ) {\n ps[i].style.color = uiColor;\n }\n }\n } else if( type == 'star_rating' ) {\n if ( parent.dataset.type == 'star-color' ) {\n let ratingStar = affectedEl.querySelectorAll('li');\n for( let i = 0; i < ratingStar.length; i++ ) {\n let span = ratingStar[i].getElementsByTagName( 'span' );\n for( let j = 0; j < span.length; j++ ) {\n span[j].style.fill = uiColor;\n }\n }\n } else if( parent.dataset.type == 'numeral-rating-color' ) {\n let wptbTextMessageSize = affectedEl.querySelector('.wptb-number-rating');\n wptbTextMessageSize.style.color = uiColor;\n }\n\n } else {\n affectedEl.style.color = uiColor;\n }\n },\n numberImputSize: function ( wptbNumberInputs, maxCount, maxValue ) {\n wptbNumberInputs.onkeydown = function() {\n let thisValue = this.value;\n thisValue = String( thisValue );\n if ( thisValue[0] == 0 ) {\n this.value = \"\";\n } else {\n thisValue = thisValue.substring( 0, maxCount );\n this.value = thisValue;\n }\n }\n wptbNumberInputs.onkeyup = function( ) {\n let thisValue = this.value;\n if ( parseInt( thisValue, 10 ) > parseInt( maxValue, 10 ) ) {\n this.value = maxValue;\n }\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n },\n ucfirst: function( str ) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n },\n wptbDocumentEventGenerate: function( eventName, element, details ) {\n if( eventName && element ) {\n if( ! details ) {\n details = true;\n }\n let event = new CustomEvent( eventName, { detail: details, bubbles: true } );\n element.dispatchEvent( event );\n }\n },\n // run script for the pointed element\n elementStartScript: function( element ) {\n //let script = element.getElementsByTagName( 'script' );\n let infArr = element.className.match(/wptb-element-(.+)-(\\d+)/i);\n if( infArr && Array.isArray( infArr ) ) {\n let kind = infArr[1];\n if( kind ) {\n// let wpTemplateId = 'wptb-' + kind + '-script';\n// let template = wp.template( wpTemplateId );\n// let data = {elemClass: infArr[0]};\n// let elementScriptText = template( data );\n// elementScriptText = elementScriptText.replace(/\\r|\\n|\\t/g, '').trim();\n//\n// let scriptNew = document.createElement( 'script' );\n// scriptNew.setAttribute( 'type', 'text/javascript' );\n// scriptNew.innerHTML = elementScriptText;\n// element.parentNode.appendChild( scriptNew );\n \n// element.parentNode.removeChild( scriptNew );\n if( kind in WPTB_ElementsScriptsLauncher ) {\n WPTB_ElementsScriptsLauncher[kind]( element );\n }\n }\n }\n },\n // deletes event handlers from the pointed option element and from all his daughter elements\n deleteEventHandlers: function( element ) {\n if( element ) {\n jQuery( element ).off();\n let elementChildren = element.children;\n if( elementChildren ) {\n for ( let i = 0; i < elementChildren.length; i++ ) {\n WPTB_Helper.deleteEventHandlers( elementChildren[i] );\n }\n }\n } else {\n return;\n }\n },\n // replace all occurrences in a string\n replaceAll: function( string, search, replace ){\n return string.split( search ).join( replace );\n },\n // clears code from TinyMCE attributes\n elementClearFromTinyMce: function( element ) {\n let mceContentBodys = element.querySelectorAll( '.mce-content-body' );\n if( mceContentBodys.length > 0 ) {\n for ( let k = 0; k < mceContentBodys.length; k++ ) {\n mceContentBodys[k].classList.remove( 'mce-content-body' );\n }\n }\n\n let dataMceStyle = element.querySelectorAll( '[data-mce-style]' );\n if ( dataMceStyle.length > 0 ) {\n for ( let k = 0; k < dataMceStyle.length; k++ ) {\n dataMceStyle[k].removeAttribute( 'data-mce-style' );\n }\n }\n \n let mceEditFocus = element.querySelectorAll( '.mce-edit-focus' );\n if( mceEditFocus.length > 0 ) {\n for ( let k = 0; k < mceEditFocus.length; k++ ) {\n mceEditFocus[k].classList.remove( 'mce-edit-focus' );\n }\n }\n\n let contentEditable = element.querySelectorAll( '[contenteditable]' );\n if ( contentEditable.length > 0 ) {\n for ( let k = 0; k < contentEditable.length; k++ ) {\n contentEditable[k].removeAttribute( 'contenteditable' );\n }\n }\n\n let spellCheck = element.querySelectorAll( '[spellcheck]' );\n if ( spellCheck.length > 0 ) {\n for ( let k = 0; k < spellCheck.length; k++ ) {\n spellCheck[k].removeAttribute( 'spellcheck' );\n }\n }\n\n let mceIds = element.querySelectorAll( '[id^=mce_]' );\n if ( mceIds.length > 0 ) {\n for ( let k = 0; k < mceIds.length; k++ ) {\n mceIds[k].removeAttribute( 'id' );\n }\n }\n \n return element;\n },\n elementOptionContainerCustomClassSet: function( targetInput, customClassForContainer ) {\n if( targetInput && customClassForContainer ) {\n let containerElement = WPTB_Helper.findAncestor( targetInput, 'wptb-element-option' );\n if( containerElement ) {\n containerElement.classList.add( customClassForContainer );\n }\n }\n },\n elementOptionContainerAdditionalStyles: function( targetInput, containerAdditionalStyles ) {\n if( targetInput && containerAdditionalStyles ) {\n let containerElement = WPTB_Helper.findAncestor( targetInput, 'wptb-element-option' );\n let containerStylesArrOne = containerAdditionalStyles.split( ';' );\n\n if( containerElement && containerStylesArrOne ) {\n function containerStylesSet( containerStyleStr, containerElement ) {\n if( containerStyleStr ) {\n containerStyleStrArr = containerStyleStr.split( ':' );\n\n if( containerStyleStrArr && Array.isArray( containerStyleStrArr ) ) {\n containerElement.style[containerStyleStrArr[0]] = containerStyleStrArr[1];\n }\n }\n }\n if( containerStylesArrOne && Array.isArray( containerStylesArrOne ) ) {\n for( let i = 0; i < containerStylesArrOne.length; i++ ) {\n console.log( containerStylesArrOne );\n if( containerStylesArrOne[i] ) {\n containerStylesSet( containerStylesArrOne[i], containerElement );\n }\n }\n } else {\n containerStylesSet( containerStylesArrOne, containerElement );\n }\n }\n }\n },\n // function which set handler for event of changes of control\n controlsInclude: function( element, functionHandler ) {\n if( element && typeof element === 'object' && typeof functionHandler === 'function' ) {\n element.addEventListener( 'click', function() {\n let infArr = element.className.match( /wptb-element-(.+)-(\\d+)/i ),\n elementKind;\n\n if( infArr && Array.isArray( infArr ) ) {\n elementKind = infArr[1];\n }\n\n if( ! element.hasOwnProperty( 'сontrolsConnectIndic' ) || element.сontrolsConnectIndic !== true && elementKind ) {\n let elementsSettingsTemplateJs = document.getElementsByClassName( 'wptb-element-datas' );\n if( elementsSettingsTemplateJs.length > 0 ) {\n elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];\n\n let elementsSettings = elementsSettingsTemplateJs.innerHTML;\n let controlClassesNames = [];\n if( elementsSettings ) {\n elementsSettings = JSON.parse( elementsSettings );\n if( elementsSettings && typeof elementsSettings === 'object' ) {\n if( 'tmpl-wptb-element-datas-' + infArr[1] + '-' + infArr[2] in elementsSettings ) {\n let elementSettings = elementsSettings['tmpl-wptb-element-datas-' + infArr[1] + '-' + infArr[2]];\n if( elementSettings && typeof elementSettings === 'object' ) {\n Object.keys( elementSettings ).forEach( function( key ) {\n let regularText = new RegExp( 'data-wptb-el-' + elementKind + '-(\\\\d+)-(.+)', \"i\" );\n let keyInfArr = key.match( regularText );\n if( keyInfArr && Array.isArray( keyInfArr ) ) {\n let controlClass = key.replace( 'data-', '' );\n controlClassesNames.push( [controlClass, keyInfArr[2]] );\n }\n });\n }\n }\n }\n }\n\n for( let i = 0; i < controlClassesNames.length; i++ ) {\n element.addEventListener( 'wptb-control:' + controlClassesNames[i][0], function() {\n let controls = {};\n let controlName = controlClassesNames[i][1];\n let control = document.getElementsByClassName( controlClassesNames[i][0] );\n if( control.length > 0 && controlName ) {\n let targetControlValue = WPTB_Helper.targetControlValueGet( control );\n\n controls[controlName] = targetControlValue;\n }\n\n functionHandler( controls, element );\n }, false );\n\n element.сontrolsConnectIndic = true;\n }\n }\n }\n }, false );\n }\n },\n oneControlInclude: function( element, functionHandler, controlName ) {\n if( element && typeof element === 'object' && typeof functionHandler === 'function' && typeof controlName === 'string' ) {\n let infArr = element.className.match( /wptb-element-((.+-)\\d+)/i ),\n elementKind;\n \n if( infArr && Array.isArray( infArr ) ) {\n elementKind = infArr[1].split( '-' )[0];\n \n let wptbContrlStacksConfigId = 'wptb-' + elementKind + '-control-stack';\n let tmplControlsConfig = wp.template( wptbContrlStacksConfigId );\n let data = {\n container: '.' + infArr[0]\n };\n let jsonControlsConfigJson = tmplControlsConfig( data );\n let jsonControlsConfig = JSON.parse( jsonControlsConfigJson );\n \n if( jsonControlsConfig && typeof jsonControlsConfig === 'object' && jsonControlsConfig.hasOwnProperty( controlName ) ) {\n let controlClassName = 'wptb-el-' + infArr[1] + '-' + controlName;\n \n element.addEventListener( 'wptb-control:' + controlClassName, function( event ) {\n let control = document.getElementsByClassName( controlClassName );\n if( control.length > 0 ) {\n let targetControlValue = WPTB_Helper.targetControlValueGet( control );\n\n functionHandler( targetControlValue, element );\n }\n }, false );\n }\n }\n } else {\n return false;\n }\n },\n //\n innerElementCopyIncludeHandler: function( element, functionHandler ) {\n if( element && typeof element === 'object' && typeof functionHandler === 'function' ) {\n element.addEventListener( 'wptb-inner-element:copy', function( event ) {\n let innerElement = event.detail;\n if( innerElement ) {\n WPTB_Helper.elementClearFromTinyMce( innerElement );\n functionHandler( innerElement, element );\n }\n }, false );\n }\n },\n //\n appearDependOn: function( dependOn, targetControlElementClass ) {\n if( Array.isArray( dependOn ) ) {\n let dependOnControlName = dependOn[0];\n let infArr = targetControlElementClass.match( /wptb-el-((.+-)\\d+)-(.+)/i );\n \n if( infArr && Array.isArray( infArr ) ) {\n let controlName = infArr[3];\n\n let dependOnControlElementClass = targetControlElementClass.replace( controlName, dependOnControlName );\n\n let dependOnControlElement = document.getElementsByClassName( dependOnControlElementClass );\n\n if( dependOnControlElement.length > 0 ) {\n dependOnControlElement = dependOnControlElement[0];\n let targetControlElement = document.getElementsByClassName( targetControlElementClass );\n if( targetControlElement.length > 0 ) {\n targetControlElement = targetControlElement[0];\n let controlContainerElem = WPTB_Helper.findAncestor( targetControlElement, 'wptb-element-option' );\n\n if( controlContainerElem ) {\n function showHideDependOnControlElement( dependOnControlElementKind ) {\n \n let elementsSettingsTemplateJs = document.getElementsByClassName( 'wptb-element-datas' );\n if( elementsSettingsTemplateJs.length > 0 ) {\n elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];\n\n let elementsSettings = elementsSettingsTemplateJs.innerHTML;\n if( elementsSettings ) {\n elementsSettings = JSON.parse( elementsSettings );\n if( elementsSettings && typeof elementsSettings === 'object' && \n ( 'tmpl-wptb-element-datas-' + dependOnControlElementKind ) in elementsSettings ) {\n let elementSettings = elementsSettings['tmpl-wptb-element-datas-' + dependOnControlElementKind];\n if( elementSettings && typeof elementSettings === 'object' && \n ( 'data-wptb-el-' + dependOnControlElementKind + '-' + dependOnControlName ) in elementSettings ) {\n let elementSettingValue = elementSettings['data-wptb-el-' + dependOnControlElementKind + '-' + dependOnControlName];\n \n if( elementSettingValue ) {\n if( dependOn[1] && Array.isArray( dependOn[1] ) && \n ( dependOn[1].indexOf( elementSettingValue ) !== -1 ) ) {\n controlContainerElem.style.display = 'block';\n } else if( dependOn[2] && Array.isArray( dependOn[2] ) && \n ( dependOn[2].indexOf( elementSettingValue ) !== -1 ) ) {\n controlContainerElem.style.display = 'none';\n }\n }\n }\n }\n }\n }\n }\n\n showHideDependOnControlElement( infArr[1] );\n\n dependOnControlElement.addEventListener( 'change', function() {\n showHideDependOnControlElement( infArr[1] );\n }, false );\n }\n }\n }\n }\n }\n },\n //\n controlsStateManager: function ( targetControlClass, controlChangeIndic ) {\n let targetControls = document.getElementsByClassName( targetControlClass );\n if( targetControls.length > 0 ) {\n //targetControls = targetControls[0];\n \n let infArr = targetControlClass.match( /wptb-el-((.+-)\\d+)-(.+)/i );\n \n if( infArr && Array.isArray( infArr ) ) {\n let selectorElement = document.querySelector( '.wptb-element-' + infArr[1] );\n if( selectorElement ) {\n let elementsSettingsTemplatesJs;\n let elementSettings = {};\n let elementsSettings;\n elementsSettingsTemplatesJs = document.getElementsByClassName( 'wptb-element-datas' );\n if( elementsSettingsTemplatesJs.length == 0 || elementsSettingsTemplatesJs[0].innerHTML == '' ) {\n let targetControlValue = WPTB_Helper.targetControlValueGet( targetControls );\n elementSettings['data-' + targetControlClass] = targetControlValue;\n\n elementsSettings = {};\n elementsSettings['tmpl-wptb-element-datas-' + infArr[1]] = elementSettings;\n elementsSettings = JSON.stringify( elementsSettings );\n\n if( elementsSettingsTemplatesJs.length == 0 ) {\n elementsSettingsTemplatesJs = document.createElement( 'script' );\n elementsSettingsTemplatesJs.setAttribute( 'type', 'text/html' );\n elementsSettingsTemplatesJs.setAttribute( 'class', 'wptb-element-datas' );\n } else {\n elementsSettingsTemplatesJs = elementsSettingsTemplatesJs[0];\n }\n\n elementsSettingsTemplatesJs.innerHTML = elementsSettings;\n\n let body = document.getElementsByTagName('body')[0];\n body.appendChild( elementsSettingsTemplatesJs );\n } else {\n elementsSettingsTemplatesJs = elementsSettingsTemplatesJs[0];\n elementsSettings = elementsSettingsTemplatesJs.innerHTML;\n if( elementsSettings ) {\n elementsSettings = JSON.parse( elementsSettings );\n\n if( elementsSettings && typeof elementsSettings === 'object' ) {\n \n \n if( controlChangeIndic ) {\n let targetControlValue = WPTB_Helper.targetControlValueGet( targetControls );\n if( ! ( ( 'tmpl-wptb-element-datas-' + infArr[1] ) in elementsSettings ) || \n typeof elementsSettings['tmpl-wptb-element-datas-' + infArr[1]] !== 'object') {\n elementsSettings['tmpl-wptb-element-datas-' + infArr[1]] = {};\n }\n elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]['data-' + targetControlClass] = targetControlValue;\n elementsSettingsTemplatesJs.innerHTML = JSON.stringify( elementsSettings );\n } else if( ! ( ( ( 'tmpl-wptb-element-datas-' + infArr[1] ) in elementsSettings ) && \n typeof elementsSettings['tmpl-wptb-element-datas-' + infArr[1]] === 'object' && \n ( 'data-' + targetControlClass ) in elementsSettings['tmpl-wptb-element-datas-' + infArr[1]] ) ) {\n let targetControlValue = WPTB_Helper.targetControlValueGet( targetControls );\n if( ! ( ( 'tmpl-wptb-element-datas-' + infArr[1] ) in elementsSettings ) || \n typeof elementsSettings['tmpl-wptb-element-datas-' + infArr[1]] !== 'object') {\n elementsSettings['tmpl-wptb-element-datas-' + infArr[1]] = {};\n }\n elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]['data-' + targetControlClass] = targetControlValue;\n elementsSettingsTemplatesJs.innerHTML = JSON.stringify( elementsSettings );\n } else if( ( ( 'tmpl-wptb-element-datas-' + infArr[1] ) in elementsSettings ) && \n typeof elementsSettings['tmpl-wptb-element-datas-' + infArr[1]] === 'object' && \n ( 'data-' + targetControlClass ) in elementsSettings['tmpl-wptb-element-datas-' + infArr[1]] ) {\n for( let i = 0; i < targetControls.length; i++ ) {\n if( targetControls[i].type == 'checkbox' ) {\n let targetControlValue;\n if( targetControls[i].name ) {\n targetControlValue = elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]['data-' + targetControlClass][targetControls[i].name];\n } else {\n targetControlValue = elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]['data-' + targetControlClass];\n }\n \n if( targetControlValue == 'checked' ) {\n targetControls[i].checked = true;\n } else if( targetControlValue == 'unchecked' ) {\n targetControls[i].checked = false;\n }\n } else {\n targetControls[i].value = elementsSettings['tmpl-wptb-element-datas-' + infArr[1]]['data-' + targetControlClass];\n }\n }\n \n }\n }\n }\n }\n }\n }\n }\n },\n //\n targetControlValueGet: function( targetControls ) {\n let targetControlValue;\n for( let i = 0; i < targetControls.length; i++ ) {\n if( targetControls[i].type == 'checkbox' && targetControls[i].name ) {\n if( ! targetControlValue ) targetControlValue = {};\n if( targetControls[i].checked == true ) {\n targetControlValue[targetControls[i].name] = 'checked';\n } else {\n targetControlValue[targetControls[i].name] = 'unchecked';\n }\n } else if( targetControls[i].type == 'checkbox' ) {\n if( targetControls[i].checked == true ) {\n targetControlValue = 'checked';\n } else {\n targetControlValue = 'unchecked';\n }\n } else {\n targetControlValue = targetControls[i].value;\n }\n }\n return targetControlValue;\n },\n //\n elementControlsStateCopy: function( elementProt, copyElem ) {\n if( elementProt && copyElem ) {\n let infArrProt = elementProt.className.match( /wptb-element-((.+-)\\d+)/i );\n let infArrCopy = copyElem.className.match( /wptb-element-((.+-)\\d+)/i );\n if( infArrProt && Array.isArray( infArrProt ) &&\n infArrCopy && Array.isArray( infArrCopy )) {\n let elemProtKind = infArrProt[1];\n let elemCopyKind = infArrCopy[1];\n let elementsSettingsTemplateJs = document.getElementsByClassName( 'wptb-element-datas' );\n if( elementsSettingsTemplateJs.length > 0 ) {\n elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];\n \n let elementsSettings = elementsSettingsTemplateJs.innerHTML;\n if( elementsSettings ) {\n elementsSettings = JSON.parse( elementsSettings );\n \n if( elementsSettings && typeof elementsSettings === 'object' ) {\n let elementSettingsProt = elementsSettings['tmpl-wptb-element-datas-' + elemProtKind];\n if( elementSettingsProt && typeof elementSettingsProt === 'object' ) {\n let elementSettingsCopy = {};\n \n Object.keys( elementSettingsProt ).forEach( function( key ) {\n let elementSettingValue = elementSettingsProt[key];\n let elementSettingKeyCopy = key.replace( elemProtKind, elemCopyKind );\n elementSettingsCopy[elementSettingKeyCopy] = elementSettingValue;\n });\n \n if( Object.keys( elementSettingsCopy ).length > 0 ) {\n elementsSettings['tmpl-wptb-element-datas-' + elemCopyKind] = elementSettingsCopy;\n \n elementsSettings = JSON.stringify( elementsSettings );\n elementsSettingsTemplateJs.innerHTML = elementsSettings;\n }\n }\n }\n }\n }\n }\n }\n },\n //\n elementControlsStateDelete: function( element ) {\n let infArr = element.className.match( /wptb-element-(.+)-(\\d+)/i );\n let body = document.getElementsByTagName( 'body' )[0];\n let wptbElementDatas = body.getElementsByClassName( 'wptb-element-datas' );\n if( infArr && Array.isArray( infArr ) && wptbElementDatas.length > 0 ) {\n wptbElementDatas = wptbElementDatas[0];\n let elementsSettings = wptbElementDatas.innerHTML;\n if( elementsSettings ) {\n elementsSettings = JSON.parse( elementsSettings );\n if( elementsSettings && typeof elementsSettings === 'object' &&\n ( ( 'tmpl-wptb-element-datas-' + infArr[1] + '-' + infArr[2] ) in elementsSettings ) ) {\n delete elementsSettings['tmpl-wptb-element-datas-' + infArr[1] + '-' + infArr[2]];\n\n if( Object.keys( elementsSettings ).length == 0 ) {\n body.removeChild( wptbElementDatas );\n } else {\n elementsSettings = JSON.stringify( elementsSettings );\n wptbElementDatas.innerHTML = elementsSettings;\n }\n }\n }\n }\n }\n}\n","var WPTB_Initializer = function () {\n\n const MIN_COLUMNS = 1,\n MIN_ROWS = 1,\n MAX_COLUMNS = 30,\n MAX_ROWS = 30;\n\n var tableGenerator = document.body;\n columnsDecrementButton = tableGenerator.getElementsByClassName('wptb-input-number-decrement')[0],\n columnsIncrementButton = tableGenerator.getElementsByClassName('wptb-input-number-increment')[0],\n rowsDecrementButton = tableGenerator.getElementsByClassName('wptb-input-number-decrement')[1],\n rowsIncrementButton = tableGenerator.getElementsByClassName('wptb-input-number-increment')[1],\n columnsInput = document.getElementById('wptb-columns-number'),\n rowsInput = document.getElementById('wptb-rows-number');\n \n columnsDecrementButton.onclick = function () {\n if (columnsInput.value > MIN_COLUMNS) {\n columnsInput.value--;\n }\n };\n\n columnsIncrementButton.onclick = function () {\n if (columnsInput.value < MAX_COLUMNS) {\n columnsInput.value++;\n }\n };\n\n rowsDecrementButton.onclick = function () {\n if (rowsInput.value > MIN_ROWS) {\n rowsInput.value--;\n }\n };\n\n rowsIncrementButton.onclick = function () {\n if (rowsInput.value < MAX_ROWS) {\n rowsInput.value++;\n }\n };\n\n document.getElementById('wptb-generate-table').onclick = function () {\n var columns = document.getElementById('wptb-columns-number').value,\n rows = document.getElementById('wptb-rows-number').value;\n\n WPTB_Table(columns, rows);\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n\n};\n","var WPTB_LeftPanel = function () {\n\n var table = document.getElementsByClassName('wptb-preview-table')[0],\n wptbElementButtons = document.getElementsByClassName('wptb-element');\n \n function wptbTdBgColorSavedSet( inputId, trNumber ) {\n if ( trNumber > 3 ) return;\n if( table ) {\n let tableRows = table.getElementsByTagName('tr');\n if ( tableRows.length > trNumber ) {\n let trBackgroundColor = tableRows[trNumber].style.backgroundColor;\n var wptbEvenRowBg = document.getElementById(inputId);\n if ( wptbEvenRowBg && trBackgroundColor ) {\n wptbEvenRowBg.value = WPTB_Helper.rgbToHex( trBackgroundColor );\n }\n }\n }\n \n }\n \n wptbTdBgColorSavedSet( 'wptb-even-row-bg', 1 );\n jQuery('#wptb-even-row-bg').wpColorPicker({\n change: function ( event, ui ) {\n var tableRows = table.getElementsByTagName('tr');\n for ( let i = 1; i < tableRows.length; i += 2 ) {\n tableRows[i].style.backgroundColor = ui.color.toString();\n }\n WPTB_Helper.wpColorPickerCheckChangeForTableStateSaving( event );\n },\n clear: function(){\n var tableRows = table.getElementsByTagName('tr');\n for ( let i = 1; i < tableRows.length; i += 2 ) {\n tableRows[i].style.backgroundColor = '';\n let tds = tableRows[i].getElementsByTagName('td');\n for ( let j = 0; j < tds.length; j++ ) {\n tds[j].style.backgroundColor = '';\n }\n }\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n },\n\n });\n \n wptbTdBgColorSavedSet( 'wptb-odd-row-bg', 2 );\n jQuery('#wptb-odd-row-bg').wpColorPicker({\n change: function ( event, ui ) {\n var tableRows = table.getElementsByTagName('tr');\n for ( let i = 2; i < tableRows.length; i += 2 ) {\n tableRows[i].style.backgroundColor = ui.color.toString();\n }\n \n WPTB_Helper.wpColorPickerCheckChangeForTableStateSaving( event );\n },\n clear: function(){\n var tableRows = table.getElementsByTagName('tr');\n for ( let i = 2; i < tableRows.length; i += 2 ) {\n tableRows[i].style.backgroundColor = '';\n let tds = tableRows[i].getElementsByTagName( 'td' );\n for ( var j = 0; j < tds.length; j++ ) {\n tds[j].style.backgroundColor = '';\n }\n }\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n },\n });\n \n wptbTdBgColorSavedSet( 'wptb-table-header-bg', 0 );\n jQuery('#wptb-table-header-bg').wpColorPicker({\n change: function (event, ui) {\n var tableHeader = table.getElementsByTagName('tr')[0];\n tableHeader.style.backgroundColor = ui.color.toString();\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n },\n clear: function(){\n var tableHeader = table.getElementsByTagName('tr')[0];\n tableHeader.style.backgroundColor = '';\n let tds = tableHeader.getElementsByTagName('td');\n for (var j = 0; j < tds.length; j++) {\n tds[j].style.backgroundColor = '';\n }\n \n WPTB_Helper.wpColorPickerCheckChangeForTableStateSaving( event );\n },\n });\n \n function tableAdaptiveForMobile( table ) {\n let wptbAdaptiveTableCheckbox = document.getElementById( 'wptb-adaptive-table-checkbox' );\n if( table && table.dataset.wptbAdaptiveTable && table.dataset.wptbAdaptiveTable == \"1\" ) {\n wptbAdaptiveTableCheckbox.checked = true;\n } else {\n wptbAdaptiveTableCheckbox.checked = false;\n }\n }\n tableAdaptiveForMobile( table );\n \n function tableTopRowAsHeadSavedSet( table ) {\n let wptbTopRowAsHeader = document.getElementById( 'wptb-top-row-as-header' );\n \n if( table && table.classList.contains( 'wptb-table-preview-head' ) ) {\n wptbTopRowAsHeader.checked = true;\n } else {\n wptbTopRowAsHeader.checked = false;\n }\n }\n tableTopRowAsHeadSavedSet( table );\n \n function tableBorderColorWidthSavedSet() {\n let table = document.getElementsByClassName('wptb-preview-table');\n if ( table.length > 0 ) {\n let tableBorderColor = table[0].style.borderColor;\n if ( tableBorderColor ) {\n let tableBorderColorInput = document.getElementById( 'wptb-table-border-color' );\n if ( tableBorderColorInput ) {\n tableBorderColorInput.value = WPTB_Helper.rgbToHex( tableBorderColor );\n }\n }\n \n let tableBorderWidth = table[0].style.borderWidth;\n if ( tableBorderWidth ) {\n let wptbTableBorderWidthSlider = document.getElementById('wptb-table-border-slider'),\n wptbTableBorderWidthNumber = document.getElementById('wptb-table-border-number');\n \n if ( wptbTableBorderWidthSlider ) {\n wptbTableBorderWidthSlider.value = parseInt( tableBorderWidth );\n }\n if ( wptbTableBorderWidthNumber ) {\n wptbTableBorderWidthNumber.value = parseInt( tableBorderWidth );\n }\n }\n \n \n let tableTd = table[0].querySelector( 'td' );\n let applyInnerBorder = tableTd.style.borderWidth;\n if ( applyInnerBorder ) {\n let innerBorderCheckInput = document.getElementById( 'wptb-inner-border-check' );\n let wptbApplyInnerBorder = document.getElementById( 'wptb-apply-inner-border' );\n if ( applyInnerBorder && parseInt( applyInnerBorder ) > 0 ) {\n if ( innerBorderCheckInput ) {\n innerBorderCheckInput.checked = true;\n \n if ( wptbApplyInnerBorder ) {\n wptbApplyInnerBorder.classList.add( 'visible' );\n let wptbTableInnerBorderSlider = document.getElementById( 'wptb-table-inner-border-slider' );\n let wptbTableInnerBorderNumber = document.getElementById( 'wptb-table-inner-border-number' );\n wptbTableInnerBorderSlider.value = parseInt( applyInnerBorder );\n wptbTableInnerBorderNumber.value = parseInt( applyInnerBorder );\n }\n }\n } else {\n innerBorderCheckInput.checked = false;\n }\n }\n \n if ( ( tableBorderWidth && parseInt( tableBorderWidth ) > 0 ) || ( applyInnerBorder && parseInt( applyInnerBorder ) > 0 ) ) {\n document.getElementById( 'wptb-table-border-color-set-area' ).style.display = '';\n }\n }\n }\n \n tableBorderColorWidthSavedSet();\n\n jQuery('#wptb-table-border-color').wpColorPicker({\n change: function (event, ui) {\n var tableCells = table.getElementsByTagName('td');\n table.style.border = document.querySelector('#wptb-table-border-number').value + 'px solid ' + ui.color.toString();\n\n for (var i = 0; i < tableCells.length; i++) {\n let tableInnerborderNumber = document.querySelector('#wptb-table-inner-border-number').value;\n if ( document.getElementById('wptb-inner-border-check').checked ) {\n tableCells[i].style.border = ( tableInnerborderNumber != 0 ? tableInnerborderNumber : 1 ) + 'px solid ' + ui.color.toString();\n }\n }\n WPTB_Helper.wpColorPickerCheckChangeForTableStateSaving( event );\n },\n clear: function() {\n var tableCells = table.getElementsByTagName('td');\n table.style.borderColor = '';\n\n for (var i = 0; i < tableCells.length; i++) {\n tableCells[i].style.borderColor = '';\n }\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n });\n\n function addInnerBorderSize(value) {\n var tableCells = table.getElementsByTagName('td');\n for (var i = 0; i < tableCells.length; i++) {\n tableCells[i].style.borderWidth = document.querySelector('#wptb-table-inner-border-number').value + 'px';\n tableCells[i].style.borderStyle = 'solid';\n }\n }\n\n function addCellPadding(value) {\n var tableCells = table.getElementsByTagName('td');\n for (var i = 0; i < tableCells.length; i++) {\n tableCells[i].style.padding = value + 'px';\n }\n }\n\n function addInnerBorder( checked ) {\n var styles, color = document.querySelector('#wptb-table-border-color').value != undefined ?\n document.querySelector('#wptb-table-border-color').value : 'rgb(0,0,0)';\n if ( document.querySelector( '#wptb-table-inner-border-slider' ).value == 0 || document.querySelector( '#wptb-table-inner-border-number' ).value == 0 ) {\n document.querySelector( '#wptb-table-inner-border-slider' ).value = 1;\n document.querySelector( '#wptb-table-inner-border-number' ).value = 1;\n }\n let width = document.querySelector( '#wptb-table-inner-border-slider' ).value + 'px';\n let wptbPreviewTable = document.getElementsByClassName('wptb-preview-table');\n if( wptbPreviewTable.length > 0 ) {\n if (checked == 'checked') {\n document.getElementById('wptb-apply-inner-border').style.marginBottom = '0px';\n var tableCells = wptbPreviewTable[0].getElementsByTagName( 'td' );\n for (var i = 0; i < tableCells.length; i++) {\n tableCells[i].style.border = width + ' solid ' + color;\n }\n document.getElementById( 'wptb-apply-inner-border' ).classList.add( 'visible' );\n } else {\n document.getElementById( 'wptb-apply-inner-border' ).classList.remove( 'visible' );\n var tableCells = wptbPreviewTable[0].getElementsByTagName( 'td' );\n for (var i = 0; i < tableCells.length; i++) {\n tableCells[i].style.border = '0px solid ' + color;\n tableCells[i].style.border = null;\n }\n }\n }\n \n }\n\n function addBorderSize( value ) {\n table.style.borderWidth = value + 'px';\n table.style.borderStyle = 'solid';\n }\n \n function cellPaddingSavedSet() {\n let table = document.getElementsByClassName('wptb-preview-table');\n \n if ( table.length > 0 ) {\n let td = table[0].querySelector( 'td' );\n \n if ( td ) {\n let padding = td.style.padding;\n \n if ( padding ) {\n let wptbTableCellSlider = document.getElementById('wptb-table-cell-slider'),\n wptbTableCellNumber = document.getElementById('wptb-table-cell-number');\n \n if ( wptbTableCellSlider ) {\n wptbTableCellSlider.value = parseInt( padding );\n }\n if ( wptbTableCellNumber ) {\n wptbTableCellNumber.value = parseInt( padding );\n }\n }\n }\n }\n }\n \n cellPaddingSavedSet();\n \n let wptbTableBorderNumber = document.getElementById( 'wptb-table-border-number' );\n WPTB_Helper.numberImputSize( wptbTableBorderNumber, 1, 50 );\n \n let wptbTableInnerBorderNumber = document.getElementById( 'wptb-table-inner-border-number' );\n WPTB_Helper.numberImputSize( wptbTableInnerBorderNumber, 1, 50 );\n \n let wptbTableCellNumber = document.getElementById( 'wptb-table-cell-number' );\n WPTB_Helper.numberImputSize( wptbTableCellNumber, 1, 50 );\n \n// let wptbTextfontSizeNumber = document.getElementById( 'wptb-size-number' );\n// WPTB_Helper.numberImputSize( wptbTextfontSizeNumber, 1, 50 );\n// \n// let wptbImageWidthNumber = document.getElementById( 'wptb-size-number' );\n// WPTB_Helper.numberImputSize( wptbImageWidthNumber, 2, 100 );\n \n let wptbTableColumnWidthNumber = document.getElementById( 'wptb-table-column-width-number' );\n WPTB_Helper.numberImputSize( wptbTableColumnWidthNumber, 2, 500 );\n \n let wptbTableRowHeightNumber = document.getElementById( 'wptb-table-row-height-number' );\n WPTB_Helper.numberImputSize( wptbTableRowHeightNumber, 2, 200 );\n \n \n \n document.getElementById('wptb-table-cell-slider').oninput = function () {\n document.getElementById('wptb-table-cell-number').value = this.value;\n addCellPadding(this.value);\n table.tdDefaultWidth();\n };\n \n document.getElementById('wptb-table-cell-slider').onchange = function() {\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n\n document.getElementById('wptb-table-cell-number').onchange = function () {\n document.getElementById('wptb-table-cell-slider').value = this.value;\n addCellPadding(this.value);\n table.tdDefaultWidth();\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n document.getElementById('wptb-table-border-slider').oninput = function () {\n document.getElementById('wptb-table-border-number').value = this.value;\n addBorderSize(this.value);\n table.tdDefaultWidth();\n \n let wptbInnerBorderCheck = document.getElementById('wptb-inner-border-check').checked,\n tableBorderColorSetArea = document.getElementById( 'wptb-table-border-color-set-area' );\n if ( this.value == 0 && wptbInnerBorderCheck == false ) {\n tableBorderColorSetArea.style.display = 'none';\n } else {\n tableBorderColorSetArea.style.display = '';\n }\n };\n \n document.getElementById('wptb-table-border-slider').onchange = function() {\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n\n document.getElementById('wptb-table-border-number').onchange = function () {\n document.getElementById('wptb-table-border-slider').value = this.value;\n addBorderSize(this.value);\n table.tdDefaultWidth();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n document.getElementById('wptb-table-inner-border-slider').oninput = function () {\n document.getElementById('wptb-table-inner-border-number').value = this.value;\n addInnerBorderSize(this.value);\n table.tdDefaultWidth();\n };\n \n document.getElementById('wptb-table-inner-border-slider').onchange = function () {\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n\n document.getElementById('wptb-table-inner-border-number').onchange = function () {\n document.getElementById('wptb-table-inner-border-slider').value = this.value;\n addInnerBorderSize(this.value);\n table.tdDefaultWidth();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n document.getElementById('wptb-inner-border-check').onchange = function () {\n if( table ) {\n let val = this.checked ? 'checked' : 'unchecked';\n addInnerBorder( val );\n let borderWidth = document.getElementById('wptb-table-border-slider').value,\n tableBorderColorSetArea = document.getElementById( 'wptb-table-border-color-set-area' );\n if( val == 'unchecked' && borderWidth == 0 ) {\n tableBorderColorSetArea.style.display = 'none';\n } else {\n tableBorderColorSetArea.style.display = '';\n }\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n };\n \n document.getElementById( 'wptb-table-column-width-slider' ).oninput = function () {\n document.getElementById( 'wptb-table-column-width-number' ).value = this.value;\n table.addColumnWidth( this.value );\n };\n \n document.getElementById( 'wptb-table-column-width-slider' ).onchange = function () {\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n \n document.getElementById( 'wptb-table-column-width-number' ).onchange = function () {\n document.getElementById( 'wptb-table-column-width-slider' ).value = this.value;\n table.addColumnWidth( this.value );\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n \n document.getElementById( 'wptb-table-column-width-auto-fixed' ).onchange = function () {\n if( this.checked ) {\n let highlighted = table.querySelector( '.wptb-highlighted' );\n let width = WPTB_Helper.getColumnWidth( table, highlighted );\n table.addColumnWidth( width );\n } else {\n table.addColumnWidth( false, true );\n let highlighted = table.querySelector( '.wptb-highlighted' );\n let width = WPTB_Helper.getColumnWidth( table, highlighted );\n document.getElementById( 'wptb-table-column-width-number' ).value = width;\n document.getElementById( 'wptb-table-column-width-slider' ).value = width;\n }\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n document.getElementById( 'wptb-table-row-height-slider' ).oninput = function () {\n document.getElementById( 'wptb-table-row-height-number' ).value = this.value;\n table.addRowHeight( this.value );\n };\n \n document.getElementById( 'wptb-table-row-height-slider' ).onchange = function () {\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n document.getElementById( 'wptb-table-row-height-number' ).onchange = function () {\n document.getElementById( 'wptb-table-row-height-slider' ).value = this.value;\n table.addRowHeight( this.value );\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n \n document.getElementById( 'wptb-table-row-height-auto-fixed' ).onchange = function () {\n if( this.checked ) {\n let highlighted = table.querySelector( '.wptb-highlighted' );\n let height = WPTB_Helper.getRowHeight( table, highlighted );\n table.addRowHeight( height );\n } else {\n table.addRowHeight( false, true );\n let highlighted = table.querySelector( '.wptb-highlighted' );\n let height = WPTB_Helper.getRowHeight( table, highlighted );\n document.getElementById( 'wptb-table-row-height-number' ).value = height;\n document.getElementById( 'wptb-table-row-height-slider' ).value = height;\n }\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n \n document.getElementById( 'wptb-adaptive-table-checkbox' ).onchange = function() {\n if( this.checked ) {\n table.dataset.wptbAdaptiveTable = 1;\n } else {\n table.dataset.wptbAdaptiveTable = 0;\n }\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n \n function createMobileHeadForTable( table, thisEvent ) {\n \n if( thisEvent.checked ) {\n WPTB_Helper.dataTitleColumnSet( table );\n \n table.classList.add( 'wptb-table-preview-head' );\n table.rows[0].classList.add( 'wptb-table-head' );\n } else {\n let rows = table.rows;\n table.classList.remove( 'wptb-table-preview-head' );\n rows[0].classList.remove( 'wptb-table-head' );\n \n for ( let i = 1; i < rows.length; i++ ) {\n let thisRow = rows[i],\n thisRowChildren = thisRow.children;\n for( let j = 0; j < thisRowChildren.length; j++ ) {\n thisRowChildren[j].removeAttribute( 'data-wptb-title-column' );\n thisRowChildren[j].removeAttribute( 'data-wptb-title-column-font-size' );\n thisRowChildren[j].removeAttribute( 'data-wptb-title-column-color' );\n thisRowChildren[j].removeAttribute( 'data-wptb-title-background-color' );\n thisRowChildren[j].removeAttribute( 'data-wptb-title-align' );\n }\n }\n }\n }\n \n document.getElementById( 'wptb-top-row-as-header' ).onchange = function () {\n createMobileHeadForTable( table, this );\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n\n for (var i = 0; i < wptbElementButtons.length; i++) {\n wptbElementButtons[i].ondragstart = function (e) {\n e.dataTransfer.setData('wptbElement', this.dataset.wptbElement);\n e.dataTransfer.setData( 'wptbElIndic-' + this.dataset.wptbElement, 'wptbElIndic-' + this.dataset.wptbElement );\n }\n }\n \n if( table ) {\n document.getElementById('wptb-activate-cell-management-mode').onclick = table.toggleTableEditMode;\n document.getElementById( 'wptb-table-edit-mode-close' ).onclick = table.toggleTableEditMode;\n document.getElementById( 'wptb-left-scroll-panel-curtain-close' ).onclick = table.toggleTableEditMode;\n document.getElementById('wptb-add-end-row').onclick = table.addRowToTheEnd;\n document.getElementById('wptb-add-start-row').onclick = table.addRowToTheStart;\n document.getElementById('wptb-add-row-before').onclick = table.addRowBefore;\n document.getElementById('wptb-add-row-after').onclick = table.addRowAfter;\n document.getElementById('wptb-add-end-column').onclick = table.addColumnEnd;\n document.getElementById('wptb-add-start-column').onclick = table.addColumnStart;\n document.getElementById('wptb-add-column-before').onclick = table.addColumnBefore;\n document.getElementById('wptb-add-column-after').onclick = table.addColumnAfter;\n document.getElementById('wptb-delete-column').onclick = table.deleteColumn;\n document.getElementById('wptb-delete-row').onclick = table.deleteRow;\n document.getElementById('wptb-merge-cells').onclick = table.mergeCells;\n document.getElementById('wptb-split-cell').onclick = table.splitCell;\n }\n \n document.querySelector( '.wptb-left-panel-extend' ).onclick = function() {\n let wptbContainer = document.querySelector( '.wptb-container' );\n if( wptbContainer ) {\n if ( wptbContainer.classList.contains( 'collapsed' ) ) {\n wptbContainer.classList.remove( 'collapsed' );\n } else {\n wptbContainer.classList.add( 'collapsed' );\n }\n }\n };\n \n // this code hides the \"element parameters\" area \n // when clicked outside this element and its \"tinymce\" toolbar \n let wptbBuilderPanel = document.getElementsByClassName( 'wptb-builder-panel' )[0];\n wptbBuilderPanel.onclick = function( e ) {\n if( ! e.target.classList.contains( 'wptb-ph-element' ) && ! WPTB_Helper.findAncestor( e.target, 'wptb-ph-element' ) && \n ! e.target.classList.contains( 'wptb-fixed-toolbar' ) && ! WPTB_Helper.findAncestor( e.target, 'wptb-fixed-toolbar' ) ) {\n clickOnFreeSpace();\n } \n };\n \n let wptbHeader = document.getElementsByClassName( 'wptb-header' );\n if( wptbHeader.length > 0 ) wptbHeader = wptbHeader[0];\n wptbHeader.onclick = function() {\n clickOnFreeSpace();\n }\n \n function clickOnFreeSpace() {\n document.getElementsByClassName( 'wptb-elements-container' )[0].style.display = 'table';\n document.getElementsByClassName( 'wptb-settings-section' )[0].style.display = 'block';\n document.getElementById( 'element-options-group' ).style.display = 'none';\n let wpcdFixedToolbar = document.getElementById( 'wpcd_fixed_toolbar' );\n if( wpcdFixedToolbar.hasAttribute( 'data-toolbar-active-id' ) ) {\n document.getElementById( wpcdFixedToolbar.getAttribute( 'data-toolbar-active-id' ) ).classList.remove( 'toolbar-active' );\n }\n }\n document.querySelector('.wptb-panel-left').addEventListener('click', function (event) {\n if (event.target.classList.contains('wptb-exit-options')) {\n clickOnFreeSpace();\n }\n });\n \n};","var MultipleSelect = function () {\n\n\tvar selectedCells = [],\n\t\tmultipleCellMode = false;\n\n\tthis.activateMultipleSelectMode = function () {\n\t\tselectedCells = [];\n\t\tvar tds = document.getElementsByClassName('wptb-preview-table')[0].getElementsByTagName('td');\n\t\tfor (var i = 0; i < tds.length; i++) {\n\t\t\ttds[i].classList.remove('wptb-highlighted');\n\t\t}\n\t\tmultipleCellMode = true;\n\t}\n\n\tthis.deactivateMultipleSelectMode = function () {\n\t\tmultipleCellMode = false;\n\t}\n\n\tthis.isActivated = function () {\n\t\treturn multipleCellMode;\n\t}\n\n\tthis.pushSelectedCell = function (cell) {\n\t\tif (!multipleCellMode) {\n\t\t\treturn;\n\t\t}\n\t\tselectedCells.push(cell);\n\t\tcell.classList.add('wptb-highlighted');\n\t};\n\n\tthis.selectedCells = function () {\n\t\treturn selectedCells;\n\t}\n\n\tthis.flushSelectedCells = function () {\n\t\tselectedCells = [];\n\t}\n\n\tthis.getFirst = function () {\n\t\tvar minXIndex = 1000, minYIndex = 1000, first;\n\t\tfor (var i = selectedCells.length - 1; i >= 0; i--) {\n\t\t\tif (minXIndex >= selectedCells[i].dataset.xIndex\n\t\t\t\t&& minYIndex >= selectedCells[i].dataset.yIndex) {\n\t\t\t\tfirst = selectedCells[i];\n\t\t\t\tminXIndex = selectedCells[i].dataset.xIndex;\n\t\t\t\tminYIndex = selectedCells[i].dataset.yIndex;\n\t\t\t}\n\t\t}\n\t\treturn first;\n\t}\n\n\tthis.getLast = function () {\n\t\tvar maxXIndex = -1, maxYIndex = -1, last;\n\t\tfor (var i = selectedCells.length - 1; i >= 0; i--) {\n\t\t\tif (maxXIndex <= selectedCells[i].dataset.xIndex\n\t\t\t\t&& maxYIndex <= selectedCells[i].dataset.yIndex) {\n\t\t\t\tlast = selectedCells[i];\n\t\t\t\tmaxXIndex = selectedCells[i].dataset.xIndex;\n\t\t\t\tmaxYIndex = selectedCells[i].dataset.yIndex;\n\t\t\t}\n\t\t}\n\t\treturn last;\n\t}\n\n\tthis.removeAllButFirst = function () {\n\t\tvar td = this.getFirst();\n\t\tfor (var i = 1; i < selectedCells.length; i++) {\n\t\t\tselectedCells[i].classList.add('wptb-fused-cell-' + td.dataset.xIndex + '-' + td.dataset.yIndex);\n\t\t}\n\t}\n\n\treturn this;\n\n};","var WPTB_Parser = function ( code ) {\n let div = document.createElement( 'div' );\n div.innerHTML = code;\n \n let table = div.children[0];\n let columnTitleMobile = [...table.querySelectorAll( '.wptb-column-title-mobile-container' )];\n \n for( let i = 0; i < columnTitleMobile.length; i++ ) {\n let parent = columnTitleMobile[i].parentNode;\n parent.removeChild( columnTitleMobile[i] );\n }\n \n let tds = table.querySelectorAll( 'td' );\n for ( let i = 0; i < tds.length; i++ ) {\n tds[i].classList.add( 'wptb-droppable' );\n tds[i].classList.remove( 'wptb-column-title-mobile-not-elements' );\n }\n \n return table;\n}","// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys\nif (!Object.keys) {\n Object.keys = (function () {\n 'use strict';\n var hasOwnProperty = Object.prototype.hasOwnProperty,\n hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),\n dontEnums = [\n 'toString',\n 'toLocaleString',\n 'valueOf',\n 'hasOwnProperty',\n 'isPrototypeOf',\n 'propertyIsEnumerable',\n 'constructor'\n ],\n dontEnumsLength = dontEnums.length;\n\n return function (obj) {\n if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {\n throw new TypeError('Object.keys called on non-object');\n }\n\n var result = [], prop, i;\n\n for (prop in obj) {\n if (hasOwnProperty.call(obj, prop)) {\n result.push(prop);\n }\n }\n\n if (hasDontEnumBug) {\n for (i = 0; i < dontEnumsLength; i++) {\n if (hasOwnProperty.call(obj, dontEnums[i])) {\n result.push(dontEnums[i]);\n }\n }\n }\n return result;\n };\n }());\n}","var WPTB_Settings = function () {\n var elems = document.getElementsByClassName('wptb-element');\n\n for ( var i = 0; i < elems.length; i++ ) {\n elems[i].ondragstart = function ( event ) {\n event.dataTransfer.effectAllowed = 'move';\n event.dataTransfer.setData( 'wptbElement', event.target.dataset.wptbElement );\n event.dataTransfer.setData( 'wptbElIndic-' + event.target.dataset.wptbElement, 'wptbElIndic-' + event.target.dataset.wptbElement );\n }\n elems[i].ondragend = function () {\n WPTB_Helper.elementDragEndClear();\n }\n };\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n let wptbUndo = document.getElementsByClassName( 'wptb-undo' );\n if( wptbUndo.length > 0 ) {\n wptbUndo = wptbUndo[0];\n \n wptbUndo.onclick = function( event ) {\n if( ! this.classList.contains( 'wptb-undoredo-disabled' ) ) {\n wptbTableStateSaveManager.tableStateGet( this.dataset.wptbUndoredo );\n let wptbUndoRedoContainer = document.getElementsByClassName( 'wptb-undo-redo-container' );\n if( wptbUndoRedoContainer.length > 0 ) {\n wptbUndoRedoContainer = wptbUndoRedoContainer[0];\n wptbUndoRedoContainer.onmouseleave = function( event ) {\n event.target.onmouseleave = '';\n WPTB_Table();\n }\n }\n }\n \n }\n }\n \n let wptbRedo = document.getElementsByClassName( 'wptb-redo' );\n if( wptbRedo.length > 0 ) {\n wptbRedo = wptbRedo[0];\n \n wptbRedo.onclick = function( event ) {\n if( ! this.classList.contains( 'wptb-undoredo-disabled' ) ) {\n wptbTableStateSaveManager.tableStateGet( this.dataset.wptbUndoredo );\n let wptbUndoRedoContainer = document.getElementsByClassName( 'wptb-undo-redo-container' );\n if( wptbUndoRedoContainer.length > 0 ) {\n wptbUndoRedoContainer = wptbUndoRedoContainer[0];\n wptbUndoRedoContainer.onmouseleave = function( event ) {\n event.target.onmouseleave = '';\n WPTB_Table();\n }\n }\n }\n \n }\n }\n \n let shortcodePopupWindow = document.getElementsByClassName( 'wptb-popup-window-modal' )[0];\n document.getElementsByClassName( 'wptb-embed-btn' )[0].onclick = function () {\n if( ! this.classList.contains( 'wptb-button-disable' ) ) {\n shortcodePopupWindow.classList.add( 'wptb-popup-show' );\n }\n }\n \n window.onbeforeunload = function(e) {\n let wptbSaveDisabled = document.getElementsByClassName( 'wptb-save-disabled' );\n if( wptbSaveDisabled.length == 0 ) {\n return true;\n } else {\n return null;\n }\n };\n \n \n document.getElementsByClassName( 'wptb-popup-dark-area' )[0].onclick = function () {\n shortcodePopupWindow.classList.remove( 'wptb-popup-show' );\n }\n \n document.getElementsByClassName( 'wptb-popup-window-close-icon' )[0].onclick = function () {\n shortcodePopupWindow.classList.remove( 'wptb-popup-show' );\n }\n \n document.getElementsByClassName( 'wptb-preview-btn' )[0].onclick = function ( e ) {\n if( this.classList.contains( 'wptb-button-disable' ) ) {\n e.preventDefault();\n }\n }\n\n document.getElementsByClassName( 'wptb-save-btn' )[0].onclick = function ( event ) {\n if( ( ! event.target.dataset.wptbTableStateNumberSave && window.wptbTableStateNumberShow == 0 ) || \n window.wptbTableStateNumberShow == event.target.dataset.wptbTableStateNumberSave ) {\n return;\n }\n let bar = document.querySelector( '.wptb-edit-bar' );\n if ( bar && bar.classList.contains( 'visible' ) ) {\n let table = document.getElementsByClassName( 'wptb-preview-table' )[0];\n table.toggleTableEditMode();\n }\n\n let http = new XMLHttpRequest(),\n url = ( wptb_admin_object ? wptb_admin_object.ajaxurl : ajaxurl ) + \"?action=save_table\",\n t = document.getElementById( 'wptb-setup-name' ).value.trim(),\n messagingArea,\n code,\n datas;\n code = document.getElementsByClassName( 'wptb-preview-table' );\n if( code.length > 0 ) {\n code = WPTB_Stringifier( code[0] );\n code = code.outerHTML;\n } else { \n code = '';\n }\n \n datas = '';\n let datas_containers = document.getElementsByClassName( 'wptb-element-datas' );\n \n if( datas_containers.length > 0 ) {\n if( datas_containers[0].innerHTML ) {\n datas = datas_containers[0].innerHTML;\n }\n }\n \n if ( t === '' || code === '' ) {\n let messagingAreaText = '';\n if( t === '' ) messagingAreaText += 'You must assign a name to the table before saving it.</br>';\n if( code === '' ) messagingAreaText += 'Table wasn\\'t created';\n messagingArea = document.getElementById( 'wptb-messaging-area' );\n messagingArea.innerHTML = '<div class=\"wptb-error wptb-message\">Error: ' + messagingAreaText + '</div>';\n messagingArea.classList.add( 'wptb-warning' );\n setTimeout(function () {\n messagingArea.removeChild( messagingArea.firstChild );\n }, 4000 );\n return;\n }\n\n let params = {\n title: t,\n content: code,\n elements_datas: datas,\n security_code: wptb_admin_object.security_code\n };\n if (( rs = WPTB_Helper.detectMode() ) || ( rs = document.wptbId )) {\n params.id = rs;\n }\n params = JSON.stringify( params );\n\n http.open('POST', url, true);\n http.setRequestHeader( 'Content-type', 'application/json; charset=utf-8' );\n\n http.onreadystatechange = function ( action ) {\n if ( this.readyState == 4 && this.status == 200 ) {\n var data = JSON.parse( http.responseText );\n messagingArea = document.getElementById( 'wptb-messaging-area' );\n\n if ( data[0] == 'saved' ) {\n document.wptbId = data[1];\n messagingArea.innerHTML = '<div class=\"wptb-success wptb-message\">Table \"' + t + '\" was successfully saved.</div>';\n document.getElementsByClassName( 'wptb-embed-btn' )[0].classList.remove( 'wptb-button-disable' );\n document.getElementById( 'wptb-embed-shortcode' ).value = '[wptb id=' + data[1] + ']';\n let wptbPreviewBtn = document.getElementsByClassName( 'wptb-preview-btn' );\n if( wptbPreviewBtn.length > 0 ) {\n wptbPreviewBtn = wptbPreviewBtn[0];\n wptbPreviewBtn.classList.remove( 'wptb-button-disable' );\n let wptbPreviewBtnHref = wptbPreviewBtn.dataset.previewHref;\n wptbPreviewBtnHref = wptbPreviewBtnHref.replace( 'empty', data[1] );\n wptbPreviewBtn.setAttribute( 'href', wptbPreviewBtnHref );\n }\n \n } else if( data[0] == 'edited' ) {\n messagingArea.innerHTML = '<div class=\"wptb-success wptb-message\">Table \"' + t + '\" was successfully updated.</div>';\n event.target.dataset.wptbTableStateNumberSave = window.wptbTableStateNumberShow;\n \n let wptbSaveBtn = document.getElementsByClassName( 'wptb-save-btn' );\n if( wptbSaveBtn.length > 0 ) {\n wptbSaveBtn = wptbSaveBtn[0];\n wptbSaveBtn.classList.add( 'wptb-save-disabled' );\n }\n } else {\n messagingArea.innerHTML = '<div class=\"wptb-error wptb-message\">Safety problems</div>';\n }\n messagingArea.classList.add( 'wptb-success' );\n setTimeout( function () {\n messagingArea.removeChild( messagingArea.firstChild );\n }, 4000 );\n }\n }\n http.send( params );\n }\n};\n","var WPTB_Stringifier = function ( codeMain ) {\n if ( codeMain ) {\n let code = codeMain.cloneNode( true );\n code.classList.add( 'wptb-table-preview-static-indic' );\n code.dataset.tableColumns = codeMain.columns;\n code.style.width = null;\n code.style.minWidth = null;\n code.style.maxWidth = null;\n \n let tds = code.getElementsByTagName( 'td' );\n if ( tds.length > 0 ) {\n for ( let i = 0; i < tds.length; i++ ) {\n \n if ( codeMain.querySelector( 'wptb-table-preview-head' ) ) {\n tds[i].removeAttribute( 'data-x-index' );\n }\n tds[i].removeAttribute( 'data-y-index' );\n tds[i].removeAttribute( 'draggable' );\n tds[i].classList.remove( 'wptb-droppable' );\n let innerElements = tds[i].getElementsByClassName( 'wptb-ph-element' );\n \n if ( innerElements.length > 0 ) {\n for ( let j = 0; j < innerElements.length; j++ ) {\n \n let mceContentBodys = innerElements[j].querySelectorAll( '.mce-content-body' );\n if( mceContentBodys.length > 0 ) {\n for ( let k = 0; k < mceContentBodys.length; k++ ) {\n mceContentBodys[k].classList.remove( 'mce-content-body' );\n }\n }\n \n let dataMceStyle = innerElements[j].querySelectorAll( '[data-mce-style]' );\n if ( dataMceStyle.length > 0 ) {\n for ( let k = 0; k < dataMceStyle.length; k++ ) {\n dataMceStyle[k].removeAttribute( 'data-mce-style' );\n }\n }\n \n let contentEditable = innerElements[j].querySelectorAll( '[contenteditable]' );\n if ( contentEditable.length > 0 ) {\n for ( let k = 0; k < contentEditable.length; k++ ) {\n contentEditable[k].removeAttribute( 'contenteditable' );\n }\n }\n \n let spellCheck = innerElements[j].querySelectorAll( '[spellcheck]' );\n if ( spellCheck.length > 0 ) {\n for ( let k = 0; k < spellCheck.length; k++ ) {\n spellCheck[k].removeAttribute( 'spellcheck' );\n }\n }\n \n let mceIds = innerElements[j].querySelectorAll( '[id^=mce_]' );\n if ( mceIds.length > 0 ) {\n for ( let k = 0; k < mceIds.length; k++ ) {\n mceIds[k].removeAttribute( 'id' );\n }\n }\n \n let wptbActions = innerElements[j].querySelectorAll( '.wptb-actions' );\n let wptbActionsLength = wptbActions.length;\n while ( wptbActionsLength > 0 ) {\n if( wptbActions[0] && wptbActions[0].parentNode ) {\n wptbActions[0].parentNode.removeChild( wptbActions[0] );\n wptbActionsLength--;\n } else {\n break;\n }\n \n } \n }\n }\n \n if( tds[i].hasAttribute( 'data-wptb-title-column' ) ) {\n let columnNameDivContainer = document.createElement( 'div' ),\n columnNameDiv = document.createElement( 'div' );\n columnNameDivContainer.classList.add( 'wptb-column-title-mobile-container' );\n columnNameDiv.classList.add( 'wptb-column-title-mobile' );\n columnNameDiv.dataset.wptbTitleColumn = tds[i].dataset.wptbTitleColumn;\n columnNameDiv.setAttribute( 'style', 'font-size:' + tds[i].dataset.wptbTitleColumnFontSize + '; \\n\\\n color:' + tds[i].dataset.wptbTitleColumnColor + '; background-color:' + tds[i].dataset.wptbTitleBackgroundColor + '; text-align:' + tds[i].dataset.wptbTitleAlign + ';' );\n columnNameDiv.style.padding = tds[i].style.padding;\n if( tds[i].children.length == 0 ) {\n tds[i].classList.add( 'wptb-column-title-mobile-not-elements' );\n }\n columnNameDivContainer.appendChild( columnNameDiv );\n tds[i].insertBefore( columnNameDivContainer, tds[i].firstChild );\n }\n }\n }\n \n return code;\n }\n}","var array = [], WPTB_Table = function (columns, rows) {\n\n /* The members of the class */\n var settings = document.getElementsByClassName('wptb-settings-items'),\n wptbTableSetup = document.getElementsByClassName(\"wptb-table-setup\")[0],\n table, row, cell,\n maxAmountOfCells,\n maxAmountOfRows;\n\n //HERE ARE THE PRIVATE FUNCTIONS\n /*\n * This function toggles buttons visibility in cell edit mode\n * (according to the amount of currently selected cells), and\n * highlights visually the clicked cell if it is not highlighted, or\n * removes highlight if clicked cell is already highlighted. \n * It too toggles the bits of our abstract representation.\n * @param Event this is the event instance of the click performed over a cell.\n */\n var mark = function ( event ) {\n var rs = this.rowSpan,\n cs = this.colSpan,\n markedCells,\n noCells = document.getElementsByClassName('wptb-no-cell-action'),\n singleCells = document.getElementsByClassName('wptb-single-action'),\n multipleCells = document.getElementsByClassName('wptb-multiple-select-action'),\n cellSettings = document.getElementById( 'wptb-left-scroll-panel-cell-settings' ),\n position = getCoords(this),\n row = position[0],\n column = position[1];\n if ( ! document.select.isActivated() ) {\n return;\n }\n if (this.className.match(/wptb-highlighted/)) {\n this.classList.remove('wptb-highlighted');\n for (var i = 0; i < rs; i++) {\n for (var j = 0; j < cs; j++) {\n array[row + i][column + j] = 0;\n }\n }\n } else {\n this.classList.add('wptb-highlighted');\n for (var i = 0; i < rs; i++) {\n for (var j = 0; j < cs; j++) {\n array[row + i][column + j] = 1;\n }\n }\n }\n\n markedCells = document.getElementsByClassName('wptb-highlighted').length;\n if (markedCells === 0) {\n for (var i = 0; i < multipleCells.length; i++) {\n multipleCells[i].classList.remove('visible');\n multipleCells[i].setAttribute('disabled', 'disabled');\n }\n for (var i = 0; i < noCells.length; i++) {\n noCells[i].classList.add('visible');\n noCells[i].removeAttribute('disabled');\n }\n for (var i = 0; i < singleCells.length; i++) {\n singleCells[i].classList.remove('visible');\n singleCells[i].setAttribute('disabled', 'disabled');\n }\n cellSettings.classList.remove( 'visible' );\n } else if (markedCells === 1) {\n for (var i = 0; i < multipleCells.length; i++) {\n multipleCells[i].classList.remove('visible');\n multipleCells[i].setAttribute('disabled', 'disabled');\n }\n for (var i = 0; i < noCells.length; i++) {\n noCells[i].classList.remove('visible');\n noCells[i].setAttribute('disabled', 'disabled');\n }\n for (var i = 0; i < singleCells.length; i++) {\n singleCells[i].classList.add('visible');\n singleCells[i].removeAttribute('disabled');\n }\n let cellHighlighted = document.querySelector( '.wptb-highlighted' );\n if( cellHighlighted ) {\n let wptbTableColumnWidthSlider = document.getElementById( 'wptb-table-column-width-slider' );\n let wptbTableColumnWidthNumber = document.getElementById( 'wptb-table-column-width-number' );\n let tableColumnWidthAutoFixedCheckbox = document.getElementById( 'wptb-table-column-width-auto-fixed' );\n let width = cellHighlighted.style.width;\n if( width ) {\n wptbTableColumnWidthSlider.value = parseFloat( width, 10 );\n wptbTableColumnWidthNumber.value = parseFloat( width, 10 );\n tableColumnWidthAutoFixedCheckbox.checked = true;\n } else if( cellHighlighted.dataset.wptbFixedWidth ) {\n wptbTableColumnWidthSlider.value = cellHighlighted.dataset.wptbFixedWidth;\n wptbTableColumnWidthNumber.value = cellHighlighted.dataset.wptbFixedWidth;\n tableColumnWidthAutoFixedCheckbox.checked = true;\n } else {\n let cellWidth = WPTB_Helper.getColumnWidth( table, cellHighlighted );\n wptbTableColumnWidthSlider.value = cellWidth;\n wptbTableColumnWidthNumber.value = cellWidth;\n tableColumnWidthAutoFixedCheckbox.checked = false;\n }\n \n \n let wptbTableRowHeightSlider = document.getElementById( 'wptb-table-row-height-slider' );\n let wptbTableRowHeightNumber = document.getElementById( 'wptb-table-row-height-number' );\n let tableRowHeightAutoFixedCheckbox = document.getElementById( 'wptb-table-row-height-auto-fixed' );\n let height = cellHighlighted.style.height;\n if( height ) {\n wptbTableRowHeightSlider.value = parseFloat( height, 10 );\n wptbTableRowHeightNumber.value = parseFloat( height, 10 );\n tableRowHeightAutoFixedCheckbox.checked = true;\n } else if( cellHighlighted.dataset.wptbFixedHeight ) {\n wptbTableRowHeightSlider.value = cellHighlighted.dataset.wptbFixedHeight;\n wptbTableRowHeightNumber.value = cellHighlighted.dataset.wptbFixedHeight;\n tableRowHeightAutoFixedCheckbox.checked = true;\n } else {\n let cellHeight = WPTB_Helper.getRowHeight( table, cellHighlighted );\n wptbTableRowHeightSlider.value = cellHeight;\n wptbTableRowHeightNumber.value = cellHeight;\n tableRowHeightAutoFixedCheckbox.checked = false;\n }\n }\n cellSettings.classList.add( 'visible' );\n } else {\n for (var i = 0; i < multipleCells.length; i++) {\n if (table.isSquare(array)) {\n multipleCells[i].classList.add('visible');\n multipleCells[i].removeAttribute('disabled');\n } else {\n multipleCells[i].classList.remove('visible');\n multipleCells[i].setAttribute('disabled', 'disabled');\n }\n }\n for (var i = 0; i < noCells.length; i++) {\n noCells[i].classList.remove('visible');\n noCells[i].setAttribute('disabled', 'disabled');\n }\n for (var i = 0; i < singleCells.length; i++) {\n singleCells[i].classList.remove('visible');\n singleCells[i].setAttribute('disabled', 'disabled');\n }\n cellSettings.classList.remove( 'visible' );\n }\n };\n\n /* \n * This function fills an array with 1's according to the actual design\n * of HTML table.\n * @returns an array of arrays containing an abstract representation\n * of HTML table.\n * @deprecated\n * */\n\n var realTimeArray = function () {\n var carried = [], tds, cols, matriz = [];\n\n for (var i = 0; i < maxAmountOfCells; i++) {\n carried[i] = 0;\n }\n\n for (var i = 0; i < table.rows.length; i++) {\n cols = [];\n\n var tds = table.rows[i].getElementsByTagName('td');\n\n for (items = 0; items < tds.length; items++) {\n\n for (var k = 0; k < tds[items].colSpan; k++) {\n cols.push(1);\n }\n\n if (tds[items].rowSpan > 1) {\n for (var k = 0; k < tds[items].colSpan; k++) {\n carried[items + k] = {\n justAssigned: true,\n amount: tds[items].rowSpan\n };\n }\n }\n }\n\n for (var k = 0; k < maxAmountOfCells; k++) {\n if (typeof carried[k] == 'object' && carried[k].amount > 0) {\n carried[k].amount--;\n if (carried[k].justAssigned) {\n carried[k].justAssigned = false;\n } else {\n cols.push(1);\n }\n }\n }\n\n matriz.push(cols);\n\n }\n return matriz;\n };\n\n /*\n * This function gets the number and position of cell spaces in current row that are occuped \n * by upper rowspanned cells.\n * @param number the number of row where we wish to calculate the carried rowspans up to.\n * @return an array with the remaining rowspans in each column.\n */\n var carriedRowspans = function (row) {\n var carried = [], tds, cols;\n\n for (var i = 0; i < maxAmountOfCells; i++) {\n carried[i] = 0;\n }\n\n if (row == -1) {\n return carried;\n }\n\n for (var i = 0; i <= row; i++) {\n cellsBuffer = table.rows[i].getElementsByTagName('td');\n cellPointer = 0;\n\n for (var xPosition = 0; xPosition < maxAmountOfCells; xPosition += stepsToMove) {\n stepsToMove = 1;\n\n if (carried[xPosition]) {\n carried[xPosition]--;\n } else {\n celda = cellsBuffer[cellPointer++];\n if (celda.rowSpan > 1) {\n for (k = 0; k < celda.colSpan; k++) {\n carried[xPosition + k] = celda.rowSpan - 1;\n }\n stepsToMove = celda.colSpan;\n } else if (celda.colSpan > 1) {\n stepsToMove = celda.colSpan;\n }\n }\n }\n\n }\n return carried;\n };\n\n /*\n * A helpful function for showing\n * the abstract table in console.\n * @param Array our abstract table.\n */\n var drawTable = function (a) {\n var string = 'DRAWING TABLE:\\n';\n for (var i = 0; i < a.length; i++) {\n\n for (var j = 0; j < a[i].length; j++) {\n string += ' ' + a[i][j];\n }\n string += '\\n';\n }\n table.isSquare(a);\n };\n\n /*\n * It resets all the bits of our abstract representation\n * to 0 and removes the highlighting class of all cells.\n */\n\n var undoSelect = function () {\n var noCells = document.getElementsByClassName('wptb-no-cell-action'),\n singleCells = document.getElementsByClassName('wptb-single-action'),\n multipleCells = document.getElementsByClassName('wptb-multiple-select-action'),\n cellSettings = document.getElementById( 'wptb-left-scroll-panel-cell-settings' ),\n tds = table.getElementsByClassName('wptb-highlighted');\n while (tds.length) {\n tds[0].classList.remove('wptb-highlighted');\n }\n cellSettings.classList.remove( 'visible' );\n for (var i = 0; i < array.length; i++) {\n for (var j = 0; j < array[i].length; j++) {\n array[i][j] = 0;\n }\n }\n for (var i = 0; i < multipleCells.length; i++) {\n multipleCells[i].classList.remove('visible');\n multipleCells[i].setAttribute('disabled', 'disabled');\n }\n for (var i = 0; i < noCells.length; i++) {\n noCells[i].classList.add('visible');\n noCells[i].removeAttribute('disabled');\n }\n for (var i = 0; i < singleCells.length; i++) {\n singleCells[i].classList.remove('visible');\n singleCells[i].setAttribute('disabled', 'disabled');\n }\n };\n\n /*\n * This fills the abstract representation of our table with \n * zeros, at the start. the max amount of cells is the greatest sum\n * of all colspans for row.\n */\n\n var fillTableArray = function () {\n var colspansSums = [], a = [];\n\n //calculate max amount of cells inside a row\n for (var i = 0; i < table.rows.length; i++) {\n var cells = table.rows[i].getElementsByTagName('td'),\n colspanSumInRow = 0;\n for (var j = 0; j < cells.length; j++) {\n colspanSumInRow += cells[j].colSpan;\n }\n colspansSums.push(colspanSumInRow);\n }\n\n maxAmountOfCells = Math.max.apply(null, colspansSums);\n //calculate max rows\n var maxAmountOfRows = table.rows.length;\n\n // fill with zeros from both values\n for (var i = 0; i < maxAmountOfRows; i++) {\n a[i] = [];\n for (var j = 0; j < maxAmountOfCells; j++) {\n a[i].push(0);\n }\n }\n drawTable(a);\n return a;\n };\n\n /*\n * This function gets the sum of all colspans in a row.\n * @param number the number of row to be used as reference.\n */\n var getActualPointsInRow = function (row) {\n var tds = table.rows[row].getElementsByTagName('td'),\n points = 0;\n for (var i = 0; i < tds.length; i++) {\n points += tds[i].colSpan;\n }\n return points;\n }\n\n /*\n * This function gets us the exact coordinates of\n * an exact cell, in a more reliable way than xIndex and yIndex,\n * these last ones were meant to be used for getting the cell trough them.\n * @param DOMElement the cell to get the coordinates.\n */\n var getCoords = function (search) {\n var skipInCols = [], cell;\n\n for (var i = 0; i < maxAmountOfCells; i++) {\n skipInCols[i] = 0;\n }\n\n for (var i = 0; i < table.rows.length; i++) {\n var cellsBuffer = table.rows[i].getElementsByTagName('td');\n cellPointer = 0;\n for (var xPosition = 0; xPosition < maxAmountOfCells; xPosition += stepsToMove) {\n stepsToMove = 1;\n\n if (skipInCols[xPosition]) {\n skipInCols[xPosition]--;\n } else {\n var td = cellsBuffer[cellPointer++];\n if (td == search) {\n return [i, xPosition];\n }\n if (td.rowSpan > 1) {\n for ( let k = 0; k < td.colSpan; k++ ) {\n skipInCols[xPosition + k] = td.rowSpan - 1;\n }\n stepsToMove = td.colSpan;\n } else if (td.colSpan > 1) {\n stepsToMove = td.colSpan;\n }\n }\n }\n }\n };\n\n jQuery('#wptb-table-header-bg').val('');\n jQuery('#wptb-even-row-bg').val('');\n jQuery('#wptb-odd-row-bg').val('');\n jQuery('#wptb-table-border-color').val('');\n jQuery('#wptb-table-inner-border-number,#wptb-table-inner-border-slider').val('0');\n jQuery('#wptb-table-border-number,#wptb-table-border-slider').val('0');\n jQuery('#wptb-table-padding-number,#wptb-table-padding-slider').val('15');\n\n if (columns || rows) {\n //END OF PRIVATE FUNCTIONS\n for (var i = 0; i < settings.length; i++) {\n if (settings[i].id !== 'wptb-apply-inner-border') {\n settings[i].classList.add('visible');\n }\n }\n\n //Create a HTML Table element.\n table = document.createElement( 'table' );\n table.classList.add( 'wptb-preview-table' );\n table.dataset.reconstraction = 1;\n table.dataset.wptbAdaptiveTable = 1;\n //Add the data rows.\n for (var i = 0; i < rows; i++) {\n\n row = table.insertRow(-1);\n row.classList.add( 'wptb-row' );\n\n for (var j = 0; j < columns; j++) {\n cell = new WPTB_Cell(mark);\n cell.setCoords(i, j);\n row.appendChild(cell.getDOMElement());\n }\n }\n } else {\n let wptb_preview_table = document.getElementsByClassName( 'wptb-preview-table' );\n\n if (wptb_preview_table.length > 0) {\n table = wptb_preview_table[0];\n\n let cells = table.getElementsByTagName('td');\n\n if (cells.length > 0) {\n for (let i = 0; i < cells.length; i++) {\n WPTB_Cell(mark, cells[i]);\n }\n }\n }\n }\n\n /*\n * This just toggles visibility of cell edit bar, and toggles \n * cell selecting mode.\n */\n\n table.toggleTableEditMode = function () {\n let bar = document.getElementsByClassName('wptb-edit-bar'),\n cellModeBackground = document.getElementById('wptb-cell_mode_background'),\n leftScrollPanelCurtain = document.getElementById('wptb-left-scroll-panel-curtain'),\n leftScrollPanelCellSettings = document.getElementById( 'wptb-left-scroll-panel-cell-settings' ),\n wptbPreviewTable = document.getElementsByClassName('wptb-preview-table');\n if (wptbPreviewTable.length > 0) {\n wptbPreviewTable = wptbPreviewTable[0];\n }\n\n if ( bar.length > 0 ) {\n for ( let i = 0; i < bar.length; i++ ) {\n if ( bar[i].classList.contains( 'visible' ) ) {\n document.select.deactivateMultipleSelectMode();\n bar[i].classList.remove( 'visible' );\n cellModeBackground.classList.remove( 'visible' );\n leftScrollPanelCurtain.classList.remove( 'visible' );\n leftScrollPanelCellSettings.classList.remove( 'visible' );\n wptbPreviewTable.parentNode.classList.remove( 'wptb-preview-table-manage-cells' );\n let wptbPreviewTableTds = wptbPreviewTable.getElementsByTagName( 'td' );\n if ( wptbPreviewTableTds.length > 0 ) {\n for ( let i = 0; i < wptbPreviewTableTds.length; i++ ) {\n wptbPreviewTableTds[i].classList.remove( 'wptb-highlighted' );\n }\n }\n } else {\n document.select.activateMultipleSelectMode();\n bar[i].classList.add( 'visible' );\n cellModeBackground.classList.add( 'visible' );\n leftScrollPanelCurtain.classList.add( 'visible' );\n wptbPreviewTable.parentNode.classList.add( 'wptb-preview-table-manage-cells' );\n }\n }\n\n }\n }\n\n /*\n * For assigning to each cell xIndex and y Index attributes,\n * these are the column number and row number of cell in table. \n */\n\n table.recalculateIndexes = function ( start ) {\n let trs = this.getElementsByTagName('tr'), tds, maxCols = 0, maxColsFull = 0,\n tdsArr = [];\n let wptbTopRowAsHeader = document.getElementById( 'wptb-top-row-as-header' );\n \n for (var i = 0; i < trs.length; i++) {\n if ( i == 0 ) {\n if ( start == undefined ) {\n trs[i].style.backgroundColor = jQuery('#wptb-table-header-bg').val();\n }\n if( wptbTopRowAsHeader.checked ) {\n if( start == undefined ) {\n this.classList.add( 'wptb-table-preview-head' ); \n trs[i].classList.add( 'wptb-table-head' )\n } ;\n } else {\n if( start == undefined ) {\n this.classList.remove( 'wptb-table-preview-head' );\n trs[i].classList.remove( 'wptb-table-head' );\n }\n }\n } else {\n if (i % 2 == 0) {\n if ( start == undefined ) {\n trs[i].style.backgroundColor = jQuery('#wptb-odd-row-bg').val();\n }\n trs[i].classList.remove( 'wptb-table-head' );\n } else {\n if ( start == undefined ) {\n trs[i].style.backgroundColor = jQuery('#wptb-even-row-bg').val();\n }\n trs[i].classList.remove( 'wptb-table-head' );\n }\n }\n\n tdsArr[i];\n tds = trs[i].getElementsByTagName('td');\n\n if (tdsArr[i] == undefined) {\n tdsArr[i] = [];\n }\n\n let jMainIter = 0;\n for (var j = 0; j < tds.length; j++) {\n if (tdsArr[i][j] != undefined) {\n for (let y = 0; y < 100; y++) {\n if (tdsArr[i][jMainIter] != undefined) {\n jMainIter++;\n continue;\n }\n tdsArr[i][jMainIter] = tds[j];\n tds[j].dataset.xIndex = jMainIter;\n break;\n }\n } else {\n tdsArr[i][j] = tds[j];\n tds[j].dataset.xIndex = jMainIter;\n }\n tds[j].dataset.yIndex = i;\n\n if (tds[j].colSpan > 1) {\n for (let k = 1; k < tds[j].colSpan; k++) {\n jMainIter++;\n tdsArr[i][jMainIter] = 'tdDummy';\n }\n }\n\n if (tds[j].rowSpan > 1) {\n for (let x = 1; x < tds[j].rowSpan; x++) {\n if (tdsArr[i + x] == undefined) {\n tdsArr[i + x] = [];\n }\n for (let z = 0; z < tds[j].colSpan; z++) {\n tdsArr[i + x][jMainIter - tds[j].colSpan + 1 + z ] = 'tdDummy';\n }\n }\n }\n jMainIter++;\n if( i == 0 ) {\n maxColsFull = jMainIter;\n }\n }\n if (j > maxCols) {\n maxCols = j;\n }\n }\n this.columns = maxCols;\n this.maxCols = maxColsFull;\n }\n \n table.addColumnWidth = function( value, cleaner ) {\n let highlighted = table.getElementsByClassName( 'wptb-highlighted' );\n if( highlighted.length > 0 ) {\n for( let k = 0; k < highlighted.length; k++ ) {\n let dataXIndex = highlighted[k].dataset.xIndex;\n if( dataXIndex ) {\n function tableTdsFor( dataXIndex, colspan ) {\n let tableRows = table.rows;\n let widthIsSet = false;\n let arrayTdsFromPreviousRow = [];\n for( let i = 0; i < tableRows.length; i++ ) {\n let row = tableRows[i];\n let tds = row.children;\n for( let j = 0; j < tds.length; j++ ) {\n let td = tds[j];\n if( td.dataset.xIndex == dataXIndex ) {\n if( value ) {\n if( td.colSpan == colspan ) {\n td.style.width = value + 'px';\n td.removeAttribute( 'data-wptb-fixed-width' );\n widthIsSet = true;\n let tableColumnWidthAutoFixedCheckbox = document.getElementById( 'wptb-table-column-width-auto-fixed' );\n if( ! tableColumnWidthAutoFixedCheckbox.checked ) {\n tableColumnWidthAutoFixedCheckbox.checked = true;\n }\n } else {\n td.style.width = null;\n td.dataset.wptbFixedWidth = value;\n if( i == tableRows.length - 1 && ! widthIsSet ) {\n tableTdsFor( dataXIndex, colspan + 1 );\n }\n }\n } else if( cleaner ) {\n td.style.width = null;\n td.removeAttribute( 'data-wptb-fixed-width' );\n } else {\n if( td.dataset.wptbFixedWidth ) {\n if( td.colSpan == colspan ) {\n td.style.width = td.dataset.wptbFixedWidth + 'px';\n td.removeAttribute( 'data-wptb-fixed-width' );\n } \n } else if( td.style.width ) {\n for( let z = 0; z < arrayTdsFromPreviousRow.length; z++ ) {\n arrayTdsFromPreviousRow[z].style.width = td.style.width;\n }\n arrayTdsFromPreviousRow = [];\n } else {\n arrayTdsFromPreviousRow.push( td );\n }\n }\n break;\n } \n }\n }\n }\n \n tableTdsFor( dataXIndex, 1 );\n }\n }\n \n table.tdDefaultWidth();\n }\n }\n \n table.tdDefaultWidth = function() {\n let rows = table.rows;\n \n let tableTdsSumMaxWidth = 0;\n let tableTdsSumMaxWidthFixed = 0;\n let tableTdsSumMaxWidthAuto = 0;\n \n let wptbTableSetup = document.getElementsByClassName( 'wptb-table-setup' )[0];\n let wptbTableSetupWidth = wptbTableSetup.offsetWidth;\n \n let arrayCellsWidthFixedHelper = [];\n let arrayCellsWidthAutoHelper = [];\n let tdPaddingCommon = 0;\n let tableTdBorderCommonWidth = 0;\n let cssForTdsWidthAuto = '';\n \n for( let i = 0; i < rows.length; i++ ) {\n let tds = rows[i].children;\n for( let j = 0; j < tds.length; j++ ) {\n let td = tds[j];\n \n if( ! arrayCellsWidthFixedHelper[parseInt( td.dataset.xIndex )] && ! arrayCellsWidthAutoHelper[parseInt( td.dataset.xIndex )] ) {\n if( td.style.width ) {\n arrayCellsWidthFixedHelper[parseInt( td.dataset.xIndex )] = parseFloat( td.style.width );\n td.removeAttribute( 'data-wptb-css-td-auto-width' );\n } else {\n if( ! td.dataset.wptbFixedWidth ) {\n arrayCellsWidthAutoHelper[parseInt( td.dataset.xIndex )] = 100;\n td.dataset.wptbCssTdAutoWidth = true;\n }\n }\n \n if( window.getComputedStyle( td, null ) ) {\n let tdStyleObj = window.getComputedStyle( td, null );\n let tdPaddingLeft = tdStyleObj.getPropertyValue( 'padding-left' );\n let tdPaddingRight = tdStyleObj.getPropertyValue( 'padding-right' );\n tdPaddingCommon = parseFloat( tdPaddingLeft, 10 ) + parseFloat( tdPaddingRight, 10 );\n\n let tableTdBorderLeftWidth = tdStyleObj.getPropertyValue( 'border-left-width' );\n let tableTdBorderRightWidth = tdStyleObj.getPropertyValue( 'border-right-width' );\n tableTdBorderCommonWidth = parseFloat( tableTdBorderLeftWidth, 10 ) + parseFloat( tableTdBorderRightWidth, 10 );\n if( arrayCellsWidthFixedHelper[parseInt( td.dataset.xIndex )] ) {\n arrayCellsWidthFixedHelper[parseInt( td.dataset.xIndex )] += tdPaddingCommon;\n arrayCellsWidthFixedHelper[parseInt( td.dataset.xIndex )] += tableTdBorderCommonWidth;\n } else {\n arrayCellsWidthAutoHelper[parseInt( td.dataset.xIndex )] += tdPaddingCommon;\n arrayCellsWidthAutoHelper[parseInt( td.dataset.xIndex )] += tableTdBorderCommonWidth;\n }\n }\n } else if( arrayCellsWidthAutoHelper[parseInt( td.dataset.xIndex )] ) {\n if( ! td.dataset.wptbFixedWidth ) {\n td.dataset.wptbCssTdAutoWidth = true;\n }\n } else if( arrayCellsWidthFixedHelper[parseInt( td.dataset.xIndex )] ) {\n td.removeAttribute( 'data-wptb-css-td-auto-width' );\n }\n }\n }\n \n for( let i = 0; i < arrayCellsWidthFixedHelper.length; i++ ) {\n if( arrayCellsWidthFixedHelper[i] ) {\n tableTdsSumMaxWidthFixed += arrayCellsWidthFixedHelper[i];\n }\n }\n \n let CellsWidthAutoCount = 0;\n for( let i = 0; i < arrayCellsWidthAutoHelper.length; i++ ) {\n if( arrayCellsWidthAutoHelper[i] ) {\n tableTdsSumMaxWidthAuto += arrayCellsWidthAutoHelper[i];\n CellsWidthAutoCount++;\n }\n }\n \n let tableFullStyleObj = window.getComputedStyle( table, null );\n let borderLeftWidth = tableFullStyleObj.getPropertyValue( 'border-left-width' );\n let borderRightWidth = tableFullStyleObj.getPropertyValue( 'border-right-width' );\n let tableBorderCommon = parseFloat( borderLeftWidth, 10 ) + parseFloat( borderRightWidth, 10 );\n tableTdsSumMaxWidth = tableTdsSumMaxWidthFixed + tableTdsSumMaxWidthAuto + tableBorderCommon;\n \n table.dataset.wptbTableTdsSumMaxWidth = tableTdsSumMaxWidth;\n if( CellsWidthAutoCount ) {\n table.dataset.wptbCellsWidthAutoCount = CellsWidthAutoCount;\n if( table.mergingСellsHorizontally ) {\n table.dataset.wptbFixedWidthSize = tableTdsSumMaxWidthFixed - tableBorderCommon;\n } else {\n table.removeAttribute( 'data-wptb-fixed-width-size' );\n }\n } else {\n table.removeAttribute( 'data-wptb-fixed-width-size' );\n table.removeAttribute( 'data-wptb-cells-width-auto-count' );\n }\n \n let styleElementCreate = false;\n let tableTdWidthAuto;\n if( tableTdsSumMaxWidth < wptbTableSetupWidth ) {\n if( CellsWidthAutoCount ) {\n table.style.minWidth = '100%';\n if( table.mergingСellsHorizontally ) {\n table.style.width = null;\n let tableTdsWidthAutoCommon = wptbTableSetupWidth - tableTdsSumMaxWidthFixed - tableBorderCommon;\n tableTdWidthAuto = tableTdsWidthAutoCommon / CellsWidthAutoCount;\n tableTdWidthAuto = tableTdWidthAuto - tdPaddingCommon - tableTdBorderCommonWidth;\n styleElementCreate = true;\n } else {\n table.style.width = '100%';\n }\n } else {\n table.style.width = null;\n table.style.minWidth = null;\n table.style.maxWidth = tableTdsSumMaxWidth + 'px';\n }\n } else {\n table.style.maxWidth = null;\n table.style.minWidth = tableTdsSumMaxWidth + 'px';\n table.style.width = null;\n tableTdWidthAuto = '100'\n styleElementCreate = true;\n }\n \n let head = document.head;\n if( head ) {\n let cssForTdsWidthAutoOld = head.querySelector( 'style[data-wptb-td-auto-width=\"true\"]' );\n if( cssForTdsWidthAutoOld ) {\n head.removeChild( cssForTdsWidthAutoOld );\n }\n }\n \n if( styleElementCreate ) {\n cssForTdsWidthAuto = document.createElement( 'style' );\n cssForTdsWidthAuto.setAttribute( 'data-wptb-td-auto-width', true );\n cssForTdsWidthAuto.innerHTML = '[data-wptb-css-td-auto-width=true]{width:' + tableTdWidthAuto + 'px}';\n if( head ) {\n head.appendChild( cssForTdsWidthAuto );\n }\n }\n }\n \n table.addRowHeight = function( value, cleaner ) {\n let highlighted = table.getElementsByClassName( 'wptb-highlighted' );\n if( highlighted.length > 0 ) {\n for( let k = 0; k < highlighted.length; k++ ) {\n let dataYIndex = highlighted[k].dataset.yIndex;\n if( dataYIndex ) {\n function tableTdsFor( dataYIndex, rowspan ) {\n let tableRows = table.rows;\n let heightIsSet = false;\n let arrayTdsPrevious = [];\n for( let i = 0; i < tableRows.length; i++ ) {\n let row = tableRows[i];\n let tds = row.children;\n for( let j = 0; j < tds.length; j++ ) {\n let td = tds[j];\n if( td.dataset.yIndex == dataYIndex ) {\n if( value ) {\n if( td.rowSpan == rowspan ) {\n td.style.height = value + 'px';\n td.removeAttribute( 'data-wptb-fixed-heidht' );\n heightIsSet = true;\n let tableColumnHeightAutoFixedCheckbox = document.getElementById( 'wptb-table-row-height-auto-fixed' );\n if( ! tableColumnHeightAutoFixedCheckbox.checked ) {\n tableColumnHeightAutoFixedCheckbox.checked = true;\n }\n continue;\n } else {\n td.style.height = null;\n td.dataset.wptbFixedHeight = value;\n if( j == tds.length - 1 && ! heightIsSet ) {\n tableTdsFor( dataYIndex , rowspan + 1 );\n }\n }\n } else if( cleaner ) {\n td.style.height = null;\n td.removeAttribute( 'data-wptb-fixed-heidht' );\n } else {\n if( td.dataset.wptbFixedHeight ) {\n if( td.rowSpan = rowspan ) {\n td.style.height = td.dataset.wptbFixedHeight + 'px';\n td.removeAttribute( 'data-wptb-fixed-width' );\n }\n } else if( td.style.height ) {\n for( let z = 0; z < arrayTdsPrevious.length; z++ ) {\n arrayTdsPrevious[z].style.height = td.style.height;\n }\n arrayTdsPrevious = [];\n } else {\n arrayTdsPrevious.push( td );\n }\n }\n } \n }\n }\n }\n \n tableTdsFor( dataYIndex, 1 );\n }\n }\n }\n }\n \n table.reconstraction = function() {\n let tds = table.getElementsByTagName( 'td' );\n let wptbAdaptiveTableChoseBlock = document.getElementsByClassName( 'wptb-adaptive-table-chose-block' );\n if( wptbAdaptiveTableChoseBlock.length > 0 ) {\n wptbAdaptiveTableChoseBlock = wptbAdaptiveTableChoseBlock[0];\n }\n table.mergingСellsHorizontally = false;\n table.mergingCellsVertically = false;\n table.dataset.reconstraction = 1;\n wptbAdaptiveTableChoseBlock.style.display = 'block';\n let forBreak = 0;\n for( let i = 0; i < tds.length; i++ ) {\n if( tds[i].colSpan > 1 ) {\n table.dataset.reconstraction = 0;\n wptbAdaptiveTableChoseBlock.style.display = 'none';\n table.mergingСellsHorizontally = true;\n forBreak++;\n }\n \n if( tds[i].rowSpan > 1 ) {\n table.dataset.reconstraction = 0;\n wptbAdaptiveTableChoseBlock.style.display = 'none';\n table.mergingCellsVertically = true;\n forBreak++;\n }\n \n if( forBreak == 2 ) {\n break;\n }\n }\n }\n\n /*\n * As simple as it is: adds a column to the end of table.\n */\n table.addColumnEnd = function () {\n let td,\n currentTable = document.getElementsByClassName('wptb-preview-table'),\n currentTableTd,\n currentTdStyle;\n if (currentTable.length > 0) {\n currentTableTd = currentTable[0].querySelector('td');\n }\n\n if (currentTableTd) {\n currentTdStyle = currentTableTd.getAttribute('style');\n }\n \n for (var i = 0; i < table.rows.length; i++) {\n td = new WPTB_Cell(mark);\n \n if (currentTdStyle) {\n td.getDOMElement().setAttribute('style', currentTdStyle);\n td.getDOMElement().style.width = null;\n td.getDOMElement().style.height = null;\n }\n \n table.rows[i].appendChild(td.getDOMElement());\n array[i].push(0);\n }\n \n maxAmountOfCells++;\n table.recalculateIndexes();\n table.tdDefaultWidth();\n table.addRowHeight();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n /*\n * As simple as it looks: adds a column to the start of table.\n */\n\n table.addColumnStart = function () {\n let td,\n firstCell,\n currentTable = document.getElementsByClassName('wptb-preview-table'),\n currentTableTd,\n currentTdStyle;\n if ( currentTable.length > 0 ) {\n currentTableTd = currentTable[0].querySelector('td');\n }\n\n if ( currentTableTd ) {\n currentTdStyle = currentTableTd.getAttribute('style');\n }\n \n for (var i = 0; i < table.rows.length; i++) {\n td = new WPTB_Cell(mark);\n if (currentTdStyle) {\n td.getDOMElement().setAttribute('style', currentTdStyle);\n td.getDOMElement().style.width = null;\n td.getDOMElement().style.height = null;\n }\n firstCell = table.rows[i].getElementsByTagName('td')[0];\n if (firstCell) {\n table.rows[i].insertBefore(td.getDOMElement(), firstCell);\n } else {\n table.rows[i].appendChild(td.getDOMElement());\n }\n array[i].push(0);\n }\n\n maxAmountOfCells++;\n table.recalculateIndexes();\n table.tdDefaultWidth();\n table.addRowHeight();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n /*\n * Well, not so simple as previous functions.\n * It adds a column after a certain column of reference.\n * @param integer the column number to be used as reference.\n *\tIf empty, then the first highlighted cell is used as reference.\n */\n\n table.addColumnAfter = function (c_pos) {\n let rows = table.rows,\n cellPointer,\n cellsBuffer,\n cell = document.querySelector('.wptb-highlighted'),\n cellStyle = cell.getAttribute('style'),\n pos = c_pos != undefined && typeof c_pos === 'number' ? c_pos : getCoords(cell)[1];\n \n \n \n if( maxAmountOfCells - pos - cell.colSpan + 1 == 1 ) {\n table.addColumnEnd();\n } else {\n let pendingInsertion = false,\n stepsToMove,\n td, bro,\n carriedRowspans = [],\n currentCell;\n\n for (var i = 0; i < maxAmountOfCells; i++) {\n carriedRowspans.push(0);\n }\n\n for (var i = 0; i < rows.length; i++) {\n cellPointer = 0;\n cellsBuffer = rows[i].getElementsByTagName('td');\n pendingInsertion = false;\n for (var xPosition = 0;\n xPosition < maxAmountOfCells;\n xPosition += stepsToMove) {\n stepsToMove = 1;\n\n if (pendingInsertion) {\n td = new WPTB_Cell(mark);\n if (cellStyle) {\n td.getDOMElement().setAttribute('style', cellStyle);\n td.getDOMElement().style.width = null;\n td.getDOMElement().style.height = null;\n }\n if (currentCell && rows[i].contains(currentCell)) {\n bro = currentCell.nextSibling;\n if (bro) {\n rows[i].insertBefore(td.getDOMElement(), bro);\n } else {\n rows[i].appendChild(td.getDOMElement());\n }\n } else {\n rows[i].insertBefore(td.getDOMElement(), cellsBuffer[0]);\n }\n break;\n } else if (carriedRowspans[xPosition] > 0) {\n // If no pending insertion, let's check if no rowspan from upper cells is pending in current position\n if (pos == xPosition) {\n pendingInsertion = true;\n }\n } else {\n currentCell = cellsBuffer[cellPointer++];\n if (currentCell.rowSpan > 1) {\n stepsToMove = currentCell.colSpan;\n for (var k = 0; k < currentCell.colSpan; k++) {\n carriedRowspans[xPosition + k] = currentCell.rowSpan;\n if (xPosition + k == pos) {\n pendingInsertion = true;\n }\n }\n } else if (currentCell.colSpan > 1) {\n stepsToMove = currentCell.colSpan;\n for (var k = 0; k < currentCell.colSpan; k++) {\n if (xPosition + k == pos) {\n pendingInsertion = true;\n }\n }\n } else if (xPosition == pos) {\n pendingInsertion = true;\n }\n }\n }\n\n for (var l = 0; l < maxAmountOfCells; l++) {\n if (carriedRowspans[l] > 0)\n carriedRowspans[l]--;\n }\n\n }\n\n for (var i = 0; i < array.length; i++) {\n array[i].push(0);\n }\n maxAmountOfCells++;\n drawTable(array);\n table.recalculateIndexes();\n table.addColumnWidth();\n table.addRowHeight();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n };\n\n /*\n * For preventing us to take a lot of time,\n * This is just calling the function addColumnAfter, but\n * using the previous column to current one as reference.\n * @see addColumnAfter\n */\n\n table.addColumnBefore = function () {\n var cell = document.querySelector('.wptb-highlighted'),\n pos = getCoords(cell)[1];\n\n if (pos === 0) {\n table.addColumnStart();\n } else {\n table.addColumnAfter(pos - 1);\n }\n };\n\n /*\n * Luckily, thisfunction is simple, \n * it just add a row to the end of table.\n */\n\n table.addRowToTheEnd = function () {\n let r = table.insertRow(-1),\n td,\n aux,\n currentTable = document.getElementsByClassName('wptb-preview-table');\n r.classList.add( 'wptb-row' );\n if (currentTable.length > 0) {\n currentTable = currentTable[0];\n \n for (var i = 0; i < maxAmountOfCells; i++) {\n td = new WPTB_Cell(mark);\n let currentTableTd = currentTable.querySelector('[data-x-index=\"' + i + '\"]');\n if( currentTableTd ) {\n let currentTdStyle = currentTableTd.getAttribute( 'style' );\n \n td.getDOMElement().setAttribute( 'style', currentTdStyle );\n td.getDOMElement().style.height = null;\n }\n r.appendChild(td.getDOMElement());\n }\n \n aux = Array.from(array[0]);\n array.push(aux);\n drawTable(array);\n table.recalculateIndexes();\n table.addColumnWidth();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n };\n\n /*\n * Yet another simple function, \n * it just add a row to the start of table.\n */\n\n table.addRowToTheStart = function () {\n let r = table.insertRow(0),\n td,\n aux,\n currentTable = document.getElementsByClassName('wptb-preview-table'),\n currentTableTd,\n currentTdStyle;\n r.classList.add( 'wptb-row' );\n if (currentTable.length > 0) {\n currentTable = currentTable[0];\n \n for (var i = 0; i < maxAmountOfCells; i++) {\n td = new WPTB_Cell(mark);\n let currentTableTd = currentTable.querySelector('[data-x-index=\"' + i + '\"]');\n if( currentTableTd ) {\n let currentTdStyle = currentTableTd.getAttribute( 'style' );\n \n td.getDOMElement().setAttribute( 'style', currentTdStyle );\n td.getDOMElement().style.height = null;\n }\n r.appendChild(td.getDOMElement());\n }\n \n aux = Array.from(array[0]);\n array.push(aux);\n drawTable(array);\n table.recalculateIndexes();\n table.addColumnWidth();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n };\n\n /* \n * This function adds a row before the current one.\n * Since the biggest factor of problem is a not-started but ongoing rowspan,\n * the most of the troubles is not here.\n */\n\n table.addRowBefore = function () {\n let cell = document.querySelector('.wptb-highlighted'),\n cellStyle = cell.getAttribute('style'),\n row = getCoords(cell)[0],\n cellNew;\n for( let i = row - 1; i >= 0; i-- ) {\n let rowChildren = table.rows[i].children;\n let rowChildrenLength = rowChildren.length;\n if( rowChildrenLength > 0 ) {\n for( let j = 0; j < rowChildrenLength; j++ ) {\n if( rowChildren[j].rowSpan == 1 ) {\n row = i;\n cellNew = true;\n break;\n }\n }\n }\n if ( cellNew ) {\n break;\n }\n }\n\n if (row === 0) {\n table.addRowToTheStart();\n } else {\n table.addRowAfter( row, cellStyle );\n }\n };\n\n /*\n * Well... by the name convention of the previous 3 functions,\n * it's pretty obvious that this functions attaches a new\n * row after highlighted cell row. The greatest obstacle it was\n * the possibility of a TR not having the exact amount of columns\n * occuped by actual node but rowspanned upper cells. For that purpose\n * it was created the function realTimeArray.\n * @see realTimeArray\n */\n\n table.addRowAfter = function ( row, cellStyle ) {\n let cellRowSpan,\n rowAfter,\n aux;\n \n if ( ( row == undefined || typeof row !== 'number' ) && cellStyle == undefined ) {\n let cell = document.querySelector('.wptb-highlighted');\n cellStyle = cell.getAttribute('style'),\n row = getCoords(cell)[0],\n cellRowSpan = cell.rowSpan,\n rowAfter = row + cellRowSpan - 1;\n } else {\n rowAfter = row;\n }\n \n \n let cellsColSpan = 0;\n if ( rowAfter < table.rows.length -1 ) {\n for( let i = 0; i <= rowAfter ; i++ ) {\n let tableRowsIChildren = table.rows[i].children,\n tableRIChildrenLength = tableRowsIChildren.length;\n if( tableRIChildrenLength > 0 ) {\n for( let j = 0; j < tableRIChildrenLength; j++ ) {\n let rowIRowSpan = tableRowsIChildren[j].rowSpan;\n\n if ( rowIRowSpan - 1 + i > rowAfter ) {\n tableRowsIChildren[j].rowSpan++;\n }\n }\n }\n }\n \n let rNext = table.rows[rowAfter + 1],\n rNextChildren = rNext.children,\n rNextChildrenLength = rNextChildren.length;\n \n if( rNextChildrenLength > 0 ) {\n for ( let i = 0; i < rNextChildrenLength; i++ ) {\n cellsColSpan += rNextChildren[i].colSpan;\n }\n }\n } else {\n cellsColSpan = array[0].length;\n }\n \n let r = table.insertRow( rowAfter + 1 );\n r.classList.add( 'wptb-row' );\n \n for ( j = 0; j < cellsColSpan; j++ ) {\n let td = new WPTB_Cell( mark );\n td.getDOMElement().setAttribute( 'style', cellStyle );\n td.getDOMElement().style.width = null;\n td.getDOMElement().style.height = null;\n r.appendChild( td.getDOMElement() );\n }\n\n aux = Array.from(array[0]);\n array.push(aux);\n drawTable(array);\n table.recalculateIndexes();\n table.addColumnWidth();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n /*\n * This function checks the current selected cells\n * make a rectangular shape.\n * @param Array the abstract table.\n * @return false, if not making a rectangle, or\n *\tArray an array containing number of rows and columns, if selection makes a rectangle.\n */\n\n table.isSquare = function (a) {\n var rowStart = -1,\n columnStart = -1,\n rowEnd = -1,\n columnEnd = -1,\n height,\n width,\n itemsEstimate = 0,\n items = 0;\n\n for (var i = 0; i < a.length; i++) {\n for (var j = 0; j < a[i].length; j++) {\n if (a[i][j] == 1) {\n if ( j < columnStart || columnStart == -1 ) {\n columnStart = j;\n }\n if ( i < rowStart || rowStart == -1 ) {\n rowStart = i;\n }\n }\n }\n \n }\n\n for (var i = a.length - 1; i > -1; i--) {\n for (var j = a[i].length - 1; j > -1; j--) {\n if (a[i][j] == 1) {\n if ( j > columnEnd ) {\n columnEnd = j;\n }\n if ( i > rowEnd ) {\n rowEnd = i;\n }\n }\n }\n }\n\n for (var i = rowStart; i < rowEnd; i++) {\n for (var j = columnStart; j < columnEnd; j++) {\n if (a[i][j] == 0 || a[i][j] == undefined) {\n return false;\n }\n }\n }\n\n for (var i = 0; i < a.length; i++) {\n for (var j = 0; j < a[i].length; j++) {\n if (a[i][j] == 1) {\n items++;\n }\n }\n }\n\n height = rowEnd - rowStart + 1;\n width = columnEnd - columnStart + 1;\n itemsEstimate = height * width;\n\n if (itemsEstimate !== items) {\n return false;\n }\n return [height, width];\n };\n\n /*\n * This function merges all selected cells.\n * Well, actually sets the colspan and rowspan of first \n * upper left cell in selection and deletes the another selected cells.\n */\n\n table.mergeCells = function () {\n var dimensions = table.isSquare(array),\n rowspan = dimensions[0],\n colspan = dimensions[1],\n first = document.querySelector('.wptb-highlighted'),\n tds = [].slice.call(document.getElementsByClassName('wptb-highlighted'), 1),\n tdsChildrenNew = [];\n\n for (let i = 0; i < tds.length; i++) {\n let tdsInternalElements = tds[i].getElementsByClassName('wptb-ph-element');\n if (tdsInternalElements.length > 0) {\n let tdsIntElemLength = tdsInternalElements.length;\n for (let j = 0; j < tdsIntElemLength; j++) {\n tdsChildrenNew.push(tdsInternalElements[j]);\n }\n }\n let p = tds[i].parentNode;\n p.removeChild(tds[i]);\n }\n if (tdsChildrenNew.length > 0) {\n for (let i = 0; i < tdsChildrenNew.length; i++) {\n first.appendChild(tdsChildrenNew[i]);\n }\n }\n\n first.colSpan = colspan;\n first.rowSpan = rowspan;\n table.recalculateIndexes();\n table.reconstraction();\n let firstWidth = first.style.width;\n let firstDataFixedWidth = first.dataset.wptbFixedWidth;\n if( firstWidth ) {\n table.addColumnWidth( parseFloat( firstWidth, 10 ) );\n } else if( firstDataFixedWidth ) {\n table.addColumnWidth();\n } else {\n table.addColumnWidth( false, true );\n }\n \n let firstHeight = first.style.height;\n let firstDataFixedHeight = first.dataset.wptbFixedHeight;\n if( firstHeight ) {\n table.addRowHeight( parseFloat( firstHeight, 10 ) );\n } else if( firstDataFixedHeight ) {\n table.addRowHeight();\n } else {\n table.addRowHeight( false, true );\n }\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n /*\n * This functions makes the exact inverse as above.\n * It resets colspan and rowspan and appends \n * the same amount in cells to the table.\n * @bug\n */\n\n table.splitCell = function () {\n var cell = document.getElementsByClassName('wptb-highlighted')[0],\n rowspan = cell.rowSpan,\n colspan = cell.colSpan,\n cellStyles = cell.getAttribute('style'),\n row = getCoords(cell)[0],\n thisRow = table.rows[row],\n cellXIndex =cell.dataset.xIndex;\n \n cell.rowSpan = 1;\n cell.colSpan = 1;\n \n for (let i = 1; i < colspan; i++) {\n let td = new WPTB_Cell(mark);\n td.getDOMElement().setAttribute('style', cellStyles);\n td.getDOMElement().classList.add( 'wptb-highlighted' );\n if ( cell.nextSibling ) {\n thisRow.insertBefore( td.getDOMElement(), cell.nextSibling );\n } else {\n thisRow.appendChild( td.getDOMElement() );\n }\n \n }\n\n if (rowspan > 1) {\n for (let i = 1; i < rowspan; i++) {\n let rowChildInsertBefore = undefined,\n rowNext = table.rows[row + i],\n rowChildren = rowNext.children,\n rowChildrenLength = rowChildren.length;\n \n if ( rowChildrenLength > 0 ) {\n for ( let k = 0; k < rowChildrenLength; k++ ) {\n if ( Number( rowChildren[k].dataset.xIndex ) > Number( cellXIndex ) ) {\n rowChildInsertBefore = rowChildren[k];\n break;\n } \n }\n }\n for ( let j = 0; j < colspan; j++ ) {\n let td = new WPTB_Cell( mark );\n td.getDOMElement().setAttribute( 'style', cellStyles );\n if ( rowChildInsertBefore != undefined ) {\n rowNext.insertBefore( td.getDOMElement(), rowChildInsertBefore );\n } else {\n rowNext.appendChild( td.getDOMElement() );\n }\n }\n }\n }\n\n table.recalculateIndexes();\n table.reconstraction();\n table.addColumnWidth();\n table.addRowHeight();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n /*\n * Searches for rowspanned cells up to row number meeting it.\n * @param number the number of row where the function\n * must search up to.\n */\n\n table.findRowspannedCells = function (row) {\n var array = [],\n difference;\n actualPoints = getActualPointsInRow(row);\n if (actualPoints === maxAmountOfCells) {\n return [];\n }\n difference = maxAmountOfCells - actualPoints;\n\n for (var i = row - 1; i >= 0 && difference; i--) {\n var tds = table.rows[i].getElementsByTagName('td');\n for (var i = 0; i < tds.length; i++) {\n if (tds[i].rowSpan > 1) {\n array.push(tds[i]);\n difference -= tds[i].colSpan;\n }\n }\n }\n return array;\n\n }\n\n /*\n * This function explores the table and adds \n * a cell for each lacking one for each row\n * to meet an even amount of cells.\n */\n\n table.addLackingCells = function () {\n var sumRows = [];\n for (var i = 0; i < table.rows.length; i++) {\n sumRows.push(0);\n }\n\n for (var i = 0; i < table.rows.length; i++) {\n var tds = table.rows[i].getElementsByTagName('td');\n for (var j = 0; j < tds.length; j++) {\n if (tds[j].rowSpan > 1) {\n for (var k = 1; k < tds[j].rowSpan; k++) {\n sumRows[i + k]++;\n }\n }\n }\n }\n\n for (var i = 0; i < table.rows.length; i++) {\n var tds = table.rows[i].getElementsByTagName('td'),\n totalColspan = 0;\n for (var j = 0; j < tds.length; j++) {\n totalColspan += tds[j].colSpan;\n }\n totalColspan += sumRows[i];\n difference = maxAmountOfCells - totalColspan;\n for (var j = 0; j < difference; j++) {\n var td = new WPTB_Cell(mark);\n table.rows[i].appendChild(td.getDOMElement());\n //table.rows[i].insertBefore( td.getDOMElement(), rows[i].nextSibling );\n }\n }\n };\n\n /*\n * This function deletes the row of currently\n * selected cell. \n */\n\n table.deleteRow = function () {\n let cell = document.querySelector('.wptb-highlighted'),\n cellStyles = cell.getAttribute('style'),\n rowspan = cell.rowSpan,\n row = getCoords(cell)[0],\n thisRow,\n aux;\n \n if ( rowspan == undefined ) rowspan = 1;\n \n for ( let i = 0; i < rowspan; i++ ) {\n thisRow = table.rows[row];\n let thisRowChildren = thisRow.children,\n nextRow = table.rows[row + 1],\n nextRowChildren,\n nextRowChildrenLength,\n tdArr = [];\n\n if( nextRow != undefined ) {\n nextRowChildren = nextRow.children;\n nextRowChildrenLength = nextRowChildren.length;\n for (let j = 0; j < thisRowChildren.length; j++) {\n if ( thisRowChildren[j].rowSpan > 1 ) {\n let td = new WPTB_Cell(mark);\n td.getDOMElement().setAttribute('style', cellStyles);\n td.getDOMElement().colSpan = thisRowChildren[j].colSpan;\n td.getDOMElement().rowSpan = thisRowChildren[j].rowSpan - 1;\n\n let nextRowChildrenK = undefined;\n for ( let k = 0; k < nextRowChildrenLength; k++ ) {\n if ( Number( nextRowChildren[k].dataset.xIndex ) > Number( thisRowChildren[j].dataset.xIndex ) ) {\n nextRowChildrenK = nextRowChildren[k];\n break;\n } \n }\n\n if ( nextRowChildrenK ) {\n tdArr.push( [td, nextRowChildrenK] );\n } else {\n tdArr.push( [td] );\n }\n }\n }\n\n if ( tdArr.length > 0 ) {\n for ( let k = 0; k < tdArr.length; k++ ) {\n if ( tdArr[k][1] != undefined ) {\n nextRow.insertBefore( tdArr[k][0].getDOMElement(), tdArr[k][1] );\n } else {\n nextRow.appendChild( tdArr[k][0].getDOMElement() );\n }\n }\n }\n }\n \n let tableRows = table.rows;\n if ( tableRows.length > 0 ) {\n for ( let j = 0; j < row; j++ ) {\n let jRowChildren = tableRows[j].children;\n if ( jRowChildren.length > 0 ) {\n for ( let x = 0; x < jRowChildren.length; x++ ) {\n if ( jRowChildren[x].rowSpan - 1 >= row - j ) {\n jRowChildren[x].rowSpan--;\n }\n }\n }\n }\n }\n aux = Array.from(array[0]);\n array.pop(aux);\n drawTable(array);\n table.getElementsByTagName('tbody')[0].removeChild(table.rows[row]);\n \n if( table.rows.length == 0 ) {\n table.toggleTableEditMode();\n wptbTableSetup.innerHTML = '';\n WPTB_Helper.settingsPanelClear();\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\n }\n \n table.recalculateIndexes();\n WPTB_Helper.dataTitleColumnSet( table );\n }\n \n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n\n /*\n * This function deletes the column of currently\n * selected cell. Again, this is way more complicated than\n * delete row case.\n */\n\n table.deleteColumn = function () {\n let cell = document.querySelector('.wptb-highlighted'),\n cellXIndex = cell.dataset.xIndex,\n colspan = cell.colSpan;\n \n for ( let i = 0; i < colspan; i++ ) {\n for ( let j = 0; j < table.rows.length; j++ ) {\n let rowChildren = table.rows[j].children;\n let rowChildrenLength = rowChildren.length;\n if( rowChildrenLength > 0 ) {\n for ( let k = rowChildrenLength - 1; k >= 0; k-- ) {\n if ( Number( rowChildren[k].dataset.xIndex ) == Number( cellXIndex ) ) {\n if ( rowChildren[k].colSpan > 1 ) {\n rowChildren[k].colSpan--;\n } else {\n table.rows[j].removeChild( rowChildren[k] );\n }\n break;\n } else if( Number( rowChildren[k].dataset.xIndex ) < Number( cellXIndex ) && \n Number( rowChildren[k].dataset.xIndex ) + \n Number( rowChildren[k].colSpan -1 ) >= cellXIndex ) {\n if ( rowChildren[k].colSpan > 1 ) {\n rowChildren[k].colSpan--;\n }\n break;\n }\n }\n }\n }\n \n for ( let j = 0; j < table.rows.length; j++ ) {\n if (array[j] != undefined)\n array[j].pop();\n }\n \n maxAmountOfCells--;\n \n if( table.querySelectorAll( 'td' ).length == 0 ) {\n table.toggleTableEditMode();\n wptbTableSetup.innerHTML = '';\n WPTB_Helper.settingsPanelClear();\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\n }\n \n table.recalculateIndexes();\n table.tdDefaultWidth();\n WPTB_Helper.dataTitleColumnSet( table );\n }\n \n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'none';\n\n array = fillTableArray();\n\n undoSelect();\n drawTable(array);\n\n wptbTableSetup.appendChild(table);\n //if (columns || rows) {\n table.recalculateIndexes( true );\n //}\n table.reconstraction();\n table.tdDefaultWidth();\n \n wptbTableSetup.onresize = function() {\n table.tdDefaultWidth();\n };\n\n WPTB_LeftPanel();\n \n // this code gets the ID of the active element in the toolbar \n // and stores it in the data attribute of the common container element \"wpcd_fixed_toolbar\"\n// let wptbPhElement = document.getElementsByClassName( 'wptb-ph-element' );\n// let wpcdFixedToolbar = document.getElementById( 'wpcd_fixed_toolbar' );\n// for ( let i = 0; i < wptbPhElement.length; i++ ) {\n// wptbPhElement[i].addEventListener( 'click', function( e ) {\n// let wptbToolbar = document.getElementById( 'wpcd_fixed_toolbar' ).children;\n// for ( let j = 0; j < wptbToolbar.length; j++ ) {\n// let elementStyles = window.getComputedStyle( wptbToolbar[j], 'null' );\n// if( elementStyles.getPropertyValue( 'display' ) == 'block' ) {\n// wpcdFixedToolbar.dataset.toolbarActiveId = wptbToolbar[j].getAttribute( 'id' );\n// }\n// }\n// }, false );\n// }\n \n// let wptbPanelLeft = document.getElementsByClassName( 'wptb-panel-left' );\n// if( wptbPanelLeft.length > 0 ) {\n// wptbPanelLeft[0].addEventListener( 'click', function( e ) {\n// let toolbarActiveElementId = wpcdFixedToolbar.dataset.toolbarActiveId;\n// document.getElementById( toolbarActiveElementId ).style.display = '';\n// }, false );\n// }\n \n// let body = document.getElementsByTagName( 'body' );\n// if( body.length > 0 ) {\n// body[0].addEventListener( 'click', function( e ) {\n// if ( e.target.classList.contains( 'wptb-panel-left' ) || WPTB_Helper.findAncestor( e.target, 'wptb-panel-left' ) ) {\n// let toolbarActiveElementId = wpcdFixedToolbar.dataset.toolbarActiveId;\n// document.getElementById( toolbarActiveElementId ).style.display = '';\n// }\n// }, false );\n// }\n};","var WPTB_TableStateSaveManager = function() {\n this.tableStateSet = () => {\n // get preview table\n let wptbPreviewTable = document.getElementsByClassName( 'wptb-preview-table' );\n if( wptbPreviewTable.length > 0 ) {\n wptbPreviewTable = wptbPreviewTable[0];\n \n // check if a global array doesn't exist with saved versions of the table \n // them create it\n if( ! window.wptbTableStateSaving ) {\n window.wptbTableStateSaving = [];\n } \n \n // remove the extra part of the array after changing the table \n // when it is showed in the not last modified version\n if( window.wptbTableStateSaving.length > window.wptbTableStateNumberShow + 1 ) {\n window.wptbTableStateSaving = window.wptbTableStateSaving.slice( 0, window.wptbTableStateNumberShow + 1 );\n }\n \n //add new state of table\n let wptbNewPreviewTable = wptbPreviewTable.cloneNode( true );\n let wptbHighlighted = wptbNewPreviewTable.getElementsByClassName( 'wptb-highlighted' );\n for( let i = 0; i < wptbHighlighted.length; i++ ) {\n wptbHighlighted[i].classList.remove( 'wptb-highlighted' );\n }\n let wptbDirectlyhovered = wptbNewPreviewTable.getElementsByClassName( 'wptb-directlyhovered' );\n for( let i = 0; i < wptbDirectlyhovered.length; i++ ) {\n wptbDirectlyhovered[i].classList.remove( 'wptb-directlyhovered' );\n }\n \n let cssForTdsWidthAutoValue = '';\n let head = document.head;\n if( head ) {\n let cssForTdsWidthAuto = head.querySelector( 'style[data-wptb-td-auto-width=\"true\"]' );\n if( cssForTdsWidthAuto ) {\n cssForTdsWidthAutoValue = cssForTdsWidthAuto.innerHTML;\n }\n }\n \n let wptbDlementDatas = document.getElementsByClassName( 'wptb-element-datas' );\n if( wptbDlementDatas.length > 0 ) {\n wptbDlementDatas = wptbDlementDatas.innerHTML;\n } else {\n wptbDlementDatas = '';\n }\n \n let mceContentBodys = wptbNewPreviewTable.querySelectorAll( '.mce-content-body' );\n if( mceContentBodys.length > 0 ) {\n for ( let k = 0; k < mceContentBodys.length; k++ ) {\n mceContentBodys[k].classList.remove( 'mce-content-body' );\n }\n }\n\n let dataMceStyle = wptbNewPreviewTable.querySelectorAll( '[data-mce-style]' );\n if ( dataMceStyle.length > 0 ) {\n for ( let k = 0; k < dataMceStyle.length; k++ ) {\n dataMceStyle[k].removeAttribute( 'data-mce-style' );\n }\n }\n\n let mceIds = wptbNewPreviewTable.querySelectorAll( '[id^=mce_]' );\n if ( mceIds.length > 0 ) {\n for ( let k = 0; k < mceIds.length; k++ ) {\n mceIds[k].removeAttribute( 'id' );\n }\n }\n \n window.wptbTableStateSaving.push( [wptbNewPreviewTable, cssForTdsWidthAutoValue, wptbDlementDatas] );\n \n // set new number of state which is showed now\n window.wptbTableStateNumberShow = window.wptbTableStateSaving.length - 1;\n \n // make undo arrow active when the table was changed\n if( window.wptbTableStateSaving.length > 1 ) {\n let wptbUndo = document.getElementsByClassName( 'wptb-undo' );\n if( wptbUndo.length > 0 ) {\n wptbUndo = wptbUndo[0];\n\n wptbUndo.classList.remove( 'wptb-undoredo-disabled' );\n }\n }\n \n // make redo arrow not active when the table was changed\n let wptbRedo = document.getElementsByClassName( 'wptb-redo' );\n if( wptbRedo.length > 0 ) {\n wptbRedo = wptbRedo[0];\n \n wptbRedo.classList.add( 'wptb-undoredo-disabled' );\n }\n \n let wptbSaveBtn = document.getElementsByClassName( 'wptb-save-btn' );\n if( wptbSaveBtn.length > 0 ) {\n wptbSaveBtn = wptbSaveBtn[0];\n if( ( ! wptbSaveBtn.dataset.wptbTableStateNumberSave && window.wptbTableStateNumberShow == 0 ) || \n window.wptbTableStateNumberShow == wptbSaveBtn.dataset.wptbTableStateNumberSave ) {\n wptbSaveBtn.classList.add( 'wptb-save-disabled' );\n } else {\n wptbSaveBtn.classList.remove( 'wptb-save-disabled' );\n }\n }\n }\n }\n \n this.tableStateGet = ( datawptbUndoredo ) => {\n if( datawptbUndoredo && window.wptbTableStateSaving && window.wptbTableStateSaving.length > 1 ) {\n \n // changes the number of the state which displays now\n if( datawptbUndoredo == 'undo' ) {\n if( window.wptbTableStateNumberShow > 0 ) {\n window.wptbTableStateNumberShow--;\n } else {\n return false;\n }\n } else if( datawptbUndoredo == 'redo' ) {\n if( window.wptbTableStateNumberShow < window.wptbTableStateSaving.length - 1 ) {\n window.wptbTableStateNumberShow++;\n } else {\n return false;\n }\n }\n \n // add or delete class \"wptb-undoredo-disabled\" for undo button\n let wptbUndo = document.getElementsByClassName( 'wptb-undo' );\n if( wptbUndo.length > 0 ) {\n wptbUndo = wptbUndo[0];\n }\n if( window.wptbTableStateNumberShow == 0 ) {\n if( wptbUndo ) {\n wptbUndo.classList.add( 'wptb-undoredo-disabled' )\n }\n } else if( window.wptbTableStateNumberShow > 0 ) {\n if( wptbUndo ) {\n wptbUndo.classList.remove( 'wptb-undoredo-disabled' )\n }\n }\n \n // add or delete class \"wptb-undoredo-disabled\" for redo button\n let wptbRedo = document.getElementsByClassName( 'wptb-redo' );\n if( wptbRedo.length > 0 ) {\n wptbRedo = wptbRedo[0];\n }\n if( window.wptbTableStateNumberShow == window.wptbTableStateSaving.length - 1 ) {\n if( wptbRedo ) {\n wptbRedo.classList.add( 'wptb-undoredo-disabled' )\n }\n } else if( window.wptbTableStateNumberShow < window.wptbTableStateSaving.length - 1 ) {\n if( wptbRedo ) {\n wptbRedo.classList.remove( 'wptb-undoredo-disabled' )\n }\n }\n \n let wptbSaveBtn = document.getElementsByClassName( 'wptb-save-btn' );\n if( wptbSaveBtn.length > 0 ) {\n wptbSaveBtn = wptbSaveBtn[0];\n if( ( ! wptbSaveBtn.dataset.wptbTableStateNumberSave && window.wptbTableStateNumberShow == 0 ) || \n window.wptbTableStateNumberShow == wptbSaveBtn.dataset.wptbTableStateNumberSave ) {\n wptbSaveBtn.classList.add( 'wptb-save-disabled' );\n } else {\n wptbSaveBtn.classList.remove( 'wptb-save-disabled' );\n }\n }\n \n // load necessary saved table state\n let wptbTableSetup = document.getElementsByClassName( 'wptb-table-setup' );\n if( wptbTableSetup.length > 0 ) {\n wptbTableSetup = wptbTableSetup[0];\n\n wptbTableSetup.innerHTML = '';\n wptbTableSetup.innerHTML = window.wptbTableStateSaving[window.wptbTableStateNumberShow][0].outerHTML;\n\n if( window.wptbTableStateSaving[window.wptbTableStateNumberShow][1] ) {\n let cssForTdsWidthAuto = document.createElement( 'style' );\n cssForTdsWidthAuto.setAttribute( 'data-wptb-td-auto-width', true );\n cssForTdsWidthAuto.innerHTML = window.wptbTableStateSaving[window.wptbTableStateNumberShow][1];\n let head = document.head;\n if( head ) {\n let cssForTdsWidthAutoOld = head.querySelector( 'style[data-wptb-td-auto-width=\"true\"]' );\n if( cssForTdsWidthAutoOld ) {\n head.removeChild( cssForTdsWidthAutoOld );\n }\n head.appendChild( cssForTdsWidthAuto );\n }\n }\n \n \n let wptbElementDatas = document.getElementsByClassName( 'wptb-element-datas' );\n let body = document.getElementsByTagName( 'body' );\n if( body.length > 0 ) {\n body = body[0];\n }\n if( window.wptbTableStateSaving[window.wptbTableStateNumberShow][2] ) {\n wptbElementDatas.innerHTML = window.wptbTableStateSaving[window.wptbTableStateNumberShow][2];\n \n if( wptbElementDatas.length > 0 ) {\n wptbElementDatas = wptbElementDatas[0];\n } else {\n wptbElementDatas = document.createElement( 'div' );\n wptbElementDatas.classList.add( 'wptb-element-datas' );\n body.appendChild( wptbElementDatas );\n }\n } else {\n if( wptbElementDatas.length > 0 ) {\n wptbElementDatas = wptbElementDatas[0];\n body.removeChild( wptbElementDatas );\n }\n }\n\n WPTB_Helper.settingsPanelClear();\n WPTB_Helper.elementOptionsPanelClear();\n WPTB_LeftPanel();\n\n let wptbLeftScrollPanelCellSetting = document.getElementById( 'wptb-left-scroll-panel-cell-settings' ); \n if( wptbLeftScrollPanelCellSetting ) {\n wptbLeftScrollPanelCellSetting.classList.remove( 'visible' );\n }\n }\n }\n }\n}","var WPTB_innerElementSet = function ( element ) {\n \n element.ondragenter = function (e) {\n var div;\n if ( e.dataTransfer.types.indexOf( 'wptbelement' ) == -1 && e.dataTransfer.types.indexOf( 'wptb-moving-mode' ) == -1 ) {\n return;\n }\n WPTB_DropHandle(this, e);\n \n element.classList.add( 'wptb-ondragenter' );\n }\n element.ondragover = function (e) {\n e.preventDefault();\n WPTB_DropHandle(this, e);\n }\n element.ondragleave = function () {\n \n }\n element.ondrop = function(e) {\n this.classList.remove( 'wptb-ondragenter' );\n let element, classId;\n e.preventDefault();\n e.stopPropagation();\n\n if (!e.dataTransfer.getData('wptbElement') && !e.dataTransfer.getData('node')) {\n return;\n }\n let wptbDropHandle,\n wptbDropBorderMarker;\n if ( document.getElementsByClassName( 'wptb-drop-handle' ).length > 0 ) {\n wptbDropHandle = document.getElementsByClassName( 'wptb-drop-handle' )[0];\n }\n if( document.getElementsByClassName( 'wptb-drop-border-marker' ).length > 0 ) {\n wptbDropBorderMarker = document.getElementsByClassName( 'wptb-drop-border-marker' )[0];\n }\n\n if ( e.dataTransfer.getData( 'wptbElement' ) ) {\n element = WPTB_Helper.newElementProxy( e.dataTransfer.getData( 'wptbElement' ) );\n element = element.getDOMElement();\n } else {\n classId = e.dataTransfer.getData( 'node' );\n element = document.getElementsByClassName( classId )[0];\n //element.classList.remove( 'wptb-moving-mode' );\n }\n \n if( wptbDropHandle.style.display == 'block' ) {\n let td;\n if( wptbDropHandle.dataset.text == 'Drop Here' ) {\n td = wptbDropHandle.getDOMParentElement();\n td.appendChild( element );\n } else {\n let innerElement = wptbDropHandle.getDOMParentElement();\n td = innerElement.parentNode;\n\n if( wptbDropHandle.dataset.text == 'Above Element' ) {\n td.insertBefore( element, innerElement );\n } else if( wptbDropHandle.dataset.text == 'Below Element' ) {\n let innerElementNext = innerElement.nextSibling;\n td.insertBefore( element, innerElementNext );\n }\n }\n let thisRow = td.parentNode\n if( thisRow.classList.contains( 'wptb-table-head' ) ) {\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\n WPTB_Helper.dataTitleColumnSet( table );\n }\n \n // start item javascript if item is new\n let infArr = element.className.match(/wptb-element-(.+)-(\\d+)/i);\n let elemKind = infArr[1];\n if ( e.dataTransfer.getData( 'wptbElement' ) && ( elemKind == 'text' || elemKind == 'button' || elemKind == 'image' || elemKind == 'star_rating' || elemKind == 'list' ) ) {\n //WPTB_Helper.elementStartScript( element );\n }\n } else {\n return;\n }\n \n wptbDropHandle.style.display = 'none';\n wptbDropBorderMarker.style.display = 'none';\n\n WPTB_innerElementSet( element );\n \n if( ! element.classList.contains( 'wptb-image-container' ) || element.classList.contains( 'wptb-moving-mode' ) ) {\n element.classList.remove( 'wptb-moving-mode' );\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n } \n return true;\n }\n element.onmouseover = function(e) {\n element.classList.remove( 'wptb-ondragenter' );\n }\n}","var applyGenericItemSettings = function ( element, kindIndexProt, copy = false ) {\n var node = element.getDOMElement(),\n index,\n copy;\n if( node.classList.contains( 'wptb-ph-element' ) ) {\n if ( kindIndexProt == undefined || copy == true ) {\n index = document.counter.nextIndex( element.kind );\n let wptbElements = document.getElementsByClassName( 'wptb-ph-element' );\n let elementIndexesArr = [];\n for( let i = 0; i < wptbElements.length; i++ ) {\n var regex = new RegExp( 'wptb-element-' + element.kind + '-(\\\\d+)', \"i\" );\n let infArr = wptbElements[i].className.match( regex );\n if( infArr ) {\n elementIndexesArr.push( infArr[1] );\n }\n }\n if( elementIndexesArr.length > 0 ) {\n let elementIndexMax = Math.max( ...elementIndexesArr );\n index = elementIndexMax + 1;\n } else { \n index = 1;\n }\n\n if( copy ) {\n // change all data-elements which save parameters for different controls\n let wptbNodeattributes = [...node.attributes];\n for( let i = 0; i < wptbNodeattributes.length; i++ ) {\n if( wptbNodeattributes[i] && typeof wptbNodeattributes[i] === 'object' && wptbNodeattributes[i].nodeName ) {\n let regularText = new RegExp( 'data-wptb-el-' + element.kind + '-(\\\\d+)-(.+)', \"i\" );\n let attr = wptbNodeattributes[i].nodeName.match( regularText );\n if( attr && Array.isArray( attr ) ) {\n let newDataAttributeName = wptbNodeattributes[i].nodeName.replace( element.kind + '-' + attr[1], element.kind + '-' + index );\n let newDataAttributeValue = wptbNodeattributes[i].nodeValue;\n node.removeAttribute( wptbNodeattributes[i].nodeName );\n node.setAttribute( newDataAttributeName, newDataAttributeValue );\n }\n }\n }\n }\n } else if ( kindIndexProt && ! copy ) {\n let kindIndexProtArr = kindIndexProt.split('-');\n index = kindIndexProtArr[kindIndexProtArr.length - 1];\n // start element javascript if element is new\n \n }\n\n let node_wptb_element_kind_num = node.className.match(/wptb-element-(.+)-(\\d+)/i);\n if ( node_wptb_element_kind_num ) {\n node.classList.remove( node_wptb_element_kind_num[0] );\n }\n if ( ! node.classList.contains( 'wptb-ph-element' ) ) {\n node.classList.add( 'wptb-ph-element' );\n if( ! node.classList.contains( 'wptb-element-' + element.kind + '-' + index ) ) {\n node.classList.add( 'wptb-element-' + element.kind + '-' + index );\n }\n } else {\n if( ! node.classList.contains( 'wptb-element-' + element.kind + '-' + index ) ) {\n node.classList.add( 'wptb-element-' + element.kind + '-' + index );\n }\n }\n new WPTB_ElementOptions( element, index, kindIndexProt );\n WPTB_Helper.elementStartScript( element.getDOMElement() );\n document.counter.increment(element.kind);\n }\n \n node.onmouseenter = function ( event ) {\n if( event.target.classList.contains( 'wptb-moving-mode' ) ) {\n return;\n }\n \n let wptbActionsField = new WPTB_ActionsField();\n \n wptbActionsField.addActionField( 1, node );\n \n wptbActionsField.setParameters( node );\n \n node.classList.remove( 'wptb-ondragenter' );\n };\n \n node.onmouseleave = function ( event ) {\n let wptbActionsField = new WPTB_ActionsField();\n \n wptbActionsField.leaveFromField( event, node );\n };\n};"]}
1
+ {"version":3,"sources":["WPTB_ActionsField.js","WPTB_Builder.js","WPTB_Cell.js","WPTB_DropHandle.js","WPTB_ElementCounters.js","WPTB_ElementObject.js","WPTB_ElementOptions.js","WPTB_Helper.js","WPTB_Initializer.js","WPTB_LeftPanel.js","WPTB_MultipleSelect.js","WPTB_Parser.js","WPTB_Polyfills.js","WPTB_Settings.js","WPTB_Stringifier.js","WPTB_Table.js","WPTB_TableStateSaveManager.js","WPTB_innerElementSet.js","applyGenericItemSettings.js"],"names":["WPTB_ActionsField","wptbActions","document","getElementsByClassName","length","addActionField","actionType","thisNode","body","getElementsByTagName","actions","previousNode","activeElem","classList","remove","parentNode","removeChild","btnDelete","btnCopy","createElement","add","appendChild","type","onclick","event","act","target","el","infArr","className","match","Array","isArray","WPTB_Helper","elementControlsStateDelete","externalCssStylesDelete","hasOwnProperty","kind","thisRow","rowIsTop","table","findAncestor","contains","dataTitleColumnSet","wptbActionsField","actionsRemove","wptbTableStateSaveManager","WPTB_TableStateSaveManager","tableStateSet","copy","activeElement","activeElemParent","data","elemProt","tinyMceClear","WPTB_ElementObject","elementControlsStateCopy","getDOMElement","externalCssStylesCopy","insertBefore","nextSibling","elementCopy","cloneNode","applyGenericItemSettings","wptbDocumentEventGenerate","WPTB_innerElementSet","setParameters","btnMove","draggable","ondragstart","wptbElementIconsDirectories","tmplIconsDirectories","wp","template","jsonIconsDirectories","IconsDirectories","JSON","parse","dragImages","getElementIcon","dataTransfer","effectAllowed","setDragImage","setData","style","display","console","log","actionsHide","ondragend","elementDragEndClear","coordinatesElement","getBoundingClientRect","wptbContainer","correctTop","top","parseFloat","removeEventListener","left","right","clientWidth","addEventListener","leaveFromField","node","relatedTarget","onmouseleave","opacity","WPTB_Builder","table_id","detectMode","http","XMLHttpRequest","urlSet","ajaxurl","open","setRequestHeader","onreadystatechange","d","readyState","status","ans","responseText","getElementById","value","wptbTableSetupEl","WPTB_Parser","elementsSettingTemplateJs","setAttribute","innerHTML","WPTB_Table","element","querySelector","WPTB_LeftPanel","WPTB_Settings","elementOptionsSet","send","counter","ElementCounters","select","MultipleSelect","initializer","WPTB_Initializer","settings","WPTB_Cell","callback","DOMElement","highlightRow","td","parentRow","columnCount","parseInt","tds","i","classToAdd","ttd","highlightColumn","index","rowCount","tr","padding","jQuery","val","innerBorderWidth","border","ondblclick","stopPropagation","currentTarget","newElementProxy","wptbPhElement","wptbElementTypeClass","wptbTypeElementArr","split","wptbInternalActiveElement","j","wptbInternalActiveElementObj","setCoords","y","x","dataset","yIndex","xIndex","getCoords","coords","appendElement","getCellDimensions","tdStyleObj","window","getComputedStyle","tdPaddingLeft","getPropertyValue","tdPaddingRight","tdBorderLeftWidth","tdBorderRightWidth","tdPaddingTop","tdPaddingBottom","tdBorderTopWidth","tdBorderBottomWidth","width","offsetWidth","height","offsetHeight","tableFullStyleObj","tableBorderLeft","tableBorderRight","tableBorderTop","tableBorderBottom","nodeName","toLowerCase","firstChild","lastChild","WPTB_DropHandle","thisElem","e","wptbDropHandle","wptbDropBorderMarker","wptbDropBorderMarkerTop","wptbDropBorderMarkerRight","wptbDropBorderMarkerBottom","wptbDropBorderMarkerLeft","ondragenter","ondragover","preventDefault","ondragleave","ondrop","getData","wptbMovingMode","text","getDOMParentElement","innerElement","innerElementNext","elemKind","undefined","onscroll","localName","indics","types","notDragEnter","indexOf","elementDrag","offsetY","layerY","bottom","priv","increment","key","nextIndex","kindIndexProt","wpTemplateId","itemHtml","replace","trim","wptbElementMutch","elementClearFromTinyMce","inElems","querySelectorAll","inElemObj","WPTB_ElementOptions","hexToRgb","hex","result","exec","rgbToHex","rgb","toString","slice","isHex","regex","RegExp","test","icon_directory","hostName","location","protocol","hostname","img","src","wptbDropHandles","wptbDropBorderMarkers","linkHttpCheckChange","link","linkArr","linkClean","rows","rowHead","computedStyleRowHead","rowHeadChildren","children","contentsForHeader","tdElements","p","textContent","textAlign","fontSize","color","backgroundColor","thisRowChildren","wptbTitleColumn","wptbTitleColumnFontSize","wptbTitleColumnColor","wptbTitleBackgroundColor","wptbTitleAlign","cls","parentElement","row","parent","getSelectionText","txt","getSelection","selection","createRange","elementOptionsPanelClear","elementOptionsGroup","wpColorPickerCheckChangeForTableStateSaving","originalEvent","wpPickerContainer","irisStripMouseUpStateSaveManager","wpColorPickerClear","attribute","isId","input","newInput","url","href","results","decodeURIComponent","getColumnWidth","cell","xIndexes","cellWidth","getRowHeight","yIndexes","cellHeight","wpColorPickerChange","ui","uiColor","classe","ps","number","affectedEl","ratingStar","span","fill","wptbTextMessageSize","numberImputSize","wptbNumberInputs","maxCount","maxValue","onkeydown","thisValue","String","substring","onkeyup","ucfirst","str","charAt","toUpperCase","eventName","details","CustomEvent","detail","bubbles","dispatchEvent","elementStartScript","WPTB_ElementsScriptsLauncher","deleteEventHandlers","off","elementChildren","replaceAll","string","search","join","mceContentBodys","k","dataMceStyle","removeAttribute","mceEditFocus","contentEditable","spellCheck","mceIds","elementOptionContainerCustomClassSet","targetInput","customClassForContainer","containerElement","elementOptionContainerAdditionalStyles","containerAdditionalStyles","containerStylesArrOne","containerStylesSet","containerStyleStr","containerStyleStrArr","controlsInclude","functionHandler","elementKind","сontrolsConnectIndic","elementsSettingsTemplateJs","elementsSettings","controlClassesNames","elementSettings","Object","keys","forEach","regularText","keyInfArr","controlClass","push","controls","controlName","control","targetControlValue","targetControlValueGet","oneControlInclude","wptbContrlStacksConfigId","tmplControlsConfig","container","jsonControlsConfigJson","jsonControlsConfig","controlClassName","innerElementCopyIncludeHandler","appearDependOnControl","dependOn","targetControlElementClass","dependOnControlName","dependOnControlElementClass","dependOnControlElement","targetControlElement","controlContainerElem","showHideDependOnControlElement","dependOnControlElementKind","elementSettingValue","controlsStateManager","targetControlClass","controlChangeIndic","targetControls","selectorElement","elementsSettingsTemplatesJs","stringify","name","checked","elementProt","copyElem","infArrProt","infArrCopy","elemProtKind","elemCopyKind","elementSettingsProt","elementSettingsCopy","elementSettingKeyCopy","nameControl","wptbElementDatas","elementContainerClass","elementOptionClassIndic","elementOptionsGroupId","wptbelementOptionClass","wptbelementOptionsContainer","childNodes","elementOptionsGroupChildren","controlScriptsArr","controlappearDependOnControl","controlKey","tmplControlTemplate","elemContainer","elementControlTargetUnicClass","controlTemplate","wptbElementOptionContainer","helperJavascriptElem","helperJavascriptCode","innerText","script","managerExternalCssStyles","elementContainer","selector","cssName","cssValue","head","cssForThisElement","cssText","cssTextArrFirst","pop","selectorExists","cssTextArrSecond","cssTextArrThird","cssNameExists","cssTextArrFourth","splice","copyElement","activeElemClass","cssForActiveElement","cssForNewElement","infArrCopyEl","cssForActiveElementInnerHTML","cssForNewElementInnerHTML","elementsStylesConvertToObject","stylesElements","stylesObj","styleElemId","getAttribute","elementsStylesSetFromObject","jsonObject","styleCss","saveTable","startSaving","previewSaving","wptbTableStateNumberSave","wptbTableStateNumberShow","bar","toggleTableEditMode","wptb_admin_object","t","messagingArea","code","datas","postId","rs","wptbId","paramIdsNecessaryChange","codeClone","columns","WPTB_Stringifier","outerHTML","datas_containers","styleObjJson","messagingAreaText","setTimeout","params","title","content","elements_datas","elements_styles","security_code","preview_saving","id","action","wptbTableStateSaving","history","pushState","wptbPreviewTable","wptbPreviewBtn","wptbPreviewBtnHref","previewHref","wptbSaveBtn","clickOnFreeSpace","wpcdFixedToolbar","hasAttribute","elementAjax","dataAjaxData","element_name","element_ajax_data","MIN_COLUMNS","MIN_ROWS","MAX_COLUMNS","MAX_ROWS","tableGenerator","columnsDecrementButton","columnsIncrementButton","rowsDecrementButton","rowsIncrementButton","columnsInput","rowsInput","wptbElementButtons","wptbTableColumnWidthNumber","wptbTableRowHeightNumber","oninput","addColumnWidth","onchange","highlighted","addRowHeight","controlsChange","inputs","tableTopRowsAsHeader","makeTableResponsive","wptbAdaptiveTable","wptbElement","addRowToTheEnd","addRowToTheStart","addRowBefore","addRowAfter","addColumnEnd","addColumnStart","addColumnBefore","addColumnAfter","deleteColumn","deleteRow","mergeCells","splitCell","wptbBuilderPanel","wptbHeader","selectedCells","multipleCellMode","activateMultipleSelectMode","deactivateMultipleSelectMode","isActivated","pushSelectedCell","flushSelectedCells","getFirst","minXIndex","minYIndex","first","getLast","maxXIndex","maxYIndex","last","removeAllButFirst","div","columnTitleMobile","prototype","hasDontEnumBug","propertyIsEnumerable","dontEnums","dontEnumsLength","obj","TypeError","prop","call","elems","wptbUndo","tableStateGet","wptbUndoredo","wptbUndoRedoContainer","wptbRedo","shortcodePopupWindow","onbeforeunload","wptbSaveDisabled","previewId","Math","floor","random","newHref","URL","searchParams","set","codeMain","tableColumns","minWidth","maxWidth","innerElements","wptbActionsLength","dataMceBogus","columnNameDivContainer","columnNameDiv","array","wptbTableSetup","maxAmountOfCells","maxAmountOfRows","mark","rowSpan","cs","colSpan","markedCells","noCells","singleCells","multipleCells","cellSettings","position","column","cellHighlighted","wptbTableColumnWidthSlider","tableColumnWidthAutoFixedCheckbox","wptbFixedWidth","wptbTableRowHeightSlider","tableRowHeightAutoFixedCheckbox","wptbFixedHeight","isSquare","realTimeArray","carried","cols","matriz","items","justAssigned","amount","carriedRowspans","cellsBuffer","cellPointer","xPosition","stepsToMove","celda","drawTable","a","undoSelect","fillTableArray","colspansSums","cells","colspanSumInRow","max","apply","getActualPointsInRow","points","skipInCols","reconstraction","insertRow","borderWidth","wptb_preview_table","cellModeBackground","leftScrollPanelCurtain","leftScrollPanelCellSettings","wptbPreviewTableTds","recalculateIndexes","start","trs","maxCols","maxColsFull","tdsArr","jMainIter","z","cleaner","dataXIndex","tableTdsFor","colspan","tableRows","widthIsSet","arrayTdsFromPreviousRow","tdDefaultWidth","tableTdsSumMaxWidth","tableTdsSumMaxWidthFixed","tableTdsSumMaxWidthAuto","wptbTableSetupWidth","arrayCellsWidthFixedHelper","arrayCellsWidthAutoHelper","tdPaddingCommon","tableTdBorderCommonWidth","cssForTdsWidthAuto","borderLeftWidth","borderRightWidth","tableBorderCommon","wptbCssTdAutoWidth","tableTdBorderLeftWidth","tableTdBorderRightWidth","CellsWidthAutoCount","wptbTableTdsSumMaxWidth","wptbCellsWidthAutoCount","mergingСellsHorizontally","wptbFixedWidthSize","styleElementCreate","tableTdWidthAuto","tableTdsWidthAutoCommon","cssForTdsWidthAutoOld","dataYIndex","rowspan","heightIsSet","arrayTdsPrevious","tableColumnHeightAutoFixedCheckbox","mergingCellsVertically","forBreak","currentTable","currentTableTd","currentTdStyle","firstCell","c_pos","cellStyle","pos","pendingInsertion","bro","currentCell","l","r","aux","from","cellNew","rowChildren","rowChildrenLength","cellRowSpan","rowAfter","cellsColSpan","tableRowsIChildren","tableRIChildrenLength","rowIRowSpan","rNext","rNextChildren","rNextChildrenLength","rowStart","columnStart","rowEnd","columnEnd","itemsEstimate","dimensions","tdsChildrenNew","tdsInternalElements","tdsIntElemLength","firstWidth","firstDataFixedWidth","firstHeight","firstDataFixedHeight","cellStyles","cellXIndex","rowChildInsertBefore","rowNext","Number","findRowspannedCells","difference","actualPoints","addLackingCells","sumRows","totalColspan","nextRow","nextRowChildren","nextRowChildrenLength","tdArr","nextRowChildrenK","jRowChildren","onresize","generate","wptbNewPreviewTable","wptbHighlighted","wptbDirectlyhovered","cssForTdsWidthAutoValue","datawptbUndoredo","wptbLeftScrollPanelCellSetting","tableStateClear","classId","onmouseover","wptbElements","elementIndexesArr","elementIndexMax","wptbNodeattributes","attributes","attr","newDataAttributeName","newDataAttributeValue","nodeValue","kindIndexProtArr","node_wptb_element_kind_num","onmouseenter"],"mappings":";;AAAA,IAAIA,oBAAoB,SAApBA,iBAAoB,GAAW;AAAA;;AAC/B;AACA,SAAKC,WAAL;AACA,QAAIC,SAASC,sBAAT,CAAiC,cAAjC,EAAkDC,MAAlD,IAA4D,CAAhE,EAAoE;AAChE,aAAKH,WAAL,GAAmBC,SAASC,sBAAT,CAAiC,cAAjC,EAAkD,CAAlD,CAAnB;AACH;;AAED,SAAKE,cAAL,GAAsB,UAAEC,UAAF,EAAcC,QAAd,EAA4B;AAC9C,YAAIC,OA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AACnC,YAAIA,MAAME,MAAN,CAAab,SAAb,CAAuB6B,QAAvB,CAAiC,kBAAjC,CAAJ,EAA4D;AACxD;AACH;;AAED,YAAIE,mBAAmB,IAAI5C,iBAAJ,EAAvB;;AAEA4C,yBAAiBvC,cAAjB,CAAiC,CAAjC,EAAoCkG,IAApC;;AAEA3D,yBAAiBsB,aAAjB,CAAgCqC,IAAhC;;AAEAA,aAAK1F,SAAL,CAAeC,MAAf,CAAuB,kBAAvB;AACH,KAZD;;AAcAyF,SAAKE,YAAL,GAAoB,UAAWjF,KAAX,EAAmB;AACnC,YAAIoB,mBAAmB,IAAI5C,iBAAJ,EAAvB;;AAEA4C,yBAAiB0D,cAAjB,CAAiC9E,KAAjC,EAAwC+E,IAAxC;AACH,KAJD;AAKH,CApFD","file":"admin.js","sourcesContent":["var WPTB_ActionsField = function() {\n //this.wptbBorderMarker;\n this.wptbActions;\n if( document.getElementsByClassName( 'wptb-actions' ).length != 0 ) {\n this.wptbActions = document.getElementsByClassName( 'wptb-actions' )[0];\n }\n \n this.addActionField = ( actionType, thisNode ) => {\n let body = document.getElementsByTagName( 'body' )[0];\n \n let actions = document.getElementsByClassName( 'wptb-actions' );\n if( actions.length != 0 ) {\n let previousNode = actions[0].activeElem;\n if( previousNode ) {\n previousNode.classList.remove( 'wptb-directlyhovered' );\n }\n \n while( actions.length != 0 ) {\n actions[0].parentNode.removeChild( actions[0] );\n }\n }\n \n if( actionType == 1 ) {\n \n let btnDelete, btnCopy;\n\n btnDelete = document.createElement( 'span' ),\n btnCopy = document.createElement( 'span' ),\n actions = document.createElement( 'div' );\n\n actions.classList.add( 'wptb-actions' );\n btnDelete.classList.add( 'dashicons', 'dashicons-trash', 'wptb-delete-action' );\n btnCopy.classList.add( 'dashicons', 'dashicons-admin-page', 'wptb-duplicate-action' );\n \n actions.appendChild( btnCopy );\n actions.appendChild( btnDelete );\n \n body.appendChild( actions );\n\n actions.activeElem = thisNode;\n\n actions.type = 1;\n\n btnDelete.onclick = function( event ) {\n let act = event.target.parentNode.activeElem,\n el = act.parentNode;\n let infArr = act.className.match( /wptb-element-(.+)-(\\d+)/i );\n if( act && infArr && Array.isArray( infArr ) ) {\n WPTB_Helper.elementControlsStateDelete( act );\n WPTB_Helper.externalCssStylesDelete( infArr[0] );\n }\n \n if( act ) {\n el.removeChild( act );\n }\n\n if( act && typeof act === 'object' && act.hasOwnProperty( 'kind' ) && act.kind == 'text' ) {\n let thisRow = el.parentNode;\n \n if( WPTB_Helper.rowIsTop( thisRow ) ) {\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\n\n if( table.classList.contains( 'wptb-table-preview-head' ) ) {\n WPTB_Helper.dataTitleColumnSet( table );\n }\n }\n }\n\n let wptbActionsField = new WPTB_ActionsField();\n wptbActionsField.actionsRemove();\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n btnCopy.onclick = ( event ) => {\n let copy,\n infArr,\n type;\n let activeElement = event.target.parentNode.activeElem;\n let activeElemParent = activeElement.parentNode;\n infArr = activeElement.className.match( /wptb-element-(.+)-(\\d+)/i );\n if( infArr && Array.isArray( infArr ) ) {\n type = infArr[1];\n let data = {};\n data.kind = type;\n data.elemProt = activeElement;\n data.tinyMceClear = true;\n copy = new WPTB_ElementObject( data );\n WPTB_Helper.elementControlsStateCopy( activeElement, copy.getDOMElement() );\n WPTB_Helper.externalCssStylesCopy( activeElement, copy.getDOMElement() );\n //WPTB_Helper.elementStartScript( copy.getDOMElement() );\n \n activeElemParent.insertBefore( copy.getDOMElement(), activeElement.nextSibling );\n } else {\n copy = {};\n let elementCopy = activeElement.cloneNode( true );\n elementCopy.classList.remove( 'wptb-directlyhovered' );\n \n copy.getDOMElement = function() {\n return elementCopy;\n }\n \n applyGenericItemSettings( copy );\n \n activeElemParent.insertBefore( copy.getDOMElement(), activeElement.nextSibling );\n \n WPTB_Helper.wptbDocumentEventGenerate( 'wptb-inner-element:copy', activeElement, copy.getDOMElement() );\n }\n \n WPTB_innerElementSet( copy.getDOMElement() );\n\n let wptbActionsField = new WPTB_ActionsField( 1, activeElement );\n wptbActionsField.setParameters( activeElement );\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n \n \n if( thisNode.classList.contains( 'wptb-ph-element' ) ) {\n let btnMove;\n btnMove = document.createElement( 'span' );\n btnMove.classList.add( \"dashicons\", \"dashicons-move\", 'wptb-move-action' );\n btnMove.draggable = true;\n actions.appendChild( btnMove );\n \n btnMove.ondragstart = ( event ) => {\n let wptbElementIconsDirectories = 'wptb-element-icons-directories';\n let tmplIconsDirectories = wp.template( wptbElementIconsDirectories );\n let data = {};\n let jsonIconsDirectories = tmplIconsDirectories( data );\n let IconsDirectories = JSON.parse( jsonIconsDirectories );\n\n let dragImages,\n actions = event.target.parentNode,\n activeElem = actions.activeElem,\n infArr,\n type;\n infArr = activeElem.className.match( /wptb-element-(.+)-(\\d+)/i );\n if( infArr && Array.isArray( infArr ) ) {\n type = infArr[1];\n activeElem.classList.add( 'wptb-moving-mode' );\n\n if( IconsDirectories && typeof IconsDirectories === 'object' && IconsDirectories[type] ) {\n dragImages = WPTB_Helper.getElementIcon( IconsDirectories[type] );\n }\n\n event.dataTransfer.effectAllowed = 'move';\n event.dataTransfer.setDragImage( dragImages, 0, 0 );\n event.dataTransfer.setData( 'node', 'wptb-element-' + infArr[1] + '-' + infArr[2] );\n event.dataTransfer.setData( 'wptb-moving-mode', 'wptb-element-' + infArr[1] + '-' + infArr[2] );\n event.dataTransfer.setData( 'wptbElIndic-' + infArr[1], 'wptbElIndic-' + infArr[1] );\n let act = event.target.parentNode.activeElem;\n if( act.kind == 'text' ) {\n let thisRow = act.parentNode.parentNode;\n \n if( WPTB_Helper.rowIsTop( thisRow ) ) {\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\n\n if( table.classList.contains( 'wptb-table-preview-head' ) ) {\n WPTB_Helper.dataTitleColumnSet( table );\n }\n }\n }\n } else {\n this.style.display = 'none';\n console.log(this);\n }\n\n this.actionsHide();\n };\n\n btnMove.ondragend = ( event ) => {\n WPTB_Helper.elementDragEndClear();\n }\n }\n\n actions.style.display = 'block';\n\n this.wptbActions = actions;\n } \n }\n \n this.setParameters = ( thisNode ) => {\n \n if( ! this.wptbActions ) {\n let actions = document.getElementsByClassName( 'wptb-actions' );\n if( actions.length > 0 ) {\n this.wptbActions = actions[0];\n } else {\n this.wptbActions = false;\n }\n }\n \n if( this.wptbActions && this.wptbActions.classList.contains( 'wptb-actions' ) ) {\n this.wptbActions.style.display = 'block';\n } else {\n return;\n }\n \n let coordinatesElement = thisNode.getBoundingClientRect();\n \n let wptbContainer = document.getElementsByClassName( 'wptb-container' )[0];\n let correctTop = () => {\n let coordinatesElement = thisNode.getBoundingClientRect();\n this.wptbActions.style.top = parseFloat( coordinatesElement.top ) - 15 + 'px';\n }\n wptbContainer.removeEventListener( 'scroll', correctTop, false );\n \n this.wptbActions.style.top = parseFloat( coordinatesElement.top ) - 15 + 'px';\n this.wptbActions.style.left = ( parseFloat( coordinatesElement.right ) - parseFloat( this.wptbActions.clientWidth ) ) + 1 + 'px';\n \n this.wptbActions.style.display = 'block';\n thisNode.classList.add( 'wptb-directlyhovered' );\n \n wptbContainer.addEventListener( 'scroll', correctTop, false );\n }\n \n this.leaveFromField = ( event, node, actionType ) => {\n if( ! this.wptbActions ) {\n let actions = document.getElementsByClassName( 'wptb-actions' );\n if( actions.length > 0 ) {\n this.wptbActions = actions[0];\n } else {\n this.wptbActions = false;\n }\n }\n \n if( ! this.wptbActions ) {\n return;\n }\n \n if( event.relatedTarget ) {\n if ( event.relatedTarget.classList.contains( 'wptb-actions' ) ||\n event.relatedTarget.classList.contains( 'wptb-move-action' ) ||\n event.relatedTarget.classList.contains( 'wptb-duplicate-action' ) ||\n event.relatedTarget.classList.contains( 'wptb-delete-action' ) ) {\n if( ! this.wptbActions ) {\n this.wptbActions = document.getElementsByClassName( 'wptb-actions' )[0];\n }\n this.wptbActions.onmouseleave = ( event ) => {\n if( event.relatedTarget != null && ( event.relatedTarget.classList.contains( 'wptb-ph-element' ) || \n WPTB_Helper.findAncestor( event.relatedTarget, 'wptb-ph-element') ) && event.relatedTarget != this.wptbActions.activeElem &&\n WPTB_Helper.findAncestor( event.relatedTarget, 'wptb-directlyhovered' ) != this.wptbActions.activeElem ) {\n \n// this.wptbActions.style.display = 'none';\n// event.relatedTarget.parentNode.parentNode.classList.remove( 'wptb-directlyhovered' );\n//\n// let wptbActionsField = new WPTB_ActionsField();\n//\n// wptbActionsField.addActionField( 1, event.relatedTarget.parentNode.parentNode );\n//\n// wptbActionsField.setParameters( event.relatedTarget.parentNode.parentNode );\n } else {\n \n }\n \n let wptbActionsField = new WPTB_ActionsField();\n\n wptbActionsField.leaveFromField( event, event.relatedTarget.parentNode.parentNode );\n \n event.target.activeElem.classList.remove( 'wptb-directlyhovered' );\n }\n\n return;\n } \n }\n \n node.classList.remove( 'wptb-directlyhovered' );\n this.wptbActions.style.display = 'none';\n \n if( event.relatedTarget ) {\n if( event.relatedTarget.classList.contains( 'wptb-ph-element' ) || WPTB_Helper.findAncestor( event.relatedTarget, 'wptb-ph-element' ) ) {\n this.addActionField( 1, event.relatedTarget.parentNode );\n\n this.setParameters( event.relatedTarget.parentNode );\n }\n }\n }\n \n this.actionsRemove = () => {\n if( ! this.wptbActions ) {\n let actions = document.getElementsByClassName( 'wptb-actions' );\n if( actions.length > 0 ) {\n this.wptbActions = actions[0];\n }\n }\n \n if( this.wptbActions ) {\n this.wptbActions.parentNode.removeChild( this.wptbActions );\n }\n }\n \n this.actionsHide = () => {\n if( ! this.wptbActions ) {\n let actions = document.getElementsByClassName( 'wptb-actions' );\n if( actions.length > 0 ) {\n this.wptbActions = actions[0];\n }\n }\n \n if( this.wptbActions ) {\n this.wptbActions.style.opacity = 0;\n }\n }\n}","(function () {\n var WPTB_Builder = function () {\n var table_id = WPTB_Helper.detectMode();\n if ( table_id ) {\n var http = new XMLHttpRequest(),\n urlSet = ajaxurl + \"?action=get_table\" + '&id=' + table_id;\n http.open('GET', urlSet, true);\n http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');\n http.onreadystatechange = function (d) {\n if (this.readyState == 4 && this.status == 200) {\n var ans = JSON.parse(http.responseText);\n document.getElementById('wptb-setup-name').value = ans[0];\n \n if( ans[1] ) {\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'none';\n let wptbTableSetupEl = document.getElementsByClassName('wptb-table-setup')[0];\n wptbTableSetupEl.appendChild( WPTB_Parser( ans[1] ) );\n \n let body = document.getElementsByTagName('body')[0];\n \n if( ans[2] ) {\n let elementsSettingTemplateJs = document.createElement( 'script' );\n elementsSettingTemplateJs.setAttribute( 'type', 'text/html' );\n elementsSettingTemplateJs.setAttribute( 'class', 'wptb-element-datas' );\n\n elementsSettingTemplateJs.innerHTML = ans[2];\n\n body.appendChild( elementsSettingTemplateJs );\n }\n \n WPTB_Table();\n let element = document.querySelector( '.wptb-preview-table' );\n if( element ) {\n let infArr = element.className.match( /wptb-element-((.+-)\\d+)/i );\n if( ! infArr ) {\n element.classList.add( 'wptb-element-main-table_setting-' + table_id );\n }\n }\n \n WPTB_LeftPanel();\n WPTB_Settings();\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n \n WPTB_Helper.elementOptionsSet( 'table_setting', element );\n } else {\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\n }\n \n return;\n }\n };\n http.send(null);\n } else {\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\n }\n document.counter = new ElementCounters();\n document.select = new MultipleSelect();\n\n var initializer = WPTB_Initializer();\n settings = WPTB_Settings();\n };\n\n document.addEventListener('DOMContentLoaded', WPTB_Builder);\n})();","var WPTB_Cell = function ( callback, DOMElement ) {\n\n function highlightRow(td) {\n var parentRow = td.parentNode,\n columnCount = parseInt(document.getElementById('wptb-columns-number').value),\n tds = document.getElementsByClassName('wptb-preview-table')[0].getElementsByTagName('td');\n for (var i = 0; i < tds.length; i++) {\n tds[i].classList.remove('wptb-highlighted-row-first', 'wptb-highlighted-row-last', 'wptb-highlighted-row-inner', 'wptb-highlighted-column-first', 'wptb-highlighted-column-last', 'wptb-highlighted-column-inner');\n }\n for (var i = 0; i < columnCount; i++) {\n\n var classToAdd = i == 0 ? 'wptb-highlighted-row-first' : i == columnCount - 1 ? 'wptb-highlighted-row-last' : 'wptb-highlighted-row-inner';\n var ttd = parentRow.getElementsByTagName('td')[i];\n if (ttd !== td) {\n ttd.classList.add(classToAdd);\n }\n }\n }\n\n function highlightColumn(td) {\n\n var index,\n parentRow = td.parentNode;\n columnCount = parseInt(document.getElementById('wptb-columns-number').value), rowCount = parseInt(document.getElementById('wptb-rows-number').value), table = document.getElementsByClassName('wptb-preview-table')[0];\n for (var i = 0; i < columnCount; i++) {\n if (parentRow.getElementsByTagName('td')[i] === td) {\n index = i;\n break;\n }\n }\n\n for (var i = 0; i < rowCount; i++) {\n var classToAdd = i == 0 ? 'wptb-highlighted-column-first' : i == rowCount - 1 ? 'wptb-highlighted-column-last' : 'wptb-highlighted-column-inner';\n var tr = table.getElementsByTagName('tr')[i];\n if (tr.getElementsByTagName('td')[index] !== td) {\n tr.getElementsByTagName('td')[index].classList.add(classToAdd);\n }\n }\n }\n \n if( ! DOMElement ) {\n DOMElement = document.createElement(\"td\");\n\n DOMElement.style.padding = jQuery('#wptb-table-padding-number').val() + 'px';\n\n var innerBorderWidth = jQuery('#wptb-table-inner-border-number').val();\n\n if (innerBorderWidth != '' && parseInt(innerBorderWidth) != 0) {\n DOMElement.style.border = innerBorderWidth + 'px solid ' + jQuery('#wptb-table-border-color').val();\n } \n\n DOMElement.classList.add('wptb-droppable', 'wptb-cell');\n console.log( 'wptb_cell_test' );\n }\n\n DOMElement.draggable = false;\n if ( callback ) {\n DOMElement.onclick = callback;\n }\n \n // Cell double click handler\n DOMElement.ondblclick = function( event ) {\n event.stopPropagation();\n if( ! WPTB_Helper.findAncestor( DOMElement, 'wptb-preview-table-manage-cells' ) && event.target == event.currentTarget ) {\n \n WPTB_Helper.wptbDocumentEventGenerate( 'table:cell:dblclick', event.target );\n \n let element = WPTB_Helper.newElementProxy( 'text' );\n element = element.getDOMElement();\n \n DOMElement.appendChild( element );\n \n WPTB_innerElementSet( element );\n }\n }\n \n WPTB_innerElementSet( DOMElement );\n \n let wptbPhElement = DOMElement.getElementsByClassName( 'wptb-ph-element' );\n \n if ( wptbPhElement.length > 0 ) {\n for( let i = 0; i < wptbPhElement.length; i++ ) {\n wptbPhElement[i].getDOMElement = function() {\n return wptbPhElement[i];\n }\n \n WPTB_innerElementSet( wptbPhElement[i] );\n \n let wptbElementTypeClass = wptbPhElement[i].className.match( /wptb-element-((.+-)\\d+)/i );\n if( wptbElementTypeClass && Array.isArray( wptbElementTypeClass ) ) {\n let wptbTypeElementArr = wptbElementTypeClass[1].split( '-' );\n wptbPhElement[i].kind = wptbTypeElementArr[0];\n applyGenericItemSettings( wptbPhElement[i], wptbElementTypeClass[1] );\n let wptbInternalActiveElement = wptbPhElement[i].getElementsByClassName( 'wptb-in-element' );\n if ( wptbInternalActiveElement.length > 0 ) {\n for ( let j = 0; j < wptbInternalActiveElement.length; j++ ) {\n let wptbInternalActiveElementObj = {};\n wptbInternalActiveElementObj.getDOMElement = function() {\n return wptbInternalActiveElement[j];\n }\n \n applyGenericItemSettings( wptbInternalActiveElementObj );\n }\n }\n }\n }\n }\n\n this.getDOMElement = function () {\n return DOMElement;\n };\n\n this.setCoords = function (y, x) {\n var el = this.getDOMElement();\n el.dataset.yIndex = y;\n el.dataset.xIndex = x;\n };\n\n this.getCoords = function () {\n var coords,\n el = this.getDOMElement();\n coords.x = el.dataset.xIndex;\n coords.y = el.dataset.yIndex;\n return coords;\n };\n\n this.appendElement = function (node) {\n getDOMElement().appendChild(node);\n };\n \n DOMElement.getCellDimensions = function() {\n \n let tdStyleObj = window.getComputedStyle( this, null );\n \n let tdPaddingLeft = tdStyleObj.getPropertyValue( 'padding-left' );\n let tdPaddingRight = tdStyleObj.getPropertyValue( 'padding-right' );\n \n let tdBorderLeftWidth = tdStyleObj.getPropertyValue( 'border-left-width' );\n let tdBorderRightWidth = tdStyleObj.getPropertyValue( 'border-right-width' );\n \n let tdPaddingTop = tdStyleObj.getPropertyValue( 'padding-top' );\n let tdPaddingBottom = tdStyleObj.getPropertyValue( 'padding-bottom' );\n \n let tdBorderTopWidth = tdStyleObj.getPropertyValue( 'border-top-width' );\n let tdBorderBottomWidth = tdStyleObj.getPropertyValue( 'border-bottom-width' );\n \n let width = parseInt( this.offsetWidth, 10 ) - \n parseInt( tdPaddingLeft, 10 ) - \n parseInt( tdPaddingRight, 10 ) -\n ( parseInt( tdBorderLeftWidth, 10 ) / 2 ) -\n ( parseInt( tdBorderRightWidth, 10 ) / 2 );\n \n let height = parseInt( this.offsetHeight, 10 ) - \n parseInt( tdPaddingTop, 10 ) - \n parseInt( tdPaddingBottom, 10 ) -\n ( parseInt( tdBorderTopWidth, 10 ) / 2 ) -\n ( parseInt( tdBorderBottomWidth, 10 ) / 2 ); \n \n \n let table = WPTB_Helper.findAncestor( this, 'wptb-preview-table' );\n if( table ) {\n let tableFullStyleObj = window.getComputedStyle( table, null );\n let tableBorderLeft = tableFullStyleObj.getPropertyValue( 'border-left-width' );\n let tableBorderRight = tableFullStyleObj.getPropertyValue( 'border-right-width' );\n let tableBorderTop = tableFullStyleObj.getPropertyValue( 'border-top-width' );\n let tableBorderBottom = tableFullStyleObj.getPropertyValue( 'border-bottom-width' );\n \n let tr = this.parentNode;\n if( tr && tr.nodeName.toLowerCase() === 'tr' ) {\n if( tr.firstChild && tr.firstChild.dataset.xIndex === this.dataset.xIndex ) {\n if( parseInt( tableBorderLeft, 10 ) > parseInt( tdBorderLeftWidth, 10 ) ) {\n width += -( parseInt( tableBorderLeft, 10 ) - parseInt( tdBorderLeftWidth, 10 ) ) / 2;\n }\n }\n\n if( tr.lastChild && tr.lastChild.dataset.xIndex === this.dataset.xIndex ) {\n if( parseInt( tableBorderRight, 10 ) > parseInt( tdBorderRightWidth, 10 ) ) {\n width += -( parseInt( tableBorderRight, 10 ) - parseInt( tdBorderRightWidth, 10 ) ) / 2;\n }\n }\n \n let body = tr.parentNode;\n if( body && body.nodeName.toLowerCase() === 'body' ) {\n if( body.firstChild && body.firstChild.firstChild.dataset.yIndex === this.dataset.yIndex ) {\n if( parseInt( tableBorderTop, 10 ) > parseInt( tdBorderTopWidth, 10 ) ) {\n height += ( parseInt( tableBorderTop, 10 ) - parseInt( tdBorderTopWidth, 10 ) ) / 2;\n }\n }\n \n if( body.lastChild && body.lastChild.firstChild.dataset.yIndex === this.dataset.yIndex ) {\n if( parseInt( tableBorderBottom, 10 ) > parseInt( tdBorderBottomWidth, 10 ) ) {\n height += ( parseInt( tableBorderBottom, 10 ) - parseInt( tdBorderBottomWidth, 10 ) ) / 2;\n }\n }\n }\n }\n }\n \n return {\n width: parseInt( width ), \n height: parseInt( height )\n };\n }\n\n return this;\n};","var WPTB_DropHandle = function (thisElem, e) {\n \n let wptbDropHandle,\n wptbDropBorderMarker;\n if ( document.getElementsByClassName( 'wptb-drop-handle' ).length == 0 ) {\n wptbDropHandle = document.createElement( 'div' );\n wptbDropHandle.classList.add( 'wptb-drop-handle' );\n \n wptbDropBorderMarker = document.createElement( 'div' );\n wptbDropBorderMarker.classList.add( 'wptb-drop-border-marker' );\n \n let wptbDropBorderMarkerTop = document.createElement( 'div' ),\n wptbDropBorderMarkerRight = document.createElement( 'div' ),\n wptbDropBorderMarkerBottom = document.createElement( 'div' ),\n wptbDropBorderMarkerLeft = document.createElement( 'div' );\n \n wptbDropBorderMarkerTop.classList.add( 'wptb-drop-border-marker-top' );\n wptbDropBorderMarkerRight.classList.add( 'wptb-drop-border-marker-right' );\n wptbDropBorderMarkerBottom.classList.add( 'wptb-drop-border-marker-bottom' );\n wptbDropBorderMarkerLeft.classList.add( 'wptb-drop-border-marker-left' );\n \n wptbDropBorderMarker.appendChild( wptbDropBorderMarkerTop );\n wptbDropBorderMarker.appendChild( wptbDropBorderMarkerRight );\n wptbDropBorderMarker.appendChild( wptbDropBorderMarkerBottom );\n wptbDropBorderMarker.appendChild( wptbDropBorderMarkerLeft );\n \n let body = document.getElementsByTagName( 'body' );\n if ( body.length > 0 ) {\n body[0].appendChild( wptbDropHandle );\n body[0].appendChild( wptbDropBorderMarker );\n }\n \n wptbDropHandle.ondragenter = function () {\n\n }\n\n wptbDropHandle.ondragover = function (e) {\n e.preventDefault();\n }\n\n wptbDropHandle.ondragleave = function () {\n\n }\n wptbDropHandle.ondrop = function (e) {\n e.preventDefault();\n let element;\n \n if ( e.dataTransfer.getData('wptbElement') ) {\n element = WPTB_Helper.newElementProxy( e.dataTransfer.getData('wptbElement') );\n element = element.getDOMElement();\n } else {\n element = document.getElementsByClassName( e.dataTransfer.getData('node') )[0];\n element.classList.remove( 'wptb-moving-mode' );\n element.classList.remove( 'wptb-moving-into-same-elem' );\n element.wptbMovingMode = 1;\n }\n \n let td;\n if( wptbDropHandle.dataset.text == 'Drop Here' ) {\n thisElem = wptbDropHandle.getDOMParentElement();\n if ( thisElem.nodeName.toLowerCase() == 'td' ) {\n td = wptbDropHandle.getDOMParentElement();\n td.appendChild( element );\n }\n } else {\n let innerElement = wptbDropHandle.getDOMParentElement();\n td = innerElement.parentNode;\n \n if( wptbDropHandle.dataset.text == 'Above Element' ) {\n td.insertBefore( element, innerElement );\n } else if( wptbDropHandle.dataset.text == 'Below Element' ) {\n let innerElementNext = innerElement.nextSibling;\n td.insertBefore( element, innerElementNext );\n }\n }\n \n let thisRow = td.parentNode;\n if( WPTB_Helper.rowIsTop( thisRow ) ) {\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\n\n if( table.classList.contains( 'wptb-table-preview-head' ) ) {\n WPTB_Helper.dataTitleColumnSet( table );\n }\n }\n \n // start item javascript if item is new\n let infArr = element.className.match(/wptb-element-(.+)-(\\d+)/i);\n let elemKind = infArr[1];\n if ( e.dataTransfer.getData( 'wptbElement' ) && ( elemKind == 'text' || elemKind == 'button' || elemKind == 'image' || elemKind == 'star_rating' || elemKind == 'list' ) ) {\n //WPTB_Helper.elementStartScript( element );\n }\n \n wptbDropHandle.style.display = 'none';\n wptbDropBorderMarker.style.display = 'none';\n \n WPTB_innerElementSet( element );\n if( ! element.classList.contains( 'wptb-image-container' ) || element.wptbMovingMode == 1 ) {\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n element.wptbMovingMode == undefined;\n }\n }\n let wptbContainer = document.querySelector( '.wptb-container' );\n wptbContainer.onscroll = function() {\n wptbDropHandle.style.display = 'none';\n wptbDropBorderMarker.style.display = 'none';\n }\n } else {\n wptbDropHandle = document.getElementsByClassName( 'wptb-drop-handle' )[0];\n wptbDropBorderMarker = document.getElementsByClassName( 'wptb-drop-border-marker' )[0];\n }\n if( thisElem && thisElem.nodeName.toLowerCase() == 'td' && \n thisElem.getElementsByClassName( 'wptb-ph-element' ).length != 0 ) {\n return;\n }\n \n let thisRow;\n if ( thisElem.localName == 'td' ) {\n thisRow = thisElem.parentNode;\n } else if ( thisElem.localName == 'div' && thisElem.classList.contains( 'wptb-ph-element' ) ) {\n thisRow = thisElem.parentNode.parentNode;\n }\n \n if( WPTB_Helper.rowIsTop( thisRow ) ) {\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\n \n if( table.classList.contains( 'wptb-table-preview-head' ) ) {\n let indics = e.dataTransfer.types;\n let notDragEnter = false;\n for ( let i = 0; i < indics.length; i++ ) {\n let infArr = indics[i].match( /wptbelindic-([a-z]+)/i );\n if ( infArr && infArr[1] != 'text' ) {\n notDragEnter = true;\n break;\n }\n }\n if( notDragEnter ) {\n return;\n }\n }\n }\n \n wptbDropHandle.style.width = thisElem.offsetWidth + 'px';\n let height = thisElem.offsetHeight,\n coordinatesElement = thisElem.getBoundingClientRect(),\n left = parseFloat( coordinatesElement.left ),\n top;\n wptbDropHandle.style.left = left + 'px';\n \n if( e.dataTransfer.types.indexOf( 'wptb-moving-mode' ) != -1 ) {\n let elementDrag = document.getElementsByClassName( 'wptb-moving-mode' )[0];\n if( thisElem == elementDrag ) {\n wptbDropHandle.classList.add('wptb-moving-into-same-elem');\n wptbDropBorderMarker.classList.add('wptb-moving-into-same-elem');\n } else {\n wptbDropHandle.classList.remove('wptb-moving-into-same-elem');\n wptbDropBorderMarker.classList.remove('wptb-moving-into-same-elem');\n }\n }\n \n wptbDropHandle.getDOMParentElement = function() {\n return thisElem;\n }\n \n wptbDropHandle.style.display = 'block';\n wptbDropBorderMarker.style.display = 'block';\n if( thisElem.nodeName.toLowerCase() != 'td' ) {\n let y = e.offsetY==undefined?e.layerY:e.offsetY;\n top = parseFloat( coordinatesElement.top ) - parseFloat( 11 );\n wptbDropHandle.dataset.text = 'Above Element';\n if ( y > height/2 ) {\n top = parseFloat( coordinatesElement.top ) + height - 1;\n wptbDropHandle.dataset.text = 'Below Element';\n }\n } else {\n wptbDropHandle.dataset.text = 'Drop Here';\n top = parseFloat( coordinatesElement.top ) + height/2 - 5;\n }\n wptbDropHandle.style.top = top + 'px';\n\n wptbDropBorderMarker.style.top = coordinatesElement.top + 'px';\n wptbDropBorderMarker.style.left = coordinatesElement.left + 'px';\n\n wptbDropBorderMarkerTop = wptbDropBorderMarker.querySelector( '.wptb-drop-border-marker-top' );\n wptbDropBorderMarkerTop.style.width = ( parseFloat( thisElem.offsetWidth ) - parseFloat( 1 ) ) + 'px';\n\n wptbDropBorderMarkerRight = wptbDropBorderMarker.querySelector( '.wptb-drop-border-marker-right' );\n wptbDropBorderMarkerRight.style.height = ( parseFloat( coordinatesElement.bottom ) - parseFloat( coordinatesElement.top ) - 1 ) + 'px';\n wptbDropBorderMarkerRight.style.left = wptbDropBorderMarkerTop.style.width;\n\n wptbDropBorderMarkerBottom = wptbDropBorderMarker.querySelector( '.wptb-drop-border-marker-bottom' );\n wptbDropBorderMarkerBottom.style.width = wptbDropBorderMarkerTop.style.width;\n wptbDropBorderMarkerBottom.style.top = wptbDropBorderMarkerRight.style.height;\n\n wptbDropBorderMarkerLeft = wptbDropBorderMarker.querySelector( '.wptb-drop-border-marker-left' );\n wptbDropBorderMarkerLeft.style.height = wptbDropBorderMarkerRight.style.height;\n}","var ElementCounters = function () {\n\n\tvar priv = [];\n\tpriv['text'] = 0;\n\tpriv['image'] = 0;\n\tpriv['list'] = 0;\n\tpriv['button'] = 0;\n\n\tthis.increment = function (key) {\n\t\tif (!(key in priv)) {\n\t\t\treturn;\n\t\t}\n\t\tpriv[key]++;\n\t}\n\n\tthis.nextIndex = function (key) {\n\t\tif (!(key in priv)) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn priv[key] + 1;\n\t}\n\n\treturn this;\n\n};","var WPTB_ElementObject = function ( data ) {\n let DOMElement, kindIndexProt, copy;\n if( ! data.elemProt ) {\n DOMElement = document.createElement('div'),\n kindIndexProt = undefined,\n copy = false;\n DOMElement.classList.add( 'wptb-' + data.kind + '-container', 'wptb-ph-element', 'wptb-item-javascript-indic' );\n \n let wpTemplateId = 'wptb-' + data.kind + '-content';\n let template = wp.template( wpTemplateId );\n data.node = DOMElement;\n let itemHtml = template( data );\n\n itemHtml = itemHtml.replace(/\\r|\\n|\\t/g, '').trim();\n DOMElement.innerHTML = itemHtml;\n } else {\n DOMElement = data.elemProt.cloneNode( true );\n DOMElement.classList.remove( 'wptb-directlyhovered' );\n let wptbElementMutch = data.elemProt.className.match( /wptb-element-((.+-)\\d+)/i );\n if ( wptbElementMutch && Array.isArray( wptbElementMutch ) ) {\n kindIndexProt = wptbElementMutch[1];\n };\n copy = true;\n \n if( data.tinyMceClear ) {\n DOMElement = WPTB_Helper.elementClearFromTinyMce( DOMElement );\n }\n }\n \n let inElems = DOMElement.querySelectorAll( '.wptb-in-element' );\n if( inElems.length > 0 ) {\n for ( let i = 0; i < inElems.length; i++ ) {\n let inElemObj = {};\n inElemObj.getDOMElement = function() {\n return inElems[i];\n }\n \n applyGenericItemSettings( inElemObj );\n }\n }\n \n window.addEventListener( 'item:onmouseenter', function( event ) {\n //console.log( event );\n }, false);\n \n \n this.kind = data.kind;\n this.getDOMElement = function () {\n return DOMElement;\n };\n \n applyGenericItemSettings( this, kindIndexProt, copy );\n return this;\n}\n\n\n","var WPTB_ElementOptions = function ( element, index, kindIndexProt ) {\n\n var node = element.getDOMElement();\n\n node.onclick = function () {\n WPTB_Helper.elementOptionsSet( element.kind, this );\n };\n};","var WPTB_Helper = {\n hexToRgb: function( hex ) {\n var result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec( hex );\n return result ? 'rgb(' + parseInt( result[1], 16 ) + ',' + parseInt( result[2], 16 ) + ',' + parseInt( result[3], 16 ) + ')' : null;\n },\n rgbToHex: function ( rgb ) {\n var rgb = rgb.match( /^rgba?[\\s+]?\\([\\s+]?(\\d+)[\\s+]?,[\\s+]?(\\d+)[\\s+]?,[\\s+]?(\\d+)[\\s+]?/i );\n\n return ( rgb && rgb.length === 4 ) ? \"#\" +\n ( \"0\" + parseInt( rgb[1],10 ).toString( 16 )).slice( -2 ) +\n ( \"0\" + parseInt( rgb[2],10 ).toString( 16 )).slice( -2 ) +\n ( \"0\" + parseInt( rgb[3],10 ).toString( 16 )).slice( -2 ) : '';\n },\n isHex: function( hex ) {\n let regex = new RegExp('^#(?:[A-Fa-f0-9]{3}){1,2}$');\n return regex.test( hex );\n },\n getElementIcon: function ( icon_directory ) {\n let hostName = location.protocol + '//' + location.hostname;\n let img = document.createElement( 'img' );\n img.src = icon_directory;\n return img;\n },\n elementDragEndClear: function() {\n let wptbMovingMode = document.getElementsByClassName( 'wptb-moving-mode' );\n if ( wptbMovingMode.length > 0 ) {\n for( let i = 0; i < wptbMovingMode.length; i++ ) {\n wptbMovingMode[i].classList.remove( 'wptb-moving-mode' );\n }\n }\n\n let wptbDropHandles = document.getElementsByClassName( 'wptb-drop-handle' );\n if ( wptbDropHandles.length > 0 ) {\n for( let i = 0; i < wptbDropHandles.length; i++ ) {\n wptbDropHandles[i].style.display = 'none';\n }\n }\n\n let wptbDropBorderMarkers = document.getElementsByClassName( 'wptb-drop-border-marker' );\n if ( wptbDropBorderMarkers.length > 0 ) {\n for( let i = 0; i < wptbDropBorderMarkers.length; i++ ) {\n wptbDropBorderMarkers[i].style.display = 'none';\n }\n }\n },\n linkHttpCheckChange: function( link ) {\n if ( link ) {\n if ( link.indexOf( 'http://' ) == -1 && link.indexOf( 'https://' ) == -1 ) {\n let linkArr = link.split( '/' ),\n linkClean;\n if ( Array.isArray( linkArr ) && linkArr.length > 0 ) {\n linkClean = linkArr[linkArr.length - 1];\n }\n return document.location.protocol + '//' + linkClean;\n } else { \n return link;\n }\n } else {\n return '';\n }\n },\n dataTitleColumnSet: function( table ) {\n let rows = table.rows,\n rowHead = rows[0];\n let computedStyleRowHead = getComputedStyle( rowHead );\n \n let rowHeadChildren = rowHead.children;\n let contentsForHeader = {};\n for( let i = 0; i < rowHeadChildren.length; i++ ) {\n let tdElements = rowHeadChildren[i].children;\n \n for( let j = 0; j < tdElements.length; j++ ) {\n let element = tdElements[j];\n if( element.classList.contains( 'wptb-ph-element' ) ) {\n let infArr = element.className.match( /wptb-element-(.+)-(\\d+)/i );\n if( infArr[1] == 'text' ) {\n let p = element.querySelector( 'p' ),\n textContent = p.textContent,\n textAlign = p.style.textAlign;\n contentsForHeader[rowHeadChildren[i].dataset.xIndex] = [textContent, element.style.fontSize, \n element.style.color, computedStyleRowHead.backgroundColor, textAlign];\n break;\n }\n }\n }\n if( ! contentsForHeader[rowHeadChildren[i].dataset.xIndex] ) {\n contentsForHeader[rowHeadChildren[i].dataset.xIndex] = ['', '', \n '', computedStyleRowHead.backgroundColor, ''];\n }\n }\n for ( let i = 1; i < rows.length; i++ ) {\n let thisRow = rows[i],\n thisRowChildren = thisRow.children;\n for( let j = 0; j < thisRowChildren.length; j++ ) {\n if ( contentsForHeader[thisRowChildren[j].dataset.xIndex] ) {\n thisRowChildren[j].dataset.wptbTitleColumn = contentsForHeader[thisRowChildren[j].dataset.xIndex][0];\n thisRowChildren[j].dataset.wptbTitleColumnFontSize = contentsForHeader[thisRowChildren[j].dataset.xIndex][1];\n thisRowChildren[j].dataset.wptbTitleColumnColor = contentsForHeader[thisRowChildren[j].dataset.xIndex][2];\n thisRowChildren[j].dataset.wptbTitleBackgroundColor = contentsForHeader[thisRowChildren[j].dataset.xIndex][3];\n thisRowChildren[j].dataset.wptbTitleAlign = contentsForHeader[thisRowChildren[j].dataset.xIndex][4];\n } else {\n thisRowChildren[j].dataset.wptbTitleColumn = '';\n thisRowChildren[j].dataset.wptbTitleColumnFontSize = '';\n thisRowChildren[j].dataset.wptbTitleColumnColor = '';\n thisRowChildren[j].dataset.wptbTitleBackgroundColor = '';\n thisRowChildren[j].dataset.wptbTitleAlign = '';\n }\n }\n }\n },\n findAncestor: function( el, cls ) {\n while ( ( el = el.parentElement ) && !el.classList.contains( cls ) );\n return el;\n },\n rowIsTop: function( row ) {\n var parent = row.parentNode;\n if( parent.children[0] == row ) {\n return true;\n } else {\n return false;\n }\n },\n getSelectionText: function() {\n var txt = '';\n if (txt = window.getSelection) {\n txt = window.getSelection().toString();\n } else {\n txt = document.selection.createRange().text;\n }\n return txt;\n },\n elementOptionsPanelClear: function() {\n let elementOptionsGroup = document.getElementById( 'element-options-group' );\n if( elementOptionsGroup ) {\n elementOptionsGroup.innerHTML = '';\n }\n },\n wpColorPickerCheckChangeForTableStateSaving: function( event ) {\n if( event.originalEvent.type == 'external' ) {\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n } else {\n let wpPickerContainer = WPTB_Helper.findAncestor( event.target, 'wp-picker-container' );\n if( wpPickerContainer ) {\n if( event.originalEvent.type == 'square' || event.originalEvent.type == 'strip' ) {\n let body = document.getElementsByTagName( 'body' )[0];\n body.removeEventListener( 'mouseup', WPTB_Helper.irisStripMouseUpStateSaveManager, false );\n body.addEventListener( 'mouseup', WPTB_Helper.irisStripMouseUpStateSaveManager, false );\n }\n }\n }\n },\n irisStripMouseUpStateSaveManager: function() {\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n \n let body = document.getElementsByTagName( 'body' )[0];\n body.removeEventListener( 'mouseup', WPTB_Helper.irisStripMouseUpStateSaveManager, false );\n },\n wpColorPickerClear: function( attribute, isId ) {\n let input;\n if( isId ) {\n input = [document.getElementById( attribute )];\n input.length = 1;\n } else {\n input = document.getElementsByClassName( attribute );\n }\n for( let i = 0; i < input.length; i++ ) {\n let wpPickerContainer = WPTB_Helper.findAncestor( input[i], 'wp-picker-container' );\n if( wpPickerContainer ) {\n let parent = wpPickerContainer.parentNode;\n parent.removeChild( wpPickerContainer );\n let newInput = document.createElement( 'input' );\n if( isId ) {\n newInput.setAttribute( 'id', attribute );\n } else {\n newInput.classList.add( 'wptb-element-property', attribute );\n }\n newInput.value = \"\";\n parent.appendChild( newInput );\n }\n }\n },\n detectMode: function() {\n var url = window.location.href,\n regex = new RegExp('[?&]table(=([^&#]*)|&|#|$)'),\n results = regex.exec(url);\n if (!results) return false;\n if (!results[2]) return '';\n return decodeURIComponent(results[2].replace(/\\+/g, ' '));\n },\n getColumnWidth: function( table, cell ) {\n let xIndex = cell.dataset.xIndex;\n let xIndexes = table.querySelectorAll( '[data-x-index=\"' + xIndex + '\"]' );\n let cellWidth = cell.getCellDimensions().width;\n for( let i = 0; i < xIndexes.length; i++ ) {\n if( cellWidth > xIndexes[i].getCellDimensions().width ) {\n cellWidth = xIndexes[i].getCellDimensions().width;\n }\n }\n return cellWidth;\n },\n getRowHeight: function( table, cell ) {\n let yIndex = cell.dataset.yIndex;\n let yIndexes = table.querySelectorAll( '[data-y-index=\"' + yIndex + '\"]' );\n let cellHeight = cell.getCellDimensions().height;\n for( let i = 0; i < yIndexes.length; i++ ) {\n if( cellHeight > yIndexes[i].getCellDimensions().height ) {\n cellHeight = yIndexes[i].getCellDimensions().height;\n }\n }\n return cellHeight;\n },\n newElementProxy: function( el ) {\n if( el ) {\n let data = {kind: el};\n return new WPTB_ElementObject( data );\n }\n },\n wpColorPickerChange: function( event, ui ) {\n let uiColor;\n if( ui ) {\n uiColor = ui.color.toString();\n } else {\n uiColor = '';\n }\n \n let parent = WPTB_Helper.findAncestor( event.target, 'wp-picker-input-wrap' ).getElementsByClassName( 'wptb-color-picker' )[0], classe, type, ps, number;\n classe = parent.dataset.element.match(/wptb-options-(.+)-(\\d+)/i);\n type = classe[1];\n number = classe[2];\n let affectedEl = document.getElementsByClassName( 'wptb-element-' + type + '-' + number )[0];\n if ( type == 'button' ) {\n if ( parent.dataset.type == 'button-text-color' ) {\n affectedEl.getElementsByClassName( 'wptb-button' )[0].style.color = uiColor;\n } else {\n affectedEl.getElementsByClassName( 'wptb-button' )[0].style.backgroundColor = uiColor;\n }\n } else if( type == 'list' ) {\n let ps = affectedEl.querySelectorAll( 'p' );\n if( ps.length > 0 ) {\n for ( let i = 0; i < ps.length; i++ ) {\n ps[i].style.color = uiColor;\n }\n }\n } else if( type == 'star_rating' ) {\n if ( parent.dataset.type == 'star-color' ) {\n let ratingStar = affectedEl.querySelectorAll('li');\n for( let i = 0; i < ratingStar.length; i++ ) {\n let span = ratingStar[i].getElementsByTagName( 'span' );\n for( let j = 0; j < span.length; j++ ) {\n span[j].style.fill = uiColor;\n }\n }\n } else if( parent.dataset.type == 'numeral-rating-color' ) {\n let wptbTextMessageSize = affectedEl.querySelector('.wptb-number-rating');\n wptbTextMessageSize.style.color = uiColor;\n }\n\n } else {\n affectedEl.style.color = uiColor;\n }\n },\n numberImputSize: function ( wptbNumberInputs, maxCount, maxValue ) {\n wptbNumberInputs.onkeydown = function() {\n let thisValue = this.value;\n thisValue = String( thisValue );\n if ( thisValue[0] == 0 ) {\n this.value = \"\";\n } else {\n thisValue = thisValue.substring( 0, maxCount );\n this.value = thisValue;\n }\n }\n wptbNumberInputs.onkeyup = function( ) {\n let thisValue = this.value;\n if ( parseInt( thisValue, 10 ) > parseInt( maxValue, 10 ) ) {\n this.value = maxValue;\n }\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n },\n ucfirst: function( str ) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n },\n wptbDocumentEventGenerate: function( eventName, element, details ) {\n if( eventName && element ) {\n if( ! details ) {\n details = true;\n }\n let event = new CustomEvent( eventName, { detail: details, bubbles: true } );\n element.dispatchEvent( event );\n }\n },\n // run script for the pointed element\n elementStartScript: function( element ) {\n //let script = element.getElementsByTagName( 'script' );\n let infArr = element.className.match(/wptb-element-(.+)-(\\d+)/i);\n if( infArr && Array.isArray( infArr ) ) {\n let kind = infArr[1];\n if( kind ) {\n// let wpTemplateId = 'wptb-' + kind + '-script';\n// let template = wp.template( wpTemplateId );\n// let data = {elemClass: infArr[0]};\n// let elementScriptText = template( data );\n// elementScriptText = elementScriptText.replace(/\\r|\\n|\\t/g, '').trim();\n//\n// let scriptNew = document.createElement( 'script' );\n// scriptNew.setAttribute( 'type', 'text/javascript' );\n// scriptNew.innerHTML = elementScriptText;\n// element.parentNode.appendChild( scriptNew );\n \n// element.parentNode.removeChild( scriptNew );\n if( kind in WPTB_ElementsScriptsLauncher ) {\n WPTB_ElementsScriptsLauncher[kind]( element );\n }\n }\n }\n },\n // deletes event handlers from the pointed option element and from all his daughter elements\n deleteEventHandlers: function( element ) {\n if( element ) {\n jQuery( element ).off();\n let elementChildren = element.children;\n if( elementChildren ) {\n for ( let i = 0; i < elementChildren.length; i++ ) {\n WPTB_Helper.deleteEventHandlers( elementChildren[i] );\n }\n }\n } else {\n return;\n }\n },\n // replace all occurrences in a string\n replaceAll: function( string, search, replace ){\n return string.split( search ).join( replace );\n },\n // clears code from TinyMCE attributes\n elementClearFromTinyMce: function( element ) {\n let mceContentBodys = element.querySelectorAll( '.mce-content-body' );\n if( mceContentBodys.length > 0 ) {\n for ( let k = 0; k < mceContentBodys.length; k++ ) {\n mceContentBodys[k].classList.remove( 'mce-content-body' );\n }\n }\n\n let dataMceStyle = element.querySelectorAll( '[data-mce-style]' );\n if ( dataMceStyle.length > 0 ) {\n for ( let k = 0; k < dataMceStyle.length; k++ ) {\n dataMceStyle[k].removeAttribute( 'data-mce-style' );\n }\n }\n \n let mceEditFocus = element.querySelectorAll( '.mce-edit-focus' );\n if( mceEditFocus.length > 0 ) {\n for ( let k = 0; k < mceEditFocus.length; k++ ) {\n mceEditFocus[k].classList.remove( 'mce-edit-focus' );\n }\n }\n\n let contentEditable = element.querySelectorAll( '[contenteditable]' );\n if ( contentEditable.length > 0 ) {\n for ( let k = 0; k < contentEditable.length; k++ ) {\n contentEditable[k].removeAttribute( 'contenteditable' );\n }\n }\n\n let spellCheck = element.querySelectorAll( '[spellcheck]' );\n if ( spellCheck.length > 0 ) {\n for ( let k = 0; k < spellCheck.length; k++ ) {\n spellCheck[k].removeAttribute( 'spellcheck' );\n }\n }\n\n let mceIds = element.querySelectorAll( '[id^=mce_]' );\n if ( mceIds.length > 0 ) {\n for ( let k = 0; k < mceIds.length; k++ ) {\n mceIds[k].removeAttribute( 'id' );\n }\n }\n \n return element;\n },\n elementOptionContainerCustomClassSet: function( targetInput, customClassForContainer ) {\n if( targetInput && customClassForContainer ) {\n let containerElement = WPTB_Helper.findAncestor( targetInput, 'wptb-element-option' );\n if( containerElement ) {\n containerElement.classList.add( customClassForContainer );\n }\n }\n },\n elementOptionContainerAdditionalStyles: function( targetInput, containerAdditionalStyles ) {\n if( targetInput && containerAdditionalStyles ) {\n let containerElement = WPTB_Helper.findAncestor( targetInput, 'wptb-element-option' );\n let containerStylesArrOne = containerAdditionalStyles.split( ';' );\n\n if( containerElement && containerStylesArrOne ) {\n function containerStylesSet( containerStyleStr, containerElement ) {\n if( containerStyleStr ) {\n containerStyleStrArr = containerStyleStr.split( ':' );\n\n if( containerStyleStrArr && Array.isArray( containerStyleStrArr ) ) {\n containerElement.style[containerStyleStrArr[0]] = containerStyleStrArr[1];\n }\n }\n }\n if( containerStylesArrOne && Array.isArray( containerStylesArrOne ) ) {\n for( let i = 0; i < containerStylesArrOne.length; i++ ) {\n console.log( containerStylesArrOne );\n if( containerStylesArrOne[i] ) {\n containerStylesSet( containerStylesArrOne[i], containerElement );\n }\n }\n } else {\n containerStylesSet( containerStylesArrOne, containerElement );\n }\n }\n }\n },\n // function which set handler for event of changes of control\n controlsInclude: function( element, functionHandler ) {\n if( element && typeof element === 'object' && typeof functionHandler === 'function' ) {\n element.addEventListener( 'element:control:active', function() {\n let infArr = element.className.match( /wptb-element-(.+)-(\\d+)/i ),\n elementKind;\n\n if( infArr && Array.isArray( infArr ) ) {\n elementKind = infArr[1];\n }\n\n if( ! element.hasOwnProperty( 'сontrolsConnectIndic' ) || element.сontrolsConnectIndic !== true && elementKind ) {\n let elementsSettingsTemplateJs = document.getElementsByClassName( 'wptb-element-datas' );\n if( elementsSettingsTemplateJs.length > 0 ) {\n elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];\n\n let elementsSettings = elementsSettingsTemplateJs.innerHTML;\n let controlClassesNames = [];\n if( elementsSettings ) {\n elementsSettings = JSON.parse( elementsSettings );\n if( elementsSettings && typeof elementsSettings === 'object' ) {\n if( 'tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2] in elementsSettings ) {\n let elementSettings = elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]];\n if( elementSettings && typeof elementSettings === 'object' ) {\n Object.keys( elementSettings ).forEach( function( key ) {\n let regularText = new RegExp( 'data-wptb-el-' + elementKind + '-(\\\\d+)-(.+)', \"i\" );\n let keyInfArr = key.match( regularText );\n if( keyInfArr && Array.isArray( keyInfArr ) ) {\n let controlClass = key.replace( 'data-', '' );\n controlClassesNames.push( [controlClass, keyInfArr[2]] );\n }\n });\n }\n }\n }\n }\n\n for( let i = 0; i < controlClassesNames.length; i++ ) {\n element.addEventListener( 'wptb-control:' + controlClassesNames[i][0], function() {\n let controls = {};\n let controlName = controlClassesNames[i][1];\n let control = document.getElementsByClassName( controlClassesNames[i][0] );\n if( control.length > 0 && controlName ) {\n let targetControlValue = WPTB_Helper.targetControlValueGet( control );\n\n controls[controlName] = targetControlValue;\n }\n\n functionHandler( controls, element );\n }, false );\n\n element.сontrolsConnectIndic = true;\n }\n }\n }\n }, false );\n }\n },\n oneControlInclude: function( element, functionHandler, controlName ) {\n if( element && typeof element === 'object' && typeof functionHandler === 'function' && typeof controlName === 'string' ) {\n let infArr = element.className.match( /wptb-element-((.+-)\\d+)/i ),\n elementKind;\n \n if( infArr && Array.isArray( infArr ) ) {\n elementKind = infArr[1].split( '-' )[0];\n \n let wptbContrlStacksConfigId = 'wptb-' + elementKind + '-control-stack';\n let tmplControlsConfig = wp.template( wptbContrlStacksConfigId );\n let data = {\n container: '.' + infArr[0]\n };\n let jsonControlsConfigJson = tmplControlsConfig( data );\n let jsonControlsConfig = JSON.parse( jsonControlsConfigJson );\n \n if( jsonControlsConfig && typeof jsonControlsConfig === 'object' && jsonControlsConfig.hasOwnProperty( controlName ) ) {\n let controlClassName = 'wptb-el-' + infArr[1] + '-' + controlName;\n \n element.addEventListener( 'wptb-control:' + controlClassName, function( event ) {\n let control = document.getElementsByClassName( controlClassName );\n if( control.length > 0 ) {\n let targetControlValue = WPTB_Helper.targetControlValueGet( control );\n\n functionHandler( targetControlValue, element );\n }\n }, false );\n }\n }\n } else {\n return false;\n }\n },\n //\n innerElementCopyIncludeHandler: function( element, functionHandler ) {\n if( element && typeof element === 'object' && typeof functionHandler === 'function' ) {\n element.addEventListener( 'wptb-inner-element:copy', function( event ) {\n let innerElement = event.detail;\n if( innerElement ) {\n WPTB_Helper.elementClearFromTinyMce( innerElement );\n functionHandler( innerElement, element );\n }\n }, false );\n }\n },\n //\n appearDependOnControl: function( dependOn, targetControlElementClass ) {\n if( Array.isArray( dependOn ) ) {\n let dependOnControlName = dependOn[0];\n let infArr = targetControlElementClass.match( /wptb-el-((.+-)\\d+)-(.+)/i );\n \n if( infArr && Array.isArray( infArr ) ) {\n let controlName = infArr[3];\n\n let dependOnControlElementClass = targetControlElementClass.replace( controlName, dependOnControlName );\n\n let dependOnControlElement = document.getElementsByClassName( dependOnControlElementClass );\n\n if( dependOnControlElement.length > 0 ) {\n dependOnControlElement = dependOnControlElement[0];\n let targetControlElement = document.getElementsByClassName( targetControlElementClass );\n if( targetControlElement.length > 0 ) {\n targetControlElement = targetControlElement[0];\n let controlContainerElem = WPTB_Helper.findAncestor( targetControlElement, 'wptb-element-option' );\n\n if( controlContainerElem ) {\n function showHideDependOnControlElement( dependOnControlElementKind ) {\n \n let elementsSettingsTemplateJs = document.getElementsByClassName( 'wptb-element-datas' );\n if( elementsSettingsTemplateJs.length > 0 ) {\n elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];\n\n let elementsSettings = elementsSettingsTemplateJs.innerHTML;\n if( elementsSettings ) {\n elementsSettings = JSON.parse( elementsSettings );\n if( elementsSettings && typeof elementsSettings === 'object' && \n ( 'tmpl-wptb-el-datas-' + dependOnControlElementKind ) in elementsSettings ) {\n let elementSettings = elementsSettings['tmpl-wptb-el-datas-' + dependOnControlElementKind];\n if( elementSettings && typeof elementSettings === 'object' && \n ( 'data-wptb-el-' + dependOnControlElementKind + '-' + dependOnControlName ) in elementSettings ) {\n let elementSettingValue = elementSettings['data-wptb-el-' + dependOnControlElementKind + '-' + dependOnControlName];\n \n if( elementSettingValue ) {\n if( dependOn[1] && Array.isArray( dependOn[1] ) && \n ( dependOn[1].indexOf( elementSettingValue ) !== -1 ) ) {\n controlContainerElem.style.display = 'block';\n } else if( dependOn[2] && Array.isArray( dependOn[2] ) && \n ( dependOn[2].indexOf( elementSettingValue ) !== -1 ) ) {\n controlContainerElem.style.display = 'none';\n }\n }\n }\n }\n }\n }\n }\n\n showHideDependOnControlElement( infArr[1] );\n\n dependOnControlElement.addEventListener( 'change', function() {\n showHideDependOnControlElement( infArr[1] );\n }, false );\n }\n }\n }\n }\n }\n },\n //\n controlsStateManager: function ( targetControlClass, controlChangeIndic ) {\n let targetControls = document.getElementsByClassName( targetControlClass );\n if( targetControls.length > 0 ) {\n //targetControls = targetControls[0];\n \n let infArr = targetControlClass.match( /wptb-el-((.+-)\\d+)-(.+)/i );\n \n if( infArr && Array.isArray( infArr ) ) {\n let selectorElement;\n selectorElement = document.querySelector( '.wptb-element-' + infArr[1] );\n \n if( selectorElement ) {\n let elementsSettingsTemplatesJs;\n let elementSettings = {};\n let elementsSettings;\n elementsSettingsTemplatesJs = document.getElementsByClassName( 'wptb-element-datas' );\n if( elementsSettingsTemplatesJs.length == 0 || elementsSettingsTemplatesJs[0].innerHTML == '' ) {\n let targetControlValue = WPTB_Helper.targetControlValueGet( targetControls );\n elementSettings['data-' + targetControlClass] = targetControlValue;\n\n elementsSettings = {};\n elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] = elementSettings;\n elementsSettings = JSON.stringify( elementsSettings );\n\n if( elementsSettingsTemplatesJs.length == 0 ) {\n elementsSettingsTemplatesJs = document.createElement( 'script' );\n elementsSettingsTemplatesJs.setAttribute( 'type', 'text/html' );\n elementsSettingsTemplatesJs.setAttribute( 'class', 'wptb-element-datas' );\n } else {\n elementsSettingsTemplatesJs = elementsSettingsTemplatesJs[0];\n }\n\n elementsSettingsTemplatesJs.innerHTML = elementsSettings;\n\n let body = document.getElementsByTagName('body')[0];\n body.appendChild( elementsSettingsTemplatesJs );\n } else {\n elementsSettingsTemplatesJs = elementsSettingsTemplatesJs[0];\n elementsSettings = elementsSettingsTemplatesJs.innerHTML;\n if( elementsSettings ) {\n elementsSettings = JSON.parse( elementsSettings );\n\n if( elementsSettings && typeof elementsSettings === 'object' ) {\n \n \n if( controlChangeIndic ) {\n let targetControlValue = WPTB_Helper.targetControlValueGet( targetControls );\n if( ! ( ( 'tmpl-wptb-el-datas-' + infArr[1] ) in elementsSettings ) || \n typeof elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] !== 'object') {\n elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] = {};\n }\n elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-' + targetControlClass] = targetControlValue;\n elementsSettingsTemplatesJs.innerHTML = JSON.stringify( elementsSettings );\n } else if( ! ( ( ( 'tmpl-wptb-el-datas-' + infArr[1] ) in elementsSettings ) && \n typeof elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] === 'object' && \n ( 'data-' + targetControlClass ) in elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] ) ) {\n let targetControlValue = WPTB_Helper.targetControlValueGet( targetControls );\n if( ! ( ( 'tmpl-wptb-el-datas-' + infArr[1] ) in elementsSettings ) || \n typeof elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] !== 'object') {\n elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] = {};\n }\n elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-' + targetControlClass] = targetControlValue;\n elementsSettingsTemplatesJs.innerHTML = JSON.stringify( elementsSettings );\n } else if( ( ( 'tmpl-wptb-el-datas-' + infArr[1] ) in elementsSettings ) && \n typeof elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] === 'object' && \n ( 'data-' + targetControlClass ) in elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] ) {\n for( let i = 0; i < targetControls.length; i++ ) {\n if( targetControls[i].type == 'checkbox' ) {\n let targetControlValue;\n if( targetControls[i].name ) {\n targetControlValue = elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-' + targetControlClass][targetControls[i].name];\n } else {\n targetControlValue = elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-' + targetControlClass];\n }\n \n if( targetControlValue == 'checked' ) {\n targetControls[i].checked = true;\n } else if( targetControlValue == 'unchecked' ) {\n targetControls[i].checked = false;\n }\n } else {\n targetControls[i].value = elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-' + targetControlClass];\n }\n }\n }\n }\n }\n }\n }\n }\n }\n },\n //\n targetControlValueGet: function( targetControls ) {\n let targetControlValue;\n for( let i = 0; i < targetControls.length; i++ ) {\n if( targetControls[i].type == 'checkbox' && targetControls[i].name ) {\n if( ! targetControlValue ) targetControlValue = {};\n if( targetControls[i].checked == true ) {\n targetControlValue[targetControls[i].name] = 'checked';\n } else {\n targetControlValue[targetControls[i].name] = 'unchecked';\n }\n } else if( targetControls[i].type == 'checkbox' ) {\n if( targetControls[i].checked == true ) {\n targetControlValue = 'checked';\n } else {\n targetControlValue = 'unchecked';\n }\n } else {\n targetControlValue = targetControls[i].value;\n }\n }\n return targetControlValue;\n },\n //\n elementControlsStateCopy: function( elementProt, copyElem ) {\n if( elementProt && copyElem ) {\n let infArrProt = elementProt.className.match( /wptb-element-((.+-)\\d+)/i );\n let infArrCopy = copyElem.className.match( /wptb-element-((.+-)\\d+)/i );\n if( infArrProt && Array.isArray( infArrProt ) &&\n infArrCopy && Array.isArray( infArrCopy )) {\n let elemProtKind = infArrProt[1];\n let elemCopyKind = infArrCopy[1];\n let elementsSettingsTemplateJs = document.getElementsByClassName( 'wptb-element-datas' );\n if( elementsSettingsTemplateJs.length > 0 ) {\n elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];\n \n let elementsSettings = elementsSettingsTemplateJs.innerHTML;\n if( elementsSettings ) {\n elementsSettings = JSON.parse( elementsSettings );\n \n if( elementsSettings && typeof elementsSettings === 'object' ) {\n let elementSettingsProt = elementsSettings['tmpl-wptb-el-datas-' + elemProtKind];\n if( elementSettingsProt && typeof elementSettingsProt === 'object' ) {\n let elementSettingsCopy = {};\n \n Object.keys( elementSettingsProt ).forEach( function( key ) {\n let elementSettingValue = elementSettingsProt[key];\n let elementSettingKeyCopy = key.replace( elemProtKind, elemCopyKind );\n elementSettingsCopy[elementSettingKeyCopy] = elementSettingValue;\n });\n \n if( Object.keys( elementSettingsCopy ).length > 0 ) {\n elementsSettings['tmpl-wptb-el-datas-' + elemCopyKind] = elementSettingsCopy;\n \n elementsSettings = JSON.stringify( elementsSettings );\n elementsSettingsTemplateJs.innerHTML = elementsSettings;\n }\n }\n }\n }\n }\n }\n }\n },\n //\n elementControlsStateDelete: function( element, nameControl ) {\n let infArr = element.className.match( /wptb-element-(.+)-(\\d+)/i );\n let body = document.getElementsByTagName( 'body' )[0];\n let wptbElementDatas = body.getElementsByClassName( 'wptb-element-datas' );\n if( infArr && Array.isArray( infArr ) && wptbElementDatas.length > 0 ) {\n wptbElementDatas = wptbElementDatas[0];\n let elementsSettings = wptbElementDatas.innerHTML;\n if( elementsSettings ) {\n elementsSettings = JSON.parse( elementsSettings );\n if( elementsSettings && typeof elementsSettings === 'object' &&\n ( ( 'tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2] ) in elementsSettings ) ) {\n if( ! nameControl ) {\n delete elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]];\n } else {\n if( elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]] && \n typeof elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]] === 'object' &&\n ( 'data-wptb-el-' + infArr[1] + '-' + infArr[2] + '-' + nameControl ) in elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]] ) {\n delete elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]]['data-wptb-el-' + infArr[1] + '-' + infArr[2] + '-' + nameControl];\n }\n }\n\n if( Object.keys( elementsSettings ).length == 0 ) {\n body.removeChild( wptbElementDatas );\n } else {\n elementsSettings = JSON.stringify( elementsSettings );\n wptbElementDatas.innerHTML = elementsSettings;\n }\n }\n }\n }\n },\n // \n elementOptionsSet: function( kind, element ) {\n // get controls config for this element\n let wptbContrlStacksConfigId = 'wptb-' + kind + '-control-stack';\n let tmplControlsConfig = wp.template( wptbContrlStacksConfigId );\n let data;\n let elementContainerClass;\n let elementOptionClassIndic;\n let elementOptionsGroup;\n let elementOptionsGroupId;\n let wptbelementOptionClass;\n \n // create a container for inserting controls of this item\n let wptbelementOptionsContainer = document.createElement( 'div' );\n \n let infArr = element.className.match( /wptb-element-((.+-)\\d+)/i );\n if( ! infArr && element.classList.contains( 'wptb-preview-table' ) ) {\n let table_id = WPTB_Helper.detectMode();\n element.classList.add( 'wptb-element-main-table_setting-' + table_id );\n infArr = element.className.match( /wptb-element-((.+-)\\d+)/i );\n }\n data = {\n container: '.' + infArr[0]\n };\n\n elementContainerClass = infArr[0];\n elementOptionClassIndic = infArr[1];\n \n if( ! element.classList.contains( 'wptb-preview-table' ) ) {\n let children = document.getElementById( 'element-options-group' ).childNodes;\n for ( let i = 0; i < children.length; i++) {\n if ( children[i].style )\n children[i].style.display = 'none';\n }\n \n wptbelementOptionsContainer.classList.add( 'wptb-element-options', 'wptb-options-' + infArr[1] );\n \n // hide wptb-elements-container and wptb-settings-section\n document.getElementsByClassName( 'wptb-elements-container' )[0].style.display = 'none';\n document.getElementsByClassName( 'wptb-settings-section' )[0].style.display = 'none';\n\n // show element-options-group \n document.getElementById( 'element-options-group' ).style.display = 'block';\n \n elementOptionsGroupId = 'element-options-group';\n wptbelementOptionClass = 'wptb-element-option';\n } else {\n elementOptionsGroupId = 'table-settings-group';\n wptbelementOptionClass = 'wptb-element-option';\n }\n\n let jsonControlsConfigJson = tmplControlsConfig( data );\n let jsonControlsConfig = JSON.parse( jsonControlsConfigJson );\n\n // clear elements from options group\n //document.getElementById( 'element-options-group' ).innerHTML = '';\n elementOptionsGroup = document.getElementById( elementOptionsGroupId );\n let elementOptionsGroupChildren = elementOptionsGroup.children;\n for( let i = 0; i < elementOptionsGroupChildren.length; i++ ) {\n elementOptionsGroup.removeChild( elementOptionsGroupChildren[i] );\n }\n\n \n // insert created container into element-option-group tag\n document.getElementById( elementOptionsGroupId ).appendChild( wptbelementOptionsContainer );\n\n // show created container\n wptbelementOptionsContainer.style.display = 'block';\n\n // array for save all scrips for each controls\n let controlScriptsArr = [];\n\n // array for keep \"appear depend on\" parametrs\n let controlappearDependOnControl = [];\n\n // create controls\n let i = 0;\n Object.keys( jsonControlsConfig ).forEach( function( key ) {\n let data = jsonControlsConfig[key];\n data.controlKey = key;\n\n // get necessary wp js template\n let tmplControlTemplate = wp.template( 'wptb-' + data.type + '-control' );\n\n data.elemContainer = elementContainerClass;\n data.elementControlTargetUnicClass = 'wptb-el-' + elementOptionClassIndic + '-' + data.controlKey;\n let controlTemplate = tmplControlTemplate( data );\n\n if( 'appearDependOnControl' in data ) {\n if( Array.isArray( data.appearDependOnControl ) ) {\n controlappearDependOnControl.push( [data.appearDependOnControl, data.elementControlTargetUnicClass] );\n }\n }\n\n //console.log( controlTemplate );\n\n let wptbElementOptionContainer = document.createElement( 'div' );\n wptbElementOptionContainer.classList.add( wptbelementOptionClass, 'wptb-settings-items' );\n\n if( data.customClassForContainer ) {\n wptbElementOptionContainer.classList.add( data.customClassForContainer );\n }\n\n if( data.containerAdditionalStyles ) {\n wptbElementOptionContainer.setAttribute( 'style', data.containerAdditionalStyles );\n }\n\n wptbElementOptionContainer.innerHTML = controlTemplate;\n\n wptbelementOptionsContainer.appendChild( wptbElementOptionContainer );\n\n let helperJavascriptElem = wptbElementOptionContainer.getElementsByTagName( 'wptb-template-script' );\n if( helperJavascriptElem.length > 0 ) {\n helperJavascriptElem = helperJavascriptElem[0];\n let helperJavascriptCode = helperJavascriptElem.innerText;\n wptbElementOptionContainer.removeChild( helperJavascriptElem );\n let script = document.createElement( 'script' );\n script.setAttribute( 'type', 'text/javascript' );\n script.innerHTML = helperJavascriptCode.replace(/\\r|\\n|\\t/g, '').trim();\n controlScriptsArr.push( script );\n }\n\n i++;\n });\n\n // run the scripts of controls\n if( controlScriptsArr.length > 0 ) {\n for( let i = 0; i < controlScriptsArr.length; i++ ) {\n wptbelementOptionsContainer.appendChild( controlScriptsArr[i] );\n }\n }\n\n // run appearDependOnControl function\n for ( let i = 0; i < controlappearDependOnControl.length; i++ ) {\n WPTB_Helper.appearDependOnControl( controlappearDependOnControl[i][0], controlappearDependOnControl[i][1] );\n }\n\n WPTB_Helper.wptbDocumentEventGenerate( 'element:control:active', element );\n },\n // function for create, update css for element\n managerExternalCssStyles: function( elementContainer, selector, cssName, cssValue ) {\n let infArr = elementContainer.match( /wptb-element-main(.+)-(\\d+)/i );\n if( ! infArr || ! Array.isArray( infArr ) ) {\n let table = document.getElementsByClassName( 'wptb-preview-table' );\n \n if( table.length > 0 ) {\n table = table[0];\n \n let infArr = table.className.match( /wptb-element-main(.+)-(\\d+)/i );\n if( infArr && Array.isArray( infArr ) ) {\n selector = '.' + infArr[0] + ' ' + selector;\n }\n }\n }\n \n let head = document.head;\n if( head ) {\n let cssForThisElement = head.querySelector( '#styles-' + elementContainer );\n if( cssForThisElement ) {\n let cssText = cssForThisElement.innerHTML;\n if( cssText ) {\n let cssTextArrFirst = cssText.split( '}' );\n cssTextArrFirst.pop();\n let selectorExists = false;\n for( let i = 0; i < cssTextArrFirst.length; i++ ) {\n let cssTextArrSecond = cssTextArrFirst[i].split( '{' );\n if( cssTextArrSecond[0] === selector ) {\n let cssTextArrThird = cssTextArrSecond[1].split( ';' );\n cssTextArrThird.pop();\n let cssNameExists = false;\n for( let j = 0; j < cssTextArrThird.length; j++ ) {\n let cssTextArrFourth = cssTextArrThird[j].split( ':' );\n if( cssTextArrFourth[0] === cssName ) {\n if( cssValue ) {\n cssTextArrThird[j] = cssName + ':' + cssValue;\n } else {\n cssTextArrThird.splice( j, 1 );\n }\n \n cssTextArrSecond[1] = cssTextArrThird.join( ';' ) ? cssTextArrThird.join( ';' ) + ';' : '';\n cssNameExists = true;\n break;\n }\n }\n if( ! cssNameExists ) {\n if( cssValue ) {\n cssTextArrSecond[1] += cssName + ':' + cssValue + ';';\n }\n }\n if( cssTextArrSecond[1] ) {\n cssTextArrFirst[i] = cssTextArrSecond[0] + '{' + cssTextArrSecond[1]\n } else {\n cssTextArrFirst.splice( i, 1 );\n }\n if( cssTextArrFirst.join( '}' ) ) {\n cssForThisElement.innerHTML = cssTextArrFirst.join( '}' ) + '}';\n } else {\n head.removeChild( cssForThisElement );\n }\n \n selectorExists = true;\n break;\n }\n }\n\n if( ! selectorExists ) {\n if( cssValue ) {\n cssForThisElement.innerHTML = cssText + selector + '{' + cssName + ':' + cssValue + ';}';\n } else {\n cssForThisElement.innerHTML = cssText;\n }\n }\n } else {\n if( cssValue ) {\n cssForThisElement.innerHTML = selector + '{' + cssName + ':' + cssValue + ';}';\n } else {\n head.removeChild( cssForThisElement );\n }\n }\n } else {\n if( cssValue ) {\n let cssForThisElement = document.createElement( 'style' );\n cssForThisElement.setAttribute( 'id', 'styles-' + elementContainer );\n cssForThisElement.classList.add( 'styles-wptb-elements' );\n cssForThisElement.innerHTML = selector + '{' + cssName + ':' + cssValue + ';}';\n head.appendChild( cssForThisElement );\n }\n }\n }\n },\n // function for deleting all external CSS for the element\n externalCssStylesDelete: function( elementContainerClass ) {\n let head = document.head;\n if( head ) {\n let cssForThisElement = head.querySelector( '#styles-' + elementContainerClass );\n \n if( cssForThisElement ) {\n head.removeChild( cssForThisElement );\n }\n }\n },\n // function for copy all external CSS for the element\n externalCssStylesCopy: function( activeElement, copyElement ) {\n if( activeElement ) {\n let infArr = activeElement.className.match( /wptb-element-(.+)-(\\d+)/i );\n if( infArr && Array.isArray( infArr ) ) {\n let activeElemClass = infArr[0];\n \n let head = document.head;\n if( head ) {\n let cssForActiveElement = head.querySelector( '#styles-' + activeElemClass );\n\n if( cssForActiveElement ) {\n let cssForNewElement = cssForActiveElement.cloneNode( true );\n \n cssForNewElement.removeAttribute( 'id', 'styles-' + activeElemClass );\n \n let infArrCopyEl = copyElement.className.match( /wptb-element-(.+)-(\\d+)/i );\n if( infArrCopyEl && Array.isArray( infArrCopyEl ) ) {\n cssForNewElement.setAttribute( 'id', 'styles-' + infArrCopyEl[0] );\n let cssForActiveElementInnerHTML = cssForActiveElement.innerHTML;\n let cssForNewElementInnerHTML = WPTB_Helper.replaceAll( cssForActiveElementInnerHTML, activeElemClass, infArrCopyEl[0] );\n cssForNewElement.innerHTML = cssForNewElementInnerHTML;\n head.appendChild( cssForNewElement );\n }\n }\n }\n }\n }\n },\n // function for convertation elements stiles in json\n elementsStylesConvertToObject: function() {\n let head = document.head;\n let stylesElements = head.querySelectorAll( '.styles-wptb-elements' );\n let stylesObj = {};\n for( let i = 0; i < stylesElements.length; i++ ) {\n let styleElemId = stylesElements[i].getAttribute( 'id' );\n if( styleElemId && stylesElements[i].innerHTML ) {\n stylesObj[styleElemId] = stylesElements[i].innerHTML;\n }\n }\n \n if( Object.keys( stylesObj ).length != 0 ) {\n return JSON.stringify( stylesObj );\n }\n return '';\n },\n // function for set scc styles tags to head\n elementsStylesSetFromObject: function( jsonObject ) {\n let head = document.head;\n if( head ) {\n let stylesElements = head.querySelectorAll( '.styles-wptb-elements' );\n if( stylesElements.length > 0 ) {\n stylesElements = [...stylesElements];\n for( let i = 0; i < stylesElements.length; i++ ) {\n head.removeChild( stylesElements[i] );\n }\n }\n if( jsonObject ) {\n let stylesObj = JSON.parse( jsonObject );\n if( Object.keys( stylesObj ).length != 0 ) {\n Object.keys( stylesObj ).forEach( function( key ) {\n let cssText = stylesObj[key];\n let styleCss = document.createElement( 'style' );\n styleCss.setAttribute( 'id', key );\n styleCss.classList.add( 'styles-wptb-elements' );\n styleCss.innerHTML = cssText;\n head.appendChild( styleCss );\n });\n }\n }\n }\n },\n // function for table saving\n saveTable: function( event, startSaving, previewSaving ) {\n if( ! previewSaving && ! startSaving ) {\n if( ( ! event.target.dataset.wptbTableStateNumberSave && window.wptbTableStateNumberShow == 0 ) || \n window.wptbTableStateNumberShow == event.target.dataset.wptbTableStateNumberSave ) {\n //return;\n }\n }\n \n if( ! previewSaving ) {\n let bar = document.querySelector( '.wptb-edit-bar' );\n if ( bar && bar.classList.contains( 'visible' ) ) {\n let table = document.getElementsByClassName( 'wptb-preview-table' )[0];\n table.toggleTableEditMode();\n }\n }\n\n let http = new XMLHttpRequest(),\n url = ( wptb_admin_object ? wptb_admin_object.ajaxurl : ajaxurl ) + \"?action=save_table\",\n t = document.getElementById( 'wptb-setup-name' ).value.trim(),\n messagingArea,\n code,\n datas;\n \n code = document.getElementsByClassName( 'wptb-preview-table' );\n \n let postId;\n if (( rs = WPTB_Helper.detectMode() ) || ( rs = document.wptbId )) {\n postId = rs;\n }\n let paramIdsNecessaryChange = false;\n if( code.length > 0 ) {\n code = code[0];\n let codeClone = code.cloneNode( true );\n if( postId ) {\n if( codeClone.classList.contains( 'wptb-element-main-table_setting-startedid-0' ) ) {\n codeClone.classList.remove( 'wptb-element-main-table_setting-startedid-0' );\n codeClone.classList.add( 'wptb-element-main-table_setting-' + postId );\n paramIdsNecessaryChange = true;\n }\n }\n codeClone.columns = code.columns;\n code = WPTB_Stringifier( codeClone );\n code = code.outerHTML;\n } else { \n code = '';\n }\n \n if( ! previewSaving ) {\n datas = '';\n let datas_containers = document.getElementsByClassName( 'wptb-element-datas' );\n\n if( datas_containers.length > 0 ) {\n if( datas_containers[0].innerHTML ) {\n datas = datas_containers[0].innerHTML;\n\n if( paramIdsNecessaryChange ) {\n datas = WPTB_Helper.replaceAll( datas, 'tmpl-wptb-el-datas-main-table_setting-startedid-0', \n 'tmpl-wptb-el-datas-main-table_setting-' + postId );\n\n datas = WPTB_Helper.replaceAll( datas, 'data-wptb-el-main-table_setting-startedid-0', \n 'data-wptb-el-main-table_setting-' + postId );\n }\n }\n }\n }\n\n let styleObjJson = WPTB_Helper.elementsStylesConvertToObject();\n if( paramIdsNecessaryChange ) {\n styleObjJson = WPTB_Helper.replaceAll( styleObjJson, '.wptb-element-main-table_setting-startedid-0', \n '.wptb-element-main-table_setting-' + postId );\n }\n \n if ( t === '' && code === '' ) {\n let messagingAreaText = '';\n if( t === '' ) messagingAreaText += 'You must assign a name to the table before saving it.</br>';\n if( code === '' ) messagingAreaText += 'Table wasn\\'t created';\n messagingArea = document.getElementById( 'wptb-messaging-area' );\n messagingArea.innerHTML = '<div class=\"wptb-error wptb-message\">Error: ' + messagingAreaText + '</div>';\n messagingArea.classList.add( 'wptb-warning' );\n setTimeout(function () {\n messagingArea.removeChild( messagingArea.firstChild );\n }, 4000 );\n return;\n }\n\n let params = {\n title: t,\n content: code,\n elements_datas: datas,\n elements_styles: styleObjJson,\n security_code: wptb_admin_object.security_code\n };\n \n \n if( previewSaving ) {\n params.preview_saving = previewSaving;\n }\n \n if ( postId ) {\n params.id = postId;\n }\n params = JSON.stringify( params );\n\n http.open('POST', url, true);\n http.setRequestHeader( 'Content-type', 'application/json; charset=utf-8' );\n\n http.onreadystatechange = function ( action ) {\n if ( this.readyState == 4 && this.status == 200 ) {\n var data = JSON.parse( http.responseText );\n messagingArea = document.getElementById( 'wptb-messaging-area' );\n\n if ( data[0] == 'saved' ) {\n console.log(window.wptbTableStateSaving);\n window.history.pushState( null, null, document.location.href.replace( '#', '' ) + '&table=' + data[1] );\n \n WPTB_Helper.saveTable( event, true );\n return;\n } else if( data[0] == 'edited' && startSaving ) {\n document.wptbId = data[1];\n messagingArea.innerHTML = '<div class=\"wptb-success wptb-message\">Table \"' + t + '\" was successfully saved.</div>';\n document.getElementsByClassName( 'wptb-embed-btn' )[0].classList.remove( 'wptb-button-disable' );\n document.getElementById( 'wptb-embed-shortcode' ).value = '[wptb id=' + data[1] + ']';\n let wptbPreviewTable = document.querySelector( '.wptb-preview-table' );\n let wptbPreviewBtn = document.getElementsByClassName( 'wptb-preview-btn' );\n if( wptbPreviewBtn.length > 0 ) {\n wptbPreviewBtn = wptbPreviewBtn[0];\n wptbPreviewBtn.classList.remove( 'wptb-button-disable' );\n let wptbPreviewBtnHref = wptbPreviewBtn.dataset.previewHref;\n wptbPreviewBtnHref = wptbPreviewBtnHref.replace( 'empty', data[1] );\n wptbPreviewBtn.setAttribute( 'href', wptbPreviewBtnHref );\n }\n \n event.target.dataset.wptbTableStateNumberSave = window.wptbTableStateNumberShow;\n let wptbSaveBtn = document.getElementsByClassName( 'wptb-save-btn' );\n if( wptbSaveBtn.length > 0 ) {\n wptbSaveBtn = wptbSaveBtn[0];\n wptbSaveBtn.classList.add( 'wptb-save-disabled' );\n }\n } else if( data[0] == 'edited' ) {\n messagingArea.innerHTML = '<div class=\"wptb-success wptb-message\">Table \"' + t + '\" was successfully updated.</div>';\n event.target.dataset.wptbTableStateNumberSave = window.wptbTableStateNumberShow;\n \n let wptbSaveBtn = document.getElementsByClassName( 'wptb-save-btn' );\n if( wptbSaveBtn.length > 0 ) {\n wptbSaveBtn = wptbSaveBtn[0];\n wptbSaveBtn.classList.add( 'wptb-save-disabled' );\n }\n } else if( data[0] == 'preview_edited' ) {\n return;\n } else {\n messagingArea.innerHTML = '<div class=\"wptb-error wptb-message\">Safety problems</div>';\n }\n messagingArea.classList.add( 'wptb-success' );\n setTimeout( function () {\n messagingArea.removeChild( messagingArea.firstChild );\n }, 4000 );\n }\n }\n http.send( params );\n },\n //\n clickOnFreeSpace: function() {\n document.getElementsByClassName( 'wptb-elements-container' )[0].style.display = 'table';\n document.getElementsByClassName( 'wptb-settings-section' )[0].style.display = 'block';\n document.getElementById( 'element-options-group' ).style.display = 'none';\n let wpcdFixedToolbar = document.getElementById( 'wpcd_fixed_toolbar' );\n if( wpcdFixedToolbar.hasAttribute( 'data-toolbar-active-id' ) ) {\n document.getElementById( wpcdFixedToolbar.getAttribute( 'data-toolbar-active-id' ) ).classList.remove( 'toolbar-active' );\n }\n let element = document.querySelector( '.wptb-preview-table' );\n if( element ) {\n WPTB_Helper.elementOptionsSet( 'table_setting', element );\n }\n },\n // function for sending of element ajax request\n elementAjax: function( dataAjaxData, element ) {\n let http = new XMLHttpRequest(),\n url = ( wptb_admin_object ? wptb_admin_object.ajaxurl : ajaxurl ) + \"?action=wptb_element_ajax\";\n let element_name;\n let infArr = element.className.match( /wptb-element-(.+)-(\\d+)/i );\n if( infArr && Array.isArray( infArr ) ) {\n element_name = infArr[1];\n }\n \n let params = {\n element_ajax_data: dataAjaxData,\n element_name: element_name,\n security_code: wptb_admin_object.security_code\n };\n params = JSON.stringify( params );\n\n http.open( 'POST', url, true );\n http.setRequestHeader( 'Content-type', 'application/json; charset=utf-8' );\n\n http.onreadystatechange = function ( action ) {\n if ( this.readyState == 4 && this.status == 200 ) {\n var data = JSON.parse( http.responseText );\n let detail;\n if ( data && Array.isArray( data ) && data[0] == 'element_ajax_responce' ) {\n detail = {value: data[1]};\n } else {\n detail = '';\n }\n WPTB_Helper.wptbDocumentEventGenerate( 'wptb-element:ajax-response', element, detail );\n }\n }\n http.send( params );\n }\n}\n","var WPTB_Initializer = function () {\n\n const MIN_COLUMNS = 1,\n MIN_ROWS = 1,\n MAX_COLUMNS = 30,\n MAX_ROWS = 30;\n\n var tableGenerator = document.body;\n columnsDecrementButton = tableGenerator.getElementsByClassName('wptb-input-number-decrement')[0],\n columnsIncrementButton = tableGenerator.getElementsByClassName('wptb-input-number-increment')[0],\n rowsDecrementButton = tableGenerator.getElementsByClassName('wptb-input-number-decrement')[1],\n rowsIncrementButton = tableGenerator.getElementsByClassName('wptb-input-number-increment')[1],\n columnsInput = document.getElementById('wptb-columns-number'),\n rowsInput = document.getElementById('wptb-rows-number');\n \n columnsDecrementButton.onclick = function () {\n if (columnsInput.value > MIN_COLUMNS) {\n columnsInput.value--;\n }\n };\n\n columnsIncrementButton.onclick = function () {\n if (columnsInput.value < MAX_COLUMNS) {\n columnsInput.value++;\n }\n };\n\n rowsDecrementButton.onclick = function () {\n if (rowsInput.value > MIN_ROWS) {\n rowsInput.value--;\n }\n };\n\n rowsIncrementButton.onclick = function () {\n if (rowsInput.value < MAX_ROWS) {\n rowsInput.value++;\n }\n };\n\n document.getElementById( 'wptb-generate-table' ).onclick = function ( ) {\n var columns = document.getElementById('wptb-columns-number').value,\n rows = document.getElementById('wptb-rows-number').value;\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n //wptbTableStateSaveManager.tableStateClear();\n \n wptbTableStateSaveManager.tableStateSet( true );\n \n WPTB_Table(columns, rows);\n \n wptbTableStateSaveManager.tableStateSet();\n }\n\n};\n","var WPTB_LeftPanel = function () {\n\n var table = document.getElementsByClassName('wptb-preview-table')[0],\n wptbElementButtons = document.getElementsByClassName('wptb-element');\n \n let wptbTableColumnWidthNumber = document.getElementById( 'wptb-table-column-width-number' );\n WPTB_Helper.numberImputSize( wptbTableColumnWidthNumber, 2, 500 );\n \n let wptbTableRowHeightNumber = document.getElementById( 'wptb-table-row-height-number' );\n WPTB_Helper.numberImputSize( wptbTableRowHeightNumber, 2, 200 );\n \n document.getElementById( 'wptb-table-column-width-slider' ).oninput = function () {\n document.getElementById( 'wptb-table-column-width-number' ).value = this.value;\n table.addColumnWidth( this.value );\n };\n \n document.getElementById( 'wptb-table-column-width-slider' ).onchange = function () {\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n \n document.getElementById( 'wptb-table-column-width-number' ).onchange = function () {\n document.getElementById( 'wptb-table-column-width-slider' ).value = this.value;\n table.addColumnWidth( this.value );\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n \n document.getElementById( 'wptb-table-column-width-auto-fixed' ).onchange = function () {\n if( this.checked ) {\n let highlighted = table.querySelector( '.wptb-highlighted' );\n let width = WPTB_Helper.getColumnWidth( table, highlighted );\n table.addColumnWidth( width );\n } else {\n table.addColumnWidth( false, true );\n let highlighted = table.querySelector( '.wptb-highlighted' );\n let width = WPTB_Helper.getColumnWidth( table, highlighted );\n document.getElementById( 'wptb-table-column-width-number' ).value = width;\n document.getElementById( 'wptb-table-column-width-slider' ).value = width;\n }\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n document.getElementById( 'wptb-table-row-height-slider' ).oninput = function () {\n document.getElementById( 'wptb-table-row-height-number' ).value = this.value;\n table.addRowHeight( this.value );\n };\n \n document.getElementById( 'wptb-table-row-height-slider' ).onchange = function () {\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n document.getElementById( 'wptb-table-row-height-number' ).onchange = function () {\n document.getElementById( 'wptb-table-row-height-slider' ).value = this.value;\n table.addRowHeight( this.value );\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n \n document.getElementById( 'wptb-table-row-height-auto-fixed' ).onchange = function () {\n if( this.checked ) {\n let highlighted = table.querySelector( '.wptb-highlighted' );\n let height = WPTB_Helper.getRowHeight( table, highlighted );\n table.addRowHeight( height );\n } else {\n table.addRowHeight( false, true );\n let highlighted = table.querySelector( '.wptb-highlighted' );\n let height = WPTB_Helper.getRowHeight( table, highlighted );\n document.getElementById( 'wptb-table-row-height-number' ).value = height;\n document.getElementById( 'wptb-table-row-height-slider' ).value = height;\n }\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n \n function controlsChange( inputs, table ) {\n if( inputs && typeof inputs === 'object' ) {\n if( inputs.hasOwnProperty( 'tableTopRowsAsHeader' ) ) {\n if( inputs.tableTopRowsAsHeader == 'checked' ) {\n let rows = table.rows;\n table.classList.add( 'wptb-table-preview-head' );\n } else if( inputs.tableTopRowsAsHeader == 'unchecked' ) {\n let rows = table.rows;\n table.classList.remove( 'wptb-table-preview-head' );\n\n for ( let i = 1; i < rows.length; i++ ) {\n let thisRow = rows[i],\n thisRowChildren = thisRow.children;\n for( let j = 0; j < thisRowChildren.length; j++ ) {\n thisRowChildren[j].removeAttribute( 'data-wptb-title-column' );\n thisRowChildren[j].removeAttribute( 'data-wptb-title-column-font-size' );\n thisRowChildren[j].removeAttribute( 'data-wptb-title-column-color' );\n thisRowChildren[j].removeAttribute( 'data-wptb-title-background-color' );\n thisRowChildren[j].removeAttribute( 'data-wptb-title-align' );\n }\n }\n }\n } else if( inputs.hasOwnProperty( 'makeTableResponsive' ) ) {\n if( inputs.makeTableResponsive == 'checked' ) {\n table.dataset.wptbAdaptiveTable = 1;\n } else if( inputs.makeTableResponsive == 'unchecked' ) {\n table.dataset.wptbAdaptiveTable = 0;\n }\n } else if( inputs.hasOwnProperty( 'tableManageCells' ) ) {\n table.toggleTableEditMode();\n }\n } \n }\n\n WPTB_Helper.controlsInclude( table, controlsChange );\n\n for (var i = 0; i < wptbElementButtons.length; i++) {\n wptbElementButtons[i].ondragstart = function (e) {\n e.dataTransfer.setData('wptbElement', this.dataset.wptbElement);\n e.dataTransfer.setData( 'wptbElIndic-' + this.dataset.wptbElement, 'wptbElIndic-' + this.dataset.wptbElement );\n }\n };\n \n if( table ) {\n document.getElementById( 'wptb-table-edit-mode-close' ).onclick = table.toggleTableEditMode;\n document.getElementById( 'wptb-left-scroll-panel-curtain-close' ).onclick = table.toggleTableEditMode;\n document.getElementById('wptb-add-end-row').onclick = table.addRowToTheEnd;\n document.getElementById('wptb-add-start-row').onclick = table.addRowToTheStart;\n document.getElementById('wptb-add-row-before').onclick = table.addRowBefore;\n document.getElementById('wptb-add-row-after').onclick = table.addRowAfter;\n document.getElementById('wptb-add-end-column').onclick = table.addColumnEnd;\n document.getElementById('wptb-add-start-column').onclick = table.addColumnStart;\n document.getElementById('wptb-add-column-before').onclick = table.addColumnBefore;\n document.getElementById('wptb-add-column-after').onclick = table.addColumnAfter;\n document.getElementById('wptb-delete-column').onclick = table.deleteColumn;\n document.getElementById('wptb-delete-row').onclick = table.deleteRow;\n document.getElementById('wptb-merge-cells').onclick = table.mergeCells;\n document.getElementById('wptb-split-cell').onclick = table.splitCell;\n };\n \n document.querySelector( '.wptb-left-panel-extend' ).onclick = function() {\n let wptbContainer = document.querySelector( '.wptb-container' );\n if( wptbContainer ) {\n if ( wptbContainer.classList.contains( 'collapsed' ) ) {\n wptbContainer.classList.remove( 'collapsed' );\n } else {\n wptbContainer.classList.add( 'collapsed' );\n }\n }\n };\n \n // this code hides the \"element parameters\" area \n // when clicked outside this element and its \"tinymce\" toolbar \n let wptbBuilderPanel = document.getElementsByClassName( 'wptb-builder-panel' )[0];\n wptbBuilderPanel.onclick = function( e ) {\n if( ! e.target.classList.contains( 'wptb-ph-element' ) && ! WPTB_Helper.findAncestor( e.target, 'wptb-ph-element' ) && \n ! e.target.classList.contains( 'wptb-fixed-toolbar' ) && ! WPTB_Helper.findAncestor( e.target, 'wptb-fixed-toolbar' ) ) {\n WPTB_Helper.clickOnFreeSpace();\n } \n };\n \n let wptbHeader = document.getElementsByClassName( 'wptb-header' );\n if( wptbHeader.length > 0 ) wptbHeader = wptbHeader[0];\n wptbHeader.onclick = function() {\n WPTB_Helper.clickOnFreeSpace();\n };\n};","var MultipleSelect = function () {\n\n\tvar selectedCells = [],\n\t\tmultipleCellMode = false;\n\n\tthis.activateMultipleSelectMode = function () {\n\t\tselectedCells = [];\n\t\tvar tds = document.getElementsByClassName('wptb-preview-table')[0].getElementsByTagName('td');\n\t\tfor (var i = 0; i < tds.length; i++) {\n\t\t\ttds[i].classList.remove('wptb-highlighted');\n\t\t}\n\t\tmultipleCellMode = true;\n\t}\n\n\tthis.deactivateMultipleSelectMode = function () {\n\t\tmultipleCellMode = false;\n\t}\n\n\tthis.isActivated = function () {\n\t\treturn multipleCellMode;\n\t}\n\n\tthis.pushSelectedCell = function (cell) {\n\t\tif (!multipleCellMode) {\n\t\t\treturn;\n\t\t}\n\t\tselectedCells.push(cell);\n\t\tcell.classList.add('wptb-highlighted');\n\t};\n\n\tthis.selectedCells = function () {\n\t\treturn selectedCells;\n\t}\n\n\tthis.flushSelectedCells = function () {\n\t\tselectedCells = [];\n\t}\n\n\tthis.getFirst = function () {\n\t\tvar minXIndex = 1000, minYIndex = 1000, first;\n\t\tfor (var i = selectedCells.length - 1; i >= 0; i--) {\n\t\t\tif (minXIndex >= selectedCells[i].dataset.xIndex\n\t\t\t\t&& minYIndex >= selectedCells[i].dataset.yIndex) {\n\t\t\t\tfirst = selectedCells[i];\n\t\t\t\tminXIndex = selectedCells[i].dataset.xIndex;\n\t\t\t\tminYIndex = selectedCells[i].dataset.yIndex;\n\t\t\t}\n\t\t}\n\t\treturn first;\n\t}\n\n\tthis.getLast = function () {\n\t\tvar maxXIndex = -1, maxYIndex = -1, last;\n\t\tfor (var i = selectedCells.length - 1; i >= 0; i--) {\n\t\t\tif (maxXIndex <= selectedCells[i].dataset.xIndex\n\t\t\t\t&& maxYIndex <= selectedCells[i].dataset.yIndex) {\n\t\t\t\tlast = selectedCells[i];\n\t\t\t\tmaxXIndex = selectedCells[i].dataset.xIndex;\n\t\t\t\tmaxYIndex = selectedCells[i].dataset.yIndex;\n\t\t\t}\n\t\t}\n\t\treturn last;\n\t}\n\n\tthis.removeAllButFirst = function () {\n\t\tvar td = this.getFirst();\n\t\tfor (var i = 1; i < selectedCells.length; i++) {\n\t\t\tselectedCells[i].classList.add('wptb-fused-cell-' + td.dataset.xIndex + '-' + td.dataset.yIndex);\n\t\t}\n\t}\n\n\treturn this;\n\n};","var WPTB_Parser = function ( code ) {\n let div = document.createElement( 'div' );\n div.innerHTML = code;\n \n let table = div.children[0];\n let columnTitleMobile = [...table.querySelectorAll( '.wptb-column-title-mobile-container' )];\n \n for( let i = 0; i < columnTitleMobile.length; i++ ) {\n let parent = columnTitleMobile[i].parentNode;\n parent.removeChild( columnTitleMobile[i] );\n }\n \n let tds = table.querySelectorAll( 'td' );\n for ( let i = 0; i < tds.length; i++ ) {\n tds[i].classList.add( 'wptb-droppable' );\n tds[i].classList.remove( 'wptb-column-title-mobile-not-elements' );\n }\n \n return table;\n}","// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys\nif (!Object.keys) {\n Object.keys = (function () {\n 'use strict';\n var hasOwnProperty = Object.prototype.hasOwnProperty,\n hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),\n dontEnums = [\n 'toString',\n 'toLocaleString',\n 'valueOf',\n 'hasOwnProperty',\n 'isPrototypeOf',\n 'propertyIsEnumerable',\n 'constructor'\n ],\n dontEnumsLength = dontEnums.length;\n\n return function (obj) {\n if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {\n throw new TypeError('Object.keys called on non-object');\n }\n\n var result = [], prop, i;\n\n for (prop in obj) {\n if (hasOwnProperty.call(obj, prop)) {\n result.push(prop);\n }\n }\n\n if (hasDontEnumBug) {\n for (i = 0; i < dontEnumsLength; i++) {\n if (hasOwnProperty.call(obj, dontEnums[i])) {\n result.push(dontEnums[i]);\n }\n }\n }\n return result;\n };\n }());\n}","var WPTB_Settings = function () {\n var elems = document.getElementsByClassName('wptb-element');\n\n for ( var i = 0; i < elems.length; i++ ) {\n elems[i].ondragstart = function ( event ) {\n event.dataTransfer.effectAllowed = 'move';\n event.dataTransfer.setData( 'wptbElement', event.target.dataset.wptbElement );\n event.dataTransfer.setData( 'wptbElIndic-' + event.target.dataset.wptbElement, 'wptbElIndic-' + event.target.dataset.wptbElement );\n }\n elems[i].ondragend = function () {\n WPTB_Helper.elementDragEndClear();\n }\n };\n let table = document.getElementsByClassName( 'wptb-preview-table' );\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n let wptbUndo = document.getElementsByClassName( 'wptb-undo' );\n if( wptbUndo.length > 0 ) {\n wptbUndo = wptbUndo[0];\n \n wptbUndo.onclick = function( event ) {\n if( ! this.classList.contains( 'wptb-undoredo-disabled' ) ) {\n wptbTableStateSaveManager.tableStateGet( this.dataset.wptbUndoredo );\n let wptbUndoRedoContainer = document.getElementsByClassName( 'wptb-undo-redo-container' );\n if( wptbUndoRedoContainer.length > 0 && table.length > 0 ) {\n wptbUndoRedoContainer = wptbUndoRedoContainer[0];\n wptbUndoRedoContainer.onmouseleave = function( event ) {\n event.target.onmouseleave = '';\n WPTB_Table();\n }\n }\n }\n \n }\n }\n \n let wptbRedo = document.getElementsByClassName( 'wptb-redo' );\n if( wptbRedo.length > 0 ) {\n wptbRedo = wptbRedo[0];\n \n wptbRedo.onclick = function( event ) {\n if( ! this.classList.contains( 'wptb-undoredo-disabled' ) ) {\n wptbTableStateSaveManager.tableStateGet( this.dataset.wptbUndoredo );\n let wptbUndoRedoContainer = document.getElementsByClassName( 'wptb-undo-redo-container' );\n if( wptbUndoRedoContainer.length > 0 && table.length > 0 ) {\n wptbUndoRedoContainer = wptbUndoRedoContainer[0];\n wptbUndoRedoContainer.onmouseleave = function( event ) {\n event.target.onmouseleave = '';\n WPTB_Table();\n }\n }\n }\n \n }\n }\n \n let shortcodePopupWindow = document.getElementsByClassName( 'wptb-popup-window-modal' )[0];\n document.getElementsByClassName( 'wptb-embed-btn' )[0].onclick = function () {\n if( ! this.classList.contains( 'wptb-button-disable' ) ) {\n shortcodePopupWindow.classList.add( 'wptb-popup-show' );\n }\n }\n \n window.onbeforeunload = function(e) {\n let wptbSaveDisabled = document.getElementsByClassName( 'wptb-save-disabled' );\n if( wptbSaveDisabled.length == 0 ) {\n return true;\n } else {\n return null;\n }\n };\n \n \n document.getElementsByClassName( 'wptb-popup-dark-area' )[0].onclick = function () {\n shortcodePopupWindow.classList.remove( 'wptb-popup-show' );\n }\n \n document.getElementsByClassName( 'wptb-popup-window-close-icon' )[0].onclick = function () {\n shortcodePopupWindow.classList.remove( 'wptb-popup-show' );\n }\n \n document.getElementsByClassName( 'wptb-preview-btn' )[0].onclick = function ( event ) {\n if( this.classList.contains( 'wptb-button-disable' ) ) {\n return;\n } \n \n let previewId = Math.floor( Math.random() * 10000 );\n \n var newHref = new URL( event.target.href );\n newHref.searchParams.set( 'preview_id', previewId );\n event.target.href = newHref.toString();\n WPTB_Helper.saveTable( event, false, previewId );\n }\n\n document.getElementsByClassName( 'wptb-save-btn' )[0].onclick = function ( event ) {\n if( ! this.classList.contains( 'wptb-save-disabled' ) ) {\n WPTB_Helper.saveTable( event );\n }\n }\n};\n","var WPTB_Stringifier = function ( codeMain ) {\n if ( codeMain ) {\n let code = codeMain.cloneNode( true );\n code.classList.add( 'wptb-table-preview-static-indic' );\n code.dataset.tableColumns = codeMain.columns;\n code.style.width = null;\n code.style.minWidth = null;\n code.style.maxWidth = null;\n \n let tds = code.getElementsByTagName( 'td' );\n if ( tds.length > 0 ) {\n for ( let i = 0; i < tds.length; i++ ) {\n \n if ( codeMain.querySelector( 'wptb-table-preview-head' ) ) {\n tds[i].removeAttribute( 'data-x-index' );\n }\n tds[i].removeAttribute( 'data-y-index' );\n tds[i].removeAttribute( 'draggable' );\n tds[i].classList.remove( 'wptb-droppable' );\n let innerElements = tds[i].getElementsByClassName( 'wptb-ph-element' );\n \n if ( innerElements.length > 0 ) {\n for ( let j = 0; j < innerElements.length; j++ ) {\n \n let mceContentBodys = innerElements[j].querySelectorAll( '.mce-content-body' );\n if( mceContentBodys.length > 0 ) {\n for ( let k = 0; k < mceContentBodys.length; k++ ) {\n mceContentBodys[k].classList.remove( 'mce-content-body' );\n }\n }\n \n let dataMceStyle = innerElements[j].querySelectorAll( '[data-mce-style]' );\n if ( dataMceStyle.length > 0 ) {\n for ( let k = 0; k < dataMceStyle.length; k++ ) {\n dataMceStyle[k].removeAttribute( 'data-mce-style' );\n }\n }\n \n let contentEditable = innerElements[j].querySelectorAll( '[contenteditable]' );\n if ( contentEditable.length > 0 ) {\n for ( let k = 0; k < contentEditable.length; k++ ) {\n contentEditable[k].removeAttribute( 'contenteditable' );\n }\n }\n \n let spellCheck = innerElements[j].querySelectorAll( '[spellcheck]' );\n if ( spellCheck.length > 0 ) {\n for ( let k = 0; k < spellCheck.length; k++ ) {\n spellCheck[k].removeAttribute( 'spellcheck' );\n }\n }\n \n let mceIds = innerElements[j].querySelectorAll( '[id^=mce_]' );\n if ( mceIds.length > 0 ) {\n for ( let k = 0; k < mceIds.length; k++ ) {\n mceIds[k].removeAttribute( 'id' );\n }\n }\n \n let wptbActions = innerElements[j].querySelectorAll( '.wptb-actions' );\n let wptbActionsLength = wptbActions.length;\n while ( wptbActionsLength > 0 ) {\n if( wptbActions[0] && wptbActions[0].parentNode ) {\n wptbActions[0].parentNode.removeChild( wptbActions[0] );\n wptbActionsLength--;\n } else {\n break;\n }\n \n } \n \n let dataMceBogus = innerElements[j].querySelectorAll( '[data-mce-bogus]' );\n if( dataMceBogus.length > 0 ) {\n dataMceBogus = [...dataMceBogus];\n for( let k = 0; k < dataMceBogus.length; k++ ) {\n if( dataMceBogus[k] && dataMceBogus[k].parentNode ) {\n dataMceBogus[k].parentNode.removeChild( dataMceBogus[k] );\n }\n }\n }\n }\n }\n \n if( tds[i].hasAttribute( 'data-wptb-title-column' ) ) {\n let columnNameDivContainer = document.createElement( 'div' ),\n columnNameDiv = document.createElement( 'div' );\n columnNameDivContainer.classList.add( 'wptb-column-title-mobile-container' );\n columnNameDiv.classList.add( 'wptb-column-title-mobile' );\n columnNameDiv.dataset.wptbTitleColumn = tds[i].dataset.wptbTitleColumn;\n columnNameDiv.setAttribute( 'style', 'font-size:' + tds[i].dataset.wptbTitleColumnFontSize + '; \\n\\\n color:' + tds[i].dataset.wptbTitleColumnColor + '; background-color:' + tds[i].dataset.wptbTitleBackgroundColor + '; text-align:' + tds[i].dataset.wptbTitleAlign + ';' );\n columnNameDiv.style.padding = tds[i].style.padding;\n if( tds[i].children.length == 0 ) {\n tds[i].classList.add( 'wptb-column-title-mobile-not-elements' );\n }\n columnNameDivContainer.appendChild( columnNameDiv );\n tds[i].insertBefore( columnNameDivContainer, tds[i].firstChild );\n }\n }\n }\n \n return code;\n }\n}","var array = [], WPTB_Table = function (columns, rows) {\n\n /* The members of the class */\n var settings = document.getElementsByClassName('wptb-settings-items'),\n wptbTableSetup = document.getElementsByClassName(\"wptb-table-setup\")[0],\n table, row, cell,\n maxAmountOfCells,\n maxAmountOfRows;\n\n //HERE ARE THE PRIVATE FUNCTIONS\n /*\n * This function toggles buttons visibility in cell edit mode\n * (according to the amount of currently selected cells), and\n * highlights visually the clicked cell if it is not highlighted, or\n * removes highlight if clicked cell is already highlighted. \n * It too toggles the bits of our abstract representation.\n * @param Event this is the event instance of the click performed over a cell.\n */\n var mark = function ( event ) {\n var rs = this.rowSpan,\n cs = this.colSpan,\n markedCells,\n noCells = document.getElementsByClassName('wptb-no-cell-action'),\n singleCells = document.getElementsByClassName('wptb-single-action'),\n multipleCells = document.getElementsByClassName('wptb-multiple-select-action'),\n cellSettings = document.getElementById( 'wptb-left-scroll-panel-cell-settings' ),\n position = getCoords(this),\n row = position[0],\n column = position[1];\n if ( ! document.select.isActivated() ) {\n return;\n }\n if (this.className.match(/wptb-highlighted/)) {\n this.classList.remove('wptb-highlighted');\n for (var i = 0; i < rs; i++) {\n for (var j = 0; j < cs; j++) {\n array[row + i][column + j] = 0;\n }\n }\n } else {\n this.classList.add('wptb-highlighted');\n for (var i = 0; i < rs; i++) {\n for (var j = 0; j < cs; j++) {\n array[row + i][column + j] = 1;\n }\n }\n }\n\n markedCells = document.getElementsByClassName('wptb-highlighted').length;\n if (markedCells === 0) {\n for (var i = 0; i < multipleCells.length; i++) {\n multipleCells[i].classList.remove('visible');\n multipleCells[i].setAttribute('disabled', 'disabled');\n }\n for (var i = 0; i < noCells.length; i++) {\n noCells[i].classList.add('visible');\n noCells[i].removeAttribute('disabled');\n }\n for (var i = 0; i < singleCells.length; i++) {\n singleCells[i].classList.remove('visible');\n singleCells[i].setAttribute('disabled', 'disabled');\n }\n cellSettings.classList.remove( 'visible' );\n } else if (markedCells === 1) {\n for (var i = 0; i < multipleCells.length; i++) {\n multipleCells[i].classList.remove('visible');\n multipleCells[i].setAttribute('disabled', 'disabled');\n }\n for (var i = 0; i < noCells.length; i++) {\n noCells[i].classList.remove('visible');\n noCells[i].setAttribute('disabled', 'disabled');\n }\n for (var i = 0; i < singleCells.length; i++) {\n singleCells[i].classList.add('visible');\n singleCells[i].removeAttribute('disabled');\n }\n let cellHighlighted = document.querySelector( '.wptb-highlighted' );\n if( cellHighlighted ) {\n let wptbTableColumnWidthSlider = document.getElementById( 'wptb-table-column-width-slider' );\n let wptbTableColumnWidthNumber = document.getElementById( 'wptb-table-column-width-number' );\n let tableColumnWidthAutoFixedCheckbox = document.getElementById( 'wptb-table-column-width-auto-fixed' );\n let width = cellHighlighted.style.width;\n if( width ) {\n wptbTableColumnWidthSlider.value = parseFloat( width, 10 );\n wptbTableColumnWidthNumber.value = parseFloat( width, 10 );\n tableColumnWidthAutoFixedCheckbox.checked = true;\n } else if( cellHighlighted.dataset.wptbFixedWidth ) {\n wptbTableColumnWidthSlider.value = cellHighlighted.dataset.wptbFixedWidth;\n wptbTableColumnWidthNumber.value = cellHighlighted.dataset.wptbFixedWidth;\n tableColumnWidthAutoFixedCheckbox.checked = true;\n } else {\n let cellWidth = WPTB_Helper.getColumnWidth( table, cellHighlighted );\n wptbTableColumnWidthSlider.value = cellWidth;\n wptbTableColumnWidthNumber.value = cellWidth;\n tableColumnWidthAutoFixedCheckbox.checked = false;\n }\n \n \n let wptbTableRowHeightSlider = document.getElementById( 'wptb-table-row-height-slider' );\n let wptbTableRowHeightNumber = document.getElementById( 'wptb-table-row-height-number' );\n let tableRowHeightAutoFixedCheckbox = document.getElementById( 'wptb-table-row-height-auto-fixed' );\n let height = cellHighlighted.style.height;\n if( height ) {\n wptbTableRowHeightSlider.value = parseFloat( height, 10 );\n wptbTableRowHeightNumber.value = parseFloat( height, 10 );\n tableRowHeightAutoFixedCheckbox.checked = true;\n } else if( cellHighlighted.dataset.wptbFixedHeight ) {\n wptbTableRowHeightSlider.value = cellHighlighted.dataset.wptbFixedHeight;\n wptbTableRowHeightNumber.value = cellHighlighted.dataset.wptbFixedHeight;\n tableRowHeightAutoFixedCheckbox.checked = true;\n } else {\n let cellHeight = WPTB_Helper.getRowHeight( table, cellHighlighted );\n wptbTableRowHeightSlider.value = cellHeight;\n wptbTableRowHeightNumber.value = cellHeight;\n tableRowHeightAutoFixedCheckbox.checked = false;\n }\n }\n cellSettings.classList.add( 'visible' );\n } else {\n for (var i = 0; i < multipleCells.length; i++) {\n if (table.isSquare(array)) {\n multipleCells[i].classList.add('visible');\n multipleCells[i].removeAttribute('disabled');\n } else {\n multipleCells[i].classList.remove('visible');\n multipleCells[i].setAttribute('disabled', 'disabled');\n }\n }\n for (var i = 0; i < noCells.length; i++) {\n noCells[i].classList.remove('visible');\n noCells[i].setAttribute('disabled', 'disabled');\n }\n for (var i = 0; i < singleCells.length; i++) {\n singleCells[i].classList.remove('visible');\n singleCells[i].setAttribute('disabled', 'disabled');\n }\n cellSettings.classList.remove( 'visible' );\n }\n };\n\n /* \n * This function fills an array with 1's according to the actual design\n * of HTML table.\n * @returns an array of arrays containing an abstract representation\n * of HTML table.\n * @deprecated\n * */\n\n var realTimeArray = function () {\n var carried = [], tds, cols, matriz = [];\n\n for (var i = 0; i < maxAmountOfCells; i++) {\n carried[i] = 0;\n }\n\n for (var i = 0; i < table.rows.length; i++) {\n cols = [];\n\n var tds = table.rows[i].getElementsByTagName('td');\n\n for (items = 0; items < tds.length; items++) {\n\n for (var k = 0; k < tds[items].colSpan; k++) {\n cols.push(1);\n }\n\n if (tds[items].rowSpan > 1) {\n for (var k = 0; k < tds[items].colSpan; k++) {\n carried[items + k] = {\n justAssigned: true,\n amount: tds[items].rowSpan\n };\n }\n }\n }\n\n for (var k = 0; k < maxAmountOfCells; k++) {\n if (typeof carried[k] == 'object' && carried[k].amount > 0) {\n carried[k].amount--;\n if (carried[k].justAssigned) {\n carried[k].justAssigned = false;\n } else {\n cols.push(1);\n }\n }\n }\n\n matriz.push(cols);\n\n }\n return matriz;\n };\n\n /*\n * This function gets the number and position of cell spaces in current row that are occuped \n * by upper rowspanned cells.\n * @param number the number of row where we wish to calculate the carried rowspans up to.\n * @return an array with the remaining rowspans in each column.\n */\n var carriedRowspans = function (row) {\n var carried = [], tds, cols;\n\n for (var i = 0; i < maxAmountOfCells; i++) {\n carried[i] = 0;\n }\n\n if (row == -1) {\n return carried;\n }\n\n for (var i = 0; i <= row; i++) {\n cellsBuffer = table.rows[i].getElementsByTagName('td');\n cellPointer = 0;\n\n for (var xPosition = 0; xPosition < maxAmountOfCells; xPosition += stepsToMove) {\n stepsToMove = 1;\n\n if (carried[xPosition]) {\n carried[xPosition]--;\n } else {\n celda = cellsBuffer[cellPointer++];\n if (celda.rowSpan > 1) {\n for (k = 0; k < celda.colSpan; k++) {\n carried[xPosition + k] = celda.rowSpan - 1;\n }\n stepsToMove = celda.colSpan;\n } else if (celda.colSpan > 1) {\n stepsToMove = celda.colSpan;\n }\n }\n }\n\n }\n return carried;\n };\n\n /*\n * A helpful function for showing\n * the abstract table in console.\n * @param Array our abstract table.\n */\n var drawTable = function (a) {\n var string = 'DRAWING TABLE:\\n';\n for (var i = 0; i < a.length; i++) {\n\n for (var j = 0; j < a[i].length; j++) {\n string += ' ' + a[i][j];\n }\n string += '\\n';\n }\n table.isSquare(a);\n };\n\n /*\n * It resets all the bits of our abstract representation\n * to 0 and removes the highlighting class of all cells.\n */\n\n var undoSelect = function () {\n var noCells = document.getElementsByClassName('wptb-no-cell-action'),\n singleCells = document.getElementsByClassName('wptb-single-action'),\n multipleCells = document.getElementsByClassName('wptb-multiple-select-action'),\n cellSettings = document.getElementById( 'wptb-left-scroll-panel-cell-settings' ),\n tds = table.getElementsByClassName('wptb-highlighted');\n while (tds.length) {\n tds[0].classList.remove('wptb-highlighted');\n }\n cellSettings.classList.remove( 'visible' );\n for (var i = 0; i < array.length; i++) {\n for (var j = 0; j < array[i].length; j++) {\n array[i][j] = 0;\n }\n }\n for (var i = 0; i < multipleCells.length; i++) {\n multipleCells[i].classList.remove('visible');\n multipleCells[i].setAttribute('disabled', 'disabled');\n }\n for (var i = 0; i < noCells.length; i++) {\n noCells[i].classList.add('visible');\n noCells[i].removeAttribute('disabled');\n }\n for (var i = 0; i < singleCells.length; i++) {\n singleCells[i].classList.remove('visible');\n singleCells[i].setAttribute('disabled', 'disabled');\n }\n };\n\n /*\n * This fills the abstract representation of our table with \n * zeros, at the start. the max amount of cells is the greatest sum\n * of all colspans for row.\n */\n\n var fillTableArray = function () {\n var colspansSums = [], a = [];\n\n //calculate max amount of cells inside a row\n for (var i = 0; i < table.rows.length; i++) {\n var cells = table.rows[i].getElementsByTagName('td'),\n colspanSumInRow = 0;\n for (var j = 0; j < cells.length; j++) {\n colspanSumInRow += cells[j].colSpan;\n }\n colspansSums.push(colspanSumInRow);\n }\n\n maxAmountOfCells = Math.max.apply(null, colspansSums);\n //calculate max rows\n var maxAmountOfRows = table.rows.length;\n\n // fill with zeros from both values\n for (var i = 0; i < maxAmountOfRows; i++) {\n a[i] = [];\n for (var j = 0; j < maxAmountOfCells; j++) {\n a[i].push(0);\n }\n }\n drawTable(a);\n return a;\n };\n\n /*\n * This function gets the sum of all colspans in a row.\n * @param number the number of row to be used as reference.\n */\n var getActualPointsInRow = function (row) {\n var tds = table.rows[row].getElementsByTagName('td'),\n points = 0;\n for (var i = 0; i < tds.length; i++) {\n points += tds[i].colSpan;\n }\n return points;\n }\n\n /*\n * This function gets us the exact coordinates of\n * an exact cell, in a more reliable way than xIndex and yIndex,\n * these last ones were meant to be used for getting the cell trough them.\n * @param DOMElement the cell to get the coordinates.\n */\n var getCoords = function (search) {\n var skipInCols = [], cell;\n\n for (var i = 0; i < maxAmountOfCells; i++) {\n skipInCols[i] = 0;\n }\n\n for (var i = 0; i < table.rows.length; i++) {\n var cellsBuffer = table.rows[i].getElementsByTagName('td');\n cellPointer = 0;\n for (var xPosition = 0; xPosition < maxAmountOfCells; xPosition += stepsToMove) {\n stepsToMove = 1;\n\n if (skipInCols[xPosition]) {\n skipInCols[xPosition]--;\n } else {\n var td = cellsBuffer[cellPointer++];\n if (td == search) {\n return [i, xPosition];\n }\n if (td.rowSpan > 1) {\n for ( let k = 0; k < td.colSpan; k++ ) {\n skipInCols[xPosition + k] = td.rowSpan - 1;\n }\n stepsToMove = td.colSpan;\n } else if (td.colSpan > 1) {\n stepsToMove = td.colSpan;\n }\n }\n }\n }\n };\n\n jQuery('#wptb-table-border-color').val('');\n jQuery('#wptb-table-padding-number,#wptb-table-padding-slider').val('15');\n\n if (columns || rows) {\n //END OF PRIVATE FUNCTIONS\n for (var i = 0; i < settings.length; i++) {\n if (settings[i].id !== 'wptb-apply-inner-border') {\n settings[i].classList.add('visible');\n }\n }\n\n //Create a HTML Table element.\n table = document.createElement( 'table' );\n table.classList.add( 'wptb-preview-table', 'wptb-element-main-table_setting-startedid-0' );\n table.style.border = '0px solid';\n table.dataset.reconstraction = 1;\n table.dataset.wptbAdaptiveTable = 1;\n //Add the data rows.\n for (var i = 0; i < rows; i++) {\n\n row = table.insertRow(-1);\n row.classList.add( 'wptb-row' );\n\n for (var j = 0; j < columns; j++) {\n cell = new WPTB_Cell(mark);\n cell.setCoords(i, j);\n cell.getDOMElement().style.borderWidth = '1px';\n row.appendChild(cell.getDOMElement());\n }\n }\n } else {\n let wptb_preview_table = document.getElementsByClassName( 'wptb-preview-table' );\n\n if (wptb_preview_table.length > 0) {\n table = wptb_preview_table[0];\n\n let cells = table.getElementsByTagName('td');\n\n if (cells.length > 0) {\n for (let i = 0; i < cells.length; i++) {\n WPTB_Cell(mark, cells[i]);\n }\n }\n } else {\n return;\n }\n }\n\n /*\n * This just toggles visibility of cell edit bar, and toggles \n * cell selecting mode.\n */\n\n table.toggleTableEditMode = function () {\n let bar = document.getElementsByClassName('wptb-edit-bar'),\n cellModeBackground = document.getElementById('wptb-cell_mode_background'),\n leftScrollPanelCurtain = document.getElementById('wptb-left-scroll-panel-curtain'),\n leftScrollPanelCellSettings = document.getElementById( 'wptb-left-scroll-panel-cell-settings' ),\n wptbPreviewTable = document.getElementsByClassName('wptb-preview-table');\n if (wptbPreviewTable.length > 0) {\n wptbPreviewTable = wptbPreviewTable[0];\n }\n\n if ( bar.length > 0 ) {\n for ( let i = 0; i < bar.length; i++ ) {\n if ( bar[i].classList.contains( 'visible' ) ) {\n document.select.deactivateMultipleSelectMode();\n bar[i].classList.remove( 'visible' );\n cellModeBackground.classList.remove( 'visible' );\n leftScrollPanelCurtain.classList.remove( 'visible' );\n leftScrollPanelCellSettings.classList.remove( 'visible' );\n wptbPreviewTable.parentNode.classList.remove( 'wptb-preview-table-manage-cells' );\n let wptbPreviewTableTds = wptbPreviewTable.getElementsByTagName( 'td' );\n if ( wptbPreviewTableTds.length > 0 ) {\n for ( let i = 0; i < wptbPreviewTableTds.length; i++ ) {\n wptbPreviewTableTds[i].classList.remove( 'wptb-highlighted' );\n }\n }\n } else {\n document.select.activateMultipleSelectMode();\n bar[i].classList.add( 'visible' );\n cellModeBackground.classList.add( 'visible' );\n leftScrollPanelCurtain.classList.add( 'visible' );\n wptbPreviewTable.parentNode.classList.add( 'wptb-preview-table-manage-cells' );\n }\n }\n\n }\n }\n\n /*\n * For assigning to each cell xIndex and y Index attributes,\n * these are the column number and row number of cell in table. \n */\n\n table.recalculateIndexes = function ( start ) {\n let trs = this.getElementsByTagName('tr'), tds, maxCols = 0, maxColsFull = 0,\n tdsArr = [];\n //let wptbTopRowAsHeader = document.getElementById( 'wptb-top-row-as-header' );\n \n for (var i = 0; i < trs.length; i++) {\n if ( i == 0 ) {\n// if( wptbTopRowAsHeader.checked ) {\n// if( start == undefined ) {\n// this.classList.add( 'wptb-table-preview-head' ); \n// trs[i].classList.add( 'wptb-table-head' )\n// } ;\n// } else {\n// if( start == undefined ) {\n// this.classList.remove( 'wptb-table-preview-head' );\n// trs[i].classList.remove( 'wptb-table-head' );\n// }\n// }\n } else {\n// if (i % 2 == 0) {\n// trs[i].classList.remove( 'wptb-table-head' );\n// } else {\n// trs[i].classList.remove( 'wptb-table-head' );\n// }\n }\n\n tdsArr[i];\n tds = trs[i].getElementsByTagName('td');\n\n if (tdsArr[i] == undefined) {\n tdsArr[i] = [];\n }\n\n let jMainIter = 0;\n for (var j = 0; j < tds.length; j++) {\n if (tdsArr[i][j] != undefined) {\n for (let y = 0; y < 100; y++) {\n if (tdsArr[i][jMainIter] != undefined) {\n jMainIter++;\n continue;\n }\n tdsArr[i][jMainIter] = tds[j];\n tds[j].dataset.xIndex = jMainIter;\n break;\n }\n } else {\n tdsArr[i][j] = tds[j];\n tds[j].dataset.xIndex = jMainIter;\n }\n tds[j].dataset.yIndex = i;\n\n if (tds[j].colSpan > 1) {\n for (let k = 1; k < tds[j].colSpan; k++) {\n jMainIter++;\n tdsArr[i][jMainIter] = 'tdDummy';\n }\n }\n\n if (tds[j].rowSpan > 1) {\n for (let x = 1; x < tds[j].rowSpan; x++) {\n if (tdsArr[i + x] == undefined) {\n tdsArr[i + x] = [];\n }\n for (let z = 0; z < tds[j].colSpan; z++) {\n tdsArr[i + x][jMainIter - tds[j].colSpan + 1 + z ] = 'tdDummy';\n }\n }\n }\n jMainIter++;\n if( i == 0 ) {\n maxColsFull = jMainIter;\n }\n }\n if (j > maxCols) {\n maxCols = j;\n }\n }\n this.columns = maxCols;\n this.maxCols = maxColsFull;\n }\n \n table.addColumnWidth = function( value, cleaner ) {\n let highlighted = table.getElementsByClassName( 'wptb-highlighted' );\n if( highlighted.length > 0 ) {\n for( let k = 0; k < highlighted.length; k++ ) {\n let dataXIndex = highlighted[k].dataset.xIndex;\n if( dataXIndex ) {\n function tableTdsFor( dataXIndex, colspan ) {\n let tableRows = table.rows;\n let widthIsSet = false;\n let arrayTdsFromPreviousRow = [];\n for( let i = 0; i < tableRows.length; i++ ) {\n let row = tableRows[i];\n let tds = row.children;\n for( let j = 0; j < tds.length; j++ ) {\n let td = tds[j];\n if( td.dataset.xIndex == dataXIndex ) {\n if( value ) {\n if( td.colSpan == colspan ) {\n td.style.width = value + 'px';\n td.removeAttribute( 'data-wptb-fixed-width' );\n widthIsSet = true;\n let tableColumnWidthAutoFixedCheckbox = document.getElementById( 'wptb-table-column-width-auto-fixed' );\n if( ! tableColumnWidthAutoFixedCheckbox.checked ) {\n tableColumnWidthAutoFixedCheckbox.checked = true;\n }\n } else {\n td.style.width = null;\n td.dataset.wptbFixedWidth = value;\n if( i == tableRows.length - 1 && ! widthIsSet ) {\n tableTdsFor( dataXIndex, colspan + 1 );\n }\n }\n } else if( cleaner ) {\n td.style.width = null;\n td.removeAttribute( 'data-wptb-fixed-width' );\n } else {\n if( td.dataset.wptbFixedWidth ) {\n if( td.colSpan == colspan ) {\n td.style.width = td.dataset.wptbFixedWidth + 'px';\n td.removeAttribute( 'data-wptb-fixed-width' );\n } \n } else if( td.style.width ) {\n for( let z = 0; z < arrayTdsFromPreviousRow.length; z++ ) {\n arrayTdsFromPreviousRow[z].style.width = td.style.width;\n }\n arrayTdsFromPreviousRow = [];\n } else {\n arrayTdsFromPreviousRow.push( td );\n }\n }\n break;\n } \n }\n }\n }\n \n tableTdsFor( dataXIndex, 1 );\n }\n }\n \n table.tdDefaultWidth();\n }\n }\n \n table.tdDefaultWidth = function() {\n let rows = table.rows;\n \n let tableTdsSumMaxWidth = 0;\n let tableTdsSumMaxWidthFixed = 0;\n let tableTdsSumMaxWidthAuto = 0;\n \n let wptbTableSetup = document.getElementsByClassName( 'wptb-table-setup' )[0];\n let wptbTableSetupWidth = wptbTableSetup.offsetWidth;\n \n let arrayCellsWidthFixedHelper = [];\n let arrayCellsWidthAutoHelper = [];\n let tdPaddingCommon = 0;\n let tableTdBorderCommonWidth = 0;\n let cssForTdsWidthAuto = '';\n \n \n let tableFullStyleObj = window.getComputedStyle( table, null );\n let borderLeftWidth = tableFullStyleObj.getPropertyValue( 'border-left-width' );\n let borderRightWidth = tableFullStyleObj.getPropertyValue( 'border-right-width' );\n let tableBorderCommon = parseFloat( borderLeftWidth, 10 ) + parseFloat( borderRightWidth, 10 );\n \n for( let i = 0; i < rows.length; i++ ) {\n let tds = rows[i].children;\n for( let j = 0; j < tds.length; j++ ) {\n let td = tds[j];\n \n if( ! arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] && ! arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] ) {\n if( td.style.width ) {\n arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] = parseFloat( td.style.width );\n td.removeAttribute( 'data-wptb-css-td-auto-width' );\n } else {\n if( ! td.dataset.wptbFixedWidth ) {\n arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] = 100;\n td.dataset.wptbCssTdAutoWidth = true;\n }\n }\n \n if( window.getComputedStyle( td, null ) ) {\n let tdStyleObj = window.getComputedStyle( td, null );\n let tdPaddingLeft = tdStyleObj.getPropertyValue( 'padding-left' );\n let tdPaddingRight = tdStyleObj.getPropertyValue( 'padding-right' );\n tdPaddingCommon = parseFloat( tdPaddingLeft, 10 ) + parseFloat( tdPaddingRight, 10 );\n\n let tableTdBorderLeftWidth = tdStyleObj.getPropertyValue( 'border-left-width' );\n let tableTdBorderRightWidth = tdStyleObj.getPropertyValue( 'border-right-width' );\n tableTdBorderCommonWidth = parseFloat( tableTdBorderLeftWidth, 10 ) + parseFloat( tableTdBorderRightWidth, 10 );\n tableTdBorderCommonWidth = tableTdBorderCommonWidth / 2;\n \n if( arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] ) {\n arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] += tdPaddingCommon;\n arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] += tableTdBorderCommonWidth;\n \n if( j == 0 && ( tableBorderCommon / 2 ) <= parseFloat( tableTdBorderLeftWidth, 10 ) ) {\n arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] += parseFloat( tableTdBorderLeftWidth, 10 ) / 2;\n } else if( j == 0 && ( tableBorderCommon / 2 ) > parseFloat( tableTdBorderLeftWidth, 10 ) ) {\n arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] += ( ( tableBorderCommon / 2 ) - ( parseFloat( tableTdBorderRightWidth, 10 ) / 2 ) );\n }\n\n if( j == tds.length - 1 && ( tableBorderCommon / 2 ) <= parseFloat( tableTdBorderRightWidth, 10 ) ) {\n arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] += parseFloat( tableTdBorderRightWidth, 10 ) / 2;\n } else if( j == tds.length - 1 && ( tableBorderCommon / 2 ) > parseFloat( tableTdBorderRightWidth, 10 ) ) {\n arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] += ( ( tableBorderCommon / 2 ) - ( parseFloat( tableTdBorderRightWidth, 10 ) / 2 ) );\n }\n } else if( arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] ) {\n arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] += tdPaddingCommon;\n arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] += tableTdBorderCommonWidth;\n \n if( j == 0 && ( tableBorderCommon / 2 ) <= parseFloat( tableTdBorderLeftWidth, 10 ) ) {\n arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] += parseFloat( tableTdBorderLeftWidth, 10 ) / 2;\n } else if( j == 0 && ( tableBorderCommon / 2 ) > parseFloat( tableTdBorderLeftWidth, 10 ) ) {\n arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] += ( ( tableBorderCommon / 2 ) - ( parseFloat( tableTdBorderLeftWidth, 10 ) / 2 ) );\n }\n\n if( j == tds.length - 1 && ( tableBorderCommon / 2 ) <= parseFloat( tableTdBorderRightWidth, 10 ) ) {\n arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] += parseFloat( tableTdBorderRightWidth, 10 ) / 2;\n } else if( j == tds.length - 1 && ( tableBorderCommon / 2 ) > parseFloat( tableTdBorderRightWidth, 10 ) ) {\n arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] += ( ( tableBorderCommon / 2 ) - ( parseFloat( tableTdBorderLeftWidth, 10 ) / 2 ) );\n }\n }\n }\n } else if( arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] ) {\n if( ! td.dataset.wptbFixedWidth ) {\n td.dataset.wptbCssTdAutoWidth = true;\n }\n } else if( arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] ) {\n td.removeAttribute( 'data-wptb-css-td-auto-width' );\n }\n }\n }\n \n for( let i = 0; i < arrayCellsWidthFixedHelper.length; i++ ) {\n if( arrayCellsWidthFixedHelper[i] ) {\n tableTdsSumMaxWidthFixed += arrayCellsWidthFixedHelper[i];\n }\n }\n \n let CellsWidthAutoCount = 0;\n for( let i = 0; i < arrayCellsWidthAutoHelper.length; i++ ) {\n if( arrayCellsWidthAutoHelper[i] ) {\n tableTdsSumMaxWidthAuto += arrayCellsWidthAutoHelper[i];\n CellsWidthAutoCount++;\n }\n }\n \n tableTdsSumMaxWidth = tableTdsSumMaxWidthFixed + tableTdsSumMaxWidthAuto;\n \n table.dataset.wptbTableTdsSumMaxWidth = tableTdsSumMaxWidth;\n if( CellsWidthAutoCount ) {\n table.dataset.wptbCellsWidthAutoCount = CellsWidthAutoCount;\n if( table.mergingСellsHorizontally ) {\n table.dataset.wptbFixedWidthSize = tableTdsSumMaxWidthFixed;\n } else {\n table.removeAttribute( 'data-wptb-fixed-width-size' );\n }\n } else {\n table.removeAttribute( 'data-wptb-fixed-width-size' );\n table.removeAttribute( 'data-wptb-cells-width-auto-count' );\n }\n \n let styleElementCreate = false;\n let tableTdWidthAuto;\n if( tableTdsSumMaxWidth < wptbTableSetupWidth ) {\n if( CellsWidthAutoCount ) {\n table.style.minWidth = '100%';\n if( table.mergingСellsHorizontally ) {\n table.style.width = null;\n let tableTdsWidthAutoCommon = wptbTableSetupWidth - tableTdsSumMaxWidthFixed;\n tableTdWidthAuto = tableTdsWidthAutoCommon / CellsWidthAutoCount;\n tableTdWidthAuto = tableTdWidthAuto - tdPaddingCommon - tableTdBorderCommonWidth;\n styleElementCreate = true;\n } else {\n table.style.width = '100%';\n }\n } else {\n table.style.width = null;\n table.style.minWidth = null;\n table.style.maxWidth = null;\n }\n } else {\n table.style.maxWidth = null;\n table.style.minWidth = tableTdsSumMaxWidth + 'px';\n table.style.width = null;\n tableTdWidthAuto = '100'\n styleElementCreate = true;\n }\n \n let head = document.head;\n if( head ) {\n let cssForTdsWidthAutoOld = head.querySelector( 'style[data-wptb-td-auto-width=\"true\"]' );\n if( cssForTdsWidthAutoOld ) {\n head.removeChild( cssForTdsWidthAutoOld );\n }\n }\n \n if( styleElementCreate ) {\n cssForTdsWidthAuto = document.createElement( 'style' );\n cssForTdsWidthAuto.setAttribute( 'data-wptb-td-auto-width', true );\n cssForTdsWidthAuto.innerHTML = '[data-wptb-css-td-auto-width=true]{width:' + tableTdWidthAuto + 'px}';\n if( head ) {\n head.appendChild( cssForTdsWidthAuto );\n }\n }\n }\n \n table.addRowHeight = function( value, cleaner ) {\n let highlighted = table.getElementsByClassName( 'wptb-highlighted' );\n if( highlighted.length > 0 ) {\n for( let k = 0; k < highlighted.length; k++ ) {\n let dataYIndex = highlighted[k].dataset.yIndex;\n if( dataYIndex ) {\n function tableTdsFor( dataYIndex, rowspan ) {\n let tableRows = table.rows;\n let heightIsSet = false;\n let arrayTdsPrevious = [];\n for( let i = 0; i < tableRows.length; i++ ) {\n let row = tableRows[i];\n let tds = row.children;\n for( let j = 0; j < tds.length; j++ ) {\n let td = tds[j];\n if( td.dataset.yIndex == dataYIndex ) {\n if( value ) {\n if( td.rowSpan == rowspan ) {\n td.style.height = value + 'px';\n td.removeAttribute( 'data-wptb-fixed-heidht' );\n heightIsSet = true;\n let tableColumnHeightAutoFixedCheckbox = document.getElementById( 'wptb-table-row-height-auto-fixed' );\n if( ! tableColumnHeightAutoFixedCheckbox.checked ) {\n tableColumnHeightAutoFixedCheckbox.checked = true;\n }\n continue;\n } else {\n td.style.height = null;\n td.dataset.wptbFixedHeight = value;\n if( j == tds.length - 1 && ! heightIsSet ) {\n tableTdsFor( dataYIndex , rowspan + 1 );\n }\n }\n } else if( cleaner ) {\n td.style.height = null;\n td.removeAttribute( 'data-wptb-fixed-heidht' );\n } else {\n if( td.dataset.wptbFixedHeight ) {\n if( td.rowSpan = rowspan ) {\n td.style.height = td.dataset.wptbFixedHeight + 'px';\n td.removeAttribute( 'data-wptb-fixed-width' );\n }\n } else if( td.style.height ) {\n for( let z = 0; z < arrayTdsPrevious.length; z++ ) {\n arrayTdsPrevious[z].style.height = td.style.height;\n }\n arrayTdsPrevious = [];\n } else {\n arrayTdsPrevious.push( td );\n }\n }\n } \n }\n }\n }\n \n tableTdsFor( dataYIndex, 1 );\n }\n }\n }\n }\n \n table.reconstraction = function() {\n let tds = table.getElementsByTagName( 'td' );\n table.mergingСellsHorizontally = false;\n table.mergingCellsVertically = false;\n table.dataset.reconstraction = 1;\n let forBreak = 0;\n for( let i = 0; i < tds.length; i++ ) {\n if( tds[i].colSpan > 1 ) {\n table.dataset.reconstraction = 0;\n table.mergingСellsHorizontally = true;\n forBreak++;\n }\n \n if( tds[i].rowSpan > 1 ) {\n table.dataset.reconstraction = 0;\n table.mergingCellsVertically = true;\n forBreak++;\n }\n \n if( forBreak == 2 ) {\n break;\n }\n }\n }\n\n /*\n * As simple as it is: adds a column to the end of table.\n */\n table.addColumnEnd = function () {\n let td,\n currentTable = document.getElementsByClassName('wptb-preview-table'),\n currentTableTd,\n currentTdStyle;\n if (currentTable.length > 0) {\n currentTableTd = currentTable[0].querySelector('td');\n }\n\n if (currentTableTd) {\n currentTdStyle = currentTableTd.getAttribute('style');\n }\n \n for (var i = 0; i < table.rows.length; i++) {\n td = new WPTB_Cell(mark);\n \n if (currentTdStyle) {\n td.getDOMElement().setAttribute('style', currentTdStyle);\n td.getDOMElement().style.width = null;\n td.getDOMElement().style.height = null;\n }\n \n table.rows[i].appendChild(td.getDOMElement());\n array[i].push(0);\n }\n \n maxAmountOfCells++;\n table.recalculateIndexes();\n table.tdDefaultWidth();\n table.addRowHeight();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n /*\n * As simple as it looks: adds a column to the start of table.\n */\n\n table.addColumnStart = function () {\n let td,\n firstCell,\n currentTable = document.getElementsByClassName('wptb-preview-table'),\n currentTableTd,\n currentTdStyle;\n if ( currentTable.length > 0 ) {\n currentTableTd = currentTable[0].querySelector('td');\n }\n\n if ( currentTableTd ) {\n currentTdStyle = currentTableTd.getAttribute('style');\n }\n \n for (var i = 0; i < table.rows.length; i++) {\n td = new WPTB_Cell(mark);\n if (currentTdStyle) {\n td.getDOMElement().setAttribute('style', currentTdStyle);\n td.getDOMElement().style.width = null;\n td.getDOMElement().style.height = null;\n }\n firstCell = table.rows[i].getElementsByTagName('td')[0];\n if (firstCell) {\n table.rows[i].insertBefore(td.getDOMElement(), firstCell);\n } else {\n table.rows[i].appendChild(td.getDOMElement());\n }\n array[i].push(0);\n }\n\n maxAmountOfCells++;\n table.recalculateIndexes();\n table.tdDefaultWidth();\n table.addRowHeight();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n /*\n * Well, not so simple as previous functions.\n * It adds a column after a certain column of reference.\n * @param integer the column number to be used as reference.\n *\tIf empty, then the first highlighted cell is used as reference.\n */\n\n table.addColumnAfter = function (c_pos) {\n let rows = table.rows,\n cellPointer,\n cellsBuffer,\n cell = document.querySelector('.wptb-highlighted'),\n cellStyle = cell.getAttribute('style'),\n pos = c_pos != undefined && typeof c_pos === 'number' ? c_pos : getCoords(cell)[1];\n \n \n \n if( maxAmountOfCells - pos - cell.colSpan + 1 == 1 ) {\n table.addColumnEnd();\n } else {\n let pendingInsertion = false,\n stepsToMove,\n td, bro,\n carriedRowspans = [],\n currentCell;\n\n for (var i = 0; i < maxAmountOfCells; i++) {\n carriedRowspans.push(0);\n }\n\n for (var i = 0; i < rows.length; i++) {\n cellPointer = 0;\n cellsBuffer = rows[i].getElementsByTagName('td');\n pendingInsertion = false;\n for (var xPosition = 0;\n xPosition < maxAmountOfCells;\n xPosition += stepsToMove) {\n stepsToMove = 1;\n\n if (pendingInsertion) {\n td = new WPTB_Cell(mark);\n if (cellStyle) {\n td.getDOMElement().setAttribute('style', cellStyle);\n td.getDOMElement().style.width = null;\n td.getDOMElement().style.height = null;\n }\n if (currentCell && rows[i].contains(currentCell)) {\n bro = currentCell.nextSibling;\n if (bro) {\n rows[i].insertBefore(td.getDOMElement(), bro);\n } else {\n rows[i].appendChild(td.getDOMElement());\n }\n } else {\n rows[i].insertBefore(td.getDOMElement(), cellsBuffer[0]);\n }\n break;\n } else if (carriedRowspans[xPosition] > 0) {\n // If no pending insertion, let's check if no rowspan from upper cells is pending in current position\n if (pos == xPosition) {\n pendingInsertion = true;\n }\n } else {\n currentCell = cellsBuffer[cellPointer++];\n if (currentCell.rowSpan > 1) {\n stepsToMove = currentCell.colSpan;\n for (var k = 0; k < currentCell.colSpan; k++) {\n carriedRowspans[xPosition + k] = currentCell.rowSpan;\n if (xPosition + k == pos) {\n pendingInsertion = true;\n }\n }\n } else if (currentCell.colSpan > 1) {\n stepsToMove = currentCell.colSpan;\n for (var k = 0; k < currentCell.colSpan; k++) {\n if (xPosition + k == pos) {\n pendingInsertion = true;\n }\n }\n } else if (xPosition == pos) {\n pendingInsertion = true;\n }\n }\n }\n\n for (var l = 0; l < maxAmountOfCells; l++) {\n if (carriedRowspans[l] > 0)\n carriedRowspans[l]--;\n }\n\n }\n\n for (var i = 0; i < array.length; i++) {\n array[i].push(0);\n }\n maxAmountOfCells++;\n drawTable(array);\n table.recalculateIndexes();\n table.addColumnWidth();\n table.addRowHeight();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n };\n\n /*\n * For preventing us to take a lot of time,\n * This is just calling the function addColumnAfter, but\n * using the previous column to current one as reference.\n * @see addColumnAfter\n */\n\n table.addColumnBefore = function () {\n var cell = document.querySelector('.wptb-highlighted'),\n pos = getCoords(cell)[1];\n\n if (pos === 0) {\n table.addColumnStart();\n } else {\n table.addColumnAfter(pos - 1);\n }\n };\n\n /*\n * Luckily, thisfunction is simple, \n * it just add a row to the end of table.\n */\n\n table.addRowToTheEnd = function () {\n let r = table.insertRow(-1),\n td,\n aux,\n currentTable = document.getElementsByClassName('wptb-preview-table');\n r.classList.add( 'wptb-row' );\n if (currentTable.length > 0) {\n currentTable = currentTable[0];\n \n for (var i = 0; i < maxAmountOfCells; i++) {\n td = new WPTB_Cell(mark);\n let currentTableTd = currentTable.querySelector('[data-x-index=\"' + i + '\"]');\n if( currentTableTd ) {\n let currentTdStyle = currentTableTd.getAttribute( 'style' );\n \n td.getDOMElement().setAttribute( 'style', currentTdStyle );\n td.getDOMElement().style.height = null;\n }\n r.appendChild(td.getDOMElement());\n }\n \n aux = Array.from(array[0]);\n array.push(aux);\n drawTable(array);\n table.recalculateIndexes();\n table.addColumnWidth();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n };\n\n /*\n * Yet another simple function, \n * it just add a row to the start of table.\n */\n\n table.addRowToTheStart = function () {\n let r = table.insertRow(0),\n td,\n aux,\n currentTable = document.getElementsByClassName('wptb-preview-table'),\n currentTableTd,\n currentTdStyle;\n r.classList.add( 'wptb-row' );\n if (currentTable.length > 0) {\n currentTable = currentTable[0];\n \n for (var i = 0; i < maxAmountOfCells; i++) {\n td = new WPTB_Cell(mark);\n let currentTableTd = currentTable.querySelector('[data-x-index=\"' + i + '\"]');\n if( currentTableTd ) {\n let currentTdStyle = currentTableTd.getAttribute( 'style' );\n \n td.getDOMElement().setAttribute( 'style', currentTdStyle );\n td.getDOMElement().style.height = null;\n }\n r.appendChild(td.getDOMElement());\n }\n \n aux = Array.from(array[0]);\n array.push(aux);\n drawTable(array);\n table.recalculateIndexes();\n table.addColumnWidth();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n };\n\n /* \n * This function adds a row before the current one.\n * Since the biggest factor of problem is a not-started but ongoing rowspan,\n * the most of the troubles is not here.\n */\n\n table.addRowBefore = function () {\n let cell = document.querySelector('.wptb-highlighted'),\n cellStyle = cell.getAttribute('style'),\n row = getCoords(cell)[0],\n cellNew;\n for( let i = row - 1; i >= 0; i-- ) {\n let rowChildren = table.rows[i].children;\n let rowChildrenLength = rowChildren.length;\n if( rowChildrenLength > 0 ) {\n for( let j = 0; j < rowChildrenLength; j++ ) {\n if( rowChildren[j].rowSpan == 1 ) {\n row = i;\n cellNew = true;\n break;\n }\n }\n }\n if ( cellNew ) {\n break;\n }\n }\n\n if (row === 0) {\n table.addRowToTheStart();\n } else {\n table.addRowAfter( row, cellStyle );\n }\n };\n\n /*\n * Well... by the name convention of the previous 3 functions,\n * it's pretty obvious that this functions attaches a new\n * row after highlighted cell row. The greatest obstacle it was\n * the possibility of a TR not having the exact amount of columns\n * occuped by actual node but rowspanned upper cells. For that purpose\n * it was created the function realTimeArray.\n * @see realTimeArray\n */\n\n table.addRowAfter = function ( row, cellStyle ) {\n let cellRowSpan,\n rowAfter,\n aux;\n \n if ( ( row == undefined || typeof row !== 'number' ) && cellStyle == undefined ) {\n let cell = document.querySelector('.wptb-highlighted');\n cellStyle = cell.getAttribute('style'),\n row = getCoords(cell)[0],\n cellRowSpan = cell.rowSpan,\n rowAfter = row + cellRowSpan - 1;\n } else {\n rowAfter = row;\n }\n \n \n let cellsColSpan = 0;\n if ( rowAfter < table.rows.length -1 ) {\n for( let i = 0; i <= rowAfter ; i++ ) {\n let tableRowsIChildren = table.rows[i].children,\n tableRIChildrenLength = tableRowsIChildren.length;\n if( tableRIChildrenLength > 0 ) {\n for( let j = 0; j < tableRIChildrenLength; j++ ) {\n let rowIRowSpan = tableRowsIChildren[j].rowSpan;\n\n if ( rowIRowSpan - 1 + i > rowAfter ) {\n tableRowsIChildren[j].rowSpan++;\n }\n }\n }\n }\n \n let rNext = table.rows[rowAfter + 1],\n rNextChildren = rNext.children,\n rNextChildrenLength = rNextChildren.length;\n \n if( rNextChildrenLength > 0 ) {\n for ( let i = 0; i < rNextChildrenLength; i++ ) {\n cellsColSpan += rNextChildren[i].colSpan;\n }\n }\n } else {\n cellsColSpan = array[0].length;\n }\n \n let r = table.insertRow( rowAfter + 1 );\n r.classList.add( 'wptb-row' );\n \n for ( j = 0; j < cellsColSpan; j++ ) {\n let td = new WPTB_Cell( mark );\n td.getDOMElement().setAttribute( 'style', cellStyle );\n td.getDOMElement().style.width = null;\n td.getDOMElement().style.height = null;\n r.appendChild( td.getDOMElement() );\n }\n\n aux = Array.from(array[0]);\n array.push(aux);\n drawTable(array);\n table.recalculateIndexes();\n table.addColumnWidth();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n /*\n * This function checks the current selected cells\n * make a rectangular shape.\n * @param Array the abstract table.\n * @return false, if not making a rectangle, or\n *\tArray an array containing number of rows and columns, if selection makes a rectangle.\n */\n\n table.isSquare = function (a) {\n var rowStart = -1,\n columnStart = -1,\n rowEnd = -1,\n columnEnd = -1,\n height,\n width,\n itemsEstimate = 0,\n items = 0;\n\n for (var i = 0; i < a.length; i++) {\n for (var j = 0; j < a[i].length; j++) {\n if (a[i][j] == 1) {\n if ( j < columnStart || columnStart == -1 ) {\n columnStart = j;\n }\n if ( i < rowStart || rowStart == -1 ) {\n rowStart = i;\n }\n }\n }\n \n }\n\n for (var i = a.length - 1; i > -1; i--) {\n for (var j = a[i].length - 1; j > -1; j--) {\n if (a[i][j] == 1) {\n if ( j > columnEnd ) {\n columnEnd = j;\n }\n if ( i > rowEnd ) {\n rowEnd = i;\n }\n }\n }\n }\n\n for (var i = rowStart; i < rowEnd; i++) {\n for (var j = columnStart; j < columnEnd; j++) {\n if (a[i][j] == 0 || a[i][j] == undefined) {\n return false;\n }\n }\n }\n\n for (var i = 0; i < a.length; i++) {\n for (var j = 0; j < a[i].length; j++) {\n if (a[i][j] == 1) {\n items++;\n }\n }\n }\n\n height = rowEnd - rowStart + 1;\n width = columnEnd - columnStart + 1;\n itemsEstimate = height * width;\n\n if (itemsEstimate !== items) {\n return false;\n }\n return [height, width];\n };\n\n /*\n * This function merges all selected cells.\n * Well, actually sets the colspan and rowspan of first \n * upper left cell in selection and deletes the another selected cells.\n */\n\n table.mergeCells = function () {\n var dimensions = table.isSquare(array),\n rowspan = dimensions[0],\n colspan = dimensions[1],\n first = document.querySelector('.wptb-highlighted'),\n tds = [].slice.call(document.getElementsByClassName('wptb-highlighted'), 1),\n tdsChildrenNew = [];\n\n for (let i = 0; i < tds.length; i++) {\n let tdsInternalElements = tds[i].getElementsByClassName('wptb-ph-element');\n if (tdsInternalElements.length > 0) {\n let tdsIntElemLength = tdsInternalElements.length;\n for (let j = 0; j < tdsIntElemLength; j++) {\n tdsChildrenNew.push(tdsInternalElements[j]);\n }\n }\n let p = tds[i].parentNode;\n p.removeChild(tds[i]);\n }\n if (tdsChildrenNew.length > 0) {\n for (let i = 0; i < tdsChildrenNew.length; i++) {\n first.appendChild(tdsChildrenNew[i]);\n }\n }\n\n first.colSpan = colspan;\n first.rowSpan = rowspan;\n table.recalculateIndexes();\n table.reconstraction();\n let firstWidth = first.style.width;\n let firstDataFixedWidth = first.dataset.wptbFixedWidth;\n if( firstWidth ) {\n table.addColumnWidth( parseFloat( firstWidth, 10 ) );\n } else if( firstDataFixedWidth ) {\n table.addColumnWidth();\n } else {\n table.addColumnWidth( false, true );\n }\n \n let firstHeight = first.style.height;\n let firstDataFixedHeight = first.dataset.wptbFixedHeight;\n if( firstHeight ) {\n table.addRowHeight( parseFloat( firstHeight, 10 ) );\n } else if( firstDataFixedHeight ) {\n table.addRowHeight();\n } else {\n table.addRowHeight( false, true );\n }\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n /*\n * This functions makes the exact inverse as above.\n * It resets colspan and rowspan and appends \n * the same amount in cells to the table.\n * @bug\n */\n\n table.splitCell = function () {\n var cell = document.getElementsByClassName('wptb-highlighted')[0],\n rowspan = cell.rowSpan,\n colspan = cell.colSpan,\n cellStyles = cell.getAttribute('style'),\n row = getCoords(cell)[0],\n thisRow = table.rows[row],\n cellXIndex =cell.dataset.xIndex;\n \n cell.rowSpan = 1;\n cell.colSpan = 1;\n \n for (let i = 1; i < colspan; i++) {\n let td = new WPTB_Cell(mark);\n td.getDOMElement().setAttribute('style', cellStyles);\n td.getDOMElement().classList.add( 'wptb-highlighted' );\n if ( cell.nextSibling ) {\n thisRow.insertBefore( td.getDOMElement(), cell.nextSibling );\n } else {\n thisRow.appendChild( td.getDOMElement() );\n }\n \n }\n\n if (rowspan > 1) {\n for (let i = 1; i < rowspan; i++) {\n let rowChildInsertBefore = undefined,\n rowNext = table.rows[row + i],\n rowChildren = rowNext.children,\n rowChildrenLength = rowChildren.length;\n \n if ( rowChildrenLength > 0 ) {\n for ( let k = 0; k < rowChildrenLength; k++ ) {\n if ( Number( rowChildren[k].dataset.xIndex ) > Number( cellXIndex ) ) {\n rowChildInsertBefore = rowChildren[k];\n break;\n } \n }\n }\n for ( let j = 0; j < colspan; j++ ) {\n let td = new WPTB_Cell( mark );\n td.getDOMElement().setAttribute( 'style', cellStyles );\n if ( rowChildInsertBefore != undefined ) {\n rowNext.insertBefore( td.getDOMElement(), rowChildInsertBefore );\n } else {\n rowNext.appendChild( td.getDOMElement() );\n }\n }\n }\n }\n\n table.recalculateIndexes();\n table.reconstraction();\n table.addColumnWidth();\n table.addRowHeight();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n /*\n * Searches for rowspanned cells up to row number meeting it.\n * @param number the number of row where the function\n * must search up to.\n */\n\n table.findRowspannedCells = function (row) {\n var array = [],\n difference;\n actualPoints = getActualPointsInRow(row);\n if (actualPoints === maxAmountOfCells) {\n return [];\n }\n difference = maxAmountOfCells - actualPoints;\n\n for (var i = row - 1; i >= 0 && difference; i--) {\n var tds = table.rows[i].getElementsByTagName('td');\n for (var i = 0; i < tds.length; i++) {\n if (tds[i].rowSpan > 1) {\n array.push(tds[i]);\n difference -= tds[i].colSpan;\n }\n }\n }\n return array;\n\n }\n\n /*\n * This function explores the table and adds \n * a cell for each lacking one for each row\n * to meet an even amount of cells.\n */\n\n table.addLackingCells = function () {\n var sumRows = [];\n for (var i = 0; i < table.rows.length; i++) {\n sumRows.push(0);\n }\n\n for (var i = 0; i < table.rows.length; i++) {\n var tds = table.rows[i].getElementsByTagName('td');\n for (var j = 0; j < tds.length; j++) {\n if (tds[j].rowSpan > 1) {\n for (var k = 1; k < tds[j].rowSpan; k++) {\n sumRows[i + k]++;\n }\n }\n }\n }\n\n for (var i = 0; i < table.rows.length; i++) {\n var tds = table.rows[i].getElementsByTagName('td'),\n totalColspan = 0;\n for (var j = 0; j < tds.length; j++) {\n totalColspan += tds[j].colSpan;\n }\n totalColspan += sumRows[i];\n difference = maxAmountOfCells - totalColspan;\n for (var j = 0; j < difference; j++) {\n var td = new WPTB_Cell(mark);\n table.rows[i].appendChild(td.getDOMElement());\n //table.rows[i].insertBefore( td.getDOMElement(), rows[i].nextSibling );\n }\n }\n };\n\n /*\n * This function deletes the row of currently\n * selected cell. \n */\n\n table.deleteRow = function () {\n let cell = document.querySelector('.wptb-highlighted'),\n cellStyles = cell.getAttribute('style'),\n rowspan = cell.rowSpan,\n row = getCoords(cell)[0],\n thisRow,\n aux;\n \n if ( rowspan == undefined ) rowspan = 1;\n \n for ( let i = 0; i < rowspan; i++ ) {\n thisRow = table.rows[row];\n let thisRowChildren = thisRow.children,\n nextRow = table.rows[row + 1],\n nextRowChildren,\n nextRowChildrenLength,\n tdArr = [];\n\n if( nextRow != undefined ) {\n nextRowChildren = nextRow.children;\n nextRowChildrenLength = nextRowChildren.length;\n for (let j = 0; j < thisRowChildren.length; j++) {\n if ( thisRowChildren[j].rowSpan > 1 ) {\n let td = new WPTB_Cell(mark);\n td.getDOMElement().setAttribute('style', cellStyles);\n td.getDOMElement().colSpan = thisRowChildren[j].colSpan;\n td.getDOMElement().rowSpan = thisRowChildren[j].rowSpan - 1;\n\n let nextRowChildrenK = undefined;\n for ( let k = 0; k < nextRowChildrenLength; k++ ) {\n if ( Number( nextRowChildren[k].dataset.xIndex ) > Number( thisRowChildren[j].dataset.xIndex ) ) {\n nextRowChildrenK = nextRowChildren[k];\n break;\n } \n }\n\n if ( nextRowChildrenK ) {\n tdArr.push( [td, nextRowChildrenK] );\n } else {\n tdArr.push( [td] );\n }\n }\n }\n\n if ( tdArr.length > 0 ) {\n for ( let k = 0; k < tdArr.length; k++ ) {\n if ( tdArr[k][1] != undefined ) {\n nextRow.insertBefore( tdArr[k][0].getDOMElement(), tdArr[k][1] );\n } else {\n nextRow.appendChild( tdArr[k][0].getDOMElement() );\n }\n }\n }\n }\n \n let tableRows = table.rows;\n if ( tableRows.length > 0 ) {\n for ( let j = 0; j < row; j++ ) {\n let jRowChildren = tableRows[j].children;\n if ( jRowChildren.length > 0 ) {\n for ( let x = 0; x < jRowChildren.length; x++ ) {\n if ( jRowChildren[x].rowSpan - 1 >= row - j ) {\n jRowChildren[x].rowSpan--;\n }\n }\n }\n }\n }\n aux = Array.from(array[0]);\n array.pop(aux);\n drawTable(array);\n table.getElementsByTagName('tbody')[0].removeChild(table.rows[row]);\n \n if( table.rows.length == 0 ) {\n table.toggleTableEditMode();\n wptbTableSetup.innerHTML = '';\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\n let wptbSaveBtn = document.getElementsByClassName( 'wptb-save-btn' );\n if( wptbSaveBtn.length > 0 ) {\n wptbSaveBtn = wptbSaveBtn[0];\n \n wptbSaveBtn.classList.add( 'wptb-save-disabled' );\n }\n } else {\n table.recalculateIndexes();\n WPTB_Helper.dataTitleColumnSet( table );\n }\n }\n \n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n\n /*\n * This function deletes the column of currently\n * selected cell. Again, this is way more complicated than\n * delete row case.\n */\n\n table.deleteColumn = function () {\n let cell = document.querySelector('.wptb-highlighted'),\n cellXIndex = cell.dataset.xIndex,\n colspan = cell.colSpan;\n \n for ( let i = 0; i < colspan; i++ ) {\n for ( let j = 0; j < table.rows.length; j++ ) {\n let rowChildren = table.rows[j].children;\n let rowChildrenLength = rowChildren.length;\n if( rowChildrenLength > 0 ) {\n for ( let k = rowChildrenLength - 1; k >= 0; k-- ) {\n if ( Number( rowChildren[k].dataset.xIndex ) == Number( cellXIndex ) ) {\n if ( rowChildren[k].colSpan > 1 ) {\n rowChildren[k].colSpan--;\n } else {\n table.rows[j].removeChild( rowChildren[k] );\n }\n break;\n } else if( Number( rowChildren[k].dataset.xIndex ) < Number( cellXIndex ) && \n Number( rowChildren[k].dataset.xIndex ) + \n Number( rowChildren[k].colSpan -1 ) >= cellXIndex ) {\n if ( rowChildren[k].colSpan > 1 ) {\n rowChildren[k].colSpan--;\n }\n break;\n }\n }\n }\n }\n \n for ( let j = 0; j < table.rows.length; j++ ) {\n if (array[j] != undefined)\n array[j].pop();\n }\n \n maxAmountOfCells--;\n \n if( table.querySelectorAll( 'td' ).length == 0 ) {\n table.toggleTableEditMode();\n wptbTableSetup.innerHTML = '';\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\n let wptbSaveBtn = document.getElementsByClassName( 'wptb-save-btn' );\n if( wptbSaveBtn.length > 0 ) {\n wptbSaveBtn = wptbSaveBtn[0];\n \n wptbSaveBtn.classList.add( 'wptb-save-disabled' );\n }\n } else {\n table.recalculateIndexes();\n table.tdDefaultWidth();\n WPTB_Helper.dataTitleColumnSet( table );\n }\n }\n \n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'none';\n\n array = fillTableArray();\n\n undoSelect();\n drawTable(array);\n\n wptbTableSetup.appendChild(table);\n //if (columns || rows) {\n table.recalculateIndexes( true );\n //}\n table.reconstraction();\n table.tdDefaultWidth();\n \n wptbTableSetup.onresize = function() {\n table.tdDefaultWidth();\n };\n\n WPTB_LeftPanel();\n \n // this code gets the ID of the active element in the toolbar \n // and stores it in the data attribute of the common container element \"wpcd_fixed_toolbar\"\n// let wptbPhElement = document.getElementsByClassName( 'wptb-ph-element' );\n// let wpcdFixedToolbar = document.getElementById( 'wpcd_fixed_toolbar' );\n// for ( let i = 0; i < wptbPhElement.length; i++ ) {\n// wptbPhElement[i].addEventListener( 'click', function( e ) {\n// let wptbToolbar = document.getElementById( 'wpcd_fixed_toolbar' ).children;\n// for ( let j = 0; j < wptbToolbar.length; j++ ) {\n// let elementStyles = window.getComputedStyle( wptbToolbar[j], 'null' );\n// if( elementStyles.getPropertyValue( 'display' ) == 'block' ) {\n// wpcdFixedToolbar.dataset.toolbarActiveId = wptbToolbar[j].getAttribute( 'id' );\n// }\n// }\n// }, false );\n// }\n \n// let wptbPanelLeft = document.getElementsByClassName( 'wptb-panel-left' );\n// if( wptbPanelLeft.length > 0 ) {\n// wptbPanelLeft[0].addEventListener( 'click', function( e ) {\n// let toolbarActiveElementId = wpcdFixedToolbar.dataset.toolbarActiveId;\n// document.getElementById( toolbarActiveElementId ).style.display = '';\n// }, false );\n// }\n \n// let body = document.getElementsByTagName( 'body' );\n// if( body.length > 0 ) {\n// body[0].addEventListener( 'click', function( e ) {\n// if ( e.target.classList.contains( 'wptb-panel-left' ) || WPTB_Helper.findAncestor( e.target, 'wptb-panel-left' ) ) {\n// let toolbarActiveElementId = wpcdFixedToolbar.dataset.toolbarActiveId;\n// document.getElementById( toolbarActiveElementId ).style.display = '';\n// }\n// }, false );\n// }\n};","var WPTB_TableStateSaveManager = function() {\n this.tableStateSet = ( generate ) => {\n \n if( generate && window.wptbTableStateSaving && Array.isArray( window.wptbTableStateSaving ) ) {\n return;\n }\n \n // get preview table\n let wptbPreviewTable = document.getElementsByClassName( 'wptb-preview-table' );\n if( wptbPreviewTable.length > 0 ) {\n wptbPreviewTable = wptbPreviewTable[0];\n } else {\n wptbPreviewTable = '';\n }\n \n // check if a global array doesn't exist with saved versions of the table \n // them create it\n if( ! window.wptbTableStateSaving && ! Array.isArray( window.wptbTableStateSaving ) ) {\n window.wptbTableStateSaving = [];\n } \n\n // remove the extra part of the array after changing the table \n // when it is showed in the not last modified version\n if( window.wptbTableStateSaving.length > window.wptbTableStateNumberShow ) {\n window.wptbTableStateSaving = window.wptbTableStateSaving.slice( 0, window.wptbTableStateNumberShow + 1 );\n }\n\n //add new state of table\n let wptbNewPreviewTable = '';\n if( wptbPreviewTable ) {\n wptbNewPreviewTable = wptbPreviewTable.cloneNode( true );\n let wptbHighlighted = wptbNewPreviewTable.getElementsByClassName( 'wptb-highlighted' );\n for( let i = 0; i < wptbHighlighted.length; i++ ) {\n wptbHighlighted[i].classList.remove( 'wptb-highlighted' );\n }\n let wptbDirectlyhovered = wptbNewPreviewTable.getElementsByClassName( 'wptb-directlyhovered' );\n for( let i = 0; i < wptbDirectlyhovered.length; i++ ) {\n wptbDirectlyhovered[i].classList.remove( 'wptb-directlyhovered' );\n }\n let mceContentBodys = wptbNewPreviewTable.querySelectorAll( '.mce-content-body' );\n if( mceContentBodys.length > 0 ) {\n for ( let k = 0; k < mceContentBodys.length; k++ ) {\n mceContentBodys[k].classList.remove( 'mce-content-body' );\n }\n }\n let dataMceStyle = wptbNewPreviewTable.querySelectorAll( '[data-mce-style]' );\n if ( dataMceStyle.length > 0 ) {\n for ( let k = 0; k < dataMceStyle.length; k++ ) {\n dataMceStyle[k].removeAttribute( 'data-mce-style' );\n }\n }\n let mceIds = wptbNewPreviewTable.querySelectorAll( '[id^=mce_]' );\n if ( mceIds.length > 0 ) {\n for ( let k = 0; k < mceIds.length; k++ ) {\n mceIds[k].removeAttribute( 'id' );\n }\n }\n }\n\n let cssForTdsWidthAutoValue = '';\n let head = document.head;\n if( head ) {\n let cssForTdsWidthAuto = head.querySelector( 'style[data-wptb-td-auto-width=\"true\"]' );\n if( cssForTdsWidthAuto ) {\n cssForTdsWidthAutoValue = cssForTdsWidthAuto.innerHTML;\n }\n }\n\n let wptbElementDatas = document.getElementsByClassName( 'wptb-element-datas' );\n if( wptbElementDatas.length > 0 ) {\n wptbElementDatas = wptbElementDatas[0];\n wptbElementDatas = wptbElementDatas.innerHTML;\n } else {\n wptbElementDatas = '';\n }\n\n let styleObjJson = WPTB_Helper.elementsStylesConvertToObject();\n\n window.wptbTableStateSaving.push( [wptbNewPreviewTable, cssForTdsWidthAutoValue, wptbElementDatas, styleObjJson] );\n\n // set new number of state which is showed now\n window.wptbTableStateNumberShow = window.wptbTableStateSaving.length - 1;\n\n // make undo arrow active when the table was changed\n if( window.wptbTableStateSaving.length - 1 > 0 ) {\n let wptbUndo = document.getElementsByClassName( 'wptb-undo' );\n if( wptbUndo.length > 0 ) {\n wptbUndo = wptbUndo[0];\n\n wptbUndo.classList.remove( 'wptb-undoredo-disabled' );\n }\n }\n\n // make redo arrow not active when the table was changed\n let wptbRedo = document.getElementsByClassName( 'wptb-redo' );\n if( wptbRedo.length > 0 ) {\n wptbRedo = wptbRedo[0];\n\n wptbRedo.classList.add( 'wptb-undoredo-disabled' );\n }\n\n let wptbSaveBtn = document.getElementsByClassName( 'wptb-save-btn' );\n if( wptbSaveBtn.length > 0 ) {\n wptbSaveBtn = wptbSaveBtn[0];\n if( ( ! wptbSaveBtn.dataset.wptbTableStateNumberSave && window.wptbTableStateNumberShow == 0 ) || \n window.wptbTableStateNumberShow == wptbSaveBtn.dataset.wptbTableStateNumberSave || ! wptbPreviewTable ) {\n wptbSaveBtn.classList.add( 'wptb-save-disabled' );\n } else {\n wptbSaveBtn.classList.remove( 'wptb-save-disabled' );\n }\n }\n }\n \n this.tableStateGet = ( datawptbUndoredo ) => {\n if( datawptbUndoredo && window.wptbTableStateSaving && window.wptbTableStateSaving.length > 0 ) {\n \n // changes the number of the state which displays now\n if( datawptbUndoredo == 'undo' ) {\n if( window.wptbTableStateNumberShow > 0 ) {\n window.wptbTableStateNumberShow--;\n } else {\n return false;\n }\n } else if( datawptbUndoredo == 'redo' ) {\n if( window.wptbTableStateNumberShow < window.wptbTableStateSaving.length ) {\n window.wptbTableStateNumberShow++;\n } else {\n return false;\n }\n }\n \n // add or delete class \"wptb-undoredo-disabled\" for undo button\n let wptbUndo = document.getElementsByClassName( 'wptb-undo' );\n if( wptbUndo.length > 0 ) {\n wptbUndo = wptbUndo[0];\n \n if( window.wptbTableStateNumberShow == 0 ) {\n if( wptbUndo ) {\n wptbUndo.classList.add( 'wptb-undoredo-disabled' );\n }\n } else if( window.wptbTableStateNumberShow > 0 ) {\n if( wptbUndo ) {\n wptbUndo.classList.remove( 'wptb-undoredo-disabled' );\n }\n }\n }\n \n // add or delete class \"wptb-undoredo-disabled\" for redo button\n let wptbRedo = document.getElementsByClassName( 'wptb-redo' );\n if( wptbRedo.length > 0 ) {\n wptbRedo = wptbRedo[0];\n \n if( window.wptbTableStateNumberShow == window.wptbTableStateSaving.length - 1 ) {\n if( wptbRedo ) {\n wptbRedo.classList.add( 'wptb-undoredo-disabled' );\n }\n } else if( window.wptbTableStateNumberShow < window.wptbTableStateSaving.length - 1 ) {\n if( wptbRedo ) {\n wptbRedo.classList.remove( 'wptb-undoredo-disabled' );\n }\n }\n }\n \n // add or delete class \"wptb-save-disabled\" for save button\n let wptbSaveBtn = document.getElementsByClassName( 'wptb-save-btn' );\n if( wptbSaveBtn.length > 0 ) {\n wptbSaveBtn = wptbSaveBtn[0];\n if( ( ! wptbSaveBtn.dataset.wptbTableStateNumberSave && window.wptbTableStateNumberShow == 0 ) || \n window.wptbTableStateNumberShow == wptbSaveBtn.dataset.wptbTableStateNumberSave ) {\n wptbSaveBtn.classList.add( 'wptb-save-disabled' );\n } else {\n wptbSaveBtn.classList.remove( 'wptb-save-disabled' );\n }\n }\n \n // load necessary saved table state\n let wptbTableSetup = document.getElementsByClassName( 'wptb-table-setup' );\n if( wptbTableSetup.length > 0 ) {\n wptbTableSetup = wptbTableSetup[0];\n\n wptbTableSetup.innerHTML = '';\n if( window.wptbTableStateSaving[window.wptbTableStateNumberShow] ) {\n if( window.wptbTableStateSaving[window.wptbTableStateNumberShow][0] && \n typeof window.wptbTableStateSaving[window.wptbTableStateNumberShow][0] === 'object' ) {\n if( 'outerHTML' in window.wptbTableStateSaving[window.wptbTableStateNumberShow][0] ) {\n wptbTableSetup.innerHTML = window.wptbTableStateSaving[window.wptbTableStateNumberShow][0].outerHTML;\n }\n }\n \n if( ! wptbTableSetup.innerHTML ) {\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\n wptbSaveBtn.classList.add( 'wptb-save-disabled' );\n } else {\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'none';\n }\n }\n // add or change or delete style element in the head for table cells who have auto width\n if( window.wptbTableStateSaving[window.wptbTableStateNumberShow] ) {\n let head = document.head;\n if( head ) {\n let cssForTdsWidthAutoOld = head.querySelector( 'style[data-wptb-td-auto-width=\"true\"]' );\n if( cssForTdsWidthAutoOld ) {\n head.removeChild( cssForTdsWidthAutoOld );\n }\n \n if( window.wptbTableStateSaving[window.wptbTableStateNumberShow][1] ) {\n let cssForTdsWidthAuto = document.createElement( 'style' );\n cssForTdsWidthAuto.setAttribute( 'data-wptb-td-auto-width', true );\n cssForTdsWidthAuto.innerHTML = window.wptbTableStateSaving[window.wptbTableStateNumberShow][1];\n head.appendChild( cssForTdsWidthAuto );\n }\n }\n }\n \n \n let body = document.getElementsByTagName( 'body' );\n if( body.length > 0 ) {\n body = body[0];\n }\n \n // add or change or delete script element from the bottom page which have data for several control types\n let wptbElementDatas = document.getElementsByClassName( 'wptb-element-datas' );\n if( window.wptbTableStateSaving[window.wptbTableStateNumberShow] && window.wptbTableStateSaving[window.wptbTableStateNumberShow][2] ) {\n \n if( wptbElementDatas.length > 0 ) {\n wptbElementDatas = wptbElementDatas[0];\n } else {\n wptbElementDatas = document.createElement( 'sctipt' );\n wptbElementDatas.classList.add( 'wptb-element-datas' );\n body.appendChild( wptbElementDatas );\n }\n \n wptbElementDatas.innerHTML = window.wptbTableStateSaving[window.wptbTableStateNumberShow][2];\n } else {\n if( wptbElementDatas.length > 0 ) {\n wptbElementDatas = wptbElementDatas[0];\n body.removeChild( wptbElementDatas );\n }\n }\n \n // runs function which adds or create or delete CSS in the head for several element settings\n if( window.wptbTableStateSaving[window.wptbTableStateNumberShow] ) {\n WPTB_Helper.elementsStylesSetFromObject( window.wptbTableStateSaving[window.wptbTableStateNumberShow][3] );\n }\n\n WPTB_Helper.elementOptionsPanelClear();\n WPTB_LeftPanel();\n\n let wptbLeftScrollPanelCellSetting = document.getElementById( 'wptb-left-scroll-panel-cell-settings' ); \n if( wptbLeftScrollPanelCellSetting ) {\n wptbLeftScrollPanelCellSetting.classList.remove( 'visible' );\n }\n }\n }\n }\n \n this.tableStateClear = function() {\n delete window.wptbTableStateSaving;\n delete window.wptbTableStateNumberShow;\n \n let wptbSaveBtn = document.getElementsByClassName( 'wptb-save-btn' );\n if( wptbSaveBtn.length > 0 ) {\n wptbSaveBtn = wptbSaveBtn[0];\n \n wptbSaveBtn.removeAttribute( 'data-wptb-table-state-number-save' );\n }\n \n let wptbUndo = document.getElementsByClassName( 'wptb-undo' );\n if( wptbUndo.length > 0 ) {\n wptbUndo = wptbUndo[0];\n \n wptbUndo.classList.add( 'wptb-undoredo-disabled' );\n }\n \n let wptbRedo = document.getElementsByClassName( 'wptb-redo' );\n if( wptbRedo.length > 0 ) {\n wptbRedo = wptbRedo[0];\n\n wptbRedo.classList.add( 'wptb-undoredo-disabled' );\n }\n }\n}","var WPTB_innerElementSet = function ( element ) {\n \n element.ondragenter = function (e) {\n var div;\n if ( e.dataTransfer.types.indexOf( 'wptbelement' ) == -1 && e.dataTransfer.types.indexOf( 'wptb-moving-mode' ) == -1 ) {\n return;\n }\n WPTB_DropHandle(this, e);\n \n element.classList.add( 'wptb-ondragenter' );\n }\n element.ondragover = function (e) {\n e.preventDefault();\n WPTB_DropHandle(this, e);\n }\n element.ondragleave = function () {\n \n }\n element.ondrop = function(e) {\n this.classList.remove( 'wptb-ondragenter' );\n let element, classId;\n e.preventDefault();\n e.stopPropagation();\n\n if (!e.dataTransfer.getData('wptbElement') && !e.dataTransfer.getData('node')) {\n return;\n }\n let wptbDropHandle,\n wptbDropBorderMarker;\n if ( document.getElementsByClassName( 'wptb-drop-handle' ).length > 0 ) {\n wptbDropHandle = document.getElementsByClassName( 'wptb-drop-handle' )[0];\n }\n if( document.getElementsByClassName( 'wptb-drop-border-marker' ).length > 0 ) {\n wptbDropBorderMarker = document.getElementsByClassName( 'wptb-drop-border-marker' )[0];\n }\n\n if ( e.dataTransfer.getData( 'wptbElement' ) ) {\n element = WPTB_Helper.newElementProxy( e.dataTransfer.getData( 'wptbElement' ) );\n element = element.getDOMElement();\n } else {\n classId = e.dataTransfer.getData( 'node' );\n element = document.getElementsByClassName( classId )[0];\n //element.classList.remove( 'wptb-moving-mode' );\n }\n \n if( wptbDropHandle.style.display == 'block' ) {\n let td;\n if( wptbDropHandle.dataset.text == 'Drop Here' ) {\n td = wptbDropHandle.getDOMParentElement();\n td.appendChild( element );\n } else {\n let innerElement = wptbDropHandle.getDOMParentElement();\n td = innerElement.parentNode;\n\n if( wptbDropHandle.dataset.text == 'Above Element' ) {\n td.insertBefore( element, innerElement );\n } else if( wptbDropHandle.dataset.text == 'Below Element' ) {\n let innerElementNext = innerElement.nextSibling;\n td.insertBefore( element, innerElementNext );\n }\n }\n \n let thisRow = td.parentNode;\n if( WPTB_Helper.rowIsTop( thisRow ) ) { \n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\n \n if( table.classList.contains( 'wptb-table-preview-head' ) ) {\n WPTB_Helper.dataTitleColumnSet( table );\n }\n }\n \n // start item javascript if item is new\n let infArr = element.className.match(/wptb-element-(.+)-(\\d+)/i);\n let elemKind = infArr[1];\n if ( e.dataTransfer.getData( 'wptbElement' ) && ( elemKind == 'text' || elemKind == 'button' || elemKind == 'image' || elemKind == 'star_rating' || elemKind == 'list' ) ) {\n //WPTB_Helper.elementStartScript( element );\n }\n } else {\n return;\n }\n \n wptbDropHandle.style.display = 'none';\n wptbDropBorderMarker.style.display = 'none';\n\n WPTB_innerElementSet( element );\n \n if( ! element.classList.contains( 'wptb-image-container' ) || element.classList.contains( 'wptb-moving-mode' ) ) {\n element.classList.remove( 'wptb-moving-mode' );\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n } \n return true;\n }\n element.onmouseover = function(e) {\n element.classList.remove( 'wptb-ondragenter' );\n }\n}","var applyGenericItemSettings = function ( element, kindIndexProt, copy = false ) {\n var node = element.getDOMElement(),\n index,\n copy;\n if( node.classList.contains( 'wptb-ph-element' ) ) {\n if ( kindIndexProt == undefined || copy == true ) {\n index = document.counter.nextIndex( element.kind );\n let wptbElements = document.getElementsByClassName( 'wptb-ph-element' );\n let elementIndexesArr = [];\n for( let i = 0; i < wptbElements.length; i++ ) {\n var regex = new RegExp( 'wptb-element-' + element.kind + '-(\\\\d+)', \"i\" );\n let infArr = wptbElements[i].className.match( regex );\n if( infArr ) {\n elementIndexesArr.push( infArr[1] );\n }\n }\n if( elementIndexesArr.length > 0 ) {\n let elementIndexMax = Math.max( ...elementIndexesArr );\n index = elementIndexMax + 1;\n } else { \n index = 1;\n }\n\n if( copy ) {\n // change all data-elements which save parameters for different controls\n let wptbNodeattributes = [...node.attributes];\n for( let i = 0; i < wptbNodeattributes.length; i++ ) {\n if( wptbNodeattributes[i] && typeof wptbNodeattributes[i] === 'object' && wptbNodeattributes[i].nodeName ) {\n let regularText = new RegExp( 'data-wptb-el-' + element.kind + '-(\\\\d+)-(.+)', \"i\" );\n let attr = wptbNodeattributes[i].nodeName.match( regularText );\n if( attr && Array.isArray( attr ) ) {\n let newDataAttributeName = wptbNodeattributes[i].nodeName.replace( element.kind + '-' + attr[1], element.kind + '-' + index );\n let newDataAttributeValue = wptbNodeattributes[i].nodeValue;\n node.removeAttribute( wptbNodeattributes[i].nodeName );\n node.setAttribute( newDataAttributeName, newDataAttributeValue );\n }\n }\n }\n }\n } else if ( kindIndexProt && ! copy ) {\n let kindIndexProtArr = kindIndexProt.split('-');\n index = kindIndexProtArr[kindIndexProtArr.length - 1];\n // start element javascript if element is new\n \n }\n\n let node_wptb_element_kind_num = node.className.match(/wptb-element-(.+)-(\\d+)/i);\n if ( node_wptb_element_kind_num ) {\n node.classList.remove( node_wptb_element_kind_num[0] );\n }\n if ( ! node.classList.contains( 'wptb-ph-element' ) ) {\n node.classList.add( 'wptb-ph-element' );\n if( ! node.classList.contains( 'wptb-element-' + element.kind + '-' + index ) ) {\n node.classList.add( 'wptb-element-' + element.kind + '-' + index );\n }\n } else {\n if( ! node.classList.contains( 'wptb-element-' + element.kind + '-' + index ) ) {\n node.classList.add( 'wptb-element-' + element.kind + '-' + index );\n }\n }\n new WPTB_ElementOptions( element, index, kindIndexProt );\n WPTB_Helper.elementStartScript( element.getDOMElement() );\n document.counter.increment(element.kind);\n }\n \n node.onmouseenter = function ( event ) {\n if( event.target.classList.contains( 'wptb-moving-mode' ) ) {\n return;\n }\n \n let wptbActionsField = new WPTB_ActionsField();\n \n wptbActionsField.addActionField( 1, node );\n \n wptbActionsField.setParameters( node );\n \n node.classList.remove( 'wptb-ondragenter' );\n };\n \n node.onmouseleave = function ( event ) {\n let wptbActionsField = new WPTB_ActionsField();\n \n wptbActionsField.leaveFromField( event, node );\n };\n};"]}
inc/admin/js/admin.min.js CHANGED
@@ -1 +1 @@
1
- var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},WPTB_ActionsField=function s(){var c=this;this.wptbActions,0!=document.getElementsByClassName("wptb-actions").length&&(this.wptbActions=document.getElementsByClassName("wptb-actions")[0]),this.addActionField=function(e,t){var a=document.getElementsByTagName("body")[0],n=document.getElementsByClassName("wptb-actions");if(0!=n.length){var l=n[0].activeElem;for(l&&l.classList.remove("wptb-directlyhovered");0!=n.length;)n[0].parentNode.removeChild(n[0])}if(1==e){var r=void 0,o=void 0;if(r=document.createElement("span"),o=document.createElement("span"),(n=document.createElement("div")).classList.add("wptb-actions"),r.classList.add("dashicons","dashicons-trash","wptb-delete-action"),o.classList.add("dashicons","dashicons-admin-page","wptb-duplicate-action"),n.appendChild(o),n.appendChild(r),a.appendChild(n),n.activeElem=t,n.type=1,r.onclick=function(e){var t=e.target.parentNode.activeElem,a=t.parentNode;if(t&&t.className.match(/wptb-element-(.+)-(\d+)/i)&&WPTB_Helper.elementControlsStateDelete(t),t&&a.removeChild(t),t&&"object"===(void 0===t?"undefined":_typeof(t))&&t.hasOwnProperty("kind")&&"text"==t.kind){var n=a.parentNode;if(n.classList.contains("wptb-table-head")){var l=WPTB_Helper.findAncestor(n,"wptb-preview-table");WPTB_Helper.dataTitleColumnSet(l)}}(new s).actionsRemove(),(new WPTB_TableStateSaveManager).tableStateSet()},o.onclick=function(e){var t,a=void 0,n=void 0,l=e.target.parentNode.activeElem,r=l.parentNode;if((t=l.className.match(/wptb-element-(.+)-(\d+)/i))&&Array.isArray(t)){n=t[1];var o={};o.kind=n,o.elemProt=l,o.tinyMceClear=!0,a=new WPTB_ElementObject(o),WPTB_Helper.elementControlsStateCopy(l,a.getDOMElement()),r.insertBefore(a.getDOMElement(),l.nextSibling)}else{a={};var i=l.cloneNode(!0);i.classList.remove("wptb-directlyhovered"),a.getDOMElement=function(){return i},applyGenericItemSettings(a),r.insertBefore(a.getDOMElement(),l.nextSibling),WPTB_Helper.wptbDocumentEventGenerate("wptb-inner-element:copy",l,a.getDOMElement())}WPTB_innerElementSet(a.getDOMElement()),new s(1,l).setParameters(l),(new WPTB_TableStateSaveManager).tableStateSet()},t.classList.contains("wptb-ph-element")){var i=void 0;(i=document.createElement("span")).classList.add("dashicons","dashicons-move","wptb-move-action"),i.draggable=!0,n.appendChild(i),i.ondragstart=function(e){var t,a=wp.template("wptb-element-icons-directories")({}),n=JSON.parse(a),l=void 0,r=e.target.parentNode.activeElem,o=void 0;if((t=r.className.match(/wptb-element-(.+)-(\d+)/i))&&Array.isArray(t)){o=t[1],r.classList.add("wptb-moving-mode"),n&&"object"===(void 0===n?"undefined":_typeof(n))&&n[o]&&(l=WPTB_Helper.getElementIcon(n[o])),e.dataTransfer.effectAllowed="move",e.dataTransfer.setDragImage(l,0,0),e.dataTransfer.setData("node","wptb-element-"+t[1]+"-"+t[2]),e.dataTransfer.setData("wptb-moving-mode","wptb-element-"+t[1]+"-"+t[2]),e.dataTransfer.setData("wptbElIndic-"+t[1],"wptbElIndic-"+t[1]);var i=e.target.parentNode.activeElem;if("text"==i.kind){var s=i.parentNode.parentNode;if(s.classList.contains("wptb-table-head")){var d=WPTB_Helper.findAncestor(s,"wptb-preview-table");WPTB_Helper.dataTitleColumnSet(d)}}}else c.style.display="none",console.log(c);c.actionsHide()},i.ondragend=function(e){WPTB_Helper.elementDragEndClear()}}n.style.display="block",c.wptbActions=n}},this.setParameters=function(t){if(!c.wptbActions){var e=document.getElementsByClassName("wptb-actions");0<e.length?c.wptbActions=e[0]:c.wptbActions=!1}if(c.wptbActions&&c.wptbActions.classList.contains("wptb-actions")){c.wptbActions.style.display="block";var a=t.getBoundingClientRect(),n=document.getElementsByClassName("wptb-container")[0],l=function(){var e=t.getBoundingClientRect();c.wptbActions.style.top=parseFloat(e.top)-15+"px"};n.removeEventListener("scroll",l,!1),c.wptbActions.style.top=parseFloat(a.top)-15+"px",c.wptbActions.style.left=parseFloat(a.right)-parseFloat(c.wptbActions.clientWidth)+1+"px",c.wptbActions.style.display="block",t.classList.add("wptb-directlyhovered"),n.addEventListener("scroll",l,!1)}},this.leaveFromField=function(e,t,a){if(!c.wptbActions){var n=document.getElementsByClassName("wptb-actions");0<n.length?c.wptbActions=n[0]:c.wptbActions=!1}if(c.wptbActions){if(e.relatedTarget&&(e.relatedTarget.classList.contains("wptb-actions")||e.relatedTarget.classList.contains("wptb-move-action")||e.relatedTarget.classList.contains("wptb-duplicate-action")||e.relatedTarget.classList.contains("wptb-delete-action")))return c.wptbActions||(c.wptbActions=document.getElementsByClassName("wptb-actions")[0]),void(c.wptbActions.onmouseleave=function(e){null!=e.relatedTarget&&(e.relatedTarget.classList.contains("wptb-ph-element")||WPTB_Helper.findAncestor(e.relatedTarget,"wptb-ph-element"))&&e.relatedTarget!=c.wptbActions.activeElem&&(WPTB_Helper.findAncestor(e.relatedTarget,"wptb-directlyhovered"),c.wptbActions.activeElem),(new s).leaveFromField(e,e.relatedTarget.parentNode.parentNode),e.target.activeElem.classList.remove("wptb-directlyhovered")});t.classList.remove("wptb-directlyhovered"),c.wptbActions.style.display="none",e.relatedTarget&&(e.relatedTarget.classList.contains("wptb-ph-element")||WPTB_Helper.findAncestor(e.relatedTarget,"wptb-ph-element"))&&(c.addActionField(1,e.relatedTarget.parentNode),c.setParameters(e.relatedTarget.parentNode))}},this.actionsRemove=function(){if(!c.wptbActions){var e=document.getElementsByClassName("wptb-actions");0<e.length&&(c.wptbActions=e[0])}c.wptbActions&&c.wptbActions.parentNode.removeChild(c.wptbActions)},this.actionsHide=function(){if(!c.wptbActions){var e=document.getElementsByClassName("wptb-actions");0<e.length&&(c.wptbActions=e[0])}c.wptbActions&&(c.wptbActions.style.opacity=0)}};document.addEventListener("DOMContentLoaded",function(){var e=WPTB_Helper.detectMode();if(e){var l=new XMLHttpRequest,t=ajaxurl+"?action=get_table&id="+e;l.open("GET",t,!0),l.setRequestHeader("Content-type","application/x-www-form-urlencoded"),l.onreadystatechange=function(e){if(4!=this.readyState||200!=this.status);else{var t=JSON.parse(l.responseText);if(document.getElementById("wptb-setup-name").value=t[0],t[1]){document.getElementsByClassName("wptb-table-generator")[0].style.display="none",document.getElementsByClassName("wptb-table-setup")[0].appendChild(WPTB_Parser(t[1]));var a=document.getElementsByTagName("body")[0];if(t[2]){var n=document.createElement("script");n.setAttribute("type","text/html"),n.setAttribute("class","wptb-element-datas"),n.innerHTML=t[2],a.appendChild(n)}WPTB_Table(),WPTB_LeftPanel(),WPTB_Settings(),(new WPTB_TableStateSaveManager).tableStateSet()}else document.getElementsByClassName("wptb-table-generator")[0].style.display="table"}},l.send(null)}else document.getElementsByClassName("wptb-table-generator")[0].style.display="table";document.counter=new ElementCounters,document.select=new MultipleSelect,WPTB_Initializer(),settings=WPTB_Settings()});var WPTB_Cell=function(e,t){if(!t){(t=document.createElement("td")).style.padding=jQuery("#wptb-table-padding-number").val()+"px";var a=jQuery("#wptb-table-inner-border-number").val();""!=a&&0!=parseInt(a)&&(t.style.border=a+"px solid "+jQuery("#wptb-table-border-color").val()),t.classList.add("wptb-droppable","wptb-cell")}t.draggable=!1,e&&(t.onclick=e),WPTB_innerElementSet(t);var o=t.getElementsByClassName("wptb-ph-element");if(0<o.length)for(var n=function(l){o[l].getDOMElement=function(){return o[l]},WPTB_innerElementSet(o[l]);var r=o[l].className.match(/wptb-element-((.+-)\d+)/i);r&&Array.isArray(r)&&function(){var e=r[1].split("-");o[l].kind=e[0],applyGenericItemSettings(o[l],r[1]);var a=o[l].getElementsByClassName("wptb-in-element");if(0<a.length)for(var t=function(e){var t={getDOMElement:function(){return a[e]}};applyGenericItemSettings(t)},n=0;n<a.length;n++)t(n)}()},l=0;l<o.length;l++)n(l);return this.getDOMElement=function(){return t},this.setCoords=function(e,t){var a=this.getDOMElement();a.dataset.yIndex=e,a.dataset.xIndex=t},this.getCoords=function(){var e,t=this.getDOMElement();return e.x=t.dataset.xIndex,e.y=t.dataset.yIndex,e},this.appendElement=function(e){getDOMElement().appendChild(e)},t.getCellDimensions=function(){var e=window.getComputedStyle(this,null),t=e.getPropertyValue("padding-left"),a=e.getPropertyValue("padding-right"),n=e.getPropertyValue("border-left-width"),l=e.getPropertyValue("border-right-width"),r=e.getPropertyValue("padding-top"),o=e.getPropertyValue("padding-bottom"),i=e.getPropertyValue("border-top-width"),s=e.getPropertyValue("border-bottom-width");return{width:parseFloat(this.offsetWidth,10)-parseFloat(t,10)-parseFloat(a,10)-parseFloat(n,10)-parseFloat(l,10),height:parseFloat(this.offsetHeight,10)-parseFloat(r,10)-parseFloat(o,10)-parseFloat(i,10)-parseFloat(s,10)}},this},WPTB_DropHandle=function(i,e){var s=void 0,d=void 0;if(0==document.getElementsByClassName("wptb-drop-handle").length){(s=document.createElement("div")).classList.add("wptb-drop-handle"),(d=document.createElement("div")).classList.add("wptb-drop-border-marker");var t=document.createElement("div"),a=document.createElement("div"),n=document.createElement("div"),l=document.createElement("div");t.classList.add("wptb-drop-border-marker-top"),a.classList.add("wptb-drop-border-marker-right"),n.classList.add("wptb-drop-border-marker-bottom"),l.classList.add("wptb-drop-border-marker-left"),d.appendChild(t),d.appendChild(a),d.appendChild(n),d.appendChild(l);var r=document.getElementsByTagName("body");0<r.length&&(r[0].appendChild(s),r[0].appendChild(d)),s.ondragenter=function(){},s.ondragover=function(e){e.preventDefault()},s.ondragleave=function(){},s.ondrop=function(e){e.preventDefault();var t=void 0;e.dataTransfer.getData("wptbElement")?t=(t=WPTB_Helper.newElementProxy(e.dataTransfer.getData("wptbElement"))).getDOMElement():((t=document.getElementsByClassName(e.dataTransfer.getData("node"))[0]).classList.remove("wptb-moving-mode"),t.classList.remove("wptb-moving-into-same-elem"),t.wptbMovingMode=1);var a=void 0;if("Drop Here"==s.dataset.text)"td"==(i=s.getDOMParentElement()).nodeName.toLowerCase()&&(a=s.getDOMParentElement()).appendChild(t);else{var n=s.getDOMParentElement();if(a=n.parentNode,"Above Element"==s.dataset.text)a.insertBefore(t,n);else if("Below Element"==s.dataset.text){var l=n.nextSibling;a.insertBefore(t,l)}}var r=a.parentNode;if(r.classList.contains("wptb-table-head")){var o=WPTB_Helper.findAncestor(r,"wptb-preview-table");WPTB_Helper.dataTitleColumnSet(o)}t.className.match(/wptb-element-(.+)-(\d+)/i)[1];(e.dataTransfer.getData("wptbElement"),s.style.display="none",d.style.display="none",WPTB_innerElementSet(t),t.classList.contains("wptb-image-container")&&1!=t.wptbMovingMode)||((new WPTB_TableStateSaveManager).tableStateSet(),t.wptbMovingMode)},document.querySelector(".wptb-container").onscroll=function(){s.style.display="none",d.style.display="none"}}else s=document.getElementsByClassName("wptb-drop-handle")[0],d=document.getElementsByClassName("wptb-drop-border-marker")[0];if(!i||"td"!=i.nodeName.toLowerCase()||0==i.getElementsByClassName("wptb-ph-element").length){var o=void 0;if("td"==i.localName?o=i.parentNode:"div"==i.localName&&i.classList.contains("wptb-ph-element")&&(o=i.parentNode.parentNode),o.classList.contains("wptb-table-head")){for(var c=e.dataTransfer.types,m=!1,p=0;p<c.length;p++){var b=c[p].match(/wptbelindic-([a-z]+)/i);if(b&&"text"!=b[1]){m=!0;break}}if(m)return}s.style.width=i.offsetWidth+"px";var u=i.offsetHeight,g=i.getBoundingClientRect(),w=parseFloat(g.left),v=void 0;if(s.style.left=w+"px",-1!=e.dataTransfer.types.indexOf("wptb-moving-mode")){var h=document.getElementsByClassName("wptb-moving-mode")[0];i==h?(s.classList.add("wptb-moving-into-same-elem"),d.classList.add("wptb-moving-into-same-elem")):(s.classList.remove("wptb-moving-into-same-elem"),d.classList.remove("wptb-moving-into-same-elem"))}if(s.getDOMParentElement=function(){return i},s.style.display="block",d.style.display="block","td"!=i.nodeName.toLowerCase()){var f=null==e.offsetY?e.layerY:e.offsetY;v=parseFloat(g.top)-parseFloat(11),s.dataset.text="Above Element",u/2<f&&(v=parseFloat(g.top)+u-1,s.dataset.text="Below Element")}else s.dataset.text="Drop Here",v=parseFloat(g.top)+u/2-5;s.style.top=v+"px",d.style.top=g.top+"px",d.style.left=g.left+"px",wptbDropBorderMarkerTop=d.querySelector(".wptb-drop-border-marker-top"),wptbDropBorderMarkerTop.style.width=parseFloat(i.offsetWidth)-parseFloat(1)+"px",wptbDropBorderMarkerRight=d.querySelector(".wptb-drop-border-marker-right"),wptbDropBorderMarkerRight.style.height=parseFloat(g.bottom)-parseFloat(g.top)-1+"px",wptbDropBorderMarkerRight.style.left=wptbDropBorderMarkerTop.style.width,wptbDropBorderMarkerBottom=d.querySelector(".wptb-drop-border-marker-bottom"),wptbDropBorderMarkerBottom.style.width=wptbDropBorderMarkerTop.style.width,wptbDropBorderMarkerBottom.style.top=wptbDropBorderMarkerRight.style.height,wptbDropBorderMarkerLeft=d.querySelector(".wptb-drop-border-marker-left"),wptbDropBorderMarkerLeft.style.height=wptbDropBorderMarkerRight.style.height}},ElementCounters=function(){var t=[];return t.text=0,t.image=0,t.list=0,t.button=0,this.increment=function(e){e in t&&t[e]++},this.nextIndex=function(e){if(e in t)return t[e]+1},this},WPTB_ElementObject=function(e){var t=void 0,a=void 0,n=void 0;if(e.elemProt){(t=e.elemProt.cloneNode(!0)).classList.remove("wptb-directlyhovered");var l=e.elemProt.className.match(/wptb-element-((.+-)\d+)/i);l&&Array.isArray(l)&&(a=l[1]),n=!0,e.tinyMceClear&&(t=WPTB_Helper.elementClearFromTinyMce(t))}else{a=void 0,n=!1,(t=document.createElement("div")).classList.add("wptb-"+e.kind+"-container","wptb-ph-element","wptb-item-javascript-indic");var r="wptb-"+e.kind+"-content",o=wp.template(r);e.node=t;var i=o(e);i=i.replace(/\r|\n|\t/g,"").trim(),t.innerHTML=i}var s=t.querySelectorAll(".wptb-in-element");if(0<s.length)for(var d=function(e){var t={getDOMElement:function(){return s[e]}};applyGenericItemSettings(t)},c=0;c<s.length;c++)d(c);return window.addEventListener("item:onmouseenter",function(e){},!1),this.kind=e.kind,this.getDOMElement=function(){return t},applyGenericItemSettings(this,a,n),this},WPTB_ElementOptions=function(g,e,t){g.getDOMElement().onclick=function(){for(var e=document.getElementById("element-options-group").childNodes,t=0;t<e.length;t++)e[t].style&&(e[t].style.display="none");var s=this.className.match(/wptb-element-((.+-)\d+)/i),a="wptb-"+g.kind+"-control-stack",n=wp.template(a)({container:"."+s[0]}),d=JSON.parse(n),c=document.createElement("div");c.classList.add("wptb-element-options","wptb-options-"+s[1]);for(var l=document.getElementById("element-options-group"),r=l.children,o=0;o<r.length;o++){var i=new RegExp("wptb-options-"+g.kind+"-(\\d+)","i");r[o].className.match(i)&&l.removeChild(r[o])}document.getElementsByClassName("wptb-elements-container")[0].style.display="none",document.getElementsByClassName("wptb-settings-section")[0].style.display="none",document.getElementById("element-options-group").style.display="block",document.getElementById("element-options-group").appendChild(c),c.style.display="block";var m=[],p=[];if(Object.keys(d).forEach(function(e){var t=d[e];t.controlKey=e;var a=wp.template("wptb-"+t.type+"-control");t.elemContainer=s[0],t.elementControlTargetUnicClass="wptb-el-"+s[1]+"-"+t.controlKey;var n=a(t);"appearDependOn"in t&&Array.isArray(t.appearDependOn)&&p.push([t.appearDependOn,t.elementControlTargetUnicClass]);var l=document.createElement("div");l.classList.add("wptb-element-option","wptb-settings-items"),t.customClassForContainer&&l.classList.add(t.customClassForContainer),t.containerAdditionalStyles&&l.setAttribute("style",t.containerAdditionalStyles),l.innerHTML=n,c.appendChild(l);var r=l.getElementsByTagName("wptb-template-script");if(0<r.length){var o=(r=r[0]).innerText;l.removeChild(r);var i=document.createElement("script");i.setAttribute("type","text/javascript"),i.innerHTML=o.replace(/\r|\n|\t/g,"").trim(),m.push(i)}0}),0<m.length)for(var b=0;b<m.length;b++)c.appendChild(m[b]);for(var u=0;u<p.length;u++)WPTB_Helper.appearDependOn(p[u][0],p[u][1]);WPTB_Helper.wptbDocumentEventGenerate("controlPanel:added:leftPanel")}},WPTB_Helper=(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},{hexToRgb:function(e){var t=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(e);return t?"rgb("+parseInt(t[1],16)+","+parseInt(t[2],16)+","+parseInt(t[3],16)+")":null},rgbToHex:function(e){return(e=e.match(/^rgba?[\s+]?\([\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?,[\s+]?(\d+)[\s+]?/i))&&4===e.length?"#"+("0"+parseInt(e[1],10).toString(16)).slice(-2)+("0"+parseInt(e[2],10).toString(16)).slice(-2)+("0"+parseInt(e[3],10).toString(16)).slice(-2):""},getElementIcon:function(e){location.protocol,location.hostname;var t=document.createElement("img");return t.src=e,t},elementDragEndClear:function(){var e=document.getElementsByClassName("wptb-moving-mode");if(0<e.length)for(var t=0;t<e.length;t++)e[t].classList.remove("wptb-moving-mode");var a=document.getElementsByClassName("wptb-drop-handle");if(0<a.length)for(var n=0;n<a.length;n++)a[n].style.display="none";var l=document.getElementsByClassName("wptb-drop-border-marker");if(0<l.length)for(var r=0;r<l.length;r++)l[r].style.display="none"},linkHttpCheckChange:function(e){if(e){if(-1!=e.indexOf("http://")||-1!=e.indexOf("https://"))return e;var t=e.split("/"),a=void 0;return Array.isArray(t)&&0<t.length&&(a=t[t.length-1]),document.location.protocol+"//"+a}return""},dataTitleColumnSet:function(e){for(var t=e.rows,a=t[0],n=getComputedStyle(a),l=a.children,r={},o=0;o<l.length;o++){for(var i=l[o].children,s=0;s<i.length;s++){var d=i[s];if(d.classList.contains("wptb-ph-element"))if("text"==d.className.match(/wptb-element-(.+)-(\d+)/i)[1]){var c=d.querySelector("p"),m=c.textContent,p=c.style.textAlign;r[l[o].dataset.xIndex]=[m,d.style.fontSize,d.style.color,n.backgroundColor,p];break}}r[l[o].dataset.xIndex]||(r[l[o].dataset.xIndex]=["","","",n.backgroundColor,""])}for(var b=1;b<t.length;b++)for(var u=t[b].children,g=0;g<u.length;g++)r[u[g].dataset.xIndex]?(u[g].dataset.wptbTitleColumn=r[u[g].dataset.xIndex][0],u[g].dataset.wptbTitleColumnFontSize=r[u[g].dataset.xIndex][1],u[g].dataset.wptbTitleColumnColor=r[u[g].dataset.xIndex][2],u[g].dataset.wptbTitleBackgroundColor=r[u[g].dataset.xIndex][3],u[g].dataset.wptbTitleAlign=r[u[g].dataset.xIndex][4]):(u[g].dataset.wptbTitleColumn="",u[g].dataset.wptbTitleColumnFontSize="",u[g].dataset.wptbTitleColumnColor="",u[g].dataset.wptbTitleBackgroundColor="",u[g].dataset.wptbTitleAlign="")},findAncestor:function(e,t){for(;(e=e.parentElement)&&!e.classList.contains(t););return e},getSelectionText:function(){return window.getSelection?window.getSelection().toString():document.selection.createRange().text},settingsPanelClear:function(){document.getElementById("wptb-adaptive-table-checkbox").checked=!1,document.getElementById("wptb-top-row-as-header").checked=!1,document.getElementById("wptb-table-border-slider").value=0,document.getElementById("wptb-table-border-number").value=0,document.getElementById("wptb-inner-border-check").checked=!1,document.getElementById("wptb-apply-inner-border").classList.remove("visible"),document.getElementById("wptb-table-inner-border-slider").value=1,document.getElementById("wptb-table-inner-border-number").value=1,WPTB_Helper.wpColorPickerClear("wptb-table-border-color",!0),WPTB_Helper.wpColorPickerClear("wptb-table-header-bg",!0),WPTB_Helper.wpColorPickerClear("wptb-even-row-bg",!0),WPTB_Helper.wpColorPickerClear("wptb-odd-row-bg",!0),document.getElementById("wptb-table-cell-slider").value=15,document.getElementById("wptb-table-cell-number").value=15},elementOptionsPanelClear:function(){var e=document.getElementById("element-options-group");e&&(e.innerHTML="")},wpColorPickerCheckChangeForTableStateSaving:function(e){if("external"==e.originalEvent.type)(new WPTB_TableStateSaveManager).tableStateSet();else if(WPTB_Helper.findAncestor(e.target,"wp-picker-container")&&("square"==e.originalEvent.type||"strip"==e.originalEvent.type)){var t=document.getElementsByTagName("body")[0];t.removeEventListener("mouseup",WPTB_Helper.irisStripMouseUpStateSaveManager,!1),t.addEventListener("mouseup",WPTB_Helper.irisStripMouseUpStateSaveManager,!1)}},irisStripMouseUpStateSaveManager:function(){(new WPTB_TableStateSaveManager).tableStateSet(),document.getElementsByTagName("body")[0].removeEventListener("mouseup",WPTB_Helper.irisStripMouseUpStateSaveManager,!1)},wpColorPickerClear:function(e,t){var a=void 0;t?(a=[document.getElementById(e)]).length=1:a=document.getElementsByClassName(e);for(var n=0;n<a.length;n++){var l=WPTB_Helper.findAncestor(a[n],"wp-picker-container");if(l){var r=l.parentNode;r.removeChild(l);var o=document.createElement("input");t?o.setAttribute("id",e):o.classList.add("wptb-element-property",e),o.value="",r.appendChild(o)}}},detectMode:function(){var e=window.location.href,t=new RegExp("[?&]table(=([^&#]*)|&|#|$)").exec(e);return!!t&&(t[2]?decodeURIComponent(t[2].replace(/\+/g," ")):"")},getColumnWidth:function(e,t){for(var a=t.dataset.xIndex,n=e.querySelectorAll('[data-x-index="'+a+'"]'),l=t.getCellDimensions().width,r=0;r<n.length;r++)l>n[r].getCellDimensions().width&&(l=n[r].getCellDimensions().width);return l},getRowHeight:function(e,t){for(var a=t.dataset.yIndex,n=e.querySelectorAll('[data-y-index="'+a+'"]'),l=t.getCellDimensions().height,r=0;r<n.length;r++)l>n[r].getCellDimensions().height&&(l=n[r].getCellDimensions().height);return l},newElementProxy:function(e){if(e)return new WPTB_ElementObject({kind:e})},wpColorPickerChange:function(e,t){var a=void 0;a=t?t.color.toString():"";var n,l,r,o=WPTB_Helper.findAncestor(e.target,"wp-picker-input-wrap").getElementsByClassName("wptb-color-picker")[0];l=(n=o.dataset.element.match(/wptb-options-(.+)-(\d+)/i))[1],r=n[2];var i=document.getElementsByClassName("wptb-element-"+l+"-"+r)[0];if("button"==l)"button-text-color"==o.dataset.type?i.getElementsByClassName("wptb-button")[0].style.color=a:i.getElementsByClassName("wptb-button")[0].style.backgroundColor=a;else if("list"==l){var s=i.querySelectorAll("p");if(0<s.length)for(var d=0;d<s.length;d++)s[d].style.color=a}else if("star_rating"==l){if("star-color"==o.dataset.type)for(var c=i.querySelectorAll("li"),m=0;m<c.length;m++)for(var p=c[m].getElementsByTagName("span"),b=0;b<p.length;b++)p[b].style.fill=a;else if("numeral-rating-color"==o.dataset.type){i.querySelector(".wptb-number-rating").style.color=a}}else i.style.color=a},numberImputSize:function(e,t,a){e.onkeydown=function(){var e=this.value;0==(e=String(e))[0]?this.value="":(e=e.substring(0,t),this.value=e)},e.onkeyup=function(){var e=this.value;parseInt(e,10)>parseInt(a,10)&&(this.value=a),(new WPTB_TableStateSaveManager).tableStateSet()}},ucfirst:function(e){return e.charAt(0).toUpperCase()+e.slice(1)},wptbDocumentEventGenerate:function(e,t,a){if(e&&t){a||(a=!0);var n=new CustomEvent(e,{detail:a,bubbles:!0});t.dispatchEvent(n)}},elementStartScript:function(e){var t=e.className.match(/wptb-element-(.+)-(\d+)/i);if(t&&Array.isArray(t)){var a=t[1];a&&a in WPTB_ElementsScriptsLauncher&&WPTB_ElementsScriptsLauncher[a](e)}},deleteEventHandlers:function(e){if(e){jQuery(e).off();var t=e.children;if(t)for(var a=0;a<t.length;a++)WPTB_Helper.deleteEventHandlers(t[a])}},replaceAll:function(e,t,a){return e.split(t).join(a)},elementClearFromTinyMce:function(e){var t=e.querySelectorAll(".mce-content-body");if(0<t.length)for(var a=0;a<t.length;a++)t[a].classList.remove("mce-content-body");var n=e.querySelectorAll("[data-mce-style]");if(0<n.length)for(var l=0;l<n.length;l++)n[l].removeAttribute("data-mce-style");var r=e.querySelectorAll(".mce-edit-focus");if(0<r.length)for(var o=0;o<r.length;o++)r[o].classList.remove("mce-edit-focus");var i=e.querySelectorAll("[contenteditable]");if(0<i.length)for(var s=0;s<i.length;s++)i[s].removeAttribute("contenteditable");var d=e.querySelectorAll("[spellcheck]");if(0<d.length)for(var c=0;c<d.length;c++)d[c].removeAttribute("spellcheck");var m=e.querySelectorAll("[id^=mce_]");if(0<m.length)for(var p=0;p<m.length;p++)m[p].removeAttribute("id");return e},elementOptionContainerCustomClassSet:function(e,t){if(e&&t){var a=WPTB_Helper.findAncestor(e,"wptb-element-option");a&&a.classList.add(t)}},elementOptionContainerAdditionalStyles:function(e,t){if(e&&t){var a=WPTB_Helper.findAncestor(e,"wptb-element-option"),n=t.split(";");if(a&&n){var l=function(e,t){e&&(containerStyleStrArr=e.split(":"),containerStyleStrArr&&Array.isArray(containerStyleStrArr)&&(t.style[containerStyleStrArr[0]]=containerStyleStrArr[1]))};if(n&&Array.isArray(n))for(var r=0;r<n.length;r++)console.log(n),n[r]&&l(n[r],a);else l(n,a)}}},controlsInclude:function(s,d){s&&"object"===(void 0===s?"undefined":_typeof(s))&&"function"==typeof d&&s.addEventListener("click",function(){var l=s.className.match(/wptb-element-(.+)-(\d+)/i),o=void 0;if(l&&Array.isArray(l)&&(o=l[1]),!s.hasOwnProperty("сontrolsConnectIndic")||!0!==s.сontrolsConnectIndic&&o){var i=document.getElementsByClassName("wptb-element-datas");0<i.length&&function(){var e=(i=i[0]).innerHTML,r=[];if(e&&(e=JSON.parse(e))&&"object"===(void 0===e?"undefined":_typeof(e))&&"tmpl-wptb-element-datas-"+l[1]+"-"+l[2]in e){var t=e["tmpl-wptb-element-datas-"+l[1]+"-"+l[2]];t&&"object"===(void 0===t?"undefined":_typeof(t))&&Object.keys(t).forEach(function(e){var t=new RegExp("data-wptb-el-"+o+"-(\\d+)-(.+)","i"),a=e.match(t);if(a&&Array.isArray(a)){var n=e.replace("data-","");r.push([n,a[2]])}})}for(var a=function(l){s.addEventListener("wptb-control:"+r[l][0],function(){var e={},t=r[l][1],a=document.getElementsByClassName(r[l][0]);if(0<a.length&&t){var n=WPTB_Helper.targetControlValueGet(a);e[t]=n}d(e,s)},!1),s.сontrolsConnectIndic=!0},n=0;n<r.length;n++)a(n)}()}},!1)},oneControlInclude:function(n,l,e){if(!n||"object"!==(void 0===n?"undefined":_typeof(n))||"function"!=typeof l||"string"!=typeof e)return!1;var t=n.className.match(/wptb-element-((.+-)\d+)/i);if(t&&Array.isArray(t)){var a="wptb-"+t[1].split("-")[0]+"-control-stack",r=wp.template(a)({container:"."+t[0]}),o=JSON.parse(r);if(o&&"object"===(void 0===o?"undefined":_typeof(o))&&o.hasOwnProperty(e)){var i="wptb-el-"+t[1]+"-"+e;n.addEventListener("wptb-control:"+i,function(e){var t=document.getElementsByClassName(i);if(0<t.length){var a=WPTB_Helper.targetControlValueGet(t);l(a,n)}},!1)}}},innerElementCopyIncludeHandler:function(a,n){a&&"object"===(void 0===a?"undefined":_typeof(a))&&"function"==typeof n&&a.addEventListener("wptb-inner-element:copy",function(e){var t=e.detail;t&&(WPTB_Helper.elementClearFromTinyMce(t),n(t,a))},!1)},appearDependOn:function(r,e){if(Array.isArray(r)){var o=r[0],t=e.match(/wptb-el-((.+-)\d+)-(.+)/i);if(t&&Array.isArray(t)){var a=t[3],n=e.replace(a,o),l=document.getElementsByClassName(n);if(0<l.length){l=l[0];var i=document.getElementsByClassName(e);if(0<i.length){i=i[0];var s=WPTB_Helper.findAncestor(i,"wptb-element-option");if(s){var d=function(e){var t=document.getElementsByClassName("wptb-element-datas");if(0<t.length){var a=(t=t[0]).innerHTML;if(a&&(a=JSON.parse(a))&&"object"===(void 0===a?"undefined":_typeof(a))&&"tmpl-wptb-element-datas-"+e in a){var n=a["tmpl-wptb-element-datas-"+e];if(n&&"object"===(void 0===n?"undefined":_typeof(n))&&"data-wptb-el-"+e+"-"+o in n){var l=n["data-wptb-el-"+e+"-"+o];l&&(r[1]&&Array.isArray(r[1])&&-1!==r[1].indexOf(l)?s.style.display="block":r[2]&&Array.isArray(r[2])&&-1!==r[2].indexOf(l)&&(s.style.display="none"))}}}};d(t[1]),l.addEventListener("change",function(){d(t[1])},!1)}}}}}},controlsStateManager:function(e,t){var a=document.getElementsByClassName(e);if(0<a.length){var n=e.match(/wptb-el-((.+-)\d+)-(.+)/i);if(n&&Array.isArray(n))if(document.querySelector(".wptb-element-"+n[1])){var l=void 0,r={},o=void 0;if(0==(l=document.getElementsByClassName("wptb-element-datas")).length||""==l[0].innerHTML){var i=WPTB_Helper.targetControlValueGet(a);r["data-"+e]=i,(o={})["tmpl-wptb-element-datas-"+n[1]]=r,o=JSON.stringify(o),0==l.length?((l=document.createElement("script")).setAttribute("type","text/html"),l.setAttribute("class","wptb-element-datas")):l=l[0],l.innerHTML=o,document.getElementsByTagName("body")[0].appendChild(l)}else if((o=(l=l[0]).innerHTML)&&(o=JSON.parse(o))&&"object"===(void 0===o?"undefined":_typeof(o)))if(t){var s=WPTB_Helper.targetControlValueGet(a);"tmpl-wptb-element-datas-"+n[1]in o&&"object"===_typeof(o["tmpl-wptb-element-datas-"+n[1]])||(o["tmpl-wptb-element-datas-"+n[1]]={}),o["tmpl-wptb-element-datas-"+n[1]]["data-"+e]=s,l.innerHTML=JSON.stringify(o)}else if("tmpl-wptb-element-datas-"+n[1]in o&&"object"===_typeof(o["tmpl-wptb-element-datas-"+n[1]])&&"data-"+e in o["tmpl-wptb-element-datas-"+n[1]]){if("tmpl-wptb-element-datas-"+n[1]in o&&"object"===_typeof(o["tmpl-wptb-element-datas-"+n[1]])&&"data-"+e in o["tmpl-wptb-element-datas-"+n[1]])for(var d=0;d<a.length;d++)if("checkbox"==a[d].type){var c=void 0;"checked"==(c=a[d].name?o["tmpl-wptb-element-datas-"+n[1]]["data-"+e][a[d].name]:o["tmpl-wptb-element-datas-"+n[1]]["data-"+e])?a[d].checked=!0:"unchecked"==c&&(a[d].checked=!1)}else a[d].value=o["tmpl-wptb-element-datas-"+n[1]]["data-"+e]}else{var m=WPTB_Helper.targetControlValueGet(a);"tmpl-wptb-element-datas-"+n[1]in o&&"object"===_typeof(o["tmpl-wptb-element-datas-"+n[1]])||(o["tmpl-wptb-element-datas-"+n[1]]={}),o["tmpl-wptb-element-datas-"+n[1]]["data-"+e]=m,l.innerHTML=JSON.stringify(o)}}}},targetControlValueGet:function(e){for(var t=void 0,a=0;a<e.length;a++)"checkbox"==e[a].type&&e[a].name?(t||(t={}),1==e[a].checked?t[e[a].name]="checked":t[e[a].name]="unchecked"):t="checkbox"==e[a].type?1==e[a].checked?"checked":"unchecked":e[a].value;return t},elementControlsStateCopy:function(e,t){if(e&&t){var a=e.className.match(/wptb-element-((.+-)\d+)/i),n=t.className.match(/wptb-element-((.+-)\d+)/i);if(a&&Array.isArray(a)&&n&&Array.isArray(n)){var l=a[1],r=n[1],o=document.getElementsByClassName("wptb-element-datas");if(0<o.length){var i=(o=o[0]).innerHTML;if(i&&(i=JSON.parse(i))&&"object"===(void 0===i?"undefined":_typeof(i))){var s=i["tmpl-wptb-element-datas-"+l];if(s&&"object"===(void 0===s?"undefined":_typeof(s))){var d={};Object.keys(s).forEach(function(e){var t=s[e],a=e.replace(l,r);d[a]=t}),0<Object.keys(d).length&&(i["tmpl-wptb-element-datas-"+r]=d,i=JSON.stringify(i),o.innerHTML=i)}}}}}},elementControlsStateDelete:function(e){var t=e.className.match(/wptb-element-(.+)-(\d+)/i),a=document.getElementsByTagName("body")[0],n=a.getElementsByClassName("wptb-element-datas");if(t&&Array.isArray(t)&&0<n.length){var l=(n=n[0]).innerHTML;l&&(l=JSON.parse(l))&&"object"===(void 0===l?"undefined":_typeof(l))&&"tmpl-wptb-element-datas-"+t[1]+"-"+t[2]in l&&(delete l["tmpl-wptb-element-datas-"+t[1]+"-"+t[2]],0==Object.keys(l).length?a.removeChild(n):(l=JSON.stringify(l),n.innerHTML=l))}}}),WPTB_Initializer=function(){var e=document.body;columnsDecrementButton=e.getElementsByClassName("wptb-input-number-decrement")[0],columnsIncrementButton=e.getElementsByClassName("wptb-input-number-increment")[0],rowsDecrementButton=e.getElementsByClassName("wptb-input-number-decrement")[1],rowsIncrementButton=e.getElementsByClassName("wptb-input-number-increment")[1],columnsInput=document.getElementById("wptb-columns-number"),rowsInput=document.getElementById("wptb-rows-number"),columnsDecrementButton.onclick=function(){1<columnsInput.value&&columnsInput.value--},columnsIncrementButton.onclick=function(){columnsInput.value<30&&columnsInput.value++},rowsDecrementButton.onclick=function(){1<rowsInput.value&&rowsInput.value--},rowsIncrementButton.onclick=function(){rowsInput.value<30&&rowsInput.value++},document.getElementById("wptb-generate-table").onclick=function(){var e=document.getElementById("wptb-columns-number").value,t=document.getElementById("wptb-rows-number").value;WPTB_Table(e,t),(new WPTB_TableStateSaveManager).tableStateSet()}},WPTB_LeftPanel=function(){var e,t,a,n,r=document.getElementsByClassName("wptb-preview-table")[0],l=document.getElementsByClassName("wptb-element");function o(e,t){if(!(3<t)&&r){var a=r.getElementsByTagName("tr");if(a.length>t){var n=a[t].style.backgroundColor,l=document.getElementById(e);l&&n&&(l.value=WPTB_Helper.rgbToHex(n))}}}function i(e){for(var t=r.getElementsByTagName("td"),a=0;a<t.length;a++)t[a].style.borderWidth=document.querySelector("#wptb-table-inner-border-number").value+"px",t[a].style.borderStyle="solid"}function s(e){for(var t=r.getElementsByTagName("td"),a=0;a<t.length;a++)t[a].style.padding=e+"px"}function d(e){r.style.borderWidth=e+"px",r.style.borderStyle="solid"}o("wptb-even-row-bg",1),jQuery("#wptb-even-row-bg").wpColorPicker({change:function(e,t){for(var a=r.getElementsByTagName("tr"),n=1;n<a.length;n+=2)a[n].style.backgroundColor=t.color.toString();WPTB_Helper.wpColorPickerCheckChangeForTableStateSaving(e)},clear:function(){for(var e=r.getElementsByTagName("tr"),t=1;t<e.length;t+=2){e[t].style.backgroundColor="";for(var a=e[t].getElementsByTagName("td"),n=0;n<a.length;n++)a[n].style.backgroundColor=""}(new WPTB_TableStateSaveManager).tableStateSet()}}),o("wptb-odd-row-bg",2),jQuery("#wptb-odd-row-bg").wpColorPicker({change:function(e,t){for(var a=r.getElementsByTagName("tr"),n=2;n<a.length;n+=2)a[n].style.backgroundColor=t.color.toString();WPTB_Helper.wpColorPickerCheckChangeForTableStateSaving(e)},clear:function(){for(var e=r.getElementsByTagName("tr"),t=2;t<e.length;t+=2){e[t].style.backgroundColor="";for(var a=e[t].getElementsByTagName("td"),n=0;n<a.length;n++)a[n].style.backgroundColor=""}(new WPTB_TableStateSaveManager).tableStateSet()}}),o("wptb-table-header-bg",0),jQuery("#wptb-table-header-bg").wpColorPicker({change:function(e,t){r.getElementsByTagName("tr")[0].style.backgroundColor=t.color.toString(),(new WPTB_TableStateSaveManager).tableStateSet()},clear:function(){var e=r.getElementsByTagName("tr")[0];e.style.backgroundColor="";for(var t=e.getElementsByTagName("td"),a=0;a<t.length;a++)t[a].style.backgroundColor="";WPTB_Helper.wpColorPickerCheckChangeForTableStateSaving(event)}}),e=r,t=document.getElementById("wptb-adaptive-table-checkbox"),e&&e.dataset.wptbAdaptiveTable&&"1"==e.dataset.wptbAdaptiveTable?t.checked=!0:t.checked=!1,a=r,n=document.getElementById("wptb-top-row-as-header"),a&&a.classList.contains("wptb-table-preview-head")?n.checked=!0:n.checked=!1,function(){var e=document.getElementsByClassName("wptb-preview-table");if(0<e.length){var t=e[0].style.borderColor;if(t){var a=document.getElementById("wptb-table-border-color");a&&(a.value=WPTB_Helper.rgbToHex(t))}var n=e[0].style.borderWidth;if(n){var l=document.getElementById("wptb-table-border-slider"),r=document.getElementById("wptb-table-border-number");l&&(l.value=parseInt(n)),r&&(r.value=parseInt(n))}var o=e[0].querySelector("td").style.borderWidth;if(o){var i=document.getElementById("wptb-inner-border-check"),s=document.getElementById("wptb-apply-inner-border");if(o&&0<parseInt(o)){if(i&&(i.checked=!0,s)){s.classList.add("visible");var d=document.getElementById("wptb-table-inner-border-slider"),c=document.getElementById("wptb-table-inner-border-number");d.value=parseInt(o),c.value=parseInt(o)}}else i.checked=!1}(n&&0<parseInt(n)||o&&0<parseInt(o))&&(document.getElementById("wptb-table-border-color-set-area").style.display="")}}(),jQuery("#wptb-table-border-color").wpColorPicker({change:function(e,t){var a=r.getElementsByTagName("td");r.style.border=document.querySelector("#wptb-table-border-number").value+"px solid "+t.color.toString();for(var n=0;n<a.length;n++){var l=document.querySelector("#wptb-table-inner-border-number").value;document.getElementById("wptb-inner-border-check").checked&&(a[n].style.border=(0!=l?l:1)+"px solid "+t.color.toString())}WPTB_Helper.wpColorPickerCheckChangeForTableStateSaving(e)},clear:function(){var e=r.getElementsByTagName("td");r.style.borderColor="";for(var t=0;t<e.length;t++)e[t].style.borderColor="";(new WPTB_TableStateSaveManager).tableStateSet()}}),function(){var e=document.getElementsByClassName("wptb-preview-table");if(0<e.length){var t=e[0].querySelector("td");if(t){var a=t.style.padding;if(a){var n=document.getElementById("wptb-table-cell-slider"),l=document.getElementById("wptb-table-cell-number");n&&(n.value=parseInt(a)),l&&(l.value=parseInt(a))}}}}();var c=document.getElementById("wptb-table-border-number");WPTB_Helper.numberImputSize(c,1,50);var m=document.getElementById("wptb-table-inner-border-number");WPTB_Helper.numberImputSize(m,1,50);var p=document.getElementById("wptb-table-cell-number");WPTB_Helper.numberImputSize(p,1,50);var b=document.getElementById("wptb-table-column-width-number");WPTB_Helper.numberImputSize(b,2,500);var u=document.getElementById("wptb-table-row-height-number");WPTB_Helper.numberImputSize(u,2,200),document.getElementById("wptb-table-cell-slider").oninput=function(){document.getElementById("wptb-table-cell-number").value=this.value,s(this.value),r.tdDefaultWidth()},document.getElementById("wptb-table-cell-slider").onchange=function(){(new WPTB_TableStateSaveManager).tableStateSet()},document.getElementById("wptb-table-cell-number").onchange=function(){document.getElementById("wptb-table-cell-slider").value=this.value,s(this.value),r.tdDefaultWidth(),(new WPTB_TableStateSaveManager).tableStateSet()},document.getElementById("wptb-table-border-slider").oninput=function(){document.getElementById("wptb-table-border-number").value=this.value,d(this.value),r.tdDefaultWidth();var e=document.getElementById("wptb-inner-border-check").checked,t=document.getElementById("wptb-table-border-color-set-area");0==this.value&&0==e?t.style.display="none":t.style.display=""},document.getElementById("wptb-table-border-slider").onchange=function(){(new WPTB_TableStateSaveManager).tableStateSet()},document.getElementById("wptb-table-border-number").onchange=function(){document.getElementById("wptb-table-border-slider").value=this.value,d(this.value),r.tdDefaultWidth(),(new WPTB_TableStateSaveManager).tableStateSet()},document.getElementById("wptb-table-inner-border-slider").oninput=function(){document.getElementById("wptb-table-inner-border-number").value=this.value,i(this.value),r.tdDefaultWidth()},document.getElementById("wptb-table-inner-border-slider").onchange=function(){(new WPTB_TableStateSaveManager).tableStateSet()},document.getElementById("wptb-table-inner-border-number").onchange=function(){document.getElementById("wptb-table-inner-border-slider").value=this.value,i(this.value),r.tdDefaultWidth(),(new WPTB_TableStateSaveManager).tableStateSet()},document.getElementById("wptb-inner-border-check").onchange=function(){if(r){var e=this.checked?"checked":"unchecked";!function(e){var t=null!=document.querySelector("#wptb-table-border-color").value?document.querySelector("#wptb-table-border-color").value:"rgb(0,0,0)";0!=document.querySelector("#wptb-table-inner-border-slider").value&&0!=document.querySelector("#wptb-table-inner-border-number").value||(document.querySelector("#wptb-table-inner-border-slider").value=1,document.querySelector("#wptb-table-inner-border-number").value=1);var a=document.querySelector("#wptb-table-inner-border-slider").value+"px",n=document.getElementsByClassName("wptb-preview-table");if(0<n.length)if("checked"==e){document.getElementById("wptb-apply-inner-border").style.marginBottom="0px";for(var l=n[0].getElementsByTagName("td"),r=0;r<l.length;r++)l[r].style.border=a+" solid "+t;document.getElementById("wptb-apply-inner-border").classList.add("visible")}else for(document.getElementById("wptb-apply-inner-border").classList.remove("visible"),l=n[0].getElementsByTagName("td"),r=0;r<l.length;r++)l[r].style.border="0px solid "+t,l[r].style.border=null}(e);var t=document.getElementById("wptb-table-border-slider").value,a=document.getElementById("wptb-table-border-color-set-area");a.style.display="unchecked"==e&&0==t?"none":"",(new WPTB_TableStateSaveManager).tableStateSet()}},document.getElementById("wptb-table-column-width-slider").oninput=function(){document.getElementById("wptb-table-column-width-number").value=this.value,r.addColumnWidth(this.value)},document.getElementById("wptb-table-column-width-slider").onchange=function(){(new WPTB_TableStateSaveManager).tableStateSet()},document.getElementById("wptb-table-column-width-number").onchange=function(){document.getElementById("wptb-table-column-width-slider").value=this.value,r.addColumnWidth(this.value),(new WPTB_TableStateSaveManager).tableStateSet()},document.getElementById("wptb-table-column-width-auto-fixed").onchange=function(){if(this.checked){var e=r.querySelector(".wptb-highlighted"),t=WPTB_Helper.getColumnWidth(r,e);r.addColumnWidth(t)}else{r.addColumnWidth(!1,!0);var a=r.querySelector(".wptb-highlighted"),n=WPTB_Helper.getColumnWidth(r,a);document.getElementById("wptb-table-column-width-number").value=n,document.getElementById("wptb-table-column-width-slider").value=n}(new WPTB_TableStateSaveManager).tableStateSet()},document.getElementById("wptb-table-row-height-slider").oninput=function(){document.getElementById("wptb-table-row-height-number").value=this.value,r.addRowHeight(this.value)},document.getElementById("wptb-table-row-height-slider").onchange=function(){(new WPTB_TableStateSaveManager).tableStateSet()},document.getElementById("wptb-table-row-height-number").onchange=function(){document.getElementById("wptb-table-row-height-slider").value=this.value,r.addRowHeight(this.value),(new WPTB_TableStateSaveManager).tableStateSet()},document.getElementById("wptb-table-row-height-auto-fixed").onchange=function(){if(this.checked){var e=r.querySelector(".wptb-highlighted"),t=WPTB_Helper.getRowHeight(r,e);r.addRowHeight(t)}else{r.addRowHeight(!1,!0);var a=r.querySelector(".wptb-highlighted"),n=WPTB_Helper.getRowHeight(r,a);document.getElementById("wptb-table-row-height-number").value=n,document.getElementById("wptb-table-row-height-slider").value=n}(new WPTB_TableStateSaveManager).tableStateSet()},document.getElementById("wptb-adaptive-table-checkbox").onchange=function(){this.checked?r.dataset.wptbAdaptiveTable=1:r.dataset.wptbAdaptiveTable=0,(new WPTB_TableStateSaveManager).tableStateSet()},document.getElementById("wptb-top-row-as-header").onchange=function(){!function(e,t){if(t.checked)WPTB_Helper.dataTitleColumnSet(e),e.classList.add("wptb-table-preview-head"),e.rows[0].classList.add("wptb-table-head");else{var a=e.rows;e.classList.remove("wptb-table-preview-head"),a[0].classList.remove("wptb-table-head");for(var n=1;n<a.length;n++)for(var l=a[n].children,r=0;r<l.length;r++)l[r].removeAttribute("data-wptb-title-column"),l[r].removeAttribute("data-wptb-title-column-font-size"),l[r].removeAttribute("data-wptb-title-column-color"),l[r].removeAttribute("data-wptb-title-background-color"),l[r].removeAttribute("data-wptb-title-align")}}(r,this),(new WPTB_TableStateSaveManager).tableStateSet()};for(var g=0;g<l.length;g++)l[g].ondragstart=function(e){e.dataTransfer.setData("wptbElement",this.dataset.wptbElement),e.dataTransfer.setData("wptbElIndic-"+this.dataset.wptbElement,"wptbElIndic-"+this.dataset.wptbElement)};r&&(document.getElementById("wptb-activate-cell-management-mode").onclick=r.toggleTableEditMode,document.getElementById("wptb-table-edit-mode-close").onclick=r.toggleTableEditMode,document.getElementById("wptb-left-scroll-panel-curtain-close").onclick=r.toggleTableEditMode,document.getElementById("wptb-add-end-row").onclick=r.addRowToTheEnd,document.getElementById("wptb-add-start-row").onclick=r.addRowToTheStart,document.getElementById("wptb-add-row-before").onclick=r.addRowBefore,document.getElementById("wptb-add-row-after").onclick=r.addRowAfter,document.getElementById("wptb-add-end-column").onclick=r.addColumnEnd,document.getElementById("wptb-add-start-column").onclick=r.addColumnStart,document.getElementById("wptb-add-column-before").onclick=r.addColumnBefore,document.getElementById("wptb-add-column-after").onclick=r.addColumnAfter,document.getElementById("wptb-delete-column").onclick=r.deleteColumn,document.getElementById("wptb-delete-row").onclick=r.deleteRow,document.getElementById("wptb-merge-cells").onclick=r.mergeCells,document.getElementById("wptb-split-cell").onclick=r.splitCell),document.querySelector(".wptb-left-panel-extend").onclick=function(){var e=document.querySelector(".wptb-container");e&&(e.classList.contains("collapsed")?e.classList.remove("collapsed"):e.classList.add("collapsed"))},document.getElementsByClassName("wptb-builder-panel")[0].onclick=function(e){e.target.classList.contains("wptb-ph-element")||WPTB_Helper.findAncestor(e.target,"wptb-ph-element")||e.target.classList.contains("wptb-fixed-toolbar")||WPTB_Helper.findAncestor(e.target,"wptb-fixed-toolbar")||v()};var w=document.getElementsByClassName("wptb-header");function v(){document.getElementsByClassName("wptb-elements-container")[0].style.display="table",document.getElementsByClassName("wptb-settings-section")[0].style.display="block",document.getElementById("element-options-group").style.display="none";var e=document.getElementById("wpcd_fixed_toolbar");e.hasAttribute("data-toolbar-active-id")&&document.getElementById(e.getAttribute("data-toolbar-active-id")).classList.remove("toolbar-active")}0<w.length&&(w=w[0]),w.onclick=function(){v()},document.querySelector(".wptb-panel-left").addEventListener("click",function(e){e.target.classList.contains("wptb-exit-options")&&v()})},MultipleSelect=function(){var l=[],a=!1;return this.activateMultipleSelectMode=function(){l=[];for(var e=document.getElementsByClassName("wptb-preview-table")[0].getElementsByTagName("td"),t=0;t<e.length;t++)e[t].classList.remove("wptb-highlighted");a=!0},this.deactivateMultipleSelectMode=function(){a=!1},this.isActivated=function(){return a},this.pushSelectedCell=function(e){a&&(l.push(e),e.classList.add("wptb-highlighted"))},this.selectedCells=function(){return l},this.flushSelectedCells=function(){l=[]},this.getFirst=function(){for(var e,t=1e3,a=1e3,n=l.length-1;0<=n;n--)t>=l[n].dataset.xIndex&&a>=l[n].dataset.yIndex&&(e=l[n],t=l[n].dataset.xIndex,a=l[n].dataset.yIndex);return e},this.getLast=function(){for(var e,t=-1,a=-1,n=l.length-1;0<=n;n--)t<=l[n].dataset.xIndex&&a<=l[n].dataset.yIndex&&(e=l[n],t=l[n].dataset.xIndex,a=l[n].dataset.yIndex);return e},this.removeAllButFirst=function(){for(var e=this.getFirst(),t=1;t<l.length;t++)l[t].classList.add("wptb-fused-cell-"+e.dataset.xIndex+"-"+e.dataset.yIndex)},this};function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,a=Array(e.length);t<e.length;t++)a[t]=e[t];return a}return Array.from(e)}var WPTB_Parser=function(e){var t=document.createElement("div");t.innerHTML=e;for(var a=t.children[0],n=[].concat(_toConsumableArray(a.querySelectorAll(".wptb-column-title-mobile-container"))),l=0;l<n.length;l++){n[l].parentNode.removeChild(n[l])}for(var r=a.querySelectorAll("td"),o=0;o<r.length;o++)r[o].classList.add("wptb-droppable"),r[o].classList.remove("wptb-column-title-mobile-not-elements");return a};_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};Object.keys||(Object.keys=function(){"use strict";var l=Object.prototype.hasOwnProperty,r=!{toString:null}.propertyIsEnumerable("toString"),o=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],i=o.length;return function(e){if("object"!==(void 0===e?"undefined":_typeof(e))&&("function"!=typeof e||null===e))throw new TypeError("Object.keys called on non-object");var t,a,n=[];for(t in e)l.call(e,t)&&n.push(t);if(r)for(a=0;a<i;a++)l.call(e,o[a])&&n.push(o[a]);return n}}());var WPTB_Settings=function(){for(var e=document.getElementsByClassName("wptb-element"),t=0;t<e.length;t++)e[t].ondragstart=function(e){e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("wptbElement",e.target.dataset.wptbElement),e.dataTransfer.setData("wptbElIndic-"+e.target.dataset.wptbElement,"wptbElIndic-"+e.target.dataset.wptbElement)},e[t].ondragend=function(){WPTB_Helper.elementDragEndClear()};var a=new WPTB_TableStateSaveManager,n=document.getElementsByClassName("wptb-undo");0<n.length&&((n=n[0]).onclick=function(e){if(!this.classList.contains("wptb-undoredo-disabled")){a.tableStateGet(this.dataset.wptbUndoredo);var t=document.getElementsByClassName("wptb-undo-redo-container");0<t.length&&((t=t[0]).onmouseleave=function(e){e.target.onmouseleave="",WPTB_Table()})}});var l=document.getElementsByClassName("wptb-redo");0<l.length&&((l=l[0]).onclick=function(e){if(!this.classList.contains("wptb-undoredo-disabled")){a.tableStateGet(this.dataset.wptbUndoredo);var t=document.getElementsByClassName("wptb-undo-redo-container");0<t.length&&((t=t[0]).onmouseleave=function(e){e.target.onmouseleave="",WPTB_Table()})}});var r=document.getElementsByClassName("wptb-popup-window-modal")[0];document.getElementsByClassName("wptb-embed-btn")[0].onclick=function(){this.classList.contains("wptb-button-disable")||r.classList.add("wptb-popup-show")},window.onbeforeunload=function(e){return 0==document.getElementsByClassName("wptb-save-disabled").length||null},document.getElementsByClassName("wptb-popup-dark-area")[0].onclick=function(){r.classList.remove("wptb-popup-show")},document.getElementsByClassName("wptb-popup-window-close-icon")[0].onclick=function(){r.classList.remove("wptb-popup-show")},document.getElementsByClassName("wptb-preview-btn")[0].onclick=function(e){this.classList.contains("wptb-button-disable")&&e.preventDefault()},document.getElementsByClassName("wptb-save-btn")[0].onclick=function(r){if((r.target.dataset.wptbTableStateNumberSave||0!=window.wptbTableStateNumberShow)&&window.wptbTableStateNumberShow!=r.target.dataset.wptbTableStateNumberSave){var e=document.querySelector(".wptb-edit-bar");if(e&&e.classList.contains("visible"))document.getElementsByClassName("wptb-preview-table")[0].toggleTableEditMode();var o=new XMLHttpRequest,t=(wptb_admin_object?wptb_admin_object.ajaxurl:ajaxurl)+"?action=save_table",i=document.getElementById("wptb-setup-name").value.trim(),s=void 0,a=void 0,n=void 0;a=0<(a=document.getElementsByClassName("wptb-preview-table")).length?(a=WPTB_Stringifier(a[0])).outerHTML:"",n="";var l=document.getElementsByClassName("wptb-element-datas");if(0<l.length&&l[0].innerHTML&&(n=l[0].innerHTML),""===i||""===a){var d="";return""===i&&(d+="You must assign a name to the table before saving it.</br>"),""===a&&(d+="Table wasn't created"),(s=document.getElementById("wptb-messaging-area")).innerHTML='<div class="wptb-error wptb-message">Error: '+d+"</div>",s.classList.add("wptb-warning"),void setTimeout(function(){s.removeChild(s.firstChild)},4e3)}var c={title:i,content:a,elements_datas:n,security_code:wptb_admin_object.security_code};((rs=WPTB_Helper.detectMode())||(rs=document.wptbId))&&(c.id=rs),c=JSON.stringify(c),o.open("POST",t,!0),o.setRequestHeader("Content-type","application/json; charset=utf-8"),o.onreadystatechange=function(e){if(4==this.readyState&&200==this.status){var t=JSON.parse(o.responseText);if(s=document.getElementById("wptb-messaging-area"),"saved"==t[0]){document.wptbId=t[1],s.innerHTML='<div class="wptb-success wptb-message">Table "'+i+'" was successfully saved.</div>',document.getElementsByClassName("wptb-embed-btn")[0].classList.remove("wptb-button-disable"),document.getElementById("wptb-embed-shortcode").value="[wptb id="+t[1]+"]";var a=document.getElementsByClassName("wptb-preview-btn");if(0<a.length){(a=a[0]).classList.remove("wptb-button-disable");var n=a.dataset.previewHref;n=n.replace("empty",t[1]),a.setAttribute("href",n)}}else if("edited"==t[0]){s.innerHTML='<div class="wptb-success wptb-message">Table "'+i+'" was successfully updated.</div>',r.target.dataset.wptbTableStateNumberSave=window.wptbTableStateNumberShow;var l=document.getElementsByClassName("wptb-save-btn");0<l.length&&(l=l[0]).classList.add("wptb-save-disabled")}else s.innerHTML='<div class="wptb-error wptb-message">Safety problems</div>';s.classList.add("wptb-success"),setTimeout(function(){s.removeChild(s.firstChild)},4e3)}},o.send(c)}}},WPTB_Stringifier=function(e){if(e){var t=e.cloneNode(!0);t.classList.add("wptb-table-preview-static-indic"),t.dataset.tableColumns=e.columns,t.style.width=null,t.style.minWidth=null,t.style.maxWidth=null;var a=t.getElementsByTagName("td");if(0<a.length)for(var n=0;n<a.length;n++){e.querySelector("wptb-table-preview-head")&&a[n].removeAttribute("data-x-index"),a[n].removeAttribute("data-y-index"),a[n].removeAttribute("draggable"),a[n].classList.remove("wptb-droppable");var l=a[n].getElementsByClassName("wptb-ph-element");if(0<l.length)for(var r=0;r<l.length;r++){var o=l[r].querySelectorAll(".mce-content-body");if(0<o.length)for(var i=0;i<o.length;i++)o[i].classList.remove("mce-content-body");var s=l[r].querySelectorAll("[data-mce-style]");if(0<s.length)for(var d=0;d<s.length;d++)s[d].removeAttribute("data-mce-style");var c=l[r].querySelectorAll("[contenteditable]");if(0<c.length)for(var m=0;m<c.length;m++)c[m].removeAttribute("contenteditable");var p=l[r].querySelectorAll("[spellcheck]");if(0<p.length)for(var b=0;b<p.length;b++)p[b].removeAttribute("spellcheck");var u=l[r].querySelectorAll("[id^=mce_]");if(0<u.length)for(var g=0;g<u.length;g++)u[g].removeAttribute("id");for(var w=l[r].querySelectorAll(".wptb-actions"),v=w.length;0<v&&w[0]&&w[0].parentNode;)w[0].parentNode.removeChild(w[0]),v--}if(a[n].hasAttribute("data-wptb-title-column")){var h=document.createElement("div"),f=document.createElement("div");h.classList.add("wptb-column-title-mobile-container"),f.classList.add("wptb-column-title-mobile"),f.dataset.wptbTitleColumn=a[n].dataset.wptbTitleColumn,f.setAttribute("style","font-size:"+a[n].dataset.wptbTitleColumnFontSize+"; \n color:"+a[n].dataset.wptbTitleColumnColor+"; background-color:"+a[n].dataset.wptbTitleBackgroundColor+"; text-align:"+a[n].dataset.wptbTitleAlign+";"),f.style.padding=a[n].style.padding,0==a[n].children.length&&a[n].classList.add("wptb-column-title-mobile-not-elements"),h.appendChild(f),a[n].insertBefore(h,a[n].firstChild)}}return t}},array=(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},[]),WPTB_Table=function(e,t){var P,a,n,v,l=document.getElementsByClassName("wptb-settings-items"),y=document.getElementsByClassName("wptb-table-setup")[0],S=function(e){var t,a=this.rowSpan,n=this.colSpan,l=document.getElementsByClassName("wptb-no-cell-action"),r=document.getElementsByClassName("wptb-single-action"),o=document.getElementsByClassName("wptb-multiple-select-action"),i=document.getElementById("wptb-left-scroll-panel-cell-settings"),s=T(this),d=s[0],c=s[1];if(document.select.isActivated()){if(this.className.match(/wptb-highlighted/)){this.classList.remove("wptb-highlighted");for(var m=0;m<a;m++)for(var p=0;p<n;p++)array[d+m][c+p]=0}else{this.classList.add("wptb-highlighted");for(m=0;m<a;m++)for(p=0;p<n;p++)array[d+m][c+p]=1}if(0===(t=document.getElementsByClassName("wptb-highlighted").length)){for(m=0;m<o.length;m++)o[m].classList.remove("visible"),o[m].setAttribute("disabled","disabled");for(m=0;m<l.length;m++)l[m].classList.add("visible"),l[m].removeAttribute("disabled");for(m=0;m<r.length;m++)r[m].classList.remove("visible"),r[m].setAttribute("disabled","disabled");i.classList.remove("visible")}else if(1===t){for(m=0;m<o.length;m++)o[m].classList.remove("visible"),o[m].setAttribute("disabled","disabled");for(m=0;m<l.length;m++)l[m].classList.remove("visible"),l[m].setAttribute("disabled","disabled");for(m=0;m<r.length;m++)r[m].classList.add("visible"),r[m].removeAttribute("disabled");var b=document.querySelector(".wptb-highlighted");if(b){var u=document.getElementById("wptb-table-column-width-slider"),g=document.getElementById("wptb-table-column-width-number"),w=document.getElementById("wptb-table-column-width-auto-fixed"),v=b.style.width;if(v)u.value=parseFloat(v,10),g.value=parseFloat(v,10),w.checked=!0;else if(b.dataset.wptbFixedWidth)u.value=b.dataset.wptbFixedWidth,g.value=b.dataset.wptbFixedWidth,w.checked=!0;else{var h=WPTB_Helper.getColumnWidth(P,b);u.value=h,g.value=h,w.checked=!1}var f=document.getElementById("wptb-table-row-height-slider"),y=document.getElementById("wptb-table-row-height-number"),S=document.getElementById("wptb-table-row-height-auto-fixed"),B=b.style.height;if(B)f.value=parseFloat(B,10),y.value=parseFloat(B,10),S.checked=!0;else if(b.dataset.wptbFixedHeight)f.value=b.dataset.wptbFixedHeight,y.value=b.dataset.wptbFixedHeight,S.checked=!0;else{var E=WPTB_Helper.getRowHeight(P,b);f.value=E,y.value=E,S.checked=!1}}i.classList.add("visible")}else{for(m=0;m<o.length;m++)P.isSquare(array)?(o[m].classList.add("visible"),o[m].removeAttribute("disabled")):(o[m].classList.remove("visible"),o[m].setAttribute("disabled","disabled"));for(m=0;m<l.length;m++)l[m].classList.remove("visible"),l[m].setAttribute("disabled","disabled");for(m=0;m<r.length;m++)r[m].classList.remove("visible"),r[m].setAttribute("disabled","disabled");i.classList.remove("visible")}}},B=function(e){for(var t=0;t<e.length;t++){for(var a=0;a<e[t].length;a++)" "+e[t][a];"\n"}P.isSquare(e)},E=function(){for(var e=document.getElementsByClassName("wptb-no-cell-action"),t=document.getElementsByClassName("wptb-single-action"),a=document.getElementsByClassName("wptb-multiple-select-action"),n=document.getElementById("wptb-left-scroll-panel-cell-settings"),l=P.getElementsByClassName("wptb-highlighted");l.length;)l[0].classList.remove("wptb-highlighted");n.classList.remove("visible");for(var r=0;r<array.length;r++)for(var o=0;o<array[r].length;o++)array[r][o]=0;for(r=0;r<a.length;r++)a[r].classList.remove("visible"),a[r].setAttribute("disabled","disabled");for(r=0;r<e.length;r++)e[r].classList.add("visible"),e[r].removeAttribute("disabled");for(r=0;r<t.length;r++)t[r].classList.remove("visible"),t[r].setAttribute("disabled","disabled")},T=function(e){for(var t=[],a=0;a<v;a++)t[a]=0;for(a=0;a<P.rows.length;a++)for(var n=P.rows[a].getElementsByTagName("td"),l=cellPointer=0;l<v;l+=stepsToMove)if(stepsToMove=1,t[l])t[l]--;else{var r=n[cellPointer++];if(r==e)return[a,l];if(1<r.rowSpan){for(var o=0;o<r.colSpan;o++)t[l+o]=r.rowSpan-1;stepsToMove=r.colSpan}else 1<r.colSpan&&(stepsToMove=r.colSpan)}};if(jQuery("#wptb-table-header-bg").val(""),jQuery("#wptb-even-row-bg").val(""),jQuery("#wptb-odd-row-bg").val(""),jQuery("#wptb-table-border-color").val(""),jQuery("#wptb-table-inner-border-number,#wptb-table-inner-border-slider").val("0"),jQuery("#wptb-table-border-number,#wptb-table-border-slider").val("0"),jQuery("#wptb-table-padding-number,#wptb-table-padding-slider").val("15"),e||t){for(var r=0;r<l.length;r++)"wptb-apply-inner-border"!==l[r].id&&l[r].classList.add("visible");(P=document.createElement("table")).classList.add("wptb-preview-table"),P.dataset.reconstraction=1,P.dataset.wptbAdaptiveTable=1;for(r=0;r<t;r++){(a=P.insertRow(-1)).classList.add("wptb-row");for(var g=0;g<e;g++)(n=new WPTB_Cell(S)).setCoords(r,g),a.appendChild(n.getDOMElement())}}else{var o=document.getElementsByClassName("wptb-preview-table");if(0<o.length){var i=(P=o[0]).getElementsByTagName("td");if(0<i.length)for(var s=0;s<i.length;s++)WPTB_Cell(S,i[s])}}P.toggleTableEditMode=function(){var e=document.getElementsByClassName("wptb-edit-bar"),t=document.getElementById("wptb-cell_mode_background"),a=document.getElementById("wptb-left-scroll-panel-curtain"),n=document.getElementById("wptb-left-scroll-panel-cell-settings"),l=document.getElementsByClassName("wptb-preview-table");if(0<l.length&&(l=l[0]),0<e.length)for(var r=0;r<e.length;r++)if(e[r].classList.contains("visible")){document.select.deactivateMultipleSelectMode(),e[r].classList.remove("visible"),t.classList.remove("visible"),a.classList.remove("visible"),n.classList.remove("visible"),l.parentNode.classList.remove("wptb-preview-table-manage-cells");var o=l.getElementsByTagName("td");if(0<o.length)for(var i=0;i<o.length;i++)o[i].classList.remove("wptb-highlighted")}else document.select.activateMultipleSelectMode(),e[r].classList.add("visible"),t.classList.add("visible"),a.classList.add("visible"),l.parentNode.classList.add("wptb-preview-table-manage-cells")},P.recalculateIndexes=function(e){for(var t=this.getElementsByTagName("tr"),a=void 0,n=0,l=0,r=[],o=document.getElementById("wptb-top-row-as-header"),i=0;i<t.length;i++){0==i?(null==e&&(t[i].style.backgroundColor=jQuery("#wptb-table-header-bg").val()),o.checked?null==e&&(this.classList.add("wptb-table-preview-head"),t[i].classList.add("wptb-table-head")):null==e&&(this.classList.remove("wptb-table-preview-head"),t[i].classList.remove("wptb-table-head"))):(i%2==0?null==e&&(t[i].style.backgroundColor=jQuery("#wptb-odd-row-bg").val()):null==e&&(t[i].style.backgroundColor=jQuery("#wptb-even-row-bg").val()),t[i].classList.remove("wptb-table-head")),r[i],a=t[i].getElementsByTagName("td"),null==r[i]&&(r[i]=[]);for(var s=0,d=0;d<a.length;d++){if(null!=r[i][d])for(var c=0;c<100;c++){if(null==r[i][s]){r[i][s]=a[d],a[d].dataset.xIndex=s;break}s++}else r[i][d]=a[d],a[d].dataset.xIndex=s;if(a[d].dataset.yIndex=i,1<a[d].colSpan)for(var m=1;m<a[d].colSpan;m++)s++,r[i][s]="tdDummy";if(1<a[d].rowSpan)for(var p=1;p<a[d].rowSpan;p++){null==r[i+p]&&(r[i+p]=[]);for(var b=0;b<a[d].colSpan;b++)r[i+p][s-a[d].colSpan+1+b]="tdDummy"}s++,0==i&&(l=s)}n<d&&(n=d)}this.columns=n,this.maxCols=l},P.addColumnWidth=function(p,b){var e=P.getElementsByClassName("wptb-highlighted");if(0<e.length){for(var t=0;t<e.length;t++){var a=e[t].dataset.xIndex;a&&function e(t,a){for(var n=P.rows,l=!1,r=[],o=0;o<n.length;o++)for(var i=n[o].children,s=0;s<i.length;s++){var d=i[s];if(d.dataset.xIndex==t){if(p)if(d.colSpan==a){d.style.width=p+"px",d.removeAttribute("data-wptb-fixed-width"),l=!0;var c=document.getElementById("wptb-table-column-width-auto-fixed");c.checked||(c.checked=!0)}else d.style.width=null,d.dataset.wptbFixedWidth=p,o!=n.length-1||l||e(t,a+1);else if(b)d.style.width=null,d.removeAttribute("data-wptb-fixed-width");else if(d.dataset.wptbFixedWidth)d.colSpan==a&&(d.style.width=d.dataset.wptbFixedWidth+"px",d.removeAttribute("data-wptb-fixed-width"));else if(d.style.width){for(var m=0;m<r.length;m++)r[m].style.width=d.style.width;r=[]}else r.push(d);break}}}(a,1)}P.tdDefaultWidth()}},P.tdDefaultWidth=function(){for(var e,t=P.rows,a=0,n=0,l=document.getElementsByClassName("wptb-table-setup")[0].offsetWidth,r=[],o=[],i=0,s=0,d="",c=0;c<t.length;c++)for(var m=t[c].children,p=0;p<m.length;p++){var b=m[p];if(r[parseInt(b.dataset.xIndex)]||o[parseInt(b.dataset.xIndex)])o[parseInt(b.dataset.xIndex)]?b.dataset.wptbFixedWidth||(b.dataset.wptbCssTdAutoWidth=!0):r[parseInt(b.dataset.xIndex)]&&b.removeAttribute("data-wptb-css-td-auto-width");else if(b.style.width?(r[parseInt(b.dataset.xIndex)]=parseFloat(b.style.width),b.removeAttribute("data-wptb-css-td-auto-width")):b.dataset.wptbFixedWidth||(o[parseInt(b.dataset.xIndex)]=100,b.dataset.wptbCssTdAutoWidth=!0),window.getComputedStyle(b,null)){var u=window.getComputedStyle(b,null),g=u.getPropertyValue("padding-left"),w=u.getPropertyValue("padding-right");i=parseFloat(g,10)+parseFloat(w,10);var v=u.getPropertyValue("border-left-width"),h=u.getPropertyValue("border-right-width");s=parseFloat(v,10)+parseFloat(h,10),r[parseInt(b.dataset.xIndex)]?(r[parseInt(b.dataset.xIndex)]+=i,r[parseInt(b.dataset.xIndex)]+=s):(o[parseInt(b.dataset.xIndex)]+=i,o[parseInt(b.dataset.xIndex)]+=s)}}for(var f=0;f<r.length;f++)r[f]&&(a+=r[f]);for(var y=0,S=0;S<o.length;S++)o[S]&&(n+=o[S],y++);var B=window.getComputedStyle(P,null),E=B.getPropertyValue("border-left-width"),T=B.getPropertyValue("border-right-width"),C=parseFloat(E,10)+parseFloat(T,10);e=a+n+C,P.dataset.wptbTableTdsSumMaxWidth=e,y?(P.dataset.wptbCellsWidthAutoCount=y,P.mergingСellsHorizontally?P.dataset.wptbFixedWidthSize=a-C:P.removeAttribute("data-wptb-fixed-width-size")):(P.removeAttribute("data-wptb-fixed-width-size"),P.removeAttribute("data-wptb-cells-width-auto-count"));var N=!1,I=void 0;e<l?y?(P.style.minWidth="100%",P.mergingСellsHorizontally?(I=(I=(l-a-C)/y)-i-s,N=!(P.style.width=null)):P.style.width="100%"):(P.style.width=null,P.style.minWidth=null,P.style.maxWidth=e+"px"):(P.style.maxWidth=null,P.style.minWidth=e+"px",I="100",N=!(P.style.width=null));var x=document.head;if(x){var A=x.querySelector('style[data-wptb-td-auto-width="true"]');A&&x.removeChild(A)}N&&((d=document.createElement("style")).setAttribute("data-wptb-td-auto-width",!0),d.innerHTML="[data-wptb-css-td-auto-width=true]{width:"+I+"px}",x&&x.appendChild(d))},P.addRowHeight=function(p,b){var e=P.getElementsByClassName("wptb-highlighted");if(0<e.length)for(var t=0;t<e.length;t++){var a=e[t].dataset.yIndex;a&&function e(t,a){for(var n=P.rows,l=!1,r=[],o=0;o<n.length;o++)for(var i=n[o].children,s=0;s<i.length;s++){var d=i[s];if(d.dataset.yIndex==t)if(p){if(d.rowSpan==a){d.style.height=p+"px",d.removeAttribute("data-wptb-fixed-heidht"),l=!0;var c=document.getElementById("wptb-table-row-height-auto-fixed");c.checked||(c.checked=!0);continue}d.style.height=null,d.dataset.wptbFixedHeight=p,s!=i.length-1||l||e(t,a+1)}else if(b)d.style.height=null,d.removeAttribute("data-wptb-fixed-heidht");else if(d.dataset.wptbFixedHeight)(d.rowSpan=a)&&(d.style.height=d.dataset.wptbFixedHeight+"px",d.removeAttribute("data-wptb-fixed-width"));else if(d.style.height){for(var m=0;m<r.length;m++)r[m].style.height=d.style.height;r=[]}else r.push(d)}}(a,1)}},P.reconstraction=function(){var e=P.getElementsByTagName("td"),t=document.getElementsByClassName("wptb-adaptive-table-chose-block");0<t.length&&(t=t[0]),P.mergingСellsHorizontally=!1,P.mergingCellsVertically=!1,P.dataset.reconstraction=1,t.style.display="block";for(var a=0,n=0;n<e.length&&(1<e[n].colSpan&&(P.dataset.reconstraction=0,t.style.display="none",P.mergingСellsHorizontally=!0,a++),1<e[n].rowSpan&&(P.dataset.reconstraction=0,t.style.display="none",P.mergingCellsVertically=!0,a++),2!=a);n++);},P.addColumnEnd=function(){var e=void 0,t=document.getElementsByClassName("wptb-preview-table"),a=void 0,n=void 0;0<t.length&&(a=t[0].querySelector("td")),a&&(n=a.getAttribute("style"));for(var l=0;l<P.rows.length;l++)e=new WPTB_Cell(S),n&&(e.getDOMElement().setAttribute("style",n),e.getDOMElement().style.width=null,e.getDOMElement().style.height=null),P.rows[l].appendChild(e.getDOMElement()),array[l].push(0);v++,P.recalculateIndexes(),P.tdDefaultWidth(),P.addRowHeight(),WPTB_Helper.dataTitleColumnSet(P),E(),(new WPTB_TableStateSaveManager).tableStateSet()},P.addColumnStart=function(){var e=void 0,t=void 0,a=document.getElementsByClassName("wptb-preview-table"),n=void 0,l=void 0;0<a.length&&(n=a[0].querySelector("td")),n&&(l=n.getAttribute("style"));for(var r=0;r<P.rows.length;r++)e=new WPTB_Cell(S),l&&(e.getDOMElement().setAttribute("style",l),e.getDOMElement().style.width=null,e.getDOMElement().style.height=null),(t=P.rows[r].getElementsByTagName("td")[0])?P.rows[r].insertBefore(e.getDOMElement(),t):P.rows[r].appendChild(e.getDOMElement()),array[r].push(0);v++,P.recalculateIndexes(),P.tdDefaultWidth(),P.addRowHeight(),WPTB_Helper.dataTitleColumnSet(P),E(),(new WPTB_TableStateSaveManager).tableStateSet()},P.addColumnAfter=function(e){var t=P.rows,a=void 0,n=void 0,l=document.querySelector(".wptb-highlighted"),r=l.getAttribute("style"),o=null!=e&&"number"==typeof e?e:T(l)[1];if(v-o-l.colSpan+1==1)P.addColumnEnd();else{for(var i=!1,s=void 0,d=void 0,c=void 0,m=[],p=void 0,b=0;b<v;b++)m.push(0);for(b=0;b<t.length;b++){a=0,n=t[b].getElementsByTagName("td"),i=!1;for(var u=0;u<v;u+=s){if(s=1,i){d=new WPTB_Cell(S),r&&(d.getDOMElement().setAttribute("style",r),d.getDOMElement().style.width=null,d.getDOMElement().style.height=null),p&&t[b].contains(p)?(c=p.nextSibling)?t[b].insertBefore(d.getDOMElement(),c):t[b].appendChild(d.getDOMElement()):t[b].insertBefore(d.getDOMElement(),n[0]);break}if(0<m[u])o==u&&(i=!0);else if(1<(p=n[a++]).rowSpan){s=p.colSpan;for(var g=0;g<p.colSpan;g++)m[u+g]=p.rowSpan,u+g==o&&(i=!0)}else if(1<p.colSpan){s=p.colSpan;for(g=0;g<p.colSpan;g++)u+g==o&&(i=!0)}else u==o&&(i=!0)}for(var w=0;w<v;w++)0<m[w]&&m[w]--}for(b=0;b<array.length;b++)array[b].push(0);v++,B(array),P.recalculateIndexes(),P.addColumnWidth(),P.addRowHeight(),WPTB_Helper.dataTitleColumnSet(P),E(),(new WPTB_TableStateSaveManager).tableStateSet()}},P.addColumnBefore=function(){var e=document.querySelector(".wptb-highlighted"),t=T(e)[1];0===t?P.addColumnStart():P.addColumnAfter(t-1)},P.addRowToTheEnd=function(){var e=P.insertRow(-1),t=void 0,a=void 0,n=document.getElementsByClassName("wptb-preview-table");if(e.classList.add("wptb-row"),0<n.length){n=n[0];for(var l=0;l<v;l++){t=new WPTB_Cell(S);var r=n.querySelector('[data-x-index="'+l+'"]');if(r){var o=r.getAttribute("style");t.getDOMElement().setAttribute("style",o),t.getDOMElement().style.height=null}e.appendChild(t.getDOMElement())}a=Array.from(array[0]),array.push(a),B(array),P.recalculateIndexes(),P.addColumnWidth(),WPTB_Helper.dataTitleColumnSet(P),E(),(new WPTB_TableStateSaveManager).tableStateSet()}},P.addRowToTheStart=function(){var e=P.insertRow(0),t=void 0,a=void 0,n=document.getElementsByClassName("wptb-preview-table");if(e.classList.add("wptb-row"),0<n.length){n=n[0];for(var l=0;l<v;l++){t=new WPTB_Cell(S);var r=n.querySelector('[data-x-index="'+l+'"]');if(r){var o=r.getAttribute("style");t.getDOMElement().setAttribute("style",o),t.getDOMElement().style.height=null}e.appendChild(t.getDOMElement())}a=Array.from(array[0]),array.push(a),B(array),P.recalculateIndexes(),P.addColumnWidth(),WPTB_Helper.dataTitleColumnSet(P),E(),(new WPTB_TableStateSaveManager).tableStateSet()}},P.addRowBefore=function(){for(var e=document.querySelector(".wptb-highlighted"),t=e.getAttribute("style"),a=T(e)[0],n=void 0,l=a-1;0<=l;l--){var r=P.rows[l].children,o=r.length;if(0<o)for(var i=0;i<o;i++)if(1==r[i].rowSpan){a=l,n=!0;break}if(n)break}0===a?P.addRowToTheStart():P.addRowAfter(a,t)},P.addRowAfter=function(e,t){var a,n=void 0;if(null!=e&&"number"==typeof e||null!=t)n=e;else{var l=document.querySelector(".wptb-highlighted");t=l.getAttribute("style"),n=(e=T(l)[0])+l.rowSpan-1}var r=0;if(n<P.rows.length-1){for(var o=0;o<=n;o++){var i=P.rows[o].children,s=i.length;if(0<s)for(var d=0;d<s;d++){n<i[d].rowSpan-1+o&&i[d].rowSpan++}}var c=P.rows[n+1].children,m=c.length;if(0<m)for(var p=0;p<m;p++)r+=c[p].colSpan}else r=array[0].length;var b=P.insertRow(n+1);for(b.classList.add("wptb-row"),g=0;g<r;g++){var u=new WPTB_Cell(S);u.getDOMElement().setAttribute("style",t),u.getDOMElement().style.width=null,u.getDOMElement().style.height=null,b.appendChild(u.getDOMElement())}a=Array.from(array[0]),array.push(a),B(array),P.recalculateIndexes(),P.addColumnWidth(),WPTB_Helper.dataTitleColumnSet(P),E(),(new WPTB_TableStateSaveManager).tableStateSet()},P.isSquare=function(e){for(var t,a,n=-1,l=-1,r=-1,o=-1,i=0,s=0;s<e.length;s++)for(var d=0;d<e[s].length;d++)1==e[s][d]&&((d<l||-1==l)&&(l=d),(s<n||-1==n)&&(n=s));for(s=e.length-1;-1<s;s--)for(d=e[s].length-1;-1<d;d--)1==e[s][d]&&(o<d&&(o=d),r<s&&(r=s));for(s=n;s<r;s++)for(d=l;d<o;d++)if(0==e[s][d]||null==e[s][d])return!1;for(s=0;s<e.length;s++)for(d=0;d<e[s].length;d++)1==e[s][d]&&i++;return(t=r-n+1)*(a=o-l+1)===i&&[t,a]},P.mergeCells=function(){for(var e=P.isSquare(array),t=e[0],a=e[1],n=document.querySelector(".wptb-highlighted"),l=[].slice.call(document.getElementsByClassName("wptb-highlighted"),1),r=[],o=0;o<l.length;o++){var i=l[o].getElementsByClassName("wptb-ph-element");if(0<i.length)for(var s=i.length,d=0;d<s;d++)r.push(i[d]);l[o].parentNode.removeChild(l[o])}if(0<r.length)for(var c=0;c<r.length;c++)n.appendChild(r[c]);n.colSpan=a,n.rowSpan=t,P.recalculateIndexes(),P.reconstraction();var m=n.style.width,p=n.dataset.wptbFixedWidth;m?P.addColumnWidth(parseFloat(m,10)):p?P.addColumnWidth():P.addColumnWidth(!1,!0);var b=n.style.height,u=n.dataset.wptbFixedHeight;b?P.addRowHeight(parseFloat(b,10)):u?P.addRowHeight():P.addRowHeight(!1,!0),WPTB_Helper.dataTitleColumnSet(P),E(),(new WPTB_TableStateSaveManager).tableStateSet()},P.splitCell=function(){var e=document.getElementsByClassName("wptb-highlighted")[0],t=e.rowSpan,a=e.colSpan,n=e.getAttribute("style"),l=T(e)[0],r=P.rows[l],o=e.dataset.xIndex;e.rowSpan=1;for(var i=e.colSpan=1;i<a;i++){var s=new WPTB_Cell(S);s.getDOMElement().setAttribute("style",n),s.getDOMElement().classList.add("wptb-highlighted"),e.nextSibling?r.insertBefore(s.getDOMElement(),e.nextSibling):r.appendChild(s.getDOMElement())}if(1<t)for(var d=1;d<t;d++){var c=void 0,m=P.rows[l+d],p=m.children,b=p.length;if(0<b)for(var u=0;u<b;u++)if(Number(p[u].dataset.xIndex)>Number(o)){c=p[u];break}for(var g=0;g<a;g++){var w=new WPTB_Cell(S);w.getDOMElement().setAttribute("style",n),null!=c?m.insertBefore(w.getDOMElement(),c):m.appendChild(w.getDOMElement())}}P.recalculateIndexes(),P.reconstraction(),P.addColumnWidth(),P.addRowHeight(),WPTB_Helper.dataTitleColumnSet(P),E(),(new WPTB_TableStateSaveManager).tableStateSet()},P.findRowspannedCells=function(e){var t,a=[];if(actualPoints=function(e){for(var t=P.rows[e].getElementsByTagName("td"),a=0,n=0;n<t.length;n++)a+=t[n].colSpan;return a}(e),actualPoints===v)return[];t=v-actualPoints;for(var n=e-1;0<=n&&t;n--){var l=P.rows[n].getElementsByTagName("td");for(n=0;n<l.length;n++)1<l[n].rowSpan&&(a.push(l[n]),t-=l[n].colSpan)}return a},P.addLackingCells=function(){for(var e=[],t=0;t<P.rows.length;t++)e.push(0);for(t=0;t<P.rows.length;t++)for(var a=P.rows[t].getElementsByTagName("td"),n=0;n<a.length;n++)if(1<a[n].rowSpan)for(var l=1;l<a[n].rowSpan;l++)e[t+l]++;for(t=0;t<P.rows.length;t++){a=P.rows[t].getElementsByTagName("td");var r=0;for(n=0;n<a.length;n++)r+=a[n].colSpan;r+=e[t],difference=v-r;for(n=0;n<difference;n++){var o=new WPTB_Cell(S);P.rows[t].appendChild(o.getDOMElement())}}},P.deleteRow=function(){var e=document.querySelector(".wptb-highlighted"),t=e.getAttribute("style"),a=e.rowSpan,n=T(e)[0],l=void 0;null==a&&(a=1);for(var r=0;r<a;r++){var o=P.rows[n].children,i=P.rows[n+1],s=void 0,d=void 0,c=[];if(null!=i){d=(s=i.children).length;for(var m=0;m<o.length;m++)if(1<o[m].rowSpan){var p=new WPTB_Cell(S);p.getDOMElement().setAttribute("style",t),p.getDOMElement().colSpan=o[m].colSpan,p.getDOMElement().rowSpan=o[m].rowSpan-1;for(var b=void 0,u=0;u<d;u++)if(Number(s[u].dataset.xIndex)>Number(o[m].dataset.xIndex)){b=s[u];break}b?c.push([p,b]):c.push([p])}if(0<c.length)for(var g=0;g<c.length;g++)null!=c[g][1]?i.insertBefore(c[g][0].getDOMElement(),c[g][1]):i.appendChild(c[g][0].getDOMElement())}var w=P.rows;if(0<w.length)for(var v=0;v<n;v++){var h=w[v].children;if(0<h.length)for(var f=0;f<h.length;f++)h[f].rowSpan-1>=n-v&&h[f].rowSpan--}l=Array.from(array[0]),array.pop(l),B(array),P.getElementsByTagName("tbody")[0].removeChild(P.rows[n]),0==P.rows.length&&(P.toggleTableEditMode(),y.innerHTML="",WPTB_Helper.settingsPanelClear(),document.getElementsByClassName("wptb-table-generator")[0].style.display="table"),P.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(P)}E(),(new WPTB_TableStateSaveManager).tableStateSet()},P.deleteColumn=function(){for(var e=document.querySelector(".wptb-highlighted"),t=e.dataset.xIndex,a=e.colSpan,n=0;n<a;n++){for(var l=0;l<P.rows.length;l++){var r=P.rows[l].children,o=r.length;if(0<o)for(var i=o-1;0<=i;i--){if(Number(r[i].dataset.xIndex)==Number(t)){1<r[i].colSpan?r[i].colSpan--:P.rows[l].removeChild(r[i]);break}if(Number(r[i].dataset.xIndex)<Number(t)&&Number(r[i].dataset.xIndex)+Number(r[i].colSpan-1)>=t){1<r[i].colSpan&&r[i].colSpan--;break}}}for(var s=0;s<P.rows.length;s++)null!=array[s]&&array[s].pop();v--,0==P.querySelectorAll("td").length&&(P.toggleTableEditMode(),y.innerHTML="",WPTB_Helper.settingsPanelClear(),document.getElementsByClassName("wptb-table-generator")[0].style.display="table"),P.recalculateIndexes(),P.tdDefaultWidth(),WPTB_Helper.dataTitleColumnSet(P)}E(),(new WPTB_TableStateSaveManager).tableStateSet()},document.getElementsByClassName("wptb-table-generator")[0].style.display="none",array=function(){for(var e=[],t=[],a=0;a<P.rows.length;a++){for(var n=P.rows[a].getElementsByTagName("td"),l=0,r=0;r<n.length;r++)l+=n[r].colSpan;e.push(l)}v=Math.max.apply(null,e);var o=P.rows.length;for(a=0;a<o;a++)for(t[a]=[],r=0;r<v;r++)t[a].push(0);return B(t),t}(),E(),B(array),y.appendChild(P),P.recalculateIndexes(!0),P.reconstraction(),P.tdDefaultWidth(),y.onresize=function(){P.tdDefaultWidth()},WPTB_LeftPanel()},WPTB_TableStateSaveManager=function(){this.tableStateSet=function(){var e=document.getElementsByClassName("wptb-preview-table");if(0<e.length){e=e[0],window.wptbTableStateSaving||(window.wptbTableStateSaving=[]),window.wptbTableStateSaving.length>window.wptbTableStateNumberShow+1&&(window.wptbTableStateSaving=window.wptbTableStateSaving.slice(0,window.wptbTableStateNumberShow+1));for(var t=e.cloneNode(!0),a=t.getElementsByClassName("wptb-highlighted"),n=0;n<a.length;n++)a[n].classList.remove("wptb-highlighted");for(var l=t.getElementsByClassName("wptb-directlyhovered"),r=0;r<l.length;r++)l[r].classList.remove("wptb-directlyhovered");var o="",i=document.head;if(i){var s=i.querySelector('style[data-wptb-td-auto-width="true"]');s&&(o=s.innerHTML)}var d=document.getElementsByClassName("wptb-element-datas");d=0<d.length?d.innerHTML:"";var c=t.querySelectorAll(".mce-content-body");if(0<c.length)for(var m=0;m<c.length;m++)c[m].classList.remove("mce-content-body");var p=t.querySelectorAll("[data-mce-style]");if(0<p.length)for(var b=0;b<p.length;b++)p[b].removeAttribute("data-mce-style");var u=t.querySelectorAll("[id^=mce_]");if(0<u.length)for(var g=0;g<u.length;g++)u[g].removeAttribute("id");if(window.wptbTableStateSaving.push([t,o,d]),window.wptbTableStateNumberShow=window.wptbTableStateSaving.length-1,1<window.wptbTableStateSaving.length){var w=document.getElementsByClassName("wptb-undo");0<w.length&&(w=w[0]).classList.remove("wptb-undoredo-disabled")}var v=document.getElementsByClassName("wptb-redo");0<v.length&&(v=v[0]).classList.add("wptb-undoredo-disabled");var h=document.getElementsByClassName("wptb-save-btn");0<h.length&&(!(h=h[0]).dataset.wptbTableStateNumberSave&&0==window.wptbTableStateNumberShow||window.wptbTableStateNumberShow==h.dataset.wptbTableStateNumberSave?h.classList.add("wptb-save-disabled"):h.classList.remove("wptb-save-disabled"))}},this.tableStateGet=function(e){if(e&&window.wptbTableStateSaving&&1<window.wptbTableStateSaving.length){if("undo"==e){if(!(0<window.wptbTableStateNumberShow))return!1;window.wptbTableStateNumberShow--}else if("redo"==e){if(!(window.wptbTableStateNumberShow<window.wptbTableStateSaving.length-1))return!1;window.wptbTableStateNumberShow++}var t=document.getElementsByClassName("wptb-undo");0<t.length&&(t=t[0]),0==window.wptbTableStateNumberShow?t&&t.classList.add("wptb-undoredo-disabled"):0<window.wptbTableStateNumberShow&&t&&t.classList.remove("wptb-undoredo-disabled");var a=document.getElementsByClassName("wptb-redo");0<a.length&&(a=a[0]),window.wptbTableStateNumberShow==window.wptbTableStateSaving.length-1?a&&a.classList.add("wptb-undoredo-disabled"):window.wptbTableStateNumberShow<window.wptbTableStateSaving.length-1&&a&&a.classList.remove("wptb-undoredo-disabled");var n=document.getElementsByClassName("wptb-save-btn");0<n.length&&(!(n=n[0]).dataset.wptbTableStateNumberSave&&0==window.wptbTableStateNumberShow||window.wptbTableStateNumberShow==n.dataset.wptbTableStateNumberSave?n.classList.add("wptb-save-disabled"):n.classList.remove("wptb-save-disabled"));var l=document.getElementsByClassName("wptb-table-setup");if(0<l.length){if((l=l[0]).innerHTML="",l.innerHTML=window.wptbTableStateSaving[window.wptbTableStateNumberShow][0].outerHTML,window.wptbTableStateSaving[window.wptbTableStateNumberShow][1]){var r=document.createElement("style");r.setAttribute("data-wptb-td-auto-width",!0),r.innerHTML=window.wptbTableStateSaving[window.wptbTableStateNumberShow][1];var o=document.head;if(o){var i=o.querySelector('style[data-wptb-td-auto-width="true"]');i&&o.removeChild(i),o.appendChild(r)}}var s=document.getElementsByClassName("wptb-element-datas"),d=document.getElementsByTagName("body");0<d.length&&(d=d[0]),window.wptbTableStateSaving[window.wptbTableStateNumberShow][2]?(s.innerHTML=window.wptbTableStateSaving[window.wptbTableStateNumberShow][2],0<s.length?s=s[0]:((s=document.createElement("div")).classList.add("wptb-element-datas"),d.appendChild(s))):0<s.length&&(s=s[0],d.removeChild(s)),WPTB_Helper.settingsPanelClear(),WPTB_Helper.elementOptionsPanelClear(),WPTB_LeftPanel();var c=document.getElementById("wptb-left-scroll-panel-cell-settings");c&&c.classList.remove("visible")}}}},WPTB_innerElementSet=function c(t){t.ondragenter=function(e){-1==e.dataTransfer.types.indexOf("wptbelement")&&-1==e.dataTransfer.types.indexOf("wptb-moving-mode")||(WPTB_DropHandle(this,e),t.classList.add("wptb-ondragenter"))},t.ondragover=function(e){e.preventDefault(),WPTB_DropHandle(this,e)},t.ondragleave=function(){},t.ondrop=function(e){this.classList.remove("wptb-ondragenter");var t=void 0,a=void 0;if(e.preventDefault(),e.stopPropagation(),e.dataTransfer.getData("wptbElement")||e.dataTransfer.getData("node")){var n=void 0,l=void 0;if(0<document.getElementsByClassName("wptb-drop-handle").length&&(n=document.getElementsByClassName("wptb-drop-handle")[0]),0<document.getElementsByClassName("wptb-drop-border-marker").length&&(l=document.getElementsByClassName("wptb-drop-border-marker")[0]),t=e.dataTransfer.getData("wptbElement")?(t=WPTB_Helper.newElementProxy(e.dataTransfer.getData("wptbElement"))).getDOMElement():(a=e.dataTransfer.getData("node"),document.getElementsByClassName(a)[0]),"block"==n.style.display){var r=void 0;if("Drop Here"==n.dataset.text)(r=n.getDOMParentElement()).appendChild(t);else{var o=n.getDOMParentElement();if(r=o.parentNode,"Above Element"==n.dataset.text)r.insertBefore(t,o);else if("Below Element"==n.dataset.text){var i=o.nextSibling;r.insertBefore(t,i)}}var s=r.parentNode;if(s.classList.contains("wptb-table-head")){var d=WPTB_Helper.findAncestor(s,"wptb-preview-table");WPTB_Helper.dataTitleColumnSet(d)}t.className.match(/wptb-element-(.+)-(\d+)/i)[1];if(e.dataTransfer.getData("wptbElement"),n.style.display="none",l.style.display="none",c(t),!t.classList.contains("wptb-image-container")||t.classList.contains("wptb-moving-mode"))t.classList.remove("wptb-moving-mode"),(new WPTB_TableStateSaveManager).tableStateSet();return!0}}},t.onmouseover=function(e){t.classList.remove("wptb-ondragenter")}};_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,a=Array(e.length);t<e.length;t++)a[t]=e[t];return a}return Array.from(e)}var applyGenericItemSettings=function(e,t){var a,n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],l=e.getDOMElement();if(l.classList.contains("wptb-ph-element")){if(null==t||1==n){a=document.counter.nextIndex(e.kind);for(var r=document.getElementsByClassName("wptb-ph-element"),o=[],i=0;i<r.length;i++){var s=new RegExp("wptb-element-"+e.kind+"-(\\d+)","i"),d=r[i].className.match(s);d&&o.push(d[1])}if(0<o.length)a=Math.max.apply(Math,o)+1;else a=1;if(n)for(var c=[].concat(_toConsumableArray(l.attributes)),m=0;m<c.length;m++)if(c[m]&&"object"===_typeof(c[m])&&c[m].nodeName){var p=new RegExp("data-wptb-el-"+e.kind+"-(\\d+)-(.+)","i"),b=c[m].nodeName.match(p);if(b&&Array.isArray(b)){var u=c[m].nodeName.replace(e.kind+"-"+b[1],e.kind+"-"+a),g=c[m].nodeValue;l.removeAttribute(c[m].nodeName),l.setAttribute(u,g)}}}else if(t&&!n){var w=t.split("-");a=w[w.length-1]}var v=l.className.match(/wptb-element-(.+)-(\d+)/i);v&&l.classList.remove(v[0]),l.classList.contains("wptb-ph-element")||l.classList.add("wptb-ph-element"),l.classList.contains("wptb-element-"+e.kind+"-"+a)||l.classList.add("wptb-element-"+e.kind+"-"+a),new WPTB_ElementOptions(e,a,t),WPTB_Helper.elementStartScript(e.getDOMElement()),document.counter.increment(e.kind)}l.onmouseenter=function(e){if(!e.target.classList.contains("wptb-moving-mode")){var t=new WPTB_ActionsField;t.addActionField(1,l),t.setParameters(l),l.classList.remove("wptb-ondragenter")}},l.onmouseleave=function(e){(new WPTB_ActionsField).leaveFromField(e,l)}};
1
+ var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},WPTB_ActionsField=function i(){var p=this;this.wptbActions,0!=document.getElementsByClassName("wptb-actions").length&&(this.wptbActions=document.getElementsByClassName("wptb-actions")[0]),this.addActionField=function(e,t){var a=document.getElementsByTagName("body")[0],n=document.getElementsByClassName("wptb-actions");if(0!=n.length){var l=n[0].activeElem;for(l&&l.classList.remove("wptb-directlyhovered");0!=n.length;)n[0].parentNode.removeChild(n[0])}if(1==e){var r=void 0,o=void 0;if(r=document.createElement("span"),o=document.createElement("span"),(n=document.createElement("div")).classList.add("wptb-actions"),r.classList.add("dashicons","dashicons-trash","wptb-delete-action"),o.classList.add("dashicons","dashicons-admin-page","wptb-duplicate-action"),n.appendChild(o),n.appendChild(r),a.appendChild(n),n.activeElem=t,n.type=1,r.onclick=function(e){var t=e.target.parentNode.activeElem,a=t.parentNode,n=t.className.match(/wptb-element-(.+)-(\d+)/i);if(t&&n&&Array.isArray(n)&&(WPTB_Helper.elementControlsStateDelete(t),WPTB_Helper.externalCssStylesDelete(n[0])),t&&a.removeChild(t),t&&"object"===(void 0===t?"undefined":_typeof(t))&&t.hasOwnProperty("kind")&&"text"==t.kind){var l=a.parentNode;if(WPTB_Helper.rowIsTop(l)){var r=WPTB_Helper.findAncestor(l,"wptb-preview-table");r.classList.contains("wptb-table-preview-head")&&WPTB_Helper.dataTitleColumnSet(r)}}(new i).actionsRemove(),(new WPTB_TableStateSaveManager).tableStateSet()},o.onclick=function(e){var t,a=void 0,n=void 0,l=e.target.parentNode.activeElem,r=l.parentNode;if((t=l.className.match(/wptb-element-(.+)-(\d+)/i))&&Array.isArray(t)){n=t[1];var o={};o.kind=n,o.elemProt=l,o.tinyMceClear=!0,a=new WPTB_ElementObject(o),WPTB_Helper.elementControlsStateCopy(l,a.getDOMElement()),WPTB_Helper.externalCssStylesCopy(l,a.getDOMElement()),r.insertBefore(a.getDOMElement(),l.nextSibling)}else{a={};var s=l.cloneNode(!0);s.classList.remove("wptb-directlyhovered"),a.getDOMElement=function(){return s},applyGenericItemSettings(a),r.insertBefore(a.getDOMElement(),l.nextSibling),WPTB_Helper.wptbDocumentEventGenerate("wptb-inner-element:copy",l,a.getDOMElement())}WPTB_innerElementSet(a.getDOMElement()),new i(1,l).setParameters(l),(new WPTB_TableStateSaveManager).tableStateSet()},t.classList.contains("wptb-ph-element")){var s=void 0;(s=document.createElement("span")).classList.add("dashicons","dashicons-move","wptb-move-action"),s.draggable=!0,n.appendChild(s),s.ondragstart=function(e){var t,a=wp.template("wptb-element-icons-directories")({}),n=JSON.parse(a),l=void 0,r=e.target.parentNode.activeElem,o=void 0;if((t=r.className.match(/wptb-element-(.+)-(\d+)/i))&&Array.isArray(t)){o=t[1],r.classList.add("wptb-moving-mode"),n&&"object"===(void 0===n?"undefined":_typeof(n))&&n[o]&&(l=WPTB_Helper.getElementIcon(n[o])),e.dataTransfer.effectAllowed="move",e.dataTransfer.setDragImage(l,0,0),e.dataTransfer.setData("node","wptb-element-"+t[1]+"-"+t[2]),e.dataTransfer.setData("wptb-moving-mode","wptb-element-"+t[1]+"-"+t[2]),e.dataTransfer.setData("wptbElIndic-"+t[1],"wptbElIndic-"+t[1]);var s=e.target.parentNode.activeElem;if("text"==s.kind){var i=s.parentNode.parentNode;if(WPTB_Helper.rowIsTop(i)){var d=WPTB_Helper.findAncestor(i,"wptb-preview-table");d.classList.contains("wptb-table-preview-head")&&WPTB_Helper.dataTitleColumnSet(d)}}}else p.style.display="none",console.log(p);p.actionsHide()},s.ondragend=function(e){WPTB_Helper.elementDragEndClear()}}n.style.display="block",p.wptbActions=n}},this.setParameters=function(t){if(!p.wptbActions){var e=document.getElementsByClassName("wptb-actions");0<e.length?p.wptbActions=e[0]:p.wptbActions=!1}if(p.wptbActions&&p.wptbActions.classList.contains("wptb-actions")){p.wptbActions.style.display="block";var a=t.getBoundingClientRect(),n=document.getElementsByClassName("wptb-container")[0],l=function(){var e=t.getBoundingClientRect();p.wptbActions.style.top=parseFloat(e.top)-15+"px"};n.removeEventListener("scroll",l,!1),p.wptbActions.style.top=parseFloat(a.top)-15+"px",p.wptbActions.style.left=parseFloat(a.right)-parseFloat(p.wptbActions.clientWidth)+1+"px",p.wptbActions.style.display="block",t.classList.add("wptb-directlyhovered"),n.addEventListener("scroll",l,!1)}},this.leaveFromField=function(e,t,a){if(!p.wptbActions){var n=document.getElementsByClassName("wptb-actions");0<n.length?p.wptbActions=n[0]:p.wptbActions=!1}if(p.wptbActions){if(e.relatedTarget&&(e.relatedTarget.classList.contains("wptb-actions")||e.relatedTarget.classList.contains("wptb-move-action")||e.relatedTarget.classList.contains("wptb-duplicate-action")||e.relatedTarget.classList.contains("wptb-delete-action")))return p.wptbActions||(p.wptbActions=document.getElementsByClassName("wptb-actions")[0]),void(p.wptbActions.onmouseleave=function(e){null!=e.relatedTarget&&(e.relatedTarget.classList.contains("wptb-ph-element")||WPTB_Helper.findAncestor(e.relatedTarget,"wptb-ph-element"))&&e.relatedTarget!=p.wptbActions.activeElem&&(WPTB_Helper.findAncestor(e.relatedTarget,"wptb-directlyhovered"),p.wptbActions.activeElem),(new i).leaveFromField(e,e.relatedTarget.parentNode.parentNode),e.target.activeElem.classList.remove("wptb-directlyhovered")});t.classList.remove("wptb-directlyhovered"),p.wptbActions.style.display="none",e.relatedTarget&&(e.relatedTarget.classList.contains("wptb-ph-element")||WPTB_Helper.findAncestor(e.relatedTarget,"wptb-ph-element"))&&(p.addActionField(1,e.relatedTarget.parentNode),p.setParameters(e.relatedTarget.parentNode))}},this.actionsRemove=function(){if(!p.wptbActions){var e=document.getElementsByClassName("wptb-actions");0<e.length&&(p.wptbActions=e[0])}p.wptbActions&&p.wptbActions.parentNode.removeChild(p.wptbActions)},this.actionsHide=function(){if(!p.wptbActions){var e=document.getElementsByClassName("wptb-actions");0<e.length&&(p.wptbActions=e[0])}p.wptbActions&&(p.wptbActions.style.opacity=0)}};document.addEventListener("DOMContentLoaded",function(){var r=WPTB_Helper.detectMode();if(r){var o=new XMLHttpRequest,e=ajaxurl+"?action=get_table&id="+r;o.open("GET",e,!0),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),o.onreadystatechange=function(e){if(4!=this.readyState||200!=this.status);else{var t=JSON.parse(o.responseText);if(document.getElementById("wptb-setup-name").value=t[0],t[1]){document.getElementsByClassName("wptb-table-generator")[0].style.display="none",document.getElementsByClassName("wptb-table-setup")[0].appendChild(WPTB_Parser(t[1]));var a=document.getElementsByTagName("body")[0];if(t[2]){var n=document.createElement("script");n.setAttribute("type","text/html"),n.setAttribute("class","wptb-element-datas"),n.innerHTML=t[2],a.appendChild(n)}WPTB_Table();var l=document.querySelector(".wptb-preview-table");l&&(l.className.match(/wptb-element-((.+-)\d+)/i)||l.classList.add("wptb-element-main-table_setting-"+r)),WPTB_LeftPanel(),WPTB_Settings(),(new WPTB_TableStateSaveManager).tableStateSet(),WPTB_Helper.elementOptionsSet("table_setting",l)}else document.getElementsByClassName("wptb-table-generator")[0].style.display="table"}},o.send(null)}else document.getElementsByClassName("wptb-table-generator")[0].style.display="table";document.counter=new ElementCounters,document.select=new MultipleSelect,WPTB_Initializer(),settings=WPTB_Settings()});var WPTB_Cell=function(e,a){if(!a){(a=document.createElement("td")).style.padding=jQuery("#wptb-table-padding-number").val()+"px";var t=jQuery("#wptb-table-inner-border-number").val();""!=t&&0!=parseInt(t)&&(a.style.border=t+"px solid "+jQuery("#wptb-table-border-color").val()),a.classList.add("wptb-droppable","wptb-cell"),console.log("wptb_cell_test")}a.draggable=!1,e&&(a.onclick=e),a.ondblclick=function(e){if(e.stopPropagation(),!WPTB_Helper.findAncestor(a,"wptb-preview-table-manage-cells")&&e.target==e.currentTarget){WPTB_Helper.wptbDocumentEventGenerate("table:cell:dblclick",e.target);var t=WPTB_Helper.newElementProxy("text");t=t.getDOMElement(),a.appendChild(t),WPTB_innerElementSet(t)}},WPTB_innerElementSet(a);var o=a.getElementsByClassName("wptb-ph-element");if(0<o.length)for(var n=function(l){o[l].getDOMElement=function(){return o[l]},WPTB_innerElementSet(o[l]);var r=o[l].className.match(/wptb-element-((.+-)\d+)/i);r&&Array.isArray(r)&&function(){var e=r[1].split("-");o[l].kind=e[0],applyGenericItemSettings(o[l],r[1]);var a=o[l].getElementsByClassName("wptb-in-element");if(0<a.length)for(var t=function(e){var t={getDOMElement:function(){return a[e]}};applyGenericItemSettings(t)},n=0;n<a.length;n++)t(n)}()},l=0;l<o.length;l++)n(l);return this.getDOMElement=function(){return a},this.setCoords=function(e,t){var a=this.getDOMElement();a.dataset.yIndex=e,a.dataset.xIndex=t},this.getCoords=function(){var e,t=this.getDOMElement();return e.x=t.dataset.xIndex,e.y=t.dataset.yIndex,e},this.appendElement=function(e){getDOMElement().appendChild(e)},a.getCellDimensions=function(){var e=window.getComputedStyle(this,null),t=e.getPropertyValue("padding-left"),a=e.getPropertyValue("padding-right"),n=e.getPropertyValue("border-left-width"),l=e.getPropertyValue("border-right-width"),r=e.getPropertyValue("padding-top"),o=e.getPropertyValue("padding-bottom"),s=e.getPropertyValue("border-top-width"),i=e.getPropertyValue("border-bottom-width"),d=parseInt(this.offsetWidth,10)-parseInt(t,10)-parseInt(a,10)-parseInt(n,10)/2-parseInt(l,10)/2,p=parseInt(this.offsetHeight,10)-parseInt(r,10)-parseInt(o,10)-parseInt(s,10)/2-parseInt(i,10)/2,c=WPTB_Helper.findAncestor(this,"wptb-preview-table");if(c){var m=window.getComputedStyle(c,null),b=m.getPropertyValue("border-left-width"),u=m.getPropertyValue("border-right-width"),w=m.getPropertyValue("border-top-width"),g=m.getPropertyValue("border-bottom-width"),v=this.parentNode;if(v&&"tr"===v.nodeName.toLowerCase()){v.firstChild&&v.firstChild.dataset.xIndex===this.dataset.xIndex&&parseInt(b,10)>parseInt(n,10)&&(d+=-(parseInt(b,10)-parseInt(n,10))/2),v.lastChild&&v.lastChild.dataset.xIndex===this.dataset.xIndex&&parseInt(u,10)>parseInt(l,10)&&(d+=-(parseInt(u,10)-parseInt(l,10))/2);var h=v.parentNode;h&&"body"===h.nodeName.toLowerCase()&&(h.firstChild&&h.firstChild.firstChild.dataset.yIndex===this.dataset.yIndex&&parseInt(w,10)>parseInt(s,10)&&(p+=(parseInt(w,10)-parseInt(s,10))/2),h.lastChild&&h.lastChild.firstChild.dataset.yIndex===this.dataset.yIndex&&parseInt(g,10)>parseInt(i,10)&&(p+=(parseInt(g,10)-parseInt(i,10))/2))}}return{width:parseInt(d),height:parseInt(p)}},this},WPTB_DropHandle=function(s,e){var i=void 0,d=void 0;if(0==document.getElementsByClassName("wptb-drop-handle").length){(i=document.createElement("div")).classList.add("wptb-drop-handle"),(d=document.createElement("div")).classList.add("wptb-drop-border-marker");var t=document.createElement("div"),a=document.createElement("div"),n=document.createElement("div"),l=document.createElement("div");t.classList.add("wptb-drop-border-marker-top"),a.classList.add("wptb-drop-border-marker-right"),n.classList.add("wptb-drop-border-marker-bottom"),l.classList.add("wptb-drop-border-marker-left"),d.appendChild(t),d.appendChild(a),d.appendChild(n),d.appendChild(l);var r=document.getElementsByTagName("body");0<r.length&&(r[0].appendChild(i),r[0].appendChild(d)),i.ondragenter=function(){},i.ondragover=function(e){e.preventDefault()},i.ondragleave=function(){},i.ondrop=function(e){e.preventDefault();var t=void 0;e.dataTransfer.getData("wptbElement")?t=(t=WPTB_Helper.newElementProxy(e.dataTransfer.getData("wptbElement"))).getDOMElement():((t=document.getElementsByClassName(e.dataTransfer.getData("node"))[0]).classList.remove("wptb-moving-mode"),t.classList.remove("wptb-moving-into-same-elem"),t.wptbMovingMode=1);var a=void 0;if("Drop Here"==i.dataset.text)"td"==(s=i.getDOMParentElement()).nodeName.toLowerCase()&&(a=i.getDOMParentElement()).appendChild(t);else{var n=i.getDOMParentElement();if(a=n.parentNode,"Above Element"==i.dataset.text)a.insertBefore(t,n);else if("Below Element"==i.dataset.text){var l=n.nextSibling;a.insertBefore(t,l)}}var r=a.parentNode;if(WPTB_Helper.rowIsTop(r)){var o=WPTB_Helper.findAncestor(r,"wptb-preview-table");o.classList.contains("wptb-table-preview-head")&&WPTB_Helper.dataTitleColumnSet(o)}t.className.match(/wptb-element-(.+)-(\d+)/i)[1];(e.dataTransfer.getData("wptbElement"),i.style.display="none",d.style.display="none",WPTB_innerElementSet(t),t.classList.contains("wptb-image-container")&&1!=t.wptbMovingMode)||((new WPTB_TableStateSaveManager).tableStateSet(),t.wptbMovingMode)},document.querySelector(".wptb-container").onscroll=function(){i.style.display="none",d.style.display="none"}}else i=document.getElementsByClassName("wptb-drop-handle")[0],d=document.getElementsByClassName("wptb-drop-border-marker")[0];if(!s||"td"!=s.nodeName.toLowerCase()||0==s.getElementsByClassName("wptb-ph-element").length){var o=void 0;if("td"==s.localName?o=s.parentNode:"div"==s.localName&&s.classList.contains("wptb-ph-element")&&(o=s.parentNode.parentNode),WPTB_Helper.rowIsTop(o))if(WPTB_Helper.findAncestor(o,"wptb-preview-table").classList.contains("wptb-table-prev