WP Table Builder – WordPress Table Plugin - Version 1.1.5

Version Description

  • FIX: Table not Showing issue.
  • FIX: Table Responsiveness issue.
  • FIX: Images not showing on mobile tables.
  • FIX: Cell Padding Settings Value not going under 0.
  • ADD: Getting Started Page with Video.
  • UPDATE: Translation Files.
Download this release

Release Info

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

Code changes from version 1.1.4 to 1.1.5

Files changed (30) hide show
  1. inc/admin/class-admin-menu.php +32 -7
  2. inc/admin/class-tables.php +2 -16
  3. inc/admin/class-wptb-listing.php +0 -4
  4. inc/admin/controls/control-alignment.php +129 -72
  5. inc/admin/controls/control-button.php +1 -3
  6. inc/admin/controls/control-checkbox.php +0 -4
  7. inc/admin/controls/control-number.php +74 -20
  8. inc/admin/controls/control-select.php +176 -15
  9. inc/admin/controls/control-size.php +135 -80
  10. inc/admin/controls/control-text.php +103 -17
  11. inc/admin/controls/control-textarea.php +110 -17
  12. inc/admin/controls/control-toggle.php +137 -57
  13. inc/admin/css/admin-welcome.css +110 -0
  14. inc/admin/css/admin.css +7 -0
  15. inc/admin/element-classes/element-scripts/button-element.js +0 -65
  16. inc/admin/element-classes/element-scripts/custom-html-element.js +7 -9
  17. inc/admin/element-classes/element-scripts/image-element.js +1 -62
  18. inc/admin/element-classes/element-scripts/list-element.js +23 -62
  19. inc/admin/element-classes/element-scripts/shortcode-element.js +15 -1
  20. inc/admin/element-classes/element-scripts/star-rating-element.js +12 -59
  21. inc/admin/element-classes/elements/button-element.php +3 -0
  22. inc/admin/element-classes/elements/custom-html-element.php +3 -0
  23. inc/admin/element-classes/elements/image-element.php +3 -0
  24. inc/admin/element-classes/elements/list-element.php +20 -6
  25. inc/admin/element-classes/elements/shortcode-element.php +3 -0
  26. inc/admin/element-classes/elements/star-rating-element.php +8 -1
  27. inc/admin/js/admin-welcome.js +0 -0
  28. inc/admin/js/admin.js +240 -249
  29. inc/admin/js/admin.js.map +1 -1
  30. inc/admin/js/admin.min.js +0 -1
inc/admin/class-admin-menu.php CHANGED
@@ -46,7 +46,7 @@ class Admin_Menu {
46
 
47
  if( wp_verify_nonce( $params->security_code, 'wptb-security-nonce' ) ) {
48
 
49
- if( ! isset( $params->id ) || ! absint( $params->id ) || get_post_status( absint( $params->id ) ) != 'draft' ) {
50
  $id = wp_insert_post([
51
  'post_title' => sanitize_text_field( $params->title ),
52
  'post_content' => '',
@@ -55,7 +55,6 @@ class Admin_Menu {
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 {
@@ -74,7 +73,6 @@ class Admin_Menu {
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
  }
@@ -87,10 +85,9 @@ class Admin_Menu {
87
  public function get_table() {
88
  $post = get_post( absint( $_REQUEST['id'] ) );
89
  $table_html = get_post_meta( absint( $_REQUEST['id'] ) , '_wptb_content_', true );
90
- $elements_datas = get_post_meta( absint( $_REQUEST['id'] ) , '_wptb_table_elements_datas_', true );
91
  $name = $post->post_title;
92
  //$html = json_decode( $html );
93
- die( json_encode( [$name, $table_html, $elements_datas] ) );
94
  }
95
 
96
 
@@ -134,6 +131,16 @@ class Admin_Menu {
134
  'wptb-builder',
135
  array( $this, 'table_builder' )
136
  );
 
 
 
 
 
 
 
 
 
 
137
 
138
  do_action( 'wptb_admin_menu', $this );
139
 
@@ -159,8 +166,14 @@ class Admin_Menu {
159
  return;
160
  }
161
 
162
-
163
- if( isset( $_GET['page'] ) && sanitize_text_field( $_GET['page'] ) == 'wptb-builder' ) {
 
 
 
 
 
 
164
  wp_register_script( 'wptb-admin-builder-js', plugin_dir_url( __FILE__ ) . 'js/admin.js', array( 'jquery', 'wptb-admin-builder-tinymce-js', 'wp-color-picker' ), NS\PLUGIN_VERSION, true );
165
  wp_register_script( 'wptb-admin-builder-tinymce-js', plugin_dir_url( __FILE__ ) . 'js/tinymce/tinymce.min.js', array(), NS\PLUGIN_VERSION, false );
166
  wp_register_script( 'wptb-admin-builder-tinymce-jquery-js', plugin_dir_url( __FILE__ ) . 'js/tinymce/jquery.tinymce.min.js', array(), NS\PLUGIN_VERSION, false );
@@ -180,9 +193,12 @@ class Admin_Menu {
180
  'security_code' => wp_create_nonce( 'wptb-security-nonce' ),
181
  ]
182
  );
 
183
  } elseif( isset( $_GET['page'] ) && sanitize_text_field( $_GET['page'] ) == 'wptb-overview' ) {
 
184
  wp_enqueue_script( 'wptb-overview-js', plugin_dir_url( __FILE__ ) . 'js/wptb-overview.js', array( 'jquery' ), NS\PLUGIN_VERSION, true );
185
  wp_enqueue_style( 'wptb-admin-common-css', plugin_dir_url( __FILE__ ) . 'css/admin-common.css', array(), NS\PLUGIN_VERSION, 'all' );
 
186
  }
187
 
188
  }
@@ -225,4 +241,13 @@ class Admin_Menu {
225
  require_once NS\WP_TABLE_BUILDER_DIR . 'inc/admin/views/wptb-builder-ui.php';
226
  }
227
 
 
 
 
 
 
 
 
 
 
228
  };
46
 
47
  if( wp_verify_nonce( $params->security_code, 'wptb-security-nonce' ) ) {
48
 
49
+ if( ! property_exists( $params, 'id') || ! absint( $params->id ) || get_post_status( absint( $params->id ) ) != 'draft' ) {
50
  $id = wp_insert_post([
51
  'post_title' => sanitize_text_field( $params->title ),
52
  'post_content' => '',
55
  ]);
56
 
57
  add_post_meta( $id, '_wptb_content_', $params->content );
 
58
 
59
  wp_die( json_encode( ['saved', $id] ) );
60
  } else {
73
  wp_die( json_encode( ['preview_edited'] ) );
74
  } else {
75
  update_post_meta( absint( $params->id ), '_wptb_content_', $params->content );
 
76
 
77
  wp_die( json_encode( ['edited', absint( $params->id )] ) );
78
  }
85
  public function get_table() {
86
  $post = get_post( absint( $_REQUEST['id'] ) );
87
  $table_html = get_post_meta( absint( $_REQUEST['id'] ) , '_wptb_content_', true );
 
88
  $name = $post->post_title;
89
  //$html = json_decode( $html );
90
+ die( json_encode( [$name, $table_html] ) );
91
  }
92
 
93
 
131
  'wptb-builder',
132
  array( $this, 'table_builder' )
133
  );
134
+
135
+ // Add Welcome sub menu item.
136
+ $builder_page = add_submenu_page(
137
+ null,
138
+ esc_html__( 'Table Builder', 'wp-table-builder' ),
139
+ esc_html__( 'Add New', 'wp-table-builder' ),
140
+ $menu_cap,
141
+ 'wp-table-builder-welcome',
142
+ array( $this, 'welcome' )
143
+ );
144
 
145
  do_action( 'wptb_admin_menu', $this );
146
 
166
  return;
167
  }
168
 
169
+
170
+ if ( isset( $_GET['page'] ) && sanitize_text_field( $_GET['page'] ) == 'wp-table-builder-welcome' ) {
171
+
172
+ //wp_enqueue_script( 'wptb-admin-welcome-js', plugin_dir_url( __FILE__ ) . 'js/admin-welcome.js', array( 'jquery' ), NS\PLUGIN_VERSION, true );
173
+ wp_enqueue_style( 'wptb-admin-welcome-css', plugin_dir_url( __FILE__ ) . 'css/admin-welcome.css', array(), NS\PLUGIN_VERSION, 'all' );
174
+
175
+ } elseif ( isset( $_GET['page'] ) && sanitize_text_field( $_GET['page'] ) == 'wptb-builder' ) {
176
+
177
  wp_register_script( 'wptb-admin-builder-js', plugin_dir_url( __FILE__ ) . 'js/admin.js', array( 'jquery', 'wptb-admin-builder-tinymce-js', 'wp-color-picker' ), NS\PLUGIN_VERSION, true );
178
  wp_register_script( 'wptb-admin-builder-tinymce-js', plugin_dir_url( __FILE__ ) . 'js/tinymce/tinymce.min.js', array(), NS\PLUGIN_VERSION, false );
179
  wp_register_script( 'wptb-admin-builder-tinymce-jquery-js', plugin_dir_url( __FILE__ ) . 'js/tinymce/jquery.tinymce.min.js', array(), NS\PLUGIN_VERSION, false );
193
  'security_code' => wp_create_nonce( 'wptb-security-nonce' ),
194
  ]
195
  );
196
+
197
  } elseif( isset( $_GET['page'] ) && sanitize_text_field( $_GET['page'] ) == 'wptb-overview' ) {
198
+
199
  wp_enqueue_script( 'wptb-overview-js', plugin_dir_url( __FILE__ ) . 'js/wptb-overview.js', array( 'jquery' ), NS\PLUGIN_VERSION, true );
200
  wp_enqueue_style( 'wptb-admin-common-css', plugin_dir_url( __FILE__ ) . 'css/admin-common.css', array(), NS\PLUGIN_VERSION, 'all' );
201
+
202
  }
203
 
204
  }
241
  require_once NS\WP_TABLE_BUILDER_DIR . 'inc/admin/views/wptb-builder-ui.php';
242
  }
243
 
244
+ /**
245
+ * Wrapper for the hook to render our plugin welcome page.
246
+ *
247
+ * @since 1.1.5
248
+ */
249
+ public function welcome() {
250
+ require_once NS\WP_TABLE_BUILDER_DIR . 'inc/admin/views/wptb-welcome.php';
251
+ }
252
+
253
  };
inc/admin/class-tables.php CHANGED
@@ -101,7 +101,7 @@ class Tables {
101
  do_action( 'wptb_frontend_enqueue_script' );
102
  $html = get_post_meta( $args['id'] , '_wptb_content_', true );
103
 
104
- if ( preg_match_all( '|<wptb_shortcode_container_element>(.+)</wptb_shortcode_container_element>|isU', $html, $arr ) ) {
105
  foreach ( $arr[1] as $value ) {
106
  if( ! isset( $args['internal_shortcodes_stop'] ) && $value ) {
107
  $pattern = get_shortcode_regex();
@@ -134,21 +134,7 @@ class Tables {
134
  . '<a href="' . admin_url( 'admin.php?page=wptb-builder&table=' . $args['id'] ) . '">' . __( "Edit Table", 'wp-table-builder' ) . '</a></div>';
135
  }
136
  $html = '<div class="wptb-table-container wptb-table-' . $args['id'] . '"><div class="wptb-table-container-matrix">' . $html . '</div></div>'. $post_edit_link;
137
- $html .= '<script>'
138
- . 'var wptbContainer = document.getElementsByClassName( "wptb-table-' . $args['id'] . '" );'
139
- . 'if( wptbContainer.length > 0 ) {'
140
- . ' wptbContainer = wptbContainer[0];'
141
- . ' var wptbPreviewTable = wptbContainer.getElementsByClassName( "wptb-preview-table" );'
142
- . ' if( wptbPreviewTable.length > 0 ) {'
143
- . ' wptbPreviewTable = wptbPreviewTable[0];'
144
- . ' if( wptbPreviewTable.dataset.wptbTableContainerMaxWidth ) {'
145
- . ' wptbContainer.style.maxWidth = wptbPreviewTable.dataset.wptbTableContainerMaxWidth + "px";'
146
- . ' }'
147
- . ' wptbPreviewTable.classList.remove( "wptb-table-preview-static-indic" );'
148
- . ' wptbPreviewTable.style.display = "none";'
149
- . ' }'
150
- . '}'
151
- . '</script>';
152
  return ( $html );
153
  }
154
 
101
  do_action( 'wptb_frontend_enqueue_script' );
102
  $html = get_post_meta( $args['id'] , '_wptb_content_', true );
103
 
104
+ if ( preg_match_all( '|<wptb_shortcode_container_element(.+)</wptb_shortcode_container_element>|isU', $html, $arr ) ) {
105
  foreach ( $arr[1] as $value ) {
106
  if( ! isset( $args['internal_shortcodes_stop'] ) && $value ) {
107
  $pattern = get_shortcode_regex();
134
  . '<a href="' . admin_url( 'admin.php?page=wptb-builder&table=' . $args['id'] ) . '">' . __( "Edit Table", 'wp-table-builder' ) . '</a></div>';
135
  }
136
  $html = '<div class="wptb-table-container wptb-table-' . $args['id'] . '"><div class="wptb-table-container-matrix">' . $html . '</div></div>'. $post_edit_link;
137
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
138
  return ( $html );
139
  }
140
 
inc/admin/class-wptb-listing.php CHANGED
@@ -57,12 +57,8 @@ class WPTB_Listing extends \WP_List_Table{
57
  'post_status' => 'draft'
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([
57
  'post_status' => 'draft'
58
  ]);
59
  $table = get_post_meta( absint( $id ) , '_wptb_content_', true );
 
 
60
 
61
  $table_new = add_post_meta( $id_new, '_wptb_content_', $table );
 
 
62
 
63
  if( $id_new && $table_new ) {
64
  wp_update_post([
inc/admin/controls/control-alignment.php CHANGED
@@ -54,6 +54,7 @@ class Control_Alignment extends Base_Control {
54
  <#
55
  let label,
56
  selector,
 
57
  selected0,
58
  selected1,
59
  selected2,
@@ -78,23 +79,16 @@ class Control_Alignment extends Base_Control {
78
  }
79
  }
80
 
 
81
  for ( let prop in data.selectors ) {
82
- selector = prop;
83
- styleAlignment = data.selectors[prop];
 
 
84
  }
85
 
86
- if( styleAlignment == 'text-align' || styleAlignment.indexOf( 'data-' ) === 0 ) {
87
- left = 'left';
88
- center = 'center';
89
- right = 'right';
90
- } else if( styleAlignment == 'justify-content' ) {
91
- left = 'flex-start';
92
- center = 'center';
93
- right = 'flex-end';
94
- } else if( styleAlignment == 'float' ) {
95
- left = 'left';
96
- center = 'none';
97
- right = 'right';
98
  }
99
 
100
  targetAddClass = data.elementControlTargetUnicClass;
@@ -118,15 +112,15 @@ class Control_Alignment extends Base_Control {
118
  <div class="wptb-settings-row wptb-settings-middle-xs" style="padding-bottom: 0px; padding-top: 23px;">
119
  <ul>
120
  <li class="wptb-btn-size-btn wptb-element-property wptb-btn-size-switcher
121
- {{{selected0}}} {{{targetAddClass}}}" data-alignment-value="{{{left}}}">
122
  <?php echo $left_align_image_svg; ?>
123
  </li>
124
  <li class="wptb-btn-size-btn wptb-element-property wptb-btn-size-switcher
125
- {{{selected1}}} {{{targetAddClass}}}" data-alignment-value="{{{center}}}">
126
  <?php echo $center_align_image_svg; ?>
127
  </li>
128
  <li class="wptb-btn-size-btn wptb-element-property wptb-btn-size-switcher
129
- {{{selected2}}} {{{targetAddClass}}}" data-alignment-value="{{{right}}}">
130
  <?php echo $right_align_image_svg; ?>
131
  </li>
132
  </ul>
@@ -135,72 +129,135 @@ class Control_Alignment extends Base_Control {
135
  <wptb-template-script>
136
  ( function() {
137
  let buttons = document.getElementsByClassName( '{{{targetAddClass}}}' );
138
- let selectorEl = document.querySelectorAll( '{{{selector}}}' );
139
- let selectedButtonAlignment;
140
- if( selectorEl.length && '{{{styleAlignment}}}' ) {
141
- for( let i = 0; i < selectorEl.length; i++ ) {
142
- if( i === 0 ) {
143
- if( '{{{styleAlignment}}}'.indexOf( 'data-' ) === 0 ) {
144
- selectedButtonAlignment = selectorEl[i].getAttribute( '{{{styleAlignment}}}' );
145
- } else {
146
- selectedButtonAlignment = selectorEl[i].style['{{{styleAlignment}}}'];
147
- }
148
- }
149
-
150
- if( i > 0 ) {
151
- if( '{{{styleAlignment}}}'.indexOf( 'data-' ) === 0 ) {
152
- if ( selectedButtonAlignment != selectorEl[i].getAttribute( '{{{styleAlignment}}}' ) ) {
153
- selectedButtonAlignment = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154
  }
155
- } else {
156
- if ( selectedButtonAlignment != selectorEl[i].style['{{{styleAlignment}}}'] ) {
157
- selectedButtonAlignment = false;
158
  }
159
  }
160
- }
161
- }
162
-
163
- }
 
 
 
164
 
165
- for ( var i = 0; i < buttons.length; i++ ) {
166
- if( selectedButtonAlignment ) {
167
- buttons[i].classList.remove( 'selected' );
 
 
 
168
 
169
- if( selectedButtonAlignment == buttons[i].dataset.alignmentValue ) {
170
- buttons[i].classList.add( 'selected' );
171
- }
172
- }
 
 
 
 
 
 
 
 
 
 
 
173
 
174
- buttons[i].onclick = function () {
175
- let selectorEl = document.querySelectorAll( '{{{selector}}}' );
176
- if( selectorEl.length > 0 && '{{{styleAlignment}}}' ) {
177
- let buttonDataAlignment = this.dataset.alignmentValue;
178
-
179
- for( let i = 0; i < selectorEl.length; i++ ) {
180
- if( '{{{styleAlignment}}}'.indexOf( 'data-' ) === 0 ) {
181
- selectorEl[i].setAttribute( '{{{styleAlignment}}}', buttonDataAlignment );
182
- } else {
183
- selectorEl[i].style['{{{styleAlignment}}}'] = buttonDataAlignment;
184
  }
185
  }
186
-
187
- var b = this.parentNode.getElementsByClassName( 'wptb-btn-size-btn' );
188
- for ( let i = 0; i < b.length; i++ ) {
189
- b[i].classList.remove( 'selected' );
190
- }
191
- this.classList.add( 'selected' );
192
-
193
- let details = {value: buttonDataAlignment};
194
- WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetAddClass}}}', selectorEl[0], details );
195
- WPTB_Helper.controlsStateManager( '{{{targetAddClass}}}', true );
196
-
197
- let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
198
- wptbTableStateSaveManager.tableStateSet();
199
  }
200
  }
201
  }
202
-
203
- WPTB_Helper.controlsStateManager( '{{{targetAddClass}}}' );
204
  } )();
205
  </wptb-template-script>
206
  <?php
54
  <#
55
  let label,
56
  selector,
57
+ selectors = [],
58
  selected0,
59
  selected1,
60
  selected2,
79
  }
80
  }
81
 
82
+ let i = 0;
83
  for ( let prop in data.selectors ) {
84
+ selectors[i] = [];
85
+ selectors[i][0] = prop;
86
+ selectors[i][1] = data.selectors[prop];
87
+ i++;
88
  }
89
 
90
+ if( selectors && Array.isArray( selectors ) ) {
91
+ selectorsJson = JSON.stringify( selectors );
 
 
 
 
 
 
 
 
 
 
92
  }
93
 
94
  targetAddClass = data.elementControlTargetUnicClass;
112
  <div class="wptb-settings-row wptb-settings-middle-xs" style="padding-bottom: 0px; padding-top: 23px;">
113
  <ul>
114
  <li class="wptb-btn-size-btn wptb-element-property wptb-btn-size-switcher
115
+ {{{selected0}}} {{{targetAddClass}}}" data-alignment-value="left" data-element="{{{elemContainer}}}">
116
  <?php echo $left_align_image_svg; ?>
117
  </li>
118
  <li class="wptb-btn-size-btn wptb-element-property wptb-btn-size-switcher
119
+ {{{selected1}}} {{{targetAddClass}}}" data-alignment-value="center" data-element="{{{elemContainer}}}">
120
  <?php echo $center_align_image_svg; ?>
121
  </li>
122
  <li class="wptb-btn-size-btn wptb-element-property wptb-btn-size-switcher
123
+ {{{selected2}}} {{{targetAddClass}}}" data-alignment-value="right" data-element="{{{elemContainer}}}">
124
  <?php echo $right_align_image_svg; ?>
125
  </li>
126
  </ul>
129
  <wptb-template-script>
130
  ( function() {
131
  let buttons = document.getElementsByClassName( '{{{targetAddClass}}}' );
132
+ if( buttons.length > 0 ) {
133
+ let dataSelectorElement = buttons[0].dataset.element;
134
+ if( dataSelectorElement ) {
135
+ let selectorElement = document.querySelector( '.' + dataSelectorElement );
136
+ if( selectorElement ) {
137
+ function getSetElementValue( selectors, value ) {
138
+ if( selectors && Array.isArray( selectors ) ) {
139
+ for( let i = 0; i < selectors.length; i++ ) {
140
+ if( selectors[i] && Array.isArray( selectors[i] ) && typeof selectors[i][0] != 'undefined' && typeof selectors[i][1] != 'undefined' ) {
141
+ let selectorElements = document.querySelectorAll( selectors[i][0] );
142
+ if( selectorElements.length > 0 ) {
143
+ for( let j = 0; j < selectorElements.length; j++ ) {
144
+ if( value ) {
145
+ let convertValue;
146
+ if( selectors[i][1] == 'justify-content' ) {
147
+ if( value == 'left' ) {
148
+ convertValue = 'flex-start';
149
+ } else if( value == 'center' ) {
150
+ convertValue = 'center';
151
+ } else if( value == 'right' ) {
152
+ convertValue = 'flex-end';
153
+ }
154
+ } else if ( selectors[i][1] == 'float' ) {
155
+ if( value == 'left' ) {
156
+ convertValue = 'left';
157
+ } else if( value == 'center' ) {
158
+ convertValue = 'none';
159
+ } else if( value == 'right' ) {
160
+ convertValue = 'right';
161
+ }
162
+ } else {
163
+ if( value == 'left' ) {
164
+ convertValue = 'left';
165
+ } else if( value == 'center' ) {
166
+ convertValue = 'center';
167
+ } else if( value == 'right' ) {
168
+ convertValue = 'right';
169
+ }
170
+ }
171
+
172
+ if( typeof selectorElements[j].style[selectors[i][1]] != 'undefined' ) {
173
+ selectorElements[j].style[selectors[i][1]] = convertValue;
174
+ } else {
175
+ selectorElements[j].setAttribute( selectors[i][1], convertValue );
176
+ }
177
+ } else {
178
+ let gettingElementValue;
179
+ if( typeof selectorElements[j].style[selectors[i][1]] != 'undefined' ) {
180
+ gettingElementValue = selectorElements[j].style[selectors[i][1]];
181
+ } else {
182
+ gettingElementValue = selectorElements[j].getAttribute( selectors[i][1] );
183
+ }
184
+
185
+ if( selectors[i][1] == 'justify-content' ) {
186
+ if( gettingElementValue == 'flex-start' ) {
187
+ return 'left';
188
+ } else if( gettingElementValue == 'center' ) {
189
+ return 'center';
190
+ } else if( gettingElementValue == 'flex-end' ) {
191
+ return 'right';
192
+ }
193
+ } else if ( selectors[i][1] == 'float' ) {
194
+ if( gettingElementValue == 'left' ) {
195
+ return 'left';
196
+ } else if( gettingElementValue == 'none' ) {
197
+ return 'center';
198
+ } else if( gettingElementValue == 'right' ) {
199
+ return 'right';
200
+ }
201
+ } else {
202
+ if( gettingElementValue == 'left' ) {
203
+ return 'left';
204
+ } else if( gettingElementValue == 'center' ) {
205
+ return 'center';
206
+ } else if( gettingElementValue == 'right' ) {
207
+ return 'right';
208
+ }
209
+ }
210
+ }
211
+ }
212
+ }
213
+ }
214
+ }
215
+ } else {
216
+ return false;
217
  }
218
+
219
+ if( ! value ) {
220
+ return false;
221
  }
222
  }
223
+
224
+ let valueSetting;
225
+ if( '{{{selectorsJson}}}' ) {
226
+ let selectors = JSON.parse( '{{{selectorsJson}}}' );
227
+
228
+ valueSetting = getSetElementValue( selectors );
229
+ }
230
 
231
+ for ( var i = 0; i < buttons.length; i++ ) {
232
+ buttons[i].classList.remove( 'selected' );
233
+
234
+ if( valueSetting == buttons[i].dataset.alignmentValue ) {
235
+ buttons[i].classList.add( 'selected' );
236
+ }
237
 
238
+ buttons[i].onclick = function () {
239
+ var b = this.parentNode.getElementsByClassName( 'wptb-btn-size-btn' );
240
+ for ( let i = 0; i < b.length; i++ ) {
241
+ b[i].classList.remove( 'selected' );
242
+ }
243
+ this.classList.add( 'selected' );
244
+
245
+ if( this.dataset.alignmentValue && '{{{selectorsJson}}}' ) {
246
+ let selectors = JSON.parse( '{{{selectorsJson}}}' );
247
+ getSetElementValue( selectors, this.dataset.alignmentValue );
248
+
249
+ let details = {value: this.dataset.alignmentValue};
250
+ console.log( '{{{targetAddClass}}}' );
251
+ WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetAddClass}}}', selectorElement, details );
252
+ }
253
 
254
+ let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
255
+ wptbTableStateSaveManager.tableStateSet();
 
 
 
 
 
 
 
 
256
  }
257
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
258
  }
259
  }
260
  }
 
 
261
  } )();
262
  </wptb-template-script>
263
  <?php
inc/admin/controls/control-button.php CHANGED
@@ -65,7 +65,7 @@ class Control_Button extends Base_Control {
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
 
@@ -81,8 +81,6 @@ class Control_Button extends Base_Control {
81
  targetInput.onclick = function( event ) {
82
  WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement );
83
  };
84
-
85
- WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}' );
86
  }
87
  }
88
  }
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-element-property wptb-button {{{targetInputAddClass}}}" data-element="{{{elemContainer}}}" value="{{{label}}}" title="{{{label}}}">
69
  </div>
70
  </div>
71
 
81
  targetInput.onclick = function( event ) {
82
  WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement );
83
  };
 
 
84
  }
85
  }
86
  }
inc/admin/controls/control-checkbox.php CHANGED
@@ -137,13 +137,9 @@ class Control_Checkbox extends Base_Control {
137
 
138
  WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement, details );
139
 
140
- WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}', true );
141
-
142
  let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
143
  wptbTableStateSaveManager.tableStateSet();
144
  };
145
-
146
- WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}' );
147
  }
148
  }
149
  }
137
 
138
  WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement, details );
139
 
 
 
140
  let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
141
  wptbTableStateSaveManager.tableStateSet();
142
  };
 
 
143
  }
144
  }
145
  }
inc/admin/controls/control-number.php CHANGED
@@ -51,6 +51,8 @@ class Control_Number extends Base_Control {
51
  ?>
52
  <#
53
  let label,
 
 
54
  min,
55
  max,
56
  defaultValue,
@@ -62,6 +64,20 @@ class Control_Number extends Base_Control {
62
  label = data.label;
63
  }
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  if( data.min ) {
66
  min = data.min;
67
  }
@@ -100,30 +116,68 @@ class Control_Number extends Base_Control {
100
  <wptb-template-script>
101
  ( function() {
102
  let targetInputs = document.getElementsByClassName( '{{{targetInputAddClass}}}' );
103
- if( targetInputs.length > 0 ) {
104
- targetInput = targetInputs[0];
105
- let dataSelectorElement = targetInput.dataset.element;
106
- if( dataSelectorElement ) {
107
- let selectorElement = document.querySelector( '.' + dataSelectorElement );
108
- if( selectorElement ) {
109
- targetInput.oninput = function( event ) {
110
- if( parseInt( this.value ) < parseInt( '{{{min}}}' ) ) {
111
- this.value = parseInt( '{{{min}}}' );
112
- } else if( parseInt( this.value ) > parseInt( '{{{max}}}' ) ) {
113
- this.value = parseInt ( '{{{max}}}' );
 
 
 
 
 
 
 
 
114
  }
115
-
116
- let details = {value: this.value};
117
- WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement, details );
118
 
119
- WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}', true );
120
-
121
- let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
122
- wptbTableStateSaveManager.tableStateSet();
123
- };
 
 
 
 
 
 
124
 
125
- WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}' );
 
 
 
 
126
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
  }
128
  }
129
  } )();
51
  ?>
52
  <#
53
  let label,
54
+ selectors = [],
55
+ selectorsJson,
56
  min,
57
  max,
58
  defaultValue,
64
  label = data.label;
65
  }
66
 
67
+ if( data.selectors && typeof data.selectors === 'object' ) {
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
+
77
+ if( selectors && Array.isArray( selectors ) ) {
78
+ selectorsJson = JSON.stringify( selectors );
79
+ }
80
+
81
  if( data.min ) {
82
  min = data.min;
83
  }
116
  <wptb-template-script>
117
  ( function() {
118
  let targetInputs = document.getElementsByClassName( '{{{targetInputAddClass}}}' );
119
+ if( targetInputs.length > 0 && targetInputs[0].dataset.element ) {
120
+ let targetInput = targetInputs[0];
121
+ let selectorElement = document.querySelector( '.' + targetInput.dataset.element );
122
+ if( selectorElement ) {
123
+ function getSetElementValue( selectors, value ) {
124
+ if( selectors && Array.isArray( selectors ) ) {
125
+ for( let i = 0; i < selectors.length; i++ ) {
126
+ if( selectors[i] && Array.isArray( selectors[i] ) && typeof selectors[i][0] != 'undefined' && selectors[i][1] != 'undefined' ) {
127
+ let selectorElements = document.querySelectorAll( selectors[i][0] );
128
+ if( selectorElements.length > 0 ) {
129
+ for( let j = 0; j < selectorElements.length; j++ ) {
130
+ if( value ) {
131
+ selectorElements[j].setAttribute( selectors[i][1], value );
132
+ } else if( selectorElements[j].getAttribute( selectors[i][1] ) ) {
133
+ return selectorElements[j].getAttribute( selectors[i][1] );
134
+ }
135
+ }
136
+ }
137
+ }
138
  }
139
+ } else {
140
+ return false;
141
+ }
142
 
143
+ if( ! value ) {
144
+ return false;
145
+ }
146
+ }
147
+
148
+ let selectorElementSettingValue;
149
+ if( '{{{selectorsJson}}}' ) {
150
+ console.log( "Hello" );
151
+ let selectors = JSON.parse( '{{{selectorsJson}}}' );
152
+
153
+ selectorElementSettingValue = getSetElementValue( selectors );
154
 
155
+ if( selectorElementSettingValue ) {
156
+ targetInput.value = selectorElementSettingValue;
157
+ } else if( '{{{defaultValue}}}' ) {
158
+ targetInput.value = '{{{defaultValue}}}';
159
+ }
160
  }
161
+
162
+ targetInput.oninput = function( event ) {
163
+ if( parseInt( this.value ) < parseInt( '{{{min}}}' ) ) {
164
+ this.value = parseInt( '{{{min}}}' );
165
+ } else if( parseInt( this.value ) > parseInt( '{{{max}}}' ) ) {
166
+ this.value = parseInt ( '{{{max}}}' );
167
+ }
168
+
169
+ let details = {value: this.value};
170
+ WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement, details );
171
+ if( '{{{selectorsJson}}}' ) {
172
+ let selectors = JSON.parse( '{{{selectorsJson}}}' );
173
+
174
+ getSetElementValue( selectors, details.value );
175
+ }
176
+
177
+
178
+ let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
179
+ wptbTableStateSaveManager.tableStateSet();
180
+ };
181
  }
182
  }
183
  } )();
inc/admin/controls/control-select.php CHANGED
@@ -53,6 +53,7 @@ class Control_Select extends Base_Control {
53
  <#
54
  let label,
55
  options = [],
 
56
  selectedDefault,
57
  targetSelectAddClass;
58
 
@@ -64,6 +65,24 @@ class Control_Select extends Base_Control {
64
  options = data.options;
65
  }
66
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67
  if( data.selectedDefault ) {
68
  selectedDefault = data.selectedDefault;
69
  }
@@ -113,24 +132,166 @@ class Control_Select extends Base_Control {
113
  <wptb-template-script>
114
  ( function() {
115
  let targetSelects = document.getElementsByClassName( '{{{targetSelectAddClass}}}' );
116
- if( targetSelects.length > 0 ) {
117
- targetSelect = targetSelects[0];
118
- let dataSelectorElement = targetSelect.dataset.element;
119
- if( dataSelectorElement ) {
120
- let selectorElement = document.querySelector( '.' + dataSelectorElement );
121
- if( selectorElement ) {
122
- targetSelect.onchange = function( event ) {
123
- let details = {value: this.value};
124
- WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetSelectAddClass}}}', selectorElement, details );
125
-
126
- WPTB_Helper.controlsStateManager( '{{{targetSelectAddClass}}}', true );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127
 
128
- let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
129
- wptbTableStateSaveManager.tableStateSet();
130
- };
 
 
 
 
 
 
 
131
 
132
- WPTB_Helper.controlsStateManager( '{{{targetSelectAddClass}}}' );
 
 
 
 
 
 
 
 
 
 
133
  }
 
 
 
 
 
 
 
 
134
  }
135
  }
136
  } )();
53
  <#
54
  let label,
55
  options = [],
56
+ selectors = [],
57
  selectedDefault,
58
  targetSelectAddClass;
59
 
65
  options = data.options;
66
  }
67
 
68
+ if( options && Array.isArray( options ) ) {
69
+ optionsJson = JSON.stringify( options );
70
+ }
71
+
72
+ if( data.selectors && typeof data.selectors === 'object' ) {
73
+ let i = 0;
74
+ for ( let prop in data.selectors ) {
75
+ selectors[i] = [];
76
+ selectors[i][0] = prop;
77
+ selectors[i][1] = data.selectors[prop];
78
+ i++;
79
+ }
80
+ }
81
+
82
+ if( selectors && Array.isArray( selectors ) ) {
83
+ selectorsJson = JSON.stringify( selectors );
84
+ }
85
+
86
  if( data.selectedDefault ) {
87
  selectedDefault = data.selectedDefault;
88
  }
132
  <wptb-template-script>
133
  ( function() {
134
  let targetSelects = document.getElementsByClassName( '{{{targetSelectAddClass}}}' );
135
+ if( targetSelects.length > 0 && targetSelects[0].dataset.element ) {
136
+ let targetSelect = targetSelects[0];
137
+ let selectorElement = document.querySelector( '.' + targetSelect.dataset.element );
138
+ if( selectorElement ) {
139
+ function getSetElementValue( options, selectors, value ) {
140
+ if( typeof selectors != 'undefined' && Array.isArray( selectors ) && typeof options != 'undefined' && Array.isArray( options ) ) {
141
+ let optionsElementAttr = [];
142
+ for( let i = 0; i < options.length; i++ ) {
143
+ if( typeof options[i] != 'undefined' && typeof options[i][2] != 'undefined' ) {
144
+ optionsElementAttr[i] = options[i][2];
145
+ }
146
+ }
147
+
148
+ for( let i = 0; i < selectors.length; i++ ) {
149
+ if( selectors[i] && Array.isArray( selectors[i] ) && typeof selectors[i][0] != 'undefined' ) {
150
+ let selectorElements = document.querySelectorAll( selectors[i][0] );
151
+ if( selectorElements.length > 0 && optionsElementAttr.length > 0 ) {
152
+ for( let j = 0; j < selectorElements.length; j++ ) {
153
+ if( typeof selectors[i][1] != 'undefined' && selectors[i][1] == 'class' ) {
154
+ if( value ) {
155
+ let valueSet;
156
+ for( let k = 0; k < optionsElementAttr.length; k++ ) {
157
+ if( optionsElementAttr[k] && Array.isArray( optionsElementAttr[k] ) ) {
158
+ for( let n = 0; n < optionsElementAttr[k].length; n++ ) {
159
+ if( optionsElementAttr[k][n] ) {
160
+ selectorElements[j].classList.remove( optionsElementAttr[k][n] );
161
+ }
162
+ }
163
+
164
+ if( options[k][1] == value ) {
165
+ for( let n = 0; n < options[k][2].length; n++ ) {
166
+ if( options[k][2][n] ) {
167
+ valueSet = options[k][2][n];
168
+ break;
169
+ }
170
+ }
171
+ }
172
+ } else {
173
+ if( optionsElementAttr[k] ) {
174
+ selectorElements[j].classList.remove( optionsElementAttr[k] );
175
+ }
176
+
177
+ if( options[k][1] == value && options[k][2] ) {
178
+ valueSet = options[k][2];
179
+ }
180
+ }
181
+ }
182
+
183
+ if( valueSet ) {
184
+ selectorElements[j].classList.add( valueSet );
185
+ }
186
+ } else {
187
+ for( let k = 0; k < optionsElementAttr.length; k++ ) {
188
+ if( optionsElementAttr[k] && Array.isArray( optionsElementAttr[k] ) ) {
189
+ for( let n = 0; n < optionsElementAttr[k].length; n++ ) {
190
+ if( selectorElements[j].classList.contains( optionsElementAttr[k][n] ) ) {
191
+ if( typeof options[k][1] != 'undefined' ) {
192
+ return options[k][1];
193
+ }
194
+ }
195
+ }
196
+ } else {
197
+ if( selectorElements[j].classList.contains( optionsElementAttr[k] ) ) {
198
+ if( typeof options[k][1] != 'undefined' ) {
199
+ return options[k][1];
200
+ }
201
+ }
202
+ }
203
+ }
204
+ }
205
+ } else if( typeof selectors[i][1] != 'undefined' && Array.isArray( selectors[i][1] ) ) {
206
+ if( typeof selectors[i][1][0] != 'undefined' && typeof selectors[i][1][1] != 'undefined' ) {
207
+
208
+ }
209
+ } else if( typeof selectors[i][1] != 'undefined' && selectors[i][1] ){
210
+ if( value ) {
211
+ let valueSet;
212
+ for( let k = 0; k < optionsElementAttr.length; k++ ) {
213
+ if( optionsElementAttr[k] && Array.isArray( optionsElementAttr[k] ) ) {
214
+ selectorElements[j].removeAttribute( selectors[i][1] );
215
+
216
+ if( options[k][1] == value ) {
217
+ for( let n = 0; n < options[k][2].length; n++ ) {
218
+ if( options[k][2][n] ) {
219
+ valueSet = options[k][2][n];
220
+ break;
221
+ }
222
+ }
223
+ }
224
+ } else {
225
+ selectorElements[j].removeAttribute( selectors[i][1] );
226
+
227
+ if( options[k][1] == value && options[k][2] ) {
228
+ valueSet = options[k][2];
229
+ }
230
+ }
231
+ }
232
+
233
+ if( valueSet ) {
234
+ selectorElements[j].setAttribute( selectors[i][1], valueSet );
235
+ }
236
+ } else {
237
+ for( let k = 0; k < optionsElementAttr.length; k++ ) {
238
+ if( optionsElementAttr[k] && Array.isArray( optionsElementAttr[k] ) ) {
239
+ for( let n = 0; n < optionsElementAttr[k].length; n++ ) {
240
+ if( selectorElements[j].getAttribute( selectors[i][1] ) == optionsElementAttr[k][n] ) {
241
+ if( typeof options[k][1] != 'undefined' ) {
242
+ return options[k][1];
243
+ }
244
+ }
245
+ }
246
+ } else {
247
+ if( selectorElements[j].getAttribute( selectors[i][1] ) == optionsElementAttr[k] ) {
248
+ if( typeof options[k][1] != 'undefined' ) {
249
+ return options[k][1];
250
+ }
251
+ }
252
+ }
253
+ }
254
+ }
255
+ }
256
+ }
257
+ }
258
+ }
259
+ }
260
+ } else {
261
+ return false;
262
+ }
263
 
264
+ if( ! value ) {
265
+ return false;
266
+ }
267
+ }
268
+
269
+ let options,
270
+ selectors;
271
+ if( '{{{optionsJson}}}' && '{{{selectorsJson}}}' ) {
272
+ options = JSON.parse( '{{{optionsJson}}}' );
273
+ selectors = JSON.parse( '{{{selectorsJson}}}' );
274
 
275
+ let selectValue = getSetElementValue( options, selectors );
276
+
277
+ if( selectValue ) {
278
+ for( let i = 0; i < targetSelect.options.length; i++ ) {
279
+ targetSelect.options[i].removeAttribute( 'selected' );
280
+
281
+ if( targetSelect.options[i].value == selectValue ) {
282
+ targetSelect.options[i].setAttribute( 'selected', 'selected' );
283
+ }
284
+ }
285
+ }
286
  }
287
+
288
+ targetSelect.onchange = function( event ) {
289
+ let details = {value: this.value};
290
+ WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetSelectAddClass}}}', selectorElement, details );
291
+ getSetElementValue( options, selectors, this.value );
292
+ let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
293
+ wptbTableStateSaveManager.tableStateSet();
294
+ };
295
  }
296
  }
297
  } )();
inc/admin/controls/control-size.php CHANGED
@@ -9,7 +9,7 @@ if ( ! defined( 'WPINC' ) ) {
9
  /**
10
  * WP Table Builder size control.
11
  *
12
- * A control class for creating size control objects
13
  * for showing size field on the left panel. This fiels set css value for html tag.
14
  * When this control adds for element, there is opportunity to point css type (width or fontSize ...)
15
  * and also to point dimension of value
@@ -39,7 +39,7 @@ class Control_Size extends Base_Control {
39
  * @access public
40
  */
41
  public function enqueue() {
42
-
43
  }
44
 
45
  /**
@@ -53,26 +53,32 @@ class Control_Size extends Base_Control {
53
  public function content_template() {
54
  ?>
55
  <#
56
- let selector,
57
- cssSetting,
58
- label,
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 ) {
68
- selector = prop;
69
- cssSetting = data.selectors[prop];
 
 
70
  }
71
  }
72
-
73
- if( data.label ) {
74
- label = data.label;
75
  }
 
76
  if( data.max ) {
77
  max = data.max;
78
  } else {
@@ -93,101 +99,150 @@ class Control_Size extends Base_Control {
93
  } else {
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
-
108
  <div class='wptb-settings-item-header' >
109
  <p class="wptb-settings-item-title">{{{label}}}</p>
110
  </div>
111
  <div class="wptb-settings-row wptb-settings-middle-xs" style="padding-bottom: 12px; padding-top: 23px;">
112
  <div class="wptb-settings-col-xs-8">
113
- <input data-type="size" class="wptb-element-property wptb-size-slider {{{targetInputAddClass}}}"
114
- type="range" min="{{{min}}}" max="{{{max}}}" step="1" value="{{{defaultValue}}}">
 
115
  </div>
116
  <div class="wptb-settings-col-xs-4">
117
- <input id="wptb-size-number" data-type="size"
118
- class="wptb-size-number wptb-number-input wptb-element-property {{{targetInputAddClass}}}"
119
- type="number" min="{{{min}}}" max="{{{max}}}" step="1" placeholder="{{{defaultValue}}}" pattern="[0-9]*">
120
  <span class="wptb-input-px">{{{dimension}}}</span>
121
  </div>
122
  </div>
123
-
124
  <wptb-template-script>
125
  ( function() {
126
- if( '{{{selector}}}' ) {
127
- let selectorElement = document.querySelector( '{{{selector}}}' );
128
- let targetInputs = document.getElementsByClassName( '{{{targetInputAddClass}}}' );
 
 
 
 
129
 
130
- for( let i = 0; i < targetInputs.length; i++ ) {
131
- let cssSetting = '{{{cssSetting}}}';
132
- let cssSettingArr = cssSetting.split( ',' );
133
-
134
- let targetInputsCss = selectorElement.style[cssSettingArr[0]];
135
- if( targetInputsCss ) {
136
- targetInputs[i].value = parseInt( targetInputsCss );
137
  }
138
- if( targetInputs[i].classList.contains( 'wptb-size-slider' ) ) {
139
- targetInputs[i].oninput = function ( event ) {
140
- if( event.target == this ) {
141
- this.parentNode.parentNode.getElementsByClassName('wptb-size-number')[0].value = this.value;
142
- }
143
 
144
- let selectorElements = document.querySelectorAll( '{{{selector}}}' );
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
- if( cssSettingArr[j].indexOf( 'data-' ) === 0 ) {
154
- selectorElements[i].setAttribute( cssSettingArr[j], this.value );
155
- } else {
156
- selectorElements[i].style[cssSettingArr[j]] = this.value + '{{{dimension}}}' + '{{{addText}}}';
157
- }
158
- }
159
  }
160
-
161
  let details = {value: this.value};
162
- WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElements[0], details );
163
- WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}', true );
 
 
 
 
 
 
 
 
 
 
164
  };
165
-
 
 
 
 
 
 
166
 
167
- event.target.onmouseup = function() {
168
- let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
169
- wptbTableStateSaveManager.tableStateSet();
170
  }
171
- };
172
- } else if( targetInputs[i].classList.contains( 'wptb-number-input' ) ) {
173
- targetInputs[i].oninput = function( event ) {
174
- if( parseInt( this.value ) < parseInt( '{{{min}}}' ) ) {
175
- this.value = parseInt( '{{{min}}}' );
176
- } else if( parseInt( this.value ) > parseInt( '{{{max}}}' ) ) {
177
- this.value = parseInt ( '{{{max}}}' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  }
179
-
180
- this.parentNode.parentNode.getElementsByClassName('wptb-size-slider')[0].value = this.value;
181
- this.parentNode.parentNode.getElementsByClassName('wptb-size-slider')[0].oninput( event );
182
  }
183
  }
184
-
185
- WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}' );
186
- }
 
 
 
 
187
  }
188
  } )();
189
  </wptb-template-script>
190
-
191
  <?php
192
  }
193
  }
9
  /**
10
  * WP Table Builder size control.
11
  *
12
+ * A control class for creating size control objects
13
  * for showing size field on the left panel. This fiels set css value for html tag.
14
  * When this control adds for element, there is opportunity to point css type (width or fontSize ...)
15
  * and also to point dimension of value
39
  * @access public
40
  */
41
  public function enqueue() {
42
+
43
  }
44
 
45
  /**
53
  public function content_template() {
54
  ?>
55
  <#
56
+ let label,
57
+ selectors = [],
58
+ selectorsJson,
59
  max,
60
  min,
61
  defaultValue,
62
+ dimension;
63
+
64
+ if( data.label ) {
65
+ label = data.label;
66
+ }
67
+
68
  if( data.selectors && typeof data.selectors === 'object' ) {
69
+ let i = 0;
70
  for ( let prop in data.selectors ) {
71
+ selectors[i] = [];
72
+ selectors[i][0] = prop;
73
+ selectors[i][1] = data.selectors[prop];
74
+ i++;
75
  }
76
  }
77
+
78
+ if( selectors && Array.isArray( selectors ) ) {
79
+ selectorsJson = JSON.stringify( selectors );
80
  }
81
+
82
  if( data.max ) {
83
  max = data.max;
84
  } else {
99
  } else {
100
  dimension = 'px';
101
  }
102
+
103
+ if( data.elemContainer ) {
104
+ elemContainer = data.elemContainer;
 
 
 
 
105
  }
106
+
107
  targetInputAddClass = data.elementControlTargetUnicClass;
108
  #>
109
+
110
  <div class='wptb-settings-item-header' >
111
  <p class="wptb-settings-item-title">{{{label}}}</p>
112
  </div>
113
  <div class="wptb-settings-row wptb-settings-middle-xs" style="padding-bottom: 12px; padding-top: 23px;">
114
  <div class="wptb-settings-col-xs-8">
115
+ <input data-type="size" class="wptb-element-property wptb-size-slider {{{targetInputAddClass}}}"
116
+ data-element="{{{elemContainer}}}" type="range" min="{{{min}}}" max="{{{max}}}"
117
+ step="1" value="{{{defaultValue}}}">
118
  </div>
119
  <div class="wptb-settings-col-xs-4">
120
+ <input id="wptb-size-number" data-type="size"
121
+ class="wptb-size-number wptb-number-input wptb-element-property {{{targetInputAddClass}}}"
122
+ data-element="{{{elemContainer}}}" type="number" min="{{{min}}}" max="{{{max}}}" step="1" placeholder="{{{defaultValue}}}" pattern="[0-9]*">
123
  <span class="wptb-input-px">{{{dimension}}}</span>
124
  </div>
125
  </div>
126
+
127
  <wptb-template-script>
128
  ( function() {
129
+ let targetInputs = document.getElementsByClassName( '{{{targetInputAddClass}}}' );
130
+ if( targetInputs.length > 0 && targetInputs[0].dataset.element ) {
131
+ let selectorElement = document.querySelector( '.' + targetInputs[0].dataset.element );
132
+ if( selectorElement ) {
133
+ let selectorElementSettingValue;
134
+ if( '{{{selectorsJson}}}' ) {
135
+ let selectors = JSON.parse( '{{{selectorsJson}}}' );
136
 
137
+ selectorElementSettingValue = getSetElementValue( selectors );
 
 
 
 
 
 
138
  }
 
 
 
 
 
139
 
140
+ for( let i = 0; i < targetInputs.length; i++ ) {
141
+ if( selectorElementSettingValue ) {
142
+ targetInputs[i].value = selectorElementSettingValue;
143
+ } else if( '{{{defaultValue}}}' ) {
144
+ targetInputs[i].value = '{{{defaultValue}}}';
145
+ }
146
+ if( targetInputs[i].classList.contains( 'wptb-size-slider' ) ) {
147
+ targetInputs[i].oninput = function ( event ) {
148
+ if( event.target == this ) {
149
+ this.parentNode.parentNode.getElementsByClassName('wptb-size-number')[0].value = this.value;
 
 
 
 
 
150
  }
151
+
152
  let details = {value: this.value};
153
+
154
+ WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement, details );
155
+ if( '{{{selectorsJson}}}' ) {
156
+ let selectors = JSON.parse( '{{{selectorsJson}}}' );
157
+
158
+ getSetElementValue( selectors, details.value );
159
+ }
160
+
161
+ event.target.onmouseup = function() {
162
+ let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
163
+ wptbTableStateSaveManager.tableStateSet();
164
+ }
165
  };
166
+ } else if( targetInputs[i].classList.contains( 'wptb-number-input' ) ) {
167
+ targetInputs[i].oninput = function( event ) {
168
+ if( parseInt( this.value ) < parseInt( '{{{min}}}' ) ) {
169
+ this.value = parseInt( '{{{min}}}' );
170
+ } else if( parseInt( this.value ) > parseInt( '{{{max}}}' ) ) {
171
+ this.value = parseInt ( '{{{max}}}' );
172
+ }
173
 
174
+ this.parentNode.parentNode.getElementsByClassName('wptb-size-slider')[0].value = this.value;
175
+ this.parentNode.parentNode.getElementsByClassName('wptb-size-slider')[0].oninput( event );
 
176
  }
177
+ }
178
+ }
179
+ }
180
+ }
181
+
182
+ function getSetElementValue(selectors, value) {
183
+ console.log( "Hello 123" );
184
+ if (selectors && Array.isArray(selectors)) {
185
+ for (let i = 0; i < selectors.length; i++) {
186
+ if (selectors[i] && Array.isArray(selectors[i]) && typeof selectors[i][0] != 'undefined' && selectors[i][1] != 'undefined') {
187
+ let selectorElements = document.querySelectorAll(selectors[i][0]);
188
+ if (selectorElements.length > 0) {
189
+ for (let j = 0; j < selectorElements.length; j++) {
190
+ if (selectors[i][1]) {
191
+ if (Array.isArray(selectors[i][1])) {
192
+ for (let k = 0; k < selectors[i][1].length; k++) {
193
+ if (selectors[i][1][k]) {
194
+ if (typeof selectorElements[j].style[selectors[i][1][k]] == 'undefined') {
195
+ if (value) {
196
+ selectorElements[j].setAttribute(selectors[i][1][k], value);
197
+ } else if (selectorElements[j].getAttribute(selectors[i][1][k])) {
198
+ return selectorElements[j].getAttribute(selectors[i][1][k]);
199
+ }
200
+ } else {
201
+ if (value) {
202
+ selectorElements[j].style[selectors[i][1][k]] = value + '{{{dimension}}}';
203
+ } else if ( typeof parseInt(selectorElements[j].style[selectors[i][1][k]]) != 'undefined' ) {
204
+ let returnValue;
205
+ parseInt( selectorElements[j].style[selectors[i][1][k]] ) === 0 ? returnValue = '0' : returnValue = parseInt( selectorElements[j].style[selectors[i][1][k]] );
206
+ return returnValue;
207
+ }
208
+ }
209
+ }
210
+ }
211
+ } else {
212
+ if (selectors[i][1]) {
213
+ if (typeof selectorElements[j].style[selectors[i][1]] == 'undefined') {
214
+ if (value) {
215
+ selectorElements[j].setAttribute(selectors[i][1], value);
216
+ } else if (selectorElements[j].getAttribute(selectors[i][1])) {
217
+ return selectorElements[j].getAttribute(selectors[i][1]);
218
+ }
219
+ } else {
220
+ if (value) {
221
+ selectorElements[j].style[selectors[i][1]] = value + '{{{dimension}}}';
222
+ } else if ( typeof parseInt(selectorElements[j].style[selectors[i][1]]) != 'undefined' ) {
223
+ let returnValue;
224
+ parseInt( selectorElements[j].style[selectors[i][1]] ) === 0 ? returnValue = '0' : returnValue = parseInt( selectorElements[j].style[selectors[i][1]] );
225
+ return returnValue;
226
+ }
227
+ }
228
+ }
229
+ }
230
+ }
231
+ }
232
  }
 
 
 
233
  }
234
  }
235
+ } else {
236
+ return false;
237
+ }
238
+
239
+ if (!value) {
240
+ return false;
241
+ }
242
  }
243
  } )();
244
  </wptb-template-script>
245
+
246
  <?php
247
  }
248
  }
inc/admin/controls/control-text.php CHANGED
@@ -51,6 +51,7 @@ class Control_Text extends Base_Control {
51
  ?>
52
  <#
53
  let label,
 
54
  placeholder,
55
  elemContainer,
56
  targetInputAddClass = '';
@@ -59,6 +60,18 @@ class Control_Text extends Base_Control {
59
  label = data.label;
60
  }
61
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  if( data.placeholder ) {
63
  placeholder = data.placeholder;
64
  }
@@ -83,26 +96,99 @@ class Control_Text extends Base_Control {
83
  <wptb-template-script>
84
  ( function() {
85
  let targetInputs = document.getElementsByClassName( '{{{targetInputAddClass}}}' );
86
- if( targetInputs.length > 0 ) {
87
  targetInput = targetInputs[0];
88
- let dataSelectorElement = targetInput.dataset.element;
89
- if( dataSelectorElement ) {
90
- let selectorElement = document.querySelector( '.' + dataSelectorElement );
91
- if( selectorElement ) {
92
- targetInput.oninput = function( event ) {
93
- let details = {value: this.value};
94
- WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement, details );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
 
96
- WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}', true );
97
- };
98
-
99
- targetInput.onchange = function( event ) {
100
- let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
101
- wptbTableStateSaveManager.tableStateSet();
102
- };
103
-
104
- WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}' );
105
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
106
  }
107
  }
108
  } )();
51
  ?>
52
  <#
53
  let label,
54
+ selectors = [],
55
  placeholder,
56
  elemContainer,
57
  targetInputAddClass = '';
60
  label = data.label;
61
  }
62
 
63
+ let i = 0;
64
+ for ( let prop in data.selectors ) {
65
+ selectors[i] = [];
66
+ selectors[i][0] = prop;
67
+ selectors[i][1] = data.selectors[prop];
68
+ i++;
69
+ }
70
+
71
+ if( selectors && Array.isArray( selectors ) ) {
72
+ selectorsJson = JSON.stringify( selectors );
73
+ }
74
+
75
  if( data.placeholder ) {
76
  placeholder = data.placeholder;
77
  }
96
  <wptb-template-script>
97
  ( function() {
98
  let targetInputs = document.getElementsByClassName( '{{{targetInputAddClass}}}' );
99
+ if( targetInputs.length > 0 && targetInputs[0].dataset.element ) {
100
  targetInput = targetInputs[0];
101
+ let selectorElement = document.querySelector( '.' + targetInput.dataset.element );
102
+ if( selectorElement ) {
103
+ function getSetElementValue( selectors, value ) {
104
+ if( selectors && Array.isArray( selectors ) ) {
105
+ for( let i = 0; i < selectors.length; i++ ) {
106
+ if( selectors[i] && Array.isArray( selectors[i] ) && typeof selectors[i][0] != 'undefined' && selectors[i][1] != 'undefined' ) {
107
+ let selectorElements = document.querySelectorAll( selectors[i][0] );
108
+ if( selectorElements.length > 0 ) {
109
+ for( let j = 0; j < selectorElements.length; j++ ) {
110
+ if( selectors[i][1] ) {
111
+ if( Array.isArray( selectors[i][1] ) ) {
112
+ for( let k = 0; k < selectors[i][1].length; k++ ) {
113
+ if( selectors[i][1][k] ) {
114
+ if( typeof selectorElements[j].style[selectors[i][1][k]] == 'undefined' ) {
115
+ if( typeof value != 'undefined' ) {
116
+ selectorElements[j].setAttribute( selectors[i][1][k], value );
117
+ } else if( selectorElements[j].getAttribute( selectors[i][1][k] ) ) {
118
+ return selectorElements[j].getAttribute( selectors[i][1][k] );
119
+ }
120
+ } else {
121
+ if( typeof value != 'undefined' ) {
122
+ selectorElements[j].style[selectors[i][1][k]] = value;
123
+ } else if( parseInt( selectorElements[j].style[selectors[i][1][k]] ) ) {
124
+ return parseInt( selectorElements[j].style[selectors[i][1][k]] );
125
+ }
126
+ }
127
+ } else {
128
+ if( typeof value != 'undefined' ) {
129
+ selectorElements[j].innerHTML = value;
130
+ } else if( selectorElements[j].innerHTML ) {
131
+ return selectorElements[j].innerHTML;
132
+ }
133
+ }
134
+ }
135
+ } else {
136
+ if( selectors[i][1] ) {
137
+ if( typeof selectorElements[j].style[selectors[i][1]] == 'undefined' ) {
138
+ if( typeof value != 'undefined' ) {
139
+ selectorElements[j].setAttribute( selectors[i][1], value );
140
+ } else if( selectorElements[j].getAttribute( selectors[i][1] ) ) {
141
+ return selectorElements[j].getAttribute( selectors[i][1] );
142
+ }
143
+ } else {
144
+ if( typeof value != 'undefined' ) {
145
+ selectorElements[j].style[selectors[i][1]] = value;
146
+ } else if( parseInt( selectorElements[j].style[selectors[i][1]] ) ) {
147
+ return parseInt( selectorElements[j].style[selectors[i][1]] );
148
+ }
149
+ }
150
+ } else {
151
+ if( typeof value != 'undefined' ) {
152
+ selectorElements[j].innerHTML = value;
153
+ } else if( selectorElements[j].innerHTML ) {
154
+ return selectorElements[j].innerHTML;
155
+ }
156
+ }
157
+ }
158
+ }
159
+ }
160
+ }
161
+ }
162
+ }
163
+ } else {
164
+ return '';
165
+ }
166
 
167
+ if( ! value ) {
168
+ return '';
169
+ }
 
 
 
 
 
 
170
  }
171
+
172
+ if( '{{{selectorsJson}}}' ) {
173
+ let selectors = JSON.parse( '{{{selectorsJson}}}' );
174
+
175
+ targetInput.value = getSetElementValue( selectors );
176
+ }
177
+
178
+ targetInput.oninput = function( event ) {
179
+ let details = {value: this.value};
180
+ WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement, details );
181
+ if( '{{{selectorsJson}}}' ) {
182
+ let selectors = JSON.parse( '{{{selectorsJson}}}' );
183
+
184
+ getSetElementValue( selectors, details.value );
185
+ }
186
+ };
187
+
188
+ targetInput.onchange = function( event ) {
189
+ let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
190
+ wptbTableStateSaveManager.tableStateSet();
191
+ };
192
  }
193
  }
194
  } )();
inc/admin/controls/control-textarea.php CHANGED
@@ -51,6 +51,7 @@ class Control_Textarea extends Base_Control {
51
  ?>
52
  <#
53
  let label,
 
54
  placeholder,
55
  rows,
56
  cols,
@@ -61,6 +62,28 @@ class Control_Textarea extends Base_Control {
61
  if( data.label ) {
62
  label = data.label;
63
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
  if( data.rows ) {
66
  rows = data.rows;
@@ -98,26 +121,96 @@ class Control_Textarea extends Base_Control {
98
  <wptb-template-script>
99
  ( function() {
100
  let targetTextarea = document.getElementsByClassName( '{{{targetTextareaAddClass}}}' );
101
- if( targetTextarea.length > 0 ) {
102
  targetTextarea = targetTextarea[0];
103
- let dataSelectorElement = targetTextarea.dataset.element;
104
- if( dataSelectorElement ) {
105
- let selectorElement = document.querySelector( '.' + dataSelectorElement );
106
- if( selectorElement ) {
107
- targetTextarea.oninput = function( event ) {
108
- let details = {value: this.value};
109
- WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetTextareaAddClass}}}', selectorElement, details );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
 
111
- WPTB_Helper.controlsStateManager( '{{{targetTextareaAddClass}}}', true );
112
- };
113
-
114
- targetTextarea.onchange = function( event ) {
115
- let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
116
- wptbTableStateSaveManager.tableStateSet();
117
- };
118
-
119
- WPTB_Helper.controlsStateManager( '{{{targetTextareaAddClass}}}' );
120
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
121
  }
122
  }
123
  } )();
51
  ?>
52
  <#
53
  let label,
54
+ selectors = [],
55
  placeholder,
56
  rows,
57
  cols,
62
  if( data.label ) {
63
  label = data.label;
64
  }
65
+
66
+ let i = 0;
67
+ for ( let prop in data.selectors ) {
68
+ selectors[i] = [];
69
+ if( Number.isInteger( parseInt( prop ) ) ) {
70
+ selectors[i][1] = '';
71
+ if( data.selectors[prop] && ! Number.isInteger( parseInt ( data.selectors[prop] ) ) ) {
72
+ selectors[i][0] = data.selectors[prop];
73
+ } else {
74
+ selectors[i][0] = '';
75
+ }
76
+ continue;
77
+ }
78
+
79
+ selectors[i][0] = prop;
80
+ selectors[i][1] = data.selectors[prop];
81
+ i++;
82
+ }
83
+
84
+ if( selectors && Array.isArray( selectors ) ) {
85
+ selectorsJson = JSON.stringify( selectors );
86
+ }
87
 
88
  if( data.rows ) {
89
  rows = data.rows;
121
  <wptb-template-script>
122
  ( function() {
123
  let targetTextarea = document.getElementsByClassName( '{{{targetTextareaAddClass}}}' );
124
+ if( targetTextarea.length > 0 && targetTextarea[0].dataset.element ) {
125
  targetTextarea = targetTextarea[0];
126
+ let selectorElement = document.querySelector( '.' + targetTextarea.dataset.element );
127
+ if( selectorElement ) {
128
+ function getSetElementValue( selectors, value ) {
129
+ if( selectors && Array.isArray( selectors ) ) {
130
+ for( let i = 0; i < selectors.length; i++ ) {
131
+ if( selectors[i] && Array.isArray( selectors[i] ) && typeof selectors[i][0] != 'undefined' && selectors[i][1] != 'undefined' ) {
132
+ let selectorElements = document.querySelectorAll( selectors[i][0] );
133
+ if( selectorElements.length > 0 ) {
134
+ for( let j = 0; j < selectorElements.length; j++ ) {
135
+ if( selectors[i][1] && Array.isArray( selectors[i][1] ) ) {
136
+ for( let k = 0; k < selectors[i][1].length; k++ ) {
137
+ if( selectors[i][1][k] ) {
138
+ if( typeof selectorElements[j].style[selectors[i][1][k]] == 'undefined' ) {
139
+ if( typeof value != 'undefined' ) {
140
+ selectorElements[j].setAttribute( selectors[i][1][k], value );
141
+ } else if( selectorElements[j].getAttribute( selectors[i][1][k] ) ) {
142
+ return selectorElements[j].getAttribute( selectors[i][1][k] );
143
+ }
144
+ } else {
145
+ if( typeof value != 'undefined' ) {
146
+ selectorElements[j].style[selectors[i][1][k]] = value;
147
+ } else if( parseInt( selectorElements[j].style[selectors[i][1][k]] ) ) {
148
+ return parseInt( selectorElements[j].style[selectors[i][1][k]] );
149
+ }
150
+ }
151
+ } else {
152
+ if( typeof value != 'undefined' ) {
153
+ selectorElements[j].innerHTML = value;
154
+ } else if( selectorElements[j].innerHTML ) {
155
+ return selectorElements[j].innerHTML;
156
+ }
157
+ }
158
+ }
159
+ } else {
160
+ if( selectors[i][1] ) {
161
+ if( typeof selectorElements[j].style[selectors[i][1]] == 'undefined' ) {
162
+ if( typeof value != 'undefined' ) {
163
+ selectorElements[j].setAttribute( selectors[i][1], value );
164
+ } else if( selectorElements[j].getAttribute( selectors[i][1] ) ) {
165
+ return selectorElements[j].getAttribute( selectors[i][1] );
166
+ }
167
+ } else {
168
+ if( typeof value != 'undefined' ) {
169
+ selectorElements[j].style[selectors[i][1]] = value;
170
+ } else if( parseInt( selectorElements[j].style[selectors[i][1]] ) ) {
171
+ return parseInt( selectorElements[j].style[selectors[i][1]] );
172
+ }
173
+ }
174
+ } else {
175
+ if( typeof value != 'undefined' ) {
176
+ selectorElements[j].innerHTML = value;
177
+ } else if( selectorElements[j].innerHTML ) {
178
+ return selectorElements[j].innerHTML;
179
+ }
180
+ }
181
+ }
182
+ }
183
+ }
184
+ }
185
+ }
186
+ } else {
187
+ return '';
188
+ }
189
+
190
+ if( ! value ) {
191
+ return '';
192
+ }
193
+ }
194
 
195
+ if( '{{{selectorsJson}}}' ) {
196
+ let selectors = JSON.parse( '{{{selectorsJson}}}' );
197
+ targetTextarea.value = getSetElementValue( selectors );
 
 
 
 
 
 
198
  }
199
+
200
+ targetTextarea.oninput = function( event ) {
201
+ let details = {value: this.value};
202
+ WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetTextareaAddClass}}}', selectorElement, details );
203
+ if( '{{{selectorsJson}}}' ) {
204
+ let selectors = JSON.parse( '{{{selectorsJson}}}' );
205
+
206
+ getSetElementValue( selectors, details.value );
207
+ }
208
+ };
209
+
210
+ targetTextarea.onchange = function( event ) {
211
+ let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
212
+ wptbTableStateSaveManager.tableStateSet();
213
+ };
214
  }
215
  }
216
  } )();
inc/admin/controls/control-toggle.php CHANGED
@@ -96,72 +96,126 @@ class Control_Toggle extends Base_Control {
96
  if( dataSelectorElement ) {
97
  let selectorElement = document.querySelector( '.' + dataSelectorElement );
98
  if( selectorElement ) {
99
- targetInput.onchange = function( event ) {
100
- let details;
101
-
102
- if( targetInput.checked == true ) {
103
- details = {value: 'checked'};
104
- } else {
105
- details = {value: 'unchecked'};
106
- }
107
-
108
- WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement, details );
109
- if( '{{{selectorsJson}}}' ) {
110
- let selectors = JSON.parse( '{{{selectorsJson}}}' );
111
-
112
- if( selectors && Array.isArray( selectors ) ) {
113
- for( let i = 0; i < selectors.length; i++ ) {
114
- if( selectors[i] && Array.isArray( selectors[i] ) && selectors[i][0] && selectors[i][1] ) {
115
- let selectorElements = document.querySelectorAll( selectors[i][0] );
116
- if( selectorElements.length > 0 ) {
117
- for( let j = 0; j < selectorElements.length; j++ ) {
118
- if( selectors[i][1] && Array.isArray( selectors[i][1] ) ) {
119
- if( selectors[i][1][0] && Array.isArray( selectors[i][1][0] ) ) {
120
- for( let k = 0; k < selectors[i][1].length; k++ ) {
121
  if( selectors[i][1][k][0] ) {
122
  let styleValue;
123
- if( details.value == 'checked' ) {
124
- styleValue = selectors[i][1][k][1] ? selectors[i][1][k][1] : '';
125
- } else {
126
- styleValue = selectors[i][1][k][2] ? selectors[i][1][k][2] : '';
 
 
 
127
  }
128
-
129
- if( selectors[i][1][k][0].indexOf( 'data-' ) === 0 ) {
130
- if( styleValue ) {
131
- selectorElements[j].setAttribute( selectors[i][1][k][0], styleValue );
 
 
 
 
 
132
  } else {
133
- selectorElements[j].removeAttribute( selectors[i][1][k][0] );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  }
135
  } else {
136
- if( styleValue ) {
137
- selectorElements[j].style[selectors[i][1][k][0]] = styleValue;
 
 
 
 
138
  } else {
139
- selectorElements[j].style[selectors[i][1][k][0]] = '';
 
 
 
 
140
  }
141
  }
142
  }
143
  }
144
- } else {
145
- if( selectors[i][1][0] ) {
146
- let styleValue;
147
- if( details.value == 'checked' ) {
148
- styleValue = selectors[i][1][1] ? selectors[i][1][1] : '';
 
 
 
 
 
 
 
 
 
 
149
  } else {
150
- styleValue = selectors[i][1][2] ? selectors[i][1][2] : '';
 
151
  }
152
-
153
- if( selectors[i][1][0].indexOf( 'data-' ) === 0 ) {
154
- if( styleValue ) {
155
- selectorElements[j].setAttribute( selectors[i][1][0], styleValue );
156
- } else {
157
- selectorElements[j].removeAttribute( selectors[i][1][0] );
158
- }
159
  } else {
160
- if( styleValue ) {
161
- selectorElements[j].style[selectors[i][1][0]] = styleValue;
162
- } else {
163
- selectorElements[j].style[selectors[i][1][0]] = '';
164
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
165
  }
166
  }
167
  }
@@ -171,15 +225,41 @@ class Control_Toggle extends Base_Control {
171
  }
172
  }
173
  }
 
 
174
  }
175
-
176
- WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}', true );
177
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
179
  wptbTableStateSaveManager.tableStateSet();
180
  };
181
-
182
- WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}' );
183
  }
184
  }
185
  }
96
  if( dataSelectorElement ) {
97
  let selectorElement = document.querySelector( '.' + dataSelectorElement );
98
  if( selectorElement ) {
99
+ function getSetElementValue( selectors, value ) {
100
+ if( selectors && Array.isArray( selectors ) ) {
101
+ for( let i = 0; i < selectors.length; i++ ) {
102
+ if( selectors[i] && Array.isArray( selectors[i] ) && typeof selectors[i][0] != 'undefined' && typeof selectors[i][1] != 'undefined' ) {
103
+ let selectorElements = document.querySelectorAll( selectors[i][0] );
104
+ if( selectorElements.length > 0 ) {
105
+ for( let j = 0; j < selectorElements.length; j++ ) {
106
+ if( selectors[i][1] && Array.isArray( selectors[i][1] ) && typeof selectors[i][1][0] != 'undefined' ) {
107
+ if( Array.isArray( selectors[i][1][0] ) ) {
108
+ for( let k = 0; k < selectors[i][1].length; k++ ) {
109
+ if( typeof selectors[i][1][k] != 'undefined' && Array.isArray( selectors[i][1][k] ) ) {
 
 
 
 
 
 
 
 
 
 
 
110
  if( selectors[i][1][k][0] ) {
111
  let styleValue;
112
+
113
+ if( value ) {
114
+ if( value == 'checked' ) {
115
+ styleValue = typeof selectors[i][1][k][1] != 'undefined' ? selectors[i][1][k][1] : '';
116
+ } else {
117
+ styleValue = typeof selectors[i][1][k][2] != 'undefined' ? selectors[i][1][k][2] : '';
118
+ }
119
  }
120
+
121
+ if( selectors[i][1][k][0] == 'class' ) {
122
+ if( value ) {
123
+ if( styleValue ) {
124
+ selectorElements[j].classList.add( styleValue );
125
+ } else {
126
+ styleValue = typeof selectors[i][1][1] != 'undefined' ? selectors[i][1][k][1] : '';
127
+ selectorElements[j].classList.remove( styleValue );
128
+ }
129
  } else {
130
+ if( typeof selectors[i][1][k][1] != 'undefined' && selectorElements[j].classList.contains( selectors[i][1][k][1] ) ) {
131
+ return true;
132
+ } else {
133
+ return false;
134
+ }
135
+ }
136
+ } else if( typeof selectorElements[j].style[selectors[i][1][k][0]] == 'undefined' ) {
137
+ if( value ) {
138
+ if( styleValue ) {
139
+ selectorElements[j].setAttribute( selectors[i][1][k][0], styleValue );
140
+ } else {
141
+ selectorElements[j].removeAttribute( selectors[i][1][k][0] );
142
+ }
143
+ } else {
144
+ if( typeof selectors[i][1][k][1] != 'undefined' && selectorElements[j].getAttribute( selectors[i][1][k][0] ) == selectors[i][1][k][1] ) {
145
+ return true;
146
+ } else {
147
+ return false;
148
+ }
149
  }
150
  } else {
151
+ if( value ) {
152
+ if( styleValue ) {
153
+ selectorElements[j].style[selectors[i][1][k][0]] = styleValue;
154
+ } else {
155
+ selectorElements[j].style[selectors[i][1][k][0]] = '';
156
+ }
157
  } else {
158
+ if( typeof selectors[i][1][k][1] != 'undefined' && selectorElements[j].style[selectors[i][1][k][0]] == selectors[i][1][k][1] ) {
159
+ return true;
160
+ } else {
161
+ return false;
162
+ }
163
  }
164
  }
165
  }
166
  }
167
+ }
168
+ } else {
169
+ let styleValue;
170
+ if( value ) {
171
+ if( value == 'checked' ) {
172
+ styleValue = typeof selectors[i][1][1] != 'undefined' ? selectors[i][1][1] : '';
173
+ } else {
174
+ styleValue = typeof selectors[i][1][2] != 'undefined' ? selectors[i][1][2] : '';
175
+ }
176
+ }
177
+
178
+ if( selectors[i][1][0] == 'class' ) {
179
+ if( value ) {
180
+ if( styleValue ) {
181
+ selectorElements[j].classList.add( styleValue );
182
  } else {
183
+ styleValue = typeof selectors[i][1][1] != 'undefined' ? selectors[i][1][1] : '';
184
+ selectorElements[j].classList.remove( styleValue );
185
  }
186
+ } else {
187
+ if( typeof selectors[i][1][1] != 'undefined' && selectorElements[j].classList.contains( selectors[i][1][1] ) ) {
188
+ return true;
 
 
 
 
189
  } else {
190
+ return false;
191
+ }
192
+ }
193
+ } else if( typeof selectorElements[j].style[selectors[i][1][0]] == 'undefined' ) {
194
+ if( value ) {
195
+ if( styleValue ) {
196
+ selectorElements[j].setAttribute( selectors[i][1][0], styleValue );
197
+ } else {
198
+ selectorElements[j].removeAttribute( selectors[i][1][0] );
199
+ }
200
+ } else {
201
+ if( typeof selectors[i][1][1] != 'undefined' && selectorElements[j].getAttribute( selectors[i][1][0] ) == selectors[i][1][1] ) {
202
+ return true;
203
+ } else if( typeof selectors[i][1][2] != 'undefined' && selectorElements[j].getAttribute( selectors[i][1][0] ) == selectors[i][1][2] ) {
204
+ return false;
205
+ }
206
+ }
207
+ } else {
208
+ if( value ) {
209
+ if( styleValue ) {
210
+ selectorElements[j].style[selectors[i][1][0]] = styleValue;
211
+ } else {
212
+ selectorElements[j].style[selectors[i][1][0]] = '';
213
+ }
214
+ } else {
215
+ if( typeof selectors[i][1][1] != 'undefined' && selectorElements[j].style[selectors[i][1][0]] == selectors[i][1][1] ) {
216
+ return true;
217
+ } else if( typeof selectors[i][1][2] != 'undefined' && selectorElements[j].style[selectors[i][1][0]] == selectors[i][1][2] ) {
218
+ return false;
219
  }
220
  }
221
  }
225
  }
226
  }
227
  }
228
+ } else {
229
+ return false;
230
  }
231
+
232
+ if( ! value ) {
233
+ return false;
234
+ }
235
+ }
236
+
237
+ if( '{{{selectorsJson}}}' ) {
238
+ let selectors = JSON.parse( '{{{selectorsJson}}}' );
239
+
240
+ targetInput.checked = getSetElementValue( selectors );
241
+ }
242
+
243
+ targetInput.onchange = function( event ) {
244
+ let details;
245
+
246
+ if( event.target.checked == true ) {
247
+ details = {value: 'checked'};
248
+ } else {
249
+ details = {value: 'unchecked'};
250
+ }
251
+
252
+ WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement, details );
253
+ if( '{{{selectorsJson}}}' ) {
254
+ let selectors = JSON.parse( '{{{selectorsJson}}}' );
255
+
256
+ getSetElementValue( selectors, details.value );
257
+ }
258
+
259
  let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
260
  wptbTableStateSaveManager.tableStateSet();
261
  };
262
+
 
263
  }
264
  }
265
  }
inc/admin/css/admin-welcome.css ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wptb-container {
2
+ max-width: 900px;
3
+ min-width: 255px;
4
+ margin: auto;
5
+ border: 1px solid #d4d4d4;
6
+ margin-top: 50px;
7
+ margin-bottom: 50px;
8
+ background-color: #fff;
9
+ }
10
+
11
+ .wptb-headerPart {
12
+ box-shadow: 0 0 8px rgba(0, 0, 0, .1);
13
+ }
14
+
15
+ .wptb-skipToPrevious {
16
+ float: right;
17
+ padding: 14px 20px 14px 20px;
18
+ border-left: 1px solid #d4d4d4;
19
+ }
20
+
21
+ .wptb-skipToPrevious a {
22
+ color: #9b9b9b;
23
+ }
24
+
25
+ .wptb-skipToPrevious a:hover {
26
+ color: #000;
27
+ }
28
+
29
+ .wptb-logoAndText img {
30
+ margin-right: 5px;
31
+ }
32
+
33
+ .wptb-logoAndText {
34
+ display: inline-block;
35
+ padding: 1%;
36
+ }
37
+
38
+ .wptb-gettingStarted {
39
+ position: relative;
40
+ text-transform: uppercase;
41
+ font-weight: 600;
42
+ top: -5px;
43
+ }
44
+
45
+ .wptb-gettingStartedContent {
46
+ width: auto;
47
+ padding: 50px;
48
+ }
49
+
50
+ .wptb-gettingStartedText {
51
+ max-width: 500px;
52
+ margin: auto;
53
+ text-align: center;
54
+ }
55
+
56
+ .wptb-gettingStartedText h2 {
57
+ margin-top: 0;
58
+ margin-bottom: 26px;
59
+ }
60
+
61
+ .wptb-gettingStartedText p {
62
+ font-size: 13px;
63
+ line-height: 1.5;
64
+ }
65
+
66
+ .wptb-gettingStartedViedo {
67
+ margin: 40px 0 60px;
68
+ text-align: center;
69
+ }
70
+
71
+ .wptb-gettingStartedViedo iframe {
72
+ box-shadow: 10px 10px 20px rgba(0, 0, 0, .15);
73
+ }
74
+
75
+ .wptb-gettingStartedButton {
76
+ max-width: 500px;
77
+ margin: auto;
78
+ }
79
+
80
+ .wptb-buttonPrimary {
81
+ font-size: 14px;
82
+ min-height: 46px;
83
+ line-height: 3.14285714;
84
+ padding: 0 36px;
85
+ margin-right: 20px;
86
+ margin-left: 36px;
87
+ background: #007cba;
88
+ border-color: #007cba;
89
+ color: #fff;
90
+ text-decoration: none;
91
+ text-shadow: none;
92
+ vertical-align: top;
93
+ display: inline-block;
94
+ border-radius: 3px;
95
+ }
96
+
97
+ .wptb-buttonSecondary {
98
+ font-size: 14px;
99
+ min-height: 46px;
100
+ line-height: 3.14285714;
101
+ padding: 0 36px;
102
+ background: #fff;
103
+ border: 1px solid #007cba;
104
+ color: #007cba;
105
+ text-decoration: none;
106
+ text-shadow: none;
107
+ vertical-align: top;
108
+ display: inline-block;
109
+ border-radius: 3px;
110
+ }
inc/admin/css/admin.css CHANGED
@@ -1565,6 +1565,7 @@ table.wptb-table {
1565
 
1566
  .mce-content-body {
1567
  min-height: 19px;
 
1568
  }
1569
 
1570
  .mce-tinymce.mce-tinymce-inline.mce-container.mce-panel {
@@ -2219,6 +2220,12 @@ td[class*="wptb-fused-cell"] {
2219
  line-height: 25px;
2220
  }
2221
 
 
 
 
 
 
 
2222
  @media screen and (max-width: 1375px) {
2223
  #wptb-messaging-area {
2224
  position: relative;
1565
 
1566
  .mce-content-body {
1567
  min-height: 19px;
1568
+ word-break: break-word;
1569
  }
1570
 
1571
  .mce-tinymce.mce-tinymce-inline.mce-container.mce-panel {
2220
  line-height: 25px;
2221
  }
2222
 
2223
+ /* Shortcode */
2224
+
2225
+ wptb_shortcode_container_element {
2226
+ display: block;
2227
+ }
2228
+
2229
  @media screen and (max-width: 1375px) {
2230
  #wptb-messaging-area {
2231
  position: relative;
inc/admin/element-classes/element-scripts/button-element.js CHANGED
@@ -80,17 +80,6 @@ if( target ) {
80
  //
81
  //WPTB_Helper.controlsInclude( element, textControlsChange );
82
 
83
- function textControlChange2( controlValue, element ) {
84
- let a = element.getElementsByTagName( 'a' );
85
- if( a.length > 0 ) {
86
- a = a[0];
87
- a.setAttribute( 'id', controlValue );
88
- }
89
- }
90
-
91
- let controlName = 'button-id';
92
- WPTB_Helper.oneControlInclude( element, textControlChange2, controlName );
93
-
94
  // for old elements which were before the change of structure of the plugin
95
  let infArr = element.className.match( /wptb-size-([A-Z]+)/i );
96
  if( infArr && Array.isArray( infArr ) ) {
@@ -103,58 +92,4 @@ if( infArr && Array.isArray( infArr ) ) {
103
  if( wptbButtonWrapper ) {
104
  wptbButtonWrapper.classList.add( wptbSizeNew );
105
  }
106
- }
107
-
108
- let infArrEl = element.className.match( /wptb-element-((.+-)\d+)/i );
109
- let elementsSettingsTemplateJs = document.getElementsByClassName( 'wptb-element-datas' );
110
- let elementsSettings;
111
- let elementSettings;
112
- if( elementsSettingsTemplateJs.length > 0 ) {
113
- elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];
114
- elementsSettings = elementsSettingsTemplateJs.innerHTML;
115
- if( elementsSettings ) {
116
- try{
117
- elementsSettings = JSON.parse( elementsSettings );
118
- } catch( error ) {
119
- console.log( error );
120
- console.log("Json Parse Error:" + elementsSettings);
121
- }
122
-
123
- if( typeof elementsSettings === 'object' && ( 'tmpl-wptb-el-datas-' + infArrEl[1] ) in elementsSettings ) {
124
- elementSettings = elementsSettings['tmpl-wptb-el-datas-' + infArrEl[1]];
125
- }
126
- }
127
- } else {
128
- elementsSettingsTemplateJs = document.createElement( 'script' );
129
- elementsSettingsTemplateJs.setAttribute( 'type', 'text/html' );
130
- elementsSettingsTemplateJs.setAttribute( 'class', 'wptb-element-datas' );
131
- let body = document.getElementsByTagName('body')[0];
132
- body.appendChild( elementsSettingsTemplateJs );
133
- }
134
-
135
-
136
-
137
- if( ! elementSettings ) {
138
- if( ! elementsSettings || typeof elementsSettings !== 'object' ) {
139
- elementsSettings = {};
140
- }
141
-
142
- elementsSettings['tmpl-wptb-el-datas-' + infArrEl[1]] = {};
143
- let buttonId;
144
- let a = element.getElementsByTagName( 'a' );
145
- if( a.length > 0 ) {
146
- a = a[0];
147
-
148
- if( a.hasAttribute( 'id' ) ) {
149
- buttonId = a.getAttribute( 'id' );
150
- elementsSettings['tmpl-wptb-el-datas-' + infArrEl[1]]['data-wptb-el-' + infArrEl[1] + '-button-id'] = buttonId;
151
- } else {
152
- elementsSettings['tmpl-wptb-el-datas-' + infArrEl[1]]['data-wptb-el-' + infArrEl[1] + '-button-id'] = '';
153
- }
154
-
155
- if( elementsSettings ) {
156
- elementsSettings = JSON.stringify( elementsSettings );
157
- elementsSettingsTemplateJs.innerHTML = elementsSettings;
158
- }
159
- }
160
  }
80
  //
81
  //WPTB_Helper.controlsInclude( element, textControlsChange );
82
 
 
 
 
 
 
 
 
 
 
 
 
83
  // for old elements which were before the change of structure of the plugin
84
  let infArr = element.className.match( /wptb-size-([A-Z]+)/i );
85
  if( infArr && Array.isArray( infArr ) ) {
92
  if( wptbButtonWrapper ) {
93
  wptbButtonWrapper.classList.add( wptbSizeNew );
94
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
95
  }
inc/admin/element-classes/element-scripts/custom-html-element.js CHANGED
@@ -27,17 +27,23 @@ tinyMCE.init({
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();
@@ -66,11 +72,3 @@ tinyMCE.init({
66
  });
67
  }
68
  });
69
-
70
- element.addEventListener( 'wptb-control:' + elementControlTargetUnicClass, function( event ) {
71
- let targetElm = element.getElementsByClassName( 'mce-content-body' );
72
- if( targetElm.length > 0 ) {
73
- targetElm = targetElm[0];
74
- targetElm.innerHTML = event.detail.value;
75
- }
76
- }, false );
27
  elementControlTextarea = elementControlTextarea[0];
28
  elementControlTextarea.value = ed.targetElm.textContent;
29
  }
 
30
  });
31
 
32
  ed.on( 'focus', function( ) {
33
  ed.targetElm.innerText = ed.targetElm.innerHTML;
34
+
35
+ WPTB_Helper.wptbDocumentEventGenerate( 'click', ed.targetElm );
36
+ WPTB_Helper.wptbDocumentEventGenerate( 'input', ed.targetElm );
37
  });
38
 
39
  ed.on( 'blur', function( ) {
40
  ed.targetElm.innerHTML = ed.targetElm.innerText;
41
  });
42
 
43
+ ed.on( 'click', function( ) {
44
+ WPTB_Helper.wptbDocumentEventGenerate( 'input', ed.targetElm );
45
+ });
46
+
47
  ed.on( 'keydown', function( e ) {
48
  let div = e.target;
49
  let divText = div.innerHTML.replace( /\s+/g, ' ' ).trim();
72
  });
73
  }
74
  });
 
 
 
 
 
 
 
 
inc/admin/element-classes/element-scripts/image-element.js CHANGED
@@ -87,71 +87,10 @@ if( iconImageButton && ! element.classList.contains( 'wptb-elem-placeholder' ) )
87
 
88
  function controlsChange( inputs, element ) {
89
  if( inputs && typeof inputs === 'object' ) {
90
- if( inputs.hasOwnProperty( 'imageAlternativeText' ) ) {
91
- let imageAltValue = inputs['imageAlternativeText'];
92
- let img = element.getElementsByTagName( 'img' );
93
- if( img.length > 0 ) {
94
- img = img[0];
95
- img.setAttribute( 'alt', imageAltValue );
96
- }
97
- } else if( inputs.hasOwnProperty( 'imageReplaceButton' ) ) {
98
  addMedia( element, true );
99
  }
100
  }
101
  }
102
 
103
  WPTB_Helper.controlsInclude( element, controlsChange );
104
-
105
-
106
- let infArrEl = element.className.match( /wptb-element-((.+-)\d+)/i );
107
- let elementsSettingsTemplateJs = document.getElementsByClassName( 'wptb-element-datas' );
108
- let elementsSettings;
109
- let elementSettings;
110
- if( elementsSettingsTemplateJs.length > 0 ) {
111
- elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];
112
- elementsSettings = elementsSettingsTemplateJs.innerHTML;
113
- if( elementsSettings ) {
114
- try{
115
- elementsSettings = JSON.parse( elementsSettings );
116
- } catch( error ) {
117
- console.log( error );
118
- console.log("Json Parse Error:" + elementsSettings);
119
- }
120
- if( typeof elementsSettings === 'object' && ( 'tmpl-wptb-el-datas-' + infArrEl[1] ) in elementsSettings ) {
121
- elementSettings = elementsSettings['tmpl-wptb-el-datas-' + infArrEl[1]];
122
- }
123
- }
124
- } else {
125
- elementsSettingsTemplateJs = document.createElement( 'script' );
126
- elementsSettingsTemplateJs.setAttribute( 'type', 'text/html' );
127
- elementsSettingsTemplateJs.setAttribute( 'class', 'wptb-element-datas' );
128
- let body = document.getElementsByTagName('body')[0];
129
- body.appendChild( elementsSettingsTemplateJs );
130
- }
131
-
132
- if( ! elementSettings ) {
133
- if( ! elementsSettings || typeof elementsSettings !== 'object' ) {
134
- elementsSettings = {};
135
- }
136
-
137
- elementsSettings['tmpl-wptb-el-datas-' + infArrEl[1]] = {};
138
- let imageAltText;
139
- let img = element.getElementsByTagName( 'img' );
140
- if( img.length > 0 ) {
141
- img = img[0];
142
-
143
- if( img.hasAttribute( 'alt' ) ) {
144
- imageAltText = img.getAttribute( 'alt' );
145
- elementsSettings['tmpl-wptb-el-datas-' + infArrEl[1]]['data-wptb-el-' + infArrEl[1] + '-imageAlternativeText'] = imageAltText;
146
- } else {
147
- elementsSettings['tmpl-wptb-el-datas-' + infArrEl[1]]['data-wptb-el-' + infArrEl[1] + '-imageAlternativeText'] = '';
148
- }
149
- }
150
-
151
-
152
-
153
- if( elementsSettings ) {
154
- elementsSettings = JSON.stringify( elementsSettings );
155
- elementsSettingsTemplateJs.innerHTML = elementsSettings;
156
- }
157
- }
87
 
88
  function controlsChange( inputs, element ) {
89
  if( inputs && typeof inputs === 'object' ) {
90
+ if( inputs.hasOwnProperty( 'imageReplaceButton' ) ) {
 
 
 
 
 
 
 
91
  addMedia( element, true );
92
  }
93
  }
94
  }
95
 
96
  WPTB_Helper.controlsInclude( element, controlsChange );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/admin/element-classes/element-scripts/list-element.js CHANGED
@@ -179,71 +179,32 @@ function selectControlsChange( selects, element ) {
179
  }
180
  }
181
 
182
- WPTB_Helper.controlsInclude( element, selectControlsChange );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
183
 
 
184
 
185
  // for old elements which were before the change of structure of the plugin
186
  if( element.classList.contains( 'wptb-list-item-container' ) ) {
187
  element.classList.add( 'wptb-list-container' );
188
- }
189
-
190
- let infArr = element.className.match( /wptb-element-((.+-)\d+)/i );
191
- let elementsSettingsTemplateJs = document.getElementsByClassName( 'wptb-element-datas' );
192
- let elementsSettings;
193
- let elementSettings;
194
- if( elementsSettingsTemplateJs.length > 0 ) {
195
- elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];
196
- elementsSettings = elementsSettingsTemplateJs.innerHTML;
197
- if( elementsSettings ) {
198
- try{
199
- elementsSettings = JSON.parse( elementsSettings );
200
- } catch( error ) {
201
- console.log( error );
202
- console.log("Json Parse Error:" + elementsSettings);
203
- }
204
- if( typeof elementsSettings === 'object' && ( 'tmpl-wptb-el-datas-' + infArr[1] ) in elementsSettings ) {
205
- elementSettings = elementsSettings['tmpl-wptb-el-datas-' + infArr[1]];
206
- }
207
- }
208
- } else {
209
- elementsSettingsTemplateJs = document.createElement( 'script' );
210
- elementsSettingsTemplateJs.setAttribute( 'type', 'text/html' );
211
- elementsSettingsTemplateJs.setAttribute( 'class', 'wptb-element-datas' );
212
- let body = document.getElementsByTagName('body')[0];
213
- body.appendChild( elementsSettingsTemplateJs );
214
- }
215
-
216
- if( ! elementSettings ) {
217
-
218
- let listItems = element.querySelectorAll( 'li' );
219
- for( let i = 0; i < listItems.length; i++ ) {
220
- let listItem = listItems[i];
221
- let p = listItem.querySelector( 'p' );
222
- if( p ) {
223
- if( infArr && Array.isArray( infArr ) ) {
224
- if( ! elementsSettings || typeof elementsSettings !== 'object' ) {
225
- elementsSettings = {};
226
- }
227
-
228
- elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] = {};
229
-
230
- let classAttr = p.className.match( /wptb-list-style-type-(.+)/i );
231
- if( classAttr && Array.isArray( classAttr ) ) {
232
- let listType = classAttr[0].replace( 'wptb-list-style-type-', '' );
233
- elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-select1'] = 'unordered';
234
- elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-select2'] = listType;
235
- } else {
236
- elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-select1'] = 'numbered';
237
- elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-select2'] = 'disc';
238
- }
239
-
240
- if( elementsSettings ) {
241
- elementsSettings = JSON.stringify( elementsSettings );
242
- elementsSettingsTemplateJs.innerHTML = elementsSettings;
243
- }
244
- }
245
-
246
- break;
247
- }
248
- }
249
  }
179
  }
180
  }
181
 
182
+ //WPTB_Helper.controlsInclude( element, selectControlsChange );
183
+ function controlsChange( inputs, element ) {
184
+ if( inputs && typeof inputs === 'object' ) {
185
+ if( inputs.hasOwnProperty( 'select1' ) ) {
186
+ console.log(inputs);
187
+ let infArr = element.className.match( /wptb-element-((.+-)\d+)/i );
188
+
189
+ if( infArr ) {
190
+ let controlSelect2 = document.querySelector( '.wptb-el-' + infArr[1] + '-select2' );
191
+ if( controlSelect2 ) {
192
+ for( let i = 0; i < controlSelect2.options.length; i++ ) {
193
+ controlSelect2.options[i].removeAttribute( 'selected' );
194
+
195
+ if( controlSelect2.options[i].value == 'disc' ) {
196
+ controlSelect2.options[i].selected = true;
197
+ }
198
+ }
199
+ }
200
+ }
201
+ }
202
+ }
203
+ }
204
 
205
+ WPTB_Helper.controlsInclude( element, controlsChange );
206
 
207
  // for old elements which were before the change of structure of the plugin
208
  if( element.classList.contains( 'wptb-list-item-container' ) ) {
209
  element.classList.add( 'wptb-list-container' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  }
inc/admin/element-classes/element-scripts/shortcode-element.js CHANGED
@@ -26,7 +26,21 @@ if( tinyMceTarget.length > 0 ) {
26
  elementControlTextarea = elementControlTextarea[0];
27
  elementControlTextarea.value = ed.targetElm.textContent;
28
  }
29
- WPTB_Helper.controlsStateManager( elementControlTargetUnicClass, true );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  });
31
 
32
  ed.on( 'keydown', function( e ) {
26
  elementControlTextarea = elementControlTextarea[0];
27
  elementControlTextarea.value = ed.targetElm.textContent;
28
  }
29
+ });
30
+
31
+ ed.on( 'focus', function( ) {
32
+ ed.targetElm.innerText = ed.targetElm.innerHTML;
33
+
34
+ WPTB_Helper.wptbDocumentEventGenerate( 'click', ed.targetElm );
35
+ WPTB_Helper.wptbDocumentEventGenerate( 'input', ed.targetElm );
36
+ });
37
+
38
+ ed.on( 'blur', function( ) {
39
+ ed.targetElm.innerHTML = ed.targetElm.innerText;
40
+ });
41
+
42
+ ed.on( 'click', function( ) {
43
+ WPTB_Helper.wptbDocumentEventGenerate( 'input', ed.targetElm );
44
  });
45
 
46
  ed.on( 'keydown', function( e ) {
inc/admin/element-classes/element-scripts/star-rating-element.js CHANGED
@@ -186,6 +186,12 @@ function starRatingNumberRatingChenge( starRatingContainer ) {
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 ) {
@@ -198,65 +204,12 @@ for( let i = 0; i < spans.length; i++ ) {
198
  }
199
  }
200
 
201
- let infArr = element.className.match( /wptb-element-((.+-)\d+)/i );
202
- let elementsSettingsTemplateJs = document.getElementsByClassName( 'wptb-element-datas' );
203
- let elementsSettings;
204
- let elementSettings;
205
- if( elementsSettingsTemplateJs.length > 0 ) {
206
- elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];
207
- elementsSettings = elementsSettingsTemplateJs.innerHTML;
208
- if( elementsSettings ) {
209
- try{
210
- elementsSettings = JSON.parse( elementsSettings );
211
- } catch( error ) {
212
- console.log( error );
213
- console.log("Json Parse Error:" + elementsSettings);
214
- }
215
- if( typeof elementsSettings === 'object' && ( 'tmpl-wptb-el-datas-' + infArr[1] ) in elementsSettings ) {
216
- elementSettings = elementsSettings['tmpl-wptb-el-datas-' + infArr[1]];
217
- }
218
- }
219
- } else {
220
- elementsSettingsTemplateJs = document.createElement( 'script' );
221
- elementsSettingsTemplateJs.setAttribute( 'type', 'text/html' );
222
- elementsSettingsTemplateJs.setAttribute( 'class', 'wptb-element-datas' );
223
- let body = document.getElementsByTagName('body')[0];
224
- body.appendChild( elementsSettingsTemplateJs );
225
- }
226
-
227
-
228
 
229
- if( ! elementSettings ) {
230
- if( ! elementsSettings || typeof elementsSettings !== 'object' ) {
231
- elementsSettings = {};
232
- }
233
-
234
- elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] = {};
235
-
236
- let listItems = element.querySelectorAll( 'li' );
237
- let listItemsNumber = listItems.length;
238
- if( listItemsNumber > 0 ) {
239
- elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-starCount'] = listItemsNumber;
240
- }
241
-
242
- let wptbSuccessBox = element.querySelector( '.wptb-success-box' );
243
- if( wptbSuccessBox ) {
244
- wptbSuccessBox.classList.add( 'wptb-number-rating-box' );
245
- wptbTextMessage = wptbSuccessBox.querySelector( '.wptb-text-message' );
246
-
247
- if( wptbTextMessage ) {
248
- wptbTextMessage.classList.add( 'wptb-number-rating' );
249
- }
250
-
251
- if( wptbSuccessBox.style.display == 'block' ) {
252
- elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-numberRatingShowHide'] = 'checked';
253
- } else if( wptbSuccessBox.style.display == 'none' ) {
254
- elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-wptb-el-' + infArr[1] + '-numberRatingShowHide'] = 'unchecked';
255
- }
256
- }
257
-
258
- if( elementsSettings ) {
259
- elementsSettings = JSON.stringify( elementsSettings );
260
- elementsSettingsTemplateJs.innerHTML = elementsSettings;
261
  }
262
  }
186
 
187
  // for old elements which were before the change of structure of the plugin
188
 
189
+ if( ! element.dataset.starCount ) {
190
+ let starsLi = element.querySelectorAll( '.wptb-rating-stars-list .wptb-rating-star' );
191
+ element.dataset.starCount = starsLi.length;
192
+ }
193
+
194
+
195
  let spans = element.querySelectorAll( 'li span' );
196
  for( let i = 0; i < spans.length; i++ ) {
197
  if( spans[i].style.fill ) {
204
  }
205
  }
206
 
207
+ let wptbSuccessBox = element.querySelector( '.wptb-success-box' );
208
+ if( wptbSuccessBox ) {
209
+ wptbSuccessBox.classList.add( 'wptb-number-rating-box' );
210
+ wptbTextMessage = wptbSuccessBox.querySelector( '.wptb-text-message' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
211
 
212
+ if( wptbTextMessage ) {
213
+ wptbTextMessage.classList.add( 'wptb-number-rating' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
214
  }
215
  }
inc/admin/element-classes/elements/button-element.php CHANGED
@@ -175,6 +175,9 @@ class Button_Element extends Element_Base_Object {
175
  'label' => __( 'Button Id', 'wp_table_builder' ),
176
  'type' => Controls_Manager::TEXT,
177
  'placeholder' => __( 'Insert Button ID Here', 'wp_table_builder' ),
 
 
 
178
  ]
179
  );
180
  }
175
  'label' => __( 'Button Id', 'wp_table_builder' ),
176
  'type' => Controls_Manager::TEXT,
177
  'placeholder' => __( 'Insert Button ID Here', 'wp_table_builder' ),
178
+ 'selectors' => [
179
+ '{{{data.container}}} .wptb-button-wrapper a' => 'id',
180
+ ]
181
  ]
182
  );
183
  }
inc/admin/element-classes/elements/custom-html-element.php CHANGED
@@ -102,6 +102,9 @@ class Custom_Html_Element extends Element_Base_Object {
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'
102
  [
103
  'label' => __( 'Insert HTML', 'wp_table_builder' ),
104
  'type' => Controls_Manager::TEXTAREA,
105
+ 'selectors' => [
106
+ '{{{data.container}}} .wptb-custom-html-wrapper',
107
+ ],
108
  'placeholder' => __( 'Insert HTML Code Here', 'wp_table_builder' ),
109
  'rows' => 5,
110
  'defaultValue' => 'Insert Custom HTML'
inc/admin/element-classes/elements/image-element.php CHANGED
@@ -146,6 +146,9 @@ class Image_Element extends Element_Base_Object {
146
  [
147
  'label' => __( 'Image Alternative Text', 'wp_table_builder' ),
148
  'type' => Controls_Manager::TEXT,
 
 
 
149
  'placeholder' => __( 'Image Alt Text', 'wp_table_builder' ),
150
  ]
151
  );
146
  [
147
  'label' => __( 'Image Alternative Text', 'wp_table_builder' ),
148
  'type' => Controls_Manager::TEXT,
149
+ 'selectors' => [
150
+ '{{{data.container}}} .wptb-image-wrapper a img' => 'alt',
151
+ ],
152
  'placeholder' => __( 'Image Alt Text', 'wp_table_builder' ),
153
  ]
154
  );
inc/admin/element-classes/elements/list-element.php CHANGED
@@ -103,8 +103,19 @@ class List_Element extends Element_Base_Object {
103
  'label' => __( 'List Type', 'wp_table_builder' ),
104
  'type' => Controls_Manager::SELECT,
105
  'options' => [
106
- ['Ordered', 'numbered'],
107
- ['Unordered', 'unordered']
 
 
 
 
 
 
 
 
 
 
 
108
  ],
109
  'selectedDefault' => 0,
110
  ]
@@ -116,10 +127,13 @@ class List_Element extends Element_Base_Object {
116
  'label' => __( 'List Icon', 'wp_table_builder' ),
117
  'type' => Controls_Manager::SELECT,
118
  'options' => [
119
- ['Circle', 'circle'],
120
- ['Square', 'square'],
121
- ['Disc', 'disc'],
122
- ['None', 'none']
 
 
 
123
  ],
124
  'selectedDefault' => 2,
125
  'appearDependOnControl' => ['select1', ['unordered'], ['numbered']]
103
  'label' => __( 'List Type', 'wp_table_builder' ),
104
  'type' => Controls_Manager::SELECT,
105
  'options' => [
106
+ ['Ordered', 'numbered', ''],
107
+ [
108
+ 'Unordered', 'unordered',
109
+ [
110
+ 'wptb-list-style-type-disc',
111
+ 'wptb-list-style-type-circle',
112
+ 'wptb-list-style-type-square',
113
+ 'wptb-list-style-type-none'
114
+ ]
115
+ ]
116
+ ],
117
+ 'selectors' => [
118
+ '{{{data.container}}} ul li p' => 'class'
119
  ],
120
  'selectedDefault' => 0,
121
  ]
127
  'label' => __( 'List Icon', 'wp_table_builder' ),
128
  'type' => Controls_Manager::SELECT,
129
  'options' => [
130
+ ['Circle', 'circle', 'wptb-list-style-type-circle'],
131
+ ['Square', 'square', 'wptb-list-style-type-square'],
132
+ ['Disc', 'disc', 'wptb-list-style-type-disc'],
133
+ ['None', 'none', 'wptb-list-style-type-none']
134
+ ],
135
+ 'selectors' => [
136
+ '{{{data.container}}} ul li p' => 'class'
137
  ],
138
  'selectedDefault' => 2,
139
  'appearDependOnControl' => ['select1', ['unordered'], ['numbered']]
inc/admin/element-classes/elements/shortcode-element.php CHANGED
@@ -102,6 +102,9 @@ class Shortcode_Element extends Element_Base_Object {
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]'
102
  [
103
  'label' => __( 'Insert Shortcode', 'wp_table_builder' ),
104
  'type' => Controls_Manager::TEXTAREA,
105
+ 'selectors' => [
106
+ '{{{data.container}}} div',
107
+ ],
108
  'placeholder' => __( 'Insert Shortcode Here', 'wp_table_builder' ),
109
  'rows' => 5,
110
  'defaultValue' => '[Shortcode]'
inc/admin/element-classes/elements/star-rating-element.php CHANGED
@@ -130,6 +130,9 @@ class Star_Rating_Element extends Element_Base_Object {
130
  'type' => Controls_Manager::NUMBER,
131
  'min' => 1,
132
  'max' => 10,
 
 
 
133
  'defaultValue' => 5,
134
  ]
135
  );
@@ -150,7 +153,11 @@ class Star_Rating_Element extends Element_Base_Object {
150
  'numberRatingShowHide',
151
  [
152
  'label' => __( 'Show Number Rating', 'wp_table_builder' ),
153
- 'type' => Controls_Manager::TOGGLE
 
 
 
 
154
  ]
155
  );
156
 
130
  'type' => Controls_Manager::NUMBER,
131
  'min' => 1,
132
  'max' => 10,
133
+ 'selectors' => [
134
+ '{{{data.container}}}' => 'data-star-count',
135
+ ],
136
  'defaultValue' => 5,
137
  ]
138
  );
153
  'numberRatingShowHide',
154
  [
155
  'label' => __( 'Show Number Rating', 'wp_table_builder' ),
156
+ 'type' => Controls_Manager::TOGGLE,
157
+ 'selectors' => [
158
+ '{{{data.container}}} .wptb-rating-stars-box .wptb-number-rating-box' => ['display', 'block', 'none'],
159
+ '{{{data.container}}} .wptb-rating-stars-box .wptb-success-box' => ['display', 'block', 'none'],
160
+ ],
161
  ]
162
  );
163
 
inc/admin/js/admin-welcome.js ADDED
File without changes
inc/admin/js/admin.js CHANGED
@@ -48,10 +48,10 @@ var WPTB_ActionsField = function WPTB_ActionsField() {
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) {
57
  el.removeChild(act);
@@ -90,8 +90,8 @@ var WPTB_ActionsField = function WPTB_ActionsField() {
90
  data.elemProt = activeElement;
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);
@@ -319,16 +319,6 @@ var WPTB_ActionsField = function WPTB_ActionsField() {
319
 
320
  var body = document.getElementsByTagName('body')[0];
321
 
322
- if (ans[2]) {
323
- var elementsSettingTemplateJs = document.createElement('script');
324
- elementsSettingTemplateJs.setAttribute('type', 'text/html');
325
- elementsSettingTemplateJs.setAttribute('class', 'wptb-element-datas');
326
-
327
- elementsSettingTemplateJs.innerHTML = ans[2];
328
-
329
- body.appendChild(elementsSettingTemplateJs);
330
- }
331
-
332
  WPTB_Table();
333
  var element = document.querySelector('.wptb-preview-table');
334
  if (element) {
@@ -344,7 +334,7 @@ var WPTB_ActionsField = function WPTB_ActionsField() {
344
  }
345
  }
346
 
347
- WPTB_LeftPanel();
348
  WPTB_Settings();
349
 
350
  var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
@@ -853,10 +843,9 @@ var WPTB_ElementObject = function WPTB_ElementObject(data) {
853
  var WPTB_ElementOptions = function WPTB_ElementOptions(element, index, kindIndexProt) {
854
 
855
  var node = element.getDOMElement();
856
-
857
- node.onclick = function () {
858
  WPTB_Helper.elementOptionsSet(element.kind, this);
859
- };
860
  };
861
  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; };
862
 
@@ -1284,63 +1273,75 @@ var WPTB_Helper = {
1284
  // function which set handler for event of changes of control
1285
  controlsInclude: function controlsInclude(element, functionHandler) {
1286
  if (element && (typeof element === 'undefined' ? 'undefined' : _typeof(element)) === 'object' && typeof functionHandler === 'function') {
1287
- element.addEventListener('element:control:active', function () {
1288
- var infArr = element.className.match(/wptb-element-(.+)-(\d+)/i),
1289
- elementKind = void 0;
 
1290
 
1291
- if (infArr && Array.isArray(infArr)) {
1292
- elementKind = infArr[1];
1293
- }
1294
-
1295
- if (!element.hasOwnProperty('сontrolsConnectIndic') || element.сontrolsConnectIndic !== true && elementKind) {
1296
- var elementsSettingsTemplateJs = document.getElementsByClassName('wptb-element-datas');
1297
- if (elementsSettingsTemplateJs.length > 0) {
1298
- (function () {
1299
- elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];
1300
-
1301
- var elementsSettings = elementsSettingsTemplateJs.innerHTML;
1302
- var controlClassesNames = [];
1303
- if (elementsSettings) {
1304
- elementsSettings = elementsSettings.trim();
1305
- elementsSettings = JSON.parse(elementsSettings);
1306
- if (elementsSettings && (typeof elementsSettings === 'undefined' ? 'undefined' : _typeof(elementsSettings)) === 'object') {
1307
- if ('tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2] in elementsSettings) {
1308
- var elementSettings = elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]];
1309
- if (elementSettings && (typeof elementSettings === 'undefined' ? 'undefined' : _typeof(elementSettings)) === 'object') {
1310
- Object.keys(elementSettings).forEach(function (key) {
1311
- var regularText = new RegExp('data-wptb-el-' + elementKind + '-(\\d+)-(.+)', "i");
1312
- var keyInfArr = key.match(regularText);
1313
- if (keyInfArr && Array.isArray(keyInfArr)) {
1314
- var controlClass = key.replace('data-', '');
1315
- controlClassesNames.push([controlClass, keyInfArr[2]]);
1316
- }
1317
- });
1318
- }
1319
- }
1320
- }
1321
- }
1322
 
1323
- var _loop = function _loop(i) {
1324
- element.addEventListener('wptb-control:' + controlClassesNames[i][0], function () {
1325
- var controls = {};
1326
- var controlName = controlClassesNames[i][1];
1327
- var control = document.getElementsByClassName(controlClassesNames[i][0]);
1328
- if (control.length > 0 && controlName) {
1329
- var targetControlValue = WPTB_Helper.targetControlValueGet(control);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1330
 
1331
- controls[controlName] = targetControlValue;
 
1332
  }
1333
 
1334
- functionHandler(controls, element);
1335
- }, false);
1336
-
1337
- element.сontrolsConnectIndic = true;
1338
- };
1339
-
1340
- for (var i = 0; i < controlClassesNames.length; i++) {
1341
- _loop(i);
1342
  }
1343
- })();
1344
  }
1345
  }
1346
  }, false);
@@ -1412,38 +1413,54 @@ var WPTB_Helper = {
1412
  var controlContainerElem = WPTB_Helper.findAncestor(targetControlElement, 'wptb-element-option');
1413
 
1414
  if (controlContainerElem) {
1415
- var showHideDependOnControlElement = function showHideDependOnControlElement(dependOnControlElementKind) {
1416
-
1417
- var elementsSettingsTemplateJs = document.getElementsByClassName('wptb-element-datas');
1418
- if (elementsSettingsTemplateJs.length > 0) {
1419
- elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];
1420
-
1421
- var elementsSettings = elementsSettingsTemplateJs.innerHTML;
1422
- if (elementsSettings) {
1423
- elementsSettings = elementsSettings.trim();
1424
- elementsSettings = JSON.parse(elementsSettings);
1425
- if (elementsSettings && (typeof elementsSettings === 'undefined' ? 'undefined' : _typeof(elementsSettings)) === 'object' && 'tmpl-wptb-el-datas-' + dependOnControlElementKind in elementsSettings) {
1426
- var elementSettings = elementsSettings['tmpl-wptb-el-datas-' + dependOnControlElementKind];
1427
- if (elementSettings && (typeof elementSettings === 'undefined' ? 'undefined' : _typeof(elementSettings)) === 'object' && 'data-wptb-el-' + dependOnControlElementKind + '-' + dependOnControlName in elementSettings) {
1428
- var elementSettingValue = elementSettings['data-wptb-el-' + dependOnControlElementKind + '-' + dependOnControlName];
1429
-
1430
- if (elementSettingValue) {
1431
- if (dependOn[1] && Array.isArray(dependOn[1]) && dependOn[1].indexOf(elementSettingValue) !== -1) {
1432
- controlContainerElem.style.display = 'block';
1433
- } else if (dependOn[2] && Array.isArray(dependOn[2]) && dependOn[2].indexOf(elementSettingValue) !== -1) {
1434
- controlContainerElem.style.display = 'none';
1435
- }
1436
- }
1437
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1438
  }
1439
  }
1440
  }
1441
  };
1442
 
1443
- showHideDependOnControlElement(infArr[1]);
1444
 
1445
- dependOnControlElement.addEventListener('change', function () {
1446
- showHideDependOnControlElement(infArr[1]);
1447
  }, false);
1448
  }
1449
  }
@@ -1646,8 +1663,9 @@ var WPTB_Helper = {
1646
  var elementOptionsGroupId = void 0;
1647
  var wptbelementOptionClass = void 0;
1648
 
1649
- // create a container for inserting controls of this item
1650
  var wptbelementOptionsContainer = document.createElement('div');
 
1651
 
1652
  var infArr = element.className.match(/wptb-element-((.+-)\d+)/i);
1653
  if (!infArr && element.classList.contains('wptb-preview-table')) {
@@ -1668,8 +1686,6 @@ var WPTB_Helper = {
1668
  if (children[_i5].style) children[_i5].style.display = 'none';
1669
  }
1670
 
1671
- wptbelementOptionsContainer.classList.add('wptb-element-options', 'wptb-options-' + infArr[1]);
1672
-
1673
  // hide wptb-elements-container and wptb-settings-section
1674
  document.getElementsByClassName('wptb-elements-container')[0].style.display = 'none';
1675
  document.getElementsByClassName('wptb-settings-section')[0].style.display = 'none';
@@ -1684,19 +1700,23 @@ var WPTB_Helper = {
1684
  wptbelementOptionClass = 'wptb-element-option';
1685
  }
1686
 
 
 
 
1687
  var jsonControlsConfigJson = tmplControlsConfig(data);
1688
  var jsonControlsConfig = JSON.parse(jsonControlsConfigJson);
1689
 
1690
  // clear elements from options group
1691
  //document.getElementById( 'element-options-group' ).innerHTML = '';
1692
  elementOptionsGroup = document.getElementById(elementOptionsGroupId);
1693
- var elementOptionsGroupChildren = elementOptionsGroup.children;
1694
  for (var _i6 = 0; _i6 < elementOptionsGroupChildren.length; _i6++) {
1695
  elementOptionsGroup.removeChild(elementOptionsGroupChildren[_i6]);
1696
  }
1697
 
1698
  // insert created container into element-option-group tag
1699
  document.getElementById(elementOptionsGroupId).appendChild(wptbelementOptionsContainer);
 
1700
 
1701
  // show created container
1702
  wptbelementOptionsContainer.style.display = 'block';
@@ -1758,7 +1778,7 @@ var WPTB_Helper = {
1758
  // run the scripts of controls
1759
  if (controlScriptsArr.length > 0) {
1760
  for (var _i7 = 0; _i7 < controlScriptsArr.length; _i7++) {
1761
- wptbelementOptionsContainer.appendChild(controlScriptsArr[_i7]);
1762
  }
1763
  }
1764
 
@@ -1767,7 +1787,7 @@ var WPTB_Helper = {
1767
  WPTB_Helper.appearDependOnControl(controlappearDependOnControl[_i8][0], controlappearDependOnControl[_i8][1]);
1768
  }
1769
 
1770
- WPTB_Helper.wptbDocumentEventGenerate('element:control:active', element);
1771
  },
1772
  // function for create, update css for element
1773
  managerExternalCssStyles: function managerExternalCssStyles(elementContainer, selector, cssName, cssValue) {
@@ -1955,7 +1975,7 @@ var WPTB_Helper = {
1955
  var bar = document.querySelector('.wptb-edit-bar');
1956
  if (bar && bar.classList.contains('visible')) {
1957
  var table = document.getElementsByClassName('wptb-preview-table')[0];
1958
- table.toggleTableEditMode();
1959
  }
1960
  }
1961
 
@@ -2148,6 +2168,49 @@ var WPTB_Helper = {
2148
  }
2149
  };
2150
  http.send(params);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2151
  }
2152
  };
2153
  var WPTB_Initializer = function WPTB_Initializer() {
@@ -2284,31 +2347,31 @@ var WPTB_LeftPanel = function WPTB_LeftPanel() {
2284
  function controlsChange(inputs, table) {
2285
  if (inputs && (typeof inputs === 'undefined' ? 'undefined' : _typeof(inputs)) === 'object') {
2286
  if (inputs.hasOwnProperty('tableTopRowsAsHeader')) {
2287
- if (inputs.tableTopRowsAsHeader == 'checked') {
2288
- var rows = table.rows;
2289
- table.classList.add('wptb-table-preview-head');
2290
- } else if (inputs.tableTopRowsAsHeader == 'unchecked') {
2291
- var _rows = table.rows;
2292
- table.classList.remove('wptb-table-preview-head');
2293
-
2294
- for (var _i = 1; _i < _rows.length; _i++) {
2295
- var thisRow = _rows[_i],
2296
- thisRowChildren = thisRow.children;
2297
- for (var j = 0; j < thisRowChildren.length; j++) {
2298
- thisRowChildren[j].removeAttribute('data-wptb-title-column');
2299
- thisRowChildren[j].removeAttribute('data-wptb-title-column-font-size');
2300
- thisRowChildren[j].removeAttribute('data-wptb-title-column-color');
2301
- thisRowChildren[j].removeAttribute('data-wptb-title-background-color');
2302
- thisRowChildren[j].removeAttribute('data-wptb-title-align');
2303
- }
2304
- }
2305
- }
2306
  } else if (inputs.hasOwnProperty('makeTableResponsive')) {
2307
- if (inputs.makeTableResponsive == 'checked') {
2308
- table.dataset.wptbAdaptiveTable = 1;
2309
- } else if (inputs.makeTableResponsive == 'unchecked') {
2310
- table.dataset.wptbAdaptiveTable = 0;
2311
- }
2312
  } else if (inputs.hasOwnProperty('applyTableContainerMaxWidth')) {
2313
  var wptbTableSetup = document.querySelector('.wptb-table-setup');
2314
  if (inputs.applyTableContainerMaxWidth == 'checked') {
@@ -2343,7 +2406,7 @@ var WPTB_LeftPanel = function WPTB_LeftPanel() {
2343
  table.tdDefaultWidth();
2344
  }
2345
  } else if (inputs.hasOwnProperty('tableManageCells')) {
2346
- table.toggleTableEditMode();
2347
  } else if (inputs.hasOwnProperty('tableAlignmentCheckbox')) {
2348
  table.tdDefaultWidth();
2349
  }
@@ -2360,8 +2423,8 @@ var WPTB_LeftPanel = function WPTB_LeftPanel() {
2360
  };
2361
 
2362
  if (table) {
2363
- document.getElementById('wptb-table-edit-mode-close').onclick = table.toggleTableEditMode;
2364
- document.getElementById('wptb-left-scroll-panel-curtain-close').onclick = table.toggleTableEditMode;
2365
  document.getElementById('wptb-add-end-row').onclick = table.addRowToTheEnd;
2366
  document.getElementById('wptb-add-start-row').onclick = table.addRowToTheStart;
2367
  document.getElementById('wptb-add-row-before').onclick = table.addRowBefore;
@@ -3168,47 +3231,6 @@ var array = [],
3168
  }
3169
  }
3170
 
3171
- /*
3172
- * This just toggles visibility of cell edit bar, and toggles
3173
- * cell selecting mode.
3174
- */
3175
-
3176
- table.toggleTableEditMode = function () {
3177
- var bar = document.getElementsByClassName('wptb-edit-bar'),
3178
- cellModeBackground = document.getElementById('wptb-cell_mode_background'),
3179
- leftScrollPanelCurtain = document.getElementById('wptb-left-scroll-panel-curtain'),
3180
- leftScrollPanelCellSettings = document.getElementById('wptb-left-scroll-panel-cell-settings'),
3181
- wptbPreviewTable = document.getElementsByClassName('wptb-preview-table');
3182
- if (wptbPreviewTable.length > 0) {
3183
- wptbPreviewTable = wptbPreviewTable[0];
3184
- }
3185
-
3186
- if (bar.length > 0) {
3187
- for (var _i2 = 0; _i2 < bar.length; _i2++) {
3188
- if (bar[_i2].classList.contains('visible')) {
3189
- document.select.deactivateMultipleSelectMode();
3190
- bar[_i2].classList.remove('visible');
3191
- cellModeBackground.classList.remove('visible');
3192
- leftScrollPanelCurtain.classList.remove('visible');
3193
- leftScrollPanelCellSettings.classList.remove('visible');
3194
- wptbPreviewTable.parentNode.classList.remove('wptb-preview-table-manage-cells');
3195
- var wptbPreviewTableTds = wptbPreviewTable.getElementsByTagName('td');
3196
- if (wptbPreviewTableTds.length > 0) {
3197
- for (var _i3 = 0; _i3 < wptbPreviewTableTds.length; _i3++) {
3198
- wptbPreviewTableTds[_i3].classList.remove('wptb-highlighted');
3199
- }
3200
- }
3201
- } else {
3202
- document.select.activateMultipleSelectMode();
3203
- bar[_i2].classList.add('visible');
3204
- cellModeBackground.classList.add('visible');
3205
- leftScrollPanelCurtain.classList.add('visible');
3206
- wptbPreviewTable.parentNode.classList.add('wptb-preview-table-manage-cells');
3207
- }
3208
- }
3209
- }
3210
- };
3211
-
3212
  /*
3213
  * For assigning to each cell xIndex and y Index attributes,
3214
  * these are the column number and row number of cell in table.
@@ -3309,8 +3331,8 @@ var array = [],
3309
  var tableRows = table.rows;
3310
  var widthIsSet = false;
3311
  var arrayTdsFromPreviousRow = [];
3312
- for (var _i4 = 0; _i4 < tableRows.length; _i4++) {
3313
- var _row = tableRows[_i4];
3314
  var tds = _row.children;
3315
  for (var _j = 0; _j < tds.length; _j++) {
3316
  var td = tds[_j];
@@ -3327,7 +3349,7 @@ var array = [],
3327
  } else {
3328
  td.style.width = null;
3329
  td.dataset.wptbFixedWidth = value;
3330
- if (_i4 == tableRows.length - 1 && !widthIsSet) {
3331
  tableTdsFor(dataXIndex, colspan + 1);
3332
  }
3333
  }
@@ -3385,8 +3407,8 @@ var array = [],
3385
  var borderRightWidth = tableFullStyleObj.getPropertyValue('border-right-width');
3386
  var tableBorderCommon = parseFloat(borderLeftWidth, 10) + parseFloat(borderRightWidth, 10);
3387
 
3388
- for (var _i5 = 0; _i5 < rows.length; _i5++) {
3389
- var tds = rows[_i5].children;
3390
  for (var _j2 = 0; _j2 < tds.length; _j2++) {
3391
  var td = tds[_j2];
3392
 
@@ -3454,16 +3476,16 @@ var array = [],
3454
  }
3455
  }
3456
 
3457
- for (var _i6 = 0; _i6 < arrayCellsWidthFixedHelper.length; _i6++) {
3458
- if (arrayCellsWidthFixedHelper[_i6]) {
3459
- tableTdsSumMaxWidthFixed += arrayCellsWidthFixedHelper[_i6];
3460
  }
3461
  }
3462
 
3463
  var CellsWidthAutoCount = 0;
3464
- for (var _i7 = 0; _i7 < arrayCellsWidthAutoHelper.length; _i7++) {
3465
- if (arrayCellsWidthAutoHelper[_i7]) {
3466
- tableTdsSumMaxWidthAuto += arrayCellsWidthAutoHelper[_i7];
3467
  CellsWidthAutoCount++;
3468
  }
3469
  }
@@ -3489,7 +3511,7 @@ var array = [],
3489
  if (CellsWidthAutoCount) {
3490
  table.style.minWidth = '100%';
3491
  if (table.mergingСellsHorizontally) {
3492
- table.style.width = null;
3493
  var tableTdsWidthAutoCommon = wptbTableSetupWidth - tableTdsSumMaxWidthFixed;
3494
  tableTdWidthAuto = tableTdsWidthAutoCommon / CellsWidthAutoCount;
3495
  tableTdWidthAuto = tableTdWidthAuto - tdPaddingCommon - tableTdBorderCommonWidth;
@@ -3498,14 +3520,14 @@ var array = [],
3498
  table.style.width = '100%';
3499
  }
3500
  } else {
3501
- table.style.width = null;
3502
  table.style.minWidth = null;
3503
  table.style.maxWidth = null;
3504
  }
3505
  } else {
3506
  table.style.maxWidth = null;
3507
  table.style.minWidth = tableTdsSumMaxWidth + 'px';
3508
- table.style.width = null;
3509
  tableTdWidthAuto = '100';
3510
  styleElementCreate = true;
3511
  }
@@ -3546,6 +3568,10 @@ var array = [],
3546
  } else {
3547
  wptbTableSetup.style.float = wptbTableAlignment;
3548
  }
 
 
 
 
3549
  } else {
3550
  table.style.float = null;
3551
  }
@@ -3562,8 +3588,8 @@ var array = [],
3562
  var tableRows = table.rows;
3563
  var heightIsSet = false;
3564
  var arrayTdsPrevious = [];
3565
- for (var _i8 = 0; _i8 < tableRows.length; _i8++) {
3566
- var _row2 = tableRows[_i8];
3567
  var tds = _row2.children;
3568
  for (var _j3 = 0; _j3 < tds.length; _j3++) {
3569
  var td = tds[_j3];
@@ -3621,14 +3647,14 @@ var array = [],
3621
  table.mergingCellsVertically = false;
3622
  table.dataset.reconstraction = 1;
3623
  var forBreak = 0;
3624
- for (var _i9 = 0; _i9 < tds.length; _i9++) {
3625
- if (tds[_i9].colSpan > 1) {
3626
  table.dataset.reconstraction = 0;
3627
  table.mergingСellsHorizontally = true;
3628
  forBreak++;
3629
  }
3630
 
3631
- if (tds[_i9].rowSpan > 1) {
3632
  table.dataset.reconstraction = 0;
3633
  table.mergingCellsVertically = true;
3634
  forBreak++;
@@ -3932,13 +3958,13 @@ var array = [],
3932
  cellStyle = cell.getAttribute('style'),
3933
  row = getCoords(cell)[0],
3934
  cellNew = void 0;
3935
- for (var _i10 = row - 1; _i10 >= 0; _i10--) {
3936
- var rowChildren = table.rows[_i10].children;
3937
  var rowChildrenLength = rowChildren.length;
3938
  if (rowChildrenLength > 0) {
3939
  for (var _j4 = 0; _j4 < rowChildrenLength; _j4++) {
3940
  if (rowChildren[_j4].rowSpan == 1) {
3941
- row = _i10;
3942
  cellNew = true;
3943
  break;
3944
  }
@@ -3980,14 +4006,14 @@ var array = [],
3980
 
3981
  var cellsColSpan = 0;
3982
  if (rowAfter < table.rows.length - 1) {
3983
- for (var _i11 = 0; _i11 <= rowAfter; _i11++) {
3984
- var tableRowsIChildren = table.rows[_i11].children,
3985
  tableRIChildrenLength = tableRowsIChildren.length;
3986
  if (tableRIChildrenLength > 0) {
3987
  for (var _j5 = 0; _j5 < tableRIChildrenLength; _j5++) {
3988
  var rowIRowSpan = tableRowsIChildren[_j5].rowSpan;
3989
 
3990
- if (rowIRowSpan - 1 + _i11 > rowAfter) {
3991
  tableRowsIChildren[_j5].rowSpan++;
3992
  }
3993
  }
@@ -3999,8 +4025,8 @@ var array = [],
3999
  rNextChildrenLength = rNextChildren.length;
4000
 
4001
  if (rNextChildrenLength > 0) {
4002
- for (var _i12 = 0; _i12 < rNextChildrenLength; _i12++) {
4003
- cellsColSpan += rNextChildren[_i12].colSpan;
4004
  }
4005
  }
4006
  } else {
@@ -4113,20 +4139,20 @@ var array = [],
4113
  tds = [].slice.call(document.getElementsByClassName('wptb-highlighted'), 1),
4114
  tdsChildrenNew = [];
4115
 
4116
- for (var _i13 = 0; _i13 < tds.length; _i13++) {
4117
- var tdsInternalElements = tds[_i13].getElementsByClassName('wptb-ph-element');
4118
  if (tdsInternalElements.length > 0) {
4119
  var tdsIntElemLength = tdsInternalElements.length;
4120
  for (var _j6 = 0; _j6 < tdsIntElemLength; _j6++) {
4121
  tdsChildrenNew.push(tdsInternalElements[_j6]);
4122
  }
4123
  }
4124
- var p = tds[_i13].parentNode;
4125
- p.removeChild(tds[_i13]);
4126
  }
4127
  if (tdsChildrenNew.length > 0) {
4128
- for (var _i14 = 0; _i14 < tdsChildrenNew.length; _i14++) {
4129
- first.appendChild(tdsChildrenNew[_i14]);
4130
  }
4131
  }
4132
 
@@ -4178,7 +4204,7 @@ var array = [],
4178
  cell.rowSpan = 1;
4179
  cell.colSpan = 1;
4180
 
4181
- for (var _i15 = 1; _i15 < colspan; _i15++) {
4182
  var td = new WPTB_Cell(mark);
4183
  td.getDOMElement().setAttribute('style', cellStyles);
4184
  td.getDOMElement().classList.add('wptb-highlighted');
@@ -4190,9 +4216,9 @@ var array = [],
4190
  }
4191
 
4192
  if (rowspan > 1) {
4193
- for (var _i16 = 1; _i16 < rowspan; _i16++) {
4194
  var rowChildInsertBefore = undefined,
4195
- rowNext = table.rows[row + _i16],
4196
  rowChildren = rowNext.children,
4197
  rowChildrenLength = rowChildren.length;
4198
 
@@ -4307,7 +4333,7 @@ var array = [],
4307
 
4308
  if (rowspan == undefined) rowspan = 1;
4309
 
4310
- for (var _i17 = 0; _i17 < rowspan; _i17++) {
4311
  thisRow = table.rows[row];
4312
  var thisRowChildren = thisRow.children,
4313
  nextRow = table.rows[row + 1],
@@ -4371,7 +4397,7 @@ var array = [],
4371
  table.getElementsByTagName('tbody')[0].removeChild(table.rows[row]);
4372
 
4373
  if (table.rows.length == 0) {
4374
- table.toggleTableEditMode();
4375
  wptbTableSetup.innerHTML = '';
4376
  document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';
4377
  var wptbSaveBtn = document.getElementsByClassName('wptb-save-btn');
@@ -4402,7 +4428,7 @@ var array = [],
4402
  cellXIndex = cell.dataset.xIndex,
4403
  colspan = cell.colSpan;
4404
 
4405
- for (var _i18 = 0; _i18 < colspan; _i18++) {
4406
  for (var _j10 = 0; _j10 < table.rows.length; _j10++) {
4407
  var rowChildren = table.rows[_j10].children;
4408
  var rowChildrenLength = rowChildren.length;
@@ -4432,7 +4458,7 @@ var array = [],
4432
  maxAmountOfCells--;
4433
 
4434
  if (table.querySelectorAll('td').length == 0) {
4435
- table.toggleTableEditMode();
4436
  wptbTableSetup.innerHTML = '';
4437
  document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';
4438
  var wptbSaveBtn = document.getElementsByClassName('wptb-save-btn');
@@ -4577,17 +4603,7 @@ var WPTB_TableStateSaveManager = function WPTB_TableStateSaveManager() {
4577
  }
4578
  }
4579
 
4580
- var wptbElementDatas = document.getElementsByClassName('wptb-element-datas');
4581
- if (wptbElementDatas.length > 0) {
4582
- wptbElementDatas = wptbElementDatas[0];
4583
- wptbElementDatas = wptbElementDatas.innerHTML;
4584
- } else {
4585
- wptbElementDatas = '';
4586
- }
4587
-
4588
- var styleObjJson = WPTB_Helper.elementsStylesConvertToObject();
4589
-
4590
- window.wptbTableStateSaving.push([wptbNewPreviewTable, cssForTdsWidthAutoValue, wptbElementDatas, styleObjJson]);
4591
 
4592
  // set new number of state which is showed now
4593
  window.wptbTableStateNumberShow = window.wptbTableStateSaving.length - 1;
@@ -4725,31 +4741,6 @@ var WPTB_TableStateSaveManager = function WPTB_TableStateSaveManager() {
4725
  body = body[0];
4726
  }
4727
 
4728
- // add or change or delete script element from the bottom page which have data for several control types
4729
- var wptbElementDatas = document.getElementsByClassName('wptb-element-datas');
4730
- if (window.wptbTableStateSaving[window.wptbTableStateNumberShow] && window.wptbTableStateSaving[window.wptbTableStateNumberShow][2]) {
4731
-
4732
- if (wptbElementDatas.length > 0) {
4733
- wptbElementDatas = wptbElementDatas[0];
4734
- } else {
4735
- wptbElementDatas = document.createElement('sctipt');
4736
- wptbElementDatas.classList.add('wptb-element-datas');
4737
- body.appendChild(wptbElementDatas);
4738
- }
4739
-
4740
- wptbElementDatas.innerHTML = window.wptbTableStateSaving[window.wptbTableStateNumberShow][2];
4741
- } else {
4742
- if (wptbElementDatas.length > 0) {
4743
- wptbElementDatas = wptbElementDatas[0];
4744
- body.removeChild(wptbElementDatas);
4745
- }
4746
- }
4747
-
4748
- // runs function which adds or create or delete CSS in the head for several element settings
4749
- if (window.wptbTableStateSaving[window.wptbTableStateNumberShow]) {
4750
- WPTB_Helper.elementsStylesSetFromObject(window.wptbTableStateSaving[window.wptbTableStateNumberShow][3]);
4751
- }
4752
-
4753
  WPTB_Helper.elementOptionsPanelClear();
4754
  WPTB_LeftPanel();
4755
 
@@ -4917,7 +4908,7 @@ var applyGenericItemSettings = function applyGenericItemSettings(element, kindIn
4917
  var wptbNodeattributes = [].concat(_toConsumableArray(node.attributes));
4918
  for (var _i = 0; _i < wptbNodeattributes.length; _i++) {
4919
  if (wptbNodeattributes[_i] && _typeof(wptbNodeattributes[_i]) === 'object' && wptbNodeattributes[_i].nodeName) {
4920
- var regularText = new RegExp('data-wptb-el-' + element.kind + '-(\\d+)-(.+)', "i");
4921
  var attr = wptbNodeattributes[_i].nodeName.match(regularText);
4922
  if (attr && Array.isArray(attr)) {
4923
  var newDataAttributeName = wptbNodeattributes[_i].nodeName.replace(element.kind + '-' + attr[1], element.kind + '-' + index);
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) {
57
  el.removeChild(act);
90
  data.elemProt = activeElement;
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);
319
 
320
  var body = document.getElementsByTagName('body')[0];
321
 
 
 
 
 
 
 
 
 
 
 
322
  WPTB_Table();
323
  var element = document.querySelector('.wptb-preview-table');
324
  if (element) {
334
  }
335
  }
336
 
337
+ //WPTB_LeftPanel();
338
  WPTB_Settings();
339
 
340
  var wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
843
  var WPTB_ElementOptions = function WPTB_ElementOptions(element, index, kindIndexProt) {
844
 
845
  var node = element.getDOMElement();
846
+ node.addEventListener('click', function () {
 
847
  WPTB_Helper.elementOptionsSet(element.kind, this);
848
+ }, { capture: true });
849
  };
850
  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; };
851
 
1273
  // function which set handler for event of changes of control
1274
  controlsInclude: function controlsInclude(element, functionHandler) {
1275
  if (element && (typeof element === 'undefined' ? 'undefined' : _typeof(element)) === 'object' && typeof functionHandler === 'function') {
1276
+ element.addEventListener('element:controls:active', function () {
1277
+ if (!element.hasOwnProperty('сontrolsConnectIndic') || element.сontrolsConnectIndic !== true) {
1278
+ var infArr = element.className.match(/wptb-element-(.+)-(\d+)/i),
1279
+ elementKind = void 0;
1280
 
1281
+ if (infArr && Array.isArray(infArr)) {
1282
+ elementKind = infArr[1];
1283
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1284
 
1285
+ // if( ! element.hasOwnProperty( 'сontrolsConnectIndic' ) || element.сontrolsConnectIndic !== true && elementKind ) {
1286
+ // let elementsSettingsTemplateJs = document.getElementsByClassName( 'wptb-element-datas' );
1287
+ // if( elementsSettingsTemplateJs.length > 0 ) {
1288
+ // elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];
1289
+ //
1290
+ // let elementsSettings = elementsSettingsTemplateJs.innerHTML;
1291
+ // let controlClassesNames = [];
1292
+ // if( elementsSettings ) {
1293
+ // elementsSettings = elementsSettings.trim();
1294
+ // elementsSettings = JSON.parse( elementsSettings );
1295
+ // if( elementsSettings && typeof elementsSettings === 'object' ) {
1296
+ // if( 'tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2] in elementsSettings ) {
1297
+ // let elementSettings = elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]];
1298
+ // if( elementSettings && typeof elementSettings === 'object' ) {
1299
+ // Object.keys( elementSettings ).forEach( function( key ) {
1300
+ // let regularText = new RegExp( 'data-wptb-el-' + elementKind + '-(\\d+)-([a-zA-Z0-9_-]+)', "i" );
1301
+ // let keyInfArr = key.match( regularText );
1302
+ // if( keyInfArr && Array.isArray( keyInfArr ) ) {
1303
+ // let controlClass = key.replace( 'data-', '' );
1304
+ // controlClassesNames.push( [controlClass, keyInfArr[2]] );
1305
+ // }
1306
+ // });
1307
+ // }
1308
+ // }
1309
+ // }
1310
+ // }
1311
+ // }
1312
+ // }
1313
+ if (elementKind) {
1314
+ var elementOptionsContainer = document.querySelector('.wptb-element-options.wptb-options-' + infArr[1] + '-' + infArr[2]);
1315
+
1316
+ var elementOptions = elementOptionsContainer.querySelectorAll('.wptb-element-option');
1317
+
1318
+ for (var i = 0; i < elementOptions.length; i++) {
1319
+ var controlActiveElement = elementOptions[i].querySelector('.wptb-element-property');
1320
+ if (controlActiveElement) {
1321
+ (function () {
1322
+ var regularText = new RegExp('wptb-el-' + elementKind + '-(\\d+)-([a-zA-Z0-9_-]+)', "i");
1323
+ var controlInfArr = controlActiveElement.className.match(regularText);
1324
+ if (controlInfArr && Array.isArray(controlInfArr)) {
1325
+ var controlUnicClassName = controlInfArr[0];
1326
+
1327
+ element.addEventListener('wptb-control:' + controlUnicClassName, function () {
1328
+ var controls = {};
1329
+ var controlName = controlInfArr[2];
1330
+ var control = document.getElementsByClassName(controlUnicClassName);
1331
+ if (control.length > 0 && controlName) {
1332
+ var targetControlValue = WPTB_Helper.targetControlValueGet(control);
1333
+
1334
+ controls[controlName] = targetControlValue;
1335
+ }
1336
 
1337
+ functionHandler(controls, element);
1338
+ }, false);
1339
  }
1340
 
1341
+ element.сontrolsConnectIndic = true;
1342
+ })();
 
 
 
 
 
 
1343
  }
1344
+ }
1345
  }
1346
  }
1347
  }, false);
1413
  var controlContainerElem = WPTB_Helper.findAncestor(targetControlElement, 'wptb-element-option');
1414
 
1415
  if (controlContainerElem) {
1416
+ var showHideDependOnControlElement = function showHideDependOnControlElement(dependOnControlElementClass, dependOn) {
1417
+
1418
+ // let elementsSettingsTemplateJs = document.getElementsByClassName( 'wptb-element-datas' );
1419
+ // if( elementsSettingsTemplateJs.length > 0 ) {
1420
+ // elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];
1421
+ //
1422
+ // let elementsSettings = elementsSettingsTemplateJs.innerHTML;
1423
+ // if( elementsSettings ) {
1424
+ // elementsSettings = elementsSettings.trim();
1425
+ // elementsSettings = JSON.parse( elementsSettings );
1426
+ // if( elementsSettings && typeof elementsSettings === 'object' &&
1427
+ // ( 'tmpl-wptb-el-datas-' + dependOnControlElementKind ) in elementsSettings ) {
1428
+ // let elementSettings = elementsSettings['tmpl-wptb-el-datas-' + dependOnControlElementKind];
1429
+ // if( elementSettings && typeof elementSettings === 'object' &&
1430
+ // ( 'data-wptb-el-' + dependOnControlElementKind + '-' + dependOnControlName ) in elementSettings ) {
1431
+ // let elementSettingValue = elementSettings['data-wptb-el-' + dependOnControlElementKind + '-' + dependOnControlName];
1432
+ //
1433
+ // if( elementSettingValue ) {
1434
+ // if( dependOn[1] && Array.isArray( dependOn[1] ) &&
1435
+ // ( dependOn[1].indexOf( elementSettingValue ) !== -1 ) ) {
1436
+ // controlContainerElem.style.display = 'block';
1437
+ // } else if( dependOn[2] && Array.isArray( dependOn[2] ) &&
1438
+ // ( dependOn[2].indexOf( elementSettingValue ) !== -1 ) ) {
1439
+ // controlContainerElem.style.display = 'none';
1440
+ // }
1441
+ // }
1442
+ // }
1443
+ // }
1444
+ // }
1445
+ // }
1446
+ if (dependOnControlElementClass) {
1447
+ var dependOnControlElements = document.getElementsByClassName(dependOnControlElementClass);
1448
+ if (dependOnControlElements.length > 0) {
1449
+ var targetControlValue = WPTB_Helper.targetControlValueGet(dependOnControlElements);
1450
+
1451
+ if (dependOn[1] && Array.isArray(dependOn[1]) && dependOn[1].indexOf(targetControlValue) !== -1) {
1452
+ controlContainerElem.style.display = 'block';
1453
+ } else if (dependOn[2] && Array.isArray(dependOn[2]) && dependOn[2].indexOf(targetControlValue) !== -1) {
1454
+ controlContainerElem.style.display = 'none';
1455
  }
1456
  }
1457
  }
1458
  };
1459
 
1460
+ showHideDependOnControlElement(dependOnControlElementClass, dependOn);
1461
 
1462
+ dependOnControlElement.addEventListener('change', function (event) {
1463
+ showHideDependOnControlElement(dependOnControlElementClass, dependOn);
1464
  }, false);
1465
  }
1466
  }
1663
  var elementOptionsGroupId = void 0;
1664
  var wptbelementOptionClass = void 0;
1665
 
1666
+ // create containers for inserting controls of this item and their scripts
1667
  var wptbelementOptionsContainer = document.createElement('div');
1668
+ var wptbelementOptionsScriptsContainer = document.createElement('div');
1669
 
1670
  var infArr = element.className.match(/wptb-element-((.+-)\d+)/i);
1671
  if (!infArr && element.classList.contains('wptb-preview-table')) {
1686
  if (children[_i5].style) children[_i5].style.display = 'none';
1687
  }
1688
 
 
 
1689
  // hide wptb-elements-container and wptb-settings-section
1690
  document.getElementsByClassName('wptb-elements-container')[0].style.display = 'none';
1691
  document.getElementsByClassName('wptb-settings-section')[0].style.display = 'none';
1700
  wptbelementOptionClass = 'wptb-element-option';
1701
  }
1702
 
1703
+ wptbelementOptionsContainer.classList.add('wptb-element-options', 'wptb-options-' + infArr[1]);
1704
+ wptbelementOptionsScriptsContainer.classList.add('wptb-element-options-scripts', 'wptb-options-' + infArr[1]);
1705
+
1706
  var jsonControlsConfigJson = tmplControlsConfig(data);
1707
  var jsonControlsConfig = JSON.parse(jsonControlsConfigJson);
1708
 
1709
  // clear elements from options group
1710
  //document.getElementById( 'element-options-group' ).innerHTML = '';
1711
  elementOptionsGroup = document.getElementById(elementOptionsGroupId);
1712
+ var elementOptionsGroupChildren = [].concat(_toConsumableArray(elementOptionsGroup.children));
1713
  for (var _i6 = 0; _i6 < elementOptionsGroupChildren.length; _i6++) {
1714
  elementOptionsGroup.removeChild(elementOptionsGroupChildren[_i6]);
1715
  }
1716
 
1717
  // insert created container into element-option-group tag
1718
  document.getElementById(elementOptionsGroupId).appendChild(wptbelementOptionsContainer);
1719
+ document.getElementById(elementOptionsGroupId).appendChild(wptbelementOptionsScriptsContainer);
1720
 
1721
  // show created container
1722
  wptbelementOptionsContainer.style.display = 'block';
1778
  // run the scripts of controls
1779
  if (controlScriptsArr.length > 0) {
1780
  for (var _i7 = 0; _i7 < controlScriptsArr.length; _i7++) {
1781
+ wptbelementOptionsScriptsContainer.appendChild(controlScriptsArr[_i7]);
1782
  }
1783
  }
1784
 
1787
  WPTB_Helper.appearDependOnControl(controlappearDependOnControl[_i8][0], controlappearDependOnControl[_i8][1]);
1788
  }
1789
 
1790
+ WPTB_Helper.wptbDocumentEventGenerate('element:controls:active', element);
1791
  },
1792
  // function for create, update css for element
1793
  managerExternalCssStyles: function managerExternalCssStyles(elementContainer, selector, cssName, cssValue) {
1975
  var bar = document.querySelector('.wptb-edit-bar');
1976
  if (bar && bar.classList.contains('visible')) {
1977
  var table = document.getElementsByClassName('wptb-preview-table')[0];
1978
+ WPTB_Helper.toggleTableEditMode();
1979
  }
1980
  }
1981
 
2168
  }
2169
  };
2170
  http.send(params);
2171
+ },
2172
+
2173
+ /*
2174
+ * This just toggles visibility of cell edit bar, and toggles
2175
+ * cell selecting mode.
2176
+ */
2177
+
2178
+ toggleTableEditMode: function toggleTableEditMode() {
2179
+ var close = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
2180
+
2181
+ var bar = document.getElementsByClassName('wptb-edit-bar'),
2182
+ cellModeBackground = document.getElementById('wptb-cell_mode_background'),
2183
+ leftScrollPanelCurtain = document.getElementById('wptb-left-scroll-panel-curtain'),
2184
+ leftScrollPanelCellSettings = document.getElementById('wptb-left-scroll-panel-cell-settings'),
2185
+ wptbPreviewTable = document.getElementsByClassName('wptb-preview-table');
2186
+ if (wptbPreviewTable.length > 0) {
2187
+ wptbPreviewTable = wptbPreviewTable[0];
2188
+ }
2189
+
2190
+ if (bar.length > 0) {
2191
+ for (var i = 0; i < bar.length; i++) {
2192
+ if (bar[i].classList.contains('visible')) {
2193
+ document.select.deactivateMultipleSelectMode();
2194
+ bar[i].classList.remove('visible');
2195
+ cellModeBackground.classList.remove('visible');
2196
+ leftScrollPanelCurtain.classList.remove('visible');
2197
+ leftScrollPanelCellSettings.classList.remove('visible');
2198
+ wptbPreviewTable.parentNode.classList.remove('wptb-preview-table-manage-cells');
2199
+ var wptbPreviewTableTds = wptbPreviewTable.getElementsByTagName('td');
2200
+ if (wptbPreviewTableTds.length > 0) {
2201
+ for (var _i9 = 0; _i9 < wptbPreviewTableTds.length; _i9++) {
2202
+ wptbPreviewTableTds[_i9].classList.remove('wptb-highlighted');
2203
+ }
2204
+ }
2205
+ } else if (!close) {
2206
+ document.select.activateMultipleSelectMode();
2207
+ bar[i].classList.add('visible');
2208
+ cellModeBackground.classList.add('visible');
2209
+ leftScrollPanelCurtain.classList.add('visible');
2210
+ wptbPreviewTable.parentNode.classList.add('wptb-preview-table-manage-cells');
2211
+ }
2212
+ }
2213
+ }
2214
  }
2215
  };
2216
  var WPTB_Initializer = function WPTB_Initializer() {
2347
  function controlsChange(inputs, table) {
2348
  if (inputs && (typeof inputs === 'undefined' ? 'undefined' : _typeof(inputs)) === 'object') {
2349
  if (inputs.hasOwnProperty('tableTopRowsAsHeader')) {
2350
+ // if( inputs.tableTopRowsAsHeader == 'checked' ) {
2351
+ // let rows = table.rows;
2352
+ // table.classList.add( 'wptb-table-preview-head' );
2353
+ // } else if( inputs.tableTopRowsAsHeader == 'unchecked' ) {
2354
+ // let rows = table.rows;
2355
+ // table.classList.remove( 'wptb-table-preview-head' );
2356
+ //
2357
+ // for ( let i = 1; i < rows.length; i++ ) {
2358
+ // let thisRow = rows[i],
2359
+ // thisRowChildren = thisRow.children;
2360
+ // for( let j = 0; j < thisRowChildren.length; j++ ) {
2361
+ // thisRowChildren[j].removeAttribute( 'data-wptb-title-column' );
2362
+ // thisRowChildren[j].removeAttribute( 'data-wptb-title-column-font-size' );
2363
+ // thisRowChildren[j].removeAttribute( 'data-wptb-title-column-color' );
2364
+ // thisRowChildren[j].removeAttribute( 'data-wptb-title-background-color' );
2365
+ // thisRowChildren[j].removeAttribute( 'data-wptb-title-align' );
2366
+ // }
2367
+ // }
2368
+ // }
2369
  } else if (inputs.hasOwnProperty('makeTableResponsive')) {
2370
+ // if( inputs.makeTableResponsive == 'checked' ) {
2371
+ // table.dataset.wptbAdaptiveTable = 1;
2372
+ // } else if( inputs.makeTableResponsive == 'unchecked' ) {
2373
+ // table.dataset.wptbAdaptiveTable = 0;
2374
+ // }
2375
  } else if (inputs.hasOwnProperty('applyTableContainerMaxWidth')) {
2376
  var wptbTableSetup = document.querySelector('.wptb-table-setup');
2377
  if (inputs.applyTableContainerMaxWidth == 'checked') {
2406
  table.tdDefaultWidth();
2407
  }
2408
  } else if (inputs.hasOwnProperty('tableManageCells')) {
2409
+ WPTB_Helper.toggleTableEditMode();
2410
  } else if (inputs.hasOwnProperty('tableAlignmentCheckbox')) {
2411
  table.tdDefaultWidth();
2412
  }
2423
  };
2424
 
2425
  if (table) {
2426
+ document.getElementById('wptb-table-edit-mode-close').onclick = WPTB_Helper.toggleTableEditMode;
2427
+ document.getElementById('wptb-left-scroll-panel-curtain-close').onclick = WPTB_Helper.toggleTableEditMode;
2428
  document.getElementById('wptb-add-end-row').onclick = table.addRowToTheEnd;
2429
  document.getElementById('wptb-add-start-row').onclick = table.addRowToTheStart;
2430
  document.getElementById('wptb-add-row-before').onclick = table.addRowBefore;
3231
  }
3232
  }
3233
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3234
  /*
3235
  * For assigning to each cell xIndex and y Index attributes,
3236
  * these are the column number and row number of cell in table.
3331
  var tableRows = table.rows;
3332
  var widthIsSet = false;
3333
  var arrayTdsFromPreviousRow = [];
3334
+ for (var _i2 = 0; _i2 < tableRows.length; _i2++) {
3335
+ var _row = tableRows[_i2];
3336
  var tds = _row.children;
3337
  for (var _j = 0; _j < tds.length; _j++) {
3338
  var td = tds[_j];
3349
  } else {
3350
  td.style.width = null;
3351
  td.dataset.wptbFixedWidth = value;
3352
+ if (_i2 == tableRows.length - 1 && !widthIsSet) {
3353
  tableTdsFor(dataXIndex, colspan + 1);
3354
  }
3355
  }
3407
  var borderRightWidth = tableFullStyleObj.getPropertyValue('border-right-width');
3408
  var tableBorderCommon = parseFloat(borderLeftWidth, 10) + parseFloat(borderRightWidth, 10);
3409
 
3410
+ for (var _i3 = 0; _i3 < rows.length; _i3++) {
3411
+ var tds = rows[_i3].children;
3412
  for (var _j2 = 0; _j2 < tds.length; _j2++) {
3413
  var td = tds[_j2];
3414
 
3476
  }
3477
  }
3478
 
3479
+ for (var _i4 = 0; _i4 < arrayCellsWidthFixedHelper.length; _i4++) {
3480
+ if (arrayCellsWidthFixedHelper[_i4]) {
3481
+ tableTdsSumMaxWidthFixed += arrayCellsWidthFixedHelper[_i4];
3482
  }
3483
  }
3484
 
3485
  var CellsWidthAutoCount = 0;
3486
+ for (var _i5 = 0; _i5 < arrayCellsWidthAutoHelper.length; _i5++) {
3487
+ if (arrayCellsWidthAutoHelper[_i5]) {
3488
+ tableTdsSumMaxWidthAuto += arrayCellsWidthAutoHelper[_i5];
3489
  CellsWidthAutoCount++;
3490
  }
3491
  }
3511
  if (CellsWidthAutoCount) {
3512
  table.style.minWidth = '100%';
3513
  if (table.mergingСellsHorizontally) {
3514
+ table.style.width = 'auto';
3515
  var tableTdsWidthAutoCommon = wptbTableSetupWidth - tableTdsSumMaxWidthFixed;
3516
  tableTdWidthAuto = tableTdsWidthAutoCommon / CellsWidthAutoCount;
3517
  tableTdWidthAuto = tableTdWidthAuto - tdPaddingCommon - tableTdBorderCommonWidth;
3520
  table.style.width = '100%';
3521
  }
3522
  } else {
3523
+ table.style.width = 'auto';
3524
  table.style.minWidth = null;
3525
  table.style.maxWidth = null;
3526
  }
3527
  } else {
3528
  table.style.maxWidth = null;
3529
  table.style.minWidth = tableTdsSumMaxWidth + 'px';
3530
+ table.style.width = 'auto';
3531
  tableTdWidthAuto = '100';
3532
  styleElementCreate = true;
3533
  }
3568
  } else {
3569
  wptbTableSetup.style.float = wptbTableAlignment;
3570
  }
3571
+
3572
+ if (tableTdWidthAuto && table.dataset.wptbTableContainerMaxWidth && table.offsetWidth < table.dataset.wptbTableContainerMaxWidth) {
3573
+ table.style.width = '100%';
3574
+ }
3575
  } else {
3576
  table.style.float = null;
3577
  }
3588
  var tableRows = table.rows;
3589
  var heightIsSet = false;
3590
  var arrayTdsPrevious = [];
3591
+ for (var _i6 = 0; _i6 < tableRows.length; _i6++) {
3592
+ var _row2 = tableRows[_i6];
3593
  var tds = _row2.children;
3594
  for (var _j3 = 0; _j3 < tds.length; _j3++) {
3595
  var td = tds[_j3];
3647
  table.mergingCellsVertically = false;
3648
  table.dataset.reconstraction = 1;
3649
  var forBreak = 0;
3650
+ for (var _i7 = 0; _i7 < tds.length; _i7++) {
3651
+ if (tds[_i7].colSpan > 1) {
3652
  table.dataset.reconstraction = 0;
3653
  table.mergingСellsHorizontally = true;
3654
  forBreak++;
3655
  }
3656
 
3657
+ if (tds[_i7].rowSpan > 1) {
3658
  table.dataset.reconstraction = 0;
3659
  table.mergingCellsVertically = true;
3660
  forBreak++;
3958
  cellStyle = cell.getAttribute('style'),
3959
  row = getCoords(cell)[0],
3960
  cellNew = void 0;
3961
+ for (var _i8 = row - 1; _i8 >= 0; _i8--) {
3962
+ var rowChildren = table.rows[_i8].children;
3963
  var rowChildrenLength = rowChildren.length;
3964
  if (rowChildrenLength > 0) {
3965
  for (var _j4 = 0; _j4 < rowChildrenLength; _j4++) {
3966
  if (rowChildren[_j4].rowSpan == 1) {
3967
+ row = _i8;
3968
  cellNew = true;
3969
  break;
3970
  }
4006
 
4007
  var cellsColSpan = 0;
4008
  if (rowAfter < table.rows.length - 1) {
4009
+ for (var _i9 = 0; _i9 <= rowAfter; _i9++) {
4010
+ var tableRowsIChildren = table.rows[_i9].children,
4011
  tableRIChildrenLength = tableRowsIChildren.length;
4012
  if (tableRIChildrenLength > 0) {
4013
  for (var _j5 = 0; _j5 < tableRIChildrenLength; _j5++) {
4014
  var rowIRowSpan = tableRowsIChildren[_j5].rowSpan;
4015
 
4016
+ if (rowIRowSpan - 1 + _i9 > rowAfter) {
4017
  tableRowsIChildren[_j5].rowSpan++;
4018
  }
4019
  }
4025
  rNextChildrenLength = rNextChildren.length;
4026
 
4027
  if (rNextChildrenLength > 0) {
4028
+ for (var _i10 = 0; _i10 < rNextChildrenLength; _i10++) {
4029
+ cellsColSpan += rNextChildren[_i10].colSpan;
4030
  }
4031
  }
4032
  } else {
4139
  tds = [].slice.call(document.getElementsByClassName('wptb-highlighted'), 1),
4140
  tdsChildrenNew = [];
4141
 
4142
+ for (var _i11 = 0; _i11 < tds.length; _i11++) {
4143
+ var tdsInternalElements = tds[_i11].getElementsByClassName('wptb-ph-element');
4144
  if (tdsInternalElements.length > 0) {
4145
  var tdsIntElemLength = tdsInternalElements.length;
4146
  for (var _j6 = 0; _j6 < tdsIntElemLength; _j6++) {
4147
  tdsChildrenNew.push(tdsInternalElements[_j6]);
4148
  }
4149
  }
4150
+ var p = tds[_i11].parentNode;
4151
+ p.removeChild(tds[_i11]);
4152
  }
4153
  if (tdsChildrenNew.length > 0) {
4154
+ for (var _i12 = 0; _i12 < tdsChildrenNew.length; _i12++) {
4155
+ first.appendChild(tdsChildrenNew[_i12]);
4156
  }
4157
  }
4158
 
4204
  cell.rowSpan = 1;
4205
  cell.colSpan = 1;
4206
 
4207
+ for (var _i13 = 1; _i13 < colspan; _i13++) {
4208
  var td = new WPTB_Cell(mark);
4209
  td.getDOMElement().setAttribute('style', cellStyles);
4210
  td.getDOMElement().classList.add('wptb-highlighted');
4216
  }
4217
 
4218
  if (rowspan > 1) {
4219
+ for (var _i14 = 1; _i14 < rowspan; _i14++) {
4220
  var rowChildInsertBefore = undefined,
4221
+ rowNext = table.rows[row + _i14],
4222
  rowChildren = rowNext.children,
4223
  rowChildrenLength = rowChildren.length;
4224
 
4333
 
4334
  if (rowspan == undefined) rowspan = 1;
4335
 
4336
+ for (var _i15 = 0; _i15 < rowspan; _i15++) {
4337
  thisRow = table.rows[row];
4338
  var thisRowChildren = thisRow.children,
4339
  nextRow = table.rows[row + 1],
4397
  table.getElementsByTagName('tbody')[0].removeChild(table.rows[row]);
4398
 
4399
  if (table.rows.length == 0) {
4400
+ WPTB_Helper.toggleTableEditMode();
4401
  wptbTableSetup.innerHTML = '';
4402
  document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';
4403
  var wptbSaveBtn = document.getElementsByClassName('wptb-save-btn');
4428
  cellXIndex = cell.dataset.xIndex,
4429
  colspan = cell.colSpan;
4430
 
4431
+ for (var _i16 = 0; _i16 < colspan; _i16++) {
4432
  for (var _j10 = 0; _j10 < table.rows.length; _j10++) {
4433
  var rowChildren = table.rows[_j10].children;
4434
  var rowChildrenLength = rowChildren.length;
4458
  maxAmountOfCells--;
4459
 
4460
  if (table.querySelectorAll('td').length == 0) {
4461
+ WPTB_Helper.toggleTableEditMode();
4462
  wptbTableSetup.innerHTML = '';
4463
  document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';
4464
  var wptbSaveBtn = document.getElementsByClassName('wptb-save-btn');
4603
  }
4604
  }
4605
 
4606
+ window.wptbTableStateSaving.push([wptbNewPreviewTable, cssForTdsWidthAutoValue]);
 
 
 
 
 
 
 
 
 
 
4607
 
4608
  // set new number of state which is showed now
4609
  window.wptbTableStateNumberShow = window.wptbTableStateSaving.length - 1;
4741
  body = body[0];
4742
  }
4743
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4744
  WPTB_Helper.elementOptionsPanelClear();
4745
  WPTB_LeftPanel();
4746
 
4908
  var wptbNodeattributes = [].concat(_toConsumableArray(node.attributes));
4909
  for (var _i = 0; _i < wptbNodeattributes.length; _i++) {
4910
  if (wptbNodeattributes[_i] && _typeof(wptbNodeattributes[_i]) === 'object' && wptbNodeattributes[_i].nodeName) {
4911
+ var regularText = new RegExp('data-wptb-el-' + element.kind + '-(\\d+)-([a-zA-Z0-9_-]+)', "i");
4912
  var attr = wptbNodeattributes[_i].nodeName.match(regularText);
4913
  if (attr && Array.isArray(attr)) {
4914
  var newDataAttributeName = wptbNodeattributes[_i].nodeName.replace(element.kind + '-' + attr[1], element.kind + '-' + index);
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","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","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","dataset","wptbTableContainerMaxWidth","maxWidth","tdDefaultWidth","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","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","alignmentValue","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","builderPageUrl","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","wptbTableSetup","applyTableContainerMaxWidth","tableContainerMaxWidthInput","tableContainerMaxWidthInputValue","tableContainerMaxWidth","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","innerElements","wptbActionsLength","dataMceBogus","columnNameDivContainer","columnNameDiv","array","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","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","wptbTableAlignment","float","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","wptbTableStateSaving","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,U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AAKxF,SAAL,CAAeO,GAAf,CAAoB,kBAAkB4G,QAAQ3F,IAA1B,GAAiC,GAAjC,GAAuCyH,KAA3D;AACH;AACJ,SALD,MAKO;AACH,gBAAI,CAAEzD,KAAKxF,SAAL,CAAe6B,QAAf,CAAyB,kBAAkBsF,QAAQ3F,IAA1B,GAAiC,GAAjC,GAAuCyH,KAAhE,CAAN,EAAgF;AAC5EzD,qBAAKxF,SAAL,CAAeO,GAAf,CAAoB,kBAAkB4G,QAAQ3F,IAA1B,GAAiC,GAAjC,GAAuCyH,KAA3D;AACH;AACJ;AACD,YAAImG,mBAAJ,CAAyBjI,OAAzB,EAAkC8B,KAAlC,EAAyCyF,aAAzC;AACAtN,oBAAY0U,kBAAZ,CAAgC3O,QAAQvE,aAAR,EAAhC;AACAvD,iBAASwI,OAAT,CAAiB0G,SAAjB,CAA2BpH,QAAQ3F,IAAnC;AACH;;AAEDgE,SAAKqtB,YAAL,GAAoB,UAAWlyB,KAAX,EAAmB;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,EAAoCgG,IAApC;;AAEAzD,yBAAiBsB,aAAjB,CAAgCmC,IAAhC;;AAEAA,aAAKxF,SAAL,CAAeC,MAAf,CAAuB,kBAAvB;AACH,KAZD;;AAcAuF,SAAKE,YAAL,GAAoB,UAAW/E,KAAX,EAAmB;AACnC,YAAIoB,mBAAmB,IAAI5C,iBAAJ,EAAvB;;AAEA4C,yBAAiBwD,cAAjB,CAAiC5E,KAAjC,EAAwC6E,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 }\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 if( element.dataset.wptbTableContainerMaxWidth ) {\n wptbTableSetupEl.style.maxWidth = element.dataset.wptbTableContainerMaxWidth + 'px';\n \n element.tdDefaultWidth();\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 }\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 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 = elementsSettings.trim();\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 = elementsSettings.trim();\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 = elementsSettings.trim();\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 if( targetControls[i].type ) {\n targetControlValue = targetControls[i].value;\n } else if( targetControls[i].dataset.alignmentValue && targetControls[i].classList.contains( 'selected' ) ){\n targetControlValue = targetControls[i].dataset.alignmentValue;\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 = elementsSettings.trim();\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 = elementsSettings.trim();\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 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 let builderPageUrl = document.location.href.replace( '#', '' );\n let regex = new RegExp( '&table=(.+)', \"i\" );\n builderPageUrl = builderPageUrl.replace( regex, '' );\n window.history.pushState( null, null, builderPageUrl + '&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( 'applyTableContainerMaxWidth' ) ) {\n let wptbTableSetup = document.querySelector( '.wptb-table-setup' );\n if( inputs.applyTableContainerMaxWidth == 'checked' ) {\n let table_id = WPTB_Helper.detectMode();\n\n if( ! table_id ) {\n table_id = 'startedid-0';\n }\n\n let tableContainerMaxWidthInput = document.getElementsByClassName( 'wptb-el-main-table_setting-' + table_id + '-tableContainerMaxWidth' );\n let tableContainerMaxWidthInputValue = 850;\n if( tableContainerMaxWidthInput.length > 0 ) {\n tableContainerMaxWidthInput = tableContainerMaxWidthInput[0];\n if( tableContainerMaxWidthInput.value ) tableContainerMaxWidthInputValue = tableContainerMaxWidthInput.value;\n }\n\n table.dataset.wptbTableContainerMaxWidth = tableContainerMaxWidthInputValue;\n if( wptbTableSetup ) wptbTableSetup.style.maxWidth = tableContainerMaxWidthInputValue + 'px';\n } else if( inputs.applyTableContainerMaxWidth == 'unchecked' ) {\n table.removeAttribute( 'data-wptb-table-container-max-width' );\n if( wptbTableSetup ) wptbTableSetup.style.maxWidth = null;\n }\n \n table.tdDefaultWidth();\n } else if( inputs.hasOwnProperty( 'tableContainerMaxWidth' ) ) {\n if( inputs.tableContainerMaxWidth ) {\n table.dataset.wptbTableContainerMaxWidth = inputs.tableContainerMaxWidth;\n \n let wptbTableSetup = document.querySelector( '.wptb-table-setup' );\n if( wptbTableSetup ) wptbTableSetup.style.maxWidth = inputs.tableContainerMaxWidth + 'px';\n \n table.tdDefaultWidth();\n }\n } else if( inputs.hasOwnProperty( 'tableManageCells' ) ) {\n table.toggleTableEditMode();\n } else if( inputs.hasOwnProperty( 'tableAlignmentCheckbox' ) ) {\n table.tdDefaultWidth();\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 if( table.dataset.wptbTableAlignment ) {\n let wptbTableAlignment = table.dataset.wptbTableAlignment;\n\n let wptbTableSetupWidth = wptbTableSetup.offsetWidth;\n if( wptbTableSetupWidth < table.offsetWidth ) {\n table.style.float = null;\n } else {\n if( wptbTableAlignment == 'center' ) {\n table.style.float = null;\n } else {\n table.style.float = wptbTableAlignment;\n }\n }\n\n if( wptbTableAlignment == 'center' ) {\n wptbTableSetup.style.float = null;\n } else {\n wptbTableSetup.style.float = wptbTableAlignment;\n }\n } else {\n table.style.float = null;\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};"]}
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","hasOwnProperty","kind","thisRow","WPTB_Helper","rowIsTop","table","findAncestor","contains","dataTitleColumnSet","wptbActionsField","actionsRemove","wptbTableStateSaveManager","WPTB_TableStateSaveManager","tableStateSet","copy","activeElement","activeElemParent","Array","isArray","data","elemProt","tinyMceClear","WPTB_ElementObject","insertBefore","getDOMElement","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","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","WPTB_Table","element","querySelector","dataset","wptbTableContainerMaxWidth","maxWidth","tdDefaultWidth","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","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","innerHTML","wptbElementMutch","elementClearFromTinyMce","inElems","querySelectorAll","inElemObj","WPTB_ElementOptions","capture","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","setAttribute","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","сontrolsConnectIndic","elementKind","elementOptionsContainer","elementOptions","controlActiveElement","regularText","controlInfArr","controlUnicClassName","controls","controlName","control","targetControlValue","targetControlValueGet","oneControlInclude","wptbContrlStacksConfigId","tmplControlsConfig","container","jsonControlsConfigJson","jsonControlsConfig","controlClassName","innerElementCopyIncludeHandler","appearDependOnControl","dependOn","targetControlElementClass","dependOnControlName","dependOnControlElementClass","dependOnControlElement","targetControlElement","controlContainerElem","showHideDependOnControlElement","dependOnControlElements","controlsStateManager","targetControlClass","controlChangeIndic","targetControls","selectorElement","elementsSettingsTemplatesJs","elementSettings","elementsSettings","stringify","name","checked","alignmentValue","elementControlsStateCopy","elementProt","copyElem","infArrProt","infArrCopy","elemProtKind","elemCopyKind","elementsSettingsTemplateJs","elementSettingsProt","elementSettingsCopy","Object","keys","forEach","elementSettingValue","elementSettingKeyCopy","elementControlsStateDelete","nameControl","wptbElementDatas","elementContainerClass","elementOptionClassIndic","elementOptionsGroupId","wptbelementOptionClass","wptbelementOptionsContainer","wptbelementOptionsScriptsContainer","childNodes","elementOptionsGroupChildren","controlScriptsArr","controlappearDependOnControl","controlKey","tmplControlTemplate","elemContainer","elementControlTargetUnicClass","controlTemplate","push","wptbElementOptionContainer","helperJavascriptElem","helperJavascriptCode","innerText","script","managerExternalCssStyles","elementContainer","selector","cssName","cssValue","head","cssForThisElement","cssText","cssTextArrFirst","pop","selectorExists","cssTextArrSecond","cssTextArrThird","cssNameExists","cssTextArrFourth","splice","externalCssStylesDelete","externalCssStylesCopy","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","builderPageUrl","history","pushState","wptbPreviewTable","wptbPreviewBtn","wptbPreviewBtnHref","previewHref","wptbSaveBtn","clickOnFreeSpace","wpcdFixedToolbar","hasAttribute","elementAjax","dataAjaxData","element_name","element_ajax_data","close","cellModeBackground","leftScrollPanelCurtain","leftScrollPanelCellSettings","deactivateMultipleSelectMode","wptbPreviewTableTds","activateMultipleSelectMode","MIN_COLUMNS","MIN_ROWS","MAX_COLUMNS","MAX_ROWS","tableGenerator","columnsDecrementButton","columnsIncrementButton","rowsDecrementButton","rowsIncrementButton","columnsInput","rowsInput","WPTB_LeftPanel","wptbElementButtons","wptbTableColumnWidthNumber","wptbTableRowHeightNumber","oninput","addColumnWidth","onchange","highlighted","addRowHeight","controlsChange","inputs","wptbTableSetup","applyTableContainerMaxWidth","tableContainerMaxWidthInput","tableContainerMaxWidthInputValue","tableContainerMaxWidth","wptbElement","addRowToTheEnd","addRowToTheStart","addRowBefore","addRowAfter","addColumnEnd","addColumnStart","addColumnBefore","addColumnAfter","deleteColumn","deleteRow","mergeCells","splitCell","wptbBuilderPanel","wptbHeader","selectedCells","multipleCellMode","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","innerElements","wptbActionsLength","dataMceBogus","columnNameDivContainer","columnNameDiv","array","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","wptbAdaptiveTable","insertRow","borderWidth","wptb_preview_table","recalculateIndexes","start","trs","maxCols","maxColsFull","tdsArr","jMainIter","z","cleaner","dataXIndex","tableTdsFor","colspan","tableRows","widthIsSet","arrayTdsFromPreviousRow","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","wptbTableAlignment","float","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","wptbTableStateSaving","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,OAAON,SAASO,oBAAT,CAA+B,MAA/B,EAAwC,CAAxC,CAAX;;AAEA,YAAIC,UAAUR,SAASC,sBAAT,CAAiC,cAAjC,CAAd;AACA,YAAIO,QAAQN,MAAR,IAAkB,CAAtB,EAA0B;AACtB,gBAAIO,eAAeD,QAAQ,CAAR,EAAWE,UAA9B;AACA,gBAAID,YAAJ,EAAmB;AACfA,6BAAaE,SAAb,CAAuBC,MAAvB,CAA+B,sBAA/B;AACH;;AAED,mBAAOJ,QAAQN,MAAR,IAAkB,CAAzB,EAA6B;AACzBM,wBAAQ,CAAR,EAAWK,UAAX,CAAsBC,WAAtB,CAAmCN,QAAQ,CAAR,CAAnC;AACH;AACJ;;AAED,YAAIJ,cAAc,CAAlB,EAAsB;;AAElB,gBAAIW,kBAAJ;AAAA,gBAAeC,gBAAf;;AAEAD,wBAAYf,SAASiB,aAAT,CAAwB,MAAxB,CAAZ,EACAD,UAAUhB,SAASiB,aAAT,CAAwB,MAAxB,CADV,EAEAT,UAAUR,SAASiB,aA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AnC;AACH;;AAEDiE,SAAK2tB,YAAL,GAAoB,UAAWpyB,KAAX,EAAmB;AACnC,YAAIA,MAAME,MAAN,CAAab,SAAb,CAAuByB,QAAvB,CAAiC,kBAAjC,CAAJ,EAA4D;AACxD;AACH;;AAED,YAAIE,mBAAmB,IAAIxC,iBAAJ,EAAvB;;AAEAwC,yBAAiBnC,cAAjB,CAAiC,CAAjC,EAAoC4F,IAApC;;AAEAzD,yBAAiBsB,aAAjB,CAAgCmC,IAAhC;;AAEAA,aAAKpF,SAAL,CAAeC,MAAf,CAAuB,kBAAvB;AACH,KAZD;;AAcAmF,SAAKE,YAAL,GAAoB,UAAW3E,KAAX,EAAmB;AACnC,YAAIgB,mBAAmB,IAAIxC,iBAAJ,EAAvB;;AAEAwC,yBAAiBwD,cAAjB,CAAiCxE,KAAjC,EAAwCyE,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 }\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 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 if( element.dataset.wptbTableContainerMaxWidth ) {\n wptbTableSetupEl.style.maxWidth = element.dataset.wptbTableContainerMaxWidth + 'px';\n \n element.tdDefaultWidth();\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 }\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 node.addEventListener( 'click', function() {\n WPTB_Helper.elementOptionsSet( element.kind, this );\n }, {capture: true} );\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 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:controls:active', function() {\n if( ! element.hasOwnProperty( 'сontrolsConnectIndic' ) || element.сontrolsConnectIndic !== true ) {\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 = elementsSettings.trim();\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+)-([a-zA-Z0-9_-]+)', \"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// }\n if( elementKind ){\n let elementOptionsContainer = document.querySelector( '.wptb-element-options.wptb-options-' + infArr[1] + '-' + infArr[2] );\n\n let elementOptions = elementOptionsContainer.querySelectorAll( '.wptb-element-option' );\n\n for( let i = 0; i < elementOptions.length; i++ ) {\n let controlActiveElement = elementOptions[i].querySelector( '.wptb-element-property' );\n if( controlActiveElement ) {\n let regularText = new RegExp( 'wptb-el-' + elementKind + '-(\\\\d+)-([a-zA-Z0-9_-]+)', \"i\" );\n let controlInfArr = controlActiveElement.className.match( regularText );\n if( controlInfArr && Array.isArray( controlInfArr ) ) {\n let controlUnicClassName = controlInfArr[0];\n\n element.addEventListener( 'wptb-control:' + controlUnicClassName, function() {\n let controls = {};\n let controlName = controlInfArr[2];\n let control = document.getElementsByClassName( controlUnicClassName );\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\n element.сontrolsConnectIndic = true;\n }\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( dependOnControlElementClass, dependOn ) {\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 = elementsSettings.trim();\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 if( dependOnControlElementClass ) {\n let dependOnControlElements = document.getElementsByClassName( dependOnControlElementClass );\n if( dependOnControlElements.length > 0 ) {\n let targetControlValue = WPTB_Helper.targetControlValueGet( dependOnControlElements );\n \n if( dependOn[1] && Array.isArray( dependOn[1] ) && \n ( dependOn[1].indexOf( targetControlValue ) !== -1 ) ) {\n controlContainerElem.style.display = 'block';\n } else if( dependOn[2] && Array.isArray( dependOn[2] ) && \n ( dependOn[2].indexOf( targetControlValue ) !== -1 ) ) {\n controlContainerElem.style.display = 'none';\n }\n }\n }\n }\n\n showHideDependOnControlElement( dependOnControlElementClass, dependOn );\n\n dependOnControlElement.addEventListener( 'change', function( event ) {\n showHideDependOnControlElement( dependOnControlElementClass, dependOn );\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 = elementsSettings.trim();\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 if( targetControls[i].type ) {\n targetControlValue = targetControls[i].value;\n } else if( targetControls[i].dataset.alignmentValue && targetControls[i].classList.contains( 'selected' ) ){\n targetControlValue = targetControls[i].dataset.alignmentValue;\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 = elementsSettings.trim();\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 = elementsSettings.trim();\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 containers for inserting controls of this item and their scripts\n let wptbelementOptionsContainer = document.createElement( 'div' );\n let wptbelementOptionsScriptsContainer = 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 // 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 wptbelementOptionsContainer.classList.add( 'wptb-element-options', 'wptb-options-' + infArr[1] );\n wptbelementOptionsScriptsContainer.classList.add( 'wptb-element-options-scripts', 'wptb-options-' + infArr[1] );\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 document.getElementById( elementOptionsGroupId ).appendChild( wptbelementOptionsScriptsContainer );\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 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 wptbelementOptionsScriptsContainer.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:controls: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 WPTB_Helper.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 let builderPageUrl = document.location.href.replace( '#', '' );\n let regex = new RegExp( '&table=(.+)', \"i\" );\n builderPageUrl = builderPageUrl.replace( regex, '' );\n window.history.pushState( null, null, builderPageUrl + '&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\n /*\n * This just toggles visibility of cell edit bar, and toggles\n * cell selecting mode.\n */\n\n toggleTableEditMode: function ( close = false ) {\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 if( ! close ) {\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","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 let 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( 'applyTableContainerMaxWidth' ) ) {\n let wptbTableSetup = document.querySelector( '.wptb-table-setup' );\n if( inputs.applyTableContainerMaxWidth == 'checked' ) {\n let table_id = WPTB_Helper.detectMode();\n\n if( ! table_id ) {\n table_id = 'startedid-0';\n }\n\n let tableContainerMaxWidthInput = document.getElementsByClassName( 'wptb-el-main-table_setting-' + table_id + '-tableContainerMaxWidth' );\n let tableContainerMaxWidthInputValue = 850;\n if( tableContainerMaxWidthInput.length > 0 ) {\n tableContainerMaxWidthInput = tableContainerMaxWidthInput[0];\n if( tableContainerMaxWidthInput.value ) tableContainerMaxWidthInputValue = tableContainerMaxWidthInput.value;\n }\n\n table.dataset.wptbTableContainerMaxWidth = tableContainerMaxWidthInputValue;\n if( wptbTableSetup ) wptbTableSetup.style.maxWidth = tableContainerMaxWidthInputValue + 'px';\n } else if( inputs.applyTableContainerMaxWidth == 'unchecked' ) {\n table.removeAttribute( 'data-wptb-table-container-max-width' );\n if( wptbTableSetup ) wptbTableSetup.style.maxWidth = null;\n }\n \n table.tdDefaultWidth();\n } else if( inputs.hasOwnProperty( 'tableContainerMaxWidth' ) ) {\n if( inputs.tableContainerMaxWidth ) {\n table.dataset.wptbTableContainerMaxWidth = inputs.tableContainerMaxWidth;\n \n let wptbTableSetup = document.querySelector( '.wptb-table-setup' );\n if( wptbTableSetup ) wptbTableSetup.style.maxWidth = inputs.tableContainerMaxWidth + 'px';\n \n table.tdDefaultWidth();\n }\n } else if( inputs.hasOwnProperty( 'tableManageCells' ) ) {\n WPTB_Helper.toggleTableEditMode();\n } else if( inputs.hasOwnProperty( 'tableAlignmentCheckbox' ) ) {\n table.tdDefaultWidth();\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 = WPTB_Helper.toggleTableEditMode;\n document.getElementById( 'wptb-left-scroll-panel-curtain-close' ).onclick = WPTB_Helper.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 * 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 = 'auto';\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 = 'auto';\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 = 'auto';\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 if( table.dataset.wptbTableAlignment ) {\n let wptbTableAlignment = table.dataset.wptbTableAlignment;\n\n let wptbTableSetupWidth = wptbTableSetup.offsetWidth;\n if( wptbTableSetupWidth < table.offsetWidth ) {\n table.style.float = null;\n } else {\n if( wptbTableAlignment == 'center' ) {\n table.style.float = null;\n } else {\n table.style.float = wptbTableAlignment;\n }\n }\n\n if( wptbTableAlignment == 'center' ) {\n wptbTableSetup.style.float = null;\n } else {\n wptbTableSetup.style.float = wptbTableAlignment;\n }\n \n if( tableTdWidthAuto && table.dataset.wptbTableContainerMaxWidth && table.offsetWidth < table.dataset.wptbTableContainerMaxWidth ) {\n table.style.width = '100%';\n }\n } else {\n table.style.float = null;\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 WPTB_Helper.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 WPTB_Helper.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 window.wptbTableStateSaving.push( [wptbNewPreviewTable, cssForTdsWidthAutoValue] );\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 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+)-([a-zA-Z0-9_-]+)', \"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 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 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()),WPTB_Helper.externalCssStylesCopy(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(WPTB_Helper.rowIsTop(s)){var d=WPTB_Helper.findAncestor(s,"wptb-preview-table");d.classList.contains("wptb-table-preview-head")&&WPTB_Helper.dataTitleColumnSet(d)}}}else p.style.display="none";p.actionsHide()},i.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 s).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 o=WPTB_Helper.detectMode();if(o){var i=new XMLHttpRequest,e=ajaxurl+"?action=get_table&id="+o;i.open("GET",e,!0),i.setRequestHeader("Content-type","application/x-www-form-urlencoded"),i.onreadystatechange=function(e){if(4!=this.readyState||200!=this.status);else{var t=JSON.parse(i.responseText);if(document.getElementById("wptb-setup-name").value=t[0],t[1]){document.getElementsByClassName("wptb-table-generator")[0].style.display="none";var a=document.getElementsByClassName("wptb-table-setup")[0];a.appendChild(WPTB_Parser(t[1]));var n=document.getElementsByTagName("body")[0];if(t[2]){var l=document.createElement("script");l.setAttribute("type","text/html"),l.setAttribute("class","wptb-element-datas"),l.innerHTML=t[2],n.appendChild(l)}WPTB_Table();var r=document.querySelector(".wptb-preview-table");r&&(r.className.match(/wptb-element-((.+-)\d+)/i)||r.classList.add("wptb-element-main-table_setting-"+o),r.dataset.wptbTableContainerMaxWidth&&(a.style.maxWidth=r.dataset.wptbTableContainerMaxWidth+"px",r.tdDefaultWidth())),WPTB_LeftPanel(),WPTB_Settings(),(new WPTB_TableStateSaveManager).tableStateSet(),WPTB_Helper.elementOptionsSet("table_setting",r)}else document.getElementsByClassName("wptb-table-generator")[0].style.display="table"}},i.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")}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"),i=e.getPropertyValue("border-top-width"),s=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(i,10)/2-parseInt(s,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"),h=this.parentNode;if(h&&"tr"===h.nodeName.toLowerCase()){h.firstChild&&h.firstChild.dataset.xIndex===this.dataset.xIndex&&parseInt(b,10)>parseInt(n,10)&&(d+=-(parseInt(b,10)-parseInt(n,10))/2),h.lastChild&&h.lastChild.dataset.xIndex===this.dataset.xIndex&&parseInt(u,10)>parseInt(l,10)&&(d+=-(parseInt(u,10)-parseInt(l,10))/2);var v=h.parentNode;v&&"body"===v.nodeName.toLowerCase()&&(v.firstChild&&v.firstChild.firstChild.dataset.yIndex===this.dataset.yIndex&&parseInt(w,10)>parseInt(i,10)&&(p+=(parseInt(w,10)-parseInt(i,10))/2),v.lastChild&&v.lastChild.firstChild.dataset.yIndex===this.dataset.yIndex&&parseInt(g,10)>parseInt(s,10)&&(p+=(parseInt(g,10)-parseInt(s,10))/2))}}return{width:parseInt(d),height:parseInt(p)}},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(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"),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),WPTB_Helper.rowIsTop(o))if(WPTB_Helper.findAncestor(o,"wptb-preview-table").classList.contains("wptb-table-preview-head")){for(var p=e.dataTransfer.types,c=!1,m=0;m<p.length;m++){var b=p[m].match(/wptbelindic-([a-z]+)/i);if(b&&"text"!=b[1]){c=!0;break}}if(c)return}s.style.width=i.offsetWidth+"px";var u=i.offsetHeight,w=i.getBoundingClientRect(),g=parseFloat(w.left),h=void 0;if(s.style.left=g+"px",-1!=e.dataTransfer.types.indexOf("wptb-moving-mode")){var v=document.getElementsByClassName("wptb-moving-mode")[0];i==v?(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;h=parseFloat(w.top)-parseFloat(11),s.dataset.text="Above Element",u/2<f&&(h=parseFloat(w.top)+u-1,s.dataset.text="Below Element")}else s.dataset.text="Drop Here",h=parseFloat(w.top)+u/2-5;s.style.top=h+"px",d.style.top=w.top+"px",d.style.left=w.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(w.bottom)-parseFloat(w.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)},p=0;p<s.length;p++)d(p);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(e,t,a){e.getDOMElement().onclick=function(){WPTB_Helper.elementOptionsSet(e.kind,this)}};_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 WPTB_Helper={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):""},isHex:function(e){return new RegExp("^#(?:[A-Fa-f0-9]{3}){1,2}$").test(e)},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 p=d.querySelector("p"),c=p.textContent,m=p.style.textAlign;r[l[o].dataset.xIndex]=[c,d.style.fontSize,d.style.color,n.backgroundColor,m];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,w=0;w<u.length;w++)r[u[w].dataset.xIndex]?(u[w].dataset.wptbTitleColumn=r[u[w].dataset.xIndex][0],u[w].dataset.wptbTitleColumnFontSize=r[u[w].dataset.xIndex][1],u[w].dataset.wptbTitleColumnColor=r[u[w].dataset.xIndex][2],u[w].dataset.wptbTitleBackgroundColor=r[u[w].dataset.xIndex][3],u[w].dataset.wptbTitleAlign=r[u[w].dataset.xIndex][4]):(u[w].dataset.wptbTitleColumn="",u[w].dataset.wptbTitleColumnFontSize="",u[w].dataset.wptbTitleColumnColor="",u[w].dataset.wptbTitleBackgroundColor="",u[w].dataset.wptbTitleAlign="")},findAncestor:function(e,t){for(;(e=e.parentElement)&&!e.classList.contains(t););return e},rowIsTop:function(e){return e.parentNode.children[0]==e},getSelectionText:function(){return window.getSelection?window.getSelection().toString():document.selection.createRange().text},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 p=i.querySelectorAll("li"),c=0;c<p.length;c++)for(var m=p[c].getElementsByTagName("span"),b=0;b<m.length;b++)m[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 p=0;p<d.length;p++)d[p].removeAttribute("spellcheck");var c=e.querySelectorAll("[id^=mce_]");if(0<c.length)for(var m=0;m<c.length;m++)c[m].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++)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("element:control:active",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=e.trim(),(e=JSON.parse(e))&&"object"===(void 0===e?"undefined":_typeof(e))&&"tmpl-wptb-el-datas-"+l[1]+"-"+l[2]in e)){var t=e["tmpl-wptb-el-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)},appearDependOnControl: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=a.trim(),(a=JSON.parse(a))&&"object"===(void 0===a?"undefined":_typeof(a))&&"tmpl-wptb-el-datas-"+e in a)){var n=a["tmpl-wptb-el-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-el-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=o.trim(),(o=JSON.parse(o))&&"object"===(void 0===o?"undefined":_typeof(o))))if(t){var s=WPTB_Helper.targetControlValueGet(a);"tmpl-wptb-el-datas-"+n[1]in o&&"object"===_typeof(o["tmpl-wptb-el-datas-"+n[1]])||(o["tmpl-wptb-el-datas-"+n[1]]={}),o["tmpl-wptb-el-datas-"+n[1]]["data-"+e]=s,l.innerHTML=JSON.stringify(o)}else if("tmpl-wptb-el-datas-"+n[1]in o&&"object"===_typeof(o["tmpl-wptb-el-datas-"+n[1]])&&"data-"+e in o["tmpl-wptb-el-datas-"+n[1]]){if("tmpl-wptb-el-datas-"+n[1]in o&&"object"===_typeof(o["tmpl-wptb-el-datas-"+n[1]])&&"data-"+e in o["tmpl-wptb-el-datas-"+n[1]])for(var d=0;d<a.length;d++)if("checkbox"==a[d].type){var p=void 0;"checked"==(p=a[d].name?o["tmpl-wptb-el-datas-"+n[1]]["data-"+e][a[d].name]:o["tmpl-wptb-el-datas-"+n[1]]["data-"+e])?a[d].checked=!0:"unchecked"==p&&(a[d].checked=!1)}else a[d].value=o["tmpl-wptb-el-datas-"+n[1]]["data-"+e]}else{var c=WPTB_Helper.targetControlValueGet(a);"tmpl-wptb-el-datas-"+n[1]in o&&"object"===_typeof(o["tmpl-wptb-el-datas-"+n[1]])||(o["tmpl-wptb-el-datas-"+n[1]]={}),o["tmpl-wptb-el-datas-"+n[1]]["data-"+e]=c,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"):"checkbox"==e[a].type?t=1==e[a].checked?"checked":"unchecked":e[a].type?t=e[a].value:e[a].dataset.alignmentValue&&e[a].classList.contains("selected")&&(t=e[a].dataset.alignmentValue);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=i.trim(),(i=JSON.parse(i))&&"object"===(void 0===i?"undefined":_typeof(i)))){var s=i["tmpl-wptb-el-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-el-datas-"+r]=d,i=JSON.stringify(i),o.innerHTML=i)}}}}}},elementControlsStateDelete:function(e,t){var a=e.className.match(/wptb-element-(.+)-(\d+)/i),n=document.getElementsByTagName("body")[0],l=n.getElementsByClassName("wptb-element-datas");if(a&&Array.isArray(a)&&0<l.length){var r=(l=l[0]).innerHTML;r&&(r=r.trim(),(r=JSON.parse(r))&&"object"===(void 0===r?"undefined":_typeof(r))&&"tmpl-wptb-el-datas-"+a[1]+"-"+a[2]in r&&(t?r["tmpl-wptb-el-datas-"+a[1]+"-"+a[2]]&&"object"===_typeof(r["tmpl-wptb-el-datas-"+a[1]+"-"+a[2]])&&"data-wptb-el-"+a[1]+"-"+a[2]+"-"+t in r["tmpl-wptb-el-datas-"+a[1]+"-"+a[2]]&&delete r["tmpl-wptb-el-datas-"+a[1]+"-"+a[2]]["data-wptb-el-"+a[1]+"-"+a[2]+"-"+t]:delete r["tmpl-wptb-el-datas-"+a[1]+"-"+a[2]],0==Object.keys(r).length?n.removeChild(l):(r=JSON.stringify(r),l.innerHTML=r)))}},elementOptionsSet:function(e,t){var a,s,d,n="wptb-"+e+"-control-stack",l=wp.template(n),r=void 0,o=void 0,p=void 0,c=document.createElement("div"),i=t.className.match(/wptb-element-((.+-)\d+)/i);if(!i&&t.classList.contains("wptb-preview-table")){var m=WPTB_Helper.detectMode();t.classList.add("wptb-element-main-table_setting-"+m),i=t.className.match(/wptb-element-((.+-)\d+)/i)}if(a={container:"."+i[0]},s=i[0],d=i[1],t.classList.contains("wptb-preview-table"))o="table-settings-group",p="wptb-element-option";else{for(var b=document.getElementById("element-options-group").childNodes,u=0;u<b.length;u++)b[u].style&&(b[u].style.display="none");c.classList.add("wptb-element-options","wptb-options-"+i[1]),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",o="element-options-group",p="wptb-element-option"}for(var w=l(a),g=JSON.parse(w),h=(r=document.getElementById(o)).children,v=0;v<h.length;v++)r.removeChild(h[v]);document.getElementById(o).appendChild(c),c.style.display="block";var f=[],y=[];if(Object.keys(g).forEach(function(e){var t=g[e];t.controlKey=e;var a=wp.template("wptb-"+t.type+"-control");t.elemContainer=s,t.elementControlTargetUnicClass="wptb-el-"+d+"-"+t.controlKey;var n=a(t);"appearDependOnControl"in t&&Array.isArray(t.appearDependOnControl)&&y.push([t.appearDependOnControl,t.elementControlTargetUnicClass]);var l=document.createElement("div");l.classList.add(p,"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(),f.push(i)}0}),0<f.length)for(var S=0;S<f.length;S++)c.appendChild(f[S]);for(var T=0;T<y.length;T++)WPTB_Helper.appearDependOnControl(y[T][0],y[T][1]);WPTB_Helper.wptbDocumentEventGenerate("element:control:active",t)},managerExternalCssStyles:function(e,t,a,n){var l=e.match(/wptb-element-main(.+)-(\d+)/i);if(!l||!Array.isArray(l)){var r=document.getElementsByClassName("wptb-preview-table");if(0<r.length){var o=(r=r[0]).className.match(/wptb-element-main(.+)-(\d+)/i);o&&Array.isArray(o)&&(t="."+o[0]+" "+t)}}var i=document.head;if(i){var s=i.querySelector("#styles-"+e);if(s){var d=s.innerHTML;if(d){var p=d.split("}");p.pop();for(var c=!1,m=0;m<p.length;m++){var b=p[m].split("{");if(b[0]===t){var u=b[1].split(";");u.pop();for(var w=!1,g=0;g<u.length;g++){if(u[g].split(":")[0]===a){n?u[g]=a+":"+n:u.splice(g,1),b[1]=u.join(";")?u.join(";")+";":"",w=!0;break}}w||n&&(b[1]+=a+":"+n+";"),b[1]?p[m]=b[0]+"{"+b[1]:p.splice(m,1),p.join("}")?s.innerHTML=p.join("}")+"}":i.removeChild(s),c=!0;break}}c||(s.innerHTML=n?d+t+"{"+a+":"+n+";}":d)}else n?s.innerHTML=t+"{"+a+":"+n+";}":i.removeChild(s)}else if(n){var h=document.createElement("style");h.setAttribute("id","styles-"+e),h.classList.add("styles-wptb-elements"),h.innerHTML=t+"{"+a+":"+n+";}",i.appendChild(h)}}},externalCssStylesDelete:function(e){var t=document.head;if(t){var a=t.querySelector("#styles-"+e);a&&t.removeChild(a)}},externalCssStylesCopy:function(e,t){if(e){var a=e.className.match(/wptb-element-(.+)-(\d+)/i);if(a&&Array.isArray(a)){var n=a[0],l=document.head;if(l){var r=l.querySelector("#styles-"+n);if(r){var o=r.cloneNode(!0);o.removeAttribute("id","styles-"+n);var i=t.className.match(/wptb-element-(.+)-(\d+)/i);if(i&&Array.isArray(i)){o.setAttribute("id","styles-"+i[0]);var s=r.innerHTML,d=WPTB_Helper.replaceAll(s,n,i[0]);o.innerHTML=d,l.appendChild(o)}}}}}},elementsStylesConvertToObject:function(){for(var e=document.head.querySelectorAll(".styles-wptb-elements"),t={},a=0;a<e.length;a++){var n=e[a].getAttribute("id");n&&e[a].innerHTML&&(t[n]=e[a].innerHTML)}return 0!=Object.keys(t).length?JSON.stringify(t):""},elementsStylesSetFromObject:function(e){var n=document.head;if(n){var t=n.querySelectorAll(".styles-wptb-elements");if(0<t.length){t=[].concat(_toConsumableArray(t));for(var a=0;a<t.length;a++)n.removeChild(t[a])}if(e){var l=JSON.parse(e);0!=Object.keys(l).length&&Object.keys(l).forEach(function(e){var t=l[e],a=document.createElement("style");a.setAttribute("id",e),a.classList.add("styles-wptb-elements"),a.innerHTML=t,n.appendChild(a)})}}},saveTable:function(s,d,e){if(e||d||!s.target.dataset.wptbTableStateNumberSave&&0==window.wptbTableStateNumberShow||(window.wptbTableStateNumberShow,s.target.dataset.wptbTableStateNumberSave),!e){var t=document.querySelector(".wptb-edit-bar");if(t&&t.classList.contains("visible"))document.getElementsByClassName("wptb-preview-table")[0].toggleTableEditMode()}var p=new XMLHttpRequest,a=(wptb_admin_object?wptb_admin_object.ajaxurl:ajaxurl)+"?action=save_table",c=document.getElementById("wptb-setup-name").value.trim(),m=void 0,n=void 0,l=void 0;n=document.getElementsByClassName("wptb-preview-table");var r=void 0;((rs=WPTB_Helper.detectMode())||(rs=document.wptbId))&&(r=rs);var o=!1;if(0<n.length){var i=(n=n[0]).cloneNode(!0);r&&i.classList.contains("wptb-element-main-table_setting-startedid-0")&&(i.classList.remove("wptb-element-main-table_setting-startedid-0"),i.classList.add("wptb-element-main-table_setting-"+r),o=!0),i.columns=n.columns,n=(n=WPTB_Stringifier(i)).outerHTML}else n="";if(!e){l="";var b=document.getElementsByClassName("wptb-element-datas");0<b.length&&b[0].innerHTML&&(l=b[0].innerHTML,o&&(l=WPTB_Helper.replaceAll(l,"tmpl-wptb-el-datas-main-table_setting-startedid-0","tmpl-wptb-el-datas-main-table_setting-"+r),l=WPTB_Helper.replaceAll(l,"data-wptb-el-main-table_setting-startedid-0","data-wptb-el-main-table_setting-"+r)))}var u=WPTB_Helper.elementsStylesConvertToObject();if(o&&(u=WPTB_Helper.replaceAll(u,".wptb-element-main-table_setting-startedid-0",".wptb-element-main-table_setting-"+r)),""===c&&""===n){var w="";return""===c&&(w+="You must assign a name to the table before saving it.</br>"),""===n&&(w+="Table wasn't created"),(m=document.getElementById("wptb-messaging-area")).innerHTML='<div class="wptb-error wptb-message">Error: '+w+"</div>",m.classList.add("wptb-warning"),void setTimeout(function(){m.removeChild(m.firstChild)},4e3)}var g={title:c,content:n,elements_datas:l,elements_styles:u,security_code:wptb_admin_object.security_code};e&&(g.preview_saving=e),r&&(g.id=r),g=JSON.stringify(g),p.open("POST",a,!0),p.setRequestHeader("Content-type","application/json; charset=utf-8"),p.onreadystatechange=function(e){if(4==this.readyState&&200==this.status){var t=JSON.parse(p.responseText);if(m=document.getElementById("wptb-messaging-area"),"saved"==t[0]){var a=document.location.href.replace("#",""),n=new RegExp("&table=(.+)","i");return a=a.replace(n,""),window.history.pushState(null,null,a+"&table="+t[1]),void WPTB_Helper.saveTable(s,!0)}if("edited"==t[0]&&d){document.wptbId=t[1],m.innerHTML='<div class="wptb-success wptb-message">Table "'+c+'" 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]+"]";document.querySelector(".wptb-preview-table");var l=document.getElementsByClassName("wptb-preview-btn");if(0<l.length){(l=l[0]).classList.remove("wptb-button-disable");var r=l.dataset.previewHref;r=r.replace("empty",t[1]),l.setAttribute("href",r)}s.target.dataset.wptbTableStateNumberSave=window.wptbTableStateNumberShow;var o=document.getElementsByClassName("wptb-save-btn");0<o.length&&(o=o[0]).classList.add("wptb-save-disabled")}else if("edited"==t[0]){m.innerHTML='<div class="wptb-success wptb-message">Table "'+c+'" was successfully updated.</div>',s.target.dataset.wptbTableStateNumberSave=window.wptbTableStateNumberShow;var i=document.getElementsByClassName("wptb-save-btn");0<i.length&&(i=i[0]).classList.add("wptb-save-disabled")}else{if("preview_edited"==t[0])return;m.innerHTML='<div class="wptb-error wptb-message">Safety problems</div>'}m.classList.add("wptb-success"),setTimeout(function(){m.removeChild(m.firstChild)},4e3)}},p.send(g)},clickOnFreeSpace:function(){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");var t=document.querySelector(".wptb-preview-table");t&&WPTB_Helper.elementOptionsSet("table_setting",t)},elementAjax:function(e,n){var l=new XMLHttpRequest,t=(wptb_admin_object?wptb_admin_object.ajaxurl:ajaxurl)+"?action=wptb_element_ajax",a=void 0,r=n.className.match(/wptb-element-(.+)-(\d+)/i);r&&Array.isArray(r)&&(a=r[1]);var o={element_ajax_data:e,element_name:a,security_code:wptb_admin_object.security_code};o=JSON.stringify(o),l.open("POST",t,!0),l.setRequestHeader("Content-type","application/json; charset=utf-8"),l.onreadystatechange=function(e){if(4==this.readyState&&200==this.status){var t=JSON.parse(l.responseText),a=void 0;a=t&&Array.isArray(t)&&"element_ajax_responce"==t[0]?{value:t[1]}:"",WPTB_Helper.wptbDocumentEventGenerate("wptb-element:ajax-response",n,a)}},l.send(o)}},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,a=new WPTB_TableStateSaveManager;a.tableStateSet(!0),WPTB_Table(e,t),a.tableStateSet()}},WPTB_LeftPanel=(_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(){var l=document.getElementsByClassName("wptb-preview-table")[0],e=document.getElementsByClassName("wptb-element"),t=document.getElementById("wptb-table-column-width-number");WPTB_Helper.numberImputSize(t,2,500);var a=document.getElementById("wptb-table-row-height-number");WPTB_Helper.numberImputSize(a,2,200),document.getElementById("wptb-table-column-width-slider").oninput=function(){document.getElementById("wptb-table-column-width-number").value=this.value,l.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,l.addColumnWidth(this.value),(new WPTB_TableStateSaveManager).tableStateSet()},document.getElementById("wptb-table-column-width-auto-fixed").onchange=function(){if(this.checked){var e=l.querySelector(".wptb-highlighted"),t=WPTB_Helper.getColumnWidth(l,e);l.addColumnWidth(t)}else{l.addColumnWidth(!1,!0);var a=l.querySelector(".wptb-highlighted"),n=WPTB_Helper.getColumnWidth(l,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,l.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,l.addRowHeight(this.value),(new WPTB_TableStateSaveManager).tableStateSet()},document.getElementById("wptb-table-row-height-auto-fixed").onchange=function(){if(this.checked){var e=l.querySelector(".wptb-highlighted"),t=WPTB_Helper.getRowHeight(l,e);l.addRowHeight(t)}else{l.addRowHeight(!1,!0);var a=l.querySelector(".wptb-highlighted"),n=WPTB_Helper.getRowHeight(l,a);document.getElementById("wptb-table-row-height-number").value=n,document.getElementById("wptb-table-row-height-slider").value=n}(new WPTB_TableStateSaveManager).tableStateSet()},WPTB_Helper.controlsInclude(l,function(e,t){if(e&&"object"===(void 0===e?"undefined":_typeof(e)))if(e.hasOwnProperty("tableTopRowsAsHeader")){if("checked"==e.tableTopRowsAsHeader)t.rows,t.classList.add("wptb-table-preview-head");else if("unchecked"==e.tableTopRowsAsHeader){var a=t.rows;t.classList.remove("wptb-table-preview-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")}}else if(e.hasOwnProperty("makeTableResponsive"))"checked"==e.makeTableResponsive?t.dataset.wptbAdaptiveTable=1:"unchecked"==e.makeTableResponsive&&(t.dataset.wptbAdaptiveTable=0);else if(e.hasOwnProperty("applyTableContainerMaxWidth")){var o=document.querySelector(".wptb-table-setup");if("checked"==e.applyTableContainerMaxWidth){var i=WPTB_Helper.detectMode();i||(i="startedid-0");var s=document.getElementsByClassName("wptb-el-main-table_setting-"+i+"-tableContainerMaxWidth"),d=850;0<s.length&&(s=s[0]).value&&(d=s.value),t.dataset.wptbTableContainerMaxWidth=d,o&&(o.style.maxWidth=d+"px")}else"unchecked"==e.applyTableContainerMaxWidth&&(t.removeAttribute("data-wptb-table-container-max-width"),o&&(o.style.maxWidth=null));t.tdDefaultWidth()}else if(e.hasOwnProperty("tableContainerMaxWidth")){if(e.tableContainerMaxWidth){t.dataset.wptbTableContainerMaxWidth=e.tableContainerMaxWidth;var p=document.querySelector(".wptb-table-setup");p&&(p.style.maxWidth=e.tableContainerMaxWidth+"px"),t.tdDefaultWidth()}}else e.hasOwnProperty("tableManageCells")?t.toggleTableEditMode():e.hasOwnProperty("tableAlignmentCheckbox")&&t.tdDefaultWidth()});for(var n=0;n<e.length;n++)e[n].ondragstart=function(e){e.dataTransfer.setData("wptbElement",this.dataset.wptbElement),e.dataTransfer.setData("wptbElIndic-"+this.dataset.wptbElement,"wptbElIndic-"+this.dataset.wptbElement)};l&&(document.getElementById("wptb-table-edit-mode-close").onclick=l.toggleTableEditMode,document.getElementById("wptb-left-scroll-panel-curtain-close").onclick=l.toggleTableEditMode,document.getElementById("wptb-add-end-row").onclick=l.addRowToTheEnd,document.getElementById("wptb-add-start-row").onclick=l.addRowToTheStart,document.getElementById("wptb-add-row-before").onclick=l.addRowBefore,document.getElementById("wptb-add-row-after").onclick=l.addRowAfter,document.getElementById("wptb-add-end-column").onclick=l.addColumnEnd,document.getElementById("wptb-add-start-column").onclick=l.addColumnStart,document.getElementById("wptb-add-column-before").onclick=l.addColumnBefore,document.getElementById("wptb-add-column-after").onclick=l.addColumnAfter,document.getElementById("wptb-delete-column").onclick=l.deleteColumn,document.getElementById("wptb-delete-row").onclick=l.deleteRow,document.getElementById("wptb-merge-cells").onclick=l.mergeCells,document.getElementById("wptb-split-cell").onclick=l.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")||WPTB_Helper.clickOnFreeSpace()};var r=document.getElementsByClassName("wptb-header");0<r.length&&(r=r[0]),r.onclick=function(){WPTB_Helper.clickOnFreeSpace()}}),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=document.getElementsByClassName("wptb-preview-table"),n=new WPTB_TableStateSaveManager,l=document.getElementsByClassName("wptb-undo");0<l.length&&((l=l[0]).onclick=function(e){if(!this.classList.contains("wptb-undoredo-disabled")){n.tableStateGet(this.dataset.wptbUndoredo);var t=document.getElementsByClassName("wptb-undo-redo-container");0<t.length&&0<a.length&&((t=t[0]).onmouseleave=function(e){e.target.onmouseleave="",WPTB_Table()})}});var r=document.getElementsByClassName("wptb-redo");0<r.length&&((r=r[0]).onclick=function(e){if(!this.classList.contains("wptb-undoredo-disabled")){n.tableStateGet(this.dataset.wptbUndoredo);var t=document.getElementsByClassName("wptb-undo-redo-container");0<t.length&&0<a.length&&((t=t[0]).onmouseleave=function(e){e.target.onmouseleave="",WPTB_Table()})}});var o=document.getElementsByClassName("wptb-popup-window-modal")[0];document.getElementsByClassName("wptb-embed-btn")[0].onclick=function(){this.classList.contains("wptb-button-disable")||o.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(){o.classList.remove("wptb-popup-show")},document.getElementsByClassName("wptb-popup-window-close-icon")[0].onclick=function(){o.classList.remove("wptb-popup-show")},document.getElementsByClassName("wptb-preview-btn")[0].onclick=function(e){if(!this.classList.contains("wptb-button-disable")){var t=Math.floor(1e4*Math.random()),a=new URL(e.target.href);a.searchParams.set("preview_id",t),e.target.href=a.toString(),WPTB_Helper.saveTable(e,!1,t)}},document.getElementsByClassName("wptb-save-btn")[0].onclick=function(e){this.classList.contains("wptb-save-disabled")||WPTB_Helper.saveTable(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 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 p=l[r].querySelectorAll("[contenteditable]");if(0<p.length)for(var c=0;c<p.length;c++)p[c].removeAttribute("contenteditable");var m=l[r].querySelectorAll("[spellcheck]");if(0<m.length)for(var b=0;b<m.length;b++)m[b].removeAttribute("spellcheck");var u=l[r].querySelectorAll("[id^=mce_]");if(0<u.length)for(var w=0;w<u.length;w++)u[w].removeAttribute("id");for(var g=l[r].querySelectorAll(".wptb-actions"),h=g.length;0<h&&g[0]&&g[0].parentNode;)g[0].parentNode.removeChild(g[0]),h--;var v=l[r].querySelectorAll("[data-mce-bogus]");if(0<v.length){v=[].concat(_toConsumableArray(v));for(var f=0;f<v.length;f++)v[f]&&v[f].parentNode&&v[f].parentNode.removeChild(v[f])}}if(a[n].hasAttribute("data-wptb-title-column")){var y=document.createElement("div"),S=document.createElement("div");y.classList.add("wptb-column-title-mobile-container"),S.classList.add("wptb-column-title-mobile"),S.dataset.wptbTitleColumn=a[n].dataset.wptbTitleColumn,S.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+";"),S.style.padding=a[n].style.padding,0==a[n].children.length&&a[n].classList.add("wptb-column-title-mobile-not-elements"),y.appendChild(S),a[n].insertBefore(y,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,h,l=document.getElementsByClassName("wptb-settings-items"),S=document.getElementsByClassName("wptb-table-setup")[0],T=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=C(this),d=s[0],p=s[1];if(document.select.isActivated()){if(this.className.match(/wptb-highlighted/)){this.classList.remove("wptb-highlighted");for(var c=0;c<a;c++)for(var m=0;m<n;m++)array[d+c][p+m]=0}else{this.classList.add("wptb-highlighted");for(c=0;c<a;c++)for(m=0;m<n;m++)array[d+c][p+m]=1}if(0===(t=document.getElementsByClassName("wptb-highlighted").length)){for(c=0;c<o.length;c++)o[c].classList.remove("visible"),o[c].setAttribute("disabled","disabled");for(c=0;c<l.length;c++)l[c].classList.add("visible"),l[c].removeAttribute("disabled");for(c=0;c<r.length;c++)r[c].classList.remove("visible"),r[c].setAttribute("disabled","disabled");i.classList.remove("visible")}else if(1===t){for(c=0;c<o.length;c++)o[c].classList.remove("visible"),o[c].setAttribute("disabled","disabled");for(c=0;c<l.length;c++)l[c].classList.remove("visible"),l[c].setAttribute("disabled","disabled");for(c=0;c<r.length;c++)r[c].classList.add("visible"),r[c].removeAttribute("disabled");var b=document.querySelector(".wptb-highlighted");if(b){var u=document.getElementById("wptb-table-column-width-slider"),w=document.getElementById("wptb-table-column-width-number"),g=document.getElementById("wptb-table-column-width-auto-fixed"),h=b.style.width;if(h)u.value=parseFloat(h,10),w.value=parseFloat(h,10),g.checked=!0;else if(b.dataset.wptbFixedWidth)u.value=b.dataset.wptbFixedWidth,w.value=b.dataset.wptbFixedWidth,g.checked=!0;else{var v=WPTB_Helper.getColumnWidth(P,b);u.value=v,w.value=v,g.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"),T=b.style.height;if(T)f.value=parseFloat(T,10),y.value=parseFloat(T,10),S.checked=!0;else if(b.dataset.wptbFixedHeight)f.value=b.dataset.wptbFixedHeight,y.value=b.dataset.wptbFixedHeight,S.checked=!0;else{var B=WPTB_Helper.getRowHeight(P,b);f.value=B,y.value=B,S.checked=!1}}i.classList.add("visible")}else{for(c=0;c<o.length;c++)P.isSquare(array)?(o[c].classList.add("visible"),o[c].removeAttribute("disabled")):(o[c].classList.remove("visible"),o[c].setAttribute("disabled","disabled"));for(c=0;c<l.length;c++)l[c].classList.remove("visible"),l[c].setAttribute("disabled","disabled");for(c=0;c<r.length;c++)r[c].classList.remove("visible"),r[c].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")},C=function(e){for(var t=[],a=0;a<h;a++)t[a]=0;for(a=0;a<P.rows.length;a++)for(var n=P.rows[a].getElementsByTagName("td"),l=cellPointer=0;l<h;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-border-color").val(""),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","wptb-element-main-table_setting-startedid-0"),P.style.border="0px solid",P.dataset.reconstraction=1,P.dataset.wptbAdaptiveTable=1;for(r=0;r<t;r++){(a=P.insertRow(-1)).classList.add("wptb-row");for(var w=0;w<e;w++)(n=new WPTB_Cell(T)).setCoords(r,w),n.getDOMElement().style.borderWidth="1px",a.appendChild(n.getDOMElement())}}else{var o=document.getElementsByClassName("wptb-preview-table");if(!(0<o.length))return;var i=(P=o[0]).getElementsByTagName("td");if(0<i.length)for(var s=0;s<i.length;s++)WPTB_Cell(T,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=0;o<t.length;o++){r[o],a=t[o].getElementsByTagName("td"),null==r[o]&&(r[o]=[]);for(var i=0,s=0;s<a.length;s++){if(null!=r[o][s])for(var d=0;d<100;d++){if(null==r[o][i]){r[o][i]=a[s],a[s].dataset.xIndex=i;break}i++}else r[o][s]=a[s],a[s].dataset.xIndex=i;if(a[s].dataset.yIndex=o,1<a[s].colSpan)for(var p=1;p<a[s].colSpan;p++)i++,r[o][i]="tdDummy";if(1<a[s].rowSpan)for(var c=1;c<a[s].rowSpan;c++){null==r[o+c]&&(r[o+c]=[]);for(var m=0;m<a[s].colSpan;m++)r[o+c][i-a[s].colSpan+1+m]="tdDummy"}i++,0==o&&(l=i)}n<s&&(n=s)}this.columns=n,this.maxCols=l},P.addColumnWidth=function(m,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(m)if(d.colSpan==a){d.style.width=m+"px",d.removeAttribute("data-wptb-fixed-width"),l=!0;var p=document.getElementById("wptb-table-column-width-auto-fixed");p.checked||(p.checked=!0)}else d.style.width=null,d.dataset.wptbFixedWidth=m,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 c=0;c<r.length;c++)r[c].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],r=l.offsetWidth,o=[],i=[],s=0,d=0,p="",c=window.getComputedStyle(P,null),m=c.getPropertyValue("border-left-width"),b=c.getPropertyValue("border-right-width"),u=parseFloat(m,10)+parseFloat(b,10),w=0;w<t.length;w++)for(var g=t[w].children,h=0;h<g.length;h++){var v=g[h];if(o[parseFloat(v.dataset.xIndex)]||i[parseFloat(v.dataset.xIndex)])i[parseFloat(v.dataset.xIndex)]?v.dataset.wptbFixedWidth||(v.dataset.wptbCssTdAutoWidth=!0):o[parseFloat(v.dataset.xIndex)]&&v.removeAttribute("data-wptb-css-td-auto-width");else if(v.style.width?(o[parseFloat(v.dataset.xIndex)]=parseFloat(v.style.width),v.removeAttribute("data-wptb-css-td-auto-width")):v.dataset.wptbFixedWidth||(i[parseFloat(v.dataset.xIndex)]=100,v.dataset.wptbCssTdAutoWidth=!0),window.getComputedStyle(v,null)){var f=window.getComputedStyle(v,null),y=f.getPropertyValue("padding-left"),S=f.getPropertyValue("padding-right");s=parseFloat(y,10)+parseFloat(S,10);var T=f.getPropertyValue("border-left-width"),B=f.getPropertyValue("border-right-width");d=parseFloat(T,10)+parseFloat(B,10),d/=2,o[parseFloat(v.dataset.xIndex)]?(o[parseFloat(v.dataset.xIndex)]+=s,o[parseFloat(v.dataset.xIndex)]+=d,0==h&&u/2<=parseFloat(T,10)?o[parseFloat(v.dataset.xIndex)]+=parseFloat(T,10)/2:0==h&&u/2>parseFloat(T,10)&&(o[parseFloat(v.dataset.xIndex)]+=u/2-parseFloat(B,10)/2),h==g.length-1&&u/2<=parseFloat(B,10)?o[parseFloat(v.dataset.xIndex)]+=parseFloat(B,10)/2:h==g.length-1&&u/2>parseFloat(B,10)&&(o[parseFloat(v.dataset.xIndex)]+=u/2-parseFloat(B,10)/2)):i[parseFloat(v.dataset.xIndex)]&&(i[parseFloat(v.dataset.xIndex)]+=s,i[parseFloat(v.dataset.xIndex)]+=d,0==h&&u/2<=parseFloat(T,10)?i[parseFloat(v.dataset.xIndex)]+=parseFloat(T,10)/2:0==h&&u/2>parseFloat(T,10)&&(i[parseFloat(v.dataset.xIndex)]+=u/2-parseFloat(T,10)/2),h==g.length-1&&u/2<=parseFloat(B,10)?i[parseFloat(v.dataset.xIndex)]+=parseFloat(B,10)/2:h==g.length-1&&u/2>parseFloat(B,10)&&(i[parseFloat(v.dataset.xIndex)]+=u/2-parseFloat(T,10)/2))}}for(var E=0;E<o.length;E++)o[E]&&(a+=o[E]);for(var C=0,x=0;x<i.length;x++)i[x]&&(n+=i[x],C++);e=a+n,P.dataset.wptbTableTdsSumMaxWidth=e,C?(P.dataset.wptbCellsWidthAutoCount=C,P.mergingСellsHorizontally?P.dataset.wptbFixedWidthSize=a:P.removeAttribute("data-wptb-fixed-width-size")):(P.removeAttribute("data-wptb-fixed-width-size"),P.removeAttribute("data-wptb-cells-width-auto-count"));var A=!1,N=void 0;e<r?C?(P.style.minWidth="100%",P.mergingСellsHorizontally?(N=(N=(r-a)/C)-s-d,A=!(P.style.width=null)):P.style.width="100%"):(P.style.width=null,P.style.minWidth=null,P.style.maxWidth=null):(P.style.maxWidth=null,P.style.minWidth=e+"px",N="100",A=!(P.style.width=null));var _=document.head;if(_){var L=_.querySelector('style[data-wptb-td-auto-width="true"]');L&&_.removeChild(L)}if(A&&((p=document.createElement("style")).setAttribute("data-wptb-td-auto-width",!0),p.innerHTML="[data-wptb-css-td-auto-width=true]{width:"+N+"px}",_&&_.appendChild(p)),P.dataset.wptbTableAlignment){var W=P.dataset.wptbTableAlignment;l.offsetWidth<P.offsetWidth?P.style.float=null:P.style.float="center"==W?null:W,l.style.float="center"==W?null:W}else P.style.float=null},P.addRowHeight=function(m,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(m){if(d.rowSpan==a){d.style.height=m+"px",d.removeAttribute("data-wptb-fixed-heidht"),l=!0;var p=document.getElementById("wptb-table-row-height-auto-fixed");p.checked||(p.checked=!0);continue}d.style.height=null,d.dataset.wptbFixedHeight=m,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 c=0;c<r.length;c++)r[c].style.height=d.style.height;r=[]}else r.push(d)}}(a,1)}},P.reconstraction=function(){var e=P.getElementsByTagName("td");P.mergingСellsHorizontally=!1,P.mergingCellsVertically=!1,P.dataset.reconstraction=1;for(var t=0,a=0;a<e.length&&(1<e[a].colSpan&&(P.dataset.reconstraction=0,P.mergingСellsHorizontally=!0,t++),1<e[a].rowSpan&&(P.dataset.reconstraction=0,P.mergingCellsVertically=!0,t++),2!=t);a++);},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(T),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);h++,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(T),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);h++,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:C(l)[1];if(h-o-l.colSpan+1==1)P.addColumnEnd();else{for(var i=!1,s=void 0,d=void 0,p=void 0,c=[],m=void 0,b=0;b<h;b++)c.push(0);for(b=0;b<t.length;b++){a=0,n=t[b].getElementsByTagName("td"),i=!1;for(var u=0;u<h;u+=s){if(s=1,i){d=new WPTB_Cell(T),r&&(d.getDOMElement().setAttribute("style",r),d.getDOMElement().style.width=null,d.getDOMElement().style.height=null),m&&t[b].contains(m)?(p=m.nextSibling)?t[b].insertBefore(d.getDOMElement(),p):t[b].appendChild(d.getDOMElement()):t[b].insertBefore(d.getDOMElement(),n[0]);break}if(0<c[u])o==u&&(i=!0);else if(1<(m=n[a++]).rowSpan){s=m.colSpan;for(var w=0;w<m.colSpan;w++)c[u+w]=m.rowSpan,u+w==o&&(i=!0)}else if(1<m.colSpan){s=m.colSpan;for(w=0;w<m.colSpan;w++)u+w==o&&(i=!0)}else u==o&&(i=!0)}for(var g=0;g<h;g++)0<c[g]&&c[g]--}for(b=0;b<array.length;b++)array[b].push(0);h++,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=C(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<h;l++){t=new WPTB_Cell(T);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<h;l++){t=new WPTB_Cell(T);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=C(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=C(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 p=P.rows[n+1].children,c=p.length;if(0<c)for(var m=0;m<c;m++)r+=p[m].colSpan}else r=array[0].length;var b=P.insertRow(n+1);for(b.classList.add("wptb-row"),w=0;w<r;w++){var u=new WPTB_Cell(T);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 p=0;p<r.length;p++)n.appendChild(r[p]);n.colSpan=a,n.rowSpan=t,P.recalculateIndexes(),P.reconstraction();var c=n.style.width,m=n.dataset.wptbFixedWidth;c?P.addColumnWidth(parseFloat(c,10)):m?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=C(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(T);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 p=void 0,c=P.rows[l+d],m=c.children,b=m.length;if(0<b)for(var u=0;u<b;u++)if(Number(m[u].dataset.xIndex)>Number(o)){p=m[u];break}for(var w=0;w<a;w++){var g=new WPTB_Cell(T);g.getDOMElement().setAttribute("style",n),null!=p?c.insertBefore(g.getDOMElement(),p):c.appendChild(g.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===h)return[];t=h-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=h-r;for(n=0;n<difference;n++){var o=new WPTB_Cell(T);P.rows[t].appendChild(o.getDOMElement())}}},P.deleteRow=function(){var e=document.querySelector(".wptb-highlighted"),t=e.getAttribute("style"),a=e.rowSpan,n=C(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,p=[];if(null!=i){d=(s=i.children).length;for(var c=0;c<o.length;c++)if(1<o[c].rowSpan){var m=new WPTB_Cell(T);m.getDOMElement().setAttribute("style",t),m.getDOMElement().colSpan=o[c].colSpan,m.getDOMElement().rowSpan=o[c].rowSpan-1;for(var b=void 0,u=0;u<d;u++)if(Number(s[u].dataset.xIndex)>Number(o[c].dataset.xIndex)){b=s[u];break}b?p.push([m,b]):p.push([m])}if(0<p.length)for(var w=0;w<p.length;w++)null!=p[w][1]?i.insertBefore(p[w][0].getDOMElement(),p[w][1]):i.appendChild(p[w][0].getDOMElement())}var g=P.rows;if(0<g.length)for(var h=0;h<n;h++){var v=g[h].children;if(0<v.length)for(var f=0;f<v.length;f++)v[f].rowSpan-1>=n-h&&v[f].rowSpan--}if(l=Array.from(array[0]),array.pop(l),B(array),P.getElementsByTagName("tbody")[0].removeChild(P.rows[n]),0==P.rows.length){P.toggleTableEditMode(),S.innerHTML="",document.getElementsByClassName("wptb-table-generator")[0].style.display="table";var y=document.getElementsByClassName("wptb-save-btn");0<y.length&&(y=y[0]).classList.add("wptb-save-disabled")}else 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();if(h--,0==P.querySelectorAll("td").length){P.toggleTableEditMode(),S.innerHTML="",document.getElementsByClassName("wptb-table-generator")[0].style.display="table";var d=document.getElementsByClassName("wptb-save-btn");0<d.length&&(d=d[0]).classList.add("wptb-save-disabled")}else 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)}h=Math.max.apply(null,e);var o=P.rows.length;for(a=0;a<o;a++)for(t[a]=[],r=0;r<h;r++)t[a].push(0);return B(t),t}(),E(),B(array),S.appendChild(P),P.recalculateIndexes(!0),P.reconstraction(),P.tdDefaultWidth(),S.onresize=function(){P.tdDefaultWidth()},WPTB_LeftPanel()},WPTB_TableStateSaveManager=(_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(){this.tableStateSet=function(e){if(!(e&&window.wptbTableStateSaving&&Array.isArray(window.wptbTableStateSaving))){var t=document.getElementsByClassName("wptb-preview-table");t=0<t.length?t[0]:"",window.wptbTableStateSaving||Array.isArray(window.wptbTableStateSaving)||(window.wptbTableStateSaving=[]),window.wptbTableStateSaving.length>window.wptbTableStateNumberShow&&(window.wptbTableStateSaving=window.wptbTableStateSaving.slice(0,window.wptbTableStateNumberShow+1));var a="";if(t){for(var n=(a=t.cloneNode(!0)).getElementsByClassName("wptb-highlighted"),l=0;l<n.length;l++)n[l].classList.remove("wptb-highlighted");for(var r=a.getElementsByClassName("wptb-directlyhovered"),o=0;o<r.length;o++)r[o].classList.remove("wptb-directlyhovered");var i=a.querySelectorAll(".mce-content-body");if(0<i.length)for(var s=0;s<i.length;s++)i[s].classList.remove("mce-content-body");var d=a.querySelectorAll("[data-mce-style]");if(0<d.length)for(var p=0;p<d.length;p++)d[p].removeAttribute("data-mce-style");var c=a.querySelectorAll("[id^=mce_]");if(0<c.length)for(var m=0;m<c.length;m++)c[m].removeAttribute("id")}var b="",u=document.head;if(u){var w=u.querySelector('style[data-wptb-td-auto-width="true"]');w&&(b=w.innerHTML)}var g=document.getElementsByClassName("wptb-element-datas");g=0<g.length?(g=g[0]).innerHTML:"";var h=WPTB_Helper.elementsStylesConvertToObject();if(window.wptbTableStateSaving.push([a,b,g,h]),window.wptbTableStateNumberShow=window.wptbTableStateSaving.length-1,0<window.wptbTableStateSaving.length-1){var v=document.getElementsByClassName("wptb-undo");0<v.length&&(v=v[0]).classList.remove("wptb-undoredo-disabled")}var f=document.getElementsByClassName("wptb-redo");0<f.length&&(f=f[0]).classList.add("wptb-undoredo-disabled");var y=document.getElementsByClassName("wptb-save-btn");0<y.length&&(!(y=y[0]).dataset.wptbTableStateNumberSave&&0==window.wptbTableStateNumberShow||window.wptbTableStateNumberShow==y.dataset.wptbTableStateNumberSave||!t?y.classList.add("wptb-save-disabled"):y.classList.remove("wptb-save-disabled"))}},this.tableStateGet=function(e){if(e&&window.wptbTableStateSaving&&0<window.wptbTableStateSaving.length){if("undo"==e){if(!(0<window.wptbTableStateNumberShow))return!1;window.wptbTableStateNumberShow--}else if("redo"==e){if(!(window.wptbTableStateNumberShow<window.wptbTableStateSaving.length))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="",window.wptbTableStateSaving[window.wptbTableStateNumberShow]&&(window.wptbTableStateSaving[window.wptbTableStateNumberShow][0]&&"object"===_typeof(window.wptbTableStateSaving[window.wptbTableStateNumberShow][0])&&"outerHTML"in window.wptbTableStateSaving[window.wptbTableStateNumberShow][0]&&(l.innerHTML=window.wptbTableStateSaving[window.wptbTableStateNumberShow][0].outerHTML),l.innerHTML?document.getElementsByClassName("wptb-table-generator")[0].style.display="none":(document.getElementsByClassName("wptb-table-generator")[0].style.display="table",n.classList.add("wptb-save-disabled"))),window.wptbTableStateSaving[window.wptbTableStateNumberShow]){var r=document.head;if(r){var o=r.querySelector('style[data-wptb-td-auto-width="true"]');if(o&&r.removeChild(o),window.wptbTableStateSaving[window.wptbTableStateNumberShow][1]){var i=document.createElement("style");i.setAttribute("data-wptb-td-auto-width",!0),i.innerHTML=window.wptbTableStateSaving[window.wptbTableStateNumberShow][1],r.appendChild(i)}}}var s=document.getElementsByTagName("body");0<s.length&&(s=s[0]);var d=document.getElementsByClassName("wptb-element-datas");window.wptbTableStateSaving[window.wptbTableStateNumberShow]&&window.wptbTableStateSaving[window.wptbTableStateNumberShow][2]?(0<d.length?d=d[0]:((d=document.createElement("sctipt")).classList.add("wptb-element-datas"),s.appendChild(d)),d.innerHTML=window.wptbTableStateSaving[window.wptbTableStateNumberShow][2]):0<d.length&&(d=d[0],s.removeChild(d)),window.wptbTableStateSaving[window.wptbTableStateNumberShow]&&WPTB_Helper.elementsStylesSetFromObject(window.wptbTableStateSaving[window.wptbTableStateNumberShow][3]),WPTB_Helper.elementOptionsPanelClear(),WPTB_LeftPanel();var p=document.getElementById("wptb-left-scroll-panel-cell-settings");p&&p.classList.remove("visible")}}},this.tableStateClear=function(){delete window.wptbTableStateSaving,delete window.wptbTableStateNumberShow;var e=document.getElementsByClassName("wptb-save-btn");0<e.length&&(e=e[0]).removeAttribute("data-wptb-table-state-number-save");var t=document.getElementsByClassName("wptb-undo");0<t.length&&(t=t[0]).classList.add("wptb-undoredo-disabled");var a=document.getElementsByClassName("wptb-redo");0<a.length&&(a=a[0]).classList.add("wptb-undoredo-disabled")}}),WPTB_innerElementSet=function p(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