WP Table Builder – WordPress Table Plugin - Version 1.1.4

Version Description

  • ADD: Option to set max width for table container.
  • FIX: Table Alignment setting issue.
  • FIX: PHP errors.
  • FIX: Table editing issue.
  • FIX: Table Settings not showing issue.
  • FIX: Table duplicaton issue.
Download this release

Release Info

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

Code changes from version 1.1.3 to 1.1.4

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_meta( absint( $params->id ) , '_wptb_content_', true ) ) {
50
  $id = wp_insert_post([
51
  'post_title' => sanitize_text_field( $params->title ),
52
  'post_content' => '',
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' => '',
inc/admin/class-tables.php CHANGED
@@ -101,43 +101,26 @@ class Tables {
101
  do_action( 'wptb_frontend_enqueue_script' );
102
  $html = get_post_meta( $args['id'] , '_wptb_content_', true );
103
 
104
- // prepating html encoding for looking for shortcodes using DOMDocument
105
- $html_encoding = mb_detect_encoding( $html );
106
- if( $html_encoding != 'UTF-8' ) {
107
- $html = mb_convert_encoding( $html, "UTF-8", $html_encoding );
108
- }
109
-
110
- $html = mb_convert_encoding( $html, 'HTML-ENTITIES', 'utf-8' );
111
-
112
- $dom = new \DOMDocument( '1.0', 'UTF-8' );
113
- $dom->validateOnParse = true;
114
- $dom->encoding="UTF-8";
115
- $dom->loadHTML( $html );
116
- $divs = $dom->getElementsByTagName( 'div' );
117
- $shortcodes = array();
118
- foreach ( $divs as $div ) {
119
- $classes = $div->getAttribute( 'class' );
120
- if ( strpos( $classes, 'wptb-shortcode-container' ) !== false ) {
121
- $div_outer_html = trim( $div->ownerDocument->saveHTML( $div ) );
122
-
123
- if( ! isset( $args['internal_shortcodes_stop'] ) && $div_outer_html ) {
124
  $pattern = get_shortcode_regex();
125
 
126
- if ( preg_match_all( '/'. $pattern .'/s', $div_outer_html, $matches ) ) {
127
 
128
  for( $i = 0; $i < count( $matches[0] ); $i++ ) {
129
  $shortcode = $matches[0][$i];
130
- if( $matches[2][$i] == 'wptb' ) {
131
 
132
  $shortcode = str_replace( ']' , ' internal_shortcodes_stop="1"]' , $matches[0][$i] );
133
 
134
- $div_outer_html_new = str_replace( $matches[0][$i] , $shortcode , $div_outer_html );
135
 
136
- $html = str_replace( $div_outer_html, $div_outer_html_new, $html );
137
 
138
  $html = str_replace( $div_outer_html_new, do_shortcode( $div_outer_html_new ), $html );
139
  } else {
140
- $html = str_replace( $div_outer_html, do_shortcode( $div_outer_html ), $html );
141
  }
142
  }
143
  }
@@ -145,7 +128,7 @@ class Tables {
145
  }
146
  }
147
 
148
- $post_edit_link;
149
  if( current_user_can( 'manage_options' ) ){
150
  $post_edit_link = '<div class="wptb-frontend-table-edit-link">'
151
  . '<a href="' . admin_url( 'admin.php?page=wptb-builder&table=' . $args['id'] ) . '">' . __( "Edit Table", 'wp-table-builder' ) . '</a></div>';
@@ -157,8 +140,12 @@ class Tables {
157
  . ' wptbContainer = wptbContainer[0];'
158
  . ' var wptbPreviewTable = wptbContainer.getElementsByClassName( "wptb-preview-table" );'
159
  . ' if( wptbPreviewTable.length > 0 ) {'
160
- . ' wptbPreviewTable[0].classList.remove( "wptb-table-preview-static-indic" );'
161
- . ' wptbPreviewTable[0].style.display = "none";'
 
 
 
 
162
  . ' }'
163
  . '}'
164
  . '</script>';
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();
108
 
109
+ if ( preg_match_all( '/'. $pattern .'/s', $value, $matches ) ) {
110
 
111
  for( $i = 0; $i < count( $matches[0] ); $i++ ) {
112
  $shortcode = $matches[0][$i];
113
+ if( isset( $matches[2][$i] ) && $matches[2][$i] == 'wptb' ) {
114
 
115
  $shortcode = str_replace( ']' , ' internal_shortcodes_stop="1"]' , $matches[0][$i] );
116
 
117
+ $div_outer_html_new = str_replace( $matches[0][$i] , $shortcode , $value );
118
 
119
+ $html = str_replace( $value, $div_outer_html_new, $html );
120
 
121
  $html = str_replace( $div_outer_html_new, do_shortcode( $div_outer_html_new ), $html );
122
  } else {
123
+ $html = str_replace( $value, do_shortcode( $value ), $html );
124
  }
125
  }
126
  }
128
  }
129
  }
130
 
131
+ $post_edit_link = '';
132
  if( current_user_can( 'manage_options' ) ){
133
  $post_edit_link = '<div class="wptb-frontend-table-edit-link">'
134
  . '<a href="' . admin_url( 'admin.php?page=wptb-builder&table=' . $args['id'] ) . '">' . __( "Edit Table", 'wp-table-builder' ) . '</a></div>';
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>';
inc/admin/controls/control-alignment.php CHANGED
@@ -83,7 +83,7 @@ class Control_Alignment extends Base_Control {
83
  styleAlignment = data.selectors[prop];
84
  }
85
 
86
- if( styleAlignment == 'text-align' ) {
87
  left = 'left';
88
  center = 'center';
89
  right = 'right';
@@ -140,15 +140,28 @@ class Control_Alignment extends Base_Control {
140
  if( selectorEl.length && '{{{styleAlignment}}}' ) {
141
  for( let i = 0; i < selectorEl.length; i++ ) {
142
  if( i === 0 ) {
143
- selectedButtonAlignment = selectorEl[i].style['{{{styleAlignment}}}'];
 
 
 
 
144
  }
145
 
146
- if( i > 0 && selectedButtonAlignment != selectorEl[i].style['{{{styleAlignment}}}'] ) {
147
- selectedButtonAlignment = false;
 
 
 
 
 
 
 
 
148
  }
149
  }
150
 
151
  }
 
152
  for ( var i = 0; i < buttons.length; i++ ) {
153
  if( selectedButtonAlignment ) {
154
  buttons[i].classList.remove( 'selected' );
@@ -160,11 +173,15 @@ class Control_Alignment extends Base_Control {
160
 
161
  buttons[i].onclick = function () {
162
  let selectorEl = document.querySelectorAll( '{{{selector}}}' );
163
- if( selectorEl.length && '{{{styleAlignment}}}' ) {
164
  let buttonDataAlignment = this.dataset.alignmentValue;
165
 
166
  for( let i = 0; i < selectorEl.length; i++ ) {
167
- selectorEl[i].style['{{{styleAlignment}}}'] = buttonDataAlignment;
 
 
 
 
168
  }
169
 
170
  var b = this.parentNode.getElementsByClassName( 'wptb-btn-size-btn' );
@@ -172,12 +189,18 @@ class Control_Alignment extends Base_Control {
172
  b[i].classList.remove( 'selected' );
173
  }
174
  this.classList.add( 'selected' );
175
-
 
 
 
 
176
  let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
177
  wptbTableStateSaveManager.tableStateSet();
178
  }
179
  }
180
  }
 
 
181
  } )();
182
  </wptb-template-script>
183
  <?php
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';
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' );
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' );
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
inc/admin/controls/control-color.php CHANGED
@@ -55,6 +55,7 @@ class Control_Color extends Base_Control {
55
  name,
56
  selectors = [],
57
  elemContainer,
 
58
  targetInputAddClass;
59
 
60
  if( data.label ) {
55
  name,
56
  selectors = [],
57
  elemContainer,
58
+ selectorsJson,
59
  targetInputAddClass;
60
 
61
  if( data.label ) {
inc/admin/controls/control-size.php CHANGED
@@ -150,10 +150,19 @@ class Control_Size extends Base_Control {
150
  continue;
151
  }
152
 
153
- selectorElements[i].style[cssSettingArr[j]] = this.value + '{{{dimension}}}' + '{{{addText}}}';
 
 
 
 
154
  }
155
  }
 
 
 
 
156
  };
 
157
 
158
  event.target.onmouseup = function() {
159
  let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
@@ -172,6 +181,8 @@ class Control_Size extends Base_Control {
172
  this.parentNode.parentNode.getElementsByClassName('wptb-size-slider')[0].oninput( event );
173
  }
174
  }
 
 
175
  }
176
  }
177
  } )();
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();
181
  this.parentNode.parentNode.getElementsByClassName('wptb-size-slider')[0].oninput( event );
182
  }
183
  }
184
+
185
+ WPTB_Helper.controlsStateManager( '{{{targetInputAddClass}}}' );
186
  }
187
  }
188
  } )();
inc/admin/controls/control-toggle.php CHANGED
@@ -52,7 +52,9 @@ class Control_Toggle extends Base_Control {
52
  let label,
53
  selector,
54
  selectors = [],
55
- elemContainer;
 
 
56
 
57
  if( data.label ) {
58
  label = data.label;
@@ -104,7 +106,6 @@ class Control_Toggle extends Base_Control {
104
  }
105
 
106
  WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement, details );
107
-
108
  if( '{{{selectorsJson}}}' ) {
109
  let selectors = JSON.parse( '{{{selectorsJson}}}' );
110
 
@@ -117,25 +118,51 @@ class Control_Toggle extends Base_Control {
117
  if( selectors[i][1] && Array.isArray( selectors[i][1] ) ) {
118
  if( selectors[i][1][0] && Array.isArray( selectors[i][1][0] ) ) {
119
  for( let k = 0; k < selectors[i][1].length; k++ ) {
120
- if( selectors[i][1][k][0] && selectors[i][1][k][1] && selectors[i][1][k][2] ) {
121
  let styleValue;
122
  if( details.value == 'checked' ) {
123
- styleValue = selectors[i][1][k][1];
 
 
 
 
 
 
 
 
 
 
124
  } else {
125
- styleValue = selectors[i][1][k][2];
 
 
 
 
126
  }
127
- selectorElements[j].style[selectors[i][1][k][0]] = styleValue;
128
  }
129
  }
130
  } else {
131
- if( selectors[i][1][0] && selectors[i][1][1] && selectors[i][1][2] ) {
132
  let styleValue;
133
  if( details.value == 'checked' ) {
134
- styleValue = selectors[i][1][1];
135
  } else {
136
- styleValue = selectors[i][1][2];
 
 
 
 
 
 
 
 
 
 
 
 
 
 
137
  }
138
- selectorElements[j].style[selectors[i][1][0]] = styleValue;
139
  }
140
  }
141
  }
52
  let label,
53
  selector,
54
  selectors = [],
55
+ elemContainer,
56
+ selectorsJson,
57
+ targetInputAddClass;
58
 
59
  if( data.label ) {
60
  label = data.label;
106
  }
107
 
108
  WPTB_Helper.wptbDocumentEventGenerate( 'wptb-control:{{{targetInputAddClass}}}', selectorElement, details );
 
109
  if( '{{{selectorsJson}}}' ) {
110
  let selectors = JSON.parse( '{{{selectorsJson}}}' );
111
 
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
  }
168
  }
inc/admin/css/admin.css CHANGED
@@ -333,6 +333,7 @@ body>img {
333
  background: none;
334
  max-width: 870px;
335
  margin: auto;
 
336
  }
337
 
338
  .wptb-edit-bar.visible {
@@ -766,19 +767,22 @@ input[type="range"]::-ms-thumb {
766
  transition: .25s;
767
  }
768
 
769
- .wptb-toggle.wptb-column-width-fix-auto input:checked+i::after {
 
770
  -webkit-transform: translateX(50px);
771
  transform: translateX(50px);
772
  }
773
 
774
- .wptb-toggle.wptb-column-width-fix-auto i {
 
775
  float: left;
776
  width: 100px;
777
  border-radius: 5px;
778
  height: 25px;
779
  }
780
 
781
- .wptb-toggle.wptb-column-width-fix-auto i:after {
 
782
  width: 50px;
783
  height: 25px;
784
  border-radius: 5px;
333
  background: none;
334
  max-width: 870px;
335
  margin: auto;
336
+ clear: both;
337
  }
338
 
339
  .wptb-edit-bar.visible {
767
  transition: .25s;
768
  }
769
 
770
+ .wptb-toggle.wptb-column-width-fix-auto input:checked+i::after,
771
+ .wptb-toggle.wptb-size-fixed-auto input:checked+i::after{
772
  -webkit-transform: translateX(50px);
773
  transform: translateX(50px);
774
  }
775
 
776
+ .wptb-toggle.wptb-column-width-fix-auto i,
777
+ .wptb-toggle.wptb-size-fixed-auto i{
778
  float: left;
779
  width: 100px;
780
  border-radius: 5px;
781
  height: 25px;
782
  }
783
 
784
+ .wptb-toggle.wptb-column-width-fix-auto i:after,
785
+ .wptb-toggle.wptb-size-fixed-auto i:after{
786
  width: 50px;
787
  height: 25px;
788
  border-radius: 5px;
inc/admin/element-classes/element-scripts/button-element.js CHANGED
@@ -60,7 +60,6 @@ if( target ) {
60
  delete document.getElementById('wpcd_fixed_toolbar').style.right;
61
  delete document.getElementById('wpcd_fixed_toolbar').style.top;
62
  }
63
- console.log('Hello555');
64
  });
65
  }
66
  });
@@ -114,7 +113,13 @@ if( elementsSettingsTemplateJs.length > 0 ) {
114
  elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];
115
  elementsSettings = elementsSettingsTemplateJs.innerHTML;
116
  if( elementsSettings ) {
117
- elementsSettings = JSON.parse( elementsSettings );
 
 
 
 
 
 
118
  if( typeof elementsSettings === 'object' && ( 'tmpl-wptb-el-datas-' + infArrEl[1] ) in elementsSettings ) {
119
  elementSettings = elementsSettings['tmpl-wptb-el-datas-' + infArrEl[1]];
120
  }
60
  delete document.getElementById('wpcd_fixed_toolbar').style.right;
61
  delete document.getElementById('wpcd_fixed_toolbar').style.top;
62
  }
 
63
  });
64
  }
65
  });
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
  }
inc/admin/element-classes/element-scripts/custom-html-element.js CHANGED
@@ -49,7 +49,6 @@ tinyMCE.init({
49
  });
50
 
51
  ed.on( 'keyup', function(e) {
52
- console.log('keyup');
53
  let div = e.target;
54
  let divText = div.innerHTML.replace( /\s+/g, ' ' ).trim();
55
  divText = divText.replace( /&nbsp;/g, '').trim();
49
  });
50
 
51
  ed.on( 'keyup', function(e) {
 
52
  let div = e.target;
53
  let divText = div.innerHTML.replace( /\s+/g, ' ' ).trim();
54
  divText = divText.replace( /&nbsp;/g, '').trim();
inc/admin/element-classes/element-scripts/image-element.js CHANGED
@@ -64,7 +64,6 @@ let addMedia = function( element, imageChange = false ) {
64
 
65
  if ( src == undefined || imageChange == true ) {
66
  file_frame.open();
67
- console.log(file_frame);
68
  file_frame.menuItemVisibility( 'gallery', 'hide' );
69
  file_frame.menuItemVisibility( 'playlist', 'hide' ),
70
  file_frame.menuItemVisibility( 'video-playlist', 'hide' ),
@@ -112,7 +111,12 @@ if( elementsSettingsTemplateJs.length > 0 ) {
112
  elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];
113
  elementsSettings = elementsSettingsTemplateJs.innerHTML;
114
  if( elementsSettings ) {
115
- elementsSettings = JSON.parse( elementsSettings );
 
 
 
 
 
116
  if( typeof elementsSettings === 'object' && ( 'tmpl-wptb-el-datas-' + infArrEl[1] ) in elementsSettings ) {
117
  elementSettings = elementsSettings['tmpl-wptb-el-datas-' + infArrEl[1]];
118
  }
64
 
65
  if ( src == undefined || imageChange == true ) {
66
  file_frame.open();
 
67
  file_frame.menuItemVisibility( 'gallery', 'hide' );
68
  file_frame.menuItemVisibility( 'playlist', 'hide' ),
69
  file_frame.menuItemVisibility( 'video-playlist', 'hide' ),
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
  }
inc/admin/element-classes/element-scripts/list-element.js CHANGED
@@ -195,7 +195,12 @@ if( elementsSettingsTemplateJs.length > 0 ) {
195
  elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];
196
  elementsSettings = elementsSettingsTemplateJs.innerHTML;
197
  if( elementsSettings ) {
198
- elementsSettings = JSON.parse( elementsSettings );
 
 
 
 
 
199
  if( typeof elementsSettings === 'object' && ( 'tmpl-wptb-el-datas-' + infArr[1] ) in elementsSettings ) {
200
  elementSettings = elementsSettings['tmpl-wptb-el-datas-' + infArr[1]];
201
  }
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
  }
inc/admin/element-classes/element-scripts/shortcode-element.js CHANGED
@@ -2,62 +2,67 @@ let infArr = element.className.match( /wptb-element-((.+-)\d+)/i );
2
  let controlKey = 'textarea';
3
  let elementControlTargetUnicClass = 'wptb-el-' + infArr[1] + '-' + controlKey;
4
 
5
- tinyMCE.init({
6
- target: element.childNodes[0],
7
- inline: true,
8
- plugins: "link, paste",
9
- dialog_type: "modal",
10
- theme: 'modern',
11
- menubar: false,
12
- force_br_newlines : false,
13
- force_p_newlines : false,
14
- forced_root_block : '',
15
- paste_as_text: true,
16
- toolbar: false,
17
- setup : function( ed ) {
18
-
19
- ed.on( 'input', function( e ) {
20
- let elementControlTextarea = document.getElementsByClassName( elementControlTargetUnicClass );
21
- if( elementControlTextarea.length > 0 ) {
22
- elementControlTextarea = elementControlTextarea[0];
23
- elementControlTextarea.value = ed.targetElm.textContent;
24
- }
25
- WPTB_Helper.controlsStateManager( elementControlTargetUnicClass, true );
26
- });
27
-
28
- ed.on( 'keydown', function( e ) {
29
- let div = e.target;
30
- let divText = div.innerHTML.replace( /\s+/g, ' ' ).trim();
31
- divText = divText.replace( /&nbsp;/g, '').trim();
32
-
33
- if( ! window.shortcodeElemKeyDown ) {
34
- window.shortcodeElemKeyDown = divText;
35
- }
36
- });
37
-
38
- ed.on( 'keyup', function(e) {
39
- let div = e.target;
40
- let divText = div.innerHTML.replace( /\s+/g, ' ' ).trim();
41
- divText = divText.replace( /&nbsp;/g, '').trim();
42
- if( divText !== window.shortcodeElemKeyDown ) {
43
- e.target.onblur = function() {
44
- let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
45
- wptbTableStateSaveManager.tableStateSet();
46
 
47
- window.shortcodeElemKeyDown = '';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  e.target.onblur = '';
49
  }
50
- } else {
51
- e.target.onblur = '';
52
- }
53
- });
54
- }
55
- });
56
 
57
- element.addEventListener( 'wptb-control:' + elementControlTargetUnicClass, function( event ) {
58
- let targetElm = element.getElementsByClassName( 'mce-content-body' );
59
- if( targetElm.length > 0 ) {
60
- targetElm = targetElm[0];
61
- targetElm.innerText = event.detail.value;
62
- }
63
- }, false );
 
2
  let controlKey = 'textarea';
3
  let elementControlTargetUnicClass = 'wptb-el-' + infArr[1] + '-' + controlKey;
4
 
5
+ let tinyMceTarget = element.getElementsByTagName( 'div' );
6
+ if( tinyMceTarget.length > 0 ) {
7
+ tinyMceTarget = tinyMceTarget[0];
8
+
9
+ tinyMCE.init({
10
+ target: tinyMceTarget,
11
+ inline: true,
12
+ plugins: "link",
13
+ dialog_type: "modal",
14
+ theme: 'modern',
15
+ menubar: false,
16
+ force_br_newlines : false,
17
+ force_p_newlines : false,
18
+ forced_root_block : '',
19
+ paste_as_text: true,
20
+ toolbar: false,
21
+ setup : function( ed ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
 
23
+ ed.on( 'input', function( e ) {
24
+ let elementControlTextarea = document.getElementsByClassName( elementControlTargetUnicClass );
25
+ if( elementControlTextarea.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 ) {
33
+ let div = e.target;
34
+ let divText = div.innerHTML.replace( /\s+/g, ' ' ).trim();
35
+ divText = divText.replace( /&nbsp;/g, '').trim();
36
+
37
+ if( ! window.shortcodeElemKeyDown ) {
38
+ window.shortcodeElemKeyDown = divText;
39
+ }
40
+ });
41
+
42
+ ed.on( 'keyup', function(e) {
43
+ let div = e.target;
44
+ let divText = div.innerHTML.replace( /\s+/g, ' ' ).trim();
45
+ divText = divText.replace( /&nbsp;/g, '').trim();
46
+ if( divText !== window.shortcodeElemKeyDown ) {
47
+ e.target.onblur = function() {
48
+ let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();
49
+ wptbTableStateSaveManager.tableStateSet();
50
+
51
+ window.shortcodeElemKeyDown = '';
52
+ e.target.onblur = '';
53
+ }
54
+ } else {
55
  e.target.onblur = '';
56
  }
57
+ });
58
+ }
59
+ });
 
 
 
60
 
61
+ element.addEventListener( 'wptb-control:' + elementControlTargetUnicClass, function( event ) {
62
+ let targetElm = element.getElementsByClassName( 'mce-content-body' );
63
+ if( targetElm.length > 0 ) {
64
+ targetElm = targetElm[0];
65
+ targetElm.innerText = event.detail.value;
66
+ }
67
+ }, false );
68
+ }
inc/admin/element-classes/element-scripts/star-rating-element.js CHANGED
@@ -206,7 +206,12 @@ if( elementsSettingsTemplateJs.length > 0 ) {
206
  elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];
207
  elementsSettings = elementsSettingsTemplateJs.innerHTML;
208
  if( elementsSettings ) {
209
- elementsSettings = JSON.parse( elementsSettings );
 
 
 
 
 
210
  if( typeof elementsSettings === 'object' && ( 'tmpl-wptb-el-datas-' + infArr[1] ) in elementsSettings ) {
211
  elementSettings = elementsSettings['tmpl-wptb-el-datas-' + infArr[1]];
212
  }
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
  }
inc/admin/element-classes/elements/shortcode-element.php CHANGED
@@ -119,7 +119,9 @@ class Shortcode_Element extends Element_Base_Object {
119
  */
120
  protected function _content_template() {
121
  ?>
122
- <div>[Shortcode]</div>
 
 
123
  <?php
124
  }
125
  }
119
  */
120
  protected function _content_template() {
121
  ?>
122
+ <wptb_shortcode_container_element>
123
+ <div>[Shortcode]</div>
124
+ </wptb_shortcode_container_element>
125
  <?php
126
  }
127
  }
inc/admin/element-classes/elements/star-rating-element.php CHANGED
@@ -226,7 +226,7 @@ class Star_Rating_Element extends Element_Base_Object {
226
  $rating_star_zero_set = '<span class="wptb-rating-star-zero-set"></span>';
227
  }
228
 
229
- $rating_star .= '<span class="wptb-rating-star-left-signal-part">' . $ratingStarZeroSet . '</span>'
230
  . '<span class="wptb-filled-rating-star">' . $filled_rating_star_html . '</span>'
231
  . '<span class="wptb-not-filled-rating-star">' . $not_filled_rating_star_html . '</span>'
232
  . '<span class="wptb-half-filled-rating-star">' . $half_filled_rating_star_html . '</span>'
226
  $rating_star_zero_set = '<span class="wptb-rating-star-zero-set"></span>';
227
  }
228
 
229
+ $rating_star .= '<span class="wptb-rating-star-left-signal-part"></span>'
230
  . '<span class="wptb-filled-rating-star">' . $filled_rating_star_html . '</span>'
231
  . '<span class="wptb-not-filled-rating-star">' . $not_filled_rating_star_html . '</span>'
232
  . '<span class="wptb-half-filled-rating-star">' . $half_filled_rating_star_html . '</span>'
inc/admin/js/admin.js CHANGED
@@ -167,7 +167,6 @@ var WPTB_ActionsField = function WPTB_ActionsField() {
167
  }
168
  } else {
169
  _this.style.display = 'none';
170
- console.log(_this);
171
  }
172
 
173
  _this.actionsHide();
@@ -337,6 +336,12 @@ var WPTB_ActionsField = function WPTB_ActionsField() {
337
  if (!infArr) {
338
  element.classList.add('wptb-element-main-table_setting-' + table_id);
339
  }
 
 
 
 
 
 
340
  }
341
 
342
  WPTB_LeftPanel();
@@ -418,7 +423,6 @@ var WPTB_Cell = function WPTB_Cell(callback, DOMElement) {
418
  }
419
 
420
  DOMElement.classList.add('wptb-droppable', 'wptb-cell');
421
- console.log('wptb_cell_test');
422
  }
423
 
424
  DOMElement.draggable = false;
@@ -1267,7 +1271,6 @@ var WPTB_Helper = {
1267
 
1268
  if (containerStylesArrOne && Array.isArray(containerStylesArrOne)) {
1269
  for (var i = 0; i < containerStylesArrOne.length; i++) {
1270
- console.log(containerStylesArrOne);
1271
  if (containerStylesArrOne[i]) {
1272
  containerStylesSet(containerStylesArrOne[i], containerElement);
1273
  }
@@ -1298,6 +1301,7 @@ var WPTB_Helper = {
1298
  var elementsSettings = elementsSettingsTemplateJs.innerHTML;
1299
  var controlClassesNames = [];
1300
  if (elementsSettings) {
 
1301
  elementsSettings = JSON.parse(elementsSettings);
1302
  if (elementsSettings && (typeof elementsSettings === 'undefined' ? 'undefined' : _typeof(elementsSettings)) === 'object') {
1303
  if ('tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2] in elementsSettings) {
@@ -1416,6 +1420,7 @@ var WPTB_Helper = {
1416
 
1417
  var elementsSettings = elementsSettingsTemplateJs.innerHTML;
1418
  if (elementsSettings) {
 
1419
  elementsSettings = JSON.parse(elementsSettings);
1420
  if (elementsSettings && (typeof elementsSettings === 'undefined' ? 'undefined' : _typeof(elementsSettings)) === 'object' && 'tmpl-wptb-el-datas-' + dependOnControlElementKind in elementsSettings) {
1421
  var elementSettings = elementsSettings['tmpl-wptb-el-datas-' + dependOnControlElementKind];
@@ -1487,6 +1492,7 @@ var WPTB_Helper = {
1487
  elementsSettingsTemplatesJs = elementsSettingsTemplatesJs[0];
1488
  elementsSettings = elementsSettingsTemplatesJs.innerHTML;
1489
  if (elementsSettings) {
 
1490
  elementsSettings = JSON.parse(elementsSettings);
1491
 
1492
  if (elementsSettings && (typeof elementsSettings === 'undefined' ? 'undefined' : _typeof(elementsSettings)) === 'object') {
@@ -1549,8 +1555,10 @@ var WPTB_Helper = {
1549
  } else {
1550
  targetControlValue = 'unchecked';
1551
  }
1552
- } else {
1553
  targetControlValue = targetControls[i].value;
 
 
1554
  }
1555
  }
1556
  return targetControlValue;
@@ -1569,6 +1577,7 @@ var WPTB_Helper = {
1569
 
1570
  var elementsSettings = elementsSettingsTemplateJs.innerHTML;
1571
  if (elementsSettings) {
 
1572
  elementsSettings = JSON.parse(elementsSettings);
1573
 
1574
  if (elementsSettings && (typeof elementsSettings === 'undefined' ? 'undefined' : _typeof(elementsSettings)) === 'object') {
@@ -1604,6 +1613,7 @@ var WPTB_Helper = {
1604
  wptbElementDatas = wptbElementDatas[0];
1605
  var elementsSettings = wptbElementDatas.innerHTML;
1606
  if (elementsSettings) {
 
1607
  elementsSettings = JSON.parse(elementsSettings);
1608
  if (elementsSettings && (typeof elementsSettings === 'undefined' ? 'undefined' : _typeof(elementsSettings)) === 'object' && 'tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2] in elementsSettings) {
1609
  if (!nameControl) {
@@ -1716,8 +1726,6 @@ var WPTB_Helper = {
1716
  }
1717
  }
1718
 
1719
- //console.log( controlTemplate );
1720
-
1721
  var wptbElementOptionContainer = document.createElement('div');
1722
  wptbElementOptionContainer.classList.add(wptbelementOptionClass, 'wptb-settings-items');
1723
 
@@ -2043,8 +2051,10 @@ var WPTB_Helper = {
2043
  messagingArea = document.getElementById('wptb-messaging-area');
2044
 
2045
  if (data[0] == 'saved') {
2046
- console.log(window.wptbTableStateSaving);
2047
- window.history.pushState(null, null, document.location.href.replace('#', '') + '&table=' + data[1]);
 
 
2048
 
2049
  WPTB_Helper.saveTable(event, true);
2050
  return;
@@ -2299,8 +2309,43 @@ var WPTB_LeftPanel = function WPTB_LeftPanel() {
2299
  } else if (inputs.makeTableResponsive == 'unchecked') {
2300
  table.dataset.wptbAdaptiveTable = 0;
2301
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2302
  } else if (inputs.hasOwnProperty('tableManageCells')) {
2303
  table.toggleTableEditMode();
 
 
2304
  }
2305
  }
2306
  }
@@ -3481,6 +3526,29 @@ var array = [],
3481
  head.appendChild(cssForTdsWidthAuto);
3482
  }
3483
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3484
  };
3485
 
3486
  table.addRowHeight = function (value, cleaner) {
167
  }
168
  } else {
169
  _this.style.display = 'none';
 
170
  }
171
 
172
  _this.actionsHide();
336
  if (!infArr) {
337
  element.classList.add('wptb-element-main-table_setting-' + table_id);
338
  }
339
+
340
+ if (element.dataset.wptbTableContainerMaxWidth) {
341
+ wptbTableSetupEl.style.maxWidth = element.dataset.wptbTableContainerMaxWidth + 'px';
342
+
343
+ element.tdDefaultWidth();
344
+ }
345
  }
346
 
347
  WPTB_LeftPanel();
423
  }
424
 
425
  DOMElement.classList.add('wptb-droppable', 'wptb-cell');
 
426
  }
427
 
428
  DOMElement.draggable = false;
1271
 
1272
  if (containerStylesArrOne && Array.isArray(containerStylesArrOne)) {
1273
  for (var i = 0; i < containerStylesArrOne.length; i++) {
 
1274
  if (containerStylesArrOne[i]) {
1275
  containerStylesSet(containerStylesArrOne[i], containerElement);
1276
  }
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) {
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];
1492
  elementsSettingsTemplatesJs = elementsSettingsTemplatesJs[0];
1493
  elementsSettings = elementsSettingsTemplatesJs.innerHTML;
1494
  if (elementsSettings) {
1495
+ elementsSettings = elementsSettings.trim();
1496
  elementsSettings = JSON.parse(elementsSettings);
1497
 
1498
  if (elementsSettings && (typeof elementsSettings === 'undefined' ? 'undefined' : _typeof(elementsSettings)) === 'object') {
1555
  } else {
1556
  targetControlValue = 'unchecked';
1557
  }
1558
+ } else if (targetControls[i].type) {
1559
  targetControlValue = targetControls[i].value;
1560
+ } else if (targetControls[i].dataset.alignmentValue && targetControls[i].classList.contains('selected')) {
1561
+ targetControlValue = targetControls[i].dataset.alignmentValue;
1562
  }
1563
  }
1564
  return targetControlValue;
1577
 
1578
  var elementsSettings = elementsSettingsTemplateJs.innerHTML;
1579
  if (elementsSettings) {
1580
+ elementsSettings = elementsSettings.trim();
1581
  elementsSettings = JSON.parse(elementsSettings);
1582
 
1583
  if (elementsSettings && (typeof elementsSettings === 'undefined' ? 'undefined' : _typeof(elementsSettings)) === 'object') {
1613
  wptbElementDatas = wptbElementDatas[0];
1614
  var elementsSettings = wptbElementDatas.innerHTML;
1615
  if (elementsSettings) {
1616
+ elementsSettings = elementsSettings.trim();
1617
  elementsSettings = JSON.parse(elementsSettings);
1618
  if (elementsSettings && (typeof elementsSettings === 'undefined' ? 'undefined' : _typeof(elementsSettings)) === 'object' && 'tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2] in elementsSettings) {
1619
  if (!nameControl) {
1726
  }
1727
  }
1728
 
 
 
1729
  var wptbElementOptionContainer = document.createElement('div');
1730
  wptbElementOptionContainer.classList.add(wptbelementOptionClass, 'wptb-settings-items');
1731
 
2051
  messagingArea = document.getElementById('wptb-messaging-area');
2052
 
2053
  if (data[0] == 'saved') {
2054
+ var builderPageUrl = document.location.href.replace('#', '');
2055
+ var regex = new RegExp('&table=(.+)', "i");
2056
+ builderPageUrl = builderPageUrl.replace(regex, '');
2057
+ window.history.pushState(null, null, builderPageUrl + '&table=' + data[1]);
2058
 
2059
  WPTB_Helper.saveTable(event, true);
2060
  return;
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') {
2315
+ var table_id = WPTB_Helper.detectMode();
2316
+
2317
+ if (!table_id) {
2318
+ table_id = 'startedid-0';
2319
+ }
2320
+
2321
+ var tableContainerMaxWidthInput = document.getElementsByClassName('wptb-el-main-table_setting-' + table_id + '-tableContainerMaxWidth');
2322
+ var tableContainerMaxWidthInputValue = 850;
2323
+ if (tableContainerMaxWidthInput.length > 0) {
2324
+ tableContainerMaxWidthInput = tableContainerMaxWidthInput[0];
2325
+ if (tableContainerMaxWidthInput.value) tableContainerMaxWidthInputValue = tableContainerMaxWidthInput.value;
2326
+ }
2327
+
2328
+ table.dataset.wptbTableContainerMaxWidth = tableContainerMaxWidthInputValue;
2329
+ if (wptbTableSetup) wptbTableSetup.style.maxWidth = tableContainerMaxWidthInputValue + 'px';
2330
+ } else if (inputs.applyTableContainerMaxWidth == 'unchecked') {
2331
+ table.removeAttribute('data-wptb-table-container-max-width');
2332
+ if (wptbTableSetup) wptbTableSetup.style.maxWidth = null;
2333
+ }
2334
+
2335
+ table.tdDefaultWidth();
2336
+ } else if (inputs.hasOwnProperty('tableContainerMaxWidth')) {
2337
+ if (inputs.tableContainerMaxWidth) {
2338
+ table.dataset.wptbTableContainerMaxWidth = inputs.tableContainerMaxWidth;
2339
+
2340
+ var _wptbTableSetup = document.querySelector('.wptb-table-setup');
2341
+ if (_wptbTableSetup) _wptbTableSetup.style.maxWidth = inputs.tableContainerMaxWidth + 'px';
2342
+
2343
+ table.tdDefaultWidth();
2344
+ }
2345
  } else if (inputs.hasOwnProperty('tableManageCells')) {
2346
  table.toggleTableEditMode();
2347
+ } else if (inputs.hasOwnProperty('tableAlignmentCheckbox')) {
2348
+ table.tdDefaultWidth();
2349
  }
2350
  }
2351
  }
3526
  head.appendChild(cssForTdsWidthAuto);
3527
  }
3528
  }
3529
+
3530
+ if (table.dataset.wptbTableAlignment) {
3531
+ var wptbTableAlignment = table.dataset.wptbTableAlignment;
3532
+
3533
+ var _wptbTableSetupWidth = wptbTableSetup.offsetWidth;
3534
+ if (_wptbTableSetupWidth < table.offsetWidth) {
3535
+ table.style.float = null;
3536
+ } else {
3537
+ if (wptbTableAlignment == 'center') {
3538
+ table.style.float = null;
3539
+ } else {
3540
+ table.style.float = wptbTableAlignment;
3541
+ }
3542
+ }
3543
+
3544
+ if (wptbTableAlignment == 'center') {
3545
+ wptbTableSetup.style.float = null;
3546
+ } else {
3547
+ wptbTableSetup.style.float = wptbTableAlignment;
3548
+ }
3549
+ } else {
3550
+ table.style.float = null;
3551
+ }
3552
  };
3553
 
3554
  table.addRowHeight = function (value, cleaner) {
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","console","log","actionsHide","ondragend","elementDragEndClear","coordinatesElement","getBoundingClientRect","wptbContainer","correctTop","top","parseFloat","removeEventListener","left","right","clientWidth","addEventListener","leaveFromField","node","relatedTarget","onmouseleave","opacity","WPTB_Builder","table_id","detectMode","http","XMLHttpRequest","urlSet","ajaxurl","open","setRequestHeader","onreadystatechange","d","readyState","status","ans","responseText","getElementById","value","wptbTableSetupEl","WPTB_Parser","elementsSettingTemplateJs","setAttribute","innerHTML","WPTB_Table","element","querySelector","WPTB_LeftPanel","WPTB_Settings","elementOptionsSet","send","counter","ElementCounters","select","MultipleSelect","initializer","WPTB_Initializer","settings","WPTB_Cell","callback","DOMElement","highlightRow","td","parentRow","columnCount","parseInt","tds","i","classToAdd","ttd","highlightColumn","index","rowCount","tr","padding","jQuery","val","innerBorderWidth","border","ondblclick","stopPropagation","currentTarget","newElementProxy","wptbPhElement","wptbElementTypeClass","wptbTypeElementArr","split","wptbInternalActiveElement","j","wptbInternalActiveElementObj","setCoords","y","x","dataset","yIndex","xIndex","getCoords","coords","appendElement","getCellDimensions","tdStyleObj","window","getComputedStyle","tdPaddingLeft","getPropertyValue","tdPaddingRight","tdBorderLeftWidth","tdBorderRightWidth","tdPaddingTop","tdPaddingBottom","tdBorderTopWidth","tdBorderBottomWidth","width","offsetWidth","height","offsetHeight","tableFullStyleObj","tableBorderLeft","tableBorderRight","tableBorderTop","tableBorderBottom","nodeName","toLowerCase","firstChild","lastChild","WPTB_DropHandle","thisElem","e","wptbDropHandle","wptbDropBorderMarker","wptbDropBorderMarkerTop","wptbDropBorderMarkerRight","wptbDropBorderMarkerBottom","wptbDropBorderMarkerLeft","ondragenter","ondragover","preventDefault","ondragleave","ondrop","getData","wptbMovingMode","text","getDOMParentElement","innerElement","innerElementNext","elemKind","undefined","onscroll","localName","indics","types","notDragEnter","indexOf","elementDrag","offsetY","layerY","bottom","priv","increment","key","nextIndex","kindIndexProt","wpTemplateId","itemHtml","replace","trim","wptbElementMutch","elementClearFromTinyMce","inElems","querySelectorAll","inElemObj","WPTB_ElementOptions","hexToRgb","hex","result","exec","rgbToHex","rgb","toString","slice","isHex","regex","RegExp","test","icon_directory","hostName","location","protocol","hostname","img","src","wptbDropHandles","wptbDropBorderMarkers","linkHttpCheckChange","link","linkArr","linkClean","rows","rowHead","computedStyleRowHead","rowHeadChildren","children","contentsForHeader","tdElements","p","textContent","textAlign","fontSize","color","backgroundColor","thisRowChildren","wptbTitleColumn","wptbTitleColumnFontSize","wptbTitleColumnColor","wptbTitleBackgroundColor","wptbTitleAlign","cls","parentElement","row","parent","getSelectionText","txt","getSelection","selection","createRange","elementOptionsPanelClear","elementOptionsGroup","wpColorPickerCheckChangeForTableStateSaving","originalEvent","wpPickerContainer","irisStripMouseUpStateSaveManager","wpColorPickerClear","attribute","isId","input","newInput","url","href","results","decodeURIComponent","getColumnWidth","cell","xIndexes","cellWidth","getRowHeight","yIndexes","cellHeight","wpColorPickerChange","ui","uiColor","classe","ps","number","affectedEl","ratingStar","span","fill","wptbTextMessageSize","numberImputSize","wptbNumberInputs","maxCount","maxValue","onkeydown","thisValue","String","substring","onkeyup","ucfirst","str","charAt","toUpperCase","eventName","details","CustomEvent","detail","bubbles","dispatchEvent","elementStartScript","WPTB_ElementsScriptsLauncher","deleteEventHandlers","off","elementChildren","replaceAll","string","search","join","mceContentBodys","k","dataMceStyle","removeAttribute","mceEditFocus","contentEditable","spellCheck","mceIds","elementOptionContainerCustomClassSet","targetInput","customClassForContainer","containerElement","elementOptionContainerAdditionalStyles","containerAdditionalStyles","containerStylesArrOne","containerStylesSet","containerStyleStr","containerStyleStrArr","controlsInclude","functionHandler","elementKind","сontrolsConnectIndic","elementsSettingsTemplateJs","elementsSettings","controlClassesNames","elementSettings","Object","keys","forEach","regularText","keyInfArr","controlClass","push","controls","controlName","control","targetControlValue","targetControlValueGet","oneControlInclude","wptbContrlStacksConfigId","tmplControlsConfig","container","jsonControlsConfigJson","jsonControlsConfig","controlClassName","innerElementCopyIncludeHandler","appearDependOnControl","dependOn","targetControlElementClass","dependOnControlName","dependOnControlElementClass","dependOnControlElement","targetControlElement","controlContainerElem","showHideDependOnControlElement","dependOnControlElementKind","elementSettingValue","controlsStateManager","targetControlClass","controlChangeIndic","targetControls","selectorElement","elementsSettingsTemplatesJs","stringify","name","checked","elementProt","copyElem","infArrProt","infArrCopy","elemProtKind","elemCopyKind","elementSettingsProt","elementSettingsCopy","elementSettingKeyCopy","nameControl","wptbElementDatas","elementContainerClass","elementOptionClassIndic","elementOptionsGroupId","wptbelementOptionClass","wptbelementOptionsContainer","childNodes","elementOptionsGroupChildren","controlScriptsArr","controlappearDependOnControl","controlKey","tmplControlTemplate","elemContainer","elementControlTargetUnicClass","controlTemplate","wptbElementOptionContainer","helperJavascriptElem","helperJavascriptCode","innerText","script","managerExternalCssStyles","elementContainer","selector","cssName","cssValue","head","cssForThisElement","cssText","cssTextArrFirst","pop","selectorExists","cssTextArrSecond","cssTextArrThird","cssNameExists","cssTextArrFourth","splice","copyElement","activeElemClass","cssForActiveElement","cssForNewElement","infArrCopyEl","cssForActiveElementInnerHTML","cssForNewElementInnerHTML","elementsStylesConvertToObject","stylesElements","stylesObj","styleElemId","getAttribute","elementsStylesSetFromObject","jsonObject","styleCss","saveTable","startSaving","previewSaving","wptbTableStateNumberSave","wptbTableStateNumberShow","bar","toggleTableEditMode","wptb_admin_object","t","messagingArea","code","datas","postId","rs","wptbId","paramIdsNecessaryChange","codeClone","columns","WPTB_Stringifier","outerHTML","datas_containers","styleObjJson","messagingAreaText","setTimeout","params","title","content","elements_datas","elements_styles","security_code","preview_saving","id","action","wptbTableStateSaving","history","pushState","wptbPreviewTable","wptbPreviewBtn","wptbPreviewBtnHref","previewHref","wptbSaveBtn","clickOnFreeSpace","wpcdFixedToolbar","hasAttribute","elementAjax","dataAjaxData","element_name","element_ajax_data","MIN_COLUMNS","MIN_ROWS","MAX_COLUMNS","MAX_ROWS","tableGenerator","columnsDecrementButton","columnsIncrementButton","rowsDecrementButton","rowsIncrementButton","columnsInput","rowsInput","wptbElementButtons","wptbTableColumnWidthNumber","wptbTableRowHeightNumber","oninput","addColumnWidth","onchange","highlighted","addRowHeight","controlsChange","inputs","tableTopRowsAsHeader","makeTableResponsive","wptbAdaptiveTable","wptbElement","addRowToTheEnd","addRowToTheStart","addRowBefore","addRowAfter","addColumnEnd","addColumnStart","addColumnBefore","addColumnAfter","deleteColumn","deleteRow","mergeCells","splitCell","wptbBuilderPanel","wptbHeader","selectedCells","multipleCellMode","activateMultipleSelectMode","deactivateMultipleSelectMode","isActivated","pushSelectedCell","flushSelectedCells","getFirst","minXIndex","minYIndex","first","getLast","maxXIndex","maxYIndex","last","removeAllButFirst","div","columnTitleMobile","prototype","hasDontEnumBug","propertyIsEnumerable","dontEnums","dontEnumsLength","obj","TypeError","prop","call","elems","wptbUndo","tableStateGet","wptbUndoredo","wptbUndoRedoContainer","wptbRedo","shortcodePopupWindow","onbeforeunload","wptbSaveDisabled","previewId","Math","floor","random","newHref","URL","searchParams","set","codeMain","tableColumns","minWidth","maxWidth","innerElements","wptbActionsLength","dataMceBogus","columnNameDivContainer","columnNameDiv","array","wptbTableSetup","maxAmountOfCells","maxAmountOfRows","mark","rowSpan","cs","colSpan","markedCells","noCells","singleCells","multipleCells","cellSettings","position","column","cellHighlighted","wptbTableColumnWidthSlider","tableColumnWidthAutoFixedCheckbox","wptbFixedWidth","wptbTableRowHeightSlider","tableRowHeightAutoFixedCheckbox","wptbFixedHeight","isSquare","realTimeArray","carried","cols","matriz","items","justAssigned","amount","carriedRowspans","cellsBuffer","cellPointer","xPosition","stepsToMove","celda","drawTable","a","undoSelect","fillTableArray","colspansSums","cells","colspanSumInRow","max","apply","getActualPointsInRow","points","skipInCols","reconstraction","insertRow","borderWidth","wptb_preview_table","cellModeBackground","leftScrollPanelCurtain","leftScrollPanelCellSettings","wptbPreviewTableTds","recalculateIndexes","start","trs","maxCols","maxColsFull","tdsArr","jMainIter","z","cleaner","dataXIndex","tableTdsFor","colspan","tableRows","widthIsSet","arrayTdsFromPreviousRow","tdDefaultWidth","tableTdsSumMaxWidth","tableTdsSumMaxWidthFixed","tableTdsSumMaxWidthAuto","wptbTableSetupWidth","arrayCellsWidthFixedHelper","arrayCellsWidthAutoHelper","tdPaddingCommon","tableTdBorderCommonWidth","cssForTdsWidthAuto","borderLeftWidth","borderRightWidth","tableBorderCommon","wptbCssTdAutoWidth","tableTdBorderLeftWidth","tableTdBorderRightWidth","CellsWidthAutoCount","wptbTableTdsSumMaxWidth","wptbCellsWidthAutoCount","mergingСellsHorizontally","wptbFixedWidthSize","styleElementCreate","tableTdWidthAuto","tableTdsWidthAutoCommon","cssForTdsWidthAutoOld","dataYIndex","rowspan","heightIsSet","arrayTdsPrevious","tableColumnHeightAutoFixedCheckbox","mergingCellsVertically","forBreak","currentTable","currentTableTd","currentTdStyle","firstCell","c_pos","cellStyle","pos","pendingInsertion","bro","currentCell","l","r","aux","from","cellNew","rowChildren","rowChildrenLength","cellRowSpan","rowAfter","cellsColSpan","tableRowsIChildren","tableRIChildrenLength","rowIRowSpan","rNext","rNextChildren","rNextChildrenLength","rowStart","columnStart","rowEnd","columnEnd","itemsEstimate","dimensions","tdsChildrenNew","tdsInternalElements","tdsIntElemLength","firstWidth","firstDataFixedWidth","firstHeight","firstDataFixedHeight","cellStyles","cellXIndex","rowChildInsertBefore","rowNext","Number","findRowspannedCells","difference","actualPoints","addLackingCells","sumRows","totalColspan","nextRow","nextRowChildren","nextRowChildrenLength","tdArr","nextRowChildrenK","jRowChildren","onresize","generate","wptbNewPreviewTable","wptbHighlighted","wptbDirectlyhovered","cssForTdsWidthAutoValue","datawptbUndoredo","wptbLeftScrollPanelCellSetting","tableStateClear","classId","onmouseover","wptbElements","elementIndexesArr","elementIndexMax","wptbNodeattributes","attributes","attr","newDataAttributeName","newDataAttributeValue","nodeValue","kindIndexProtArr","node_wptb_element_kind_num","onmouseenter"],"mappings":";;AAAA,IAAIA,oBAAoB,SAApBA,iBAAoB,GAAW;AAAA;;AAC/B;AACA,SAAKC,WAAL;AACA,QAAIC,SAASC,sBAAT,CAAiC,cAAjC,EAAkDC,MAAlD,IAA4D,CAAhE,EAAoE;AAChE,aAAKH,WAAL,GAAmBC,SAASC,sBAAT,CAAiC,cAAjC,EAAkD,CAAlD,CAAnB;AACH;;AAED,SAAKE,cAAL,GAAsB,UAAEC,UAAF,EAAcC,QAAd,EAA4B;AAC9C,YAAIC,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,aAAT,CAAwB,KAAxB,CAFV;;AAIAT,o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G,QAAQ7F,IAA1B,GAAiC,GAAjC,GAAuCuH,KAA3D;AACH;AACJ,SALD,MAKO;AACH,gBAAI,CAAErD,KAAK1F,SAAL,CAAe6B,QAAf,CAAyB,kBAAkBwF,QAAQ7F,IAA1B,GAAiC,GAAjC,GAAuCuH,KAAhE,CAAN,EAAgF;AAC5ErD,qBAAK1F,SAAL,CAAeO,GAAf,CAAoB,kBAAkB8G,QAAQ7F,IAA1B,GAAiC,GAAjC,GAAuCuH,KAA3D;AACH;AACJ;AACD,YAAIoG,mBAAJ,CAAyB9H,OAAzB,EAAkC0B,KAAlC,EAAyC0F,aAAzC;AACArN,oBAAYyU,kBAAZ,CAAgCxO,QAAQzE,aAAR,EAAhC;AACAvD,iBAASsI,OAAT,CAAiB2G,SAAjB,CAA2BjH,QAAQ7F,IAAnC;AACH;;AAEDkE,SAAK4sB,YAAL,GAAoB,UAAW3xB,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,EAAoCkG,IAApC;;AAEA3D,yBAAiBsB,aAAjB,CAAgCqC,IAAhC;;AAEAA,aAAK1F,SAAL,CAAeC,MAAf,CAAuB,kBAAvB;AACH,KAZD;;AAcAyF,SAAKE,YAAL,GAAoB,UAAWjF,KAAX,EAAmB;AACnC,YAAIoB,mBAAmB,IAAI5C,iBAAJ,EAAvB;;AAEA4C,yBAAiB0D,cAAjB,CAAiC9E,KAAjC,EAAwC+E,IAAxC;AACH,KAJD;AAKH,CApFD","file":"admin.js","sourcesContent":["var WPTB_ActionsField = function() {\n //this.wptbBorderMarker;\n this.wptbActions;\n if( document.getElementsByClassName( 'wptb-actions' ).length != 0 ) {\n this.wptbActions = document.getElementsByClassName( 'wptb-actions' )[0];\n }\n \n this.addActionField = ( actionType, thisNode ) => {\n let body = document.getElementsByTagName( 'body' )[0];\n \n let actions = document.getElementsByClassName( 'wptb-actions' );\n if( actions.length != 0 ) {\n let previousNode = actions[0].activeElem;\n if( previousNode ) {\n previousNode.classList.remove( 'wptb-directlyhovered' );\n }\n \n while( actions.length != 0 ) {\n actions[0].parentNode.removeChild( actions[0] );\n }\n }\n \n if( actionType == 1 ) {\n \n let btnDelete, btnCopy;\n\n btnDelete = document.createElement( 'span' ),\n btnCopy = document.createElement( 'span' ),\n actions = document.createElement( 'div' );\n\n actions.classList.add( 'wptb-actions' );\n btnDelete.classList.add( 'dashicons', 'dashicons-trash', 'wptb-delete-action' );\n btnCopy.classList.add( 'dashicons', 'dashicons-admin-page', 'wptb-duplicate-action' );\n \n actions.appendChild( btnCopy );\n actions.appendChild( btnDelete );\n \n body.appendChild( actions );\n\n actions.activeElem = thisNode;\n\n actions.type = 1;\n\n btnDelete.onclick = function( event ) {\n let act = event.target.parentNode.activeElem,\n el = act.parentNode;\n let infArr = act.className.match( /wptb-element-(.+)-(\\d+)/i );\n if( act && infArr && Array.isArray( infArr ) ) {\n WPTB_Helper.elementControlsStateDelete( act );\n WPTB_Helper.externalCssStylesDelete( infArr[0] );\n }\n \n if( act ) {\n el.removeChild( act );\n }\n\n if( act && typeof act === 'object' && act.hasOwnProperty( 'kind' ) && act.kind == 'text' ) {\n let thisRow = el.parentNode;\n \n if( WPTB_Helper.rowIsTop( thisRow ) ) {\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\n\n if( table.classList.contains( 'wptb-table-preview-head' ) ) {\n WPTB_Helper.dataTitleColumnSet( table );\n }\n }\n }\n\n let wptbActionsField = new WPTB_ActionsField();\n wptbActionsField.actionsRemove();\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n btnCopy.onclick = ( event ) => {\n let copy,\n infArr,\n type;\n let activeElement = event.target.parentNode.activeElem;\n let activeElemParent = activeElement.parentNode;\n infArr = activeElement.className.match( /wptb-element-(.+)-(\\d+)/i );\n if( infArr && Array.isArray( infArr ) ) {\n type = infArr[1];\n let data = {};\n data.kind = type;\n data.elemProt = activeElement;\n data.tinyMceClear = true;\n copy = new WPTB_ElementObject( data );\n WPTB_Helper.elementControlsStateCopy( activeElement, copy.getDOMElement() );\n WPTB_Helper.externalCssStylesCopy( activeElement, copy.getDOMElement() );\n //WPTB_Helper.elementStartScript( copy.getDOMElement() );\n \n activeElemParent.insertBefore( copy.getDOMElement(), activeElement.nextSibling );\n } else {\n copy = {};\n let elementCopy = activeElement.cloneNode( true );\n elementCopy.classList.remove( 'wptb-directlyhovered' );\n \n copy.getDOMElement = function() {\n return elementCopy;\n }\n \n applyGenericItemSettings( copy );\n \n activeElemParent.insertBefore( copy.getDOMElement(), activeElement.nextSibling );\n \n WPTB_Helper.wptbDocumentEventGenerate( 'wptb-inner-element:copy', activeElement, copy.getDOMElement() );\n }\n \n WPTB_innerElementSet( copy.getDOMElement() );\n\n let wptbActionsField = new WPTB_ActionsField( 1, activeElement );\n wptbActionsField.setParameters( activeElement );\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n \n \n if( thisNode.classList.contains( 'wptb-ph-element' ) ) {\n let btnMove;\n btnMove = document.createElement( 'span' );\n btnMove.classList.add( \"dashicons\", \"dashicons-move\", 'wptb-move-action' );\n btnMove.draggable = true;\n actions.appendChild( btnMove );\n \n btnMove.ondragstart = ( event ) => {\n let wptbElementIconsDirectories = 'wptb-element-icons-directories';\n let tmplIconsDirectories = wp.template( wptbElementIconsDirectories );\n let data = {};\n let jsonIconsDirectories = tmplIconsDirectories( data );\n let IconsDirectories = JSON.parse( jsonIconsDirectories );\n\n let dragImages,\n actions = event.target.parentNode,\n activeElem = actions.activeElem,\n infArr,\n type;\n infArr = activeElem.className.match( /wptb-element-(.+)-(\\d+)/i );\n if( infArr && Array.isArray( infArr ) ) {\n type = infArr[1];\n activeElem.classList.add( 'wptb-moving-mode' );\n\n if( IconsDirectories && typeof IconsDirectories === 'object' && IconsDirectories[type] ) {\n dragImages = WPTB_Helper.getElementIcon( IconsDirectories[type] );\n }\n\n event.dataTransfer.effectAllowed = 'move';\n event.dataTransfer.setDragImage( dragImages, 0, 0 );\n event.dataTransfer.setData( 'node', 'wptb-element-' + infArr[1] + '-' + infArr[2] );\n event.dataTransfer.setData( 'wptb-moving-mode', 'wptb-element-' + infArr[1] + '-' + infArr[2] );\n event.dataTransfer.setData( 'wptbElIndic-' + infArr[1], 'wptbElIndic-' + infArr[1] );\n let act = event.target.parentNode.activeElem;\n if( act.kind == 'text' ) {\n let thisRow = act.parentNode.parentNode;\n \n if( WPTB_Helper.rowIsTop( thisRow ) ) {\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\n\n if( table.classList.contains( 'wptb-table-preview-head' ) ) {\n WPTB_Helper.dataTitleColumnSet( table );\n }\n }\n }\n } else {\n this.style.display = 'none';\n console.log(this);\n }\n\n this.actionsHide();\n };\n\n btnMove.ondragend = ( event ) => {\n WPTB_Helper.elementDragEndClear();\n }\n }\n\n actions.style.display = 'block';\n\n this.wptbActions = actions;\n } \n }\n \n this.setParameters = ( thisNode ) => {\n \n if( ! this.wptbActions ) {\n let actions = document.getElementsByClassName( 'wptb-actions' );\n if( actions.length > 0 ) {\n this.wptbActions = actions[0];\n } else {\n this.wptbActions = false;\n }\n }\n \n if( this.wptbActions && this.wptbActions.classList.contains( 'wptb-actions' ) ) {\n this.wptbActions.style.display = 'block';\n } else {\n return;\n }\n \n let coordinatesElement = thisNode.getBoundingClientRect();\n \n let wptbContainer = document.getElementsByClassName( 'wptb-container' )[0];\n let correctTop = () => {\n let coordinatesElement = thisNode.getBoundingClientRect();\n this.wptbActions.style.top = parseFloat( coordinatesElement.top ) - 15 + 'px';\n }\n wptbContainer.removeEventListener( 'scroll', correctTop, false );\n \n this.wptbActions.style.top = parseFloat( coordinatesElement.top ) - 15 + 'px';\n this.wptbActions.style.left = ( parseFloat( coordinatesElement.right ) - parseFloat( this.wptbActions.clientWidth ) ) + 1 + 'px';\n \n this.wptbActions.style.display = 'block';\n thisNode.classList.add( 'wptb-directlyhovered' );\n \n wptbContainer.addEventListener( 'scroll', correctTop, false );\n }\n \n this.leaveFromField = ( event, node, actionType ) => {\n if( ! this.wptbActions ) {\n let actions = document.getElementsByClassName( 'wptb-actions' );\n if( actions.length > 0 ) {\n this.wptbActions = actions[0];\n } else {\n this.wptbActions = false;\n }\n }\n \n if( ! this.wptbActions ) {\n return;\n }\n \n if( event.relatedTarget ) {\n if ( event.relatedTarget.classList.contains( 'wptb-actions' ) ||\n event.relatedTarget.classList.contains( 'wptb-move-action' ) ||\n event.relatedTarget.classList.contains( 'wptb-duplicate-action' ) ||\n event.relatedTarget.classList.contains( 'wptb-delete-action' ) ) {\n if( ! this.wptbActions ) {\n this.wptbActions = document.getElementsByClassName( 'wptb-actions' )[0];\n }\n this.wptbActions.onmouseleave = ( event ) => {\n if( event.relatedTarget != null && ( event.relatedTarget.classList.contains( 'wptb-ph-element' ) || \n WPTB_Helper.findAncestor( event.relatedTarget, 'wptb-ph-element') ) && event.relatedTarget != this.wptbActions.activeElem &&\n WPTB_Helper.findAncestor( event.relatedTarget, 'wptb-directlyhovered' ) != this.wptbActions.activeElem ) {\n \n// this.wptbActions.style.display = 'none';\n// event.relatedTarget.parentNode.parentNode.classList.remove( 'wptb-directlyhovered' );\n//\n// let wptbActionsField = new WPTB_ActionsField();\n//\n// wptbActionsField.addActionField( 1, event.relatedTarget.parentNode.parentNode );\n//\n// wptbActionsField.setParameters( event.relatedTarget.parentNode.parentNode );\n } else {\n \n }\n \n let wptbActionsField = new WPTB_ActionsField();\n\n wptbActionsField.leaveFromField( event, event.relatedTarget.parentNode.parentNode );\n \n event.target.activeElem.classList.remove( 'wptb-directlyhovered' );\n }\n\n return;\n } \n }\n \n node.classList.remove( 'wptb-directlyhovered' );\n this.wptbActions.style.display = 'none';\n \n if( event.relatedTarget ) {\n if( event.relatedTarget.classList.contains( 'wptb-ph-element' ) || WPTB_Helper.findAncestor( event.relatedTarget, 'wptb-ph-element' ) ) {\n this.addActionField( 1, event.relatedTarget.parentNode );\n\n this.setParameters( event.relatedTarget.parentNode );\n }\n }\n }\n \n this.actionsRemove = () => {\n if( ! this.wptbActions ) {\n let actions = document.getElementsByClassName( 'wptb-actions' );\n if( actions.length > 0 ) {\n this.wptbActions = actions[0];\n }\n }\n \n if( this.wptbActions ) {\n this.wptbActions.parentNode.removeChild( this.wptbActions );\n }\n }\n \n this.actionsHide = () => {\n if( ! this.wptbActions ) {\n let actions = document.getElementsByClassName( 'wptb-actions' );\n if( actions.length > 0 ) {\n this.wptbActions = actions[0];\n }\n }\n \n if( this.wptbActions ) {\n this.wptbActions.style.opacity = 0;\n }\n }\n}","(function () {\n var WPTB_Builder = function () {\n var table_id = WPTB_Helper.detectMode();\n if ( table_id ) {\n var http = new XMLHttpRequest(),\n urlSet = ajaxurl + \"?action=get_table\" + '&id=' + table_id;\n http.open('GET', urlSet, true);\n http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');\n http.onreadystatechange = function (d) {\n if (this.readyState == 4 && this.status == 200) {\n var ans = JSON.parse(http.responseText);\n document.getElementById('wptb-setup-name').value = ans[0];\n \n if( ans[1] ) {\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'none';\n let wptbTableSetupEl = document.getElementsByClassName('wptb-table-setup')[0];\n wptbTableSetupEl.appendChild( WPTB_Parser( ans[1] ) );\n \n let body = document.getElementsByTagName('body')[0];\n \n if( ans[2] ) {\n let elementsSettingTemplateJs = document.createElement( 'script' );\n elementsSettingTemplateJs.setAttribute( 'type', 'text/html' );\n elementsSettingTemplateJs.setAttribute( 'class', 'wptb-element-datas' );\n\n elementsSettingTemplateJs.innerHTML = ans[2];\n\n body.appendChild( elementsSettingTemplateJs );\n }\n \n WPTB_Table();\n let element = document.querySelector( '.wptb-preview-table' );\n if( element ) {\n let infArr = element.className.match( /wptb-element-((.+-)\\d+)/i );\n if( ! infArr ) {\n element.classList.add( 'wptb-element-main-table_setting-' + table_id );\n }\n }\n \n WPTB_LeftPanel();\n WPTB_Settings();\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n \n WPTB_Helper.elementOptionsSet( 'table_setting', element );\n } else {\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\n }\n \n return;\n }\n };\n http.send(null);\n } else {\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\n }\n document.counter = new ElementCounters();\n document.select = new MultipleSelect();\n\n var initializer = WPTB_Initializer();\n settings = WPTB_Settings();\n };\n\n document.addEventListener('DOMContentLoaded', WPTB_Builder);\n})();","var WPTB_Cell = function ( callback, DOMElement ) {\n\n function highlightRow(td) {\n var parentRow = td.parentNode,\n columnCount = parseInt(document.getElementById('wptb-columns-number').value),\n tds = document.getElementsByClassName('wptb-preview-table')[0].getElementsByTagName('td');\n for (var i = 0; i < tds.length; i++) {\n tds[i].classList.remove('wptb-highlighted-row-first', 'wptb-highlighted-row-last', 'wptb-highlighted-row-inner', 'wptb-highlighted-column-first', 'wptb-highlighted-column-last', 'wptb-highlighted-column-inner');\n }\n for (var i = 0; i < columnCount; i++) {\n\n var classToAdd = i == 0 ? 'wptb-highlighted-row-first' : i == columnCount - 1 ? 'wptb-highlighted-row-last' : 'wptb-highlighted-row-inner';\n var ttd = parentRow.getElementsByTagName('td')[i];\n if (ttd !== td) {\n ttd.classList.add(classToAdd);\n }\n }\n }\n\n function highlightColumn(td) {\n\n var index,\n parentRow = td.parentNode;\n columnCount = parseInt(document.getElementById('wptb-columns-number').value), rowCount = parseInt(document.getElementById('wptb-rows-number').value), table = document.getElementsByClassName('wptb-preview-table')[0];\n for (var i = 0; i < columnCount; i++) {\n if (parentRow.getElementsByTagName('td')[i] === td) {\n index = i;\n break;\n }\n }\n\n for (var i = 0; i < rowCount; i++) {\n var classToAdd = i == 0 ? 'wptb-highlighted-column-first' : i == rowCount - 1 ? 'wptb-highlighted-column-last' : 'wptb-highlighted-column-inner';\n var tr = table.getElementsByTagName('tr')[i];\n if (tr.getElementsByTagName('td')[index] !== td) {\n tr.getElementsByTagName('td')[index].classList.add(classToAdd);\n }\n }\n }\n \n if( ! DOMElement ) {\n DOMElement = document.createElement(\"td\");\n\n DOMElement.style.padding = jQuery('#wptb-table-padding-number').val() + 'px';\n\n var innerBorderWidth = jQuery('#wptb-table-inner-border-number').val();\n\n if (innerBorderWidth != '' && parseInt(innerBorderWidth) != 0) {\n DOMElement.style.border = innerBorderWidth + 'px solid ' + jQuery('#wptb-table-border-color').val();\n } \n\n DOMElement.classList.add('wptb-droppable', 'wptb-cell');\n console.log( 'wptb_cell_test' );\n }\n\n DOMElement.draggable = false;\n if ( callback ) {\n DOMElement.onclick = callback;\n }\n \n // Cell double click handler\n DOMElement.ondblclick = function( event ) {\n event.stopPropagation();\n if( ! WPTB_Helper.findAncestor( DOMElement, 'wptb-preview-table-manage-cells' ) && event.target == event.currentTarget ) {\n \n WPTB_Helper.wptbDocumentEventGenerate( 'table:cell:dblclick', event.target );\n \n let element = WPTB_Helper.newElementProxy( 'text' );\n element = element.getDOMElement();\n \n DOMElement.appendChild( element );\n \n WPTB_innerElementSet( element );\n }\n }\n \n WPTB_innerElementSet( DOMElement );\n \n let wptbPhElement = DOMElement.getElementsByClassName( 'wptb-ph-element' );\n \n if ( wptbPhElement.length > 0 ) {\n for( let i = 0; i < wptbPhElement.length; i++ ) {\n wptbPhElement[i].getDOMElement = function() {\n return wptbPhElement[i];\n }\n \n WPTB_innerElementSet( wptbPhElement[i] );\n \n let wptbElementTypeClass = wptbPhElement[i].className.match( /wptb-element-((.+-)\\d+)/i );\n if( wptbElementTypeClass && Array.isArray( wptbElementTypeClass ) ) {\n let wptbTypeElementArr = wptbElementTypeClass[1].split( '-' );\n wptbPhElement[i].kind = wptbTypeElementArr[0];\n applyGenericItemSettings( wptbPhElement[i], wptbElementTypeClass[1] );\n let wptbInternalActiveElement = wptbPhElement[i].getElementsByClassName( 'wptb-in-element' );\n if ( wptbInternalActiveElement.length > 0 ) {\n for ( let j = 0; j < wptbInternalActiveElement.length; j++ ) {\n let wptbInternalActiveElementObj = {};\n wptbInternalActiveElementObj.getDOMElement = function() {\n return wptbInternalActiveElement[j];\n }\n \n applyGenericItemSettings( wptbInternalActiveElementObj );\n }\n }\n }\n }\n }\n\n this.getDOMElement = function () {\n return DOMElement;\n };\n\n this.setCoords = function (y, x) {\n var el = this.getDOMElement();\n el.dataset.yIndex = y;\n el.dataset.xIndex = x;\n };\n\n this.getCoords = function () {\n var coords,\n el = this.getDOMElement();\n coords.x = el.dataset.xIndex;\n coords.y = el.dataset.yIndex;\n return coords;\n };\n\n this.appendElement = function (node) {\n getDOMElement().appendChild(node);\n };\n \n DOMElement.getCellDimensions = function() {\n \n let tdStyleObj = window.getComputedStyle( this, null );\n \n let tdPaddingLeft = tdStyleObj.getPropertyValue( 'padding-left' );\n let tdPaddingRight = tdStyleObj.getPropertyValue( 'padding-right' );\n \n let tdBorderLeftWidth = tdStyleObj.getPropertyValue( 'border-left-width' );\n let tdBorderRightWidth = tdStyleObj.getPropertyValue( 'border-right-width' );\n \n let tdPaddingTop = tdStyleObj.getPropertyValue( 'padding-top' );\n let tdPaddingBottom = tdStyleObj.getPropertyValue( 'padding-bottom' );\n \n let tdBorderTopWidth = tdStyleObj.getPropertyValue( 'border-top-width' );\n let tdBorderBottomWidth = tdStyleObj.getPropertyValue( 'border-bottom-width' );\n \n let width = parseInt( this.offsetWidth, 10 ) - \n parseInt( tdPaddingLeft, 10 ) - \n parseInt( tdPaddingRight, 10 ) -\n ( parseInt( tdBorderLeftWidth, 10 ) / 2 ) -\n ( parseInt( tdBorderRightWidth, 10 ) / 2 );\n \n let height = parseInt( this.offsetHeight, 10 ) - \n parseInt( tdPaddingTop, 10 ) - \n parseInt( tdPaddingBottom, 10 ) -\n ( parseInt( tdBorderTopWidth, 10 ) / 2 ) -\n ( parseInt( tdBorderBottomWidth, 10 ) / 2 ); \n \n \n let table = WPTB_Helper.findAncestor( this, 'wptb-preview-table' );\n if( table ) {\n let tableFullStyleObj = window.getComputedStyle( table, null );\n let tableBorderLeft = tableFullStyleObj.getPropertyValue( 'border-left-width' );\n let tableBorderRight = tableFullStyleObj.getPropertyValue( 'border-right-width' );\n let tableBorderTop = tableFullStyleObj.getPropertyValue( 'border-top-width' );\n let tableBorderBottom = tableFullStyleObj.getPropertyValue( 'border-bottom-width' );\n \n let tr = this.parentNode;\n if( tr && tr.nodeName.toLowerCase() === 'tr' ) {\n if( tr.firstChild && tr.firstChild.dataset.xIndex === this.dataset.xIndex ) {\n if( parseInt( tableBorderLeft, 10 ) > parseInt( tdBorderLeftWidth, 10 ) ) {\n width += -( parseInt( tableBorderLeft, 10 ) - parseInt( tdBorderLeftWidth, 10 ) ) / 2;\n }\n }\n\n if( tr.lastChild && tr.lastChild.dataset.xIndex === this.dataset.xIndex ) {\n if( parseInt( tableBorderRight, 10 ) > parseInt( tdBorderRightWidth, 10 ) ) {\n width += -( parseInt( tableBorderRight, 10 ) - parseInt( tdBorderRightWidth, 10 ) ) / 2;\n }\n }\n \n let body = tr.parentNode;\n if( body && body.nodeName.toLowerCase() === 'body' ) {\n if( body.firstChild && body.firstChild.firstChild.dataset.yIndex === this.dataset.yIndex ) {\n if( parseInt( tableBorderTop, 10 ) > parseInt( tdBorderTopWidth, 10 ) ) {\n height += ( parseInt( tableBorderTop, 10 ) - parseInt( tdBorderTopWidth, 10 ) ) / 2;\n }\n }\n \n if( body.lastChild && body.lastChild.firstChild.dataset.yIndex === this.dataset.yIndex ) {\n if( parseInt( tableBorderBottom, 10 ) > parseInt( tdBorderBottomWidth, 10 ) ) {\n height += ( parseInt( tableBorderBottom, 10 ) - parseInt( tdBorderBottomWidth, 10 ) ) / 2;\n }\n }\n }\n }\n }\n \n return {\n width: parseInt( width ), \n height: parseInt( height )\n };\n }\n\n return this;\n};","var WPTB_DropHandle = function (thisElem, e) {\n \n let wptbDropHandle,\n wptbDropBorderMarker;\n if ( document.getElementsByClassName( 'wptb-drop-handle' ).length == 0 ) {\n wptbDropHandle = document.createElement( 'div' );\n wptbDropHandle.classList.add( 'wptb-drop-handle' );\n \n wptbDropBorderMarker = document.createElement( 'div' );\n wptbDropBorderMarker.classList.add( 'wptb-drop-border-marker' );\n \n let wptbDropBorderMarkerTop = document.createElement( 'div' ),\n wptbDropBorderMarkerRight = document.createElement( 'div' ),\n wptbDropBorderMarkerBottom = document.createElement( 'div' ),\n wptbDropBorderMarkerLeft = document.createElement( 'div' );\n \n wptbDropBorderMarkerTop.classList.add( 'wptb-drop-border-marker-top' );\n wptbDropBorderMarkerRight.classList.add( 'wptb-drop-border-marker-right' );\n wptbDropBorderMarkerBottom.classList.add( 'wptb-drop-border-marker-bottom' );\n wptbDropBorderMarkerLeft.classList.add( 'wptb-drop-border-marker-left' );\n \n wptbDropBorderMarker.appendChild( wptbDropBorderMarkerTop );\n wptbDropBorderMarker.appendChild( wptbDropBorderMarkerRight );\n wptbDropBorderMarker.appendChild( wptbDropBorderMarkerBottom );\n wptbDropBorderMarker.appendChild( wptbDropBorderMarkerLeft );\n \n let body = document.getElementsByTagName( 'body' );\n if ( body.length > 0 ) {\n body[0].appendChild( wptbDropHandle );\n body[0].appendChild( wptbDropBorderMarker );\n }\n \n wptbDropHandle.ondragenter = function () {\n\n }\n\n wptbDropHandle.ondragover = function (e) {\n e.preventDefault();\n }\n\n wptbDropHandle.ondragleave = function () {\n\n }\n wptbDropHandle.ondrop = function (e) {\n e.preventDefault();\n let element;\n \n if ( e.dataTransfer.getData('wptbElement') ) {\n element = WPTB_Helper.newElementProxy( e.dataTransfer.getData('wptbElement') );\n element = element.getDOMElement();\n } else {\n element = document.getElementsByClassName( e.dataTransfer.getData('node') )[0];\n element.classList.remove( 'wptb-moving-mode' );\n element.classList.remove( 'wptb-moving-into-same-elem' );\n element.wptbMovingMode = 1;\n }\n \n let td;\n if( wptbDropHandle.dataset.text == 'Drop Here' ) {\n thisElem = wptbDropHandle.getDOMParentElement();\n if ( thisElem.nodeName.toLowerCase() == 'td' ) {\n td = wptbDropHandle.getDOMParentElement();\n td.appendChild( element );\n }\n } else {\n let innerElement = wptbDropHandle.getDOMParentElement();\n td = innerElement.parentNode;\n \n if( wptbDropHandle.dataset.text == 'Above Element' ) {\n td.insertBefore( element, innerElement );\n } else if( wptbDropHandle.dataset.text == 'Below Element' ) {\n let innerElementNext = innerElement.nextSibling;\n td.insertBefore( element, innerElementNext );\n }\n }\n \n let thisRow = td.parentNode;\n if( WPTB_Helper.rowIsTop( thisRow ) ) {\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\n\n if( table.classList.contains( 'wptb-table-preview-head' ) ) {\n WPTB_Helper.dataTitleColumnSet( table );\n }\n }\n \n // start item javascript if item is new\n let infArr = element.className.match(/wptb-element-(.+)-(\\d+)/i);\n let elemKind = infArr[1];\n if ( e.dataTransfer.getData( 'wptbElement' ) && ( elemKind == 'text' || elemKind == 'button' || elemKind == 'image' || elemKind == 'star_rating' || elemKind == 'list' ) ) {\n //WPTB_Helper.elementStartScript( element );\n }\n \n wptbDropHandle.style.display = 'none';\n wptbDropBorderMarker.style.display = 'none';\n \n WPTB_innerElementSet( element );\n if( ! element.classList.contains( 'wptb-image-container' ) || element.wptbMovingMode == 1 ) {\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n element.wptbMovingMode == undefined;\n }\n }\n let wptbContainer = document.querySelector( '.wptb-container' );\n wptbContainer.onscroll = function() {\n wptbDropHandle.style.display = 'none';\n wptbDropBorderMarker.style.display = 'none';\n }\n } else {\n wptbDropHandle = document.getElementsByClassName( 'wptb-drop-handle' )[0];\n wptbDropBorderMarker = document.getElementsByClassName( 'wptb-drop-border-marker' )[0];\n }\n if( thisElem && thisElem.nodeName.toLowerCase() == 'td' && \n thisElem.getElementsByClassName( 'wptb-ph-element' ).length != 0 ) {\n return;\n }\n \n let thisRow;\n if ( thisElem.localName == 'td' ) {\n thisRow = thisElem.parentNode;\n } else if ( thisElem.localName == 'div' && thisElem.classList.contains( 'wptb-ph-element' ) ) {\n thisRow = thisElem.parentNode.parentNode;\n }\n \n if( WPTB_Helper.rowIsTop( thisRow ) ) {\n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\n \n if( table.classList.contains( 'wptb-table-preview-head' ) ) {\n let indics = e.dataTransfer.types;\n let notDragEnter = false;\n for ( let i = 0; i < indics.length; i++ ) {\n let infArr = indics[i].match( /wptbelindic-([a-z]+)/i );\n if ( infArr && infArr[1] != 'text' ) {\n notDragEnter = true;\n break;\n }\n }\n if( notDragEnter ) {\n return;\n }\n }\n }\n \n wptbDropHandle.style.width = thisElem.offsetWidth + 'px';\n let height = thisElem.offsetHeight,\n coordinatesElement = thisElem.getBoundingClientRect(),\n left = parseFloat( coordinatesElement.left ),\n top;\n wptbDropHandle.style.left = left + 'px';\n \n if( e.dataTransfer.types.indexOf( 'wptb-moving-mode' ) != -1 ) {\n let elementDrag = document.getElementsByClassName( 'wptb-moving-mode' )[0];\n if( thisElem == elementDrag ) {\n wptbDropHandle.classList.add('wptb-moving-into-same-elem');\n wptbDropBorderMarker.classList.add('wptb-moving-into-same-elem');\n } else {\n wptbDropHandle.classList.remove('wptb-moving-into-same-elem');\n wptbDropBorderMarker.classList.remove('wptb-moving-into-same-elem');\n }\n }\n \n wptbDropHandle.getDOMParentElement = function() {\n return thisElem;\n }\n \n wptbDropHandle.style.display = 'block';\n wptbDropBorderMarker.style.display = 'block';\n if( thisElem.nodeName.toLowerCase() != 'td' ) {\n let y = e.offsetY==undefined?e.layerY:e.offsetY;\n top = parseFloat( coordinatesElement.top ) - parseFloat( 11 );\n wptbDropHandle.dataset.text = 'Above Element';\n if ( y > height/2 ) {\n top = parseFloat( coordinatesElement.top ) + height - 1;\n wptbDropHandle.dataset.text = 'Below Element';\n }\n } else {\n wptbDropHandle.dataset.text = 'Drop Here';\n top = parseFloat( coordinatesElement.top ) + height/2 - 5;\n }\n wptbDropHandle.style.top = top + 'px';\n\n wptbDropBorderMarker.style.top = coordinatesElement.top + 'px';\n wptbDropBorderMarker.style.left = coordinatesElement.left + 'px';\n\n wptbDropBorderMarkerTop = wptbDropBorderMarker.querySelector( '.wptb-drop-border-marker-top' );\n wptbDropBorderMarkerTop.style.width = ( parseFloat( thisElem.offsetWidth ) - parseFloat( 1 ) ) + 'px';\n\n wptbDropBorderMarkerRight = wptbDropBorderMarker.querySelector( '.wptb-drop-border-marker-right' );\n wptbDropBorderMarkerRight.style.height = ( parseFloat( coordinatesElement.bottom ) - parseFloat( coordinatesElement.top ) - 1 ) + 'px';\n wptbDropBorderMarkerRight.style.left = wptbDropBorderMarkerTop.style.width;\n\n wptbDropBorderMarkerBottom = wptbDropBorderMarker.querySelector( '.wptb-drop-border-marker-bottom' );\n wptbDropBorderMarkerBottom.style.width = wptbDropBorderMarkerTop.style.width;\n wptbDropBorderMarkerBottom.style.top = wptbDropBorderMarkerRight.style.height;\n\n wptbDropBorderMarkerLeft = wptbDropBorderMarker.querySelector( '.wptb-drop-border-marker-left' );\n wptbDropBorderMarkerLeft.style.height = wptbDropBorderMarkerRight.style.height;\n}","var ElementCounters = function () {\n\n\tvar priv = [];\n\tpriv['text'] = 0;\n\tpriv['image'] = 0;\n\tpriv['list'] = 0;\n\tpriv['button'] = 0;\n\n\tthis.increment = function (key) {\n\t\tif (!(key in priv)) {\n\t\t\treturn;\n\t\t}\n\t\tpriv[key]++;\n\t}\n\n\tthis.nextIndex = function (key) {\n\t\tif (!(key in priv)) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn priv[key] + 1;\n\t}\n\n\treturn this;\n\n};","var WPTB_ElementObject = function ( data ) {\n let DOMElement, kindIndexProt, copy;\n if( ! data.elemProt ) {\n DOMElement = document.createElement('div'),\n kindIndexProt = undefined,\n copy = false;\n DOMElement.classList.add( 'wptb-' + data.kind + '-container', 'wptb-ph-element', 'wptb-item-javascript-indic' );\n \n let wpTemplateId = 'wptb-' + data.kind + '-content';\n let template = wp.template( wpTemplateId );\n data.node = DOMElement;\n let itemHtml = template( data );\n\n itemHtml = itemHtml.replace(/\\r|\\n|\\t/g, '').trim();\n DOMElement.innerHTML = itemHtml;\n } else {\n DOMElement = data.elemProt.cloneNode( true );\n DOMElement.classList.remove( 'wptb-directlyhovered' );\n let wptbElementMutch = data.elemProt.className.match( /wptb-element-((.+-)\\d+)/i );\n if ( wptbElementMutch && Array.isArray( wptbElementMutch ) ) {\n kindIndexProt = wptbElementMutch[1];\n };\n copy = true;\n \n if( data.tinyMceClear ) {\n DOMElement = WPTB_Helper.elementClearFromTinyMce( DOMElement );\n }\n }\n \n let inElems = DOMElement.querySelectorAll( '.wptb-in-element' );\n if( inElems.length > 0 ) {\n for ( let i = 0; i < inElems.length; i++ ) {\n let inElemObj = {};\n inElemObj.getDOMElement = function() {\n return inElems[i];\n }\n \n applyGenericItemSettings( inElemObj );\n }\n }\n \n window.addEventListener( 'item:onmouseenter', function( event ) {\n //console.log( event );\n }, false);\n \n \n this.kind = data.kind;\n this.getDOMElement = function () {\n return DOMElement;\n };\n \n applyGenericItemSettings( this, kindIndexProt, copy );\n return this;\n}\n\n\n","var WPTB_ElementOptions = function ( element, index, kindIndexProt ) {\n\n var node = element.getDOMElement();\n\n node.onclick = function () {\n WPTB_Helper.elementOptionsSet( element.kind, this );\n };\n};","var WPTB_Helper = {\n hexToRgb: function( hex ) {\n var result = /^#?([a-f\\d]{2})([a-f\\d]{2})([a-f\\d]{2})$/i.exec( hex );\n return result ? 'rgb(' + parseInt( result[1], 16 ) + ',' + parseInt( result[2], 16 ) + ',' + parseInt( result[3], 16 ) + ')' : null;\n },\n rgbToHex: function ( rgb ) {\n var rgb = rgb.match( /^rgba?[\\s+]?\\([\\s+]?(\\d+)[\\s+]?,[\\s+]?(\\d+)[\\s+]?,[\\s+]?(\\d+)[\\s+]?/i );\n\n return ( rgb && rgb.length === 4 ) ? \"#\" +\n ( \"0\" + parseInt( rgb[1],10 ).toString( 16 )).slice( -2 ) +\n ( \"0\" + parseInt( rgb[2],10 ).toString( 16 )).slice( -2 ) +\n ( \"0\" + parseInt( rgb[3],10 ).toString( 16 )).slice( -2 ) : '';\n },\n isHex: function( hex ) {\n let regex = new RegExp('^#(?:[A-Fa-f0-9]{3}){1,2}$');\n return regex.test( hex );\n },\n getElementIcon: function ( icon_directory ) {\n let hostName = location.protocol + '//' + location.hostname;\n let img = document.createElement( 'img' );\n img.src = icon_directory;\n return img;\n },\n elementDragEndClear: function() {\n let wptbMovingMode = document.getElementsByClassName( 'wptb-moving-mode' );\n if ( wptbMovingMode.length > 0 ) {\n for( let i = 0; i < wptbMovingMode.length; i++ ) {\n wptbMovingMode[i].classList.remove( 'wptb-moving-mode' );\n }\n }\n\n let wptbDropHandles = document.getElementsByClassName( 'wptb-drop-handle' );\n if ( wptbDropHandles.length > 0 ) {\n for( let i = 0; i < wptbDropHandles.length; i++ ) {\n wptbDropHandles[i].style.display = 'none';\n }\n }\n\n let wptbDropBorderMarkers = document.getElementsByClassName( 'wptb-drop-border-marker' );\n if ( wptbDropBorderMarkers.length > 0 ) {\n for( let i = 0; i < wptbDropBorderMarkers.length; i++ ) {\n wptbDropBorderMarkers[i].style.display = 'none';\n }\n }\n },\n linkHttpCheckChange: function( link ) {\n if ( link ) {\n if ( link.indexOf( 'http://' ) == -1 && link.indexOf( 'https://' ) == -1 ) {\n let linkArr = link.split( '/' ),\n linkClean;\n if ( Array.isArray( linkArr ) && linkArr.length > 0 ) {\n linkClean = linkArr[linkArr.length - 1];\n }\n return document.location.protocol + '//' + linkClean;\n } else { \n return link;\n }\n } else {\n return '';\n }\n },\n dataTitleColumnSet: function( table ) {\n let rows = table.rows,\n rowHead = rows[0];\n let computedStyleRowHead = getComputedStyle( rowHead );\n \n let rowHeadChildren = rowHead.children;\n let contentsForHeader = {};\n for( let i = 0; i < rowHeadChildren.length; i++ ) {\n let tdElements = rowHeadChildren[i].children;\n \n for( let j = 0; j < tdElements.length; j++ ) {\n let element = tdElements[j];\n if( element.classList.contains( 'wptb-ph-element' ) ) {\n let infArr = element.className.match( /wptb-element-(.+)-(\\d+)/i );\n if( infArr[1] == 'text' ) {\n let p = element.querySelector( 'p' ),\n textContent = p.textContent,\n textAlign = p.style.textAlign;\n contentsForHeader[rowHeadChildren[i].dataset.xIndex] = [textContent, element.style.fontSize, \n element.style.color, computedStyleRowHead.backgroundColor, textAlign];\n break;\n }\n }\n }\n if( ! contentsForHeader[rowHeadChildren[i].dataset.xIndex] ) {\n contentsForHeader[rowHeadChildren[i].dataset.xIndex] = ['', '', \n '', computedStyleRowHead.backgroundColor, ''];\n }\n }\n for ( let i = 1; i < rows.length; i++ ) {\n let thisRow = rows[i],\n thisRowChildren = thisRow.children;\n for( let j = 0; j < thisRowChildren.length; j++ ) {\n if ( contentsForHeader[thisRowChildren[j].dataset.xIndex] ) {\n thisRowChildren[j].dataset.wptbTitleColumn = contentsForHeader[thisRowChildren[j].dataset.xIndex][0];\n thisRowChildren[j].dataset.wptbTitleColumnFontSize = contentsForHeader[thisRowChildren[j].dataset.xIndex][1];\n thisRowChildren[j].dataset.wptbTitleColumnColor = contentsForHeader[thisRowChildren[j].dataset.xIndex][2];\n thisRowChildren[j].dataset.wptbTitleBackgroundColor = contentsForHeader[thisRowChildren[j].dataset.xIndex][3];\n thisRowChildren[j].dataset.wptbTitleAlign = contentsForHeader[thisRowChildren[j].dataset.xIndex][4];\n } else {\n thisRowChildren[j].dataset.wptbTitleColumn = '';\n thisRowChildren[j].dataset.wptbTitleColumnFontSize = '';\n thisRowChildren[j].dataset.wptbTitleColumnColor = '';\n thisRowChildren[j].dataset.wptbTitleBackgroundColor = '';\n thisRowChildren[j].dataset.wptbTitleAlign = '';\n }\n }\n }\n },\n findAncestor: function( el, cls ) {\n while ( ( el = el.parentElement ) && !el.classList.contains( cls ) );\n return el;\n },\n rowIsTop: function( row ) {\n var parent = row.parentNode;\n if( parent.children[0] == row ) {\n return true;\n } else {\n return false;\n }\n },\n getSelectionText: function() {\n var txt = '';\n if (txt = window.getSelection) {\n txt = window.getSelection().toString();\n } else {\n txt = document.selection.createRange().text;\n }\n return txt;\n },\n elementOptionsPanelClear: function() {\n let elementOptionsGroup = document.getElementById( 'element-options-group' );\n if( elementOptionsGroup ) {\n elementOptionsGroup.innerHTML = '';\n }\n },\n wpColorPickerCheckChangeForTableStateSaving: function( event ) {\n if( event.originalEvent.type == 'external' ) {\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n } else {\n let wpPickerContainer = WPTB_Helper.findAncestor( event.target, 'wp-picker-container' );\n if( wpPickerContainer ) {\n if( event.originalEvent.type == 'square' || event.originalEvent.type == 'strip' ) {\n let body = document.getElementsByTagName( 'body' )[0];\n body.removeEventListener( 'mouseup', WPTB_Helper.irisStripMouseUpStateSaveManager, false );\n body.addEventListener( 'mouseup', WPTB_Helper.irisStripMouseUpStateSaveManager, false );\n }\n }\n }\n },\n irisStripMouseUpStateSaveManager: function() {\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n \n let body = document.getElementsByTagName( 'body' )[0];\n body.removeEventListener( 'mouseup', WPTB_Helper.irisStripMouseUpStateSaveManager, false );\n },\n wpColorPickerClear: function( attribute, isId ) {\n let input;\n if( isId ) {\n input = [document.getElementById( attribute )];\n input.length = 1;\n } else {\n input = document.getElementsByClassName( attribute );\n }\n for( let i = 0; i < input.length; i++ ) {\n let wpPickerContainer = WPTB_Helper.findAncestor( input[i], 'wp-picker-container' );\n if( wpPickerContainer ) {\n let parent = wpPickerContainer.parentNode;\n parent.removeChild( wpPickerContainer );\n let newInput = document.createElement( 'input' );\n if( isId ) {\n newInput.setAttribute( 'id', attribute );\n } else {\n newInput.classList.add( 'wptb-element-property', attribute );\n }\n newInput.value = \"\";\n parent.appendChild( newInput );\n }\n }\n },\n detectMode: function() {\n var url = window.location.href,\n regex = new RegExp('[?&]table(=([^&#]*)|&|#|$)'),\n results = regex.exec(url);\n if (!results) return false;\n if (!results[2]) return '';\n return decodeURIComponent(results[2].replace(/\\+/g, ' '));\n },\n getColumnWidth: function( table, cell ) {\n let xIndex = cell.dataset.xIndex;\n let xIndexes = table.querySelectorAll( '[data-x-index=\"' + xIndex + '\"]' );\n let cellWidth = cell.getCellDimensions().width;\n for( let i = 0; i < xIndexes.length; i++ ) {\n if( cellWidth > xIndexes[i].getCellDimensions().width ) {\n cellWidth = xIndexes[i].getCellDimensions().width;\n }\n }\n return cellWidth;\n },\n getRowHeight: function( table, cell ) {\n let yIndex = cell.dataset.yIndex;\n let yIndexes = table.querySelectorAll( '[data-y-index=\"' + yIndex + '\"]' );\n let cellHeight = cell.getCellDimensions().height;\n for( let i = 0; i < yIndexes.length; i++ ) {\n if( cellHeight > yIndexes[i].getCellDimensions().height ) {\n cellHeight = yIndexes[i].getCellDimensions().height;\n }\n }\n return cellHeight;\n },\n newElementProxy: function( el ) {\n if( el ) {\n let data = {kind: el};\n return new WPTB_ElementObject( data );\n }\n },\n wpColorPickerChange: function( event, ui ) {\n let uiColor;\n if( ui ) {\n uiColor = ui.color.toString();\n } else {\n uiColor = '';\n }\n \n let parent = WPTB_Helper.findAncestor( event.target, 'wp-picker-input-wrap' ).getElementsByClassName( 'wptb-color-picker' )[0], classe, type, ps, number;\n classe = parent.dataset.element.match(/wptb-options-(.+)-(\\d+)/i);\n type = classe[1];\n number = classe[2];\n let affectedEl = document.getElementsByClassName( 'wptb-element-' + type + '-' + number )[0];\n if ( type == 'button' ) {\n if ( parent.dataset.type == 'button-text-color' ) {\n affectedEl.getElementsByClassName( 'wptb-button' )[0].style.color = uiColor;\n } else {\n affectedEl.getElementsByClassName( 'wptb-button' )[0].style.backgroundColor = uiColor;\n }\n } else if( type == 'list' ) {\n let ps = affectedEl.querySelectorAll( 'p' );\n if( ps.length > 0 ) {\n for ( let i = 0; i < ps.length; i++ ) {\n ps[i].style.color = uiColor;\n }\n }\n } else if( type == 'star_rating' ) {\n if ( parent.dataset.type == 'star-color' ) {\n let ratingStar = affectedEl.querySelectorAll('li');\n for( let i = 0; i < ratingStar.length; i++ ) {\n let span = ratingStar[i].getElementsByTagName( 'span' );\n for( let j = 0; j < span.length; j++ ) {\n span[j].style.fill = uiColor;\n }\n }\n } else if( parent.dataset.type == 'numeral-rating-color' ) {\n let wptbTextMessageSize = affectedEl.querySelector('.wptb-number-rating');\n wptbTextMessageSize.style.color = uiColor;\n }\n\n } else {\n affectedEl.style.color = uiColor;\n }\n },\n numberImputSize: function ( wptbNumberInputs, maxCount, maxValue ) {\n wptbNumberInputs.onkeydown = function() {\n let thisValue = this.value;\n thisValue = String( thisValue );\n if ( thisValue[0] == 0 ) {\n this.value = \"\";\n } else {\n thisValue = thisValue.substring( 0, maxCount );\n this.value = thisValue;\n }\n }\n wptbNumberInputs.onkeyup = function( ) {\n let thisValue = this.value;\n if ( parseInt( thisValue, 10 ) > parseInt( maxValue, 10 ) ) {\n this.value = maxValue;\n }\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n },\n ucfirst: function( str ) {\n return str.charAt(0).toUpperCase() + str.slice(1);\n },\n wptbDocumentEventGenerate: function( eventName, element, details ) {\n if( eventName && element ) {\n if( ! details ) {\n details = true;\n }\n let event = new CustomEvent( eventName, { detail: details, bubbles: true } );\n element.dispatchEvent( event );\n }\n },\n // run script for the pointed element\n elementStartScript: function( element ) {\n //let script = element.getElementsByTagName( 'script' );\n let infArr = element.className.match(/wptb-element-(.+)-(\\d+)/i);\n if( infArr && Array.isArray( infArr ) ) {\n let kind = infArr[1];\n if( kind ) {\n// let wpTemplateId = 'wptb-' + kind + '-script';\n// let template = wp.template( wpTemplateId );\n// let data = {elemClass: infArr[0]};\n// let elementScriptText = template( data );\n// elementScriptText = elementScriptText.replace(/\\r|\\n|\\t/g, '').trim();\n//\n// let scriptNew = document.createElement( 'script' );\n// scriptNew.setAttribute( 'type', 'text/javascript' );\n// scriptNew.innerHTML = elementScriptText;\n// element.parentNode.appendChild( scriptNew );\n \n// element.parentNode.removeChild( scriptNew );\n if( kind in WPTB_ElementsScriptsLauncher ) {\n WPTB_ElementsScriptsLauncher[kind]( element );\n }\n }\n }\n },\n // deletes event handlers from the pointed option element and from all his daughter elements\n deleteEventHandlers: function( element ) {\n if( element ) {\n jQuery( element ).off();\n let elementChildren = element.children;\n if( elementChildren ) {\n for ( let i = 0; i < elementChildren.length; i++ ) {\n WPTB_Helper.deleteEventHandlers( elementChildren[i] );\n }\n }\n } else {\n return;\n }\n },\n // replace all occurrences in a string\n replaceAll: function( string, search, replace ){\n return string.split( search ).join( replace );\n },\n // clears code from TinyMCE attributes\n elementClearFromTinyMce: function( element ) {\n let mceContentBodys = element.querySelectorAll( '.mce-content-body' );\n if( mceContentBodys.length > 0 ) {\n for ( let k = 0; k < mceContentBodys.length; k++ ) {\n mceContentBodys[k].classList.remove( 'mce-content-body' );\n }\n }\n\n let dataMceStyle = element.querySelectorAll( '[data-mce-style]' );\n if ( dataMceStyle.length > 0 ) {\n for ( let k = 0; k < dataMceStyle.length; k++ ) {\n dataMceStyle[k].removeAttribute( 'data-mce-style' );\n }\n }\n \n let mceEditFocus = element.querySelectorAll( '.mce-edit-focus' );\n if( mceEditFocus.length > 0 ) {\n for ( let k = 0; k < mceEditFocus.length; k++ ) {\n mceEditFocus[k].classList.remove( 'mce-edit-focus' );\n }\n }\n\n let contentEditable = element.querySelectorAll( '[contenteditable]' );\n if ( contentEditable.length > 0 ) {\n for ( let k = 0; k < contentEditable.length; k++ ) {\n contentEditable[k].removeAttribute( 'contenteditable' );\n }\n }\n\n let spellCheck = element.querySelectorAll( '[spellcheck]' );\n if ( spellCheck.length > 0 ) {\n for ( let k = 0; k < spellCheck.length; k++ ) {\n spellCheck[k].removeAttribute( 'spellcheck' );\n }\n }\n\n let mceIds = element.querySelectorAll( '[id^=mce_]' );\n if ( mceIds.length > 0 ) {\n for ( let k = 0; k < mceIds.length; k++ ) {\n mceIds[k].removeAttribute( 'id' );\n }\n }\n \n return element;\n },\n elementOptionContainerCustomClassSet: function( targetInput, customClassForContainer ) {\n if( targetInput && customClassForContainer ) {\n let containerElement = WPTB_Helper.findAncestor( targetInput, 'wptb-element-option' );\n if( containerElement ) {\n containerElement.classList.add( customClassForContainer );\n }\n }\n },\n elementOptionContainerAdditionalStyles: function( targetInput, containerAdditionalStyles ) {\n if( targetInput && containerAdditionalStyles ) {\n let containerElement = WPTB_Helper.findAncestor( targetInput, 'wptb-element-option' );\n let containerStylesArrOne = containerAdditionalStyles.split( ';' );\n\n if( containerElement && containerStylesArrOne ) {\n function containerStylesSet( containerStyleStr, containerElement ) {\n if( containerStyleStr ) {\n containerStyleStrArr = containerStyleStr.split( ':' );\n\n if( containerStyleStrArr && Array.isArray( containerStyleStrArr ) ) {\n containerElement.style[containerStyleStrArr[0]] = containerStyleStrArr[1];\n }\n }\n }\n if( containerStylesArrOne && Array.isArray( containerStylesArrOne ) ) {\n for( let i = 0; i < containerStylesArrOne.length; i++ ) {\n console.log( containerStylesArrOne );\n if( containerStylesArrOne[i] ) {\n containerStylesSet( containerStylesArrOne[i], containerElement );\n }\n }\n } else {\n containerStylesSet( containerStylesArrOne, containerElement );\n }\n }\n }\n },\n // function which set handler for event of changes of control\n controlsInclude: function( element, functionHandler ) {\n if( element && typeof element === 'object' && typeof functionHandler === 'function' ) {\n element.addEventListener( 'element:control:active', function() {\n let infArr = element.className.match( /wptb-element-(.+)-(\\d+)/i ),\n elementKind;\n\n if( infArr && Array.isArray( infArr ) ) {\n elementKind = infArr[1];\n }\n\n if( ! element.hasOwnProperty( 'сontrolsConnectIndic' ) || element.сontrolsConnectIndic !== true && elementKind ) {\n let elementsSettingsTemplateJs = document.getElementsByClassName( 'wptb-element-datas' );\n if( elementsSettingsTemplateJs.length > 0 ) {\n elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];\n\n let elementsSettings = elementsSettingsTemplateJs.innerHTML;\n let controlClassesNames = [];\n if( elementsSettings ) {\n elementsSettings = JSON.parse( elementsSettings );\n if( elementsSettings && typeof elementsSettings === 'object' ) {\n if( 'tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2] in elementsSettings ) {\n let elementSettings = elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]];\n if( elementSettings && typeof elementSettings === 'object' ) {\n Object.keys( elementSettings ).forEach( function( key ) {\n let regularText = new RegExp( 'data-wptb-el-' + elementKind + '-(\\\\d+)-(.+)', \"i\" );\n let keyInfArr = key.match( regularText );\n if( keyInfArr && Array.isArray( keyInfArr ) ) {\n let controlClass = key.replace( 'data-', '' );\n controlClassesNames.push( [controlClass, keyInfArr[2]] );\n }\n });\n }\n }\n }\n }\n\n for( let i = 0; i < controlClassesNames.length; i++ ) {\n element.addEventListener( 'wptb-control:' + controlClassesNames[i][0], function() {\n let controls = {};\n let controlName = controlClassesNames[i][1];\n let control = document.getElementsByClassName( controlClassesNames[i][0] );\n if( control.length > 0 && controlName ) {\n let targetControlValue = WPTB_Helper.targetControlValueGet( control );\n\n controls[controlName] = targetControlValue;\n }\n\n functionHandler( controls, element );\n }, false );\n\n element.сontrolsConnectIndic = true;\n }\n }\n }\n }, false );\n }\n },\n oneControlInclude: function( element, functionHandler, controlName ) {\n if( element && typeof element === 'object' && typeof functionHandler === 'function' && typeof controlName === 'string' ) {\n let infArr = element.className.match( /wptb-element-((.+-)\\d+)/i ),\n elementKind;\n \n if( infArr && Array.isArray( infArr ) ) {\n elementKind = infArr[1].split( '-' )[0];\n \n let wptbContrlStacksConfigId = 'wptb-' + elementKind + '-control-stack';\n let tmplControlsConfig = wp.template( wptbContrlStacksConfigId );\n let data = {\n container: '.' + infArr[0]\n };\n let jsonControlsConfigJson = tmplControlsConfig( data );\n let jsonControlsConfig = JSON.parse( jsonControlsConfigJson );\n \n if( jsonControlsConfig && typeof jsonControlsConfig === 'object' && jsonControlsConfig.hasOwnProperty( controlName ) ) {\n let controlClassName = 'wptb-el-' + infArr[1] + '-' + controlName;\n \n element.addEventListener( 'wptb-control:' + controlClassName, function( event ) {\n let control = document.getElementsByClassName( controlClassName );\n if( control.length > 0 ) {\n let targetControlValue = WPTB_Helper.targetControlValueGet( control );\n\n functionHandler( targetControlValue, element );\n }\n }, false );\n }\n }\n } else {\n return false;\n }\n },\n //\n innerElementCopyIncludeHandler: function( element, functionHandler ) {\n if( element && typeof element === 'object' && typeof functionHandler === 'function' ) {\n element.addEventListener( 'wptb-inner-element:copy', function( event ) {\n let innerElement = event.detail;\n if( innerElement ) {\n WPTB_Helper.elementClearFromTinyMce( innerElement );\n functionHandler( innerElement, element );\n }\n }, false );\n }\n },\n //\n appearDependOnControl: function( dependOn, targetControlElementClass ) {\n if( Array.isArray( dependOn ) ) {\n let dependOnControlName = dependOn[0];\n let infArr = targetControlElementClass.match( /wptb-el-((.+-)\\d+)-(.+)/i );\n \n if( infArr && Array.isArray( infArr ) ) {\n let controlName = infArr[3];\n\n let dependOnControlElementClass = targetControlElementClass.replace( controlName, dependOnControlName );\n\n let dependOnControlElement = document.getElementsByClassName( dependOnControlElementClass );\n\n if( dependOnControlElement.length > 0 ) {\n dependOnControlElement = dependOnControlElement[0];\n let targetControlElement = document.getElementsByClassName( targetControlElementClass );\n if( targetControlElement.length > 0 ) {\n targetControlElement = targetControlElement[0];\n let controlContainerElem = WPTB_Helper.findAncestor( targetControlElement, 'wptb-element-option' );\n\n if( controlContainerElem ) {\n function showHideDependOnControlElement( dependOnControlElementKind ) {\n \n let elementsSettingsTemplateJs = document.getElementsByClassName( 'wptb-element-datas' );\n if( elementsSettingsTemplateJs.length > 0 ) {\n elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];\n\n let elementsSettings = elementsSettingsTemplateJs.innerHTML;\n if( elementsSettings ) {\n elementsSettings = JSON.parse( elementsSettings );\n if( elementsSettings && typeof elementsSettings === 'object' && \n ( 'tmpl-wptb-el-datas-' + dependOnControlElementKind ) in elementsSettings ) {\n let elementSettings = elementsSettings['tmpl-wptb-el-datas-' + dependOnControlElementKind];\n if( elementSettings && typeof elementSettings === 'object' && \n ( 'data-wptb-el-' + dependOnControlElementKind + '-' + dependOnControlName ) in elementSettings ) {\n let elementSettingValue = elementSettings['data-wptb-el-' + dependOnControlElementKind + '-' + dependOnControlName];\n \n if( elementSettingValue ) {\n if( dependOn[1] && Array.isArray( dependOn[1] ) && \n ( dependOn[1].indexOf( elementSettingValue ) !== -1 ) ) {\n controlContainerElem.style.display = 'block';\n } else if( dependOn[2] && Array.isArray( dependOn[2] ) && \n ( dependOn[2].indexOf( elementSettingValue ) !== -1 ) ) {\n controlContainerElem.style.display = 'none';\n }\n }\n }\n }\n }\n }\n }\n\n showHideDependOnControlElement( infArr[1] );\n\n dependOnControlElement.addEventListener( 'change', function() {\n showHideDependOnControlElement( infArr[1] );\n }, false );\n }\n }\n }\n }\n }\n },\n //\n controlsStateManager: function ( targetControlClass, controlChangeIndic ) {\n let targetControls = document.getElementsByClassName( targetControlClass );\n if( targetControls.length > 0 ) {\n //targetControls = targetControls[0];\n \n let infArr = targetControlClass.match( /wptb-el-((.+-)\\d+)-(.+)/i );\n \n if( infArr && Array.isArray( infArr ) ) {\n let selectorElement;\n selectorElement = document.querySelector( '.wptb-element-' + infArr[1] );\n \n if( selectorElement ) {\n let elementsSettingsTemplatesJs;\n let elementSettings = {};\n let elementsSettings;\n elementsSettingsTemplatesJs = document.getElementsByClassName( 'wptb-element-datas' );\n if( elementsSettingsTemplatesJs.length == 0 || elementsSettingsTemplatesJs[0].innerHTML == '' ) {\n let targetControlValue = WPTB_Helper.targetControlValueGet( targetControls );\n elementSettings['data-' + targetControlClass] = targetControlValue;\n\n elementsSettings = {};\n elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] = elementSettings;\n elementsSettings = JSON.stringify( elementsSettings );\n\n if( elementsSettingsTemplatesJs.length == 0 ) {\n elementsSettingsTemplatesJs = document.createElement( 'script' );\n elementsSettingsTemplatesJs.setAttribute( 'type', 'text/html' );\n elementsSettingsTemplatesJs.setAttribute( 'class', 'wptb-element-datas' );\n } else {\n elementsSettingsTemplatesJs = elementsSettingsTemplatesJs[0];\n }\n\n elementsSettingsTemplatesJs.innerHTML = elementsSettings;\n\n let body = document.getElementsByTagName('body')[0];\n body.appendChild( elementsSettingsTemplatesJs );\n } else {\n elementsSettingsTemplatesJs = elementsSettingsTemplatesJs[0];\n elementsSettings = elementsSettingsTemplatesJs.innerHTML;\n if( elementsSettings ) {\n elementsSettings = JSON.parse( elementsSettings );\n\n if( elementsSettings && typeof elementsSettings === 'object' ) {\n \n \n if( controlChangeIndic ) {\n let targetControlValue = WPTB_Helper.targetControlValueGet( targetControls );\n if( ! ( ( 'tmpl-wptb-el-datas-' + infArr[1] ) in elementsSettings ) || \n typeof elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] !== 'object') {\n elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] = {};\n }\n elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-' + targetControlClass] = targetControlValue;\n elementsSettingsTemplatesJs.innerHTML = JSON.stringify( elementsSettings );\n } else if( ! ( ( ( 'tmpl-wptb-el-datas-' + infArr[1] ) in elementsSettings ) && \n typeof elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] === 'object' && \n ( 'data-' + targetControlClass ) in elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] ) ) {\n let targetControlValue = WPTB_Helper.targetControlValueGet( targetControls );\n if( ! ( ( 'tmpl-wptb-el-datas-' + infArr[1] ) in elementsSettings ) || \n typeof elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] !== 'object') {\n elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] = {};\n }\n elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-' + targetControlClass] = targetControlValue;\n elementsSettingsTemplatesJs.innerHTML = JSON.stringify( elementsSettings );\n } else if( ( ( 'tmpl-wptb-el-datas-' + infArr[1] ) in elementsSettings ) && \n typeof elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] === 'object' && \n ( 'data-' + targetControlClass ) in elementsSettings['tmpl-wptb-el-datas-' + infArr[1]] ) {\n for( let i = 0; i < targetControls.length; i++ ) {\n if( targetControls[i].type == 'checkbox' ) {\n let targetControlValue;\n if( targetControls[i].name ) {\n targetControlValue = elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-' + targetControlClass][targetControls[i].name];\n } else {\n targetControlValue = elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-' + targetControlClass];\n }\n \n if( targetControlValue == 'checked' ) {\n targetControls[i].checked = true;\n } else if( targetControlValue == 'unchecked' ) {\n targetControls[i].checked = false;\n }\n } else {\n targetControls[i].value = elementsSettings['tmpl-wptb-el-datas-' + infArr[1]]['data-' + targetControlClass];\n }\n }\n }\n }\n }\n }\n }\n }\n }\n },\n //\n targetControlValueGet: function( targetControls ) {\n let targetControlValue;\n for( let i = 0; i < targetControls.length; i++ ) {\n if( targetControls[i].type == 'checkbox' && targetControls[i].name ) {\n if( ! targetControlValue ) targetControlValue = {};\n if( targetControls[i].checked == true ) {\n targetControlValue[targetControls[i].name] = 'checked';\n } else {\n targetControlValue[targetControls[i].name] = 'unchecked';\n }\n } else if( targetControls[i].type == 'checkbox' ) {\n if( targetControls[i].checked == true ) {\n targetControlValue = 'checked';\n } else {\n targetControlValue = 'unchecked';\n }\n } else {\n targetControlValue = targetControls[i].value;\n }\n }\n return targetControlValue;\n },\n //\n elementControlsStateCopy: function( elementProt, copyElem ) {\n if( elementProt && copyElem ) {\n let infArrProt = elementProt.className.match( /wptb-element-((.+-)\\d+)/i );\n let infArrCopy = copyElem.className.match( /wptb-element-((.+-)\\d+)/i );\n if( infArrProt && Array.isArray( infArrProt ) &&\n infArrCopy && Array.isArray( infArrCopy )) {\n let elemProtKind = infArrProt[1];\n let elemCopyKind = infArrCopy[1];\n let elementsSettingsTemplateJs = document.getElementsByClassName( 'wptb-element-datas' );\n if( elementsSettingsTemplateJs.length > 0 ) {\n elementsSettingsTemplateJs = elementsSettingsTemplateJs[0];\n \n let elementsSettings = elementsSettingsTemplateJs.innerHTML;\n if( elementsSettings ) {\n elementsSettings = JSON.parse( elementsSettings );\n \n if( elementsSettings && typeof elementsSettings === 'object' ) {\n let elementSettingsProt = elementsSettings['tmpl-wptb-el-datas-' + elemProtKind];\n if( elementSettingsProt && typeof elementSettingsProt === 'object' ) {\n let elementSettingsCopy = {};\n \n Object.keys( elementSettingsProt ).forEach( function( key ) {\n let elementSettingValue = elementSettingsProt[key];\n let elementSettingKeyCopy = key.replace( elemProtKind, elemCopyKind );\n elementSettingsCopy[elementSettingKeyCopy] = elementSettingValue;\n });\n \n if( Object.keys( elementSettingsCopy ).length > 0 ) {\n elementsSettings['tmpl-wptb-el-datas-' + elemCopyKind] = elementSettingsCopy;\n \n elementsSettings = JSON.stringify( elementsSettings );\n elementsSettingsTemplateJs.innerHTML = elementsSettings;\n }\n }\n }\n }\n }\n }\n }\n },\n //\n elementControlsStateDelete: function( element, nameControl ) {\n let infArr = element.className.match( /wptb-element-(.+)-(\\d+)/i );\n let body = document.getElementsByTagName( 'body' )[0];\n let wptbElementDatas = body.getElementsByClassName( 'wptb-element-datas' );\n if( infArr && Array.isArray( infArr ) && wptbElementDatas.length > 0 ) {\n wptbElementDatas = wptbElementDatas[0];\n let elementsSettings = wptbElementDatas.innerHTML;\n if( elementsSettings ) {\n elementsSettings = JSON.parse( elementsSettings );\n if( elementsSettings && typeof elementsSettings === 'object' &&\n ( ( 'tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2] ) in elementsSettings ) ) {\n if( ! nameControl ) {\n delete elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]];\n } else {\n if( elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]] && \n typeof elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]] === 'object' &&\n ( 'data-wptb-el-' + infArr[1] + '-' + infArr[2] + '-' + nameControl ) in elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]] ) {\n delete elementsSettings['tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2]]['data-wptb-el-' + infArr[1] + '-' + infArr[2] + '-' + nameControl];\n }\n }\n\n if( Object.keys( elementsSettings ).length == 0 ) {\n body.removeChild( wptbElementDatas );\n } else {\n elementsSettings = JSON.stringify( elementsSettings );\n wptbElementDatas.innerHTML = elementsSettings;\n }\n }\n }\n }\n },\n // \n elementOptionsSet: function( kind, element ) {\n // get controls config for this element\n let wptbContrlStacksConfigId = 'wptb-' + kind + '-control-stack';\n let tmplControlsConfig = wp.template( wptbContrlStacksConfigId );\n let data;\n let elementContainerClass;\n let elementOptionClassIndic;\n let elementOptionsGroup;\n let elementOptionsGroupId;\n let wptbelementOptionClass;\n \n // create a container for inserting controls of this item\n let wptbelementOptionsContainer = document.createElement( 'div' );\n \n let infArr = element.className.match( /wptb-element-((.+-)\\d+)/i );\n if( ! infArr && element.classList.contains( 'wptb-preview-table' ) ) {\n let table_id = WPTB_Helper.detectMode();\n element.classList.add( 'wptb-element-main-table_setting-' + table_id );\n infArr = element.className.match( /wptb-element-((.+-)\\d+)/i );\n }\n data = {\n container: '.' + infArr[0]\n };\n\n elementContainerClass = infArr[0];\n elementOptionClassIndic = infArr[1];\n \n if( ! element.classList.contains( 'wptb-preview-table' ) ) {\n let children = document.getElementById( 'element-options-group' ).childNodes;\n for ( let i = 0; i < children.length; i++) {\n if ( children[i].style )\n children[i].style.display = 'none';\n }\n \n wptbelementOptionsContainer.classList.add( 'wptb-element-options', 'wptb-options-' + infArr[1] );\n \n // hide wptb-elements-container and wptb-settings-section\n document.getElementsByClassName( 'wptb-elements-container' )[0].style.display = 'none';\n document.getElementsByClassName( 'wptb-settings-section' )[0].style.display = 'none';\n\n // show element-options-group \n document.getElementById( 'element-options-group' ).style.display = 'block';\n \n elementOptionsGroupId = 'element-options-group';\n wptbelementOptionClass = 'wptb-element-option';\n } else {\n elementOptionsGroupId = 'table-settings-group';\n wptbelementOptionClass = 'wptb-element-option';\n }\n\n let jsonControlsConfigJson = tmplControlsConfig( data );\n let jsonControlsConfig = JSON.parse( jsonControlsConfigJson );\n\n // clear elements from options group\n //document.getElementById( 'element-options-group' ).innerHTML = '';\n elementOptionsGroup = document.getElementById( elementOptionsGroupId );\n let elementOptionsGroupChildren = elementOptionsGroup.children;\n for( let i = 0; i < elementOptionsGroupChildren.length; i++ ) {\n elementOptionsGroup.removeChild( elementOptionsGroupChildren[i] );\n }\n\n \n // insert created container into element-option-group tag\n document.getElementById( elementOptionsGroupId ).appendChild( wptbelementOptionsContainer );\n\n // show created container\n wptbelementOptionsContainer.style.display = 'block';\n\n // array for save all scrips for each controls\n let controlScriptsArr = [];\n\n // array for keep \"appear depend on\" parametrs\n let controlappearDependOnControl = [];\n\n // create controls\n let i = 0;\n Object.keys( jsonControlsConfig ).forEach( function( key ) {\n let data = jsonControlsConfig[key];\n data.controlKey = key;\n\n // get necessary wp js template\n let tmplControlTemplate = wp.template( 'wptb-' + data.type + '-control' );\n\n data.elemContainer = elementContainerClass;\n data.elementControlTargetUnicClass = 'wptb-el-' + elementOptionClassIndic + '-' + data.controlKey;\n let controlTemplate = tmplControlTemplate( data );\n\n if( 'appearDependOnControl' in data ) {\n if( Array.isArray( data.appearDependOnControl ) ) {\n controlappearDependOnControl.push( [data.appearDependOnControl, data.elementControlTargetUnicClass] );\n }\n }\n\n //console.log( controlTemplate );\n\n let wptbElementOptionContainer = document.createElement( 'div' );\n wptbElementOptionContainer.classList.add( wptbelementOptionClass, 'wptb-settings-items' );\n\n if( data.customClassForContainer ) {\n wptbElementOptionContainer.classList.add( data.customClassForContainer );\n }\n\n if( data.containerAdditionalStyles ) {\n wptbElementOptionContainer.setAttribute( 'style', data.containerAdditionalStyles );\n }\n\n wptbElementOptionContainer.innerHTML = controlTemplate;\n\n wptbelementOptionsContainer.appendChild( wptbElementOptionContainer );\n\n let helperJavascriptElem = wptbElementOptionContainer.getElementsByTagName( 'wptb-template-script' );\n if( helperJavascriptElem.length > 0 ) {\n helperJavascriptElem = helperJavascriptElem[0];\n let helperJavascriptCode = helperJavascriptElem.innerText;\n wptbElementOptionContainer.removeChild( helperJavascriptElem );\n let script = document.createElement( 'script' );\n script.setAttribute( 'type', 'text/javascript' );\n script.innerHTML = helperJavascriptCode.replace(/\\r|\\n|\\t/g, '').trim();\n controlScriptsArr.push( script );\n }\n\n i++;\n });\n\n // run the scripts of controls\n if( controlScriptsArr.length > 0 ) {\n for( let i = 0; i < controlScriptsArr.length; i++ ) {\n wptbelementOptionsContainer.appendChild( controlScriptsArr[i] );\n }\n }\n\n // run appearDependOnControl function\n for ( let i = 0; i < controlappearDependOnControl.length; i++ ) {\n WPTB_Helper.appearDependOnControl( controlappearDependOnControl[i][0], controlappearDependOnControl[i][1] );\n }\n\n WPTB_Helper.wptbDocumentEventGenerate( 'element:control:active', element );\n },\n // function for create, update css for element\n managerExternalCssStyles: function( elementContainer, selector, cssName, cssValue ) {\n let infArr = elementContainer.match( /wptb-element-main(.+)-(\\d+)/i );\n if( ! infArr || ! Array.isArray( infArr ) ) {\n let table = document.getElementsByClassName( 'wptb-preview-table' );\n \n if( table.length > 0 ) {\n table = table[0];\n \n let infArr = table.className.match( /wptb-element-main(.+)-(\\d+)/i );\n if( infArr && Array.isArray( infArr ) ) {\n selector = '.' + infArr[0] + ' ' + selector;\n }\n }\n }\n \n let head = document.head;\n if( head ) {\n let cssForThisElement = head.querySelector( '#styles-' + elementContainer );\n if( cssForThisElement ) {\n let cssText = cssForThisElement.innerHTML;\n if( cssText ) {\n let cssTextArrFirst = cssText.split( '}' );\n cssTextArrFirst.pop();\n let selectorExists = false;\n for( let i = 0; i < cssTextArrFirst.length; i++ ) {\n let cssTextArrSecond = cssTextArrFirst[i].split( '{' );\n if( cssTextArrSecond[0] === selector ) {\n let cssTextArrThird = cssTextArrSecond[1].split( ';' );\n cssTextArrThird.pop();\n let cssNameExists = false;\n for( let j = 0; j < cssTextArrThird.length; j++ ) {\n let cssTextArrFourth = cssTextArrThird[j].split( ':' );\n if( cssTextArrFourth[0] === cssName ) {\n if( cssValue ) {\n cssTextArrThird[j] = cssName + ':' + cssValue;\n } else {\n cssTextArrThird.splice( j, 1 );\n }\n \n cssTextArrSecond[1] = cssTextArrThird.join( ';' ) ? cssTextArrThird.join( ';' ) + ';' : '';\n cssNameExists = true;\n break;\n }\n }\n if( ! cssNameExists ) {\n if( cssValue ) {\n cssTextArrSecond[1] += cssName + ':' + cssValue + ';';\n }\n }\n if( cssTextArrSecond[1] ) {\n cssTextArrFirst[i] = cssTextArrSecond[0] + '{' + cssTextArrSecond[1]\n } else {\n cssTextArrFirst.splice( i, 1 );\n }\n if( cssTextArrFirst.join( '}' ) ) {\n cssForThisElement.innerHTML = cssTextArrFirst.join( '}' ) + '}';\n } else {\n head.removeChild( cssForThisElement );\n }\n \n selectorExists = true;\n break;\n }\n }\n\n if( ! selectorExists ) {\n if( cssValue ) {\n cssForThisElement.innerHTML = cssText + selector + '{' + cssName + ':' + cssValue + ';}';\n } else {\n cssForThisElement.innerHTML = cssText;\n }\n }\n } else {\n if( cssValue ) {\n cssForThisElement.innerHTML = selector + '{' + cssName + ':' + cssValue + ';}';\n } else {\n head.removeChild( cssForThisElement );\n }\n }\n } else {\n if( cssValue ) {\n let cssForThisElement = document.createElement( 'style' );\n cssForThisElement.setAttribute( 'id', 'styles-' + elementContainer );\n cssForThisElement.classList.add( 'styles-wptb-elements' );\n cssForThisElement.innerHTML = selector + '{' + cssName + ':' + cssValue + ';}';\n head.appendChild( cssForThisElement );\n }\n }\n }\n },\n // function for deleting all external CSS for the element\n externalCssStylesDelete: function( elementContainerClass ) {\n let head = document.head;\n if( head ) {\n let cssForThisElement = head.querySelector( '#styles-' + elementContainerClass );\n \n if( cssForThisElement ) {\n head.removeChild( cssForThisElement );\n }\n }\n },\n // function for copy all external CSS for the element\n externalCssStylesCopy: function( activeElement, copyElement ) {\n if( activeElement ) {\n let infArr = activeElement.className.match( /wptb-element-(.+)-(\\d+)/i );\n if( infArr && Array.isArray( infArr ) ) {\n let activeElemClass = infArr[0];\n \n let head = document.head;\n if( head ) {\n let cssForActiveElement = head.querySelector( '#styles-' + activeElemClass );\n\n if( cssForActiveElement ) {\n let cssForNewElement = cssForActiveElement.cloneNode( true );\n \n cssForNewElement.removeAttribute( 'id', 'styles-' + activeElemClass );\n \n let infArrCopyEl = copyElement.className.match( /wptb-element-(.+)-(\\d+)/i );\n if( infArrCopyEl && Array.isArray( infArrCopyEl ) ) {\n cssForNewElement.setAttribute( 'id', 'styles-' + infArrCopyEl[0] );\n let cssForActiveElementInnerHTML = cssForActiveElement.innerHTML;\n let cssForNewElementInnerHTML = WPTB_Helper.replaceAll( cssForActiveElementInnerHTML, activeElemClass, infArrCopyEl[0] );\n cssForNewElement.innerHTML = cssForNewElementInnerHTML;\n head.appendChild( cssForNewElement );\n }\n }\n }\n }\n }\n },\n // function for convertation elements stiles in json\n elementsStylesConvertToObject: function() {\n let head = document.head;\n let stylesElements = head.querySelectorAll( '.styles-wptb-elements' );\n let stylesObj = {};\n for( let i = 0; i < stylesElements.length; i++ ) {\n let styleElemId = stylesElements[i].getAttribute( 'id' );\n if( styleElemId && stylesElements[i].innerHTML ) {\n stylesObj[styleElemId] = stylesElements[i].innerHTML;\n }\n }\n \n if( Object.keys( stylesObj ).length != 0 ) {\n return JSON.stringify( stylesObj );\n }\n return '';\n },\n // function for set scc styles tags to head\n elementsStylesSetFromObject: function( jsonObject ) {\n let head = document.head;\n if( head ) {\n let stylesElements = head.querySelectorAll( '.styles-wptb-elements' );\n if( stylesElements.length > 0 ) {\n stylesElements = [...stylesElements];\n for( let i = 0; i < stylesElements.length; i++ ) {\n head.removeChild( stylesElements[i] );\n }\n }\n if( jsonObject ) {\n let stylesObj = JSON.parse( jsonObject );\n if( Object.keys( stylesObj ).length != 0 ) {\n Object.keys( stylesObj ).forEach( function( key ) {\n let cssText = stylesObj[key];\n let styleCss = document.createElement( 'style' );\n styleCss.setAttribute( 'id', key );\n styleCss.classList.add( 'styles-wptb-elements' );\n styleCss.innerHTML = cssText;\n head.appendChild( styleCss );\n });\n }\n }\n }\n },\n // function for table saving\n saveTable: function( event, startSaving, previewSaving ) {\n if( ! previewSaving && ! startSaving ) {\n if( ( ! event.target.dataset.wptbTableStateNumberSave && window.wptbTableStateNumberShow == 0 ) || \n window.wptbTableStateNumberShow == event.target.dataset.wptbTableStateNumberSave ) {\n //return;\n }\n }\n \n if( ! previewSaving ) {\n let bar = document.querySelector( '.wptb-edit-bar' );\n if ( bar && bar.classList.contains( 'visible' ) ) {\n let table = document.getElementsByClassName( 'wptb-preview-table' )[0];\n table.toggleTableEditMode();\n }\n }\n\n let http = new XMLHttpRequest(),\n url = ( wptb_admin_object ? wptb_admin_object.ajaxurl : ajaxurl ) + \"?action=save_table\",\n t = document.getElementById( 'wptb-setup-name' ).value.trim(),\n messagingArea,\n code,\n datas;\n \n code = document.getElementsByClassName( 'wptb-preview-table' );\n \n let postId;\n if (( rs = WPTB_Helper.detectMode() ) || ( rs = document.wptbId )) {\n postId = rs;\n }\n let paramIdsNecessaryChange = false;\n if( code.length > 0 ) {\n code = code[0];\n let codeClone = code.cloneNode( true );\n if( postId ) {\n if( codeClone.classList.contains( 'wptb-element-main-table_setting-startedid-0' ) ) {\n codeClone.classList.remove( 'wptb-element-main-table_setting-startedid-0' );\n codeClone.classList.add( 'wptb-element-main-table_setting-' + postId );\n paramIdsNecessaryChange = true;\n }\n }\n codeClone.columns = code.columns;\n code = WPTB_Stringifier( codeClone );\n code = code.outerHTML;\n } else { \n code = '';\n }\n \n if( ! previewSaving ) {\n datas = '';\n let datas_containers = document.getElementsByClassName( 'wptb-element-datas' );\n\n if( datas_containers.length > 0 ) {\n if( datas_containers[0].innerHTML ) {\n datas = datas_containers[0].innerHTML;\n\n if( paramIdsNecessaryChange ) {\n datas = WPTB_Helper.replaceAll( datas, 'tmpl-wptb-el-datas-main-table_setting-startedid-0', \n 'tmpl-wptb-el-datas-main-table_setting-' + postId );\n\n datas = WPTB_Helper.replaceAll( datas, 'data-wptb-el-main-table_setting-startedid-0', \n 'data-wptb-el-main-table_setting-' + postId );\n }\n }\n }\n }\n\n let styleObjJson = WPTB_Helper.elementsStylesConvertToObject();\n if( paramIdsNecessaryChange ) {\n styleObjJson = WPTB_Helper.replaceAll( styleObjJson, '.wptb-element-main-table_setting-startedid-0', \n '.wptb-element-main-table_setting-' + postId );\n }\n \n if ( t === '' && code === '' ) {\n let messagingAreaText = '';\n if( t === '' ) messagingAreaText += 'You must assign a name to the table before saving it.</br>';\n if( code === '' ) messagingAreaText += 'Table wasn\\'t created';\n messagingArea = document.getElementById( 'wptb-messaging-area' );\n messagingArea.innerHTML = '<div class=\"wptb-error wptb-message\">Error: ' + messagingAreaText + '</div>';\n messagingArea.classList.add( 'wptb-warning' );\n setTimeout(function () {\n messagingArea.removeChild( messagingArea.firstChild );\n }, 4000 );\n return;\n }\n\n let params = {\n title: t,\n content: code,\n elements_datas: datas,\n elements_styles: styleObjJson,\n security_code: wptb_admin_object.security_code\n };\n \n \n if( previewSaving ) {\n params.preview_saving = previewSaving;\n }\n \n if ( postId ) {\n params.id = postId;\n }\n params = JSON.stringify( params );\n\n http.open('POST', url, true);\n http.setRequestHeader( 'Content-type', 'application/json; charset=utf-8' );\n\n http.onreadystatechange = function ( action ) {\n if ( this.readyState == 4 && this.status == 200 ) {\n var data = JSON.parse( http.responseText );\n messagingArea = document.getElementById( 'wptb-messaging-area' );\n\n if ( data[0] == 'saved' ) {\n console.log(window.wptbTableStateSaving);\n window.history.pushState( null, null, document.location.href.replace( '#', '' ) + '&table=' + data[1] );\n \n WPTB_Helper.saveTable( event, true );\n return;\n } else if( data[0] == 'edited' && startSaving ) {\n document.wptbId = data[1];\n messagingArea.innerHTML = '<div class=\"wptb-success wptb-message\">Table \"' + t + '\" was successfully saved.</div>';\n document.getElementsByClassName( 'wptb-embed-btn' )[0].classList.remove( 'wptb-button-disable' );\n document.getElementById( 'wptb-embed-shortcode' ).value = '[wptb id=' + data[1] + ']';\n let wptbPreviewTable = document.querySelector( '.wptb-preview-table' );\n let wptbPreviewBtn = document.getElementsByClassName( 'wptb-preview-btn' );\n if( wptbPreviewBtn.length > 0 ) {\n wptbPreviewBtn = wptbPreviewBtn[0];\n wptbPreviewBtn.classList.remove( 'wptb-button-disable' );\n let wptbPreviewBtnHref = wptbPreviewBtn.dataset.previewHref;\n wptbPreviewBtnHref = wptbPreviewBtnHref.replace( 'empty', data[1] );\n wptbPreviewBtn.setAttribute( 'href', wptbPreviewBtnHref );\n }\n \n event.target.dataset.wptbTableStateNumberSave = window.wptbTableStateNumberShow;\n let wptbSaveBtn = document.getElementsByClassName( 'wptb-save-btn' );\n if( wptbSaveBtn.length > 0 ) {\n wptbSaveBtn = wptbSaveBtn[0];\n wptbSaveBtn.classList.add( 'wptb-save-disabled' );\n }\n } else if( data[0] == 'edited' ) {\n messagingArea.innerHTML = '<div class=\"wptb-success wptb-message\">Table \"' + t + '\" was successfully updated.</div>';\n event.target.dataset.wptbTableStateNumberSave = window.wptbTableStateNumberShow;\n \n let wptbSaveBtn = document.getElementsByClassName( 'wptb-save-btn' );\n if( wptbSaveBtn.length > 0 ) {\n wptbSaveBtn = wptbSaveBtn[0];\n wptbSaveBtn.classList.add( 'wptb-save-disabled' );\n }\n } else if( data[0] == 'preview_edited' ) {\n return;\n } else {\n messagingArea.innerHTML = '<div class=\"wptb-error wptb-message\">Safety problems</div>';\n }\n messagingArea.classList.add( 'wptb-success' );\n setTimeout( function () {\n messagingArea.removeChild( messagingArea.firstChild );\n }, 4000 );\n }\n }\n http.send( params );\n },\n //\n clickOnFreeSpace: function() {\n document.getElementsByClassName( 'wptb-elements-container' )[0].style.display = 'table';\n document.getElementsByClassName( 'wptb-settings-section' )[0].style.display = 'block';\n document.getElementById( 'element-options-group' ).style.display = 'none';\n let wpcdFixedToolbar = document.getElementById( 'wpcd_fixed_toolbar' );\n if( wpcdFixedToolbar.hasAttribute( 'data-toolbar-active-id' ) ) {\n document.getElementById( wpcdFixedToolbar.getAttribute( 'data-toolbar-active-id' ) ).classList.remove( 'toolbar-active' );\n }\n let element = document.querySelector( '.wptb-preview-table' );\n if( element ) {\n WPTB_Helper.elementOptionsSet( 'table_setting', element );\n }\n },\n // function for sending of element ajax request\n elementAjax: function( dataAjaxData, element ) {\n let http = new XMLHttpRequest(),\n url = ( wptb_admin_object ? wptb_admin_object.ajaxurl : ajaxurl ) + \"?action=wptb_element_ajax\";\n let element_name;\n let infArr = element.className.match( /wptb-element-(.+)-(\\d+)/i );\n if( infArr && Array.isArray( infArr ) ) {\n element_name = infArr[1];\n }\n \n let params = {\n element_ajax_data: dataAjaxData,\n element_name: element_name,\n security_code: wptb_admin_object.security_code\n };\n params = JSON.stringify( params );\n\n http.open( 'POST', url, true );\n http.setRequestHeader( 'Content-type', 'application/json; charset=utf-8' );\n\n http.onreadystatechange = function ( action ) {\n if ( this.readyState == 4 && this.status == 200 ) {\n var data = JSON.parse( http.responseText );\n let detail;\n if ( data && Array.isArray( data ) && data[0] == 'element_ajax_responce' ) {\n detail = {value: data[1]};\n } else {\n detail = '';\n }\n WPTB_Helper.wptbDocumentEventGenerate( 'wptb-element:ajax-response', element, detail );\n }\n }\n http.send( params );\n }\n}\n","var WPTB_Initializer = function () {\n\n const MIN_COLUMNS = 1,\n MIN_ROWS = 1,\n MAX_COLUMNS = 30,\n MAX_ROWS = 30;\n\n var tableGenerator = document.body;\n columnsDecrementButton = tableGenerator.getElementsByClassName('wptb-input-number-decrement')[0],\n columnsIncrementButton = tableGenerator.getElementsByClassName('wptb-input-number-increment')[0],\n rowsDecrementButton = tableGenerator.getElementsByClassName('wptb-input-number-decrement')[1],\n rowsIncrementButton = tableGenerator.getElementsByClassName('wptb-input-number-increment')[1],\n columnsInput = document.getElementById('wptb-columns-number'),\n rowsInput = document.getElementById('wptb-rows-number');\n \n columnsDecrementButton.onclick = function () {\n if (columnsInput.value > MIN_COLUMNS) {\n columnsInput.value--;\n }\n };\n\n columnsIncrementButton.onclick = function () {\n if (columnsInput.value < MAX_COLUMNS) {\n columnsInput.value++;\n }\n };\n\n rowsDecrementButton.onclick = function () {\n if (rowsInput.value > MIN_ROWS) {\n rowsInput.value--;\n }\n };\n\n rowsIncrementButton.onclick = function () {\n if (rowsInput.value < MAX_ROWS) {\n rowsInput.value++;\n }\n };\n\n document.getElementById( 'wptb-generate-table' ).onclick = function ( ) {\n var columns = document.getElementById('wptb-columns-number').value,\n rows = document.getElementById('wptb-rows-number').value;\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n //wptbTableStateSaveManager.tableStateClear();\n \n wptbTableStateSaveManager.tableStateSet( true );\n \n WPTB_Table(columns, rows);\n \n wptbTableStateSaveManager.tableStateSet();\n }\n\n};\n","var WPTB_LeftPanel = function () {\n\n var table = document.getElementsByClassName('wptb-preview-table')[0],\n wptbElementButtons = document.getElementsByClassName('wptb-element');\n \n let wptbTableColumnWidthNumber = document.getElementById( 'wptb-table-column-width-number' );\n WPTB_Helper.numberImputSize( wptbTableColumnWidthNumber, 2, 500 );\n \n let wptbTableRowHeightNumber = document.getElementById( 'wptb-table-row-height-number' );\n WPTB_Helper.numberImputSize( wptbTableRowHeightNumber, 2, 200 );\n \n document.getElementById( 'wptb-table-column-width-slider' ).oninput = function () {\n document.getElementById( 'wptb-table-column-width-number' ).value = this.value;\n table.addColumnWidth( this.value );\n };\n \n document.getElementById( 'wptb-table-column-width-slider' ).onchange = function () {\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n \n document.getElementById( 'wptb-table-column-width-number' ).onchange = function () {\n document.getElementById( 'wptb-table-column-width-slider' ).value = this.value;\n table.addColumnWidth( this.value );\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n \n document.getElementById( 'wptb-table-column-width-auto-fixed' ).onchange = function () {\n if( this.checked ) {\n let highlighted = table.querySelector( '.wptb-highlighted' );\n let width = WPTB_Helper.getColumnWidth( table, highlighted );\n table.addColumnWidth( width );\n } else {\n table.addColumnWidth( false, true );\n let highlighted = table.querySelector( '.wptb-highlighted' );\n let width = WPTB_Helper.getColumnWidth( table, highlighted );\n document.getElementById( 'wptb-table-column-width-number' ).value = width;\n document.getElementById( 'wptb-table-column-width-slider' ).value = width;\n }\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n document.getElementById( 'wptb-table-row-height-slider' ).oninput = function () {\n document.getElementById( 'wptb-table-row-height-number' ).value = this.value;\n table.addRowHeight( this.value );\n };\n \n document.getElementById( 'wptb-table-row-height-slider' ).onchange = function () {\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n document.getElementById( 'wptb-table-row-height-number' ).onchange = function () {\n document.getElementById( 'wptb-table-row-height-slider' ).value = this.value;\n table.addRowHeight( this.value );\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n \n document.getElementById( 'wptb-table-row-height-auto-fixed' ).onchange = function () {\n if( this.checked ) {\n let highlighted = table.querySelector( '.wptb-highlighted' );\n let height = WPTB_Helper.getRowHeight( table, highlighted );\n table.addRowHeight( height );\n } else {\n table.addRowHeight( false, true );\n let highlighted = table.querySelector( '.wptb-highlighted' );\n let height = WPTB_Helper.getRowHeight( table, highlighted );\n document.getElementById( 'wptb-table-row-height-number' ).value = height;\n document.getElementById( 'wptb-table-row-height-slider' ).value = height;\n }\n \n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n \n function controlsChange( inputs, table ) {\n if( inputs && typeof inputs === 'object' ) {\n if( inputs.hasOwnProperty( 'tableTopRowsAsHeader' ) ) {\n if( inputs.tableTopRowsAsHeader == 'checked' ) {\n let rows = table.rows;\n table.classList.add( 'wptb-table-preview-head' );\n } else if( inputs.tableTopRowsAsHeader == 'unchecked' ) {\n let rows = table.rows;\n table.classList.remove( 'wptb-table-preview-head' );\n\n for ( let i = 1; i < rows.length; i++ ) {\n let thisRow = rows[i],\n thisRowChildren = thisRow.children;\n for( let j = 0; j < thisRowChildren.length; j++ ) {\n thisRowChildren[j].removeAttribute( 'data-wptb-title-column' );\n thisRowChildren[j].removeAttribute( 'data-wptb-title-column-font-size' );\n thisRowChildren[j].removeAttribute( 'data-wptb-title-column-color' );\n thisRowChildren[j].removeAttribute( 'data-wptb-title-background-color' );\n thisRowChildren[j].removeAttribute( 'data-wptb-title-align' );\n }\n }\n }\n } else if( inputs.hasOwnProperty( 'makeTableResponsive' ) ) {\n if( inputs.makeTableResponsive == 'checked' ) {\n table.dataset.wptbAdaptiveTable = 1;\n } else if( inputs.makeTableResponsive == 'unchecked' ) {\n table.dataset.wptbAdaptiveTable = 0;\n }\n } else if( inputs.hasOwnProperty( 'tableManageCells' ) ) {\n table.toggleTableEditMode();\n }\n } \n }\n\n WPTB_Helper.controlsInclude( table, controlsChange );\n\n for (var i = 0; i < wptbElementButtons.length; i++) {\n wptbElementButtons[i].ondragstart = function (e) {\n e.dataTransfer.setData('wptbElement', this.dataset.wptbElement);\n e.dataTransfer.setData( 'wptbElIndic-' + this.dataset.wptbElement, 'wptbElIndic-' + this.dataset.wptbElement );\n }\n };\n \n if( table ) {\n document.getElementById( 'wptb-table-edit-mode-close' ).onclick = table.toggleTableEditMode;\n document.getElementById( 'wptb-left-scroll-panel-curtain-close' ).onclick = table.toggleTableEditMode;\n document.getElementById('wptb-add-end-row').onclick = table.addRowToTheEnd;\n document.getElementById('wptb-add-start-row').onclick = table.addRowToTheStart;\n document.getElementById('wptb-add-row-before').onclick = table.addRowBefore;\n document.getElementById('wptb-add-row-after').onclick = table.addRowAfter;\n document.getElementById('wptb-add-end-column').onclick = table.addColumnEnd;\n document.getElementById('wptb-add-start-column').onclick = table.addColumnStart;\n document.getElementById('wptb-add-column-before').onclick = table.addColumnBefore;\n document.getElementById('wptb-add-column-after').onclick = table.addColumnAfter;\n document.getElementById('wptb-delete-column').onclick = table.deleteColumn;\n document.getElementById('wptb-delete-row').onclick = table.deleteRow;\n document.getElementById('wptb-merge-cells').onclick = table.mergeCells;\n document.getElementById('wptb-split-cell').onclick = table.splitCell;\n };\n \n document.querySelector( '.wptb-left-panel-extend' ).onclick = function() {\n let wptbContainer = document.querySelector( '.wptb-container' );\n if( wptbContainer ) {\n if ( wptbContainer.classList.contains( 'collapsed' ) ) {\n wptbContainer.classList.remove( 'collapsed' );\n } else {\n wptbContainer.classList.add( 'collapsed' );\n }\n }\n };\n \n // this code hides the \"element parameters\" area \n // when clicked outside this element and its \"tinymce\" toolbar \n let wptbBuilderPanel = document.getElementsByClassName( 'wptb-builder-panel' )[0];\n wptbBuilderPanel.onclick = function( e ) {\n if( ! e.target.classList.contains( 'wptb-ph-element' ) && ! WPTB_Helper.findAncestor( e.target, 'wptb-ph-element' ) && \n ! e.target.classList.contains( 'wptb-fixed-toolbar' ) && ! WPTB_Helper.findAncestor( e.target, 'wptb-fixed-toolbar' ) ) {\n WPTB_Helper.clickOnFreeSpace();\n } \n };\n \n let wptbHeader = document.getElementsByClassName( 'wptb-header' );\n if( wptbHeader.length > 0 ) wptbHeader = wptbHeader[0];\n wptbHeader.onclick = function() {\n WPTB_Helper.clickOnFreeSpace();\n };\n};","var MultipleSelect = function () {\n\n\tvar selectedCells = [],\n\t\tmultipleCellMode = false;\n\n\tthis.activateMultipleSelectMode = function () {\n\t\tselectedCells = [];\n\t\tvar tds = document.getElementsByClassName('wptb-preview-table')[0].getElementsByTagName('td');\n\t\tfor (var i = 0; i < tds.length; i++) {\n\t\t\ttds[i].classList.remove('wptb-highlighted');\n\t\t}\n\t\tmultipleCellMode = true;\n\t}\n\n\tthis.deactivateMultipleSelectMode = function () {\n\t\tmultipleCellMode = false;\n\t}\n\n\tthis.isActivated = function () {\n\t\treturn multipleCellMode;\n\t}\n\n\tthis.pushSelectedCell = function (cell) {\n\t\tif (!multipleCellMode) {\n\t\t\treturn;\n\t\t}\n\t\tselectedCells.push(cell);\n\t\tcell.classList.add('wptb-highlighted');\n\t};\n\n\tthis.selectedCells = function () {\n\t\treturn selectedCells;\n\t}\n\n\tthis.flushSelectedCells = function () {\n\t\tselectedCells = [];\n\t}\n\n\tthis.getFirst = function () {\n\t\tvar minXIndex = 1000, minYIndex = 1000, first;\n\t\tfor (var i = selectedCells.length - 1; i >= 0; i--) {\n\t\t\tif (minXIndex >= selectedCells[i].dataset.xIndex\n\t\t\t\t&& minYIndex >= selectedCells[i].dataset.yIndex) {\n\t\t\t\tfirst = selectedCells[i];\n\t\t\t\tminXIndex = selectedCells[i].dataset.xIndex;\n\t\t\t\tminYIndex = selectedCells[i].dataset.yIndex;\n\t\t\t}\n\t\t}\n\t\treturn first;\n\t}\n\n\tthis.getLast = function () {\n\t\tvar maxXIndex = -1, maxYIndex = -1, last;\n\t\tfor (var i = selectedCells.length - 1; i >= 0; i--) {\n\t\t\tif (maxXIndex <= selectedCells[i].dataset.xIndex\n\t\t\t\t&& maxYIndex <= selectedCells[i].dataset.yIndex) {\n\t\t\t\tlast = selectedCells[i];\n\t\t\t\tmaxXIndex = selectedCells[i].dataset.xIndex;\n\t\t\t\tmaxYIndex = selectedCells[i].dataset.yIndex;\n\t\t\t}\n\t\t}\n\t\treturn last;\n\t}\n\n\tthis.removeAllButFirst = function () {\n\t\tvar td = this.getFirst();\n\t\tfor (var i = 1; i < selectedCells.length; i++) {\n\t\t\tselectedCells[i].classList.add('wptb-fused-cell-' + td.dataset.xIndex + '-' + td.dataset.yIndex);\n\t\t}\n\t}\n\n\treturn this;\n\n};","var WPTB_Parser = function ( code ) {\n let div = document.createElement( 'div' );\n div.innerHTML = code;\n \n let table = div.children[0];\n let columnTitleMobile = [...table.querySelectorAll( '.wptb-column-title-mobile-container' )];\n \n for( let i = 0; i < columnTitleMobile.length; i++ ) {\n let parent = columnTitleMobile[i].parentNode;\n parent.removeChild( columnTitleMobile[i] );\n }\n \n let tds = table.querySelectorAll( 'td' );\n for ( let i = 0; i < tds.length; i++ ) {\n tds[i].classList.add( 'wptb-droppable' );\n tds[i].classList.remove( 'wptb-column-title-mobile-not-elements' );\n }\n \n return table;\n}","// From https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys\nif (!Object.keys) {\n Object.keys = (function () {\n 'use strict';\n var hasOwnProperty = Object.prototype.hasOwnProperty,\n hasDontEnumBug = !({toString: null}).propertyIsEnumerable('toString'),\n dontEnums = [\n 'toString',\n 'toLocaleString',\n 'valueOf',\n 'hasOwnProperty',\n 'isPrototypeOf',\n 'propertyIsEnumerable',\n 'constructor'\n ],\n dontEnumsLength = dontEnums.length;\n\n return function (obj) {\n if (typeof obj !== 'object' && (typeof obj !== 'function' || obj === null)) {\n throw new TypeError('Object.keys called on non-object');\n }\n\n var result = [], prop, i;\n\n for (prop in obj) {\n if (hasOwnProperty.call(obj, prop)) {\n result.push(prop);\n }\n }\n\n if (hasDontEnumBug) {\n for (i = 0; i < dontEnumsLength; i++) {\n if (hasOwnProperty.call(obj, dontEnums[i])) {\n result.push(dontEnums[i]);\n }\n }\n }\n return result;\n };\n }());\n}","var WPTB_Settings = function () {\n var elems = document.getElementsByClassName('wptb-element');\n\n for ( var i = 0; i < elems.length; i++ ) {\n elems[i].ondragstart = function ( event ) {\n event.dataTransfer.effectAllowed = 'move';\n event.dataTransfer.setData( 'wptbElement', event.target.dataset.wptbElement );\n event.dataTransfer.setData( 'wptbElIndic-' + event.target.dataset.wptbElement, 'wptbElIndic-' + event.target.dataset.wptbElement );\n }\n elems[i].ondragend = function () {\n WPTB_Helper.elementDragEndClear();\n }\n };\n let table = document.getElementsByClassName( 'wptb-preview-table' );\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n let wptbUndo = document.getElementsByClassName( 'wptb-undo' );\n if( wptbUndo.length > 0 ) {\n wptbUndo = wptbUndo[0];\n \n wptbUndo.onclick = function( event ) {\n if( ! this.classList.contains( 'wptb-undoredo-disabled' ) ) {\n wptbTableStateSaveManager.tableStateGet( this.dataset.wptbUndoredo );\n let wptbUndoRedoContainer = document.getElementsByClassName( 'wptb-undo-redo-container' );\n if( wptbUndoRedoContainer.length > 0 && table.length > 0 ) {\n wptbUndoRedoContainer = wptbUndoRedoContainer[0];\n wptbUndoRedoContainer.onmouseleave = function( event ) {\n event.target.onmouseleave = '';\n WPTB_Table();\n }\n }\n }\n \n }\n }\n \n let wptbRedo = document.getElementsByClassName( 'wptb-redo' );\n if( wptbRedo.length > 0 ) {\n wptbRedo = wptbRedo[0];\n \n wptbRedo.onclick = function( event ) {\n if( ! this.classList.contains( 'wptb-undoredo-disabled' ) ) {\n wptbTableStateSaveManager.tableStateGet( this.dataset.wptbUndoredo );\n let wptbUndoRedoContainer = document.getElementsByClassName( 'wptb-undo-redo-container' );\n if( wptbUndoRedoContainer.length > 0 && table.length > 0 ) {\n wptbUndoRedoContainer = wptbUndoRedoContainer[0];\n wptbUndoRedoContainer.onmouseleave = function( event ) {\n event.target.onmouseleave = '';\n WPTB_Table();\n }\n }\n }\n \n }\n }\n \n let shortcodePopupWindow = document.getElementsByClassName( 'wptb-popup-window-modal' )[0];\n document.getElementsByClassName( 'wptb-embed-btn' )[0].onclick = function () {\n if( ! this.classList.contains( 'wptb-button-disable' ) ) {\n shortcodePopupWindow.classList.add( 'wptb-popup-show' );\n }\n }\n \n window.onbeforeunload = function(e) {\n let wptbSaveDisabled = document.getElementsByClassName( 'wptb-save-disabled' );\n if( wptbSaveDisabled.length == 0 ) {\n return true;\n } else {\n return null;\n }\n };\n \n \n document.getElementsByClassName( 'wptb-popup-dark-area' )[0].onclick = function () {\n shortcodePopupWindow.classList.remove( 'wptb-popup-show' );\n }\n \n document.getElementsByClassName( 'wptb-popup-window-close-icon' )[0].onclick = function () {\n shortcodePopupWindow.classList.remove( 'wptb-popup-show' );\n }\n \n document.getElementsByClassName( 'wptb-preview-btn' )[0].onclick = function ( event ) {\n if( this.classList.contains( 'wptb-button-disable' ) ) {\n return;\n } \n \n let previewId = Math.floor( Math.random() * 10000 );\n \n var newHref = new URL( event.target.href );\n newHref.searchParams.set( 'preview_id', previewId );\n event.target.href = newHref.toString();\n WPTB_Helper.saveTable( event, false, previewId );\n }\n\n document.getElementsByClassName( 'wptb-save-btn' )[0].onclick = function ( event ) {\n if( ! this.classList.contains( 'wptb-save-disabled' ) ) {\n WPTB_Helper.saveTable( event );\n }\n }\n};\n","var WPTB_Stringifier = function ( codeMain ) {\n if ( codeMain ) {\n let code = codeMain.cloneNode( true );\n code.classList.add( 'wptb-table-preview-static-indic' );\n code.dataset.tableColumns = codeMain.columns;\n code.style.width = null;\n code.style.minWidth = null;\n code.style.maxWidth = null;\n \n let tds = code.getElementsByTagName( 'td' );\n if ( tds.length > 0 ) {\n for ( let i = 0; i < tds.length; i++ ) {\n \n if ( codeMain.querySelector( 'wptb-table-preview-head' ) ) {\n tds[i].removeAttribute( 'data-x-index' );\n }\n tds[i].removeAttribute( 'data-y-index' );\n tds[i].removeAttribute( 'draggable' );\n tds[i].classList.remove( 'wptb-droppable' );\n let innerElements = tds[i].getElementsByClassName( 'wptb-ph-element' );\n \n if ( innerElements.length > 0 ) {\n for ( let j = 0; j < innerElements.length; j++ ) {\n \n let mceContentBodys = innerElements[j].querySelectorAll( '.mce-content-body' );\n if( mceContentBodys.length > 0 ) {\n for ( let k = 0; k < mceContentBodys.length; k++ ) {\n mceContentBodys[k].classList.remove( 'mce-content-body' );\n }\n }\n \n let dataMceStyle = innerElements[j].querySelectorAll( '[data-mce-style]' );\n if ( dataMceStyle.length > 0 ) {\n for ( let k = 0; k < dataMceStyle.length; k++ ) {\n dataMceStyle[k].removeAttribute( 'data-mce-style' );\n }\n }\n \n let contentEditable = innerElements[j].querySelectorAll( '[contenteditable]' );\n if ( contentEditable.length > 0 ) {\n for ( let k = 0; k < contentEditable.length; k++ ) {\n contentEditable[k].removeAttribute( 'contenteditable' );\n }\n }\n \n let spellCheck = innerElements[j].querySelectorAll( '[spellcheck]' );\n if ( spellCheck.length > 0 ) {\n for ( let k = 0; k < spellCheck.length; k++ ) {\n spellCheck[k].removeAttribute( 'spellcheck' );\n }\n }\n \n let mceIds = innerElements[j].querySelectorAll( '[id^=mce_]' );\n if ( mceIds.length > 0 ) {\n for ( let k = 0; k < mceIds.length; k++ ) {\n mceIds[k].removeAttribute( 'id' );\n }\n }\n \n let wptbActions = innerElements[j].querySelectorAll( '.wptb-actions' );\n let wptbActionsLength = wptbActions.length;\n while ( wptbActionsLength > 0 ) {\n if( wptbActions[0] && wptbActions[0].parentNode ) {\n wptbActions[0].parentNode.removeChild( wptbActions[0] );\n wptbActionsLength--;\n } else {\n break;\n }\n \n } \n \n let dataMceBogus = innerElements[j].querySelectorAll( '[data-mce-bogus]' );\n if( dataMceBogus.length > 0 ) {\n dataMceBogus = [...dataMceBogus];\n for( let k = 0; k < dataMceBogus.length; k++ ) {\n if( dataMceBogus[k] && dataMceBogus[k].parentNode ) {\n dataMceBogus[k].parentNode.removeChild( dataMceBogus[k] );\n }\n }\n }\n }\n }\n \n if( tds[i].hasAttribute( 'data-wptb-title-column' ) ) {\n let columnNameDivContainer = document.createElement( 'div' ),\n columnNameDiv = document.createElement( 'div' );\n columnNameDivContainer.classList.add( 'wptb-column-title-mobile-container' );\n columnNameDiv.classList.add( 'wptb-column-title-mobile' );\n columnNameDiv.dataset.wptbTitleColumn = tds[i].dataset.wptbTitleColumn;\n columnNameDiv.setAttribute( 'style', 'font-size:' + tds[i].dataset.wptbTitleColumnFontSize + '; \\n\\\n color:' + tds[i].dataset.wptbTitleColumnColor + '; background-color:' + tds[i].dataset.wptbTitleBackgroundColor + '; text-align:' + tds[i].dataset.wptbTitleAlign + ';' );\n columnNameDiv.style.padding = tds[i].style.padding;\n if( tds[i].children.length == 0 ) {\n tds[i].classList.add( 'wptb-column-title-mobile-not-elements' );\n }\n columnNameDivContainer.appendChild( columnNameDiv );\n tds[i].insertBefore( columnNameDivContainer, tds[i].firstChild );\n }\n }\n }\n \n return code;\n }\n}","var array = [], WPTB_Table = function (columns, rows) {\n\n /* The members of the class */\n var settings = document.getElementsByClassName('wptb-settings-items'),\n wptbTableSetup = document.getElementsByClassName(\"wptb-table-setup\")[0],\n table, row, cell,\n maxAmountOfCells,\n maxAmountOfRows;\n\n //HERE ARE THE PRIVATE FUNCTIONS\n /*\n * This function toggles buttons visibility in cell edit mode\n * (according to the amount of currently selected cells), and\n * highlights visually the clicked cell if it is not highlighted, or\n * removes highlight if clicked cell is already highlighted. \n * It too toggles the bits of our abstract representation.\n * @param Event this is the event instance of the click performed over a cell.\n */\n var mark = function ( event ) {\n var rs = this.rowSpan,\n cs = this.colSpan,\n markedCells,\n noCells = document.getElementsByClassName('wptb-no-cell-action'),\n singleCells = document.getElementsByClassName('wptb-single-action'),\n multipleCells = document.getElementsByClassName('wptb-multiple-select-action'),\n cellSettings = document.getElementById( 'wptb-left-scroll-panel-cell-settings' ),\n position = getCoords(this),\n row = position[0],\n column = position[1];\n if ( ! document.select.isActivated() ) {\n return;\n }\n if (this.className.match(/wptb-highlighted/)) {\n this.classList.remove('wptb-highlighted');\n for (var i = 0; i < rs; i++) {\n for (var j = 0; j < cs; j++) {\n array[row + i][column + j] = 0;\n }\n }\n } else {\n this.classList.add('wptb-highlighted');\n for (var i = 0; i < rs; i++) {\n for (var j = 0; j < cs; j++) {\n array[row + i][column + j] = 1;\n }\n }\n }\n\n markedCells = document.getElementsByClassName('wptb-highlighted').length;\n if (markedCells === 0) {\n for (var i = 0; i < multipleCells.length; i++) {\n multipleCells[i].classList.remove('visible');\n multipleCells[i].setAttribute('disabled', 'disabled');\n }\n for (var i = 0; i < noCells.length; i++) {\n noCells[i].classList.add('visible');\n noCells[i].removeAttribute('disabled');\n }\n for (var i = 0; i < singleCells.length; i++) {\n singleCells[i].classList.remove('visible');\n singleCells[i].setAttribute('disabled', 'disabled');\n }\n cellSettings.classList.remove( 'visible' );\n } else if (markedCells === 1) {\n for (var i = 0; i < multipleCells.length; i++) {\n multipleCells[i].classList.remove('visible');\n multipleCells[i].setAttribute('disabled', 'disabled');\n }\n for (var i = 0; i < noCells.length; i++) {\n noCells[i].classList.remove('visible');\n noCells[i].setAttribute('disabled', 'disabled');\n }\n for (var i = 0; i < singleCells.length; i++) {\n singleCells[i].classList.add('visible');\n singleCells[i].removeAttribute('disabled');\n }\n let cellHighlighted = document.querySelector( '.wptb-highlighted' );\n if( cellHighlighted ) {\n let wptbTableColumnWidthSlider = document.getElementById( 'wptb-table-column-width-slider' );\n let wptbTableColumnWidthNumber = document.getElementById( 'wptb-table-column-width-number' );\n let tableColumnWidthAutoFixedCheckbox = document.getElementById( 'wptb-table-column-width-auto-fixed' );\n let width = cellHighlighted.style.width;\n if( width ) {\n wptbTableColumnWidthSlider.value = parseFloat( width, 10 );\n wptbTableColumnWidthNumber.value = parseFloat( width, 10 );\n tableColumnWidthAutoFixedCheckbox.checked = true;\n } else if( cellHighlighted.dataset.wptbFixedWidth ) {\n wptbTableColumnWidthSlider.value = cellHighlighted.dataset.wptbFixedWidth;\n wptbTableColumnWidthNumber.value = cellHighlighted.dataset.wptbFixedWidth;\n tableColumnWidthAutoFixedCheckbox.checked = true;\n } else {\n let cellWidth = WPTB_Helper.getColumnWidth( table, cellHighlighted );\n wptbTableColumnWidthSlider.value = cellWidth;\n wptbTableColumnWidthNumber.value = cellWidth;\n tableColumnWidthAutoFixedCheckbox.checked = false;\n }\n \n \n let wptbTableRowHeightSlider = document.getElementById( 'wptb-table-row-height-slider' );\n let wptbTableRowHeightNumber = document.getElementById( 'wptb-table-row-height-number' );\n let tableRowHeightAutoFixedCheckbox = document.getElementById( 'wptb-table-row-height-auto-fixed' );\n let height = cellHighlighted.style.height;\n if( height ) {\n wptbTableRowHeightSlider.value = parseFloat( height, 10 );\n wptbTableRowHeightNumber.value = parseFloat( height, 10 );\n tableRowHeightAutoFixedCheckbox.checked = true;\n } else if( cellHighlighted.dataset.wptbFixedHeight ) {\n wptbTableRowHeightSlider.value = cellHighlighted.dataset.wptbFixedHeight;\n wptbTableRowHeightNumber.value = cellHighlighted.dataset.wptbFixedHeight;\n tableRowHeightAutoFixedCheckbox.checked = true;\n } else {\n let cellHeight = WPTB_Helper.getRowHeight( table, cellHighlighted );\n wptbTableRowHeightSlider.value = cellHeight;\n wptbTableRowHeightNumber.value = cellHeight;\n tableRowHeightAutoFixedCheckbox.checked = false;\n }\n }\n cellSettings.classList.add( 'visible' );\n } else {\n for (var i = 0; i < multipleCells.length; i++) {\n if (table.isSquare(array)) {\n multipleCells[i].classList.add('visible');\n multipleCells[i].removeAttribute('disabled');\n } else {\n multipleCells[i].classList.remove('visible');\n multipleCells[i].setAttribute('disabled', 'disabled');\n }\n }\n for (var i = 0; i < noCells.length; i++) {\n noCells[i].classList.remove('visible');\n noCells[i].setAttribute('disabled', 'disabled');\n }\n for (var i = 0; i < singleCells.length; i++) {\n singleCells[i].classList.remove('visible');\n singleCells[i].setAttribute('disabled', 'disabled');\n }\n cellSettings.classList.remove( 'visible' );\n }\n };\n\n /* \n * This function fills an array with 1's according to the actual design\n * of HTML table.\n * @returns an array of arrays containing an abstract representation\n * of HTML table.\n * @deprecated\n * */\n\n var realTimeArray = function () {\n var carried = [], tds, cols, matriz = [];\n\n for (var i = 0; i < maxAmountOfCells; i++) {\n carried[i] = 0;\n }\n\n for (var i = 0; i < table.rows.length; i++) {\n cols = [];\n\n var tds = table.rows[i].getElementsByTagName('td');\n\n for (items = 0; items < tds.length; items++) {\n\n for (var k = 0; k < tds[items].colSpan; k++) {\n cols.push(1);\n }\n\n if (tds[items].rowSpan > 1) {\n for (var k = 0; k < tds[items].colSpan; k++) {\n carried[items + k] = {\n justAssigned: true,\n amount: tds[items].rowSpan\n };\n }\n }\n }\n\n for (var k = 0; k < maxAmountOfCells; k++) {\n if (typeof carried[k] == 'object' && carried[k].amount > 0) {\n carried[k].amount--;\n if (carried[k].justAssigned) {\n carried[k].justAssigned = false;\n } else {\n cols.push(1);\n }\n }\n }\n\n matriz.push(cols);\n\n }\n return matriz;\n };\n\n /*\n * This function gets the number and position of cell spaces in current row that are occuped \n * by upper rowspanned cells.\n * @param number the number of row where we wish to calculate the carried rowspans up to.\n * @return an array with the remaining rowspans in each column.\n */\n var carriedRowspans = function (row) {\n var carried = [], tds, cols;\n\n for (var i = 0; i < maxAmountOfCells; i++) {\n carried[i] = 0;\n }\n\n if (row == -1) {\n return carried;\n }\n\n for (var i = 0; i <= row; i++) {\n cellsBuffer = table.rows[i].getElementsByTagName('td');\n cellPointer = 0;\n\n for (var xPosition = 0; xPosition < maxAmountOfCells; xPosition += stepsToMove) {\n stepsToMove = 1;\n\n if (carried[xPosition]) {\n carried[xPosition]--;\n } else {\n celda = cellsBuffer[cellPointer++];\n if (celda.rowSpan > 1) {\n for (k = 0; k < celda.colSpan; k++) {\n carried[xPosition + k] = celda.rowSpan - 1;\n }\n stepsToMove = celda.colSpan;\n } else if (celda.colSpan > 1) {\n stepsToMove = celda.colSpan;\n }\n }\n }\n\n }\n return carried;\n };\n\n /*\n * A helpful function for showing\n * the abstract table in console.\n * @param Array our abstract table.\n */\n var drawTable = function (a) {\n var string = 'DRAWING TABLE:\\n';\n for (var i = 0; i < a.length; i++) {\n\n for (var j = 0; j < a[i].length; j++) {\n string += ' ' + a[i][j];\n }\n string += '\\n';\n }\n table.isSquare(a);\n };\n\n /*\n * It resets all the bits of our abstract representation\n * to 0 and removes the highlighting class of all cells.\n */\n\n var undoSelect = function () {\n var noCells = document.getElementsByClassName('wptb-no-cell-action'),\n singleCells = document.getElementsByClassName('wptb-single-action'),\n multipleCells = document.getElementsByClassName('wptb-multiple-select-action'),\n cellSettings = document.getElementById( 'wptb-left-scroll-panel-cell-settings' ),\n tds = table.getElementsByClassName('wptb-highlighted');\n while (tds.length) {\n tds[0].classList.remove('wptb-highlighted');\n }\n cellSettings.classList.remove( 'visible' );\n for (var i = 0; i < array.length; i++) {\n for (var j = 0; j < array[i].length; j++) {\n array[i][j] = 0;\n }\n }\n for (var i = 0; i < multipleCells.length; i++) {\n multipleCells[i].classList.remove('visible');\n multipleCells[i].setAttribute('disabled', 'disabled');\n }\n for (var i = 0; i < noCells.length; i++) {\n noCells[i].classList.add('visible');\n noCells[i].removeAttribute('disabled');\n }\n for (var i = 0; i < singleCells.length; i++) {\n singleCells[i].classList.remove('visible');\n singleCells[i].setAttribute('disabled', 'disabled');\n }\n };\n\n /*\n * This fills the abstract representation of our table with \n * zeros, at the start. the max amount of cells is the greatest sum\n * of all colspans for row.\n */\n\n var fillTableArray = function () {\n var colspansSums = [], a = [];\n\n //calculate max amount of cells inside a row\n for (var i = 0; i < table.rows.length; i++) {\n var cells = table.rows[i].getElementsByTagName('td'),\n colspanSumInRow = 0;\n for (var j = 0; j < cells.length; j++) {\n colspanSumInRow += cells[j].colSpan;\n }\n colspansSums.push(colspanSumInRow);\n }\n\n maxAmountOfCells = Math.max.apply(null, colspansSums);\n //calculate max rows\n var maxAmountOfRows = table.rows.length;\n\n // fill with zeros from both values\n for (var i = 0; i < maxAmountOfRows; i++) {\n a[i] = [];\n for (var j = 0; j < maxAmountOfCells; j++) {\n a[i].push(0);\n }\n }\n drawTable(a);\n return a;\n };\n\n /*\n * This function gets the sum of all colspans in a row.\n * @param number the number of row to be used as reference.\n */\n var getActualPointsInRow = function (row) {\n var tds = table.rows[row].getElementsByTagName('td'),\n points = 0;\n for (var i = 0; i < tds.length; i++) {\n points += tds[i].colSpan;\n }\n return points;\n }\n\n /*\n * This function gets us the exact coordinates of\n * an exact cell, in a more reliable way than xIndex and yIndex,\n * these last ones were meant to be used for getting the cell trough them.\n * @param DOMElement the cell to get the coordinates.\n */\n var getCoords = function (search) {\n var skipInCols = [], cell;\n\n for (var i = 0; i < maxAmountOfCells; i++) {\n skipInCols[i] = 0;\n }\n\n for (var i = 0; i < table.rows.length; i++) {\n var cellsBuffer = table.rows[i].getElementsByTagName('td');\n cellPointer = 0;\n for (var xPosition = 0; xPosition < maxAmountOfCells; xPosition += stepsToMove) {\n stepsToMove = 1;\n\n if (skipInCols[xPosition]) {\n skipInCols[xPosition]--;\n } else {\n var td = cellsBuffer[cellPointer++];\n if (td == search) {\n return [i, xPosition];\n }\n if (td.rowSpan > 1) {\n for ( let k = 0; k < td.colSpan; k++ ) {\n skipInCols[xPosition + k] = td.rowSpan - 1;\n }\n stepsToMove = td.colSpan;\n } else if (td.colSpan > 1) {\n stepsToMove = td.colSpan;\n }\n }\n }\n }\n };\n\n jQuery('#wptb-table-border-color').val('');\n jQuery('#wptb-table-padding-number,#wptb-table-padding-slider').val('15');\n\n if (columns || rows) {\n //END OF PRIVATE FUNCTIONS\n for (var i = 0; i < settings.length; i++) {\n if (settings[i].id !== 'wptb-apply-inner-border') {\n settings[i].classList.add('visible');\n }\n }\n\n //Create a HTML Table element.\n table = document.createElement( 'table' );\n table.classList.add( 'wptb-preview-table', 'wptb-element-main-table_setting-startedid-0' );\n table.style.border = '0px solid';\n table.dataset.reconstraction = 1;\n table.dataset.wptbAdaptiveTable = 1;\n //Add the data rows.\n for (var i = 0; i < rows; i++) {\n\n row = table.insertRow(-1);\n row.classList.add( 'wptb-row' );\n\n for (var j = 0; j < columns; j++) {\n cell = new WPTB_Cell(mark);\n cell.setCoords(i, j);\n cell.getDOMElement().style.borderWidth = '1px';\n row.appendChild(cell.getDOMElement());\n }\n }\n } else {\n let wptb_preview_table = document.getElementsByClassName( 'wptb-preview-table' );\n\n if (wptb_preview_table.length > 0) {\n table = wptb_preview_table[0];\n\n let cells = table.getElementsByTagName('td');\n\n if (cells.length > 0) {\n for (let i = 0; i < cells.length; i++) {\n WPTB_Cell(mark, cells[i]);\n }\n }\n } else {\n return;\n }\n }\n\n /*\n * This just toggles visibility of cell edit bar, and toggles \n * cell selecting mode.\n */\n\n table.toggleTableEditMode = function () {\n let bar = document.getElementsByClassName('wptb-edit-bar'),\n cellModeBackground = document.getElementById('wptb-cell_mode_background'),\n leftScrollPanelCurtain = document.getElementById('wptb-left-scroll-panel-curtain'),\n leftScrollPanelCellSettings = document.getElementById( 'wptb-left-scroll-panel-cell-settings' ),\n wptbPreviewTable = document.getElementsByClassName('wptb-preview-table');\n if (wptbPreviewTable.length > 0) {\n wptbPreviewTable = wptbPreviewTable[0];\n }\n\n if ( bar.length > 0 ) {\n for ( let i = 0; i < bar.length; i++ ) {\n if ( bar[i].classList.contains( 'visible' ) ) {\n document.select.deactivateMultipleSelectMode();\n bar[i].classList.remove( 'visible' );\n cellModeBackground.classList.remove( 'visible' );\n leftScrollPanelCurtain.classList.remove( 'visible' );\n leftScrollPanelCellSettings.classList.remove( 'visible' );\n wptbPreviewTable.parentNode.classList.remove( 'wptb-preview-table-manage-cells' );\n let wptbPreviewTableTds = wptbPreviewTable.getElementsByTagName( 'td' );\n if ( wptbPreviewTableTds.length > 0 ) {\n for ( let i = 0; i < wptbPreviewTableTds.length; i++ ) {\n wptbPreviewTableTds[i].classList.remove( 'wptb-highlighted' );\n }\n }\n } else {\n document.select.activateMultipleSelectMode();\n bar[i].classList.add( 'visible' );\n cellModeBackground.classList.add( 'visible' );\n leftScrollPanelCurtain.classList.add( 'visible' );\n wptbPreviewTable.parentNode.classList.add( 'wptb-preview-table-manage-cells' );\n }\n }\n\n }\n }\n\n /*\n * For assigning to each cell xIndex and y Index attributes,\n * these are the column number and row number of cell in table. \n */\n\n table.recalculateIndexes = function ( start ) {\n let trs = this.getElementsByTagName('tr'), tds, maxCols = 0, maxColsFull = 0,\n tdsArr = [];\n //let wptbTopRowAsHeader = document.getElementById( 'wptb-top-row-as-header' );\n \n for (var i = 0; i < trs.length; i++) {\n if ( i == 0 ) {\n// if( wptbTopRowAsHeader.checked ) {\n// if( start == undefined ) {\n// this.classList.add( 'wptb-table-preview-head' ); \n// trs[i].classList.add( 'wptb-table-head' )\n// } ;\n// } else {\n// if( start == undefined ) {\n// this.classList.remove( 'wptb-table-preview-head' );\n// trs[i].classList.remove( 'wptb-table-head' );\n// }\n// }\n } else {\n// if (i % 2 == 0) {\n// trs[i].classList.remove( 'wptb-table-head' );\n// } else {\n// trs[i].classList.remove( 'wptb-table-head' );\n// }\n }\n\n tdsArr[i];\n tds = trs[i].getElementsByTagName('td');\n\n if (tdsArr[i] == undefined) {\n tdsArr[i] = [];\n }\n\n let jMainIter = 0;\n for (var j = 0; j < tds.length; j++) {\n if (tdsArr[i][j] != undefined) {\n for (let y = 0; y < 100; y++) {\n if (tdsArr[i][jMainIter] != undefined) {\n jMainIter++;\n continue;\n }\n tdsArr[i][jMainIter] = tds[j];\n tds[j].dataset.xIndex = jMainIter;\n break;\n }\n } else {\n tdsArr[i][j] = tds[j];\n tds[j].dataset.xIndex = jMainIter;\n }\n tds[j].dataset.yIndex = i;\n\n if (tds[j].colSpan > 1) {\n for (let k = 1; k < tds[j].colSpan; k++) {\n jMainIter++;\n tdsArr[i][jMainIter] = 'tdDummy';\n }\n }\n\n if (tds[j].rowSpan > 1) {\n for (let x = 1; x < tds[j].rowSpan; x++) {\n if (tdsArr[i + x] == undefined) {\n tdsArr[i + x] = [];\n }\n for (let z = 0; z < tds[j].colSpan; z++) {\n tdsArr[i + x][jMainIter - tds[j].colSpan + 1 + z ] = 'tdDummy';\n }\n }\n }\n jMainIter++;\n if( i == 0 ) {\n maxColsFull = jMainIter;\n }\n }\n if (j > maxCols) {\n maxCols = j;\n }\n }\n this.columns = maxCols;\n this.maxCols = maxColsFull;\n }\n \n table.addColumnWidth = function( value, cleaner ) {\n let highlighted = table.getElementsByClassName( 'wptb-highlighted' );\n if( highlighted.length > 0 ) {\n for( let k = 0; k < highlighted.length; k++ ) {\n let dataXIndex = highlighted[k].dataset.xIndex;\n if( dataXIndex ) {\n function tableTdsFor( dataXIndex, colspan ) {\n let tableRows = table.rows;\n let widthIsSet = false;\n let arrayTdsFromPreviousRow = [];\n for( let i = 0; i < tableRows.length; i++ ) {\n let row = tableRows[i];\n let tds = row.children;\n for( let j = 0; j < tds.length; j++ ) {\n let td = tds[j];\n if( td.dataset.xIndex == dataXIndex ) {\n if( value ) {\n if( td.colSpan == colspan ) {\n td.style.width = value + 'px';\n td.removeAttribute( 'data-wptb-fixed-width' );\n widthIsSet = true;\n let tableColumnWidthAutoFixedCheckbox = document.getElementById( 'wptb-table-column-width-auto-fixed' );\n if( ! tableColumnWidthAutoFixedCheckbox.checked ) {\n tableColumnWidthAutoFixedCheckbox.checked = true;\n }\n } else {\n td.style.width = null;\n td.dataset.wptbFixedWidth = value;\n if( i == tableRows.length - 1 && ! widthIsSet ) {\n tableTdsFor( dataXIndex, colspan + 1 );\n }\n }\n } else if( cleaner ) {\n td.style.width = null;\n td.removeAttribute( 'data-wptb-fixed-width' );\n } else {\n if( td.dataset.wptbFixedWidth ) {\n if( td.colSpan == colspan ) {\n td.style.width = td.dataset.wptbFixedWidth + 'px';\n td.removeAttribute( 'data-wptb-fixed-width' );\n } \n } else if( td.style.width ) {\n for( let z = 0; z < arrayTdsFromPreviousRow.length; z++ ) {\n arrayTdsFromPreviousRow[z].style.width = td.style.width;\n }\n arrayTdsFromPreviousRow = [];\n } else {\n arrayTdsFromPreviousRow.push( td );\n }\n }\n break;\n } \n }\n }\n }\n \n tableTdsFor( dataXIndex, 1 );\n }\n }\n \n table.tdDefaultWidth();\n }\n }\n \n table.tdDefaultWidth = function() {\n let rows = table.rows;\n \n let tableTdsSumMaxWidth = 0;\n let tableTdsSumMaxWidthFixed = 0;\n let tableTdsSumMaxWidthAuto = 0;\n \n let wptbTableSetup = document.getElementsByClassName( 'wptb-table-setup' )[0];\n let wptbTableSetupWidth = wptbTableSetup.offsetWidth;\n \n let arrayCellsWidthFixedHelper = [];\n let arrayCellsWidthAutoHelper = [];\n let tdPaddingCommon = 0;\n let tableTdBorderCommonWidth = 0;\n let cssForTdsWidthAuto = '';\n \n \n let tableFullStyleObj = window.getComputedStyle( table, null );\n let borderLeftWidth = tableFullStyleObj.getPropertyValue( 'border-left-width' );\n let borderRightWidth = tableFullStyleObj.getPropertyValue( 'border-right-width' );\n let tableBorderCommon = parseFloat( borderLeftWidth, 10 ) + parseFloat( borderRightWidth, 10 );\n \n for( let i = 0; i < rows.length; i++ ) {\n let tds = rows[i].children;\n for( let j = 0; j < tds.length; j++ ) {\n let td = tds[j];\n \n if( ! arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] && ! arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] ) {\n if( td.style.width ) {\n arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] = parseFloat( td.style.width );\n td.removeAttribute( 'data-wptb-css-td-auto-width' );\n } else {\n if( ! td.dataset.wptbFixedWidth ) {\n arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] = 100;\n td.dataset.wptbCssTdAutoWidth = true;\n }\n }\n \n if( window.getComputedStyle( td, null ) ) {\n let tdStyleObj = window.getComputedStyle( td, null );\n let tdPaddingLeft = tdStyleObj.getPropertyValue( 'padding-left' );\n let tdPaddingRight = tdStyleObj.getPropertyValue( 'padding-right' );\n tdPaddingCommon = parseFloat( tdPaddingLeft, 10 ) + parseFloat( tdPaddingRight, 10 );\n\n let tableTdBorderLeftWidth = tdStyleObj.getPropertyValue( 'border-left-width' );\n let tableTdBorderRightWidth = tdStyleObj.getPropertyValue( 'border-right-width' );\n tableTdBorderCommonWidth = parseFloat( tableTdBorderLeftWidth, 10 ) + parseFloat( tableTdBorderRightWidth, 10 );\n tableTdBorderCommonWidth = tableTdBorderCommonWidth / 2;\n \n if( arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] ) {\n arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] += tdPaddingCommon;\n arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] += tableTdBorderCommonWidth;\n \n if( j == 0 && ( tableBorderCommon / 2 ) <= parseFloat( tableTdBorderLeftWidth, 10 ) ) {\n arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] += parseFloat( tableTdBorderLeftWidth, 10 ) / 2;\n } else if( j == 0 && ( tableBorderCommon / 2 ) > parseFloat( tableTdBorderLeftWidth, 10 ) ) {\n arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] += ( ( tableBorderCommon / 2 ) - ( parseFloat( tableTdBorderRightWidth, 10 ) / 2 ) );\n }\n\n if( j == tds.length - 1 && ( tableBorderCommon / 2 ) <= parseFloat( tableTdBorderRightWidth, 10 ) ) {\n arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] += parseFloat( tableTdBorderRightWidth, 10 ) / 2;\n } else if( j == tds.length - 1 && ( tableBorderCommon / 2 ) > parseFloat( tableTdBorderRightWidth, 10 ) ) {\n arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] += ( ( tableBorderCommon / 2 ) - ( parseFloat( tableTdBorderRightWidth, 10 ) / 2 ) );\n }\n } else if( arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] ) {\n arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] += tdPaddingCommon;\n arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] += tableTdBorderCommonWidth;\n \n if( j == 0 && ( tableBorderCommon / 2 ) <= parseFloat( tableTdBorderLeftWidth, 10 ) ) {\n arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] += parseFloat( tableTdBorderLeftWidth, 10 ) / 2;\n } else if( j == 0 && ( tableBorderCommon / 2 ) > parseFloat( tableTdBorderLeftWidth, 10 ) ) {\n arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] += ( ( tableBorderCommon / 2 ) - ( parseFloat( tableTdBorderLeftWidth, 10 ) / 2 ) );\n }\n\n if( j == tds.length - 1 && ( tableBorderCommon / 2 ) <= parseFloat( tableTdBorderRightWidth, 10 ) ) {\n arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] += parseFloat( tableTdBorderRightWidth, 10 ) / 2;\n } else if( j == tds.length - 1 && ( tableBorderCommon / 2 ) > parseFloat( tableTdBorderRightWidth, 10 ) ) {\n arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] += ( ( tableBorderCommon / 2 ) - ( parseFloat( tableTdBorderLeftWidth, 10 ) / 2 ) );\n }\n }\n }\n } else if( arrayCellsWidthAutoHelper[parseFloat( td.dataset.xIndex )] ) {\n if( ! td.dataset.wptbFixedWidth ) {\n td.dataset.wptbCssTdAutoWidth = true;\n }\n } else if( arrayCellsWidthFixedHelper[parseFloat( td.dataset.xIndex )] ) {\n td.removeAttribute( 'data-wptb-css-td-auto-width' );\n }\n }\n }\n \n for( let i = 0; i < arrayCellsWidthFixedHelper.length; i++ ) {\n if( arrayCellsWidthFixedHelper[i] ) {\n tableTdsSumMaxWidthFixed += arrayCellsWidthFixedHelper[i];\n }\n }\n \n let CellsWidthAutoCount = 0;\n for( let i = 0; i < arrayCellsWidthAutoHelper.length; i++ ) {\n if( arrayCellsWidthAutoHelper[i] ) {\n tableTdsSumMaxWidthAuto += arrayCellsWidthAutoHelper[i];\n CellsWidthAutoCount++;\n }\n }\n \n tableTdsSumMaxWidth = tableTdsSumMaxWidthFixed + tableTdsSumMaxWidthAuto;\n \n table.dataset.wptbTableTdsSumMaxWidth = tableTdsSumMaxWidth;\n if( CellsWidthAutoCount ) {\n table.dataset.wptbCellsWidthAutoCount = CellsWidthAutoCount;\n if( table.mergingСellsHorizontally ) {\n table.dataset.wptbFixedWidthSize = tableTdsSumMaxWidthFixed;\n } else {\n table.removeAttribute( 'data-wptb-fixed-width-size' );\n }\n } else {\n table.removeAttribute( 'data-wptb-fixed-width-size' );\n table.removeAttribute( 'data-wptb-cells-width-auto-count' );\n }\n \n let styleElementCreate = false;\n let tableTdWidthAuto;\n if( tableTdsSumMaxWidth < wptbTableSetupWidth ) {\n if( CellsWidthAutoCount ) {\n table.style.minWidth = '100%';\n if( table.mergingСellsHorizontally ) {\n table.style.width = null;\n let tableTdsWidthAutoCommon = wptbTableSetupWidth - tableTdsSumMaxWidthFixed;\n tableTdWidthAuto = tableTdsWidthAutoCommon / CellsWidthAutoCount;\n tableTdWidthAuto = tableTdWidthAuto - tdPaddingCommon - tableTdBorderCommonWidth;\n styleElementCreate = true;\n } else {\n table.style.width = '100%';\n }\n } else {\n table.style.width = null;\n table.style.minWidth = null;\n table.style.maxWidth = null;\n }\n } else {\n table.style.maxWidth = null;\n table.style.minWidth = tableTdsSumMaxWidth + 'px';\n table.style.width = null;\n tableTdWidthAuto = '100'\n styleElementCreate = true;\n }\n \n let head = document.head;\n if( head ) {\n let cssForTdsWidthAutoOld = head.querySelector( 'style[data-wptb-td-auto-width=\"true\"]' );\n if( cssForTdsWidthAutoOld ) {\n head.removeChild( cssForTdsWidthAutoOld );\n }\n }\n \n if( styleElementCreate ) {\n cssForTdsWidthAuto = document.createElement( 'style' );\n cssForTdsWidthAuto.setAttribute( 'data-wptb-td-auto-width', true );\n cssForTdsWidthAuto.innerHTML = '[data-wptb-css-td-auto-width=true]{width:' + tableTdWidthAuto + 'px}';\n if( head ) {\n head.appendChild( cssForTdsWidthAuto );\n }\n }\n }\n \n table.addRowHeight = function( value, cleaner ) {\n let highlighted = table.getElementsByClassName( 'wptb-highlighted' );\n if( highlighted.length > 0 ) {\n for( let k = 0; k < highlighted.length; k++ ) {\n let dataYIndex = highlighted[k].dataset.yIndex;\n if( dataYIndex ) {\n function tableTdsFor( dataYIndex, rowspan ) {\n let tableRows = table.rows;\n let heightIsSet = false;\n let arrayTdsPrevious = [];\n for( let i = 0; i < tableRows.length; i++ ) {\n let row = tableRows[i];\n let tds = row.children;\n for( let j = 0; j < tds.length; j++ ) {\n let td = tds[j];\n if( td.dataset.yIndex == dataYIndex ) {\n if( value ) {\n if( td.rowSpan == rowspan ) {\n td.style.height = value + 'px';\n td.removeAttribute( 'data-wptb-fixed-heidht' );\n heightIsSet = true;\n let tableColumnHeightAutoFixedCheckbox = document.getElementById( 'wptb-table-row-height-auto-fixed' );\n if( ! tableColumnHeightAutoFixedCheckbox.checked ) {\n tableColumnHeightAutoFixedCheckbox.checked = true;\n }\n continue;\n } else {\n td.style.height = null;\n td.dataset.wptbFixedHeight = value;\n if( j == tds.length - 1 && ! heightIsSet ) {\n tableTdsFor( dataYIndex , rowspan + 1 );\n }\n }\n } else if( cleaner ) {\n td.style.height = null;\n td.removeAttribute( 'data-wptb-fixed-heidht' );\n } else {\n if( td.dataset.wptbFixedHeight ) {\n if( td.rowSpan = rowspan ) {\n td.style.height = td.dataset.wptbFixedHeight + 'px';\n td.removeAttribute( 'data-wptb-fixed-width' );\n }\n } else if( td.style.height ) {\n for( let z = 0; z < arrayTdsPrevious.length; z++ ) {\n arrayTdsPrevious[z].style.height = td.style.height;\n }\n arrayTdsPrevious = [];\n } else {\n arrayTdsPrevious.push( td );\n }\n }\n } \n }\n }\n }\n \n tableTdsFor( dataYIndex, 1 );\n }\n }\n }\n }\n \n table.reconstraction = function() {\n let tds = table.getElementsByTagName( 'td' );\n table.mergingСellsHorizontally = false;\n table.mergingCellsVertically = false;\n table.dataset.reconstraction = 1;\n let forBreak = 0;\n for( let i = 0; i < tds.length; i++ ) {\n if( tds[i].colSpan > 1 ) {\n table.dataset.reconstraction = 0;\n table.mergingСellsHorizontally = true;\n forBreak++;\n }\n \n if( tds[i].rowSpan > 1 ) {\n table.dataset.reconstraction = 0;\n table.mergingCellsVertically = true;\n forBreak++;\n }\n \n if( forBreak == 2 ) {\n break;\n }\n }\n }\n\n /*\n * As simple as it is: adds a column to the end of table.\n */\n table.addColumnEnd = function () {\n let td,\n currentTable = document.getElementsByClassName('wptb-preview-table'),\n currentTableTd,\n currentTdStyle;\n if (currentTable.length > 0) {\n currentTableTd = currentTable[0].querySelector('td');\n }\n\n if (currentTableTd) {\n currentTdStyle = currentTableTd.getAttribute('style');\n }\n \n for (var i = 0; i < table.rows.length; i++) {\n td = new WPTB_Cell(mark);\n \n if (currentTdStyle) {\n td.getDOMElement().setAttribute('style', currentTdStyle);\n td.getDOMElement().style.width = null;\n td.getDOMElement().style.height = null;\n }\n \n table.rows[i].appendChild(td.getDOMElement());\n array[i].push(0);\n }\n \n maxAmountOfCells++;\n table.recalculateIndexes();\n table.tdDefaultWidth();\n table.addRowHeight();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n /*\n * As simple as it looks: adds a column to the start of table.\n */\n\n table.addColumnStart = function () {\n let td,\n firstCell,\n currentTable = document.getElementsByClassName('wptb-preview-table'),\n currentTableTd,\n currentTdStyle;\n if ( currentTable.length > 0 ) {\n currentTableTd = currentTable[0].querySelector('td');\n }\n\n if ( currentTableTd ) {\n currentTdStyle = currentTableTd.getAttribute('style');\n }\n \n for (var i = 0; i < table.rows.length; i++) {\n td = new WPTB_Cell(mark);\n if (currentTdStyle) {\n td.getDOMElement().setAttribute('style', currentTdStyle);\n td.getDOMElement().style.width = null;\n td.getDOMElement().style.height = null;\n }\n firstCell = table.rows[i].getElementsByTagName('td')[0];\n if (firstCell) {\n table.rows[i].insertBefore(td.getDOMElement(), firstCell);\n } else {\n table.rows[i].appendChild(td.getDOMElement());\n }\n array[i].push(0);\n }\n\n maxAmountOfCells++;\n table.recalculateIndexes();\n table.tdDefaultWidth();\n table.addRowHeight();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n /*\n * Well, not so simple as previous functions.\n * It adds a column after a certain column of reference.\n * @param integer the column number to be used as reference.\n *\tIf empty, then the first highlighted cell is used as reference.\n */\n\n table.addColumnAfter = function (c_pos) {\n let rows = table.rows,\n cellPointer,\n cellsBuffer,\n cell = document.querySelector('.wptb-highlighted'),\n cellStyle = cell.getAttribute('style'),\n pos = c_pos != undefined && typeof c_pos === 'number' ? c_pos : getCoords(cell)[1];\n \n \n \n if( maxAmountOfCells - pos - cell.colSpan + 1 == 1 ) {\n table.addColumnEnd();\n } else {\n let pendingInsertion = false,\n stepsToMove,\n td, bro,\n carriedRowspans = [],\n currentCell;\n\n for (var i = 0; i < maxAmountOfCells; i++) {\n carriedRowspans.push(0);\n }\n\n for (var i = 0; i < rows.length; i++) {\n cellPointer = 0;\n cellsBuffer = rows[i].getElementsByTagName('td');\n pendingInsertion = false;\n for (var xPosition = 0;\n xPosition < maxAmountOfCells;\n xPosition += stepsToMove) {\n stepsToMove = 1;\n\n if (pendingInsertion) {\n td = new WPTB_Cell(mark);\n if (cellStyle) {\n td.getDOMElement().setAttribute('style', cellStyle);\n td.getDOMElement().style.width = null;\n td.getDOMElement().style.height = null;\n }\n if (currentCell && rows[i].contains(currentCell)) {\n bro = currentCell.nextSibling;\n if (bro) {\n rows[i].insertBefore(td.getDOMElement(), bro);\n } else {\n rows[i].appendChild(td.getDOMElement());\n }\n } else {\n rows[i].insertBefore(td.getDOMElement(), cellsBuffer[0]);\n }\n break;\n } else if (carriedRowspans[xPosition] > 0) {\n // If no pending insertion, let's check if no rowspan from upper cells is pending in current position\n if (pos == xPosition) {\n pendingInsertion = true;\n }\n } else {\n currentCell = cellsBuffer[cellPointer++];\n if (currentCell.rowSpan > 1) {\n stepsToMove = currentCell.colSpan;\n for (var k = 0; k < currentCell.colSpan; k++) {\n carriedRowspans[xPosition + k] = currentCell.rowSpan;\n if (xPosition + k == pos) {\n pendingInsertion = true;\n }\n }\n } else if (currentCell.colSpan > 1) {\n stepsToMove = currentCell.colSpan;\n for (var k = 0; k < currentCell.colSpan; k++) {\n if (xPosition + k == pos) {\n pendingInsertion = true;\n }\n }\n } else if (xPosition == pos) {\n pendingInsertion = true;\n }\n }\n }\n\n for (var l = 0; l < maxAmountOfCells; l++) {\n if (carriedRowspans[l] > 0)\n carriedRowspans[l]--;\n }\n\n }\n\n for (var i = 0; i < array.length; i++) {\n array[i].push(0);\n }\n maxAmountOfCells++;\n drawTable(array);\n table.recalculateIndexes();\n table.addColumnWidth();\n table.addRowHeight();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n };\n\n /*\n * For preventing us to take a lot of time,\n * This is just calling the function addColumnAfter, but\n * using the previous column to current one as reference.\n * @see addColumnAfter\n */\n\n table.addColumnBefore = function () {\n var cell = document.querySelector('.wptb-highlighted'),\n pos = getCoords(cell)[1];\n\n if (pos === 0) {\n table.addColumnStart();\n } else {\n table.addColumnAfter(pos - 1);\n }\n };\n\n /*\n * Luckily, thisfunction is simple, \n * it just add a row to the end of table.\n */\n\n table.addRowToTheEnd = function () {\n let r = table.insertRow(-1),\n td,\n aux,\n currentTable = document.getElementsByClassName('wptb-preview-table');\n r.classList.add( 'wptb-row' );\n if (currentTable.length > 0) {\n currentTable = currentTable[0];\n \n for (var i = 0; i < maxAmountOfCells; i++) {\n td = new WPTB_Cell(mark);\n let currentTableTd = currentTable.querySelector('[data-x-index=\"' + i + '\"]');\n if( currentTableTd ) {\n let currentTdStyle = currentTableTd.getAttribute( 'style' );\n \n td.getDOMElement().setAttribute( 'style', currentTdStyle );\n td.getDOMElement().style.height = null;\n }\n r.appendChild(td.getDOMElement());\n }\n \n aux = Array.from(array[0]);\n array.push(aux);\n drawTable(array);\n table.recalculateIndexes();\n table.addColumnWidth();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n };\n\n /*\n * Yet another simple function, \n * it just add a row to the start of table.\n */\n\n table.addRowToTheStart = function () {\n let r = table.insertRow(0),\n td,\n aux,\n currentTable = document.getElementsByClassName('wptb-preview-table'),\n currentTableTd,\n currentTdStyle;\n r.classList.add( 'wptb-row' );\n if (currentTable.length > 0) {\n currentTable = currentTable[0];\n \n for (var i = 0; i < maxAmountOfCells; i++) {\n td = new WPTB_Cell(mark);\n let currentTableTd = currentTable.querySelector('[data-x-index=\"' + i + '\"]');\n if( currentTableTd ) {\n let currentTdStyle = currentTableTd.getAttribute( 'style' );\n \n td.getDOMElement().setAttribute( 'style', currentTdStyle );\n td.getDOMElement().style.height = null;\n }\n r.appendChild(td.getDOMElement());\n }\n \n aux = Array.from(array[0]);\n array.push(aux);\n drawTable(array);\n table.recalculateIndexes();\n table.addColumnWidth();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n };\n\n /* \n * This function adds a row before the current one.\n * Since the biggest factor of problem is a not-started but ongoing rowspan,\n * the most of the troubles is not here.\n */\n\n table.addRowBefore = function () {\n let cell = document.querySelector('.wptb-highlighted'),\n cellStyle = cell.getAttribute('style'),\n row = getCoords(cell)[0],\n cellNew;\n for( let i = row - 1; i >= 0; i-- ) {\n let rowChildren = table.rows[i].children;\n let rowChildrenLength = rowChildren.length;\n if( rowChildrenLength > 0 ) {\n for( let j = 0; j < rowChildrenLength; j++ ) {\n if( rowChildren[j].rowSpan == 1 ) {\n row = i;\n cellNew = true;\n break;\n }\n }\n }\n if ( cellNew ) {\n break;\n }\n }\n\n if (row === 0) {\n table.addRowToTheStart();\n } else {\n table.addRowAfter( row, cellStyle );\n }\n };\n\n /*\n * Well... by the name convention of the previous 3 functions,\n * it's pretty obvious that this functions attaches a new\n * row after highlighted cell row. The greatest obstacle it was\n * the possibility of a TR not having the exact amount of columns\n * occuped by actual node but rowspanned upper cells. For that purpose\n * it was created the function realTimeArray.\n * @see realTimeArray\n */\n\n table.addRowAfter = function ( row, cellStyle ) {\n let cellRowSpan,\n rowAfter,\n aux;\n \n if ( ( row == undefined || typeof row !== 'number' ) && cellStyle == undefined ) {\n let cell = document.querySelector('.wptb-highlighted');\n cellStyle = cell.getAttribute('style'),\n row = getCoords(cell)[0],\n cellRowSpan = cell.rowSpan,\n rowAfter = row + cellRowSpan - 1;\n } else {\n rowAfter = row;\n }\n \n \n let cellsColSpan = 0;\n if ( rowAfter < table.rows.length -1 ) {\n for( let i = 0; i <= rowAfter ; i++ ) {\n let tableRowsIChildren = table.rows[i].children,\n tableRIChildrenLength = tableRowsIChildren.length;\n if( tableRIChildrenLength > 0 ) {\n for( let j = 0; j < tableRIChildrenLength; j++ ) {\n let rowIRowSpan = tableRowsIChildren[j].rowSpan;\n\n if ( rowIRowSpan - 1 + i > rowAfter ) {\n tableRowsIChildren[j].rowSpan++;\n }\n }\n }\n }\n \n let rNext = table.rows[rowAfter + 1],\n rNextChildren = rNext.children,\n rNextChildrenLength = rNextChildren.length;\n \n if( rNextChildrenLength > 0 ) {\n for ( let i = 0; i < rNextChildrenLength; i++ ) {\n cellsColSpan += rNextChildren[i].colSpan;\n }\n }\n } else {\n cellsColSpan = array[0].length;\n }\n \n let r = table.insertRow( rowAfter + 1 );\n r.classList.add( 'wptb-row' );\n \n for ( j = 0; j < cellsColSpan; j++ ) {\n let td = new WPTB_Cell( mark );\n td.getDOMElement().setAttribute( 'style', cellStyle );\n td.getDOMElement().style.width = null;\n td.getDOMElement().style.height = null;\n r.appendChild( td.getDOMElement() );\n }\n\n aux = Array.from(array[0]);\n array.push(aux);\n drawTable(array);\n table.recalculateIndexes();\n table.addColumnWidth();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n /*\n * This function checks the current selected cells\n * make a rectangular shape.\n * @param Array the abstract table.\n * @return false, if not making a rectangle, or\n *\tArray an array containing number of rows and columns, if selection makes a rectangle.\n */\n\n table.isSquare = function (a) {\n var rowStart = -1,\n columnStart = -1,\n rowEnd = -1,\n columnEnd = -1,\n height,\n width,\n itemsEstimate = 0,\n items = 0;\n\n for (var i = 0; i < a.length; i++) {\n for (var j = 0; j < a[i].length; j++) {\n if (a[i][j] == 1) {\n if ( j < columnStart || columnStart == -1 ) {\n columnStart = j;\n }\n if ( i < rowStart || rowStart == -1 ) {\n rowStart = i;\n }\n }\n }\n \n }\n\n for (var i = a.length - 1; i > -1; i--) {\n for (var j = a[i].length - 1; j > -1; j--) {\n if (a[i][j] == 1) {\n if ( j > columnEnd ) {\n columnEnd = j;\n }\n if ( i > rowEnd ) {\n rowEnd = i;\n }\n }\n }\n }\n\n for (var i = rowStart; i < rowEnd; i++) {\n for (var j = columnStart; j < columnEnd; j++) {\n if (a[i][j] == 0 || a[i][j] == undefined) {\n return false;\n }\n }\n }\n\n for (var i = 0; i < a.length; i++) {\n for (var j = 0; j < a[i].length; j++) {\n if (a[i][j] == 1) {\n items++;\n }\n }\n }\n\n height = rowEnd - rowStart + 1;\n width = columnEnd - columnStart + 1;\n itemsEstimate = height * width;\n\n if (itemsEstimate !== items) {\n return false;\n }\n return [height, width];\n };\n\n /*\n * This function merges all selected cells.\n * Well, actually sets the colspan and rowspan of first \n * upper left cell in selection and deletes the another selected cells.\n */\n\n table.mergeCells = function () {\n var dimensions = table.isSquare(array),\n rowspan = dimensions[0],\n colspan = dimensions[1],\n first = document.querySelector('.wptb-highlighted'),\n tds = [].slice.call(document.getElementsByClassName('wptb-highlighted'), 1),\n tdsChildrenNew = [];\n\n for (let i = 0; i < tds.length; i++) {\n let tdsInternalElements = tds[i].getElementsByClassName('wptb-ph-element');\n if (tdsInternalElements.length > 0) {\n let tdsIntElemLength = tdsInternalElements.length;\n for (let j = 0; j < tdsIntElemLength; j++) {\n tdsChildrenNew.push(tdsInternalElements[j]);\n }\n }\n let p = tds[i].parentNode;\n p.removeChild(tds[i]);\n }\n if (tdsChildrenNew.length > 0) {\n for (let i = 0; i < tdsChildrenNew.length; i++) {\n first.appendChild(tdsChildrenNew[i]);\n }\n }\n\n first.colSpan = colspan;\n first.rowSpan = rowspan;\n table.recalculateIndexes();\n table.reconstraction();\n let firstWidth = first.style.width;\n let firstDataFixedWidth = first.dataset.wptbFixedWidth;\n if( firstWidth ) {\n table.addColumnWidth( parseFloat( firstWidth, 10 ) );\n } else if( firstDataFixedWidth ) {\n table.addColumnWidth();\n } else {\n table.addColumnWidth( false, true );\n }\n \n let firstHeight = first.style.height;\n let firstDataFixedHeight = first.dataset.wptbFixedHeight;\n if( firstHeight ) {\n table.addRowHeight( parseFloat( firstHeight, 10 ) );\n } else if( firstDataFixedHeight ) {\n table.addRowHeight();\n } else {\n table.addRowHeight( false, true );\n }\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n /*\n * This functions makes the exact inverse as above.\n * It resets colspan and rowspan and appends \n * the same amount in cells to the table.\n * @bug\n */\n\n table.splitCell = function () {\n var cell = document.getElementsByClassName('wptb-highlighted')[0],\n rowspan = cell.rowSpan,\n colspan = cell.colSpan,\n cellStyles = cell.getAttribute('style'),\n row = getCoords(cell)[0],\n thisRow = table.rows[row],\n cellXIndex =cell.dataset.xIndex;\n \n cell.rowSpan = 1;\n cell.colSpan = 1;\n \n for (let i = 1; i < colspan; i++) {\n let td = new WPTB_Cell(mark);\n td.getDOMElement().setAttribute('style', cellStyles);\n td.getDOMElement().classList.add( 'wptb-highlighted' );\n if ( cell.nextSibling ) {\n thisRow.insertBefore( td.getDOMElement(), cell.nextSibling );\n } else {\n thisRow.appendChild( td.getDOMElement() );\n }\n \n }\n\n if (rowspan > 1) {\n for (let i = 1; i < rowspan; i++) {\n let rowChildInsertBefore = undefined,\n rowNext = table.rows[row + i],\n rowChildren = rowNext.children,\n rowChildrenLength = rowChildren.length;\n \n if ( rowChildrenLength > 0 ) {\n for ( let k = 0; k < rowChildrenLength; k++ ) {\n if ( Number( rowChildren[k].dataset.xIndex ) > Number( cellXIndex ) ) {\n rowChildInsertBefore = rowChildren[k];\n break;\n } \n }\n }\n for ( let j = 0; j < colspan; j++ ) {\n let td = new WPTB_Cell( mark );\n td.getDOMElement().setAttribute( 'style', cellStyles );\n if ( rowChildInsertBefore != undefined ) {\n rowNext.insertBefore( td.getDOMElement(), rowChildInsertBefore );\n } else {\n rowNext.appendChild( td.getDOMElement() );\n }\n }\n }\n }\n\n table.recalculateIndexes();\n table.reconstraction();\n table.addColumnWidth();\n table.addRowHeight();\n WPTB_Helper.dataTitleColumnSet( table );\n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n /*\n * Searches for rowspanned cells up to row number meeting it.\n * @param number the number of row where the function\n * must search up to.\n */\n\n table.findRowspannedCells = function (row) {\n var array = [],\n difference;\n actualPoints = getActualPointsInRow(row);\n if (actualPoints === maxAmountOfCells) {\n return [];\n }\n difference = maxAmountOfCells - actualPoints;\n\n for (var i = row - 1; i >= 0 && difference; i--) {\n var tds = table.rows[i].getElementsByTagName('td');\n for (var i = 0; i < tds.length; i++) {\n if (tds[i].rowSpan > 1) {\n array.push(tds[i]);\n difference -= tds[i].colSpan;\n }\n }\n }\n return array;\n\n }\n\n /*\n * This function explores the table and adds \n * a cell for each lacking one for each row\n * to meet an even amount of cells.\n */\n\n table.addLackingCells = function () {\n var sumRows = [];\n for (var i = 0; i < table.rows.length; i++) {\n sumRows.push(0);\n }\n\n for (var i = 0; i < table.rows.length; i++) {\n var tds = table.rows[i].getElementsByTagName('td');\n for (var j = 0; j < tds.length; j++) {\n if (tds[j].rowSpan > 1) {\n for (var k = 1; k < tds[j].rowSpan; k++) {\n sumRows[i + k]++;\n }\n }\n }\n }\n\n for (var i = 0; i < table.rows.length; i++) {\n var tds = table.rows[i].getElementsByTagName('td'),\n totalColspan = 0;\n for (var j = 0; j < tds.length; j++) {\n totalColspan += tds[j].colSpan;\n }\n totalColspan += sumRows[i];\n difference = maxAmountOfCells - totalColspan;\n for (var j = 0; j < difference; j++) {\n var td = new WPTB_Cell(mark);\n table.rows[i].appendChild(td.getDOMElement());\n //table.rows[i].insertBefore( td.getDOMElement(), rows[i].nextSibling );\n }\n }\n };\n\n /*\n * This function deletes the row of currently\n * selected cell. \n */\n\n table.deleteRow = function () {\n let cell = document.querySelector('.wptb-highlighted'),\n cellStyles = cell.getAttribute('style'),\n rowspan = cell.rowSpan,\n row = getCoords(cell)[0],\n thisRow,\n aux;\n \n if ( rowspan == undefined ) rowspan = 1;\n \n for ( let i = 0; i < rowspan; i++ ) {\n thisRow = table.rows[row];\n let thisRowChildren = thisRow.children,\n nextRow = table.rows[row + 1],\n nextRowChildren,\n nextRowChildrenLength,\n tdArr = [];\n\n if( nextRow != undefined ) {\n nextRowChildren = nextRow.children;\n nextRowChildrenLength = nextRowChildren.length;\n for (let j = 0; j < thisRowChildren.length; j++) {\n if ( thisRowChildren[j].rowSpan > 1 ) {\n let td = new WPTB_Cell(mark);\n td.getDOMElement().setAttribute('style', cellStyles);\n td.getDOMElement().colSpan = thisRowChildren[j].colSpan;\n td.getDOMElement().rowSpan = thisRowChildren[j].rowSpan - 1;\n\n let nextRowChildrenK = undefined;\n for ( let k = 0; k < nextRowChildrenLength; k++ ) {\n if ( Number( nextRowChildren[k].dataset.xIndex ) > Number( thisRowChildren[j].dataset.xIndex ) ) {\n nextRowChildrenK = nextRowChildren[k];\n break;\n } \n }\n\n if ( nextRowChildrenK ) {\n tdArr.push( [td, nextRowChildrenK] );\n } else {\n tdArr.push( [td] );\n }\n }\n }\n\n if ( tdArr.length > 0 ) {\n for ( let k = 0; k < tdArr.length; k++ ) {\n if ( tdArr[k][1] != undefined ) {\n nextRow.insertBefore( tdArr[k][0].getDOMElement(), tdArr[k][1] );\n } else {\n nextRow.appendChild( tdArr[k][0].getDOMElement() );\n }\n }\n }\n }\n \n let tableRows = table.rows;\n if ( tableRows.length > 0 ) {\n for ( let j = 0; j < row; j++ ) {\n let jRowChildren = tableRows[j].children;\n if ( jRowChildren.length > 0 ) {\n for ( let x = 0; x < jRowChildren.length; x++ ) {\n if ( jRowChildren[x].rowSpan - 1 >= row - j ) {\n jRowChildren[x].rowSpan--;\n }\n }\n }\n }\n }\n aux = Array.from(array[0]);\n array.pop(aux);\n drawTable(array);\n table.getElementsByTagName('tbody')[0].removeChild(table.rows[row]);\n \n if( table.rows.length == 0 ) {\n table.toggleTableEditMode();\n wptbTableSetup.innerHTML = '';\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\n let wptbSaveBtn = document.getElementsByClassName( 'wptb-save-btn' );\n if( wptbSaveBtn.length > 0 ) {\n wptbSaveBtn = wptbSaveBtn[0];\n \n wptbSaveBtn.classList.add( 'wptb-save-disabled' );\n }\n } else {\n table.recalculateIndexes();\n WPTB_Helper.dataTitleColumnSet( table );\n }\n }\n \n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n }\n\n /*\n * This function deletes the column of currently\n * selected cell. Again, this is way more complicated than\n * delete row case.\n */\n\n table.deleteColumn = function () {\n let cell = document.querySelector('.wptb-highlighted'),\n cellXIndex = cell.dataset.xIndex,\n colspan = cell.colSpan;\n \n for ( let i = 0; i < colspan; i++ ) {\n for ( let j = 0; j < table.rows.length; j++ ) {\n let rowChildren = table.rows[j].children;\n let rowChildrenLength = rowChildren.length;\n if( rowChildrenLength > 0 ) {\n for ( let k = rowChildrenLength - 1; k >= 0; k-- ) {\n if ( Number( rowChildren[k].dataset.xIndex ) == Number( cellXIndex ) ) {\n if ( rowChildren[k].colSpan > 1 ) {\n rowChildren[k].colSpan--;\n } else {\n table.rows[j].removeChild( rowChildren[k] );\n }\n break;\n } else if( Number( rowChildren[k].dataset.xIndex ) < Number( cellXIndex ) && \n Number( rowChildren[k].dataset.xIndex ) + \n Number( rowChildren[k].colSpan -1 ) >= cellXIndex ) {\n if ( rowChildren[k].colSpan > 1 ) {\n rowChildren[k].colSpan--;\n }\n break;\n }\n }\n }\n }\n \n for ( let j = 0; j < table.rows.length; j++ ) {\n if (array[j] != undefined)\n array[j].pop();\n }\n \n maxAmountOfCells--;\n \n if( table.querySelectorAll( 'td' ).length == 0 ) {\n table.toggleTableEditMode();\n wptbTableSetup.innerHTML = '';\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\n let wptbSaveBtn = document.getElementsByClassName( 'wptb-save-btn' );\n if( wptbSaveBtn.length > 0 ) {\n wptbSaveBtn = wptbSaveBtn[0];\n \n wptbSaveBtn.classList.add( 'wptb-save-disabled' );\n }\n } else {\n table.recalculateIndexes();\n table.tdDefaultWidth();\n WPTB_Helper.dataTitleColumnSet( table );\n }\n }\n \n undoSelect();\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n };\n\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'none';\n\n array = fillTableArray();\n\n undoSelect();\n drawTable(array);\n\n wptbTableSetup.appendChild(table);\n //if (columns || rows) {\n table.recalculateIndexes( true );\n //}\n table.reconstraction();\n table.tdDefaultWidth();\n \n wptbTableSetup.onresize = function() {\n table.tdDefaultWidth();\n };\n\n WPTB_LeftPanel();\n \n // this code gets the ID of the active element in the toolbar \n // and stores it in the data attribute of the common container element \"wpcd_fixed_toolbar\"\n// let wptbPhElement = document.getElementsByClassName( 'wptb-ph-element' );\n// let wpcdFixedToolbar = document.getElementById( 'wpcd_fixed_toolbar' );\n// for ( let i = 0; i < wptbPhElement.length; i++ ) {\n// wptbPhElement[i].addEventListener( 'click', function( e ) {\n// let wptbToolbar = document.getElementById( 'wpcd_fixed_toolbar' ).children;\n// for ( let j = 0; j < wptbToolbar.length; j++ ) {\n// let elementStyles = window.getComputedStyle( wptbToolbar[j], 'null' );\n// if( elementStyles.getPropertyValue( 'display' ) == 'block' ) {\n// wpcdFixedToolbar.dataset.toolbarActiveId = wptbToolbar[j].getAttribute( 'id' );\n// }\n// }\n// }, false );\n// }\n \n// let wptbPanelLeft = document.getElementsByClassName( 'wptb-panel-left' );\n// if( wptbPanelLeft.length > 0 ) {\n// wptbPanelLeft[0].addEventListener( 'click', function( e ) {\n// let toolbarActiveElementId = wpcdFixedToolbar.dataset.toolbarActiveId;\n// document.getElementById( toolbarActiveElementId ).style.display = '';\n// }, false );\n// }\n \n// let body = document.getElementsByTagName( 'body' );\n// if( body.length > 0 ) {\n// body[0].addEventListener( 'click', function( e ) {\n// if ( e.target.classList.contains( 'wptb-panel-left' ) || WPTB_Helper.findAncestor( e.target, 'wptb-panel-left' ) ) {\n// let toolbarActiveElementId = wpcdFixedToolbar.dataset.toolbarActiveId;\n// document.getElementById( toolbarActiveElementId ).style.display = '';\n// }\n// }, false );\n// }\n};","var WPTB_TableStateSaveManager = function() {\n this.tableStateSet = ( generate ) => {\n \n if( generate && window.wptbTableStateSaving && Array.isArray( window.wptbTableStateSaving ) ) {\n return;\n }\n \n // get preview table\n let wptbPreviewTable = document.getElementsByClassName( 'wptb-preview-table' );\n if( wptbPreviewTable.length > 0 ) {\n wptbPreviewTable = wptbPreviewTable[0];\n } else {\n wptbPreviewTable = '';\n }\n \n // check if a global array doesn't exist with saved versions of the table \n // them create it\n if( ! window.wptbTableStateSaving && ! Array.isArray( window.wptbTableStateSaving ) ) {\n window.wptbTableStateSaving = [];\n } \n\n // remove the extra part of the array after changing the table \n // when it is showed in the not last modified version\n if( window.wptbTableStateSaving.length > window.wptbTableStateNumberShow ) {\n window.wptbTableStateSaving = window.wptbTableStateSaving.slice( 0, window.wptbTableStateNumberShow + 1 );\n }\n\n //add new state of table\n let wptbNewPreviewTable = '';\n if( wptbPreviewTable ) {\n wptbNewPreviewTable = wptbPreviewTable.cloneNode( true );\n let wptbHighlighted = wptbNewPreviewTable.getElementsByClassName( 'wptb-highlighted' );\n for( let i = 0; i < wptbHighlighted.length; i++ ) {\n wptbHighlighted[i].classList.remove( 'wptb-highlighted' );\n }\n let wptbDirectlyhovered = wptbNewPreviewTable.getElementsByClassName( 'wptb-directlyhovered' );\n for( let i = 0; i < wptbDirectlyhovered.length; i++ ) {\n wptbDirectlyhovered[i].classList.remove( 'wptb-directlyhovered' );\n }\n let mceContentBodys = wptbNewPreviewTable.querySelectorAll( '.mce-content-body' );\n if( mceContentBodys.length > 0 ) {\n for ( let k = 0; k < mceContentBodys.length; k++ ) {\n mceContentBodys[k].classList.remove( 'mce-content-body' );\n }\n }\n let dataMceStyle = wptbNewPreviewTable.querySelectorAll( '[data-mce-style]' );\n if ( dataMceStyle.length > 0 ) {\n for ( let k = 0; k < dataMceStyle.length; k++ ) {\n dataMceStyle[k].removeAttribute( 'data-mce-style' );\n }\n }\n let mceIds = wptbNewPreviewTable.querySelectorAll( '[id^=mce_]' );\n if ( mceIds.length > 0 ) {\n for ( let k = 0; k < mceIds.length; k++ ) {\n mceIds[k].removeAttribute( 'id' );\n }\n }\n }\n\n let cssForTdsWidthAutoValue = '';\n let head = document.head;\n if( head ) {\n let cssForTdsWidthAuto = head.querySelector( 'style[data-wptb-td-auto-width=\"true\"]' );\n if( cssForTdsWidthAuto ) {\n cssForTdsWidthAutoValue = cssForTdsWidthAuto.innerHTML;\n }\n }\n\n let wptbElementDatas = document.getElementsByClassName( 'wptb-element-datas' );\n if( wptbElementDatas.length > 0 ) {\n wptbElementDatas = wptbElementDatas[0];\n wptbElementDatas = wptbElementDatas.innerHTML;\n } else {\n wptbElementDatas = '';\n }\n\n let styleObjJson = WPTB_Helper.elementsStylesConvertToObject();\n\n window.wptbTableStateSaving.push( [wptbNewPreviewTable, cssForTdsWidthAutoValue, wptbElementDatas, styleObjJson] );\n\n // set new number of state which is showed now\n window.wptbTableStateNumberShow = window.wptbTableStateSaving.length - 1;\n\n // make undo arrow active when the table was changed\n if( window.wptbTableStateSaving.length - 1 > 0 ) {\n let wptbUndo = document.getElementsByClassName( 'wptb-undo' );\n if( wptbUndo.length > 0 ) {\n wptbUndo = wptbUndo[0];\n\n wptbUndo.classList.remove( 'wptb-undoredo-disabled' );\n }\n }\n\n // make redo arrow not active when the table was changed\n let wptbRedo = document.getElementsByClassName( 'wptb-redo' );\n if( wptbRedo.length > 0 ) {\n wptbRedo = wptbRedo[0];\n\n wptbRedo.classList.add( 'wptb-undoredo-disabled' );\n }\n\n let wptbSaveBtn = document.getElementsByClassName( 'wptb-save-btn' );\n if( wptbSaveBtn.length > 0 ) {\n wptbSaveBtn = wptbSaveBtn[0];\n if( ( ! wptbSaveBtn.dataset.wptbTableStateNumberSave && window.wptbTableStateNumberShow == 0 ) || \n window.wptbTableStateNumberShow == wptbSaveBtn.dataset.wptbTableStateNumberSave || ! wptbPreviewTable ) {\n wptbSaveBtn.classList.add( 'wptb-save-disabled' );\n } else {\n wptbSaveBtn.classList.remove( 'wptb-save-disabled' );\n }\n }\n }\n \n this.tableStateGet = ( datawptbUndoredo ) => {\n if( datawptbUndoredo && window.wptbTableStateSaving && window.wptbTableStateSaving.length > 0 ) {\n \n // changes the number of the state which displays now\n if( datawptbUndoredo == 'undo' ) {\n if( window.wptbTableStateNumberShow > 0 ) {\n window.wptbTableStateNumberShow--;\n } else {\n return false;\n }\n } else if( datawptbUndoredo == 'redo' ) {\n if( window.wptbTableStateNumberShow < window.wptbTableStateSaving.length ) {\n window.wptbTableStateNumberShow++;\n } else {\n return false;\n }\n }\n \n // add or delete class \"wptb-undoredo-disabled\" for undo button\n let wptbUndo = document.getElementsByClassName( 'wptb-undo' );\n if( wptbUndo.length > 0 ) {\n wptbUndo = wptbUndo[0];\n \n if( window.wptbTableStateNumberShow == 0 ) {\n if( wptbUndo ) {\n wptbUndo.classList.add( 'wptb-undoredo-disabled' );\n }\n } else if( window.wptbTableStateNumberShow > 0 ) {\n if( wptbUndo ) {\n wptbUndo.classList.remove( 'wptb-undoredo-disabled' );\n }\n }\n }\n \n // add or delete class \"wptb-undoredo-disabled\" for redo button\n let wptbRedo = document.getElementsByClassName( 'wptb-redo' );\n if( wptbRedo.length > 0 ) {\n wptbRedo = wptbRedo[0];\n \n if( window.wptbTableStateNumberShow == window.wptbTableStateSaving.length - 1 ) {\n if( wptbRedo ) {\n wptbRedo.classList.add( 'wptb-undoredo-disabled' );\n }\n } else if( window.wptbTableStateNumberShow < window.wptbTableStateSaving.length - 1 ) {\n if( wptbRedo ) {\n wptbRedo.classList.remove( 'wptb-undoredo-disabled' );\n }\n }\n }\n \n // add or delete class \"wptb-save-disabled\" for save button\n let wptbSaveBtn = document.getElementsByClassName( 'wptb-save-btn' );\n if( wptbSaveBtn.length > 0 ) {\n wptbSaveBtn = wptbSaveBtn[0];\n if( ( ! wptbSaveBtn.dataset.wptbTableStateNumberSave && window.wptbTableStateNumberShow == 0 ) || \n window.wptbTableStateNumberShow == wptbSaveBtn.dataset.wptbTableStateNumberSave ) {\n wptbSaveBtn.classList.add( 'wptb-save-disabled' );\n } else {\n wptbSaveBtn.classList.remove( 'wptb-save-disabled' );\n }\n }\n \n // load necessary saved table state\n let wptbTableSetup = document.getElementsByClassName( 'wptb-table-setup' );\n if( wptbTableSetup.length > 0 ) {\n wptbTableSetup = wptbTableSetup[0];\n\n wptbTableSetup.innerHTML = '';\n if( window.wptbTableStateSaving[window.wptbTableStateNumberShow] ) {\n if( window.wptbTableStateSaving[window.wptbTableStateNumberShow][0] && \n typeof window.wptbTableStateSaving[window.wptbTableStateNumberShow][0] === 'object' ) {\n if( 'outerHTML' in window.wptbTableStateSaving[window.wptbTableStateNumberShow][0] ) {\n wptbTableSetup.innerHTML = window.wptbTableStateSaving[window.wptbTableStateNumberShow][0].outerHTML;\n }\n }\n \n if( ! wptbTableSetup.innerHTML ) {\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'table';\n wptbSaveBtn.classList.add( 'wptb-save-disabled' );\n } else {\n document.getElementsByClassName('wptb-table-generator')[0].style.display = 'none';\n }\n }\n // add or change or delete style element in the head for table cells who have auto width\n if( window.wptbTableStateSaving[window.wptbTableStateNumberShow] ) {\n let head = document.head;\n if( head ) {\n let cssForTdsWidthAutoOld = head.querySelector( 'style[data-wptb-td-auto-width=\"true\"]' );\n if( cssForTdsWidthAutoOld ) {\n head.removeChild( cssForTdsWidthAutoOld );\n }\n \n if( window.wptbTableStateSaving[window.wptbTableStateNumberShow][1] ) {\n let cssForTdsWidthAuto = document.createElement( 'style' );\n cssForTdsWidthAuto.setAttribute( 'data-wptb-td-auto-width', true );\n cssForTdsWidthAuto.innerHTML = window.wptbTableStateSaving[window.wptbTableStateNumberShow][1];\n head.appendChild( cssForTdsWidthAuto );\n }\n }\n }\n \n \n let body = document.getElementsByTagName( 'body' );\n if( body.length > 0 ) {\n body = body[0];\n }\n \n // add or change or delete script element from the bottom page which have data for several control types\n let wptbElementDatas = document.getElementsByClassName( 'wptb-element-datas' );\n if( window.wptbTableStateSaving[window.wptbTableStateNumberShow] && window.wptbTableStateSaving[window.wptbTableStateNumberShow][2] ) {\n \n if( wptbElementDatas.length > 0 ) {\n wptbElementDatas = wptbElementDatas[0];\n } else {\n wptbElementDatas = document.createElement( 'sctipt' );\n wptbElementDatas.classList.add( 'wptb-element-datas' );\n body.appendChild( wptbElementDatas );\n }\n \n wptbElementDatas.innerHTML = window.wptbTableStateSaving[window.wptbTableStateNumberShow][2];\n } else {\n if( wptbElementDatas.length > 0 ) {\n wptbElementDatas = wptbElementDatas[0];\n body.removeChild( wptbElementDatas );\n }\n }\n \n // runs function which adds or create or delete CSS in the head for several element settings\n if( window.wptbTableStateSaving[window.wptbTableStateNumberShow] ) {\n WPTB_Helper.elementsStylesSetFromObject( window.wptbTableStateSaving[window.wptbTableStateNumberShow][3] );\n }\n\n WPTB_Helper.elementOptionsPanelClear();\n WPTB_LeftPanel();\n\n let wptbLeftScrollPanelCellSetting = document.getElementById( 'wptb-left-scroll-panel-cell-settings' ); \n if( wptbLeftScrollPanelCellSetting ) {\n wptbLeftScrollPanelCellSetting.classList.remove( 'visible' );\n }\n }\n }\n }\n \n this.tableStateClear = function() {\n delete window.wptbTableStateSaving;\n delete window.wptbTableStateNumberShow;\n \n let wptbSaveBtn = document.getElementsByClassName( 'wptb-save-btn' );\n if( wptbSaveBtn.length > 0 ) {\n wptbSaveBtn = wptbSaveBtn[0];\n \n wptbSaveBtn.removeAttribute( 'data-wptb-table-state-number-save' );\n }\n \n let wptbUndo = document.getElementsByClassName( 'wptb-undo' );\n if( wptbUndo.length > 0 ) {\n wptbUndo = wptbUndo[0];\n \n wptbUndo.classList.add( 'wptb-undoredo-disabled' );\n }\n \n let wptbRedo = document.getElementsByClassName( 'wptb-redo' );\n if( wptbRedo.length > 0 ) {\n wptbRedo = wptbRedo[0];\n\n wptbRedo.classList.add( 'wptb-undoredo-disabled' );\n }\n }\n}","var WPTB_innerElementSet = function ( element ) {\n \n element.ondragenter = function (e) {\n var div;\n if ( e.dataTransfer.types.indexOf( 'wptbelement' ) == -1 && e.dataTransfer.types.indexOf( 'wptb-moving-mode' ) == -1 ) {\n return;\n }\n WPTB_DropHandle(this, e);\n \n element.classList.add( 'wptb-ondragenter' );\n }\n element.ondragover = function (e) {\n e.preventDefault();\n WPTB_DropHandle(this, e);\n }\n element.ondragleave = function () {\n \n }\n element.ondrop = function(e) {\n this.classList.remove( 'wptb-ondragenter' );\n let element, classId;\n e.preventDefault();\n e.stopPropagation();\n\n if (!e.dataTransfer.getData('wptbElement') && !e.dataTransfer.getData('node')) {\n return;\n }\n let wptbDropHandle,\n wptbDropBorderMarker;\n if ( document.getElementsByClassName( 'wptb-drop-handle' ).length > 0 ) {\n wptbDropHandle = document.getElementsByClassName( 'wptb-drop-handle' )[0];\n }\n if( document.getElementsByClassName( 'wptb-drop-border-marker' ).length > 0 ) {\n wptbDropBorderMarker = document.getElementsByClassName( 'wptb-drop-border-marker' )[0];\n }\n\n if ( e.dataTransfer.getData( 'wptbElement' ) ) {\n element = WPTB_Helper.newElementProxy( e.dataTransfer.getData( 'wptbElement' ) );\n element = element.getDOMElement();\n } else {\n classId = e.dataTransfer.getData( 'node' );\n element = document.getElementsByClassName( classId )[0];\n //element.classList.remove( 'wptb-moving-mode' );\n }\n \n if( wptbDropHandle.style.display == 'block' ) {\n let td;\n if( wptbDropHandle.dataset.text == 'Drop Here' ) {\n td = wptbDropHandle.getDOMParentElement();\n td.appendChild( element );\n } else {\n let innerElement = wptbDropHandle.getDOMParentElement();\n td = innerElement.parentNode;\n\n if( wptbDropHandle.dataset.text == 'Above Element' ) {\n td.insertBefore( element, innerElement );\n } else if( wptbDropHandle.dataset.text == 'Below Element' ) {\n let innerElementNext = innerElement.nextSibling;\n td.insertBefore( element, innerElementNext );\n }\n }\n \n let thisRow = td.parentNode;\n if( WPTB_Helper.rowIsTop( thisRow ) ) { \n let table = WPTB_Helper.findAncestor( thisRow, 'wptb-preview-table' );\n \n if( table.classList.contains( 'wptb-table-preview-head' ) ) {\n WPTB_Helper.dataTitleColumnSet( table );\n }\n }\n \n // start item javascript if item is new\n let infArr = element.className.match(/wptb-element-(.+)-(\\d+)/i);\n let elemKind = infArr[1];\n if ( e.dataTransfer.getData( 'wptbElement' ) && ( elemKind == 'text' || elemKind == 'button' || elemKind == 'image' || elemKind == 'star_rating' || elemKind == 'list' ) ) {\n //WPTB_Helper.elementStartScript( element );\n }\n } else {\n return;\n }\n \n wptbDropHandle.style.display = 'none';\n wptbDropBorderMarker.style.display = 'none';\n\n WPTB_innerElementSet( element );\n \n if( ! element.classList.contains( 'wptb-image-container' ) || element.classList.contains( 'wptb-moving-mode' ) ) {\n element.classList.remove( 'wptb-moving-mode' );\n let wptbTableStateSaveManager = new WPTB_TableStateSaveManager();\n wptbTableStateSaveManager.tableStateSet();\n } \n return true;\n }\n element.onmouseover = function(e) {\n element.classList.remove( 'wptb-ondragenter' );\n }\n}","var applyGenericItemSettings = function ( element, kindIndexProt, copy = false ) {\n var node = element.getDOMElement(),\n index,\n copy;\n if( node.classList.contains( 'wptb-ph-element' ) ) {\n if ( kindIndexProt == undefined || copy == true ) {\n index = document.counter.nextIndex( element.kind );\n let wptbElements = document.getElementsByClassName( 'wptb-ph-element' );\n let elementIndexesArr = [];\n for( let i = 0; i < wptbElements.length; i++ ) {\n var regex = new RegExp( 'wptb-element-' + element.kind + '-(\\\\d+)', \"i\" );\n let infArr = wptbElements[i].className.match( regex );\n if( infArr ) {\n elementIndexesArr.push( infArr[1] );\n }\n }\n if( elementIndexesArr.length > 0 ) {\n let elementIndexMax = Math.max( ...elementIndexesArr );\n index = elementIndexMax + 1;\n } else { \n index = 1;\n }\n\n if( copy ) {\n // change all data-elements which save parameters for different controls\n let wptbNodeattributes = [...node.attributes];\n for( let i = 0; i < wptbNodeattributes.length; i++ ) {\n if( wptbNodeattributes[i] && typeof wptbNodeattributes[i] === 'object' && wptbNodeattributes[i].nodeName ) {\n let regularText = new RegExp( 'data-wptb-el-' + element.kind + '-(\\\\d+)-(.+)', \"i\" );\n let attr = wptbNodeattributes[i].nodeName.match( regularText );\n if( attr && Array.isArray( attr ) ) {\n let newDataAttributeName = wptbNodeattributes[i].nodeName.replace( element.kind + '-' + attr[1], element.kind + '-' + index );\n let newDataAttributeValue = wptbNodeattributes[i].nodeValue;\n node.removeAttribute( wptbNodeattributes[i].nodeName );\n node.setAttribute( newDataAttributeName, newDataAttributeValue );\n }\n }\n }\n }\n } else if ( kindIndexProt && ! copy ) {\n let kindIndexProtArr = kindIndexProt.split('-');\n index = kindIndexProtArr[kindIndexProtArr.length - 1];\n // start element javascript if element is new\n \n }\n\n let node_wptb_element_kind_num = node.className.match(/wptb-element-(.+)-(\\d+)/i);\n if ( node_wptb_element_kind_num ) {\n node.classList.remove( node_wptb_element_kind_num[0] );\n }\n if ( ! node.classList.contains( 'wptb-ph-element' ) ) {\n node.classList.add( 'wptb-ph-element' );\n if( ! node.classList.contains( 'wptb-element-' + element.kind + '-' + index ) ) {\n node.classList.add( 'wptb-element-' + element.kind + '-' + index );\n }\n } else {\n if( ! node.classList.contains( 'wptb-element-' + element.kind + '-' + index ) ) {\n node.classList.add( 'wptb-element-' + element.kind + '-' + index );\n }\n }\n new WPTB_ElementOptions( element, index, kindIndexProt );\n WPTB_Helper.elementStartScript( element.getDOMElement() );\n document.counter.increment(element.kind);\n }\n \n node.onmouseenter = function ( event ) {\n if( event.target.classList.contains( 'wptb-moving-mode' ) ) {\n return;\n }\n \n let wptbActionsField = new WPTB_ActionsField();\n \n wptbActionsField.addActionField( 1, node );\n \n wptbActionsField.setParameters( node );\n \n node.classList.remove( 'wptb-ondragenter' );\n };\n \n node.onmouseleave = function ( event ) {\n let wptbActionsField = new WPTB_ActionsField();\n \n wptbActionsField.leaveFromField( event, node );\n };\n};"]}
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,W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sField = 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};"]}
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 i(){var p=this;this.wptbActions,0!=document.getElementsByClassName("wptb-actions").length&&(this.wptbActions=document.getElementsByClassName("wptb-actions")[0]),this.addActionField=function(e,t){var a=document.getElementsByTagName("body")[0],n=document.getElementsByClassName("wptb-actions");if(0!=n.length){var l=n[0].activeElem;for(l&&l.classList.remove("wptb-directlyhovered");0!=n.length;)n[0].parentNode.removeChild(n[0])}if(1==e){var r=void 0,o=void 0;if(r=document.createElement("span"),o=document.createElement("span"),(n=document.createElement("div")).classList.add("wptb-actions"),r.classList.add("dashicons","dashicons-trash","wptb-delete-action"),o.classList.add("dashicons","dashicons-admin-page","wptb-duplicate-action"),n.appendChild(o),n.appendChild(r),a.appendChild(n),n.activeElem=t,n.type=1,r.onclick=function(e){var t=e.target.parentNode.activeElem,a=t.parentNode,n=t.className.match(/wptb-element-(.+)-(\d+)/i);if(t&&n&&Array.isArray(n)&&(WPTB_Helper.elementControlsStateDelete(t),WPTB_Helper.externalCssStylesDelete(n[0])),t&&a.removeChild(t),t&&"object"===(void 0===t?"undefined":_typeof(t))&&t.hasOwnProperty("kind")&&"text"==t.kind){var l=a.parentNode;if(WPTB_Helper.rowIsTop(l)){var r=WPTB_Helper.findAncestor(l,"wptb-preview-table");r.classList.contains("wptb-table-preview-head")&&WPTB_Helper.dataTitleColumnSet(r)}}(new i).actionsRemove(),(new WPTB_TableStateSaveManager).tableStateSet()},o.onclick=function(e){var t,a=void 0,n=void 0,l=e.target.parentNode.activeElem,r=l.parentNode;if((t=l.className.match(/wptb-element-(.+)-(\d+)/i))&&Array.isArray(t)){n=t[1];var o={};o.kind=n,o.elemProt=l,o.tinyMceClear=!0,a=new WPTB_ElementObject(o),WPTB_Helper.elementControlsStateCopy(l,a.getDOMElement()),WPTB_Helper.externalCssStylesCopy(l,a.getDOMElement()),r.insertBefore(a.getDOMElement(),l.nextSibling)}else{a={};var s=l.cloneNode(!0);s.classList.remove("wptb-directlyhovered"),a.getDOMElement=function(){return s},applyGenericItemSettings(a),r.insertBefore(a.getDOMElement(),l.nextSibling),WPTB_Helper.wptbDocumentEventGenerate("wptb-inner-element:copy",l,a.getDOMElement())}WPTB_innerElementSet(a.getDOMElement()),new i(1,l).setParameters(l),(new WPTB_TableStateSaveManager).tableStateSet()},t.classList.contains("wptb-ph-element")){var s=void 0;(s=document.createElement("span")).classList.add("dashicons","dashicons-move","wptb-move-action"),s.draggable=!0,n.appendChild(s),s.ondragstart=function(e){var t,a=wp.template("wptb-element-icons-directories")({}),n=JSON.parse(a),l=void 0,r=e.target.parentNode.activeElem,o=void 0;if((t=r.className.match(/wptb-element-(.+)-(\d+)/i))&&Array.isArray(t)){o=t[1],r.classList.add("wptb-moving-mode"),n&&"object"===(void 0===n?"undefined":_typeof(n))&&n[o]&&(l=WPTB_Helper.getElementIcon(n[o])),e.dataTransfer.effectAllowed="move",e.dataTransfer.setDragImage(l,0,0),e.dataTransfer.setData("node","wptb-element-"+t[1]+"-"+t[2]),e.dataTransfer.setData("wptb-moving-mode","wptb-element-"+t[1]+"-"+t[2]),e.dataTransfer.setData("wptbElIndic-"+t[1],"wptbElIndic-"+t[1]);var s=e.target.parentNode.activeElem;if("text"==s.kind){var i=s.parentNode.parentNode;if(WPTB_Helper.rowIsTop(i)){var d=WPTB_Helper.findAncestor(i,"wptb-preview-table");d.classList.contains("wptb-table-preview-head")&&WPTB_Helper.dataTitleColumnSet(d)}}}else p.style.display="none",console.log(p);p.actionsHide()},s.ondragend=function(e){WPTB_Helper.elementDragEndClear()}}n.style.display="block",p.wptbActions=n}},this.setParameters=function(t){if(!p.wptbActions){var e=document.getElementsByClassName("wptb-actions");0<e.length?p.wptbActions=e[0]:p.wptbActions=!1}if(p.wptbActions&&p.wptbActions.classList.contains("wptb-actions")){p.wptbActions.style.display="block";var a=t.getBoundingClientRect(),n=document.getElementsByClassName("wptb-container")[0],l=function(){var e=t.getBoundingClientRect();p.wptbActions.style.top=parseFloat(e.top)-15+"px"};n.removeEventListener("scroll",l,!1),p.wptbActions.style.top=parseFloat(a.top)-15+"px",p.wptbActions.style.left=parseFloat(a.right)-parseFloat(p.wptbActions.clientWidth)+1+"px",p.wptbActions.style.display="block",t.classList.add("wptb-directlyhovered"),n.addEventListener("scroll",l,!1)}},this.leaveFromField=function(e,t,a){if(!p.wptbActions){var n=document.getElementsByClassName("wptb-actions");0<n.length?p.wptbActions=n[0]:p.wptbActions=!1}if(p.wptbActions){if(e.relatedTarget&&(e.relatedTarget.classList.contains("wptb-actions")||e.relatedTarget.classList.contains("wptb-move-action")||e.relatedTarget.classList.contains("wptb-duplicate-action")||e.relatedTarget.classList.contains("wptb-delete-action")))return p.wptbActions||(p.wptbActions=document.getElementsByClassName("wptb-actions")[0]),void(p.wptbActions.onmouseleave=function(e){null!=e.relatedTarget&&(e.relatedTarget.classList.contains("wptb-ph-element")||WPTB_Helper.findAncestor(e.relatedTarget,"wptb-ph-element"))&&e.relatedTarget!=p.wptbActions.activeElem&&(WPTB_Helper.findAncestor(e.relatedTarget,"wptb-directlyhovered"),p.wptbActions.activeElem),(new i).leaveFromField(e,e.relatedTarget.parentNode.parentNode),e.target.activeElem.classList.remove("wptb-directlyhovered")});t.classList.remove("wptb-directlyhovered"),p.wptbActions.style.display="none",e.relatedTarget&&(e.relatedTarget.classList.contains("wptb-ph-element")||WPTB_Helper.findAncestor(e.relatedTarget,"wptb-ph-element"))&&(p.addActionField(1,e.relatedTarget.parentNode),p.setParameters(e.relatedTarget.parentNode))}},this.actionsRemove=function(){if(!p.wptbActions){var e=document.getElementsByClassName("wptb-actions");0<e.length&&(p.wptbActions=e[0])}p.wptbActions&&p.wptbActions.parentNode.removeChild(p.wptbActions)},this.actionsHide=function(){if(!p.wptbActions){var e=document.getElementsByClassName("wptb-actions");0<e.length&&(p.wptbActions=e[0])}p.wptbActions&&(p.wptbActions.style.opacity=0)}};document.addEventListener("DOMContentLoaded",function(){var r=WPTB_Helper.detectMode();if(r){var o=new XMLHttpRequest,e=ajaxurl+"?action=get_table&id="+r;o.open("GET",e,!0),o.setRequestHeader("Content-type","application/x-www-form-urlencoded"),o.onreadystatechange=function(e){if(4!=this.readyState||200!=this.status);else{var t=JSON.parse(o.responseText);if(document.getElementById("wptb-setup-name").value=t[0],t[1]){document.getElementsByClassName("wptb-table-generator")[0].style.display="none",document.getElementsByClassName("wptb-table-setup")[0].appendChild(WPTB_Parser(t[1]));var a=document.getElementsByTagName("body")[0];if(t[2]){var n=document.createElement("script");n.setAttribute("type","text/html"),n.setAttribute("class","wptb-element-datas"),n.innerHTML=t[2],a.appendChild(n)}WPTB_Table();var l=document.querySelector(".wptb-preview-table");l&&(l.className.match(/wptb-element-((.+-)\d+)/i)||l.classList.add("wptb-element-main-table_setting-"+r)),WPTB_LeftPanel(),WPTB_Settings(),(new WPTB_TableStateSaveManager).tableStateSet(),WPTB_Helper.elementOptionsSet("table_setting",l)}else document.getElementsByClassName("wptb-table-generator")[0].style.display="table"}},o.send(null)}else document.getElementsByClassName("wptb-table-generator")[0].style.display="table";document.counter=new ElementCounters,document.select=new MultipleSelect,WPTB_Initializer(),settings=WPTB_Settings()});var WPTB_Cell=function(e,a){if(!a){(a=document.createElement("td")).style.padding=jQuery("#wptb-table-padding-number").val()+"px";var t=jQuery("#wptb-table-inner-border-number").val();""!=t&&0!=parseInt(t)&&(a.style.border=t+"px solid "+jQuery("#wptb-table-border-color").val()),a.classList.add("wptb-droppable","wptb-cell"),console.log("wptb_cell_test")}a.draggable=!1,e&&(a.onclick=e),a.ondblclick=function(e){if(e.stopPropagation(),!WPTB_Helper.findAncestor(a,"wptb-preview-table-manage-cells")&&e.target==e.currentTarget){WPTB_Helper.wptbDocumentEventGenerate("table:cell:dblclick",e.target);var t=WPTB_Helper.newElementProxy("text");t=t.getDOMElement(),a.appendChild(t),WPTB_innerElementSet(t)}},WPTB_innerElementSet(a);var o=a.getElementsByClassName("wptb-ph-element");if(0<o.length)for(var n=function(l){o[l].getDOMElement=function(){return o[l]},WPTB_innerElementSet(o[l]);var r=o[l].className.match(/wptb-element-((.+-)\d+)/i);r&&Array.isArray(r)&&function(){var e=r[1].split("-");o[l].kind=e[0],applyGenericItemSettings(o[l],r[1]);var a=o[l].getElementsByClassName("wptb-in-element");if(0<a.length)for(var t=function(e){var t={getDOMElement:function(){return a[e]}};applyGenericItemSettings(t)},n=0;n<a.length;n++)t(n)}()},l=0;l<o.length;l++)n(l);return this.getDOMElement=function(){return a},this.setCoords=function(e,t){var a=this.getDOMElement();a.dataset.yIndex=e,a.dataset.xIndex=t},this.getCoords=function(){var e,t=this.getDOMElement();return e.x=t.dataset.xIndex,e.y=t.dataset.yIndex,e},this.appendElement=function(e){getDOMElement().appendChild(e)},a.getCellDimensions=function(){var e=window.getComputedStyle(this,null),t=e.getPropertyValue("padding-left"),a=e.getPropertyValue("padding-right"),n=e.getPropertyValue("border-left-width"),l=e.getPropertyValue("border-right-width"),r=e.getPropertyValue("padding-top"),o=e.getPropertyValue("padding-bottom"),s=e.getPropertyValue("border-top-width"),i=e.getPropertyValue("border-bottom-width"),d=parseInt(this.offsetWidth,10)-parseInt(t,10)-parseInt(a,10)-parseInt(n,10)/2-parseInt(l,10)/2,p=parseInt(this.offsetHeight,10)-parseInt(r,10)-parseInt(o,10)-parseInt(s,10)/2-parseInt(i,10)/2,c=WPTB_Helper.findAncestor(this,"wptb-preview-table");if(c){var m=window.getComputedStyle(c,null),b=m.getPropertyValue("border-left-width"),u=m.getPropertyValue("border-right-width"),w=m.getPropertyValue("border-top-width"),g=m.getPropertyValue("border-bottom-width"),v=this.parentNode;if(v&&"tr"===v.nodeName.toLowerCase()){v.firstChild&&v.firstChild.dataset.xIndex===this.dataset.xIndex&&parseInt(b,10)>parseInt(n,10)&&(d+=-(parseInt(b,10)-parseInt(n,10))/2),v.lastChild&&v.lastChild.dataset.xIndex===this.dataset.xIndex&&parseInt(u,10)>parseInt(l,10)&&(d+=-(parseInt(u,10)-parseInt(l,10))/2);var h=v.parentNode;h&&"body"===h.nodeName.toLowerCase()&&(h.firstChild&&h.firstChild.firstChild.dataset.yIndex===this.dataset.yIndex&&parseInt(w,10)>parseInt(s,10)&&(p+=(parseInt(w,10)-parseInt(s,10))/2),h.lastChild&&h.lastChild.firstChild.dataset.yIndex===this.dataset.yIndex&&parseInt(g,10)>parseInt(i,10)&&(p+=(parseInt(g,10)-parseInt(i,10))/2))}}return{width:parseInt(d),height:parseInt(p)}},this},WPTB_DropHandle=function(s,e){var i=void 0,d=void 0;if(0==document.getElementsByClassName("wptb-drop-handle").length){(i=document.createElement("div")).classList.add("wptb-drop-handle"),(d=document.createElement("div")).classList.add("wptb-drop-border-marker");var t=document.createElement("div"),a=document.createElement("div"),n=document.createElement("div"),l=document.createElement("div");t.classList.add("wptb-drop-border-marker-top"),a.classList.add("wptb-drop-border-marker-right"),n.classList.add("wptb-drop-border-marker-bottom"),l.classList.add("wptb-drop-border-marker-left"),d.appendChild(t),d.appendChild(a),d.appendChild(n),d.appendChild(l);var r=document.getElementsByTagName("body");0<r.length&&(r[0].appendChild(i),r[0].appendChild(d)),i.ondragenter=function(){},i.ondragover=function(e){e.preventDefault()},i.ondragleave=function(){},i.ondrop=function(e){e.preventDefault();var t=void 0;e.dataTransfer.getData("wptbElement")?t=(t=WPTB_Helper.newElementProxy(e.dataTransfer.getData("wptbElement"))).getDOMElement():((t=document.getElementsByClassName(e.dataTransfer.getData("node"))[0]).classList.remove("wptb-moving-mode"),t.classList.remove("wptb-moving-into-same-elem"),t.wptbMovingMode=1);var a=void 0;if("Drop Here"==i.dataset.text)"td"==(s=i.getDOMParentElement()).nodeName.toLowerCase()&&(a=i.getDOMParentElement()).appendChild(t);else{var n=i.getDOMParentElement();if(a=n.parentNode,"Above Element"==i.dataset.text)a.insertBefore(t,n);else if("Below Element"==i.dataset.text){var l=n.nextSibling;a.insertBefore(t,l)}}var r=a.parentNode;if(WPTB_Helper.rowIsTop(r)){var o=WPTB_Helper.findAncestor(r,"wptb-preview-table");o.classList.contains("wptb-table-preview-head")&&WPTB_Helper.dataTitleColumnSet(o)}t.className.match(/wptb-element-(.+)-(\d+)/i)[1];(e.dataTransfer.getData("wptbElement"),i.style.display="none",d.style.display="none",WPTB_innerElementSet(t),t.classList.contains("wptb-image-container")&&1!=t.wptbMovingMode)||((new WPTB_TableStateSaveManager).tableStateSet(),t.wptbMovingMode)},document.querySelector(".wptb-container").onscroll=function(){i.style.display="none",d.style.display="none"}}else i=document.getElementsByClassName("wptb-drop-handle")[0],d=document.getElementsByClassName("wptb-drop-border-marker")[0];if(!s||"td"!=s.nodeName.toLowerCase()||0==s.getElementsByClassName("wptb-ph-element").length){var o=void 0;if("td"==s.localName?o=s.parentNode:"div"==s.localName&&s.classList.contains("wptb-ph-element")&&(o=s.parentNode.parentNode),WPTB_Helper.rowIsTop(o))if(WPTB_Helper.findAncestor(o,"wptb-preview-table").classList.contains("wptb-table-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}i.style.width=s.offsetWidth+"px";var u=s.offsetHeight,w=s.getBoundingClientRect(),g=parseFloat(w.left),v=void 0;if(i.style.left=g+"px",-1!=e.dataTransfer.types.indexOf("wptb-moving-mode")){var h=document.getElementsByClassName("wptb-moving-mode")[0];s==h?(i.classList.add("wptb-moving-into-same-elem"),d.classList.add("wptb-moving-into-same-elem")):(i.classList.remove("wptb-moving-into-same-elem"),d.classList.remove("wptb-moving-into-same-elem"))}if(i.getDOMParentElement=function(){return s},i.style.display="block",d.style.display="block","td"!=s.nodeName.toLowerCase()){var f=null==e.offsetY?e.layerY:e.offsetY;v=parseFloat(w.top)-parseFloat(11),i.dataset.text="Above Element",u/2<f&&(v=parseFloat(w.top)+u-1,i.dataset.text="Below Element")}else i.dataset.text="Drop Here",v=parseFloat(w.top)+u/2-5;i.style.top=v+"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(s.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 s=o(e);s=s.replace(/\r|\n|\t/g,"").trim(),t.innerHTML=s}var i=t.querySelectorAll(".wptb-in-element");if(0<i.length)for(var d=function(e){var t={getDOMElement:function(){return i[e]}};applyGenericItemSettings(t)},p=0;p<i.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 s=l[o].children,i=0;i<s.length;i++){var d=s[i];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 s=document.getElementsByClassName("wptb-element-"+l+"-"+r)[0];if("button"==l)"button-text-color"==o.dataset.type?s.getElementsByClassName("wptb-button")[0].style.color=a:s.getElementsByClassName("wptb-button")[0].style.backgroundColor=a;else if("list"==l){var i=s.querySelectorAll("p");if(0<i.length)for(var d=0;d<i.length;d++)i[d].style.color=a}else if("star_rating"==l){if("star-color"==o.dataset.type)for(var p=s.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){s.querySelector(".wptb-number-rating").style.color=a}}else s.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 s=e.querySelectorAll("[contenteditable]");if(0<s.length)for(var i=0;i<s.length;i++)s[i].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++)console.log(n),n[r]&&l(n[r],a);else l(n,a)}}},controlsInclude:function(i,d){i&&"object"===(void 0===i?"undefined":_typeof(i))&&"function"==typeof d&&i.addEventListener("element:control:active",function(){var l=i.className.match(/wptb-element-(.+)-(\d+)/i),o=void 0;if(l&&Array.isArray(l)&&(o=l[1]),!i.hasOwnProperty("сontrolsConnectIndic")||!0!==i.сontrolsConnectIndic&&o){var s=document.getElementsByClassName("wptb-element-datas");0<s.length&&function(){var e=(s=s[0]).innerHTML,r=[];if(e&&(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){i.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,i)},!1),i.с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 s="wptb-el-"+t[1]+"-"+e;n.addEventListener("wptb-control:"+s,function(e){var t=document.getElementsByClassName(s);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 s=document.getElementsByClassName(e);if(0<s.length){s=s[0];var i=WPTB_Helper.findAncestor(s,"wptb-element-option");if(i){var d=function(e){var t=document.getElementsByClassName("wptb-element-datas");if(0<t.length){var a=(t=t[0]).innerHTML;if(a&&(a=JSON.parse(a))&&"object"===(void 0===a?"undefined":_typeof(a))&&"tmpl-wptb-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)?i.style.display="block":r[2]&&Array.isArray(r[2])&&-1!==r[2].indexOf(l)&&(i.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 s=WPTB_Helper.targetControlValueGet(a);r["data-"+e]=s,(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=JSON.parse(o))&&"object"===(void 0===o?"undefined":_typeof(o)))if(t){var i=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]=i,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"):t="checkbox"==e[a].type?1==e[a].checked?"checked":"unchecked":e[a].value;return t},elementControlsStateCopy:function(e,t){if(e&&t){var a=e.className.match(/wptb-element-((.+-)\d+)/i),n=t.className.match(/wptb-element-((.+-)\d+)/i);if(a&&Array.isArray(a)&&n&&Array.isArray(n)){var l=a[1],r=n[1],o=document.getElementsByClassName("wptb-element-datas");if(0<o.length){var s=(o=o[0]).innerHTML;if(s&&(s=JSON.parse(s))&&"object"===(void 0===s?"undefined":_typeof(s))){var i=s["tmpl-wptb-el-datas-"+l];if(i&&"object"===(void 0===i?"undefined":_typeof(i))){var d={};Object.keys(i).forEach(function(e){var t=i[e],a=e.replace(l,r);d[a]=t}),0<Object.keys(d).length&&(s["tmpl-wptb-el-datas-"+r]=d,s=JSON.stringify(s),o.innerHTML=s)}}}}}},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=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,i,d,n="wptb-"+e+"-control-stack",l=wp.template(n),r=void 0,o=void 0,p=void 0,c=document.createElement("div"),s=t.className.match(/wptb-element-((.+-)\d+)/i);if(!s&&t.classList.contains("wptb-preview-table")){var m=WPTB_Helper.detectMode();t.classList.add("wptb-element-main-table_setting-"+m),s=t.className.match(/wptb-element-((.+-)\d+)/i)}if(a={container:"."+s[0]},i=s[0],d=s[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-"+s[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),v=(r=document.getElementById(o)).children,h=0;h<v.length;h++)r.removeChild(v[h]);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=i,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 s=document.createElement("script");s.setAttribute("type","text/javascript"),s.innerHTML=o.replace(/\r|\n|\t/g,"").trim(),f.push(s)}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 s=document.head;if(s){var i=s.querySelector("#styles-"+e);if(i){var d=i.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("}")?i.innerHTML=p.join("}")+"}":s.removeChild(i),c=!0;break}}c||(i.innerHTML=n?d+t+"{"+a+":"+n+";}":d)}else n?i.innerHTML=t+"{"+a+":"+n+";}":s.removeChild(i)}else if(n){var v=document.createElement("style");v.setAttribute("id","styles-"+e),v.classList.add("styles-wptb-elements"),v.innerHTML=t+"{"+a+":"+n+";}",s.appendChild(v)}}},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 s=t.className.match(/wptb-element-(.+)-(\d+)/i);if(s&&Array.isArray(s)){o.setAttribute("id","styles-"+s[0]);var i=r.innerHTML,d=WPTB_Helper.replaceAll(i,n,s[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(o,s,e){if(e||s||!o.target.dataset.wptbTableStateNumberSave&&0==window.wptbTableStateNumberShow||(window.wptbTableStateNumberShow,o.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 i=new XMLHttpRequest,a=(wptb_admin_object?wptb_admin_object.ajaxurl:ajaxurl)+"?action=save_table",d=document.getElementById("wptb-setup-name").value.trim(),p=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 c=!1;if(0<n.length){var m=(n=n[0]).cloneNode(!0);r&&m.classList.contains("wptb-element-main-table_setting-startedid-0")&&(m.classList.remove("wptb-element-main-table_setting-startedid-0"),m.classList.add("wptb-element-main-table_setting-"+r),c=!0),m.columns=n.columns,n=(n=WPTB_Stringifier(m)).outerHTML}else n="";if(!e){l="";var b=document.getElementsByClassName("wptb-element-datas");0<b.length&&b[0].innerHTML&&(l=b[0].innerHTML,c&&(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(c&&(u=WPTB_Helper.replaceAll(u,".wptb-element-main-table_setting-startedid-0",".wptb-element-main-table_setting-"+r)),""===d&&""===n){var w="";return""===d&&(w+="You must assign a name to the table before saving it.</br>"),""===n&&(w+="Table wasn't created"),(p=document.getElementById("wptb-messaging-area")).innerHTML='<div class="wptb-error wptb-message">Error: '+w+"</div>",p.classList.add("wptb-warning"),void setTimeout(function(){p.removeChild(p.firstChild)},4e3)}var g={title:d,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),i.open("POST",a,!0),i.setRequestHeader("Content-type","application/json; charset=utf-8"),i.onreadystatechange=function(e){if(4==this.readyState&&200==this.status){var t=JSON.parse(i.responseText);if(p=document.getElementById("wptb-messaging-area"),"saved"==t[0])return console.log(window.wptbTableStateSaving),window.history.pushState(null,null,document.location.href.replace("#","")+"&table="+t[1]),void WPTB_Helper.saveTable(o,!0);if("edited"==t[0]&&s){document.wptbId=t[1],p.innerHTML='<div class="wptb-success wptb-message">Table "'+d+'" 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 a=document.getElementsByClassName("wptb-preview-btn");if(0<a.length){(a=a[0]).classList.remove("wptb-button-disable");var n=a.dataset.previewHref;n=n.replace("empty",t[1]),a.setAttribute("href",n)}o.target.dataset.wptbTableStateNumberSave=window.wptbTableStateNumberShow;var l=document.getElementsByClassName("wptb-save-btn");0<l.length&&(l=l[0]).classList.add("wptb-save-disabled")}else if("edited"==t[0]){p.innerHTML='<div class="wptb-success wptb-message">Table "'+d+'" was successfully updated.</div>',o.target.dataset.wptbTableStateNumberSave=window.wptbTableStateNumberShow;var r=document.getElementsByClassName("wptb-save-btn");0<r.length&&(r=r[0]).classList.add("wptb-save-disabled")}else{if("preview_edited"==t[0])return;p.innerHTML='<div class="wptb-error wptb-message">Safety problems</div>'}p.classList.add("wptb-success"),setTimeout(function(){p.removeChild(p.firstChild)},4e3)}},i.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 e.hasOwnProperty("makeTableResponsive")?"checked"==e.makeTableResponsive?t.dataset.wptbAdaptiveTable=1:"unchecked"==e.makeTableResponsive&&(t.dataset.wptbAdaptiveTable=0):e.hasOwnProperty("tableManageCells")&&t.toggleTableEditMode()});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"],s=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<s;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 s=0;s<o.length;s++)o[s].classList.remove("mce-content-body");var i=l[r].querySelectorAll("[data-mce-style]");if(0<i.length)for(var d=0;d<i.length;d++)i[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"),v=g.length;0<v&&g[0]&&g[0].parentNode;)g[0].parentNode.removeChild(g[0]),v--;var h=l[r].querySelectorAll("[data-mce-bogus]");if(0<h.length){h=[].concat(_toConsumableArray(h));for(var f=0;f<h.length;f++)h[f]&&h[f].parentNode&&h[f].parentNode.removeChild(h[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 L,a,n,v,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"),s=document.getElementById("wptb-left-scroll-panel-cell-settings"),i=C(this),d=i[0],p=i[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");s.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"),v=b.style.width;if(v)u.value=parseFloat(v,10),w.value=parseFloat(v,10),g.checked=!0;else if(b.dataset.wptbFixedWidth)u.value=b.dataset.wptbFixedWidth,w.value=b.dataset.wptbFixedWidth,g.checked=!0;else{var h=WPTB_Helper.getColumnWidth(L,b);u.value=h,w.value=h,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(L,b);f.value=B,y.value=B,S.checked=!1}}s.classList.add("visible")}else{for(c=0;c<o.length;c++)L.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");s.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"}L.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=L.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<v;a++)t[a]=0;for(a=0;a<L.rows.length;a++)for(var n=L.rows[a].getElementsByTagName("td"),l=cellPointer=0;l<v;l+=stepsToMove)if(stepsToMove=1,t[l])t[l]--;else{var r=n[cellPointer++];if(r==e)return[a,l];if(1<r.rowSpan){for(var o=0;o<r.colSpan;o++)t[l+o]=r.rowSpan-1;stepsToMove=r.colSpan}else 1<r.colSpan&&(stepsToMove=r.colSpan)}};if(jQuery("#wptb-table-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");(L=document.createElement("table")).classList.add("wptb-preview-table","wptb-element-main-table_setting-startedid-0"),L.style.border="0px solid",L.dataset.reconstraction=1,L.dataset.wptbAdaptiveTable=1;for(r=0;r<t;r++){(a=L.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 s=(L=o[0]).getElementsByTagName("td");if(0<s.length)for(var i=0;i<s.length;i++)WPTB_Cell(T,s[i])}L.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 s=0;s<o.length;s++)o[s].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")},L.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 s=0,i=0;i<a.length;i++){if(null!=r[o][i])for(var d=0;d<100;d++){if(null==r[o][s]){r[o][s]=a[i],a[i].dataset.xIndex=s;break}s++}else r[o][i]=a[i],a[i].dataset.xIndex=s;if(a[i].dataset.yIndex=o,1<a[i].colSpan)for(var p=1;p<a[i].colSpan;p++)s++,r[o][s]="tdDummy";if(1<a[i].rowSpan)for(var c=1;c<a[i].rowSpan;c++){null==r[o+c]&&(r[o+c]=[]);for(var m=0;m<a[i].colSpan;m++)r[o+c][s-a[i].colSpan+1+m]="tdDummy"}s++,0==o&&(l=s)}n<i&&(n=i)}this.columns=n,this.maxCols=l},L.addColumnWidth=function(m,b){var e=L.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=L.rows,l=!1,r=[],o=0;o<n.length;o++)for(var s=n[o].children,i=0;i<s.length;i++){var d=s[i];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)}L.tdDefaultWidth()}},L.tdDefaultWidth=function(){for(var e,t=L.rows,a=0,n=0,l=document.getElementsByClassName("wptb-table-setup")[0].offsetWidth,r=[],o=[],s=0,i=0,d="",p=window.getComputedStyle(L,null),c=p.getPropertyValue("border-left-width"),m=p.getPropertyValue("border-right-width"),b=parseFloat(c,10)+parseFloat(m,10),u=0;u<t.length;u++)for(var w=t[u].children,g=0;g<w.length;g++){var v=w[g];if(r[parseFloat(v.dataset.xIndex)]||o[parseFloat(v.dataset.xIndex)])o[parseFloat(v.dataset.xIndex)]?v.dataset.wptbFixedWidth||(v.dataset.wptbCssTdAutoWidth=!0):r[parseFloat(v.dataset.xIndex)]&&v.removeAttribute("data-wptb-css-td-auto-width");else if(v.style.width?(r[parseFloat(v.dataset.xIndex)]=parseFloat(v.style.width),v.removeAttribute("data-wptb-css-td-auto-width")):v.dataset.wptbFixedWidth||(o[parseFloat(v.dataset.xIndex)]=100,v.dataset.wptbCssTdAutoWidth=!0),window.getComputedStyle(v,null)){var h=window.getComputedStyle(v,null),f=h.getPropertyValue("padding-left"),y=h.getPropertyValue("padding-right");s=parseFloat(f,10)+parseFloat(y,10);var S=h.getPropertyValue("border-left-width"),T=h.getPropertyValue("border-right-width");i=parseFloat(S,10)+parseFloat(T,10),i/=2,r[parseFloat(v.dataset.xIndex)]?(r[parseFloat(v.dataset.xIndex)]+=s,r[parseFloat(v.dataset.xIndex)]+=i,0==g&&b/2<=parseFloat(S,10)?r[parseFloat(v.dataset.xIndex)]+=parseFloat(S,10)/2:0==g&&b/2>parseFloat(S,10)&&(r[parseFloat(v.dataset.xIndex)]+=b/2-parseFloat(T,10)/2),g==w.length-1&&b/2<=parseFloat(T,10)?r[parseFloat(v.dataset.xIndex)]+=parseFloat(T,10)/2:g==w.length-1&&b/2>parseFloat(T,10)&&(r[parseFloat(v.dataset.xIndex)]+=b/2-parseFloat(T,10)/2)):o[parseFloat(v.dataset.xIndex)]&&(o[parseFloat(v.dataset.xIndex)]+=s,o[parseFloat(v.dataset.xIndex)]+=i,0==g&&b/2<=parseFloat(S,10)?o[parseFloat(v.dataset.xIndex)]+=parseFloat(S,10)/2:0==g&&b/2>parseFloat(S,10)&&(o[parseFloat(v.dataset.xIndex)]+=b/2-parseFloat(S,10)/2),g==w.length-1&&b/2<=parseFloat(T,10)?o[parseFloat(v.dataset.xIndex)]+=parseFloat(T,10)/2:g==w.length-1&&b/2>parseFloat(T,10)&&(o[parseFloat(v.dataset.xIndex)]+=b/2-parseFloat(S,10)/2))}}for(var B=0;B<r.length;B++)r[B]&&(a+=r[B]);for(var E=0,C=0;C<o.length;C++)o[C]&&(n+=o[C],E++);e=a+n,L.dataset.wptbTableTdsSumMaxWidth=e,E?(L.dataset.wptbCellsWidthAutoCount=E,L.mergingСellsHorizontally?L.dataset.wptbFixedWidthSize=a:L.removeAttribute("data-wptb-fixed-width-size")):(L.removeAttribute("data-wptb-fixed-width-size"),L.removeAttribute("data-wptb-cells-width-auto-count"));var N=!1,A=void 0;e<l?E?(L.style.minWidth="100%",L.mergingСellsHorizontally?(A=(A=(l-a)/E)-s-i,N=!(L.style.width=null)):L.style.width="100%"):(L.style.width=null,L.style.minWidth=null,L.style.maxWidth=null):(L.style.maxWidth=null,L.style.minWidth=e+"px",A="100",N=!(L.style.width=null));var x=document.head;if(x){var _=x.querySelector('style[data-wptb-td-auto-width="true"]');_&&x.removeChild(_)}N&&((d=document.createElement("style")).setAttribute("data-wptb-td-auto-width",!0),d.innerHTML="[data-wptb-css-td-auto-width=true]{width:"+A+"px}",x&&x.appendChild(d))},L.addRowHeight=function(m,b){var e=L.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=L.rows,l=!1,r=[],o=0;o<n.length;o++)for(var s=n[o].children,i=0;i<s.length;i++){var d=s[i];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,i!=s.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)}},L.reconstraction=function(){var e=L.getElementsByTagName("td");L.mergingСellsHorizontally=!1,L.mergingCellsVertically=!1,L.dataset.reconstraction=1;for(var t=0,a=0;a<e.length&&(1<e[a].colSpan&&(L.dataset.reconstraction=0,L.mergingСellsHorizontally=!0,t++),1<e[a].rowSpan&&(L.dataset.reconstraction=0,L.mergingCellsVertically=!0,t++),2!=t);a++);},L.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<L.rows.length;l++)e=new WPTB_Cell(T),n&&(e.getDOMElement().setAttribute("style",n),e.getDOMElement().style.width=null,e.getDOMElement().style.height=null),L.rows[l].appendChild(e.getDOMElement()),array[l].push(0);v++,L.recalculateIndexes(),L.tdDefaultWidth(),L.addRowHeight(),WPTB_Helper.dataTitleColumnSet(L),E(),(new WPTB_TableStateSaveManager).tableStateSet()},L.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<L.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=L.rows[r].getElementsByTagName("td")[0])?L.rows[r].insertBefore(e.getDOMElement(),t):L.rows[r].appendChild(e.getDOMElement()),array[r].push(0);v++,L.recalculateIndexes(),L.tdDefaultWidth(),L.addRowHeight(),WPTB_Helper.dataTitleColumnSet(L),E(),(new WPTB_TableStateSaveManager).tableStateSet()},L.addColumnAfter=function(e){var t=L.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(v-o-l.colSpan+1==1)L.addColumnEnd();else{for(var s=!1,i=void 0,d=void 0,p=void 0,c=[],m=void 0,b=0;b<v;b++)c.push(0);for(b=0;b<t.length;b++){a=0,n=t[b].getElementsByTagName("td"),s=!1;for(var u=0;u<v;u+=i){if(i=1,s){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&&(s=!0);else if(1<(m=n[a++]).rowSpan){i=m.colSpan;for(var w=0;w<m.colSpan;w++)c[u+w]=m.rowSpan,u+w==o&&(s=!0)}else if(1<m.colSpan){i=m.colSpan;for(w=0;w<m.colSpan;w++)u+w==o&&(s=!0)}else u==o&&(s=!0)}for(var g=0;g<v;g++)0<c[g]&&c[g]--}for(b=0;b<array.length;b++)array[b].push(0);v++,B(array),L.recalculateIndexes(),L.addColumnWidth(),L.addRowHeight(),WPTB_Helper.dataTitleColumnSet(L),E(),(new WPTB_TableStateSaveManager).tableStateSet()}},L.addColumnBefore=function(){var e=document.querySelector(".wptb-highlighted"),t=C(e)[1];0===t?L.addColumnStart():L.addColumnAfter(t-1)},L.addRowToTheEnd=function(){var e=L.insertRow(-1),t=void 0,a=void 0,n=document.getElementsByClassName("wptb-preview-table");if(e.classList.add("wptb-row"),0<n.length){n=n[0];for(var l=0;l<v;l++){t=new WPTB_Cell(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),L.recalculateIndexes(),L.addColumnWidth(),WPTB_Helper.dataTitleColumnSet(L),E(),(new WPTB_TableStateSaveManager).tableStateSet()}},L.addRowToTheStart=function(){var e=L.insertRow(0),t=void 0,a=void 0,n=document.getElementsByClassName("wptb-preview-table");if(e.classList.add("wptb-row"),0<n.length){n=n[0];for(var l=0;l<v;l++){t=new WPTB_Cell(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),L.recalculateIndexes(),L.addColumnWidth(),WPTB_Helper.dataTitleColumnSet(L),E(),(new WPTB_TableStateSaveManager).tableStateSet()}},L.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=L.rows[l].children,o=r.length;if(0<o)for(var s=0;s<o;s++)if(1==r[s].rowSpan){a=l,n=!0;break}if(n)break}0===a?L.addRowToTheStart():L.addRowAfter(a,t)},L.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<L.rows.length-1){for(var o=0;o<=n;o++){var s=L.rows[o].children,i=s.length;if(0<i)for(var d=0;d<i;d++){n<s[d].rowSpan-1+o&&s[d].rowSpan++}}var p=L.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=L.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),L.recalculateIndexes(),L.addColumnWidth(),WPTB_Helper.dataTitleColumnSet(L),E(),(new WPTB_TableStateSaveManager).tableStateSet()},L.isSquare=function(e){for(var t,a,n=-1,l=-1,r=-1,o=-1,s=0,i=0;i<e.length;i++)for(var d=0;d<e[i].length;d++)1==e[i][d]&&((d<l||-1==l)&&(l=d),(i<n||-1==n)&&(n=i));for(i=e.length-1;-1<i;i--)for(d=e[i].length-1;-1<d;d--)1==e[i][d]&&(o<d&&(o=d),r<i&&(r=i));for(i=n;i<r;i++)for(d=l;d<o;d++)if(0==e[i][d]||null==e[i][d])return!1;for(i=0;i<e.length;i++)for(d=0;d<e[i].length;d++)1==e[i][d]&&s++;return(t=r-n+1)*(a=o-l+1)===s&&[t,a]},L.mergeCells=function(){for(var e=L.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 s=l[o].getElementsByClassName("wptb-ph-element");if(0<s.length)for(var i=s.length,d=0;d<i;d++)r.push(s[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,L.recalculateIndexes(),L.reconstraction();var c=n.style.width,m=n.dataset.wptbFixedWidth;c?L.addColumnWidth(parseFloat(c,10)):m?L.addColumnWidth():L.addColumnWidth(!1,!0);var b=n.style.height,u=n.dataset.wptbFixedHeight;b?L.addRowHeight(parseFloat(b,10)):u?L.addRowHeight():L.addRowHeight(!1,!0),WPTB_Helper.dataTitleColumnSet(L),E(),(new WPTB_TableStateSaveManager).tableStateSet()},L.splitCell=function(){var e=document.getElementsByClassName("wptb-highlighted")[0],t=e.rowSpan,a=e.colSpan,n=e.getAttribute("style"),l=C(e)[0],r=L.rows[l],o=e.dataset.xIndex;e.rowSpan=1;for(var s=e.colSpan=1;s<a;s++){var i=new WPTB_Cell(T);i.getDOMElement().setAttribute("style",n),i.getDOMElement().classList.add("wptb-highlighted"),e.nextSibling?r.insertBefore(i.getDOMElement(),e.nextSibling):r.appendChild(i.getDOMElement())}if(1<t)for(var d=1;d<t;d++){var p=void 0,c=L.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())}}L.recalculateIndexes(),L.reconstraction(),L.addColumnWidth(),L.addRowHeight(),WPTB_Helper.dataTitleColumnSet(L),E(),(new WPTB_TableStateSaveManager).tableStateSet()},L.findRowspannedCells=function(e){var t,a=[];if(actualPoints=function(e){for(var t=L.rows[e].getElementsByTagName("td"),a=0,n=0;n<t.length;n++)a+=t[n].colSpan;return a}(e),actualPoints===v)return[];t=v-actualPoints;for(var n=e-1;0<=n&&t;n--){var l=L.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},L.addLackingCells=function(){for(var e=[],t=0;t<L.rows.length;t++)e.push(0);for(t=0;t<L.rows.length;t++)for(var a=L.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<L.rows.length;t++){a=L.rows[t].getElementsByTagName("td");var r=0;for(n=0;n<a.length;n++)r+=a[n].colSpan;r+=e[t],difference=v-r;for(n=0;n<difference;n++){var o=new WPTB_Cell(T);L.rows[t].appendChild(o.getDOMElement())}}},L.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=L.rows[n].children,s=L.rows[n+1],i=void 0,d=void 0,p=[];if(null!=s){d=(i=s.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(i[u].dataset.xIndex)>Number(o[c].dataset.xIndex)){b=i[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]?s.insertBefore(p[w][0].getDOMElement(),p[w][1]):s.appendChild(p[w][0].getDOMElement())}var g=L.rows;if(0<g.length)for(var v=0;v<n;v++){var h=g[v].children;if(0<h.length)for(var f=0;f<h.length;f++)h[f].rowSpan-1>=n-v&&h[f].rowSpan--}if(l=Array.from(array[0]),array.pop(l),B(array),L.getElementsByTagName("tbody")[0].removeChild(L.rows[n]),0==L.rows.length){L.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 L.recalculateIndexes(),WPTB_Helper.dataTitleColumnSet(L)}E(),(new WPTB_TableStateSaveManager).tableStateSet()},L.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<L.rows.length;l++){var r=L.rows[l].children,o=r.length;if(0<o)for(var s=o-1;0<=s;s--){if(Number(r[s].dataset.xIndex)==Number(t)){1<r[s].colSpan?r[s].colSpan--:L.rows[l].removeChild(r[s]);break}if(Number(r[s].dataset.xIndex)<Number(t)&&Number(r[s].dataset.xIndex)+Number(r[s].colSpan-1)>=t){1<r[s].colSpan&&r[s].colSpan--;break}}}for(var i=0;i<L.rows.length;i++)null!=array[i]&&array[i].pop();if(v--,0==L.querySelectorAll("td").length){L.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 L.recalculateIndexes(),L.tdDefaultWidth(),WPTB_Helper.dataTitleColumnSet(L)}E(),(new WPTB_TableStateSaveManager).tableStateSet()},document.getElementsByClassName("wptb-table-generator")[0].style.display="none",array=function(){for(var e=[],t=[],a=0;a<L.rows.length;a++){for(var n=L.rows[a].getElementsByTagName("td"),l=0,r=0;r<n.length;r++)l+=n[r].colSpan;e.push(l)}v=Math.max.apply(null,e);var o=L.rows.length;for(a=0;a<o;a++)for(t[a]=[],r=0;r<v;r++)t[a].push(0);return B(t),t}(),E(),B(array),S.appendChild(L),L.recalculateIndexes(!0),L.reconstraction(),L.tdDefaultWidth(),S.onresize=function(){L.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 s=a.querySelectorAll(".mce-content-body");if(0<s.length)for(var i=0;i<s.length;i++)s[i].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 v=WPTB_Helper.elementsStylesConvertToObject();if(window.wptbTableStateSaving.push([a,b,g,v]),window.wptbTableStateNumberShow=window.wptbTableStateSaving.length-1,0<window.wptbTableStateSaving.length-1){var h=document.getElementsByClassName("wptb-undo");0<h.length&&(h=h[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 s=document.createElement("style");s.setAttribute("data-wptb-td-auto-width",!0),s.innerHTML=window.wptbTableStateSaving[window.wptbTableStateNumberShow][1],r.appendChild(s)}}}var i=document.getElementsByTagName("body");0<i.length&&(i=i[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"),i.appendChild(d)),d.innerHTML=window.wptbTableStateSaving[window.wptbTableStateNumberShow][2]):0<d.length&&(d=d[0],i.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 t=void 0,a=void 0;if(e.preventDefault(),e.stopPropagation(),e.dataTransfer.getData("wptbElement")||e.dataTransfer.getData("node")){var n=void 0,l=void 0;if(0<document.getElementsByClassName("wptb-drop-handle").length&&(n=document.getElementsByClassName("wptb-drop-handle")[0]),0<document.getElementsByClassName("wptb-drop-border-marker").length&&(l=document.getElementsByClassName("wptb-drop-border-marker")[0]),t=e.dataTransfer.getData("wptbElement")?(t=WPTB_Helper.newElementProxy(e.dataTransfer.getData("wptbElement"))).getDOMElement():(a=e.dataTransfer.getData("node"),document.getElementsByClassName(a)[0]),"block"==n.style.display){var r=void 0;if("Drop Here"==n.dataset.text)(r=n.getDOMParentElement()).appendChild(t);else{var o=n.getDOMParentElement();if(r=o.parentNode,"Above Element"==n.dataset.text)r.insertBefore(t,o);else if("Below Element"==n.dataset.text){var s=o.nextSibling;r.insertBefore(t,s)}}var i=r.parentNode;if(WPTB_Helper.rowIsTop(i)){var d=WPTB_Helper.findAncestor(i,"wptb-preview-table");d.classList.contains("wptb-table-preview-head")&&WPTB_Helper.dataTitleColumnSet(d)}t.className.match(/wptb-element-(.+)-(\d+)/i)[1];if(e.dataTransfer.getData("wptbElement"),n.style.display="none",l.style.display="none",p(t),!t.classList.contains("wptb-image-container")||t.classList.contains("wptb-moving-mode"))t.classList.remove("wptb-moving-mode"),(new WPTB_TableStateSaveManager).tableStateSet();return!0}}},t.onmouseover=function(e){t.classList.remove("wptb-ondragenter")}};_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,a=Array(e.length);t<e.length;t++)a[t]=e[t];return a}return Array.from(e)}var applyGenericItemSettings=function(e,t){var a,n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],l=e.getDOMElement();if(l.classList.contains("wptb-ph-element")){if(null==t||1==n){a=document.counter.nextIndex(e.kind);for(var r=document.getElementsByClassName("wptb-ph-element"),o=[],s=0;s<r.length;s++){var i=new RegExp("wptb-element-"+e.kind+"-(\\d+)","i"),d=r[s].className.match(i);d&&o.push(d[1])}if(0<o.length)a=Math.max.apply(Math,o)+1;else a=1;if(n)for(var p=[].concat(_toConsumableArray(l.attributes)),c=0;c<p.length;c++)if(p[c]&&"object"===_typeof(p[c])&&p[c].nodeName){var m=new RegExp("data-wptb-el-"+e.kind+"-(\\d+)-(.+)","i"),b=p[c].nodeName.match(m);if(b&&Array.isArray(b)){var u=p[c].nodeName.replace(e.kind+"-"+b[1],e.kind+"-"+a),w=p[c].nodeValue;l.removeAttribute(p[c].nodeName),l.setAttribute(u,w)}}}else if(t&&!n){var g=t.split("-");a=g[g.length-1]}var v=l.className.match(/wptb-element-(.+)-(\d+)/i);v&&l.classList.remove(v[0]),l.classList.contains("wptb-ph-element")||l.classList.add("wptb-ph-element"),l.classList.contains("wptb-element-"+e.kind+"-"+a)||l.classList.add("wptb-element-"+e.kind+"-"+a),new WPTB_ElementOptions(e,a,t),WPTB_Helper.elementStartScript(e.getDOMElement()),document.counter.increment(e.kind)}l.onmouseenter=function(e){if(!e.target.classList.contains("wptb-moving-mode")){var t=new WPTB_ActionsField;t.addActionField(1,l),t.setParameters(l),l.classList.remove("wptb-ondragenter")}},l.onmouseleave=function(e){(new WPTB_ActionsField).leaveFromField(e,l)}};
1
+ var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},WPTB_ActionsField=function 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 t=void 0,a=void 0;if(e.preventDefault(),e.stopPropagation(),e.dataTransfer.getData("wptbElement")||e.dataTransfer.getData("node")){var n=void 0,l=void 0;if(0<document.getElementsByClassName("wptb-drop-handle").length&&(n=document.getElementsByClassName("wptb-drop-handle")[0]),0<document.getElementsByClassName("wptb-drop-border-marker").length&&(l=document.getElementsByClassName("wptb-drop-border-marker")[0]),t=e.dataTransfer.getData("wptbElement")?(t=WPTB_Helper.newElementProxy(e.dataTransfer.getData("wptbElement"))).getDOMElement():(a=e.dataTransfer.getData("node"),document.getElementsByClassName(a)[0]),"block"==n.style.display){var r=void 0;if("Drop Here"==n.dataset.text)(r=n.getDOMParentElement()).appendChild(t);else{var o=n.getDOMParentElement();if(r=o.parentNode,"Above Element"==n.dataset.text)r.insertBefore(t,o);else if("Below Element"==n.dataset.text){var i=o.nextSibling;r.insertBefore(t,i)}}var s=r.parentNode;if(WPTB_Helper.rowIsTop(s)){var d=WPTB_Helper.findAncestor(s,"wptb-preview-table");d.classList.contains("wptb-table-preview-head")&&WPTB_Helper.dataTitleColumnSet(d)}t.className.match(/wptb-element-(.+)-(\d+)/i)[1];if(e.dataTransfer.getData("wptbElement"),n.style.display="none",l.style.display="none",p(t),!t.classList.contains("wptb-image-container")||t.classList.contains("wptb-moving-mode"))t.classList.remove("wptb-moving-mode"),(new WPTB_TableStateSaveManager).tableStateSet();return!0}}},t.onmouseover=function(e){t.classList.remove("wptb-ondragenter")}};_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};function _toConsumableArray(e){if(Array.isArray(e)){for(var t=0,a=Array(e.length);t<e.length;t++)a[t]=e[t];return a}return Array.from(e)}var applyGenericItemSettings=function(e,t){var a,n=2<arguments.length&&void 0!==arguments[2]&&arguments[2],l=e.getDOMElement();if(l.classList.contains("wptb-ph-element")){if(null==t||1==n){a=document.counter.nextIndex(e.kind);for(var r=document.getElementsByClassName("wptb-ph-element"),o=[],i=0;i<r.length;i++){var s=new RegExp("wptb-element-"+e.kind+"-(\\d+)","i"),d=r[i].className.match(s);d&&o.push(d[1])}if(0<o.length)a=Math.max.apply(Math,o)+1;else a=1;if(n)for(var p=[].concat(_toConsumableArray(l.attributes)),c=0;c<p.length;c++)if(p[c]&&"object"===_typeof(p[c])&&p[c].nodeName){var m=new RegExp("data-wptb-el-"+e.kind+"-(\\d+)-(.+)","i"),b=p[c].nodeName.match(m);if(b&&Array.isArray(b)){var u=p[c].nodeName.replace(e.kind+"-"+b[1],e.kind+"-"+a),w=p[c].nodeValue;l.removeAttribute(p[c].nodeName),l.setAttribute(u,w)}}}else if(t&&!n){var g=t.split("-");a=g[g.length-1]}var h=l.className.match(/wptb-element-(.+)-(\d+)/i);h&&l.classList.remove(h[0]),l.classList.contains("wptb-ph-element")||l.classList.add("wptb-ph-element"),l.classList.contains("wptb-element-"+e.kind+"-"+a)||l.classList.add("wptb-element-"+e.kind+"-"+a),new WPTB_ElementOptions(e,a,t),WPTB_Helper.elementStartScript(e.getDOMElement()),document.counter.increment(e.kind)}l.onmouseenter=function(e){if(!e.target.classList.contains("wptb-moving-mode")){var t=new WPTB_ActionsField;t.addActionField(1,l),t.setParameters(l),l.classList.remove("wptb-ondragenter")}},l.onmouseleave=function(e){(new WPTB_ActionsField).leaveFromField(e,l)}};
inc/admin/js/core/WPTB_ActionsField.js CHANGED
@@ -165,7 +165,6 @@ var WPTB_ActionsField = function() {
165
  }
166
  } else {
167
  this.style.display = 'none';
168
- console.log(this);
169
  }
170
 
171
  this.actionsHide();
165
  }
166
  } else {
167
  this.style.display = 'none';
 
168
  }
169
 
170
  this.actionsHide();
inc/admin/js/core/WPTB_Builder.js CHANGED
@@ -8,7 +8,7 @@
8
  http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
9
  http.onreadystatechange = function (d) {
10
  if (this.readyState == 4 && this.status == 200) {
11
- var ans = JSON.parse(http.responseText);
12
  document.getElementById('wptb-setup-name').value = ans[0];
13
 
14
  if( ans[1] ) {
@@ -35,6 +35,12 @@
35
  if( ! infArr ) {
36
  element.classList.add( 'wptb-element-main-table_setting-' + table_id );
37
  }
 
 
 
 
 
 
38
  }
39
 
40
  WPTB_LeftPanel();
8
  http.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
9
  http.onreadystatechange = function (d) {
10
  if (this.readyState == 4 && this.status == 200) {
11
+ var ans = JSON.parse( http.responseText );
12
  document.getElementById('wptb-setup-name').value = ans[0];
13
 
14
  if( ans[1] ) {
35
  if( ! infArr ) {
36
  element.classList.add( 'wptb-element-main-table_setting-' + table_id );
37
  }
38
+
39
+ if( element.dataset.wptbTableContainerMaxWidth ) {
40
+ wptbTableSetupEl.style.maxWidth = element.dataset.wptbTableContainerMaxWidth + 'px';
41
+
42
+ element.tdDefaultWidth();
43
+ }
44
  }
45
 
46
  WPTB_LeftPanel();
inc/admin/js/core/WPTB_Cell.js CHANGED
@@ -50,7 +50,6 @@ var WPTB_Cell = function ( callback, DOMElement ) {
50
  }
51
 
52
  DOMElement.classList.add('wptb-droppable', 'wptb-cell');
53
- console.log( 'wptb_cell_test' );
54
  }
55
 
56
  DOMElement.draggable = false;
50
  }
51
 
52
  DOMElement.classList.add('wptb-droppable', 'wptb-cell');
 
53
  }
54
 
55
  DOMElement.draggable = false;
inc/admin/js/core/WPTB_Helper.js CHANGED
@@ -408,7 +408,6 @@ var WPTB_Helper = {
408
  }
409
  if( containerStylesArrOne && Array.isArray( containerStylesArrOne ) ) {
410
  for( let i = 0; i < containerStylesArrOne.length; i++ ) {
411
- console.log( containerStylesArrOne );
412
  if( containerStylesArrOne[i] ) {
413
  containerStylesSet( containerStylesArrOne[i], containerElement );
414
  }
@@ -438,6 +437,7 @@ var WPTB_Helper = {
438
  let elementsSettings = elementsSettingsTemplateJs.innerHTML;
439
  let controlClassesNames = [];
440
  if( elementsSettings ) {
 
441
  elementsSettings = JSON.parse( elementsSettings );
442
  if( elementsSettings && typeof elementsSettings === 'object' ) {
443
  if( 'tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2] in elementsSettings ) {
@@ -551,6 +551,7 @@ var WPTB_Helper = {
551
 
552
  let elementsSettings = elementsSettingsTemplateJs.innerHTML;
553
  if( elementsSettings ) {
 
554
  elementsSettings = JSON.parse( elementsSettings );
555
  if( elementsSettings && typeof elementsSettings === 'object' &&
556
  ( 'tmpl-wptb-el-datas-' + dependOnControlElementKind ) in elementsSettings ) {
@@ -626,6 +627,7 @@ var WPTB_Helper = {
626
  elementsSettingsTemplatesJs = elementsSettingsTemplatesJs[0];
627
  elementsSettings = elementsSettingsTemplatesJs.innerHTML;
628
  if( elementsSettings ) {
 
629
  elementsSettings = JSON.parse( elementsSettings );
630
 
631
  if( elementsSettings && typeof elementsSettings === 'object' ) {
@@ -695,8 +697,10 @@ var WPTB_Helper = {
695
  } else {
696
  targetControlValue = 'unchecked';
697
  }
698
- } else {
699
  targetControlValue = targetControls[i].value;
 
 
700
  }
701
  }
702
  return targetControlValue;
@@ -716,6 +720,7 @@ var WPTB_Helper = {
716
 
717
  let elementsSettings = elementsSettingsTemplateJs.innerHTML;
718
  if( elementsSettings ) {
 
719
  elementsSettings = JSON.parse( elementsSettings );
720
 
721
  if( elementsSettings && typeof elementsSettings === 'object' ) {
@@ -751,6 +756,7 @@ var WPTB_Helper = {
751
  wptbElementDatas = wptbElementDatas[0];
752
  let elementsSettings = wptbElementDatas.innerHTML;
753
  if( elementsSettings ) {
 
754
  elementsSettings = JSON.parse( elementsSettings );
755
  if( elementsSettings && typeof elementsSettings === 'object' &&
756
  ( ( 'tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2] ) in elementsSettings ) ) {
@@ -868,8 +874,6 @@ var WPTB_Helper = {
868
  }
869
  }
870
 
871
- //console.log( controlTemplate );
872
-
873
  let wptbElementOptionContainer = document.createElement( 'div' );
874
  wptbElementOptionContainer.classList.add( wptbelementOptionClass, 'wptb-settings-items' );
875
 
@@ -1200,8 +1204,10 @@ var WPTB_Helper = {
1200
  messagingArea = document.getElementById( 'wptb-messaging-area' );
1201
 
1202
  if ( data[0] == 'saved' ) {
1203
- console.log(window.wptbTableStateSaving);
1204
- window.history.pushState( null, null, document.location.href.replace( '#', '' ) + '&table=' + data[1] );
 
 
1205
 
1206
  WPTB_Helper.saveTable( event, true );
1207
  return;
408
  }
409
  if( containerStylesArrOne && Array.isArray( containerStylesArrOne ) ) {
410
  for( let i = 0; i < containerStylesArrOne.length; i++ ) {
 
411
  if( containerStylesArrOne[i] ) {
412
  containerStylesSet( containerStylesArrOne[i], containerElement );
413
  }
437
  let elementsSettings = elementsSettingsTemplateJs.innerHTML;
438
  let controlClassesNames = [];
439
  if( elementsSettings ) {
440
+ elementsSettings = elementsSettings.trim();
441
  elementsSettings = JSON.parse( elementsSettings );
442
  if( elementsSettings && typeof elementsSettings === 'object' ) {
443
  if( 'tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2] in elementsSettings ) {
551
 
552
  let elementsSettings = elementsSettingsTemplateJs.innerHTML;
553
  if( elementsSettings ) {
554
+ elementsSettings = elementsSettings.trim();
555
  elementsSettings = JSON.parse( elementsSettings );
556
  if( elementsSettings && typeof elementsSettings === 'object' &&
557
  ( 'tmpl-wptb-el-datas-' + dependOnControlElementKind ) in elementsSettings ) {
627
  elementsSettingsTemplatesJs = elementsSettingsTemplatesJs[0];
628
  elementsSettings = elementsSettingsTemplatesJs.innerHTML;
629
  if( elementsSettings ) {
630
+ elementsSettings = elementsSettings.trim();
631
  elementsSettings = JSON.parse( elementsSettings );
632
 
633
  if( elementsSettings && typeof elementsSettings === 'object' ) {
697
  } else {
698
  targetControlValue = 'unchecked';
699
  }
700
+ } else if( targetControls[i].type ) {
701
  targetControlValue = targetControls[i].value;
702
+ } else if( targetControls[i].dataset.alignmentValue && targetControls[i].classList.contains( 'selected' ) ){
703
+ targetControlValue = targetControls[i].dataset.alignmentValue;
704
  }
705
  }
706
  return targetControlValue;
720
 
721
  let elementsSettings = elementsSettingsTemplateJs.innerHTML;
722
  if( elementsSettings ) {
723
+ elementsSettings = elementsSettings.trim();
724
  elementsSettings = JSON.parse( elementsSettings );
725
 
726
  if( elementsSettings && typeof elementsSettings === 'object' ) {
756
  wptbElementDatas = wptbElementDatas[0];
757
  let elementsSettings = wptbElementDatas.innerHTML;
758
  if( elementsSettings ) {
759
+ elementsSettings = elementsSettings.trim();
760
  elementsSettings = JSON.parse( elementsSettings );
761
  if( elementsSettings && typeof elementsSettings === 'object' &&
762
  ( ( 'tmpl-wptb-el-datas-' + infArr[1] + '-' + infArr[2] ) in elementsSettings ) ) {
874
  }
875
  }
876
 
 
 
877
  let wptbElementOptionContainer = document.createElement( 'div' );
878
  wptbElementOptionContainer.classList.add( wptbelementOptionClass, 'wptb-settings-items' );
879
 
1204
  messagingArea = document.getElementById( 'wptb-messaging-area' );
1205
 
1206
  if ( data[0] == 'saved' ) {
1207
+ let builderPageUrl = document.location.href.replace( '#', '' );
1208
+ let regex = new RegExp( '&table=(.+)', "i" );
1209
+ builderPageUrl = builderPageUrl.replace( regex, '' );
1210
+ window.history.pushState( null, null, builderPageUrl + '&table=' + data[1] );
1211
 
1212
  WPTB_Helper.saveTable( event, true );
1213
  return;
inc/admin/js/core/WPTB_LeftPanel.js CHANGED
@@ -107,8 +107,43 @@ var WPTB_LeftPanel = function () {
107
  } else if( inputs.makeTableResponsive == 'unchecked' ) {
108
  table.dataset.wptbAdaptiveTable = 0;
109
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
110
  } else if( inputs.hasOwnProperty( 'tableManageCells' ) ) {
111
  table.toggleTableEditMode();
 
 
112
  }
113
  }
114
  }
107
  } else if( inputs.makeTableResponsive == 'unchecked' ) {
108
  table.dataset.wptbAdaptiveTable = 0;
109
  }
110
+ } else if( inputs.hasOwnProperty( 'applyTableContainerMaxWidth' ) ) {
111
+ let wptbTableSetup = document.querySelector( '.wptb-table-setup' );
112
+ if( inputs.applyTableContainerMaxWidth == 'checked' ) {
113
+ let table_id = WPTB_Helper.detectMode();
114
+
115
+ if( ! table_id ) {
116
+ table_id = 'startedid-0';
117
+ }
118
+
119
+ let tableContainerMaxWidthInput = document.getElementsByClassName( 'wptb-el-main-table_setting-' + table_id + '-tableContainerMaxWidth' );
120
+ let tableContainerMaxWidthInputValue = 850;
121
+ if( tableContainerMaxWidthInput.length > 0 ) {
122
+ tableContainerMaxWidthInput = tableContainerMaxWidthInput[0];
123
+ if( tableContainerMaxWidthInput.value ) tableContainerMaxWidthInputValue = tableContainerMaxWidthInput.value;
124
+ }
125
+
126
+ table.dataset.wptbTableContainerMaxWidth = tableContainerMaxWidthInputValue;
127
+ if( wptbTableSetup ) wptbTableSetup.style.maxWidth = tableContainerMaxWidthInputValue + 'px';
128
+ } else if( inputs.applyTableContainerMaxWidth == 'unchecked' ) {
129
+ table.removeAttribute( 'data-wptb-table-container-max-width' );
130
+ if( wptbTableSetup ) wptbTableSetup.style.maxWidth = null;
131
+ }
132
+
133
+ table.tdDefaultWidth();
134
+ } else if( inputs.hasOwnProperty( 'tableContainerMaxWidth' ) ) {
135
+ if( inputs.tableContainerMaxWidth ) {
136
+ table.dataset.wptbTableContainerMaxWidth = inputs.tableContainerMaxWidth;
137
+
138
+ let wptbTableSetup = document.querySelector( '.wptb-table-setup' );
139
+ if( wptbTableSetup ) wptbTableSetup.style.maxWidth = inputs.tableContainerMaxWidth + 'px';
140
+
141
+ table.tdDefaultWidth();
142
+ }
143
  } else if( inputs.hasOwnProperty( 'tableManageCells' ) ) {
144
  table.toggleTableEditMode();
145
+ } else if( inputs.hasOwnProperty( 'tableAlignmentCheckbox' ) ) {
146
+ table.tdDefaultWidth();
147
  }
148
  }
149
  }
inc/admin/js/core/WPTB_Table.js CHANGED
@@ -774,6 +774,29 @@ var array = [], WPTB_Table = function (columns, rows) {
774
  head.appendChild( cssForTdsWidthAuto );
775
  }
776
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
777
  }
778
 
779
  table.addRowHeight = function( value, cleaner ) {
774
  head.appendChild( cssForTdsWidthAuto );
775
  }
776
  }
777
+
778
+ if( table.dataset.wptbTableAlignment ) {
779
+ let wptbTableAlignment = table.dataset.wptbTableAlignment;
780
+
781
+ let wptbTableSetupWidth = wptbTableSetup.offsetWidth;
782
+ if( wptbTableSetupWidth < table.offsetWidth ) {
783
+ table.style.float = null;
784
+ } else {
785
+ if( wptbTableAlignment == 'center' ) {
786
+ table.style.float = null;
787
+ } else {
788
+ table.style.float = wptbTableAlignment;
789
+ }
790
+ }
791
+
792
+ if( wptbTableAlignment == 'center' ) {
793
+ wptbTableSetup.style.float = null;
794
+ } else {
795
+ wptbTableSetup.style.float = wptbTableAlignment;
796
+ }
797
+ } else {
798
+ table.style.float = null;
799
+ }
800
  }
801
 
802
  table.addRowHeight = function( value, cleaner ) {
inc/admin/views/builder/table-settings-element.php CHANGED
@@ -77,6 +77,30 @@ class Table_Settings_Element extends Controls_Stack {
77
  ]
78
  );
79
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
  $this->add_control(
81
  'tableBorder',
82
  [
@@ -153,7 +177,7 @@ class Table_Settings_Element extends Controls_Stack {
153
  'type' => Controls_Manager::ALIGNMENT,
154
  'selected' => 1,
155
  'selectors' => [
156
- '{{{data.container}}}' => 'float',
157
  ]
158
  ]
159
  );
77
  ]
78
  );
79
 
80
+ $this->add_control(
81
+ 'applyTableContainerMaxWidth',
82
+ [
83
+ 'label' => __( 'Table Container Max Width', 'wp_table_builder' ),
84
+ 'type' => Controls_Manager::TOGGLE
85
+ ]
86
+ );
87
+
88
+ $this->add_control(
89
+ 'tableContainerMaxWidth',
90
+ [
91
+ 'label' => __( 'Table Container Max Width', 'wp_table_builder' ),
92
+ 'type' => Controls_Manager::SIZE,
93
+ 'selectors' => [
94
+ '{{{data.container}}}' => ['data-wptb-table-container-max-width']
95
+ ],
96
+ 'min' => 100,
97
+ 'max' => 5000,
98
+ 'defaultValue' => 850,
99
+ 'dimension' => 'px',
100
+ 'appearDependOnControl' => ['applyTableContainerMaxWidth', ['checked'], ['unchecked']]
101
+ ]
102
+ );
103
+
104
  $this->add_control(
105
  'tableBorder',
106
  [
177
  'type' => Controls_Manager::ALIGNMENT,
178
  'selected' => 1,
179
  'selectors' => [
180
+ '{{{data.container}}}' => 'data-wptb-table-alignment',
181
  ]
182
  ]
183
  );
inc/core/class-preview.php CHANGED
@@ -223,7 +223,7 @@ class Preview {
223
  */
224
  public function the_content() {
225
 
226
- $content = esc_html__( 'This is a preview of your table. This page is not publicly accessible.', 'wp-table-builder' );
227
 
228
  do_action( 'wptb_frontend_enqueue_style' );
229
  do_action( 'wptb_frontend_enqueue_script' );
@@ -231,48 +231,31 @@ class Preview {
231
  // Check nonce
232
  $nonce = sanitize_text_field( $_GET['_wpnonce'] );
233
  if( $nonce && wp_verify_nonce( $nonce, 'wptb_nonce_table' ) ) {
234
- $content .= get_post_meta( absint( $this->table_data->ID ) , '_wptb_content_', true );
235
  } else if( $nonce && wp_verify_nonce( $nonce, 'wptb_nonce_table_preview' ) ) {
236
- $content .= get_post_meta( absint( $this->table_data->ID ) , '_wptb_content_preview_', true );
237
  }
238
 
239
- // prepating html encoding for looking for shortcodes using DOMDocument
240
- $html_encoding = mb_detect_encoding( $content );
241
- if( $html_encoding != 'UTF-8' ) {
242
- $content = mb_convert_encoding( $content, "UTF-8", $html_encoding );
243
- }
244
-
245
- $content = mb_convert_encoding( $content, 'HTML-ENTITIES', 'utf-8' );
246
-
247
- $dom = new \DOMDocument( '1.0', 'UTF-8' );
248
- $dom->validateOnParse = true;
249
- $dom->encoding="UTF-8";
250
- $dom->loadHTML( $content );
251
- $divs = $dom->getElementsByTagName( 'div' );
252
- $shortcodes = array();
253
- foreach ( $divs as $div ) {
254
- $classes = $div->getAttribute( 'class' );
255
- if ( strpos( $classes, 'wptb-shortcode-container' ) !== false ) {
256
- $div_outer_html = trim( $div->ownerDocument->saveHTML( $div ) );
257
-
258
- if( ! isset( $args['internal_shortcodes_stop'] ) && $div_outer_html ) {
259
  $pattern = get_shortcode_regex();
260
 
261
- if ( preg_match_all( '/'. $pattern .'/s', $div_outer_html, $matches ) ) {
262
 
263
  for( $i = 0; $i < count( $matches[0] ); $i++ ) {
264
  $shortcode = $matches[0][$i];
265
- if( $matches[2][$i] == 'wptb' ) {
266
 
267
  $shortcode = str_replace( ']' , ' internal_shortcodes_stop="1"]' , $matches[0][$i] );
268
 
269
- $div_outer_html_new = str_replace( $matches[0][$i] , $shortcode , $div_outer_html );
270
 
271
- $content = str_replace( $div_outer_html, $div_outer_html_new, $content );
272
 
273
- $content = str_replace( $div_outer_html_new, do_shortcode( $div_outer_html_new ), $content );
274
  } else {
275
- $content = str_replace( $div_outer_html, do_shortcode( $div_outer_html ), $content );
276
  }
277
  }
278
  }
@@ -281,20 +264,27 @@ class Preview {
281
  }
282
 
283
  //$content = do_shortcode( $content );
284
- $content = '<div class="wptb-table-container wptb-table-' . absint( $this->table_data->ID ) . '">'
285
- . '<div class="wptb-table-container-matrix">' . $content . '</div>'
 
286
  . '</div>';
287
- $content .= '<script>'
288
  . 'var wptbContainer = document.getElementsByClassName( "wptb-table-' . absint( $this->table_data->ID ) . '" );'
289
  . 'if( wptbContainer.length > 0 ) {'
290
  . ' wptbContainer = wptbContainer[0];'
291
  . ' var wptbPreviewTable = wptbContainer.getElementsByClassName( "wptb-preview-table" );'
292
- . ' wptbPreviewTable[0].classList.remove( "wptb-table-preview-static-indic" );'
293
- . ' wptbPreviewTable[0].style.display = "none";'
 
 
 
 
 
 
294
  . '}'
295
  . '</script>';
296
 
297
- return $content;
298
 
299
  }
300
 
223
  */
224
  public function the_content() {
225
 
226
+ $message = esc_html__( 'This is a preview of your table. This page is not publicly accessible.', 'wp-table-builder' );
227
 
228
  do_action( 'wptb_frontend_enqueue_style' );
229
  do_action( 'wptb_frontend_enqueue_script' );
231
  // Check nonce
232
  $nonce = sanitize_text_field( $_GET['_wpnonce'] );
233
  if( $nonce && wp_verify_nonce( $nonce, 'wptb_nonce_table' ) ) {
234
+ $html .= get_post_meta( absint( $this->table_data->ID ) , '_wptb_content_', true );
235
  } else if( $nonce && wp_verify_nonce( $nonce, 'wptb_nonce_table_preview' ) ) {
236
+ $html .= get_post_meta( absint( $this->table_data->ID ) , '_wptb_content_preview_', true );
237
  }
238
 
239
+ if ( preg_match_all( '|<wptb_shortcode_container_element>(.+)</wptb_shortcode_container_element>|isU', $html, $arr ) ) {
240
+ foreach ( $arr[1] as $value ) {
241
+ if( ! isset( $args['internal_shortcodes_stop'] ) && $value ) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
242
  $pattern = get_shortcode_regex();
243
 
244
+ if ( preg_match_all( '/'. $pattern .'/s', $value, $matches ) ) {
245
 
246
  for( $i = 0; $i < count( $matches[0] ); $i++ ) {
247
  $shortcode = $matches[0][$i];
248
+ if( isset( $matches[2][$i] ) && $matches[2][$i] == 'wptb' ) {
249
 
250
  $shortcode = str_replace( ']' , ' internal_shortcodes_stop="1"]' , $matches[0][$i] );
251
 
252
+ $div_outer_html_new = str_replace( $matches[0][$i] , $shortcode , $value );
253
 
254
+ $html = str_replace( $value, $div_outer_html_new, $html );
255
 
256
+ $html = str_replace( $div_outer_html_new, do_shortcode( $div_outer_html_new ), $html );
257
  } else {
258
+ $html = str_replace( $value, do_shortcode( $value ), $html );
259
  }
260
  }
261
  }
264
  }
265
 
266
  //$content = do_shortcode( $content );
267
+ $html = '<div class="wptb-table-container wptb-table-' . absint( $this->table_data->ID ) . '">'
268
+ . '<div style="text-align:center;">' . $message . '</div>'
269
+ . '<div class="wptb-table-container-matrix">' . $html . '</div>'
270
  . '</div>';
271
+ $html .= '<script>'
272
  . 'var wptbContainer = document.getElementsByClassName( "wptb-table-' . absint( $this->table_data->ID ) . '" );'
273
  . 'if( wptbContainer.length > 0 ) {'
274
  . ' wptbContainer = wptbContainer[0];'
275
  . ' var wptbPreviewTable = wptbContainer.getElementsByClassName( "wptb-preview-table" );'
276
+ . ' if( wptbPreviewTable.length > 0 ) {'
277
+ . ' wptbPreviewTable = wptbPreviewTable[0];'
278
+ . ' if( wptbPreviewTable.dataset.wptbTableContainerMaxWidth ) {'
279
+ . ' wptbContainer.style.maxWidth = wptbPreviewTable.dataset.wptbTableContainerMaxWidth + "px";'
280
+ . ' }'
281
+ . ' wptbPreviewTable.classList.remove( "wptb-table-preview-static-indic" );'
282
+ . ' wptbPreviewTable.style.display = "none";'
283
+ . ' }'
284
  . '}'
285
  . '</script>';
286
 
287
+ return $html;
288
 
289
  }
290
 
inc/frontend/css/wp-table-builder-frontend.css CHANGED
@@ -9,8 +9,16 @@
9
  overflow: auto;
10
  position: relative;
11
  width: 100%;
12
- min-width: 100%;
13
- margin: 30px 0;
 
 
 
 
 
 
 
 
14
  }
15
 
16
  .wptb-table-container table {
9
  overflow: auto;
10
  position: relative;
11
  width: 100%;
12
+ /*min-width: 100%;*/
13
+ margin: 30px auto;
14
+ }
15
+
16
+ .wptb-table-container-matrix {
17
+ margin: auto;
18
+ }
19
+
20
+ .wptb-frontend-table-edit-link {
21
+ clear: both;
22
  }
23
 
24
  .wptb-table-container table {
inc/frontend/js/wp-table-builder-frontend.js CHANGED
@@ -158,6 +158,28 @@ jQuery( document ).ready( function ( $ ) {
158
  previewTable = previewTable[0];
159
  tableContainerMatrix = tableContainerMatrix[0];
160
  previewTable.style.display = 'table';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
161
 
162
  // check data parametrs reconstraction and wptbAdaptiveTable if they are both equal 1 then continue
163
  if( previewTable.dataset.reconstraction == 1 && previewTable.dataset.wptbAdaptiveTable == 1 ) {
@@ -220,7 +242,6 @@ jQuery( document ).ready( function ( $ ) {
220
 
221
  // add css class for new mobile table
222
  newTable.classList.add( 'wptb-preview-table-mobile' );
223
- newTable.classList.add( 'wptb-preview-table-mobile' );
224
  let infArr = previewTable.className.match( /wptb-element-main(.+)-(\d+)/i );
225
  if( infArr && Array.isArray( infArr ) ) {
226
  newTable.classList.add( infArr[0] );
@@ -452,7 +473,7 @@ jQuery( document ).ready( function ( $ ) {
452
 
453
  function wptb_tdDefaultWidth() {
454
  let wptbTableContainers = document.getElementsByClassName( 'wptb-table-container' );
455
- let frontendEditLink = document.querySelectorAll( '.wptb-frontend-table-edit-link' );
456
  for( let i = 0; i < wptbTableContainers.length; i++ ) {
457
  let wptbTableContainer = wptbTableContainers[i];
458
 
@@ -487,10 +508,10 @@ jQuery( document ).ready( function ( $ ) {
487
  if( wptbTableTdsSumMaxWidth < wptbTableContainerWidth ) {
488
  if( wptbCellsWidthAutoCount ) {
489
  table.style.minWidth = '100%';
490
-
491
- if( frontendEditLink && frontendEditLink[i] ) {
492
- frontendEditLink[i].style.minWidth = wptbTableTdsSumMaxWidth + 'px';
493
- }
494
 
495
  if( table.mergingСellsHorizontally ) {
496
  table.style.width = null;
@@ -501,21 +522,21 @@ jQuery( document ).ready( function ( $ ) {
501
  } else {
502
  table.style.width = '100%';
503
 
504
- if( frontendEditLink && frontendEditLink[i] ) {
505
- frontendEditLink[i].style.width = '100%';
506
- frontendEditLink[i].style.maxWidth = '100%';
507
- }
508
  }
509
  } else {
510
  table.style.width = null;
511
  table.style.minWidth = null;
512
  table.style.maxWidth = wptbTableTdsSumMaxWidth + 'px';
513
-
514
- if( frontendEditLink && frontendEditLink[i] ) {
515
- frontendEditLink[i].style.width = null;
516
- frontendEditLink[i].style.minWidth = null;
517
- frontendEditLink[i].style.maxWidth = wptbTableTdsSumMaxWidth + 'px';
518
- }
519
  }
520
  } else {
521
  table.style.maxWidth = null;
@@ -524,11 +545,11 @@ jQuery( document ).ready( function ( $ ) {
524
  tableTdWidthAuto = '100';
525
  styleElementCreate = true;
526
 
527
- if( frontendEditLink && frontendEditLink[i] ) {
528
- frontendEditLink[i].style.maxWidth = '100%';
529
- frontendEditLink[i].style.minWidth = table.dataset.wptbTableTdsSumMaxWidth + 'px';
530
- frontendEditLink[i].style.width = null;
531
- }
532
  }
533
 
534
  let head = document.head;
158
  previewTable = previewTable[0];
159
  tableContainerMatrix = tableContainerMatrix[0];
160
  previewTable.style.display = 'table';
161
+
162
+
163
+ if( previewTable.dataset.wptbTableAlignment ) {
164
+ let wptbTableAlignment = previewTable.dataset.wptbTableAlignment;
165
+
166
+ let wptbTableContainerWidth = tableContainer.offsetWidth;
167
+ if( wptbTableContainerWidth < previewTable.offsetWidth ) {
168
+ previewTable.style.float = null;
169
+ } else {
170
+ if( wptbTableAlignment == 'center' ) {
171
+ previewTable.style.float = null;
172
+ } else {
173
+ previewTable.style.float = wptbTableAlignment;
174
+ }
175
+ }
176
+
177
+ if( wptbTableAlignment == 'center' ) {
178
+ tableContainer.style.float = null;
179
+ } else {
180
+ tableContainer.style.float = wptbTableAlignment;
181
+ }
182
+ }
183
 
184
  // check data parametrs reconstraction and wptbAdaptiveTable if they are both equal 1 then continue
185
  if( previewTable.dataset.reconstraction == 1 && previewTable.dataset.wptbAdaptiveTable == 1 ) {
242
 
243
  // add css class for new mobile table
244
  newTable.classList.add( 'wptb-preview-table-mobile' );
 
245
  let infArr = previewTable.className.match( /wptb-element-main(.+)-(\d+)/i );
246
  if( infArr && Array.isArray( infArr ) ) {
247
  newTable.classList.add( infArr[0] );
473
 
474
  function wptb_tdDefaultWidth() {
475
  let wptbTableContainers = document.getElementsByClassName( 'wptb-table-container' );
476
+ //let frontendEditLink = document.querySelectorAll( '.wptb-frontend-table-edit-link' );
477
  for( let i = 0; i < wptbTableContainers.length; i++ ) {
478
  let wptbTableContainer = wptbTableContainers[i];
479
 
508
  if( wptbTableTdsSumMaxWidth < wptbTableContainerWidth ) {
509
  if( wptbCellsWidthAutoCount ) {
510
  table.style.minWidth = '100%';
511
+
512
+ // if( frontendEditLink && frontendEditLink[i] ) {
513
+ // frontendEditLink[i].style.minWidth = wptbTableTdsSumMaxWidth + 'px';
514
+ // }
515
 
516
  if( table.mergingСellsHorizontally ) {
517
  table.style.width = null;
522
  } else {
523
  table.style.width = '100%';
524
 
525
+ // if( frontendEditLink && frontendEditLink[i] ) {
526
+ // frontendEditLink[i].style.width = '100%';
527
+ // frontendEditLink[i].style.maxWidth = '100%';
528
+ // }
529
  }
530
  } else {
531
  table.style.width = null;
532
  table.style.minWidth = null;
533
  table.style.maxWidth = wptbTableTdsSumMaxWidth + 'px';
534
+
535
+ // if( frontendEditLink && frontendEditLink[i] ) {
536
+ // frontendEditLink[i].style.width = null;
537
+ // frontendEditLink[i].style.minWidth = null;
538
+ // frontendEditLink[i].style.maxWidth = wptbTableTdsSumMaxWidth + 'px';
539
+ // }
540
  }
541
  } else {
542
  table.style.maxWidth = null;
545
  tableTdWidthAuto = '100';
546
  styleElementCreate = true;
547
 
548
+ // if( frontendEditLink && frontendEditLink[i] ) {
549
+ // frontendEditLink[i].style.maxWidth = '100%';
550
+ // frontendEditLink[i].style.minWidth = table.dataset.wptbTableTdsSumMaxWidth + 'px';
551
+ // frontendEditLink[i].style.width = null;
552
+ // }
553
  }
554
 
555
  let head = document.head;
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: wptb, imtiazrayhan, istiakrayhan, ultimateblocks, wpcdplugin, wple
3
  Tags: table, table builder, drag and drop
4
  Requires at least: 4.9
5
  Tested up to: 5.3
6
- Stable tag: 1.1.3
7
  Requires PHP: 5.6
8
  License: GPL3+
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.txt
@@ -73,16 +73,25 @@ That's it. You're done!
73
 
74
  == Changelog ==
75
 
 
 
 
 
 
 
 
 
 
76
  = 1.1.3 =
77
 
78
- ADD: Custom HTML Element.
79
- ADD: Shortcode Element.
80
- ADD: Double Click On Cell to Add Text Element.
81
- ADD: Option to Change/Replace Image in Image Element.
82
- ADD: Option to Change Button Text Size.
83
- ADD: Frontend Link to Edit Table When Logged in.
84
- FIX: Image Height Issue / Image getting stretched.
85
- FIX: Bug in Cell Width Change function.
86
 
87
  = 1.1.2 =
88
 
3
  Tags: table, table builder, drag and drop
4
  Requires at least: 4.9
5
  Tested up to: 5.3
6
+ Stable tag: 1.1.4
7
  Requires PHP: 5.6
8
  License: GPL3+
9
  License URI: http://www.gnu.org/licenses/gpl-3.0.txt
73
 
74
  == Changelog ==
75
 
76
+ = 1.1.4 =
77
+
78
+ * ADD: Option to set max width for table container.
79
+ * FIX: Table Alignment setting issue.
80
+ * FIX: PHP errors.
81
+ * FIX: Table editing issue.
82
+ * FIX: Table Settings not showing issue.
83
+ * FIX: Table duplicaton issue.
84
+
85
  = 1.1.3 =
86
 
87
+ * ADD: Custom HTML Element
88
+ * ADD: Shortcode Element
89
+ * ADD: Double Click On Cell to Add Text Element.
90
+ * ADD: Option to Change/Replace Image in Image Element.
91
+ * ADD: Option to Change Button Text Size.
92
+ * ADD: Frontend Link to Edit Table When Logged in.
93
+ * FIX: Image Height Issue / Image getting stretched.
94
+ * FIX: Bug in Cell Width Change function.
95
 
96
  = 1.1.2 =
97
 
wp-table-builder.php CHANGED
@@ -15,7 +15,7 @@
15
  * Plugin Name: WP Table Builder
16
  * Plugin URI: https://wptablebuilder.com/
17
  * Description: Drag and Drop Responsive Table Builder Plugin for WordPress.
18
- * Version: 1.1.3
19
  * Author: WP Table Builder
20
  * Author URI: https://wptablebuilder.com//
21
  * License: GPL-3.0+
@@ -39,7 +39,7 @@ define( __NAMESPACE__ . '\NS', __NAMESPACE__ . '\\' );
39
 
40
  define( NS . 'WP_TABLE_BUILDER', 'wp-table-builder' );
41
 
42
- define( NS . 'PLUGIN_VERSION', '1.1.3' );
43
 
44
  define( NS . 'WP_TABLE_BUILDER_DIR', plugin_dir_path( __FILE__ ) );
45
 
15
  * Plugin Name: WP Table Builder
16
  * Plugin URI: https://wptablebuilder.com/
17
  * Description: Drag and Drop Responsive Table Builder Plugin for WordPress.
18
+ * Version: 1.1.4
19
  * Author: WP Table Builder
20
  * Author URI: https://wptablebuilder.com//
21
  * License: GPL-3.0+
39
 
40
  define( NS . 'WP_TABLE_BUILDER', 'wp-table-builder' );
41
 
42
+ define( NS . 'PLUGIN_VERSION', '1.1.4' );
43
 
44
  define( NS . 'WP_TABLE_BUILDER_DIR', plugin_dir_path( __FILE__ ) );
45